diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index 7dd8315..1cf4d63 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -614,6 +614,7 @@ public class EnergyController extends BaseController { carbonActVo.setValue(parGasValue.getActualNitPotValue()); carbonActVo.setUnit("%"); carbonActVo.setName("碳/氮势"); + carbonActVo.setTime(parGasValue.getCreateTime()); carbonActVo.setCode(currTask.getStoveCode()); carbon.add(carbonActVo); @@ -681,6 +682,7 @@ public class EnergyController extends BaseController { carbonActVo.setValue(parGasValue.getActualNitPotValue()); carbonActVo.setUnit("%"); carbonActVo.setName("碳/氮势"); + carbonActVo.setTime(parGasValue.getCreateTime()); carbonActVo.setCode(currTask.getStoveCode()); carbon.add(carbonActVo); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java index 8b63836..35e96aa 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java @@ -79,6 +79,10 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService CurrTaskDetServiceBiz currTaskDetServiceBiz; @Autowired InStockInfoServiceBiz inStockInfoServiceBiz; + @Autowired + TaskDetHisServiceBiz taskDetHisServiceBiz; + @Autowired + TaskHisServiceBiz taskHisServiceBiz; private Logger logger = LoggerFactory.getLogger(getClass()); @Override @@ -390,6 +394,13 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService if (!status.equals(currTask.getStatus())) { //修改为加工中,多步骤任务修改为加工中,查询缓存区,查询前置任务状态,并修改 if (status == 1) { + currTask.setStatus(1); + currTask.setIsIn(1); + currTask.setUpdaterId(99); + currTask.setUpdateTime(LocalDateTime.now()); + currTask.setBeginTime(LocalDateTime.now()); + //生产炉号 + createStoveCode(currTask); InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.TASK_ID, currTask.getId())); if (inStockInfo != null) { //更新库位状态为未占用 @@ -420,6 +431,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTask1.setUpdaterId(99); currTask1.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask1); + apmsEndProcess(currTask1); + apmsStartProcess(currTask); } else if (currTask.getId().equals(autoExeTask.getThTaskId())) { //该任务为自动任务第三条,修改自动任务第二条的状态 CurrTask currTask2 = currTaskServiceBiz.getById(autoExeTask.getFTaskId()); @@ -429,15 +442,11 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTask2.setUpdaterId(99); currTask2.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask2); + apmsEndProcess(currTask2); + apmsStartProcess(currTask); } } - currTask.setStatus(1); - currTask.setIsIn(1); - currTask.setUpdaterId(99); - currTask.setUpdateTime(LocalDateTime.now()); - currTask.setBeginTime(LocalDateTime.now()); - //生产炉号 - createStoveCode(currTask); + currTaskServiceBiz.updateById(currTask); logger.info("修改任务" + currTask.getId() + "状态为加工中成功"); } @@ -451,12 +460,23 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService locationServiceBiz.updateById(location); //删除库位缓存 inStockInfoServiceBiz.removeById(inStockInfo); + } currTask.setStatus(1); currTask.setCreatorId(99); currTask.setBeginTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); logger.info("修改任务" + currTask.getId() + "状态为加工完成成功"); + //存入历史任务表以便查询能源消耗 + TaskHis taskHis = new TaskHis(); + org.springframework.beans.BeanUtils.copyProperties(currTask, taskHis); + taskHis.setStatus(2); + taskHis.setIsIn(2); + taskHis.setTaskId(currTask.getId()); + taskHisServiceBiz.save(taskHis); + List currTaskDets = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask.getId())); + List taskDetHisList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDets, TaskDetHis.class); + taskDetHisServiceBiz.saveBatch(taskDetHisList); } currTask.setStatus(status); currTask.setCreatorId(99); @@ -682,6 +702,9 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService if (currTask.getStatus() != 0) { return R.failed("该任务状态不为未执行,无法执行!"); } + if (currTask.getCacheSatatus()==2||currTask.getIsCache()==1){ + return R.failed("该任务已在缓存队列,状态不为未执行,无法执行!"); + } //是否为自动任务 if (currTask.getIsAuto() == 1) { List exeTaskList = autoExeTaskServiceBiz.list(new QueryWrapper().eq(AutoExeTask.F_TASK_ID, taskId)); @@ -781,6 +804,55 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService return true; } } + /** + * 上报apms开始加工 + * + * @param currTask + * @return + */ + private Boolean apmsStartProcess(CurrTask currTask) { + String code = kilnInfoServiceBiz.getById(currTask.getKilnId()).getCode(); + ApmsStartProcess apmsStartProcess = new ApmsStartProcess(); + apmsStartProcess.setStartUser("QJJP03"); + apmsStartProcess.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsStartProcess.setTechName(currTask.getCraftCodeId().toString()); + apmsStartProcess.setSheetNo(currTask.getSheetNo()); + if (currTask.getStoveCode() != null) { + apmsStartProcess.setStoveCode(currTask.getStoveCode()); + } + + R apmsStartProcessR = apmsControl.startProcess(apmsStartProcess); + if (apmsStartProcessR.getCode() != 0) { + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms失败"); + return false; + } + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms成功"); + return true; + } + + /** + * 上报apms-end + * + * @param currTask + * @return + */ + private Boolean apmsEndProcess(CurrTask currTask) { + ApmsEndProcess apmsEndProcess = new ApmsEndProcess(); + LocalDateTime date=LocalDateTime.now(); + if (currTask.getEndTime()!=null){ + date=currTask.getEndTime(); + } + apmsEndProcess.setEndTime(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsEndProcess.setEndUser("QJJP03"); + apmsEndProcess.setSheetNo(currTask.getSheetNo()); + R apmsEndProcessVoR = apmsControl.endProcess(apmsEndProcess); + if (apmsEndProcessVoR.getCode() != 0) { + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms失败"); + return false; + } + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms成功"); + return true; + } /** * 生成炉号 * 多步骤任务除了第一步为清洗炉外,每步都生成炉号 diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java index b9fa907..64c028f 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java @@ -119,6 +119,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic .like(StringUtils.isNotBlank(param.getOrderNo()), OrderInfo.ORDER_NO, param.getOrderNo()) .like(StringUtils.isNotBlank(param.getCustomerName()),OrderInfo.CUSTOMER_NAME,param.getCustomerName()) .in(OrderInfo.STATUS,0,1) + .eq(OrderInfo.ORDER_VOID,1) .orderByDesc(OrderInfo.CREATE_TIME); Page page = orderInfoService.page(new Page<>(param.getCurrent(), param.getSize()), wrapper); PageVo orderInfoVoPageVo = new PageVo<>(page, OrderInfoVo.class); @@ -219,7 +220,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic @Override public R getTaskInfoByIdenCardNum(String idenCardNum) { QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(OrderInfo.IDEN_CARD_NUM, idenCardNum).eq(OrderInfo.VALID, 1); + wrapper.eq(OrderInfo.IDEN_CARD_NUM, idenCardNum).eq(OrderInfo.VALID, 1).eq(OrderInfo.ORDER_VOID,1); OrderInfo one = orderInfoService.getOne(wrapper); Assert.notNull("未找到该标识卡信息!", one); OrderInfoVo build = OrderInfoVo.builder().build(); @@ -261,7 +262,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic for (TaskCreateDetParam detParam : detParams) { QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(OrderInfo.IDEN_CARD_NUM, detParam.getIdenCardNum()).eq(OrderInfo.VALID, 1); + wrapper.eq(OrderInfo.IDEN_CARD_NUM, detParam.getIdenCardNum()).eq(OrderInfo.VALID, 1).eq(OrderInfo.ORDER_VOID,1); OrderInfo one = orderInfoService.getOne(wrapper); Assert.notNull("错误,标识卡号" + detParam.getIdenCardNum() + "在订单中不存在!", one); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index c768666..52e101f 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -507,15 +507,15 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, kilnInfo.getCode(), yeyaTaiCode, rgv2CurrPosition); if (conflictBoolean) { - Integer status = moveRgv(2, 1L, 2, 0); + Integer status = moveRgv(2, 1L, 1, 0); logger.info(status.toString()); if (status != 1) { - logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行失败==="); + logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行失败==="); // 2022/3/6 websocket通知页面 webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行失败"); } else { - logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行成功==="); + logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行成功==="); } } } else { @@ -606,14 +606,14 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, location.getCode(), yeyaTaiCode, rgv2CurrPosition); if (conflictBoolean) { - Integer status = moveRgv(2, 1L, 2, 0); + Integer status = moveRgv(2, 1L, 1, 0); if (status != 1) { - logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位39,执行失败==="); + logger.info("===执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1,执行失败==="); // 2022/3/6 websocket通知页面 webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位39,执行失败"); return; } - logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位39,执行成功==="); + logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1,执行成功==="); } } else { logger.info("RGV2不在线,跳过检测是否避让。"); @@ -629,12 +629,12 @@ public class AsynRunTaskService extends BaseService { if (conflictBoolean) { Integer status = moveRgv(1, 1L, 12, 0); if (status != 1) { - logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1,执行失败==="); + logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位12,执行失败==="); // 2022/3/6 websocket通知页面 webSocketServer.sendtoAll(LocalDateTime.now() + "执行出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1,执行失败"); return; } - logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位1,执行成功==="); + logger.info("===执行任务出库任务时车辆位置冲突,执行车辆位移任务,车辆" + vehicleId + "移动到点位12,执行成功==="); } } else { logger.info("RGV1不在线,跳过检测是否避让。"); @@ -1331,8 +1331,12 @@ public class AsynRunTaskService extends BaseService { * @return */ private Boolean apmsEndProcess(CurrTask currTask) { + LocalDateTime date=LocalDateTime.now(); + if (currTask.getEndTime()!=null){ + date=currTask.getEndTime(); + } ApmsEndProcess apmsEndProcess = new ApmsEndProcess(); - apmsEndProcess.setEndTime(currTask.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsEndProcess.setEndTime(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); apmsEndProcess.setEndUser("QJJP03"); apmsEndProcess.setSheetNo(currTask.getSheetNo()); R apmsEndProcessVoR = apmsController.endProcess(apmsEndProcess); @@ -1424,13 +1428,13 @@ public class AsynRunTaskService extends BaseService { //两辆小车是否冲突 Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, startPosition, targetPosition, rgv2CurrPosition); if (conflictBoolean) { - Integer status = moveRgv(2, currTaskId, 2, 0); + Integer status = moveRgv(2, currTaskId, 1, 0); logger.info(status.toString()); if (status != 1) { - logger.info("===执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行失败==="); + logger.info("===执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行失败==="); webSocketServer.sendtoAll(LocalDateTime.now() + "执行任务:" + currTask.getTaskCode() + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行失败"); } else { - logger.info("===执行任务:" + currTaskId + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位2,执行成功==="); + logger.info("===执行任务:" + currTaskId + " 时车辆位置冲突,执行车辆位移任务,车辆" + anotherVehicleId + "移动到点位1,执行成功==="); } } } else { diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index f1abf68..617ac2a 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -12,6 +12,9 @@ import com.mt.wms.core.utils.CodeGeneratorHelper; import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.utils.StringUtils; import com.mt.wms.core.vo.R; +import com.mt.wms.empty.controller.ApmsController; +import com.mt.wms.empty.params.ApmsEndProcess; +import com.mt.wms.empty.vo.ApmsEndProcessVo; import com.mt.wms.empty.vo.CurrTaskDetVo; import com.mt.wms.empty.vo.NowCurrTaskDetVo; import com.mt.wms.empty.websocket.WebSocketServer; @@ -25,6 +28,7 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.io.IOException; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -81,6 +85,8 @@ public class ScheduledTask extends BaseService { private TaskHisServiceBiz taskHisServiceBiz; @Resource private TaskDetHisServiceBiz taskDetHisServiceBiz; + @Resource + private ApmsController apmsController; //@Scheduled(fixedDelay = 1000*20) @@ -243,6 +249,8 @@ public class ScheduledTask extends BaseService { taskDetHisServiceBiz.saveBatch(taskDetHisList); //加工结束而没有立马出炉,加工结束记录能源消耗值只记录一次 asynRunTaskService.asynEndRecordConsume(currTask.getId(), kilnId); + apmsEndProcess(currTask); + logger.info(currTask+"上报apms结束当前工艺加工"); logger.info(kilnInfo.getCode() + "炉子中的任务:" + currTask.getId() + "已加工结束,记录加工结束能源消耗值"); } runTaskUtils.runTaskForOutKiln(kilnId); @@ -585,6 +593,9 @@ public class ScheduledTask extends BaseService { if (vehicleInfos.size() > 0) { return; } + if (kilnStopRecTask(kilnInfo.getId())){ + continue; + } Boolean kilnReadyIn = false; if (kilnInfo.getType() == 1) { kilnReadyIn = kilnReadyIn(kilnInfo.getId()); @@ -792,6 +803,15 @@ public class ScheduledTask extends BaseService { return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); } + private Boolean kilnStopRecTask(Long kilnId) { + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId) + .eq(PlcNameSpace.TYPE, 0)); + String nameSpaceNote = nameSpace.getName(); + String result = readPlcToString(nameSpaceNote, "StopRecTask"); + return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + } private Boolean kilnReadyIn(Long kilnId) { PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() .eq(PlcNameSpace.EQ_TYPE, 0) @@ -871,4 +891,27 @@ public class ScheduledTask extends BaseService { Boolean free = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); return free; } + /** + * 上报apms-end + * + * @param currTask + * @return + */ + private Boolean apmsEndProcess(CurrTask currTask) { + LocalDateTime date=LocalDateTime.now(); + if (currTask.getEndTime()!=null){ + date=currTask.getEndTime(); + } + ApmsEndProcess apmsEndProcess = new ApmsEndProcess(); + apmsEndProcess.setEndTime(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsEndProcess.setEndUser("QJJP03"); + apmsEndProcess.setSheetNo(currTask.getSheetNo()); + R apmsEndProcessVoR = apmsController.endProcess(apmsEndProcess); + if (apmsEndProcessVoR.getCode() != 0) { + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms失败"); + return false; + } + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单完成处理上报apms成功"); + return true; + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java index d00341f..978ae9d 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/TaskDistanceUtils.java @@ -121,10 +121,10 @@ public class TaskDistanceUtils { if (otherNowPosition>=minDistance&&otherNowPosition<=maxDistance){ return true; }else { - if (Math.abs(otherNowPosition-maxDistance)<3.5){ + if (Math.abs(otherNowPosition-maxDistance)<4){ return true; } - if (Math.abs(otherNowPosition-minDistance)<3.5){ + if (Math.abs(otherNowPosition-minDistance)<4){ return true; } return false;