| | |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.enums.TaskStatusType; |
| | | import com.zy.asrs.entity.CommandInfo; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.entity.TaskWrkLog; |
| | | import com.zy.asrs.entity.param.NotifyDto; |
| | | import com.zy.asrs.entity.param.TaskOverToWms; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.CommandInfoService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.TaskWrkService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | |
| | | @Autowired |
| | | private CommandInfoService commandInfoService; |
| | | |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | |
| | | @Value("${wms.TaskExecCallback}") |
| | | private String TaskExecCallback; |
| | | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | |
| | | @RequestMapping(value = "/taskWrk/{wrkNo}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("wrkNo") Integer wrkNo) { |
| | |
| | | |
| | | @RequestMapping(value = "/taskWrk/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | public R list(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | EntityWrapper<TaskWrk> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | if (!Cools.isEmpty(orderByField)) { |
| | | wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); |
| | | } |
| | | return R.ok(taskWrkService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) { |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | if (val.contains(RANGE_TIME_LINK)) { |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/update/auth") |
| | | @ManagerAuth |
| | | public R update(TaskWrk taskWrk){ |
| | | @RequestMapping(value = "/taskWrk/update/auth") |
| | | @ManagerAuth |
| | | public R update(TaskWrk taskWrk) { |
| | | if (Cools.isEmpty(taskWrk) || null == taskWrk.getTaskNo()) { |
| | | return R.error(); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/taskWrk/updatePoint/auth") |
| | | @ManagerAuth |
| | | public R updatePoint(TaskWrk taskWrk){ |
| | | public R updatePoint(TaskWrk taskWrk) { |
| | | if (Cools.isEmpty(taskWrk) || null == taskWrk.getTaskNo()) { |
| | | return R.error(); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/taskWrk/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | public R delete(@RequestParam(value = "ids[]") Long[] ids) { |
| | | for (Long id : ids) { |
| | | taskWrkService.deleteById(id); |
| | | } |
| | | return R.ok(); |
| | |
| | | |
| | | @RequestMapping(value = "/taskWrk/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | | public R export(@RequestBody JSONObject param) { |
| | | EntityWrapper<TaskWrk> wrapper = new EntityWrapper<>(); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("taskWrk")); |
| | |
| | | wrapper.like("id", condition); |
| | | Page<TaskWrk> page = taskWrkService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (TaskWrk taskWrk : page.getRecords()){ |
| | | for (TaskWrk taskWrk : page.getRecords()) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", taskWrk.getTaskNo()); |
| | | map.put("value", taskWrk.getTaskNo()); |
| | |
| | | @ManagerAuth |
| | | public R query(@RequestBody JSONObject param) { |
| | | Wrapper<TaskWrk> wrapper = new EntityWrapper<TaskWrk>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); |
| | | if (null != taskWrkService.selectOne(wrapper)){ |
| | | if (null != taskWrkService.selectOne(wrapper)) { |
| | | return R.parse(BaseRes.REPEAT).add(getComment(TaskWrk.class, String.valueOf(param.get("key")))); |
| | | } |
| | | return R.ok(); |
| | |
| | | @ManagerAuth(memo = "手动完成任务") |
| | | public R complete(@RequestParam String taskNo) { |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); |
| | | |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("x-api-key","7a15b5db-29b6-552c-8cff-0cfec3756da2"); |
| | | TaskOverToWms taskOverToWms = new TaskOverToWms(); |
| | | taskOverToWms.setFeedbackFrom("WCS"); //来源 |
| | | taskOverToWms.setWarehouseId("1688469798893297665"); //仓库标识 |
| | | taskOverToWms.setTaskNo(taskWrk.getTaskNo()); //任务号 |
| | | taskOverToWms.setTaskType(getTaskType(taskWrk.getIoType())); // 任务类型 |
| | | taskOverToWms.setContainerCode(taskWrk.getBarcode()); // 容器编码 |
| | | if (taskWrk.getIoType() ==1 ){ |
| | | taskOverToWms.setEquipmentCode(String.valueOf(taskWrk.getCrnNo())); //设备编码 |
| | | taskOverToWms.setTargetLocationCode(taskWrk.getOriginTargetPoint()); //目标库位 |
| | | }else if (taskWrk.getIoType() ==2){ |
| | | Map<Integer,String> map1 = new HashMap<>(); |
| | | map1.put(102,"J-1101"); |
| | | map1.put(106,"J-1103"); |
| | | map1.put(110,"J-1105"); |
| | | map1.put(114,"J-1107"); |
| | | map1.put(118,"J-1109"); |
| | | map1.put(122,"J-1111"); |
| | | taskOverToWms.setEquipmentCode(map1.get(taskWrk.getTargetPoint())); //设备编码 |
| | | taskOverToWms.setSourceLocationCode(taskWrk.getOriginStartPoint()); //源库位 |
| | | if (Cools.isEmpty(taskWrk) || taskWrk.getStatus() >= 3) { |
| | | return R.error("已完结或已取消"); |
| | | } |
| | | LocMast locMast = new LocMast(); |
| | | if (taskWrk.getIoType() == 1) {//入库任务完成库位为F |
| | | locMast = locMastService.selectByLocNo(taskWrk.getOriginTargetPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("F"); |
| | | locMast.setModiTime(new Date()); |
| | | locMast.setBarcode(taskWrk.getBarcode()); |
| | | } else if (taskWrk.getIoType() == 2) {//出库任务完成库位为O |
| | | locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(new Date()); |
| | | } else if (taskWrk.getIoType() == 3) { |
| | | locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(new Date()); |
| | | locMastService.updateById(locMast); |
| | | locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | R.error("没有找到该库位"); |
| | | } |
| | | locMast.setLocSts("F"); |
| | | locMast.setModiTime(new Date()); |
| | | locMast.setBarcode(taskWrk.getBarcode()); |
| | | |
| | | taskOverToWms.setTaskStatus("handle"); //任务状态 |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(map) |
| | | .setUri(wmsUrl) |
| | | .setPath("wcsManager/wcsInterface/taskStatusFeedback") |
| | | .setJson(JSON.toJSONString(taskOverToWms)) |
| | | .build() |
| | | .doPost(); |
| | | }catch (Exception e){ |
| | | log.error("wms连接失败"); |
| | | } |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)){ |
| | | if (taskWrk == null) { |
| | | return R.error(); |
| | | } |
| | | if (taskWrk.getStatus().equals(TaskStatusType.COMPLETE.id)) { |
| | | return R.error(taskWrk.getTaskNo() + "已完结"); |
| | | } |
| | | Date now = new Date(); |
| | | taskWrk.setStatus(TaskStatusType.COMPLETE.id); |
| | | taskWrk.setModiTime(now);//操作时间 |
| | | try{ |
| | | taskWrk.setModiUser(getUserId());//操作员 |
| | | }catch (Exception e){ |
| | | taskWrk.setModiUser(9999L);//操作员 |
| | | } |
| | | taskWrk.setCompleteTime(now);//完结时间 |
| | | taskWrkService.updateById(taskWrk); |
| | | |
| | | |
| | | if (taskWrkService.saveToHistory(taskWrk.getTaskNo()) > 0) { |
| | | //任务已经转日志,将该任务下面的指令转日志 |
| | | commandInfoService.saveToHistory(taskWrk.getTaskNo()); |
| | | |
| | | //删除任务 |
| | | taskWrkService.delete(new EntityWrapper<TaskWrk>().eq("task_no", taskWrk.getTaskNo())); |
| | | //删除指令 |
| | | commandInfoService.delete(new EntityWrapper<CommandInfo>().eq("task_no", taskWrk.getTaskNo())); |
| | | } |
| | | }else { |
| | | return R.error("wms通讯失败"); |
| | | } |
| | | |
| | | |
| | | locMastService.updateById(locMast); |
| | | taskWrk.setStatus(6);//手动完成任务 |
| | | taskWrk.setModiTime(new Date()); |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping(value = "/taskWrk/returnWorkingCondition/auth") |
| | | @ManagerAuth(memo = "重新给堆垛机下发任务") |
| | | public R returnWorkingCondition(@RequestParam String taskNo) { |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); |
| | | if (!Cools.isEmpty(taskWrk) && taskWrk.getWrkSts() == 12) { |
| | | taskWrk.setWrkSts(11); |
| | | if (!taskWrkService.updateById(taskWrk)) { |
| | | return R.error("更新任务状态失败"); |
| | | } |
| | | return R.ok(); |
| | | } else if (!Cools.isEmpty(taskWrk) && taskWrk.getWrkSts() == 3) { |
| | | taskWrk.setWrkSts(2); |
| | | taskWrkService.updateById(taskWrk); |
| | | if (!taskWrkService.updateById(taskWrk)) { |
| | | return R.error("更新任务状态失败"); |
| | | } |
| | | return R.ok(); |
| | | } else { |
| | | return R.error("任务状态不对无法重新给堆垛机下发任务"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @PostMapping(value = "/taskWrk/cancel/auth") |
| | |
| | | Date now = new Date(); |
| | | taskWrk.setStatus(TaskStatusType.CANCEL.id); |
| | | taskWrk.setModiTime(now);//操作时间 |
| | | try{ |
| | | try { |
| | | taskWrk.setModiUser(getUserId());//操作员 |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | taskWrk.setModiUser(9999L);//操作员 |
| | | } |
| | | taskWrk.setStatus(4);//手动取消 |
| | | taskWrk.setCompleteTime(now);//完结时间 |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | public static String getTaskType(Integer paramIoType){ |
| | | switch (paramIoType){ |
| | | public static String getTaskType(Integer paramIoType) { |
| | | switch (paramIoType) { |
| | | case 1: |
| | | return "RK"; |
| | | case 2: |
| | |
| | | } |
| | | } |
| | | |
| | | @PostMapping(value = "/taskWrk/state") |
| | | // @ManagerAuth(memo = "接收RCS任务状态") |
| | | public R taskWrkState(@RequestBody NotifyDto notifyDto) { |
| | | R r = R.ok(); |
| | | log.info("接收RCS任务状态={}", notifyDto); |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(notifyDto.getSuperTaskNo());//wms任务号 |
| | | if (taskWrk == null) { |
| | | return R.error("没有找到该任务={" + notifyDto + "}"); |
| | | } |
| | | Date now = new Date(); |
| | | |
| | | /** |
| | | * 任务完成 |
| | | */ |
| | | switch (notifyDto.getMsgType()) { |
| | | case "task_complete": |
| | | r = taskWrkService.taskComplete(taskWrk); |
| | | break; |
| | | |
| | | } |
| | | // if (notifyDto.getMsgType().equals("task_complete") && taskWrk.getIoType() == 3) {//移库 |
| | | // taskWrk.setWrkSts(7);//更新数据完成,直接转历史档 |
| | | // |
| | | // //更新源库位状态为空库位 |
| | | // LocMast locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); |
| | | // locMast.setLocSts("O"); |
| | | // locMastService.updateById(locMast); |
| | | // |
| | | // //更新目标库状态为在库 |
| | | // LocMast locMast2 = locMastService.selectByLocNo(taskWrk.getTargetPoint()); |
| | | // locMast2.setLocSts("F"); |
| | | // locMastService.updateById(locMast2); |
| | | // taskWrk.setModiTime(now);//操作时间 |
| | | // taskWrk.setModiUser(9998L);//操作员 |
| | | // taskWrkService.updateById(taskWrk); |
| | | // } |
| | | return r; |
| | | } |
| | | |
| | | } |