| | |
| | | import com.zy.api.service.WcsApiService; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.task.support.OutboundBatchSeqReleaseGuard; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.model.LocTypeDto; |
| | |
| | | private static final long OUT_LOCK_REPORT_PENDING_WRK_STS = 13L; |
| | | private static final long OUT_LOCK_REPORT_SUCCESS_WRK_STS = 21L; |
| | | private static final long OUT_LOCK_REPORT_FAIL_WRK_STS = 22L; |
| | | private static final long OUTBOUND_CRN_COMPLETE_WRK_STS = 25L; |
| | | private static final long OUTBOUND_STATION_COMPLETE_WRK_STS = 26L; |
| | | private static final String OUT_LOCK_REPORT_PENDING_FLAG = "P"; |
| | | |
| | | /** 同一 WCS 路径、同一单号下一组下发的任务条数上限 */ |
| | |
| | | private RowLastnoService rowLastnoService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private OutboundBatchSeqReleaseGuard outboundBatchSeqReleaseGuard; |
| | | |
| | | |
| | | /** |
| | |
| | | String validateMsg = validatePubTask(params, wrkMast); |
| | | if (!Cools.isEmpty(validateMsg)) { |
| | | return R.error(validateMsg); |
| | | } |
| | | String batchBlockMsg = validateOutboundBatchSeqReady(params, wrkMast); |
| | | if (!Cools.isEmpty(batchBlockMsg)) { |
| | | return R.error(batchBlockMsg); |
| | | } |
| | | String url = resolveTaskPath(params); |
| | | String requestJson = JSON.toJSONString(params); |
| | |
| | | return null; |
| | | } |
| | | WorkTaskParams head = chunk.get(0); |
| | | if (!"out".equalsIgnoreCase(head.getType())) { |
| | | return null; |
| | | } |
| | | WrkMast headMast = wrkMastMap.get(head.getTaskNo()); |
| | | String userNo = sortUserNoForPub(head, headMast); |
| | | if (Cools.isEmpty(userNo)) { |
| | | return null; |
| | | } |
| | | String batchSeq = sortBatchGroupForPub(head, headMast); |
| | | String blockingBatchSeq = findFirstUnfinishedOutboundBatchSeq(userNo); |
| | | if (blockingBatchSeq == null || compareBatchSeqNatural(batchSeq, blockingBatchSeq) == 0) { |
| | | return null; |
| | | } |
| | | return "出库批次未完成,暂停后续下发, userNo=" + userNo |
| | | + ", blockingBatchSeq=" + normalizeBatchSeq(blockingBatchSeq) |
| | | + ", nextBatchSeq=" + normalizeBatchSeq(batchSeq); |
| | | return validateOutboundBatchSeqReady(head, wrkMastMap.get(head.getTaskNo())); |
| | | } |
| | | |
| | | private String findFirstUnfinishedOutboundBatchSeq(String userNo) { |
| | | EntityWrapper<WrkMast> wrapper = new EntityWrapper<>(); |
| | | if (Cools.isEmpty(userNo)) { |
| | | wrapper.isNull("user_no"); |
| | | } else { |
| | | wrapper.eq("user_no", userNo); |
| | | } |
| | | wrapper.eq("io_type", 101); |
| | | wrapper.last(" and (wrk_sts < 14 or wrk_sts in (" |
| | | + OUT_LOCK_REPORT_SUCCESS_WRK_STS + "," + OUT_LOCK_REPORT_FAIL_WRK_STS + "))"); |
| | | List<WrkMast> rows = wrkMastService.selectList(wrapper); |
| | | if (rows == null || rows.isEmpty()) { |
| | | private String validateOutboundBatchSeqReady(WorkTaskParams params, WrkMast wrkMast) { |
| | | if (params == null || !"out".equalsIgnoreCase(params.getType())) { |
| | | return null; |
| | | } |
| | | String firstBatchSeq = null; |
| | | for (WrkMast row : rows) { |
| | | if (row == null) { |
| | | continue; |
| | | } |
| | | String batchSeq = sortBatchGroupForPub(null, row); |
| | | if (firstBatchSeq == null || compareBatchSeqNatural(batchSeq, firstBatchSeq) < 0) { |
| | | firstBatchSeq = batchSeq; |
| | | } |
| | | if (wrkMast == null || !Objects.equals(wrkMast.getIoType(), 101)) { |
| | | return null; |
| | | } |
| | | return firstBatchSeq; |
| | | return outboundBatchSeqReleaseGuard.validateReady( |
| | | sortUserNoForPub(params, wrkMast), |
| | | sortBatchGroupForPub(params, wrkMast)); |
| | | } |
| | | |
| | | private boolean outboundPltSlotReleasedInWms(String userNo, String batchSeq, int pltType) { |
| | |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } |
| | | } else if (params.getNotifyType().equals("task")) { |
| | | } else if (isOutboundCrnTaskComplete(params)) { |
| | | // WCS出库任务完成:堆垛机出库任务执行完成,工作状态 -> 25。 |
| | | if (isOutboundTask(mast) && canMarkOutboundCrnComplete(mast)) { |
| | | mast.setWrkSts(OUTBOUND_CRN_COMPLETE_WRK_STS); |
| | | mast.setModiTime(new Date()); |
| | | if (!wrkMastService.updateById(mast)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } |
| | | } else if (isOutboundStationTaskRunComplete(params)) { |
| | | // WCS输送站点出库任务运行完成:托盘已到目的地,工作状态 -> 26。 |
| | | if (isOutboundTask(mast) && canMarkOutboundStationComplete(mast)) { |
| | | mast.setWrkSts(OUTBOUND_STATION_COMPLETE_WRK_STS); |
| | | mast.setModiTime(new Date()); |
| | | if (!wrkMastService.updateById(mast)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } |
| | | } else if ("task".equalsIgnoreCase(params.getNotifyType())) { |
| | | //任务 |
| | | if (params.getMsgType().equals("task_complete")) { |
| | | if ("task_complete".equalsIgnoreCase(params.getMsgType())) { |
| | | |
| | | if (mast.getIoType() == 1 || mast.getIoType() == 2 ||mast.getIoType() == 10) { |
| | | mast.setWrkSts(4L); |
| | |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | //wcs任务取消接口 |
| | | } else if (params.getMsgType().equals("task_cancel")) { |
| | | } else if ("task_cancel".equalsIgnoreCase(params.getMsgType())) { |
| | | workService.cancelWrkMast(String.valueOf(mast.getWrkNo()), 9955L); |
| | | } |
| | | } |
| | |
| | | && "crn_out_task_run".equalsIgnoreCase(params.getMsgType()); |
| | | } |
| | | |
| | | private boolean isOutboundCrnTaskComplete(ReceviceTaskParams params) { |
| | | return params != null |
| | | && "Crn".equalsIgnoreCase(params.getNotifyType()) |
| | | && "crn_out_task_complete".equalsIgnoreCase(params.getMsgType()); |
| | | } |
| | | |
| | | private boolean isOutboundStationTaskRunComplete(ReceviceTaskParams params) { |
| | | return params != null |
| | | && "Devp".equalsIgnoreCase(params.getNotifyType()) |
| | | && "station_out_task_run_complete".equalsIgnoreCase(params.getMsgType()); |
| | | } |
| | | |
| | | private boolean isOutboundTask(WrkMast mast) { |
| | | return mast != null && mast.getIoType() != null && (mast.getIoType() == 101 || mast.getIoType() == 110); |
| | | } |
| | | |
| | | private boolean canMarkOutboundCrnComplete(WrkMast mast) { |
| | | if (mast == null || mast.getWrkSts() == null) { |
| | | return false; |
| | | } |
| | | return mast.getWrkSts() < 14 |
| | | || mast.getWrkSts().equals(OUT_LOCK_REPORT_SUCCESS_WRK_STS) |
| | | || mast.getWrkSts().equals(OUT_LOCK_REPORT_FAIL_WRK_STS); |
| | | } |
| | | |
| | | private boolean canMarkOutboundTaskComplete(WrkMast mast) { |
| | |
| | | } |
| | | return mast.getWrkSts() < 14 |
| | | || mast.getWrkSts().equals(OUT_LOCK_REPORT_SUCCESS_WRK_STS) |
| | | || mast.getWrkSts().equals(OUT_LOCK_REPORT_FAIL_WRK_STS); |
| | | || mast.getWrkSts().equals(OUT_LOCK_REPORT_FAIL_WRK_STS) |
| | | || mast.getWrkSts().equals(OUTBOUND_CRN_COMPLETE_WRK_STS) |
| | | || mast.getWrkSts().equals(OUTBOUND_STATION_COMPLETE_WRK_STS); |
| | | } |
| | | |
| | | private boolean canMarkOutboundStationComplete(WrkMast mast) { |
| | | if (mast == null || mast.getWrkSts() == null) { |
| | | return false; |
| | | } |
| | | return mast.getWrkSts() < 14 |
| | | || mast.getWrkSts().equals(OUT_LOCK_REPORT_SUCCESS_WRK_STS) |
| | | || mast.getWrkSts().equals(OUT_LOCK_REPORT_FAIL_WRK_STS) |
| | | || mast.getWrkSts().equals(OUTBOUND_CRN_COMPLETE_WRK_STS); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if ("Y".equalsIgnoreCase(wrkMast.getPauseMk())) { |
| | | return "task paused"; |
| | | } |
| | | if (Objects.equals(wrkMast.getIoType(), 101) && Cools.isEmpty(wrkMast.getBatchSeq())) { |
| | | return "出库进仓编号(batchSeq)为空,跳过下发"; |
| | | } |
| | | if (requiresOutboundErpConfirm(wrkMast) && !"Y".equalsIgnoreCase(wrkMast.getPdcType())) { |
| | | return "task not confirmed by erp"; |
| | | } |