| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 对外暴露接口 |
| | |
| | | private BasConveyorService basConveyorService; |
| | | @Autowired |
| | | private BasConveyorStaService basConveyorStaService; |
| | | |
| | | |
| | | @PostMapping("/cancelWcsTask") |
| | | public HashMap<String,Object> cancelWcsTask(@RequestBody CreateWcsTaskParam param){ |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | if (Cools.isEmpty(param)){ |
| | | map.put("success", "0"); |
| | | map.put("message", "失败,请求参数为空"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | } |
| | | if (Cools.isEmpty(param.getRequestPK()) || Cools.isEmpty(param.getContNo()) ){ |
| | | map.put("success", "0"); |
| | | map.put("message", "失败,请求参数为空"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | } |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, param.getRequestPK()).eq(Task::getHostId,1L)); |
| | | if (task == null){ |
| | | map.put("success", "0"); |
| | | map.put("message", "失败,未找到相同编号的任务"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | } |
| | | if (task.getTaskSts() == 1 || task.getTaskSts() == 101){ |
| | | boolean remove = false; |
| | | try { |
| | | remove = taskService.removeById(task); |
| | | }catch (Exception e){ |
| | | map.put("success", "0"); |
| | | map.put("message", "取消任务失败:"+e.getMessage()); |
| | | map.put("result", ""); |
| | | map.put("requestPK",param.getRequestPK()); |
| | | return map; |
| | | }finally { |
| | | if (remove){ |
| | | map.put("success", "1"); |
| | | map.put("message", "取消任务成功"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | }else { |
| | | map.put("success", "0"); |
| | | map.put("message", "取消任务失败"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | } |
| | | } |
| | | }else { |
| | | map.put("success", "0"); |
| | | map.put("message", "失败,任务已执行"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | } |
| | | return map; |
| | | |
| | | } |
| | | |
| | | |
| | | //mes下发任务 |
| | | @PostMapping("/createWcsTaskParam") |
| | | public HashMap<String,Object> createWcsTask(@RequestBody CreateWcsTaskParam param){ |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | if (Cools.isEmpty(param)){ |
| | | map.put("success", "0"); |
| | | map.put("message", "失败,请求参数为空"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | } |
| | | if (Cools.isEmpty(param.getRequestPK()) || Cools.isEmpty(param.getContNo()) || Cools.isEmpty(param.getTrkPrty()) || Cools.isEmpty(param.getToPos())){ |
| | | map.put("success", "0"); |
| | | map.put("message", "失败,请求参数为空"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | } |
| | | |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, param.getRequestPK()).eq(Task::getHostId,1L)); |
| | | if(task != null){ |
| | | map.put("success", "0"); |
| | | map.put("message", "失败,存在相同编号的任务"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | } |
| | | ArrayList<String> inlist = new ArrayList<>(); |
| | | inlist.add("1");inlist.add("8"); |
| | | ArrayList<String> outlist = new ArrayList<>(); |
| | | outlist.add("2");outlist.add("9"); |
| | | if (inlist.contains(param.getTrkType())){ |
| | | CreateInTaskParam createInTaskParam = new CreateInTaskParam(); |
| | | createInTaskParam.setTaskNo(param.getRequestPK()); |
| | | createInTaskParam.setDestLoc(getWMStoWCSLocNo(param.getToPos())); |
| | | createInTaskParam.setOriginSite("100"); |
| | | createInTaskParam.setBarcode(param.getContNo()); |
| | | createInTaskParam.setPriority(Integer.valueOf(param.getTrkPrty())); |
| | | R inTask = null; |
| | | try { |
| | | inTask = createInTask(createInTaskParam); |
| | | }catch (Exception e){ |
| | | map.put("success", "0"); |
| | | map.put("message", "生成任务出错"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | }finally { |
| | | int code = (int) inTask.get("code"); |
| | | if (code == 200){ |
| | | map.put("success", "1"); |
| | | map.put("message", inTask.get("msg")); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | }else { |
| | | map.put("success", "0"); |
| | | map.put("message", inTask.get("msg")); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | } |
| | | } |
| | | } else if (outlist.contains(param.getTrkType())) { |
| | | CreateOutTaskParam createOutTaskParam = new CreateOutTaskParam(); |
| | | createOutTaskParam.setTaskNo(param.getRequestPK()); |
| | | createOutTaskParam.setOriginLoc(getWMStoWCSLocNo(param.getFrmPos())); |
| | | createOutTaskParam.setOriginSite("101"); |
| | | createOutTaskParam.setDestSite("100"); |
| | | createOutTaskParam.setPriority(Integer.valueOf(param.getTrkPrty())); |
| | | R outTask = null; |
| | | try { |
| | | outTask = createOutTask(createOutTaskParam); |
| | | }catch (Exception e){ |
| | | map.put("success", "0"); |
| | | map.put("message", "生成任务出错"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | return map; |
| | | }finally { |
| | | int code = (int) outTask.get("code"); |
| | | if (code == 200){ |
| | | map.put("success", "1"); |
| | | map.put("message", outTask.get("msg")); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | }else { |
| | | map.put("success", "0"); |
| | | map.put("message", outTask.get("msg")); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | } |
| | | } |
| | | |
| | | }else { |
| | | map.put("success", "0"); |
| | | map.put("message", "未找到对应任务类型"); |
| | | map.put("result", ""); |
| | | map.put("requestPK", param.getRequestPK()); |
| | | } |
| | | return map; |
| | | } |
| | | public static String getWMStoWCSLocNo(String loc){ |
| | | String locNo = ""; |
| | | int row = Integer.parseInt(loc.substring(6,8)); |
| | | int bay = Integer.parseInt(loc.substring(8,10)); |
| | | int lev = Integer.parseInt(loc.substring(10,12)); |
| | | locNo = row +"-"+bay+"-"+lev; |
| | | return locNo; |
| | | } |
| | | |
| | | //生成入库任务 |
| | | @PostMapping("/createInTask") |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String wmStoWCSLocNo = getWMStoWCSLocNo("0601KW010101"); |
| | | System.out.println(wmStoWCSLocNo); |
| | | } |
| | | |
| | | } |