feat(schedule): 优化楼层任务调度逻辑
- 新增任务执行阶段状态管理,支持多阶段任务查询 - 完善任务下发逻辑,增加任务执行状态更新机制 - 修改PLC写入逻辑,确保任务正确下发至设备 - 移除冗余代码,提升线程执行效率 - 更新任务执行阶段常量定义,统一状态码管理 - 优化MydoJob实体类,支持执行阶段列表查询 - 调整数据库查询条件,支持入口ID列表筛选
This commit is contained in:
@@ -29,6 +29,16 @@ public class TaskStatusCode {
|
|||||||
* 任务状态-作废
|
* 任务状态-作废
|
||||||
*/
|
*/
|
||||||
public static final String TASK_STATUS_INVALID = "5";
|
public static final String TASK_STATUS_INVALID = "5";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务执行阶段 创建
|
||||||
|
*/
|
||||||
|
public static final String TASK_EP_CREATE = "0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务执行阶段 产线
|
||||||
|
*/
|
||||||
|
public static final String TASK_EP_LINE_SSJ = "1";
|
||||||
/**
|
/**
|
||||||
* 任务执行阶段 AGV
|
* 任务执行阶段 AGV
|
||||||
*/
|
*/
|
||||||
@@ -40,17 +50,16 @@ public class TaskStatusCode {
|
|||||||
/**
|
/**
|
||||||
* 任务执行阶段 巷道口
|
* 任务执行阶段 巷道口
|
||||||
*/
|
*/
|
||||||
public static final String TASK_EP_ROADWAY_SSJ = "3";
|
public static final String TASK_EP_ROADWAY_SSJ = "4";
|
||||||
/**
|
/**
|
||||||
* 任务执行阶段 堆垛机
|
* 任务执行阶段 堆垛机
|
||||||
*/
|
*/
|
||||||
public static final String TASK_EP_DDJ = "4";
|
public static final String TASK_EP_DDJ = "5";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务执行阶段 回传wms完成
|
* 任务执行阶段 回传wms完成
|
||||||
*/
|
*/
|
||||||
public static final String TASK_EP_WMS_FINISH = "6";
|
public static final String TASK_EP_WMS_FINISH = "6";
|
||||||
|
|
||||||
public static final String TASK_EP_LINE_SSJ = "1";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||||||
import com.ruoyi.common.annotation.Excel;
|
import com.ruoyi.common.annotation.Excel;
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作业信息对象 mydo_job_wcs
|
* 作业信息对象 mydo_job_wcs
|
||||||
*
|
*
|
||||||
@@ -91,4 +93,6 @@ public class MydoJob extends BaseEntity
|
|||||||
private String inOut;
|
private String inOut;
|
||||||
|
|
||||||
private String flag;
|
private String flag;
|
||||||
|
|
||||||
|
private List<String> epList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
|||||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||||
int taskNo = ssj.getTaskNo();
|
int taskNo = ssj.getTaskNo();
|
||||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(taskNo));
|
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(taskNo));
|
||||||
|
if (ObjUtil.isNotNull(mydoJob) && "1".equals(mydoJob.getStatus()) && TASK_EP_SSJ.equals(mydoJob.getExecutionPhase()) && Convert.toInt(mydoJob.getInOrOut())<20){
|
||||||
|
//修改作业执行状态
|
||||||
|
mydoJob.setStatus(TASK_STATUS_RUNNING);
|
||||||
|
mydoJob.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
|
||||||
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
|
}
|
||||||
if (ObjUtil.isNotNull(mydoJob) && mydoJob.getExecutionPhase().equals(TASK_EP_SSJ)) {
|
if (ObjUtil.isNotNull(mydoJob) && mydoJob.getExecutionPhase().equals(TASK_EP_SSJ)) {
|
||||||
mydoJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
mydoJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
@@ -200,8 +206,11 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
|||||||
}else {
|
}else {
|
||||||
//查询下发的任务
|
//查询下发的任务
|
||||||
MydoJob param = new MydoJob();
|
MydoJob param = new MydoJob();
|
||||||
param.setExecutionPhase("1");
|
ArrayList<String> epList = new ArrayList<>();
|
||||||
param.setStatus("1");
|
epList.add(TASK_EP_CREATE);
|
||||||
|
epList.add(TASK_EP_SSJ);
|
||||||
|
param.setEpList(epList);
|
||||||
|
param.setStatus(TASK_STATUS_CREATE);
|
||||||
param.setEntranceId(ssj.getDeviceCode());
|
param.setEntranceId(ssj.getDeviceCode());
|
||||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||||
if (CollUtil.isNotEmpty(mydoJobs)){
|
if (CollUtil.isNotEmpty(mydoJobs)){
|
||||||
@@ -209,7 +218,7 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
|||||||
MydoJob mydoJob = mydoJobs.get(0);
|
MydoJob mydoJob = mydoJobs.get(0);
|
||||||
int i = writeToSsj(ssj.getPlcDbWriteAddress(),mydoJob.getTaskNo(),1,1);
|
int i = writeToSsj(ssj.getPlcDbWriteAddress(),mydoJob.getTaskNo(),1,1);
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
mydoJob.setExecutionPhase("1");
|
mydoJob.setExecutionPhase(TASK_EP_SSJ);
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
log.info("{}已重复下发任务号{}:",ssj.getDeviceCode(),mydoJob.getTaskNo());
|
log.info("{}已重复下发任务号{}:",ssj.getDeviceCode(),mydoJob.getTaskNo());
|
||||||
}
|
}
|
||||||
@@ -221,10 +230,11 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
|||||||
AjaxResult ajaxResult = apiService.selectMydoJobByNoTrayCode(paramMap);
|
AjaxResult ajaxResult = apiService.selectMydoJobByNoTrayCode(paramMap);
|
||||||
if (ajaxResult.isSuccess()) {
|
if (ajaxResult.isSuccess()) {
|
||||||
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
|
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
|
||||||
|
mydoJob2.setExecutionPhase(TASK_EP_CREATE);
|
||||||
mydoJobService.insertMydoJob(mydoJob2);
|
mydoJobService.insertMydoJob(mydoJob2);
|
||||||
int i = writeToSsj(ssj.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
|
int i = writeToSsj(ssj.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
mydoJob2.setExecutionPhase("1");
|
mydoJob2.setExecutionPhase(TASK_EP_SSJ);
|
||||||
mydoJobService.updateMydoJob(mydoJob2);
|
mydoJobService.updateMydoJob(mydoJob2);
|
||||||
log.info("{}已下发任务号{}:",ssj.getDeviceCode(),mydoJob2.getTaskNo());
|
log.info("{}已下发任务号{}:",ssj.getDeviceCode(),mydoJob2.getTaskNo());
|
||||||
}
|
}
|
||||||
@@ -243,15 +253,7 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0 && ssj.getTraySize() != 0){
|
|
||||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(ssj.getTaskNo()));
|
|
||||||
if (ObjUtil.isNotNull(mydoJob) && "1".equals(mydoJob.getStatus()) && "1".equals(mydoJob.getExecutionPhase()) && Convert.toInt(mydoJob.getInOrOut())<20){
|
|
||||||
//修改作业执行状态
|
|
||||||
mydoJob.setStatus("3");
|
|
||||||
mydoJob.setStartTime(DateUtil.formatDateTime(DateUtil.date()));
|
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.ruoyi.common.TaskStatusCode.TASK_EP_LINE_SSJ;
|
|
||||||
import static com.ruoyi.common.TaskStatusCode.TASK_EP_SSJ;
|
import static com.ruoyi.common.TaskStatusCode.TASK_EP_SSJ;
|
||||||
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.writeToSsj;
|
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.writeToSsj;
|
||||||
|
|
||||||
|
|||||||
@@ -36,23 +36,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectMydoJobList" parameterType="MydoJob" resultMap="MydoJobResult">
|
<select id="selectMydoJobList" parameterType="MydoJob" resultMap="MydoJobResult">
|
||||||
<include refid="selectMydoJobVo"/>
|
<include refid="selectMydoJobVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
<if test="status != null and status != ''">and status = #{status}</if>
|
||||||
<if test="taskNo != null and taskNo != ''"> and task_no = #{taskNo}</if>
|
<if test="taskNo != null and taskNo != ''">and task_no = #{taskNo}</if>
|
||||||
<if test="roadwayId != null and roadwayId != ''"> and roadway_id = #{roadwayId}</if>
|
<if test="roadwayId != null and roadwayId != ''">and roadway_id = #{roadwayId}</if>
|
||||||
<if test="cargoSpaceId != null and cargoSpaceId != ''"> and cargo_space_id = #{cargoSpaceId}</if>
|
<if test="cargoSpaceId != null and cargoSpaceId != ''">and cargo_space_id = #{cargoSpaceId}</if>
|
||||||
<if test="targetRoadwayId != null and targetRoadwayId != ''"> and target_roadway_id = #{targetRoadwayId}</if>
|
<if test="targetRoadwayId != null and targetRoadwayId != ''">and target_roadway_id = #{targetRoadwayId}
|
||||||
<if test="targetCargoSpaceId != null and targetCargoSpaceId != ''"> and target_cargo_space_id = #{targetCargoSpaceId}</if>
|
</if>
|
||||||
<if test="priority != null "> and priority = #{priority}</if>
|
<if test="targetCargoSpaceId != null and targetCargoSpaceId != ''">and target_cargo_space_id =
|
||||||
<if test="executionPhase != null and executionPhase != ''"> and execution_phase = #{executionPhase}</if>
|
#{targetCargoSpaceId}
|
||||||
<if test="inOrOut != null and inOrOut != ''"> and in_or_out = #{inOrOut}</if>
|
</if>
|
||||||
<if test="startTime != null and startTime != ''"> and start_time = #{startTime}</if>
|
<if test="priority != null ">and priority = #{priority}</if>
|
||||||
<if test="finishTime != null and finishTime != ''"> and finish_time = #{finishTime}</if>
|
<if test="executionPhase != null and executionPhase != ''">and execution_phase = #{executionPhase}</if>
|
||||||
<if test="entranceId != null and entranceId != ''"> and entrance_id = #{entranceId}</if>
|
<if test="inOrOut != null and inOrOut != ''">and in_or_out = #{inOrOut}</if>
|
||||||
<if test="exitId != null and exitId != ''"> and exit_id = #{exitId}</if>
|
<if test="startTime != null and startTime != ''">and start_time = #{startTime}</if>
|
||||||
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
|
<if test="finishTime != null and finishTime != ''">and finish_time = #{finishTime}</if>
|
||||||
<if test="faultFlag != null and faultFlag != ''"> and fault_flag = #{faultFlag}</if>
|
<if test="entranceId != null and entranceId != ''">and entrance_id = #{entranceId}</if>
|
||||||
<if test="flag != null and flag != ''"> and flag = #{flag}</if>
|
<if test="exitId != null and exitId != ''">and exit_id = #{exitId}</if>
|
||||||
<if test="trayCode != null and trayCode != ''"> and trayCode = #{tray_code}</if>
|
<if test="warehouseId != null and warehouseId != ''">and warehouse_id = #{warehouseId}</if>
|
||||||
|
<if test="faultFlag != null and faultFlag != ''">and fault_flag = #{faultFlag}</if>
|
||||||
|
<if test="flag != null and flag != ''">and flag = #{flag}</if>
|
||||||
|
<if test="trayCode != null and trayCode != ''">and trayCode = #{tray_code}</if>
|
||||||
|
<if test="epList != null and epList.size() > 0">
|
||||||
|
and entrance_id in
|
||||||
|
<foreach item="item" index="index" collection="epList" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user