| | |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.mapper.BasCrnErrorMapper; |
| | | import com.zy.asrs.mapper.BasDevpMapper; |
| | | import com.zy.asrs.mapper.WrkChargeMapper; |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.LocTypeDto; |
| | |
| | | private WrkChargeMapper wrkChargeMapper; |
| | | @Autowired |
| | | private BasDevpMapper basDevpMapper; |
| | | @Autowired |
| | | private WaitPakinMapper waitPakinMapper; |
| | | |
| | | /** |
| | | * 组托 |
| | |
| | | && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999)) |
| | | && staProtocol.isPakMk()) { |
| | | |
| | | //20230201. 2号堆垛机有出库任务时,禁止新板入库 |
| | | if (staProtocol.getWorkNo() == 9995) { |
| | | if ( inSta.getStaNo()==103 && devpThread.ioModeOf1F == IoModeType.PAKOUT_MODE) { |
| | | //有出库任务,退库到入库口 |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo((short)100); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | News.error("MainServiceImpl generateStoreWrkFile"+"103为出库模式,禁止入库,退回入库口。!!!"); |
| | | continue; |
| | | } |
| | | if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { |
| | | //有出库任务,退库到入库口 |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo((short)200); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | News.error("MainServiceImpl generateStoreWrkFile"+"203为出库模式,禁止入库,退回入库口。!!!"); |
| | | continue; |
| | | } |
| | | if ( inSta.getStaNo()==113 && devpThread.ioModeOf3F == IoModeType.PAKOUT_MODE) { |
| | | //有出库任务,退库到入库口 |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo((short)114); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | News.error("MainServiceImpl generateStoreWrkFile"+"103为出库模式,禁止入库,退回入库口。!!!"); |
| | | continue; |
| | | } |
| | | if ( inSta.getStaNo()==213 && devpThread.ioModeOf4F == IoModeType.PAKOUT_MODE) { |
| | | //有出库任务,退库到入库口 |
| | | staProtocol.setWorkNo((short) 9999); |
| | | staProtocol.setStaNo((short)214); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | News.error("MainServiceImpl generateStoreWrkFile"+"203为出库模式,禁止入库,退回入库口。!!!"); |
| | | continue; |
| | | } |
| | | } |
| | | // //20230201. 2号堆垛机有出库任务时,禁止新板入库 |
| | | // if (staProtocol.getWorkNo() == 9995) { |
| | | // if ( inSta.getStaNo()==103 && devpThread.ioModeOf1F == IoModeType.PAKOUT_MODE) { |
| | | // //有出库任务,退库到入库口 |
| | | // staProtocol.setWorkNo((short) 9999); |
| | | // staProtocol.setStaNo((short)100); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // News.error("MainServiceImpl generateStoreWrkFile"+"103为出库模式,禁止入库,退回入库口。!!!"); |
| | | // continue; |
| | | // } |
| | | // if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { |
| | | // //有出库任务,退库到入库口 |
| | | // staProtocol.setWorkNo((short) 9999); |
| | | // staProtocol.setStaNo((short)200); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // News.error("MainServiceImpl generateStoreWrkFile"+"203为出库模式,禁止入库,退回入库口。!!!"); |
| | | // continue; |
| | | // } |
| | | // if ( inSta.getStaNo()==113 && devpThread.ioModeOf3F == IoModeType.PAKOUT_MODE) { |
| | | // //有出库任务,退库到入库口 |
| | | // staProtocol.setWorkNo((short) 9999); |
| | | // staProtocol.setStaNo((short)114); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // News.error("MainServiceImpl generateStoreWrkFile"+"103为出库模式,禁止入库,退回入库口。!!!"); |
| | | // continue; |
| | | // } |
| | | // if ( inSta.getStaNo()==213 && devpThread.ioModeOf4F == IoModeType.PAKOUT_MODE) { |
| | | // //有出库任务,退库到入库口 |
| | | // staProtocol.setWorkNo((short) 9999); |
| | | // staProtocol.setStaNo((short)214); |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // News.error("MainServiceImpl generateStoreWrkFile"+"203为出库模式,禁止入库,退回入库口。!!!"); |
| | | // continue; |
| | | // } |
| | | // } |
| | | |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } else if (code == 500){ |
| | | if (ledThread != null) { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | | if (!Cools.isEmpty(errorMsg)) { |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } |
| | | News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | // } else if (code == 500){ |
| | | // if (ledThread != null) { |
| | | // String errorMsg = jsonObject.getString("msg"); |
| | | // if (!Cools.isEmpty(errorMsg)) { |
| | | // MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | // } |
| | | // } |
| | | // News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } else if (code == 700) { |
| | | staProtocol.setWorkNo((short) 9995); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | |
| | | String errorMsg = barcode + "托盘识别异常,请先进行组托!"; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } else if (code == 1000){ |
| | | } else if (code == 500 || code == 1000){ |
| | | if (inSta.getStaNo().equals(103)){ |
| | | staProtocol.setWorkNo((short)9996); |
| | | staProtocol.setStaNo((short)203); |
| | | }else { |
| | | } |
| | | if (inSta.getStaNo().equals(203)){ |
| | | staProtocol.setWorkNo((short)9996); |
| | | staProtocol.setStaNo((short)103); |
| | | }if (inSta.getStaNo().equals(113)){ |
| | | staProtocol.setWorkNo((short)9995); |
| | | staProtocol.setStaNo((short)114); |
| | | }else if (inSta.getStaNo().equals(213)){ |
| | | staProtocol.setWorkNo((short)9995); |
| | | staProtocol.setStaNo((short)214); |
| | | } |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg = barcode + "需要换入库站。目标站:"+staProtocol.getStaNo(); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | String data = jsonObject.getString("data"); |
| | | String msg = jsonObject.getString("msg"); |
| | | if (code == 500){ |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg ="入库站:" + staProtocol.getStaNo() + "---" + barcode + "检索库位失败,请检查库存剩余。===>>" + data + "--" + msg; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } else if (code == 1000){ |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | | String errorMsg ="入库站:" + staProtocol.getStaNo() + "---" + barcode + "需要换入库站。"; |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | if(flag){ |
| | | return false; |
| | | continue; |
| | | // return false; |
| | | } |
| | | |
| | | // 判断是否已存在小车绑定任务 |
| | |
| | | } else { |
| | | List<String> shallowLocs = Utils.getShallowLocs(wrkMast.getSourceLocNo()); |
| | | if (!Cools.isEmpty(shallowLocs)) { |
| | | // 浅库位组有货 |
| | | for (String shallowLocNo : shallowLocs) { |
| | | LocMast shallowLoc = locMastService.selectById(shallowLocNo); |
| | | WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); |
| | | // 浅库位在作业中 |
| | | if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { |
| | | if (Cools.isEmpty(waitWrkMast)){ |
| | | News.error("库位异常"); |
| | |
| | | break; |
| | | } |
| | | } |
| | | }else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { |
| | | // 浅库位组有货,且没有在作业中 |
| | | } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { |
| | | if (null == waitWrkMast) { |
| | | // 生成一笔移库任务工作档、改变浅库位的源库/目标库 库位状态 |
| | | // 没有作业中的出库任务时,才能生成移库任务 |
| | |
| | | } |
| | | LocMast loc = null; |
| | | |
| | | if(shallowLoc.getLocType2() == 3){ //低频混直接出库 |
| | | if(shallowLoc.getLocType2() == 3 || shallowLoc.getLocType2() == 1){ |
| | | //低频混直接出库 |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | Date now = new Date(); |
| | |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setIoTime(now); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | // 生成对应的组托档 |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(wrkDetl); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakinMapper.insert(waitPakin); |
| | | |
| | | } |
| | | } |
| | | // 修改源库位状态 |
| | |
| | | // } |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKIN_MODE; |
| | | |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, 1); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol != null) { |
| | | if (crnProtocol.getTaskNo() != 0) { |
| | | if (crnProtocol.isStatusEnd()){ |
| | | // 出库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKOUT_MODE; |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKIN_MODE; |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKIN_MODE; |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKIN_MODE; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | |
| | | // } |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf4F = IoModeType.PAKIN_MODE; |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, 3); |
| | | CrnProtocol crnProtocol = crnThread.getCrnProtocol(); |
| | | if (crnProtocol != null) { |
| | | if (crnProtocol.getTaskNo() != 0) { |
| | | if (crnProtocol.isStatusEnd()){ |
| | | // 出库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKOUT_MODE; |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKIN_MODE; |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKIN_MODE; |
| | | } |
| | | } else { |
| | | // 入库模式 |
| | | devpThread.ioModeOf3F = IoModeType.PAKIN_MODE; |
| | | } |
| | | } |
| | | } |
| | | break; |