| | |
| | | import com.zy.asrs.domain.enums.LedErrorAreaType; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.InboundTaskApplyParam; |
| | | import com.zy.asrs.mapper.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.*; |
| | |
| | | private BasDevpPositionService basDevpPositionService; |
| | | @Autowired |
| | | private TaskWrkService taskWrkService; |
| | | @Autowired |
| | | private OpenService openService; |
| | | |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | | String barcode = barcodeThread.getBarcode(); |
| | | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | // log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if ("00000000".endsWith(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) { |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | |
| | | // 获取入库站信息 |
| | | // SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | // log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if ("00000000".endsWith(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) { |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | |
| | | // 尺寸检测异常 |
| | |
| | | } |
| | | // 退回 |
| | | if (back) { |
| | | barcodeThread.setBarcode(""); |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(3); |
| | | |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false,201); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // led 异常显示 |
| | | LedErrorThreadUtil.ledErrorThread(errMsg,inSta.getLed(), LedErrorAreaType.FOUR_BARCODE.getDesc()); |
| | | continue; |
| | |
| | | |
| | | try { |
| | | |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setBarcode(barcode); |
| | | param.setIoType(1); |
| | | param.setSourceStaNo(inSta.getStaNo()); |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | // 替换为新的任务申请接口 |
| | | InboundTaskApplyParam applyParam = new InboundTaskApplyParam(); |
| | | applyParam.setBarcode(barcode); |
| | | applyParam.setStationCode(String.valueOf(inSta.getStaNo())); |
| | | applyParam.setStatus(1); // 1:满板 |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .setPath("/inboundTaskApply") |
| | | .setJson(JSON.toJSONString(applyParam)) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | // 解析响应,只确认申请是否成功 |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | // LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); |
| | | |
| | | |
| | | barcodeThread.setBarcode(""); |
| | | staProtocol.setWorkNo(dto.getWorkNo()); |
| | | |
| | | // if(Cools.isEmpty(dto.getRgvNo()) || dto.getRgvNo() <= 0) { |
| | | // staProtocol.setStaNo(607);//607 |
| | | // } else {//如果存在RGV编号,说明需要RGV接驳,先下发任务到RGV源站 |
| | | staProtocol.setStaNo(dto.getRgvSstaNo().shortValue()); |
| | | // } |
| | | |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false,283); |
| | | if (jsonObject != null && jsonObject.getInteger("code") != null && jsonObject.getInteger("code") == 200) { |
| | | log.info("入库任务申请成功,等待WMS下发任务。条码:{},站点:{}", barcode, inSta.getStaNo()); |
| | | staProtocol.setWorkNo(9998);//设置为9998等待上位机下发任务/9997是空板入库判断,待下发时也写入9998 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | LedErrorThreadUtil.ledErrorThread("更新plc站点信息失败!站点号:"+inSta.getStaNo(),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc()); |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } else { |
| | | // // 获取工作号 |
| | | int workNo = commonService.getWorkNo(3); |
| | | |
| | | staProtocol.setWorkNo(workNo); |
| | | staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false,201); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // led 异常显示 |
| | | LedErrorThreadUtil.ledErrorThread("入库请求失败"+jsonObject.getInteger("code"),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc()); |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/inboundTaskApply", JSON.toJSONString(applyParam), response); |
| | | } |
| | | |
| | | // 原有逻辑注释掉 |
| | | // LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | // |
| | | // SearchLocParam param = new SearchLocParam(); |
| | | // param.setBarcode(barcode); |
| | | // param.setIoType(1); |
| | | // param.setSourceStaNo(inSta.getStaNo()); |
| | | // param.setLocType1(locTypeDto.getLocType1()); |
| | | // String response = new HttpHandler.Builder() |
| | | // .setUri(wmsUrl) |
| | | // .setPath("/rpc/pakin/loc/v1") |
| | | // .setJson(JSON.toJSONString(param)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getInteger("code").equals(200)) { |
| | | // StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | // |
| | | // barcodeThread.setBarcode(""); |
| | | // staProtocol.setWorkNo(dto.getWorkNo()); |
| | | // staProtocol.setStaNo(wrkMast.getStaNoSou$().shortValue()); |
| | | // |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false,283); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // if (!result) { |
| | | // LedErrorThreadUtil.ledErrorThread("更新plc站点信息失败!站点号:"+inSta.getStaNo(),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc()); |
| | | // throw new CoolException("更新plc站点信息失败"); |
| | | // } |
| | | // } else { |
| | | // // 获取工作号 |
| | | // int workNo = commonService.getWorkNo(3); |
| | | // |
| | | // staProtocol.setWorkNo(workNo); |
| | | // staProtocol.setStaNo(inSta.getBackSta().shortValue()); |
| | | // |
| | | // devpThread.setPakMk(staProtocol.getSiteId(), false,201); |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | // // led 异常显示 |
| | | // LedErrorThreadUtil.ledErrorThread("入库请求失败"+jsonObject.getInteger("code"),inSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc()); |
| | | // log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | // } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | // 站点条件判断 |
| | | if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() |
| | | && staProtocol.isEmptyMk() && ((staProtocol.getWorkNo() > 9000 && staProtocol.getWorkNo() <= 9999) || staProtocol.getWorkNo()==0) && staProtocol.isPakMk()) { |
| | | && staProtocol.isEmptyMk() && ((staProtocol.getWorkNo() > 9000 && staProtocol.getWorkNo() <= 9997) || staProtocol.getWorkNo()==0) && staProtocol.isPakMk()) { |
| | | |
| | | try { |
| | | LocTypeDto locTypeDto = new LocTypeDto(staProtocol); |
| | | |
| | | SearchLocParam param = new SearchLocParam(); |
| | | param.setIoType(10); |
| | | param.setSourceStaNo(emptyInSta.getStaNo()); |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | InboundTaskApplyParam applyParam = new InboundTaskApplyParam(); |
| | | applyParam.setBarcode(null); |
| | | applyParam.setStationCode(String.valueOf(emptyInSta.getStaNo())); |
| | | applyParam.setStatus(0); // 1:满板 |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/loc/v1") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .setPath("/inboundTaskApply") |
| | | .setJson(JSON.toJSONString(applyParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | // 更新站点信息 且 下发plc命令 |
| | | staProtocol.setWorkNo(dto.getWorkNo()); |
| | | staProtocol.setStaNo(dto.getStaNoSou$(dto.getStaNo(),staProtocol.getSiteId()).shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false,4087); |
| | | // 解析响应,只确认申请是否成功 |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject != null && jsonObject.getInteger("code") != null && jsonObject.getInteger("code") == 200) { |
| | | log.info("入库任务申请成功,等待WMS下发任务,站点:{}",emptyInSta.getStaNo()); |
| | | staProtocol.setWorkNo(9998);//设置为9998等待上位机下发任务 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | LedErrorThreadUtil.ledErrorThread("更新plc站点信息失败!站点号:"+emptyInSta.getStaNo(),emptyInSta.getLed(), LedErrorAreaType.ONE_OTHER.getDesc()); |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/inboundTaskApply", JSON.toJSONString(applyParam), response); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | if (wrkMastMapper.updateById(wrkMast) != 0) { |
| | | // 复位堆垛机 |
| | | crnThread.setResetFlag(true); |
| | | if(wrkMast.getIoType() == 103 || wrkMast.getIoType() == 107) { //拣料出库任务状态上报,其他上报在wms任务完成定时任务中 |
| | | openService.reportTaskStatus(String.valueOf(wrkMast.getWrkNo()),3,1,wrkMast.getBarcode()); |
| | | } |
| | | |
| | | } else { |
| | | log.error("更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo()); |
| | | } |
| | |
| | | if (!WrkMastLogList.isEmpty()) { |
| | | boolean signT = false; |
| | | for (WrkMast wrkMast : WrkMastLogList){ |
| | | Date completeTime = wrkMast.getIoTime(); |
| | | Date completeTime = wrkMast.getModiTime(); |
| | | if (completeTime==null){ |
| | | continue; |
| | | } |