| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | |
| | | private MainProcessTaskSubmitter mainProcessTaskSubmitter; |
| | | |
| | | private static final String CRN_OUT_REQUIRE_STATION_OUT_ENABLE_CONFIG = "crnOutRequireStationOutEnable"; |
| | | |
| | | public synchronized void crnIoExecute() { |
| | | List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | crnIoExecute(basCrnp); |
| | | } |
| | | } |
| | | |
| | | public void crnIoExecute(BasCrnp basCrnp) { |
| | | if (basCrnp == null || basCrnp.getCrnNo() == null) { |
| | |
| | | if (wrkMast.getWrkSts() != null && wrkMast.getWrkSts() == WrkStsType.INBOUND_STATION_RUN_COMPLETE.sts) { |
| | | boolean result = this.crnExecuteInPlanner(currentCrn, crnThread, wrkMast); |
| | | if (result) { |
| | | crnProtocol.setLastIo("O"); |
| | | crnProtocol.setLastIo("I"); |
| | | return; |
| | | } |
| | | continue; |
| | |
| | | if (wrkMast.getWrkSts() != null && wrkMast.getWrkSts() == WrkStsType.NEW_OUTBOUND.sts) { |
| | | boolean result = this.crnExecuteOutPlanner(currentCrn, crnThread, wrkMast); |
| | | if (result) { |
| | | crnProtocol.setLastIo("I"); |
| | | crnProtocol.setLastIo("O"); |
| | | return; |
| | | } |
| | | continue; |
| | |
| | | } |
| | | |
| | | if (!allowBatchOutboundExecute(wrkMast, true)) { |
| | | return false; |
| | | } |
| | | |
| | | //检查是否为出库模式 |
| | | if(!checkOutTargetStationIoMode(wrkMast)) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | //检查是否为出库模式 |
| | | private boolean checkOutTargetStationIoMode(WrkMast wrkMast) { |
| | | if (wrkMast == null || wrkMast.getStaNo() == null) { |
| | | return false; |
| | | } |
| | | BasStation basStation = basStationService.getById(wrkMast.getStaNo()); |
| | | if (basStation == null) { |
| | | return false; |
| | | } |
| | | |
| | | StationThread targetStationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo()); |
| | | if (targetStationThread == null) { |
| | | return false; |
| | | } |
| | | |
| | | StationProtocol targetStationProtocol = targetStationThread.getStatusMap().get(wrkMast.getStaNo()); |
| | | if (targetStationProtocol == null) { |
| | | return false; |
| | | } |
| | | |
| | | if (targetStationProtocol.getIoMode() == 2) { |
| | | return true;//出库模式 |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private int getSystemConfigInt(String code, int defaultValue) { |
| | | Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key); |
| | | if (systemConfigMapObj == null) { |
| | |
| | | return defaultValue; |
| | | } |
| | | |
| | | //堆垛机任务执行完成 |
| | | public synchronized void crnIoExecuteFinish() { |
| | | List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | crnIoExecuteFinish(basCrnp); |
| | | } |
| | | } |
| | | |
| | | public void crnIoExecuteFinish(BasCrnp basCrnp) { |
| | | if (basCrnp == null || basCrnp.getCrnNo() == null) { |
| | | return; |
| | |
| | | }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){ |
| | | updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts; |
| | | notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_COMPLETE, null); |
| | | |
| | | List<StationObjModel> outStationList = basCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("堆垛机:{} 出库站点未设置", basCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | StationObjModel outStationObjModel = null; |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) { |
| | | outStationObjModel = stationObjModel; |
| | | break; |
| | | } |
| | | } |
| | | redisUtil.set(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24); |
| | | }else if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){ |
| | | updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts; |
| | | notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_COMPLETE, null); |
| | |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock",10); |
| | | } |
| | | } |
| | | |
| | | public synchronized void plannerExecute() { |
| | | List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | plannerExecute(basCrnp); |
| | | } |
| | | } |
| | | |