产线入库流程修改

This commit is contained in:
liuhanqing
2025-09-28 14:56:02 +08:00
parent fd9b720fe6
commit 3273fae260
12 changed files with 109 additions and 62 deletions

View File

@@ -108,7 +108,7 @@ public class JobCallBackServiceImpl implements IJobCallBackService
Map<String, Object> param = new HashMap<>();
param.put("jobId", jobCallBack.getMydojobId());
param.put("taskNo", jobCallBack.getTaskNo());
param.put("type", jobCallBack.getType());
param.put("wmsType", jobCallBack.getType());
RequestLog requestLog = apiService.finishMydoJob(param);
if ("1".equals(requestLog.getIsSuccessful())){
jobCallBack.setStatus("1");

View File

@@ -61,4 +61,6 @@ public interface DdjDeviceExecutionQueueMapper
public int deleteDdjDeviceExecutionQueueByUuids(String[] uuids);
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(@Param("rwlx")Integer rwlx,@Param("devId") Integer devId);
DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwhAndXd(@Param("rwh") Long rwh, @Param("devId") Integer devId);
}

View File

@@ -59,7 +59,7 @@ public interface IDdjDeviceExecutionQueueService
*/
public int deleteDdjDeviceExecutionQueueByUuid(String uuid);
DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh);
DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh,Integer devId);
List<DdjDeviceExecutionQueue> selectDdjDeviceExecutionQueueListByRwlx(Integer rwlx,Integer devId);
}

View File

