Commit 9d8acd40 authored by wanghao's avatar wanghao

1 托盘信息 预计老化结束时间 由之前的根据配置实时读取,改成单独存取,因为之前确认的是每次上料都是上同一类型的板子,老化时间是一样的,现在改成了可以随意老化不同类型的板子,所以时间显示不一样了。

parent 914df7d6
...@@ -74,3 +74,6 @@ WHERE ...@@ -74,3 +74,6 @@ WHERE
) OR ) OR
JOB_NAME LIKE 'COMM_%' OR -- 确保清理所有旧的通信任务 JOB_NAME LIKE 'COMM_%' OR -- 确保清理所有旧的通信任务
JOB_NAME LIKE 'FINAL_%'; -- 确保清理所有旧的最终任务 JOB_NAME LIKE 'FINAL_%'; -- 确保清理所有旧的最终任务
ALTER TABLE `t_storey_info`
ADD COLUMN `f_estimated_end_time` datetime DEFAULT NULL COMMENT '预计老化结束时间';
...@@ -12,7 +12,7 @@ import com.zehong.common.core.domain.BaseEntity; ...@@ -12,7 +12,7 @@ import com.zehong.common.core.domain.BaseEntity;
/** /**
* 老化层信息对象 t_storey_info * 老化层信息对象 t_storey_info
* *
* @author zehong * @author zehong
* @date 2025-05-29 * @date 2025-05-29
*/ */
...@@ -91,6 +91,11 @@ public class TStoreyInfo extends BaseEntity ...@@ -91,6 +91,11 @@ public class TStoreyInfo extends BaseEntity
@Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date fAlarmTime; private Date fAlarmTime;
/** 预计结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "预计结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date estimatedEndTime;
/** 投料指令 */ /** 投料指令 */
private String feedingCommand; private String feedingCommand;
...@@ -110,44 +115,44 @@ public class TStoreyInfo extends BaseEntity ...@@ -110,44 +115,44 @@ public class TStoreyInfo extends BaseEntity
this.fStoreyId = fStoreyId; this.fStoreyId = fStoreyId;
} }
public Long getfStoreyId() public Long getfStoreyId()
{ {
return fStoreyId; return fStoreyId;
} }
public void setfEquipmentId(Long fEquipmentId) public void setfEquipmentId(Long fEquipmentId)
{ {
this.fEquipmentId = fEquipmentId; this.fEquipmentId = fEquipmentId;
} }
public Long getfEquipmentId() public Long getfEquipmentId()
{ {
return fEquipmentId; return fEquipmentId;
} }
public void setfStoreyCode(String fStoreyCode) public void setfStoreyCode(String fStoreyCode)
{ {
this.fStoreyCode = fStoreyCode; this.fStoreyCode = fStoreyCode;
} }
public String getfStoreyCode() public String getfStoreyCode()
{ {
return fStoreyCode; return fStoreyCode;
} }
public void setfIp(String fIp) public void setfIp(String fIp)
{ {
this.fIp = fIp; this.fIp = fIp;
} }
public String getfIp() public String getfIp()
{ {
return fIp; return fIp;
} }
public void setfStatus(String fStatus) public void setfStatus(String fStatus)
{ {
this.fStatus = fStatus; this.fStatus = fStatus;
} }
public String getfStatus() public String getfStatus()
{ {
return fStatus; return fStatus;
} }
...@@ -183,25 +188,25 @@ public class TStoreyInfo extends BaseEntity ...@@ -183,25 +188,25 @@ public class TStoreyInfo extends BaseEntity
this.fUpdateTime = fUpdateTime; this.fUpdateTime = fUpdateTime;
} }
public Date getfUpdateTime() public Date getfUpdateTime()
{ {
return fUpdateTime; return fUpdateTime;
} }
public void setfCreateTime(Date fCreateTime) public void setfCreateTime(Date fCreateTime)
{ {
this.fCreateTime = fCreateTime; this.fCreateTime = fCreateTime;
} }
public Date getfCreateTime() public Date getfCreateTime()
{ {
return fCreateTime; return fCreateTime;
} }
public void setfAlarmTime(Date fAlarmTime) public void setfAlarmTime(Date fAlarmTime)
{ {
this.fAlarmTime = fAlarmTime; this.fAlarmTime = fAlarmTime;
} }
public Date getfAlarmTime() public Date getfAlarmTime()
{ {
return fAlarmTime; return fAlarmTime;
} }
...@@ -238,6 +243,14 @@ public class TStoreyInfo extends BaseEntity ...@@ -238,6 +243,14 @@ public class TStoreyInfo extends BaseEntity
this.fAgingEndTime = fAgingEndTime; this.fAgingEndTime = fAgingEndTime;
} }
public Date getEstimatedEndTime() {
return estimatedEndTime;
}
public void setEstimatedEndTime(Date estimatedEndTime) {
this.estimatedEndTime = estimatedEndTime;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
...@@ -251,6 +264,7 @@ public class TStoreyInfo extends BaseEntity ...@@ -251,6 +264,7 @@ public class TStoreyInfo extends BaseEntity
.append("fUpdateTime", getfUpdateTime()) .append("fUpdateTime", getfUpdateTime())
.append("fCreateTime", getfCreateTime()) .append("fCreateTime", getfCreateTime())
.append("fAlarmTime", getfAlarmTime()) .append("fAlarmTime", getfAlarmTime())
.append("estimatedEndTime", getEstimatedEndTime())
.toString(); .toString();
} }
} }
...@@ -9,7 +9,7 @@ import com.zehong.common.core.domain.BaseEntity; ...@@ -9,7 +9,7 @@ import com.zehong.common.core.domain.BaseEntity;
/** /**
* 托盘信息对象 t_tray_info * 托盘信息对象 t_tray_info
* *
* @author zehong * @author zehong
* @date 2025-06-06 * @date 2025-06-06
*/ */
...@@ -54,66 +54,72 @@ public class TTrayInfo extends BaseEntity ...@@ -54,66 +54,72 @@ public class TTrayInfo extends BaseEntity
@Excel(name = "老化开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "老化开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date fAgingStartTime; private Date fAgingStartTime;
public void setfTrayId(Long fTrayId) /** 预计结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "预计结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date estimatedEndTime;
public void setfTrayId(Long fTrayId)
{ {
this.fTrayId = fTrayId; this.fTrayId = fTrayId;
} }
public Long getfTrayId() public Long getfTrayId()
{ {
return fTrayId; return fTrayId;
} }
public void setfTrayCode(String fTrayCode) public void setfTrayCode(String fTrayCode)
{ {
this.fTrayCode = fTrayCode; this.fTrayCode = fTrayCode;
} }
public String getfTrayCode() public String getfTrayCode()
{ {
return fTrayCode; return fTrayCode;
} }
public void setfStoreyCode(String fStoreyCode) public void setfStoreyCode(String fStoreyCode)
{ {
this.fStoreyCode = fStoreyCode; this.fStoreyCode = fStoreyCode;
} }
public String getfStoreyCode() public String getfStoreyCode()
{ {
return fStoreyCode; return fStoreyCode;
} }
public void setfStatus(String fStatus) public void setfStatus(String fStatus)
{ {
this.fStatus = fStatus; this.fStatus = fStatus;
} }
public String getfStatus() public String getfStatus()
{ {
return fStatus; return fStatus;
} }
public void setfBindingTime(Date fBindingTime) public void setfBindingTime(Date fBindingTime)
{ {
this.fBindingTime = fBindingTime; this.fBindingTime = fBindingTime;
} }
public Date getfBindingTime() public Date getfBindingTime()
{ {
return fBindingTime; return fBindingTime;
} }
public void setfUnbindingTime(Date fUnbindingTime) public void setfUnbindingTime(Date fUnbindingTime)
{ {
this.fUnbindingTime = fUnbindingTime; this.fUnbindingTime = fUnbindingTime;
} }
public Date getfUnbindingTime() public Date getfUnbindingTime()
{ {
return fUnbindingTime; return fUnbindingTime;
} }
public void setfCreateTime(Date fCreateTime) public void setfCreateTime(Date fCreateTime)
{ {
this.fCreateTime = fCreateTime; this.fCreateTime = fCreateTime;
} }
public Date getfCreateTime() public Date getfCreateTime()
{ {
return fCreateTime; return fCreateTime;
} }
...@@ -134,6 +140,14 @@ public class TTrayInfo extends BaseEntity ...@@ -134,6 +140,14 @@ public class TTrayInfo extends BaseEntity
this.fAgingStartTime = fAgingStartTime; this.fAgingStartTime = fAgingStartTime;
} }
public Date getEstimatedEndTime() {
return estimatedEndTime;
}
public void setEstimatedEndTime(Date estimatedEndTime) {
this.estimatedEndTime = estimatedEndTime;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
...@@ -145,6 +159,7 @@ public class TTrayInfo extends BaseEntity ...@@ -145,6 +159,7 @@ public class TTrayInfo extends BaseEntity
.append("fUnbindingTime", getfUnbindingTime()) .append("fUnbindingTime", getfUnbindingTime())
.append("fCreateTime", getfCreateTime()) .append("fCreateTime", getfCreateTime())
.append("fAgingStartTime", getfAgingStartTime()) .append("fAgingStartTime", getfAgingStartTime())
.append("estimatedEndTime", getEstimatedEndTime())
.toString(); .toString();
} }
} }
...@@ -6,15 +6,15 @@ import org.apache.ibatis.annotations.Param; ...@@ -6,15 +6,15 @@ import org.apache.ibatis.annotations.Param;
/** /**
* 老化层信息Mapper接口 * 老化层信息Mapper接口
* *
* @author zehong * @author zehong
* @date 2025-05-28 * @date 2025-05-28
*/ */
public interface TStoreyInfoMapper public interface TStoreyInfoMapper
{ {
/** /**
* 查询老化层信息 * 查询老化层信息
* *
* @param fStoreyId 老化层信息ID * @param fStoreyId 老化层信息ID
* @return 老化层信息 * @return 老化层信息
*/ */
...@@ -38,7 +38,7 @@ public interface TStoreyInfoMapper ...@@ -38,7 +38,7 @@ public interface TStoreyInfoMapper
public TStoreyInfo selectNearestFreeStorey(); public TStoreyInfo selectNearestFreeStorey();
/** /**
* 查询老化层信息列表 * 查询老化层信息列表
* *
* @param tStoreyInfo 老化层信息 * @param tStoreyInfo 老化层信息
* @return 老化层信息集合 * @return 老化层信息集合
*/ */
...@@ -50,7 +50,7 @@ public interface TStoreyInfoMapper ...@@ -50,7 +50,7 @@ public interface TStoreyInfoMapper
/** /**
* 新增老化层信息 * 新增老化层信息
* *
* @param tStoreyInfo 老化层信息 * @param tStoreyInfo 老化层信息
* @return 结果 * @return 结果
*/ */
...@@ -60,19 +60,21 @@ public interface TStoreyInfoMapper ...@@ -60,19 +60,21 @@ public interface TStoreyInfoMapper
/** /**
* 修改老化层信息 * 修改老化层信息
* *
* @param tStoreyInfo 老化层信息 * @param tStoreyInfo 老化层信息
* @return 结果 * @return 结果
*/ */
public int updateTStoreyInfo(TStoreyInfo tStoreyInfo); public int updateTStoreyInfo(TStoreyInfo tStoreyInfo);
public int setStartRunningByCode(TStoreyInfo tStoreyInfo);
public int updateAllStatusAndAgingStartTime(TStoreyInfo tStoreyInfo); public int updateAllStatusAndAgingStartTime(TStoreyInfo tStoreyInfo);
public int updateBatch(@Param("storeyInfos") List<TStoreyInfo> storeyInfos); public int updateBatch(@Param("storeyInfos") List<TStoreyInfo> storeyInfos);
/** /**
* 删除老化层信息 * 删除老化层信息
* *
* @param fStoreyId 老化层信息ID * @param fStoreyId 老化层信息ID
* @return 结果 * @return 结果
*/ */
...@@ -80,7 +82,7 @@ public interface TStoreyInfoMapper ...@@ -80,7 +82,7 @@ public interface TStoreyInfoMapper
/** /**
* 批量删除老化层信息 * 批量删除老化层信息
* *
* @param fStoreyIds 需要删除的数据ID * @param fStoreyIds 需要删除的数据ID
* @return 结果 * @return 结果
*/ */
......
...@@ -203,6 +203,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -203,6 +203,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
TStoreyInfo tStoreyInfo = new TStoreyInfo(); TStoreyInfo tStoreyInfo = new TStoreyInfo();
tStoreyInfo.setfStatus("0"); tStoreyInfo.setfStatus("0");
tStoreyInfo.setfAgingStartTime(null); tStoreyInfo.setfAgingStartTime(null);
tStoreyInfo.setfAgingEndTime(null);
tStoreyInfoMapper.updateAllStatusAndAgingStartTime(tStoreyInfo); tStoreyInfoMapper.updateAllStatusAndAgingStartTime(tStoreyInfo);
}).join(); // 阻塞等待所有操作完成 }).join(); // 阻塞等待所有操作完成
} }
...@@ -787,6 +788,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService ...@@ -787,6 +788,7 @@ public class TStoreyInfoServiceImpl implements ITStoreyInfoService
tStoreyInfo.setfStatus("0"); tStoreyInfo.setfStatus("0");
tStoreyInfo.setfAgingStartTime(null); tStoreyInfo.setfAgingStartTime(null);
tStoreyInfo.setfAgingEndTime(null);
tStoreyInfoMapper.updateTStoreyInfo(tStoreyInfo); tStoreyInfoMapper.updateTStoreyInfo(tStoreyInfo);
} }
return AjaxResult.success(); return AjaxResult.success();
......
...@@ -4,21 +4,28 @@ import com.serotonin.modbus4j.ModbusMaster; ...@@ -4,21 +4,28 @@ import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ErrorResponseException; import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException; import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException; import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.SysConfig;
import com.zehong.system.domain.TEquipmentAlarmData; import com.zehong.system.domain.TEquipmentAlarmData;
import com.zehong.system.domain.TStoreyInfo; import com.zehong.system.domain.TStoreyInfo;
import com.zehong.system.domain.TTrayInfo; import com.zehong.system.domain.TTrayInfo;
import com.zehong.system.mapper.TStoreyInfoMapper; import com.zehong.system.mapper.TStoreyInfoMapper;
import com.zehong.system.mapper.TTrayInfoMapper; import com.zehong.system.mapper.TTrayInfoMapper;
import com.zehong.system.modbus.util.Modbus4jUtils; import com.zehong.system.modbus.util.Modbus4jUtils;
import com.zehong.system.service.ISysConfigService;
import com.zehong.system.service.ITEquipmentAlarmDataService; import com.zehong.system.service.ITEquipmentAlarmDataService;
import com.zehong.system.service.ITStoreyInfoService; import com.zehong.system.service.ITStoreyInfoService;
import com.zehong.system.service.ITTrayInfoService; import com.zehong.system.service.ITTrayInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author lenovo * @author lenovo
...@@ -44,6 +51,12 @@ public class AllCommandHandler { ...@@ -44,6 +51,12 @@ public class AllCommandHandler {
@Resource @Resource
private DeviceTaskScheduler deviceTaskScheduler; private DeviceTaskScheduler deviceTaskScheduler;
@Autowired
private ISysConfigService configService;
// 使用常量定义索引,避免魔法数字
private static final int AGING_STAGE_INDEX = 3;
private static final int DEFAULT_HOURS = 72;
/** /**
* check是否启动 ,没启动就启动下 开始老化 * check是否启动 ,没启动就启动下 开始老化
* *
...@@ -72,9 +85,13 @@ public class AllCommandHandler { ...@@ -72,9 +85,13 @@ public class AllCommandHandler {
if (!aBoolean) { if (!aBoolean) {
Modbus4jUtils.writeCoil(master, 1, registerOffset, true); Modbus4jUtils.writeCoil(master, 1, registerOffset, true);
// 把预计老化结束时间保存到数据库中,因为可能会不同的老化时间
Date estimatedEndTime = getAgingEndTime();
TStoreyInfo tStoreyInfo = tStoreyInfoMapper.selectTStoreyInfoByCode(storeyCode); TStoreyInfo tStoreyInfo = tStoreyInfoMapper.selectTStoreyInfoByCode(storeyCode);
tStoreyInfo.setfStatus("1"); tStoreyInfo.setfStatus("1");
tStoreyInfo.setfAgingStartTime(new Date()); tStoreyInfo.setfAgingStartTime(new Date());
tStoreyInfo.setEstimatedEndTime(estimatedEndTime);
tStoreyInfoMapper.updateTStoreyInfo(tStoreyInfo); tStoreyInfoMapper.updateTStoreyInfo(tStoreyInfo);
// 同时 把 托盘的 状态更新 // 同时 把 托盘的 状态更新
...@@ -96,7 +113,29 @@ public class AllCommandHandler { ...@@ -96,7 +113,29 @@ public class AllCommandHandler {
} }
} }
public Date getAgingEndTime() {
List<SysConfig> sysConfigs = configService.selectAgingStageTime();
int milliseconds = getAgingMilliseconds(sysConfigs);
return DateUtils.addMilliseconds(new Date(), milliseconds);
}
private int getAgingMilliseconds(List<SysConfig> sysConfigs) {
try {
if (CollectionUtils.isNotEmpty(sysConfigs) &&
sysConfigs.size() > AGING_STAGE_INDEX) {
SysConfig config = sysConfigs.get(AGING_STAGE_INDEX);
if (config != null && StringUtils.isNotBlank(config.getConfigValue())) {
return Integer.parseInt(config.getConfigValue());
}
}
} catch (NumberFormatException e) {
log.warn("老化时间配置解析异常,使用默认值", e);
}
// 返回默认值(72小时转换为毫秒)
return DEFAULT_HOURS * 60 * 60 * 1000;
}
@Async // 异步执行 @Async // 异步执行
@EventListener(PowerOffCommandEvent.class) @EventListener(PowerOffCommandEvent.class)
public void handlePowerOffCommand(PowerOffCommandEvent event) { public void handlePowerOffCommand(PowerOffCommandEvent event) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TStoreyInfoMapper"> <mapper namespace="com.zehong.system.mapper.TStoreyInfoMapper">
<resultMap type="TStoreyInfo" id="TStoreyInfoResult"> <resultMap type="TStoreyInfo" id="TStoreyInfoResult">
<result property="fStoreyId" column="f_storey_id" /> <result property="fStoreyId" column="f_storey_id" />
<result property="fEquipmentId" column="f_equipment_id" /> <result property="fEquipmentId" column="f_equipment_id" />
...@@ -21,6 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -21,6 +21,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="blankingCommand" column="f_blanking_command" /> <result property="blankingCommand" column="f_blanking_command" />
<result property="feedingCommand" column="f_feeding_command" /> <result property="feedingCommand" column="f_feeding_command" />
<result property="estimatedEndTime" column="f_estimated_end_time" />
</resultMap> </resultMap>
<sql id="selectTStoreyInfoVo"> <sql id="selectTStoreyInfoVo">
...@@ -32,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -32,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
storeyInfo.f_port, storeyInfo.f_port,
storeyInfo.f_aging_start_time, storeyInfo.f_aging_start_time,
storeyInfo.f_aging_end_time, storeyInfo.f_aging_end_time,
storeyInfo.f_estimated_end_time,
storeyInfo.f_update_time, storeyInfo.f_update_time,
storeyInfo.f_create_time, storeyInfo.f_create_time,
storeyInfo.f_alarm_time, storeyInfo.f_alarm_time,
...@@ -71,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -71,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where storeyInfo.f_equipment_id = #{fEquipmentId} where storeyInfo.f_equipment_id = #{fEquipmentId}
order by storeyInfo.f_storey_id asc order by storeyInfo.f_storey_id asc
</select> </select>
<select id="selectTStoreyInfoById" parameterType="Long" resultMap="TStoreyInfoResult"> <select id="selectTStoreyInfoById" parameterType="Long" resultMap="TStoreyInfoResult">
<include refid="selectTStoreyInfoVo"/> <include refid="selectTStoreyInfoVo"/>
where f_storey_id = #{fStoreyId} where f_storey_id = #{fStoreyId}
...@@ -96,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -96,6 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f_port, f_port,
f_aging_start_time, f_aging_start_time,
f_aging_end_time, f_aging_end_time,
f_estimated_end_time,
f_update_time, f_update_time,
f_create_time, f_create_time,
f_alarm_time, f_alarm_time,
...@@ -147,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -147,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="blankingCommand != null">f_blanking_command,</if> <if test="blankingCommand != null">f_blanking_command,</if>
<if test="feedingCommand != null">f_feeding_command,</if> <if test="feedingCommand != null">f_feeding_command,</if>
<if test="estimatedEndTime != null">f_estimated_end_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="fStoreyId != null">#{fStoreyId},</if> <if test="fStoreyId != null">#{fStoreyId},</if>
...@@ -161,6 +166,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -161,6 +166,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="blankingCommand != null">#{blankingCommand},</if> <if test="blankingCommand != null">#{blankingCommand},</if>
<if test="feedingCommand != null">#{feedingCommand},</if> <if test="feedingCommand != null">#{feedingCommand},</if>
<if test="estimatedEndTime != null">#{estimatedEndTime},</if>
</trim> </trim>
</insert> </insert>
...@@ -193,6 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -193,6 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="blankingCommand != null">f_blanking_command = #{blankingCommand},</if> <if test="blankingCommand != null">f_blanking_command = #{blankingCommand},</if>
<if test="feedingCommand != null">f_feeding_command = #{feedingCommand},</if> <if test="feedingCommand != null">f_feeding_command = #{feedingCommand},</if>
<if test="estimatedEndTime != null">f_estimated_end_time = #{estimatedEndTime},</if>
</trim> </trim>
where f_storey_id = #{fStoreyId} where f_storey_id = #{fStoreyId}
</update> </update>
...@@ -204,13 +211,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -204,13 +211,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fAgingStartTime == null">f_aging_start_time = null,</if> <if test="fAgingStartTime == null">f_aging_start_time = null,</if>
<if test="fAgingEndTime != null">f_aging_end_time = #{fAgingEndTime},</if> <if test="fAgingEndTime != null">f_aging_end_time = #{fAgingEndTime},</if>
<if test="fAgingEndTime == null">f_aging_end_time = null,</if> <if test="fAgingEndTime == null">f_aging_end_time = null,</if>
<if test="estimatedEndTime != null">f_estimated_end_time = #{estimatedEndTime},</if>
<if test="estimatedEndTime == null">f_estimated_end_time = null,</if>
</trim> </trim>
where f_storey_id = #{fStoreyId} where f_storey_id = #{fStoreyId}
</update> </update>
<update id="setStartRunningByCode" parameterType="TStoreyInfo">
update t_storey_info
<trim prefix="SET" suffixOverrides=",">
<if test="fStatus != null">f_status = #{fStatus},</if>
<if test="fAgingStartTime != null">f_aging_start_time = #{fAgingStartTime},</if>
<if test="fAgingEndTime != null">f_aging_end_time = #{fAgingEndTime},</if>
<if test="estimatedEndTime != null">f_estimated_end_time = #{estimatedEndTime},</if>
</trim>
</update>
<update id="unbindByCode" parameterType="TStoreyInfo"> <update id="unbindByCode" parameterType="TStoreyInfo">
update t_storey_info update t_storey_info
set f_status = '0', f_aging_start_time = null,f_aging_end_time = null set f_status = '0', f_aging_start_time = null,f_aging_end_time = null,f_estimated_end_time = null
where f_storey_code = #{fStoreyCode} where f_storey_code = #{fStoreyCode}
</update> </update>
<update id="updateStatusByCode" parameterType="TStoreyInfo"> <update id="updateStatusByCode" parameterType="TStoreyInfo">
...@@ -226,9 +244,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -226,9 +244,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteTStoreyInfoByIds" parameterType="String"> <delete id="deleteTStoreyInfoByIds" parameterType="String">
delete from t_storey_info where f_storey_id in delete from t_storey_info where f_storey_id in
<foreach item="fStoreyId" collection="array" open="(" separator="," close=")"> <foreach item="fStoreyId" collection="array" open="(" separator="," close=")">
#{fStoreyId} #{fStoreyId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TTrayInfoMapper"> <mapper namespace="com.zehong.system.mapper.TTrayInfoMapper">
<resultMap type="TTrayInfo" id="TTrayInfoResult"> <resultMap type="TTrayInfo" id="TTrayInfoResult">
<result property="fTrayId" column="f_tray_id" /> <result property="fTrayId" column="f_tray_id" />
<result property="fTrayCode" column="f_tray_code" /> <result property="fTrayCode" column="f_tray_code" />
...@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="fUnbindingTime" column="f_unbinding_time" /> <result property="fUnbindingTime" column="f_unbinding_time" />
<result property="fCreateTime" column="f_create_time" /> <result property="fCreateTime" column="f_create_time" />
<result property="fAgingStartTime" column="f_aging_start_time" /> <result property="fAgingStartTime" column="f_aging_start_time" />
<result property="estimatedEndTime" column="f_estimated_end_time" />
</resultMap> </resultMap>
<sql id="selectTTrayInfoVo"> <sql id="selectTTrayInfoVo">
...@@ -25,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -25,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
trayInfo.f_unbinding_time, trayInfo.f_unbinding_time,
trayInfo.f_create_time, trayInfo.f_create_time,
( SELECT count( 1 ) FROM t_pallet_device_binding WHERE f_tray_id = trayInfo.f_tray_id AND ( f_device_code != '' ) AND f_unbinding_time IS NULL ) AS boardCount , ( SELECT count( 1 ) FROM t_pallet_device_binding WHERE f_tray_id = trayInfo.f_tray_id AND ( f_device_code != '' ) AND f_unbinding_time IS NULL ) AS boardCount ,
storeyInfo.f_aging_start_time storeyInfo.f_aging_start_time,
storeyInfo.f_estimated_end_time
FROM FROM
t_tray_info trayInfo t_tray_info trayInfo
LEFT JOIN t_storey_info storeyInfo ON trayInfo.f_storey_code = storeyInfo.f_storey_code LEFT JOIN t_storey_info storeyInfo ON trayInfo.f_storey_code = storeyInfo.f_storey_code
...@@ -33,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -33,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTTrayInfoList" parameterType="TTrayInfo" resultMap="TTrayInfoResult"> <select id="selectTTrayInfoList" parameterType="TTrayInfo" resultMap="TTrayInfoResult">
<include refid="selectTTrayInfoVo"/> <include refid="selectTTrayInfoVo"/>
<where> <where>
<if test="fTrayCode != null and fTrayCode != ''"> and trayInfo.f_tray_code like concat('%',#{fTrayCode},'%')</if> <if test="fTrayCode != null and fTrayCode != ''"> and trayInfo.f_tray_code like concat('%',#{fTrayCode},'%')</if>
<if test="fStoreyCode != null and fStoreyCode != ''"> and trayInfo.f_storey_code = #{fStoreyCode}</if> <if test="fStoreyCode != null and fStoreyCode != ''"> and trayInfo.f_storey_code = #{fStoreyCode}</if>
<if test="fStatus != null and fStatus != ''"> and trayInfo.f_status = #{fStatus}</if> <if test="fStatus != null and fStatus != ''"> and trayInfo.f_status = #{fStatus}</if>
...@@ -43,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -43,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
ORDER BY trayInfo.f_tray_id ORDER BY trayInfo.f_tray_id
</select> </select>
<select id="selectTTrayInfoById" parameterType="Long" resultMap="TTrayInfoResult"> <select id="selectTTrayInfoById" parameterType="Long" resultMap="TTrayInfoResult">
<include refid="selectTTrayInfoVo"/> <include refid="selectTTrayInfoVo"/>
where trayInfo.f_tray_id = #{fTrayId} where trayInfo.f_tray_id = #{fTrayId}
...@@ -56,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -56,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTTrayInfoVo"/> <include refid="selectTTrayInfoVo"/>
where trayInfo.f_storey_code = #{fStoreyCode} where trayInfo.f_storey_code = #{fStoreyCode}
</select> </select>
<insert id="insertTTrayInfo" parameterType="TTrayInfo" useGeneratedKeys="true" keyProperty="fTrayId"> <insert id="insertTTrayInfo" parameterType="TTrayInfo" useGeneratedKeys="true" keyProperty="fTrayId">
insert into t_tray_info insert into t_tray_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
...@@ -140,9 +142,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -140,9 +142,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteTTrayInfoByIds" parameterType="String"> <delete id="deleteTTrayInfoByIds" parameterType="String">
delete from t_tray_info where f_tray_id in delete from t_tray_info where f_tray_id in
<foreach item="fTrayId" collection="array" open="(" separator="," close=")"> <foreach item="fTrayId" collection="array" open="(" separator="," close=")">
#{fTrayId} #{fTrayId}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<!-- 可滚动列:预计老化结束时间 --> <!-- 可滚动列:预计老化结束时间 -->
<el-table-column prop="fAgingEndTime" label="预计老化结束时间" align="center" width="200"> <el-table-column prop="fAgingEndTime" label="预计老化结束时间" align="center" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<div class="device-code">{{ scope.row.fAgingEndTime ? formatDate(scope.row.fAgingEndTime) : '-' }}</div> <div class="device-code">{{ scope.row.estimatedEndTime ? formatDate(scope.row.estimatedEndTime) : '-' }}</div>
</template> </template>
</el-table-column> </el-table-column>
<!-- 可滚动列:主板数量 --> <!-- 可滚动列:主板数量 -->
...@@ -146,7 +146,8 @@ export default { ...@@ -146,7 +146,8 @@ export default {
// 动态列宽 // 动态列宽
boardCountWidth: '150', boardCountWidth: '150',
locationWidth: '150', locationWidth: '150',
agingStage4Time: 0, // // 把预计老化结束时间保存到数据库中,因为可能会不同的老化时间
// agingStage4Time: 0,
}; };
}, },
created() { created() {
...@@ -159,7 +160,8 @@ export default { ...@@ -159,7 +160,8 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.adjustTableLayout(); this.adjustTableLayout();
}); });
this.initAgingStage4Time(); //// 把预计老化结束时间保存到数据库中,因为可能会不同的老化时间
// this.initAgingStage4Time();
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('resize', this.handleResize); window.removeEventListener('resize', this.handleResize);
...@@ -217,26 +219,28 @@ export default { ...@@ -217,26 +219,28 @@ export default {
// 获取托盘数据 // 获取托盘数据
fetchTrays() { fetchTrays() {
listTray(this.queryParams).then(response => { listTray(this.queryParams).then(response => {
this.trays = response.rows.map(item => { // // 把预计老化结束时间保存到数据库中,因为可能会不同的老化时间
// 如果是运行中状态且有老化开始时间,计算预计老化结束时间 // this.trays = response.rows.map(item => {
if (item.fStatus === '1' && item.fAgingStartTime) { // // 如果是运行中状态且有老化开始时间,计算预计老化结束时间
try { // if (item.fStatus === '1' && item.fAgingStartTime) {
// 将开始时间转换为Date对象 // try {
const startTime = new Date(item.fAgingStartTime); // // 将开始时间转换为Date对象
// 加上配置的分钟数(agingStage3Time以分钟为单位) // const startTime = new Date(item.fAgingStartTime);
const endTime = new Date(startTime.getTime() + this.agingStage4Time * 60 * 1000); // // 加上配置的分钟数(agingStage3Time以分钟为单位)
// 添加到item对象中 // const endTime = new Date(startTime.getTime() + this.agingStage4Time * 60 * 1000);
item.fAgingEndTime = endTime; // // 添加到item对象中
} catch (e) { // item.fAgingEndTime = endTime;
console.error('计算预计老化结束时间失败:', e); // } catch (e) {
item.fAgingEndTime = null; // console.error('计算预计老化结束时间失败:', e);
} // item.fAgingEndTime = null;
} else { // }
item.fAgingEndTime = null; // } else {
item.fAgingStartTime = null; // item.fAgingEndTime = null;
} // item.fAgingStartTime = null;
return item; // }
}); // return item;
// });
this.trays = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
// 数据加载完成后调整表格布局 // 数据加载完成后调整表格布局
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment