|
|
|
|
@ -1,37 +1,52 @@ |
|
|
|
|
package com.shkj.wcs.plc; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.shkj.common.constant.RedisConstant; |
|
|
|
|
import com.shkj.common.core.domain.Result; |
|
|
|
|
import com.shkj.common.enums.BusinessType; |
|
|
|
|
import com.shkj.common.utils.DateUtils; |
|
|
|
|
import com.shkj.plc.sdk.device.PlcOperate; |
|
|
|
|
import com.shkj.system.service.ISysParameterService; |
|
|
|
|
import com.shkj.wcs.bo.WcsPlcConnectQueryBo; |
|
|
|
|
import com.shkj.wcs.domain.BusinDataTask; |
|
|
|
|
import com.shkj.wcs.domain.WcsPlcConnect; |
|
|
|
|
import com.shkj.wcs.domain.WcsPlcProperty; |
|
|
|
|
import com.shkj.wcs.mapper.WcsPlcConnectMapper; |
|
|
|
|
import com.shkj.wcs.service.IBusinDataTaskService; |
|
|
|
|
import com.shkj.wcs.service.IWcsPlcConnectService; |
|
|
|
|
import com.shkj.wcs.service.IWcsPlcPropertyService; |
|
|
|
|
import com.shkj.wcs.third.rcs.CounterService; |
|
|
|
|
import com.shkj.wcs.third.rcs.RCSUtil; |
|
|
|
|
import com.shkj.wcs.third.rcs.dto.CarrierInfoList; |
|
|
|
|
import com.shkj.wcs.third.rcs.dto.RcsCreateTaskDto; |
|
|
|
|
import com.shkj.wcs.third.rcs.dto.RcsIdList; |
|
|
|
|
import com.shkj.wcs.third.rcs.enums.RCSOperation; |
|
|
|
|
import com.shkj.wcs.third.rcs.vo.RcsResponseVo; |
|
|
|
|
import com.shkj.wcs.third.workbinWcs.WCSUtil; |
|
|
|
|
import com.shkj.wcs.third.workbinWcs.dto.WCSQueryAreaStatusBody; |
|
|
|
|
import com.shkj.wcs.third.workbinWcs.dto.WCSQueryTaskStatusBody; |
|
|
|
|
import com.shkj.wcs.third.workbinWcs.dto.WcsIncomingTaskRequestBody; |
|
|
|
|
import com.shkj.wcs.third.workbinWcs.dto.WcsIncomingTrayCheckBody; |
|
|
|
|
import com.shkj.wcs.third.workbinWcs.dto.*; |
|
|
|
|
import com.shkj.wcs.vo.TaskStatusBody; |
|
|
|
|
import com.shkj.wcs.vo.WcsPlcConnectVo; |
|
|
|
|
import com.shkj.wcs.vo.WcsResponseVo; |
|
|
|
|
import com.shkj.wms.enums.BusinTaskTypeEnum; |
|
|
|
|
import com.shkj.wms.enums.MapEnum; |
|
|
|
|
import com.shkj.wms.enums.TaskStatusEnum; |
|
|
|
|
import com.shkj.wms.enums.TaskTypeEnum; |
|
|
|
|
import com.shkj.wms.utils.IntIdUtil; |
|
|
|
|
import com.shkj.wms.utils.JsonUtil; |
|
|
|
|
import com.shkj.wms.vo.PlanOrderLocationVo; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.ibatis.exceptions.TooManyResultsException; |
|
|
|
|
import org.mvel2.util.Make; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.*; |
|
|
|
|
|
|
|
|
|
@ -58,10 +73,7 @@ public class PlcEventTask { |
|
|
|
|
IWcsPlcPropertyService iWcsPlcPropertyService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
ISysParameterService isysParameterService; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
WcsPlcConnectMapper wcsPlcConnectMapper; |
|
|
|
|
IBusinDataTaskService iBusinDataTaskService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
@ -159,7 +171,7 @@ public class PlcEventTask { |
|
|
|
|
//根据连接的plcId获取属性
|
|
|
|
|
PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); |
|
|
|
|
Map<String, Object> pointMap = plcReadAndWrite.readPlcData(plcOperate, pointTables); |
|
|
|
|
log.info("连接的IP:"+conn.getPlcIp()+":设备:"+conn.getConnectName()+" 读取的点位内容:"+pointMap); |
|
|
|
|
log.info("连接的IP:" + conn.getPlcIp() + ":设备:" + conn.getConnectName() + " 读取的点位内容:" + pointMap); |
|
|
|
|
|
|
|
|
|
List<WcsPlcProperty> propertyList = (List<WcsPlcProperty>) redisTemplate.opsForValue().get(RedisConstant.redisPlcProperty + plcId); |
|
|
|
|
if (propertyList == null || propertyList.size() == 0) { |
|
|
|
|
@ -272,6 +284,23 @@ public class PlcEventTask { |
|
|
|
|
String retInOutSwitVt = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//空托上报请求序列号
|
|
|
|
|
String rptEySeria = ""; |
|
|
|
|
|
|
|
|
|
//空托上报条码
|
|
|
|
|
String rptEyBarcod = ""; |
|
|
|
|
|
|
|
|
|
//空托上报确认序列号
|
|
|
|
|
String retEyCfmSeria = ""; |
|
|
|
|
String retEyCfmSeriaVt = ""; |
|
|
|
|
|
|
|
|
|
//空托上报条码确认
|
|
|
|
|
String retEyCfmBarcod = ""; |
|
|
|
|
String retEyCfmBarcodVt = ""; |
|
|
|
|
|
|
|
|
|
//空托上报返回信息
|
|
|
|
|
String retEy = ""; |
|
|
|
|
String retEyVt = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WcsPlcProperty plcProperty : propertyList) { |
|
|
|
|
@ -331,16 +360,29 @@ public class PlcEventTask { |
|
|
|
|
} else if (pointType.equals("retOut1")) { |
|
|
|
|
retOut1 = plcProperty.getAddress(); |
|
|
|
|
retOutVt1 = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("rptEySeria")) { |
|
|
|
|
rptEySeria = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("rptEyBarcod")) { |
|
|
|
|
rptEyBarcod = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("retEyCfmSeria")) { |
|
|
|
|
retEyCfmSeria = plcProperty.getAddress(); |
|
|
|
|
retEyCfmSeriaVt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("retEyCfmBarcod")) { |
|
|
|
|
retEyCfmBarcod = plcProperty.getAddress(); |
|
|
|
|
retEyCfmBarcodVt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("retEy")) { |
|
|
|
|
retEy = plcProperty.getAddress(); |
|
|
|
|
retEyVt = plcProperty.getValueType(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//扫码处入库申请
|
|
|
|
|
//生产区扫码处入库申请
|
|
|
|
|
//&& Boolean.valueOf(pointMap.get(reqInSeria).toString())
|
|
|
|
|
if (pointMap.containsKey(reqInSeria) && !pointMap.get(reqInSeria).equals("0")) { |
|
|
|
|
//读取请求序列号内容
|
|
|
|
|
String bCR01SeriaV1 = Objects.toString(pointMap.get(reqInSeria), ""); |
|
|
|
|
Integer bCR01SeriaV = 0; |
|
|
|
|
if(!bCR01SeriaV1.isEmpty()){ |
|
|
|
|
if (!bCR01SeriaV1.isEmpty()) { |
|
|
|
|
bCR01SeriaV = Integer.parseInt(bCR01SeriaV1.toString()); |
|
|
|
|
} |
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
@ -349,11 +391,11 @@ public class PlcEventTask { |
|
|
|
|
log.info("扫码处入库申请时,读取的条码内容:" + s); |
|
|
|
|
//根据托盘条码返回正在执行的任务号
|
|
|
|
|
WcsIncomingTrayCheckBody body = new WcsIncomingTrayCheckBody(); |
|
|
|
|
body.setStation("SC-G1-00-00-1001"); |
|
|
|
|
body.setStation(MapEnum.oneIn.getValue()); |
|
|
|
|
body.setTaskType(TaskTypeEnum.In.getValue()); |
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.trayCheck.getValue()); |
|
|
|
|
body.setTrayCode(s); |
|
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
|
body.setCreateDt(getNowDate()); |
|
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTrayCheck(body); |
|
|
|
|
log.info("扫码处入库申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
@ -371,7 +413,7 @@ public class PlcEventTask { |
|
|
|
|
allMap.put(reqInDest, destMap); |
|
|
|
|
} else { |
|
|
|
|
Map<String, Integer> destMap = new HashMap<>(1); |
|
|
|
|
destMap.put(reqInDestVt, 1); |
|
|
|
|
destMap.put(reqInDestVt, 2); |
|
|
|
|
allMap.put(reqInDest, destMap); |
|
|
|
|
} |
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
@ -382,10 +424,10 @@ public class PlcEventTask { |
|
|
|
|
//空托盘申请
|
|
|
|
|
if (pointMap.containsKey(reqEmpty) && !pointMap.get(reqEmpty).equals("0")) { |
|
|
|
|
WcsIncomingTaskRequestBody body = new WcsIncomingTaskRequestBody(); |
|
|
|
|
body.setStation("SC-G1-00-00-1002"); |
|
|
|
|
body.setStation(MapEnum.oneOut.getValue()); |
|
|
|
|
body.setTaskType(TaskTypeEnum.Out.getValue()); |
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.stockOut.getValue()); |
|
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
|
body.setCreateDt(getNowDate()); |
|
|
|
|
//调用agv接口查询库区状态
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("areaInLocation", "SC-A2"); |
|
|
|
|
@ -396,15 +438,15 @@ public class PlcEventTask { |
|
|
|
|
map2.put("status", 1); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map3 = new HashMap<>(); |
|
|
|
|
map1.put("areaInLocation", "SC-C2"); |
|
|
|
|
map1.put("status", 1); |
|
|
|
|
map3.put("areaInLocation", "SC-C2"); |
|
|
|
|
map3.put("status", 1); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map4 = new HashMap<>(); |
|
|
|
|
map2.put("areaInLocation", "SC-D2"); |
|
|
|
|
map2.put("status", 1); |
|
|
|
|
map4.put("areaInLocation", "SC-D2"); |
|
|
|
|
map4.put("status", 1); |
|
|
|
|
|
|
|
|
|
Object[] areaStatus = new Object[] { map1,map2,map3,map4}; |
|
|
|
|
log.info("每个库区的状态:"+Arrays.toString(areaStatus)); |
|
|
|
|
Object[] areaStatus = new Object[]{map1, map2, map3, map4}; |
|
|
|
|
log.info("每个库区的状态:" + Arrays.toString(areaStatus)); |
|
|
|
|
body.setAreaStatus(areaStatus); |
|
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(body); |
|
|
|
|
log.info("空托申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
@ -428,7 +470,7 @@ public class PlcEventTask { |
|
|
|
|
//读取序列号
|
|
|
|
|
String IntegeroutSeria = Objects.toString(pointMap.get(rptOutSeria), ""); |
|
|
|
|
Integer outSeria = 0; |
|
|
|
|
if(!IntegeroutSeria.isEmpty()){ |
|
|
|
|
if (!IntegeroutSeria.isEmpty()) { |
|
|
|
|
outSeria = Integer.parseInt(IntegeroutSeria.toString()); |
|
|
|
|
} |
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
@ -437,11 +479,11 @@ public class PlcEventTask { |
|
|
|
|
log.info("实盘出口上报时,读取的条码内容:" + s); |
|
|
|
|
//调用wz-wcs接口
|
|
|
|
|
WcsIncomingTaskRequestBody body = new WcsIncomingTaskRequestBody(); |
|
|
|
|
body.setStation("SC-G2-00-00-2002"); |
|
|
|
|
body.setStation(MapEnum.twoDownIn.getValue()); |
|
|
|
|
body.setTaskType(TaskTypeEnum.In.getValue()); |
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.stockIn.getValue()); |
|
|
|
|
body.setTrayCode(s); |
|
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
|
body.setCreateDt(getNowDate()); |
|
|
|
|
//调用agv接口查询库区状态
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("areaInLocation", "SC-A2"); |
|
|
|
|
@ -459,11 +501,11 @@ public class PlcEventTask { |
|
|
|
|
map4.put("areaInLocation", "SC-D2"); |
|
|
|
|
map4.put("status", 1); |
|
|
|
|
|
|
|
|
|
Object[] areaStatus = new Object[] { map1,map2,map3,map4}; |
|
|
|
|
log.info("每个库区的状态:"+Arrays.toString(areaStatus)); |
|
|
|
|
Object[] areaStatus = new Object[]{map1, map2, map3, map4}; |
|
|
|
|
log.info("每个库区的状态:" + Arrays.toString(areaStatus)); |
|
|
|
|
body.setAreaStatus(areaStatus); |
|
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(body); |
|
|
|
|
log.info("agv扫码处申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
log.info("实盘出口上报wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> seriaMap = new HashMap<>(1); |
|
|
|
|
seriaMap.put(rptOutCfmSeriaVt, outSeria); |
|
|
|
|
@ -491,7 +533,7 @@ public class PlcEventTask { |
|
|
|
|
//读取序列号
|
|
|
|
|
String IntegeroutSeria = Objects.toString(pointMap.get(rptOutSeria1), ""); |
|
|
|
|
Integer outSeria = 0; |
|
|
|
|
if(!IntegeroutSeria.isEmpty()){ |
|
|
|
|
if (!IntegeroutSeria.isEmpty()) { |
|
|
|
|
outSeria = Integer.parseInt(IntegeroutSeria); |
|
|
|
|
} |
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
@ -501,11 +543,11 @@ public class PlcEventTask { |
|
|
|
|
log.info("实盘出口上报时,读取的条码内容:" + s); |
|
|
|
|
//调用wz-wcs接口
|
|
|
|
|
WcsIncomingTaskRequestBody body = new WcsIncomingTaskRequestBody(); |
|
|
|
|
body.setStation("SC-G2-00-00-2001"); |
|
|
|
|
body.setStation(MapEnum.twoUpIn.getValue()); |
|
|
|
|
body.setTaskType(TaskTypeEnum.In.getValue()); |
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.stockIn.getValue()); |
|
|
|
|
body.setTrayCode(s); |
|
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
|
body.setCreateDt(getNowDate()); |
|
|
|
|
//调用agv接口查询库区状态
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("areaInLocation", "SC-A2"); |
|
|
|
|
@ -523,8 +565,8 @@ public class PlcEventTask { |
|
|
|
|
map4.put("areaInLocation", "SC-D2"); |
|
|
|
|
map4.put("status", 1); |
|
|
|
|
|
|
|
|
|
Object[] areaStatus = new Object[] { map1,map2,map3,map4}; |
|
|
|
|
log.info("每个库区的状态:"+Arrays.toString(areaStatus)); |
|
|
|
|
Object[] areaStatus = new Object[]{map1, map2, map3, map4}; |
|
|
|
|
log.info("每个库区的状态:" + Arrays.toString(areaStatus)); |
|
|
|
|
body.setAreaStatus(areaStatus); |
|
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(body); |
|
|
|
|
log.info("agv扫码处申请wz-wcs返回:" + vo.getHeader()); |
|
|
|
|
@ -532,16 +574,12 @@ public class PlcEventTask { |
|
|
|
|
Map<String, Integer> seriaMap = new HashMap<>(1); |
|
|
|
|
seriaMap.put(rptOutCfmSeriaVt1, outSeria); |
|
|
|
|
allMap.put(rptOutCfmSeria1, seriaMap); |
|
|
|
|
|
|
|
|
|
// Map<String, String> barcodMap = new HashMap<>(1);
|
|
|
|
|
// barcodMap.put(rptOutCfmBarcodVt1, s);
|
|
|
|
|
// allMap.put(rptOutCfmBarcod1, barcodMap);
|
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
|
|
|
|
|
if (Result.isOk(vo.getHeader().getMsgCode())) { |
|
|
|
|
reqMap.put(retOutVt1, 1); |
|
|
|
|
} else { |
|
|
|
|
reqMap.put(retOutVt1, 1); |
|
|
|
|
reqMap.put(retOutVt1, 2); |
|
|
|
|
} |
|
|
|
|
allMap.put(retOut1, reqMap); |
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
@ -554,12 +592,13 @@ public class PlcEventTask { |
|
|
|
|
//出入库切换
|
|
|
|
|
if (pointMap.containsKey(inOutSwit) && !pointMap.get(inOutSwit).equals("0")) { |
|
|
|
|
WCSQueryTaskStatusBody body = new WCSQueryTaskStatusBody(); |
|
|
|
|
body.setDestination("SC-G1-00-00-1002"); |
|
|
|
|
body.setDestination(MapEnum.oneOut.getValue()); |
|
|
|
|
body.setTaskType("1"); |
|
|
|
|
body.setTrayType("2"); |
|
|
|
|
WcsResponseVo<TaskStatusBody> vo = JSON.parseObject( |
|
|
|
|
JSON.toJSONString(wcsUtil.queryTaskStatus(body)), |
|
|
|
|
new TypeReference<WcsResponseVo<TaskStatusBody>>() {} |
|
|
|
|
new TypeReference<WcsResponseVo<TaskStatusBody>>() { |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
Integer taskCount = vo.getBody().get(0).getTaskCount(); |
|
|
|
|
|
|
|
|
|
@ -581,6 +620,72 @@ public class PlcEventTask { |
|
|
|
|
log.info("出入库切换时,写入的命令返回结果:" + inOutSwitBoolean.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//空托上报完成
|
|
|
|
|
if (pointMap.containsKey(rptEySeria) && !pointMap.get(rptEySeria).equals("0")) { |
|
|
|
|
//读取序列号
|
|
|
|
|
String IntegeroutSeria = Objects.toString(pointMap.get(rptEySeria), ""); |
|
|
|
|
Integer outSeria = 0; |
|
|
|
|
if (!IntegeroutSeria.isEmpty()) { |
|
|
|
|
outSeria = Integer.parseInt(IntegeroutSeria); |
|
|
|
|
} |
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
String barcodeValueOne = Objects.toString(pointMap.get(rptEyBarcod), ""); |
|
|
|
|
String s = barcodeValueOne.replaceAll("[^A-Za-z0-9]", ""); |
|
|
|
|
|
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> seriaMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
|
|
|
|
|
log.info("空托上报完成时,读取的条码内容:" + s); |
|
|
|
|
if(!s.isEmpty()){ |
|
|
|
|
LambdaQueryWrapper<BusinDataTask> lqw = new LambdaQueryWrapper<BusinDataTask>().eq(BusinDataTask::getContainerCode,s) |
|
|
|
|
.eq(BusinDataTask::getTaskStatus,TaskStatusEnum.wait_callback.getValue()); |
|
|
|
|
BusinDataTask businDataTask = iBusinDataTaskService.getOne(lqw); |
|
|
|
|
if(businDataTask != null){ |
|
|
|
|
log.info("空托报完成任务号:"+ businDataTask.getTaskCode()); |
|
|
|
|
businDataTask.setTaskStatus(TaskStatusEnum.finished.getValue()); |
|
|
|
|
businDataTask.setDestination(MapEnum.oneOut.getValue()); |
|
|
|
|
businDataTask.setTaskEntime(new Date()); |
|
|
|
|
iBusinDataTaskService.updateById(businDataTask); |
|
|
|
|
UploadWCSTaskStatusDto uploadWCSTaskStatusDto = new UploadWCSTaskStatusDto(); |
|
|
|
|
WcsCreateTaskHeader header = new WcsCreateTaskHeader(); |
|
|
|
|
header.setBusinessType("stockOutReturn"); |
|
|
|
|
|
|
|
|
|
uploadWCSTaskStatusDto.setHeader(header); |
|
|
|
|
UploadWCSTaskStatusBody body = new UploadWCSTaskStatusBody(); |
|
|
|
|
List<UploadWCSTaskStatusBody> bodyList = new ArrayList<>(); |
|
|
|
|
body.setTaskId(businDataTask.getTaskCode()); |
|
|
|
|
body.setTrayCode(businDataTask.getContainerCode()); |
|
|
|
|
body.setTaskType(businDataTask.getTaskType()); |
|
|
|
|
body.setStatus(businDataTask.getTaskStatus()); |
|
|
|
|
body.setDestination(MapEnum.oneOut.getValue()); |
|
|
|
|
body.setMsgCode("200"); |
|
|
|
|
bodyList.add(body); |
|
|
|
|
uploadWCSTaskStatusDto.setBody(bodyList); |
|
|
|
|
log.info("空托任务状态上报请求zk-wcs参数{}", JSONObject.toJSONString(uploadWCSTaskStatusDto)); |
|
|
|
|
WcsResponseVo vo = wcsUtil.uploadWCSTaskStatus(uploadWCSTaskStatusDto); |
|
|
|
|
log.info("空托任务状态上报反馈:"+ JSONObject.toJSONString(vo)); |
|
|
|
|
if (Result.isOk(vo.getHeader().getMsgCode())) { |
|
|
|
|
reqMap.put(retEyVt, 1); |
|
|
|
|
} else { |
|
|
|
|
reqMap.put(retEyVt, 2); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
log.info("未查询到条码为:"+s+"未完成的任务"); |
|
|
|
|
reqMap.put(retEyVt, 2); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
reqMap.put(retEyVt, 2); |
|
|
|
|
} |
|
|
|
|
seriaMap.put(retEyCfmSeriaVt, outSeria); |
|
|
|
|
allMap.put(retEy, reqMap); |
|
|
|
|
allMap.put(retEyCfmSeria,seriaMap); |
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
log.info("空托上报完成时,给输送线写命令数据:{}", allMapJson); |
|
|
|
|
Boolean rptOutBoolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
log.info("空托上报完成时,写入的命令返回结果:" + rptOutBoolean.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("dpsRealTimeTask:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
@ -595,6 +700,22 @@ public class PlcEventTask { |
|
|
|
|
/** |
|
|
|
|
* 叠盘机 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//叠盘机请求序列号
|
|
|
|
|
String dpjSeria = ""; |
|
|
|
|
|
|
|
|
|
//叠盘机确认序列号
|
|
|
|
|
String retDpjCfmSeria = ""; |
|
|
|
|
String retDpjCfmSeriaVt = ""; |
|
|
|
|
|
|
|
|
|
//叠盘机请求条码
|
|
|
|
|
String dpjBarcod = ""; |
|
|
|
|
|
|
|
|
|
//叠盘机返回条码
|
|
|
|
|
String retDpjCfmBarcod = ""; |
|
|
|
|
String retDpjCfmBarcodVt = ""; |
|
|
|
|
|
|
|
|
|
//叠盘机完成
|
|
|
|
|
String dpj = ""; |
|
|
|
|
|
|
|
|
|
@ -602,6 +723,31 @@ public class PlcEventTask { |
|
|
|
|
String retDpj = ""; |
|
|
|
|
String retDpjVt = ""; |
|
|
|
|
|
|
|
|
|
//叠盘机返回
|
|
|
|
|
String retDpj1 = ""; |
|
|
|
|
String retDpj1Vt = ""; |
|
|
|
|
|
|
|
|
|
//请求叠盘工位1
|
|
|
|
|
String dpjGw1 = ""; |
|
|
|
|
|
|
|
|
|
//请求叠盘工位1返回
|
|
|
|
|
String retDpjGw1 = ""; |
|
|
|
|
String retDpjGw1Vt = ""; |
|
|
|
|
|
|
|
|
|
//请求叠盘工位2
|
|
|
|
|
String dpjGw2 = ""; |
|
|
|
|
|
|
|
|
|
//请求叠盘工位2返回
|
|
|
|
|
String retDpjGw2 = ""; |
|
|
|
|
String retDpjGw2Vt = ""; |
|
|
|
|
|
|
|
|
|
//请求叠盘工位3
|
|
|
|
|
String dpjGw3 = ""; |
|
|
|
|
|
|
|
|
|
//请求叠盘工位3返回
|
|
|
|
|
String retDpjGw3 = ""; |
|
|
|
|
String retDpjGw3Vt = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WcsPlcProperty plcProperty : propertyList) { |
|
|
|
|
String pointType = plcProperty.getPointType(); |
|
|
|
|
@ -611,18 +757,54 @@ public class PlcEventTask { |
|
|
|
|
} else if (pointType.equals("retDpj")) { |
|
|
|
|
retDpj = plcProperty.getAddress(); |
|
|
|
|
retDpjVt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("dpjSeria")) { |
|
|
|
|
dpjSeria = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("retDpjCfmSeria")) { |
|
|
|
|
retDpjCfmSeria = plcProperty.getAddress(); |
|
|
|
|
retDpjCfmSeriaVt = plcProperty.getValueType(); |
|
|
|
|
}else if (pointType.equals("dpjBarcod")) { |
|
|
|
|
dpjBarcod = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("retDpj1")) { |
|
|
|
|
retDpj1 = plcProperty.getAddress(); |
|
|
|
|
retDpj1Vt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("dpjGw1")) { |
|
|
|
|
dpjGw1 = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("retDpjGw1")) { |
|
|
|
|
retDpjGw1 = plcProperty.getAddress(); |
|
|
|
|
retDpjGw1Vt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("dpjGw2")) { |
|
|
|
|
dpjGw2 = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("retDpjGw2")) { |
|
|
|
|
retDpjGw2 = plcProperty.getAddress(); |
|
|
|
|
retDpjGw2Vt = plcProperty.getValueType(); |
|
|
|
|
} else if (pointType.equals("dpjGw3")) { |
|
|
|
|
dpjGw3 = plcProperty.getAddress(); |
|
|
|
|
} else if (pointType.equals("retDpjGw3")) { |
|
|
|
|
retDpjGw3 = plcProperty.getAddress(); |
|
|
|
|
retDpjGw3Vt = plcProperty.getValueType(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//叠盘机
|
|
|
|
|
if (pointMap.containsKey(dpj) && !pointMap.get(dpj).equals("0")) { |
|
|
|
|
if (pointMap.containsKey(dpjSeria) && !pointMap.get(dpjSeria).equals("0")) { |
|
|
|
|
|
|
|
|
|
//读取序列号
|
|
|
|
|
String IntegeroutSeria = Objects.toString(pointMap.get(dpjSeria), ""); |
|
|
|
|
Integer seria = 0; |
|
|
|
|
if (!IntegeroutSeria.isEmpty()) { |
|
|
|
|
seria = Integer.parseInt(IntegeroutSeria); |
|
|
|
|
} |
|
|
|
|
//读取托盘条码内容
|
|
|
|
|
String barcodeValueOne = Objects.toString(pointMap.get(dpjBarcod), ""); |
|
|
|
|
String s = barcodeValueOne.replaceAll("[^A-Za-z0-9]", ""); |
|
|
|
|
log.info("叠盘机入库请求读取的条码:"+ s); |
|
|
|
|
WcsIncomingTaskRequestBody body = new WcsIncomingTaskRequestBody(); |
|
|
|
|
body.setStation("SC-G2-00-00-2003"); |
|
|
|
|
body.setStation(MapEnum.dpj.getValue()); |
|
|
|
|
body.setTaskType(TaskTypeEnum.In.getValue()); |
|
|
|
|
body.setTrayCode("TP4077566601"); |
|
|
|
|
body.setTrayCode(s); |
|
|
|
|
body.setBussinessType(BusinTaskTypeEnum.stockIn.getValue()); |
|
|
|
|
body.setCreateDt(new Date().toString()); |
|
|
|
|
body.setCreateDt(getNowDate()); |
|
|
|
|
//调用agv接口查询库区状态
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("areaInLocation", "SC-A2"); |
|
|
|
|
@ -633,32 +815,193 @@ public class PlcEventTask { |
|
|
|
|
map2.put("status", 1); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map3 = new HashMap<>(); |
|
|
|
|
map1.put("areaInLocation", "SC-C2"); |
|
|
|
|
map1.put("status", 1); |
|
|
|
|
map3.put("areaInLocation", "SC-C2"); |
|
|
|
|
map3.put("status", 1); |
|
|
|
|
|
|
|
|
|
Map<String, Object> map4 = new HashMap<>(); |
|
|
|
|
map2.put("areaInLocation", "SC-D2"); |
|
|
|
|
map2.put("status", 1); |
|
|
|
|
map4.put("areaInLocation", "SC-D2"); |
|
|
|
|
map4.put("status", 1); |
|
|
|
|
|
|
|
|
|
Object[] areaStatus = new Object[] { map1,map2,map3,map4}; |
|
|
|
|
log.info("每个库区的状态:"+Arrays.toString(areaStatus)); |
|
|
|
|
Object[] areaStatus = new Object[]{map1, map2, map3, map4}; |
|
|
|
|
log.info("每个库区的状态:" + Arrays.toString(areaStatus)); |
|
|
|
|
body.setAreaStatus(areaStatus); |
|
|
|
|
WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(body); |
|
|
|
|
log.info("叠盘机满入库任务申请WZ-WCS返回:" + vo.getHeader()); |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> req1Map = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> seriaMap = new HashMap<>(1); |
|
|
|
|
seriaMap.put(retDpjCfmSeriaVt,seria); |
|
|
|
|
if (Result.isOk(vo.getHeader().getMsgCode())) { |
|
|
|
|
reqMap.put(retDpjVt, 1); |
|
|
|
|
req1Map.put(retDpj1Vt,1); |
|
|
|
|
} else { |
|
|
|
|
reqMap.put(retDpjVt, 2); |
|
|
|
|
req1Map.put(retDpj1Vt,2); |
|
|
|
|
} |
|
|
|
|
allMap.put(retDpj, reqMap); |
|
|
|
|
allMap.put(retDpj1, req1Map); |
|
|
|
|
allMap.put(retDpjCfmSeria,seriaMap); |
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
log.info("叠盘机叠满上报时,给输送线写命令数据:{}", allMapJson); |
|
|
|
|
Boolean bCR01Boolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
log.info("叠盘机叠满上报时,写入的命令返回结果:" + bCR01Boolean.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//叠盘机搬运1
|
|
|
|
|
if (pointMap.containsKey(dpjGw1) && !pointMap.get(dpjGw1).equals("0")) { |
|
|
|
|
BusinDataTask businDataTask; |
|
|
|
|
boolean save = true; |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
LambdaQueryWrapper<BusinDataTask> lqwTask = new LambdaQueryWrapper<BusinDataTask>() |
|
|
|
|
.eq(BusinDataTask::getFromSide,MapEnum.dpjGw1.getValue()) |
|
|
|
|
.eq(BusinDataTask::getTaskStatus,TaskStatusEnum.wait_put); |
|
|
|
|
businDataTask = iBusinDataTaskService.getOne(lqwTask); |
|
|
|
|
if(businDataTask != null){ |
|
|
|
|
log.info("还未下发的任务:"+businDataTask.getTaskCode()); |
|
|
|
|
}else{ |
|
|
|
|
String taskCode = IntIdUtil.generateIntId().toString(); |
|
|
|
|
businDataTask.setTaskCode(taskCode); |
|
|
|
|
businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue()); |
|
|
|
|
businDataTask.setTaskType(TaskTypeEnum.Carry.getValue()); |
|
|
|
|
businDataTask.setTaskPath(MapEnum.dpj.getValue()); |
|
|
|
|
businDataTask.setPriority("1"); |
|
|
|
|
businDataTask.setFromSide(MapEnum.dpjGw1.getValue()); |
|
|
|
|
businDataTask.setToSide(MapEnum.dpj.getValue()); |
|
|
|
|
businDataTask.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
businDataTask.setAgvType("B113"); |
|
|
|
|
save = iBusinDataTaskService.save(businDataTask); |
|
|
|
|
} |
|
|
|
|
if (!save) { |
|
|
|
|
log.info("叠盘工位1,任务存储失败!"); |
|
|
|
|
reqMap.put(retDpjGw1Vt, 2); |
|
|
|
|
allMap.put(retDpjGw1, reqMap); |
|
|
|
|
}else{ |
|
|
|
|
Result result = iBusinDataTaskService.rcsTaskIssued(businDataTask); |
|
|
|
|
if (!Result.isOk(result)) { |
|
|
|
|
log.info("叠盘工位1,给rcs下发任务失败!"); |
|
|
|
|
reqMap.put(retDpjGw1Vt, 2); |
|
|
|
|
allMap.put(retDpjGw1, reqMap); |
|
|
|
|
}else{ |
|
|
|
|
log.info("叠盘工位1,给rcs下发任务成功!"); |
|
|
|
|
reqMap.put(retDpjGw1Vt, 1); |
|
|
|
|
allMap.put(retDpjGw1, reqMap); |
|
|
|
|
businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); |
|
|
|
|
businDataTask.setTaskStarttime(DateUtils.getNowDate()); |
|
|
|
|
businDataTask.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
iBusinDataTaskService.updateById(businDataTask); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
log.info("叠盘工位1叠盘请求时,给输送线写命令数据:{}", allMapJson); |
|
|
|
|
Boolean bCR01Boolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
log.info("叠盘工位1叠盘请求时,写入的命令返回结果:" + bCR01Boolean.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//叠盘机搬运2
|
|
|
|
|
if (pointMap.containsKey(dpjGw2) && !pointMap.get(dpjGw2).equals("0")) { |
|
|
|
|
BusinDataTask businDataTask; |
|
|
|
|
boolean save = true; |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
LambdaQueryWrapper<BusinDataTask> lqwTask = new LambdaQueryWrapper<BusinDataTask>() |
|
|
|
|
.eq(BusinDataTask::getFromSide,MapEnum.dpjGw2.getValue()) |
|
|
|
|
.eq(BusinDataTask::getTaskStatus,TaskStatusEnum.wait_put); |
|
|
|
|
businDataTask = iBusinDataTaskService.getOne(lqwTask); |
|
|
|
|
if(businDataTask != null){ |
|
|
|
|
log.info("还未下发的任务:"+businDataTask.getTaskCode()); |
|
|
|
|
}else{ |
|
|
|
|
String taskCode = IntIdUtil.generateIntId().toString(); |
|
|
|
|
businDataTask.setTaskCode(taskCode); |
|
|
|
|
businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue()); |
|
|
|
|
businDataTask.setTaskType(TaskTypeEnum.Carry.getValue()); |
|
|
|
|
businDataTask.setTaskPath(MapEnum.dpj.getValue()); |
|
|
|
|
businDataTask.setPriority("1"); |
|
|
|
|
businDataTask.setFromSide(MapEnum.dpjGw2.getValue()); |
|
|
|
|
businDataTask.setToSide(MapEnum.dpj.getValue()); |
|
|
|
|
businDataTask.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
businDataTask.setAgvType("B113"); |
|
|
|
|
save = iBusinDataTaskService.save(businDataTask); |
|
|
|
|
} |
|
|
|
|
if (!save) { |
|
|
|
|
log.info("叠盘工位2,任务存储失败!"); |
|
|
|
|
reqMap.put(retDpjGw2Vt, 2); |
|
|
|
|
allMap.put(retDpjGw2, reqMap); |
|
|
|
|
}else{ |
|
|
|
|
Result result = iBusinDataTaskService.rcsTaskIssued(businDataTask); |
|
|
|
|
if (!Result.isOk(result)) { |
|
|
|
|
log.info("叠盘工位2,给rcs下发任务失败!"); |
|
|
|
|
reqMap.put(retDpjGw2Vt, 2); |
|
|
|
|
allMap.put(retDpjGw2, reqMap); |
|
|
|
|
}else{ |
|
|
|
|
log.info("叠盘工位2,给rcs下发任务成功!"); |
|
|
|
|
reqMap.put(retDpjGw2Vt, 1); |
|
|
|
|
allMap.put(retDpjGw2, reqMap); |
|
|
|
|
businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); |
|
|
|
|
businDataTask.setTaskStarttime(DateUtils.getNowDate()); |
|
|
|
|
businDataTask.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
iBusinDataTaskService.updateById(businDataTask); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
log.info("叠盘工位2叠盘请求时,给输送线写命令数据:{}", allMapJson); |
|
|
|
|
Boolean bCR01Boolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
log.info("叠盘工位2叠盘请求时,写入的命令返回结果:" + bCR01Boolean.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//叠盘机搬运3
|
|
|
|
|
if (pointMap.containsKey(dpjGw3) && !pointMap.get(dpjGw3).equals("0")) { |
|
|
|
|
BusinDataTask businDataTask; |
|
|
|
|
boolean save = true; |
|
|
|
|
Map<String, Object> allMap = new HashMap<>(1); |
|
|
|
|
Map<String, Integer> reqMap = new HashMap<>(1); |
|
|
|
|
LambdaQueryWrapper<BusinDataTask> lqwTask = new LambdaQueryWrapper<BusinDataTask>() |
|
|
|
|
.eq(BusinDataTask::getFromSide,MapEnum.dpjGw3.getValue()) |
|
|
|
|
.eq(BusinDataTask::getTaskStatus,TaskStatusEnum.wait_put); |
|
|
|
|
businDataTask = iBusinDataTaskService.getOne(lqwTask); |
|
|
|
|
if(businDataTask != null){ |
|
|
|
|
log.info("还未下发的任务:"+businDataTask.getTaskCode()); |
|
|
|
|
}else{ |
|
|
|
|
String taskCode = IntIdUtil.generateIntId().toString(); |
|
|
|
|
businDataTask.setTaskCode(taskCode); |
|
|
|
|
businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue()); |
|
|
|
|
businDataTask.setTaskType(TaskTypeEnum.Carry.getValue()); |
|
|
|
|
businDataTask.setTaskPath(MapEnum.dpj.getValue()); |
|
|
|
|
businDataTask.setPriority("1"); |
|
|
|
|
businDataTask.setFromSide(MapEnum.dpjGw3.getValue()); |
|
|
|
|
businDataTask.setToSide(MapEnum.dpj.getValue()); |
|
|
|
|
businDataTask.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
businDataTask.setAgvType("B113"); |
|
|
|
|
save = iBusinDataTaskService.save(businDataTask); |
|
|
|
|
} |
|
|
|
|
if (!save) { |
|
|
|
|
log.info("叠盘工位3,任务存储失败!"); |
|
|
|
|
reqMap.put(retDpjGw3Vt, 2); |
|
|
|
|
allMap.put(retDpjGw3, reqMap); |
|
|
|
|
}else{ |
|
|
|
|
Result result = iBusinDataTaskService.rcsTaskIssued(businDataTask); |
|
|
|
|
if (!Result.isOk(result)) { |
|
|
|
|
log.info("叠盘工位3,给rcs下发任务失败!"); |
|
|
|
|
reqMap.put(retDpjGw3Vt, 2); |
|
|
|
|
allMap.put(retDpjGw3, reqMap); |
|
|
|
|
}else{ |
|
|
|
|
log.info("叠盘工位3,给rcs下发任务成功!"); |
|
|
|
|
reqMap.put(retDpjGw3Vt, 1); |
|
|
|
|
allMap.put(retDpjGw3, reqMap); |
|
|
|
|
businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); |
|
|
|
|
businDataTask.setTaskStarttime(DateUtils.getNowDate()); |
|
|
|
|
businDataTask.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
iBusinDataTaskService.updateById(businDataTask); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String allMapJson = JsonUtil.toJSONString(allMap); |
|
|
|
|
log.info("叠盘工位3叠盘请求时,给输送线写命令数据:{}", allMapJson); |
|
|
|
|
Boolean bCR01Boolean = plcReadAndWrite.execWrite(plcOperate, allMapJson); |
|
|
|
|
log.info("叠盘工位3叠盘请求时,写入的命令返回结果:" + bCR01Boolean.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("dpsRealTimeTask:" + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
@ -667,6 +1010,14 @@ public class PlcEventTask { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getNowDate() { |
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); |
|
|
|
|
return LocalDateTime.now().format(formatter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 单个的plc写入 |
|
|
|
|
*/ |
|
|
|
|
|