| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | String response; |
| | | R r = R.ok(); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getTaskNo())); |
| | | if (!Objects.isNull(wrkMast) && "out".equalsIgnoreCase(params.getType()) && "Y".equalsIgnoreCase(wrkMast.getPauseMk())) { |
| | | return R.error("task paused"); |
| | | if (!Objects.isNull(wrkMast) && "out".equalsIgnoreCase(params.getType())) { |
| | | if ("Y".equalsIgnoreCase(wrkMast.getPauseMk())) { |
| | | return R.error("task paused"); |
| | | } |
| | | if (requiresOutboundErpConfirm(wrkMast) && !"Y".equalsIgnoreCase(wrkMast.getPdcType())) { |
| | | return R.error("task not confirmed by erp"); |
| | | } |
| | | } |
| | | try { |
| | | log.info("下发搬运任务给wcs="+JSON.toJSONString(params)); |
| | |
| | | if (!wrkMastService.updateById(mast)) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | //wcs任务取消接口 |
| | | } else if (params.getMsgType().equals("task_cancel")) { |
| | | if (mast.getIoType() != null && mast.getIoType() > 100 && mast.getWrkSts() < 14) { |
| | | mast.setPauseMk("Y"); |
| | | mast.setUpdMk("WCS_CANCELLED"); |
| | | mast.setManuType("WCS_CANCELLED"); |
| | | mast.setModiTime(new Date()); |
| | | if (!wrkMastService.updateById(mast)) { |
| | | throw new CoolException("task cancel update fail"); |
| | | } |
| | | } |
| | | }else if (params.getMsgType().equals("task_arrive")) { |
| | | workService.cancelWrkMast(String.valueOf(mast.getWrkNo()), 9955L); |
| | | } else if (params.getMsgType().equals("task_arrive")) { |
| | | //到达目的地 |
| | | //如果出库任务是跨区则需要生成新的入库任务入库 |
| | | if(!Cools.isEmpty(mast.getLocNo())){ |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private boolean requiresOutboundErpConfirm(WrkMast wrkMast) { |
| | | Integer ioType = wrkMast == null ? null : wrkMast.getIoType(); |
| | | return ioType != null && (ioType == 101 || ioType == 103 || ioType == 104 || ioType == 107 || ioType == 110); |
| | | } |
| | | @Override |
| | | public R pauseOutTasks(StopOutTaskParams params) { |
| | | if (params == null || params.getTasks() == null || params.getTasks().isEmpty()) { |
| | | return R.ok("no tasks to stop"); |
| | | public R pauseOutTasks(List<HashMap<String,Object>> params) { |
| | | if (params == null || params.size() == 0) { |
| | | return R.ok("无任务需要取消"); |
| | | } |
| | | if (!Boolean.parseBoolean(String.valueOf(switchValue))) { |
| | | return R.ok("wcs switch off"); |
| | | return R.ok("WCS开关关闭"); |
| | | } |
| | | String response; |
| | | try { |
| | | log.info("调用WCS取消出库任务, request={}", JSON.toJSONString(params)); |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wcs_address) |
| | | .setPath(stopOutTask) |
| | |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response == null ? "{}" : response); |
| | | log.info("WCS取消出库任务返回, response={}", response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code == null || !Objects.equals(code, 200)) { |
| | | String msg = jsonObject.getString("msg"); |
| | | throw new CoolException(Cools.isEmpty(msg) ? "WCS stop out task failed" : msg); |
| | | throw new CoolException(Cools.isEmpty(msg) ? "WCS取消出库任务失败" : msg); |
| | | } |
| | | return R.ok(Cools.isEmpty(jsonObject.getString("msg")) ? "操作成功" : jsonObject.getString("msg")); |
| | | } catch (IOException e) { |
| | | throw new CoolException("call WCS stop out task fail: " + e.getMessage()); |
| | | throw new CoolException("调用WCS取消出库任务失败: " + e.getMessage()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |