| | |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.entity.FindCrnNoResult; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.RedisUtil; |
| | |
| | | } |
| | | |
| | | Integer crnNo = basDualCrnp.getCrnNo(); |
| | | int station = calcStation(dualCrnProtocol, "in"); |
| | | if (station == 0) { |
| | | News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo()); |
| | | return false; |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) { |
| | | return false; |
| | |
| | | inStationObjModel = stationObjModel; |
| | | break; |
| | | } |
| | | |
| | | StationObjModel dualCrnSlaveStationObjModel = stationObjModel.getDualCrnSlaveStation(); |
| | | if (dualCrnSlaveStationObjModel == null) { |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol slaveStationProtocol = stationProtocolMap.get(dualCrnSlaveStationObjModel.getStationId()); |
| | | if (slaveStationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!slaveStationProtocol.isAutoing()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!slaveStationProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | |
| | | if (slaveStationProtocol.getTaskNo() <= 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (slaveStationProtocol.getTaskNo().equals(wrkMast.getWrkNo())) { |
| | | inStationObjModel = dualCrnSlaveStationObjModel; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (inStationObjModel == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "未搜索到取货站点"); |
| | | return false; |
| | | } |
| | | |
| | | Integer station = inStationObjModel.getDualCrnExecuteStation(); |
| | | if (station == 1) { |
| | | List<Integer> basList = basDualCrnp.getDisableStationOneBays$(); |
| | | if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) { |
| | | //禁止放货列,申请重新分配 |
| | | reassignTaskLocNo(wrkMast, inStationObjModel); |
| | | return false; |
| | | } |
| | | }else { |
| | | List<Integer> basList = basDualCrnp.getDisableStationTwoBays$(); |
| | | if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) { |
| | | //禁止放货列,申请重新分配 |
| | | reassignTaskLocNo(wrkMast, inStationObjModel); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | String sourceLocNo = Utils.getLocNo(inStationObjModel.getDeviceRow(), inStationObjModel.getDeviceBay(), inStationObjModel.getDeviceLev()); |
| | |
| | | return false; |
| | | } |
| | | |
| | | List<StationObjModel> enableUseStationList = new ArrayList<>(); |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) { |
| | | continue; |
| | | } |
| | | |
| | | if(stationObjModel.getDualCrnExecuteStation().equals(station)) { |
| | | enableUseStationList.add(stationObjModel); |
| | | } |
| | | |
| | | StationObjModel dualCrnSlaveStation = stationObjModel.getDualCrnSlaveStation(); |
| | | if(dualCrnSlaveStation != null) { |
| | | if (dualCrnSlaveStation.getDualCrnExecuteStation().equals(station)) { |
| | | enableUseStationList.add(stationObjModel); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : enableUseStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | |
| | | } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts) { |
| | | updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts; |
| | | notifyUtils.notify(String.valueOf(SlaveType.DualCrn), basDualCrnp.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_COMPLETE, null); |
| | | |
| | | |
| | | List<StationObjModel> outStationList = basDualCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | StationObjModel outStationObjModel = null; |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) { |
| | | outStationObjModel = stationObjModel; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (outStationObjModel == null) { |
| | | News.info("双工位堆垛机:{} 未找到匹配的任务出库站", basDualCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | if (station == 1) { |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24); |
| | | }else { |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel.getDualCrnSlaveStation(), SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24); |
| | | } |
| | | |
| | | if(mainProcessPlugin.contains("Fake")) { |
| | | //生成仿真站点数据 |
| | | List<StationObjModel> outStationList = basDualCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) { |
| | | continue; |
| | |
| | | return 0; |
| | | } |
| | | |
| | | private boolean reassignTaskLocNo(WrkMast wrkMast, StationObjModel stationObjModel) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | return false; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null) { |
| | | return false; |
| | | } |
| | | |
| | | String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationObjModel.getStationId()); |
| | | if (response == null) { |
| | | News.taskError(wrkMast.getWrkNo(), "请求WMS重新分配入库库位接口失败,接口未响应!!!response:{}", response); |
| | | return false; |
| | | } |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | String sourceLocNo = wrkMast.getLocNo(); |
| | | String locNo = dto.getLocNo(); |
| | | |
| | | LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo); |
| | | if (sourceLocMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位信息不存在", sourceLocNo); |
| | | return false; |
| | | } |
| | | |
| | | if (!sourceLocMast.getLocSts().equals("S")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位状态不处于入库预约", sourceLocNo); |
| | | return false; |
| | | } |
| | | |
| | | LocMast locMast = locMastService.queryByLoc(locNo); |
| | | if (locMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位信息不存在", locNo); |
| | | return false; |
| | | } |
| | | |
| | | if (!locMast.getLocSts().equals("O")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位状态不处于空库位", locNo); |
| | | return false; |
| | | } |
| | | //更新源库位 |
| | | sourceLocMast.setLocSts("O"); |
| | | sourceLocMast.setModiTime(new Date()); |
| | | locMastService.updateById(sourceLocMast); |
| | | |
| | | //更新目标库位 |
| | | locMast.setLocSts("S"); |
| | | locMast.setModiTime(new Date()); |
| | | locMastService.updateById(locMast); |
| | | |
| | | //更新工作档数据 |
| | | wrkMast.setLocNo(locNo); |
| | | wrkMastService.updateById(wrkMast); |
| | | return true; |
| | | } else { |
| | | News.error("请求WMS更换双工位库位接口失败!!!response:{}", response); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |