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_EP_CREATE = "0";
|
||||
|
||||
/**
|
||||
* 任务执行阶段 产线
|
||||
*/
|
||||
public static final String TASK_EP_LINE_SSJ = "1";
|
||||
/**
|
||||
* 任务执行阶段 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完成
|
||||
*/
|
||||
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.core.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 作业信息对象 mydo_job_wcs
|
||||
*
|
||||
@@ -91,4 +93,6 @@ public class MydoJob extends BaseEntity
|
||||
private String inOut;
|
||||
|
||||
private String flag;
|
||||
|
||||
private List<String> epList;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,12 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
||||
if (ssj.getDw() == 1 && ssj.getTaskNo() > 0) {
|
||||
int taskNo = ssj.getTaskNo();
|
||||
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)) {
|
||||
mydoJob.setExecutionPhase(TASK_EP_ROADWAY_SSJ);
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
@@ -200,8 +206,11 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
||||
}else {
|
||||
//查询下发的任务
|
||||
MydoJob param = new MydoJob();
|
||||
param.setExecutionPhase("1");
|
||||
param.setStatus("1");
|
||||
ArrayList<String> epList = new ArrayList<>();
|
||||
epList.add(TASK_EP_CREATE);
|
||||
epList.add(TASK_EP_SSJ);
|
||||
param.setEpList(epList);
|
||||
param.setStatus(TASK_STATUS_CREATE);
|
||||
param.setEntranceId(ssj.getDeviceCode());
|
||||
List<MydoJob> mydoJobs = mydoJobService.selectMydoJobList(param);
|
||||
if (CollUtil.isNotEmpty(mydoJobs)){
|
||||
@@ -209,7 +218,7 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
||||
MydoJob mydoJob = mydoJobs.get(0);
|
||||
int i = writeToSsj(ssj.getPlcDbWriteAddress(),mydoJob.getTaskNo(),1,1);
|
||||
if (i == 1) {
|
||||
mydoJob.setExecutionPhase("1");
|
||||
mydoJob.setExecutionPhase(TASK_EP_SSJ);
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("{}已重复下发任务号{}:",ssj.getDeviceCode(),mydoJob.getTaskNo());
|
||||
}
|
||||
@@ -221,10 +230,11 @@ public class Floor1BothWayInSsjThread implements Runnable {
|
||||
AjaxResult ajaxResult = apiService.selectMydoJobByNoTrayCode(paramMap);
|
||||
if (ajaxResult.isSuccess()) {
|
||||
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class);
|
||||
mydoJob2.setExecutionPhase(TASK_EP_CREATE);
|
||||
mydoJobService.insertMydoJob(mydoJob2);
|
||||
int i = writeToSsj(ssj.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
|
||||
if (i == 1) {
|
||||
mydoJob2.setExecutionPhase("1");
|
||||
mydoJob2.setExecutionPhase(TASK_EP_SSJ);
|
||||
mydoJobService.updateMydoJob(mydoJob2);
|
||||
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.List;
|
||||
|
||||
import static com.ruoyi.common.TaskStatusCode.TASK_EP_LINE_SSJ;
|
||||
import static com.ruoyi.common.TaskStatusCode.TASK_EP_SSJ;
|
||||
import static com.ruoyi.schedule.plcRead.ssj.PlcSsjRead.writeToSsj;
|
||||
|
||||
|
||||
@@ -40,8 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="taskNo != null and taskNo != ''">and task_no = #{taskNo}</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="targetRoadwayId != null and targetRoadwayId != ''"> and target_roadway_id = #{targetRoadwayId}</if>
|
||||
<if test="targetCargoSpaceId != null and targetCargoSpaceId != ''"> and target_cargo_space_id = #{targetCargoSpaceId}</if>
|
||||
<if test="targetRoadwayId != null and targetRoadwayId != ''">and target_roadway_id = #{targetRoadwayId}
|
||||
</if>
|
||||
<if test="targetCargoSpaceId != null and targetCargoSpaceId != ''">and target_cargo_space_id =
|
||||
#{targetCargoSpaceId}
|
||||
</if>
|
||||
<if test="priority != null ">and priority = #{priority}</if>
|
||||
<if test="executionPhase != null and executionPhase != ''">and execution_phase = #{executionPhase}</if>
|
||||
<if test="inOrOut != null and inOrOut != ''">and in_or_out = #{inOrOut}</if>
|
||||
@@ -53,6 +56,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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>
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user