@@ -92,8 +92,8 @@ public class DdjDeviceExecutionQueueServiceImpl implements IDdjDeviceExecutionQu
}
@Override
public DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh) {
return null;
public DdjDeviceExecutionQueue selectDdjDeviceExecutionQueueByRwh(Long rwh,Integer devId) {
return ddjDeviceExecutionQueueMapper.selectDdjDeviceExecutionQueueByRwhAndXd(rwh,devId);
}
@Override

View File

@@ -113,9 +113,11 @@ public class ScheduleThread {
for (MsgDdj msgDdj : msgDdjs) {
switch (msgDdj.getId()){
case 1:
msgDdj.setPlcDbReadAddress("DB40.0");
case 2:
msgDdj.setPlcDbReadAddress("DB41.0");
break;
case 2:
msgDdj.setPlcDbReadAddress("DB42.0");
break;
}
ddjList.put("ddj" + msgDdj.getId(), msgDdj);
}
@@ -139,9 +141,9 @@ public class ScheduleThread {
*/
public void startAllThread2() {
monitoringCustomThread.thread.start();
floor1BothWayInSsjCustomThread.thread.start();
floor1BothWayOutSsjCustomThread.thread.start();
floor1SingleSsjCustomThread.thread.start();
//floor1BothWayInSsjCustomThread.thread.start();
//floor1BothWayOutSsjCustomThread.thread.start();
//floor1SingleSsjCustomThread.thread.start();
floor2InSsjCustomThread.thread.start();
lineSsjCustomThread.thread.start();
floor2OutSsjCustomThread.thread.start();

View File

@@ -11,8 +11,10 @@ import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.common.domain.HslRead;
import com.ruoyi.common.domain.PlcConnectInfo;
import com.ruoyi.schedule.plcRead.util.ParseUtil;
import com.ruoyi.schedule.plcRead.util.Tools;
import lombok.extern.slf4j.Slf4j;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
@@ -125,8 +127,10 @@ public class PlcSsjRead implements Runnable {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setException(ParseUtil.optInt(8, ddsx1));
ssjDevice.setException(ParseUtil.optInt(4, ddsx1));
ssjDevice.setAllowPut(ParseUtil.optInt(6, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
}
}
@@ -136,16 +140,23 @@ public class PlcSsjRead implements Runnable {
* @param ssjDevice
*/
private void readPlcLineSsj(DeviceSsj ssjDevice) {
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("220"));
String ddsx1 = "0";
if (read2.IsSuccess) {
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
ssjDevice.setTraySize(ParseUtil.optInt(14, ddsx1));
ssjDevice.setTraySize(ParseUtil.optInt(6, ddsx1));
ssjDevice.setTaskNo(ParseUtil.optDInt(8, ddsx1));
OperateResultExOne<byte[]> trayCodeRead = readWriteNet.Read("DB502.0", Short.parseShort("220"));
if (trayCodeRead.IsSuccess){
byte[] content = trayCodeRead.Content;
//去除bytes中
ssjDevice.setTrayCode(ParseUtil.filterAndConvert(trayCodeRead.Content));
}
}
}
@@ -196,4 +207,7 @@ public class PlcSsjRead implements Runnable {
setIsConnect(false);
}
}

View File

@@ -51,6 +51,29 @@ public class ParseUtil {
}
/**
* 过滤ASCII数组中的无效字符,只保留可打印字符(32-126)
* @param asciiArray 原始ASCII码数组
* @return 转换后的字符串
*/
public static String filterAndConvert(byte[] asciiArray) {
if (asciiArray == null) {
return "";
}
StringBuilder sb = new StringBuilder();
for (int code : asciiArray) {
// 只保留可打印ASCII字符(32-空格到126-~)
if (code >= 32 && code <= 126) {
sb.append((char) code);
}
}
return sb.toString();
}

View File

@@ -92,7 +92,7 @@ public class Ddj1Thread implements Runnable {
Long rwh = ddj.getRwh();
//完成作业
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh,ddj.getId());
if (mydoJob != null && ddjDeviceExecutionQueue != null) {
//回传完成信号
ddjTaskFinish(rwh, ddj.getId());
@@ -106,7 +106,7 @@ public class Ddj1Thread implements Runnable {
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1 && (ddj.getJdbz() == 2 || ddj.getJdbz() == 3 || ddj.getJdbz() == 4)) {
//根据堆垛机上任务号,修改任务执行阶段
Long rwh = ddj.getRwh();
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
if (ddjDeviceExecutionQueue != null) {
//修改队列执行阶段
ddjDeviceExecutionQueue.setRwzt(ddj.getJdbz());
@@ -140,7 +140,7 @@ public class Ddj1Thread implements Runnable {
if (ddj.getCzfs() == 5 && ddj.getSbzt() == 1053 && ddj.getJdbz() < 5) {
Long rwh = ddj.getRwh();
//无货异常处理
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh,ddj.getId());
//找到对应任务 调用api接口 取货无货,重新分配单据
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
AjaxResult ajaxResult = apiService.reMaterial(new JobParam(rwh.toString(), null, null));
@@ -161,7 +161,7 @@ public class Ddj1Thread implements Runnable {
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
if (ObjUtil.isNotNull(mydoJob) && "2".equals(mydoJob.getFaultFlag())) {
//判断任务是否重分完成
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh);
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh,ddj.getId());
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
//重新下发堆垛机任务
int i = issuedDDJTask(ddj.getId(), ddjDeviceExecutionQueue);

View File

@@ -1,21 +1,17 @@
package com.ruoyi.schedule.scheduleTask.ssj.floor2;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
import com.ruoyi.api.service.IApiService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.domain.SendData;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.job.domain.JobCallBack;
import com.ruoyi.job.domain.MydoJob;
import com.ruoyi.job.service.IJobCallBackService;
import com.ruoyi.job.service.IMydoJobService;
import com.ruoyi.queue.agv.domain.AgvQueue;
import com.ruoyi.queue.agv.service.IAgvQueueService;
import com.ruoyi.device.ssj.domain.DeviceSsj;
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
import com.ruoyi.schedule.plcRead.util.Tools;
import lombok.extern.slf4j.Slf4j;
@@ -98,7 +94,7 @@ public class Floor2InSsjThread implements Runnable {
agvQueue.setPositionCode2(inSsjDevice.getDeviceCode());
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueue);
//不允许放货
if(agvQueues.size()!=0 && inSsjDevice.getAllowPut()==0){
if(!agvQueues.isEmpty() && inSsjDevice.getAllowPut()==0){
//如果有这个输送机口的agv队列并请求放货(状态为6)
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(),"0",Integer.valueOf(agvQueues.get(0).getCtnrType()),1);
if(i==1){
@@ -106,7 +102,7 @@ public class Floor2InSsjThread implements Runnable {
}
}
//允许放货
if(agvQueues.size()!=0 && inSsjDevice.getAllowPut()==1 ){
if(!agvQueues.isEmpty() && inSsjDevice.getAllowPut()==1 ){
log.info("设备:{} 位置:{} 任务号:{} 请求放货成功", inSsjDevice.getDeviceCode(), "输送线", agvQueues.get(0).getTaskCode());
AjaxResult ajaxResult = apiService.continueTask(agvQueues.get(0));
if(ajaxResult.isSuccess()) {
@@ -117,14 +113,14 @@ public class Floor2InSsjThread implements Runnable {
}
}
//入库下发输送线
//入库下发输送线
if(inSsjDevice.getKx()==0 && inSsjDevice.getTaskNo()==0){
AgvQueue agvQueue = new AgvQueue();
agvQueue.setStatus("7"); //end
agvQueue.setPositionCode2(inSsjDevice.getDeviceCode());
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueue);
if(agvQueues.size()!=0) {
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), agvQueue.getWmsTaskNo(), 1, 1);
if(!agvQueues.isEmpty()) {
int i = writeToSsj(inSsjDevice.getPlcDbWriteAddress(), agvQueues.get(0).getWmsTaskNo(), 1, 1);
if (i == 1) {
log.info(inSsjDevice.getDeviceCode() + "输送机下发任务号成功");
MydoJob mydoJob = mydoJobService.selectMydoJobByJobId(agvQueues.get(0).getTaskCode());
@@ -136,7 +132,7 @@ public class Floor2InSsjThread implements Runnable {
}
}
//出库到位
//出库到位
if(inSsjDevice.getDw()==1 && inSsjDevice.getTaskNo()>0){
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(Convert.toLong(inSsjDevice.getTaskNo()));

View File

@@ -1,8 +1,7 @@
package com.ruoyi.schedule.scheduleTask.ssj.floor2;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskResponse;
import com.ruoyi.api.service.IApiService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.domain.SendData;
@@ -17,6 +16,7 @@ import com.ruoyi.schedule.plcRead.util.Tools;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -101,7 +101,7 @@ public class LineSsjThread implements Runnable {
mydoJob = mydoJobs.get(0);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob.getTaskNo(),1,1);
if (i == 1) {
mydoJob.setExecutionPhase(TASK_EP_AGV);
//mydoJob.setExecutionPhase(TASK_EP_AGV);
mydoJobService.updateMydoJob(mydoJob);
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
}
@@ -118,11 +118,15 @@ public class LineSsjThread implements Runnable {
AjaxResult ajaxResult = apiService.createInMydoJob(paramMap);
if (ajaxResult.isSuccess()) {
//拿到正常作业,插到wcs作业表,下发给输送机任务号,覆盖任务号
MydoJob mydoJob2 = (MydoJob) ajaxResult.get("data");
MydoJob mydoJob2 = BeanUtil.toBean(ajaxResult.get("data"), MydoJob.class) ;
mydoJob2.setStatus("1");
mydoJob2.setExecutionPhase("0");
mydoJob2.setCreateTime(new Date());
mydoJobService.insertMydoJob(mydoJob2);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob2.getTaskNo(),1,1);
if (i == 1) {
mydoJob2.setExecutionPhase("1");
//mydoJob2.setExecutionPhase("1");
mydoJobService.updateMydoJob(mydoJob2);
log.info("G1005产线输送机下发任务号成功:" + mydoJob2.getTaskNo());
}
@@ -155,7 +159,6 @@ public class LineSsjThread implements Runnable {
mydoJob = mydoJobs.get(0);
int i = writeToSsj(SsjDevice.getPlcDbWriteAddress(),mydoJob.getTaskNo(),1,1);
if (i == 1) {
mydoJob.setExecutionPhase("1");
mydoJobService.updateMydoJob(mydoJob);
log.info("G1005产线输送机下发任务号成功:" + mydoJob.getTaskNo());
}
@@ -207,31 +210,33 @@ public class LineSsjThread implements Runnable {
List<MydoJob> mydoJob2 = mydoJobService.selectInOrOutMydoJobList(mydoJob1);
if (mydoJob2.size() == 0 && kx == 1) {
if (mydoJob2.isEmpty() && kx == 1) {
//查是否有队列,如果有了请求放货修改为允许放货
AgvQueue agvQueue = agvQueueService.selectAgvQueueByTaskCode(mydoJob.getJobId());
if (agvQueue != null && "1".equals(agvQueue.getStatus()) && "3".equals(mydoJob.getStatus()) ) {
AjaxResult ajaxResult = apiService.continueTask(agvQueue);
if (ajaxResult.isSuccess()) {
log.info("给agv下发允许取货继续任务成功"+agvQueue.getWmsTaskNo());
agvQueue.setStatus("2");
agvQueueService.updateAgvQueue(agvQueue);
}
} else if("1".equals(mydoJob.getStatus()) && agvQueue==null){
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("trayCode", mydoJob.getTrayCode());
paramMap.put("taskNo", mydoJob.getJobId());
paramMap.put("startPoint", "G1005");
paramMap.put("endPoint", deviceCode);
paramMap.put("traySize",String.valueOf(SsjDevice.getTraySize()));
paramMap.put("wmstaskNo",mydoJob.getTaskNo());
AjaxResult ajaxResult = apiService.receiveAgvMoveJob(paramMap);
if (ajaxResult.isSuccess()) {
mydoJob.setStatus("3");
mydoJob.setExecutionPhase("2");
mydoJobService.updateMydoJob(mydoJob);
if (agvQueue != null){
if ("3".equals(mydoJob.getStatus()) && "1".equals(agvQueue.getStatus())){
AjaxResult ajaxResult = apiService.continueTask(agvQueue);
if (ajaxResult.isSuccess()) {
log.info("给agv下发允许取货继续任务成功"+agvQueue.getWmsTaskNo());
agvQueue.setStatus("2");
agvQueueService.updateAgvQueue(agvQueue);
}
}
}else {
if ("1".equals(mydoJob.getStatus())){
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("trayCode", mydoJob.getTrayCode());
paramMap.put("taskNo", mydoJob.getJobId());
paramMap.put("startPoint", "G1005");
paramMap.put("endPoint", deviceCode);
paramMap.put("traySize",String.valueOf(SsjDevice.getTraySize()));
paramMap.put("wmstaskNo",mydoJob.getTaskNo());
AjaxResult ajaxResult = apiService.receiveAgvMoveJob(paramMap);
if (ajaxResult.isSuccess()) {
mydoJob.setStatus("3");
mydoJob.setExecutionPhase(TASK_EP_AGV);
mydoJobService.updateMydoJob(mydoJob);
}
}
}
}

View File

@@ -117,9 +117,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="yph != null">yph = #{yph},</if>
<if test="ylh != null">ylh = #{ylh},</if>
<if test="ych != null">ych = #{ych},</if>
<if test="mbph != null">mbp = #{mbph},</if>
<if test="mblh != null">mbl = #{mblh},</if>
<if test="mbch != null">mbc = #{mbch},</if>
<if test="mbph != null">mbph = #{mbph},</if>
<if test="mblh != null">mblh = #{mblh},</if>
<if test="mbch != null">mbch = #{mbch},</if>
<if test="xtxh != null">xtxh = #{xtxh},</if>
<if test="dqxd != null">dqxd = #{dqxd},</if>
<if test="hczt != null">hczt = #{hczt},</if>

View File

@@ -67,6 +67,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where rwlx = #{rwlx} and dev_id = #{devId}
</select>
<select id="selectDdjDeviceExecutionQueueByRwhAndXd"
resultMap="DdjDeviceExecutionQueueResult">
<include refid="selectDdjDeviceExecutionQueueVo"/>
where rwh = #{rwh} and dev_id = #{devId}
</select>
<insert id="insertDdjDeviceExecutionQueue" parameterType="DdjDeviceExecutionQueue">