|  |  | 
 |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
 |  |  | import com.core.common.Cools; | 
 |  |  | import com.core.common.R; | 
 |  |  | import com.core.common.SpringUtils; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.asrs.domain.enums.TaskStatusType; | 
 |  |  | import com.zy.asrs.domain.enums.WorkNoType; | 
 |  |  | 
 |  |  |     public R taskCreate(TaskCreateParam param) { | 
 |  |  |         TaskWrk taskWrk = taskWrkService.selectByTaskNo(param.getTaskNo()); | 
 |  |  |         if (taskWrk != null) { | 
 |  |  |             try{ | 
 |  |  |                 DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                 deviceErrorService.addDeviceError("wmsErr", 1, "任务已存在,请勿重复提交,taskWrk:"+JSON.toJSONString(taskWrk)); | 
 |  |  |             } catch (Exception e2){ | 
 |  |  | //                    log.error("e2:"+e2.getMessage()); | 
 |  |  |             } | 
 |  |  |             throw new CoolException(param.getTaskNo() + "任务已存在,请勿重复提交"); | 
 |  |  |         } | 
 |  |  |         if (param.getIoType().equals(0)){ | 
 |  |  |             try{ | 
 |  |  |                 DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                 deviceErrorService.addDeviceError("wmsErr", 1, "生成任务失败,任务类型不存在!,iotype:"+JSON.toJSONString(param.getIoType())); | 
 |  |  |             } catch (Exception e2){ | 
 |  |  | //                    log.error("e2:"+e2.getMessage()); | 
 |  |  |             } | 
 |  |  |             throw new CoolException("生成任务失败,任务类型不存在!"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Date now = new Date(); | 
 |  |  |         taskWrk = new TaskWrk(); | 
 |  |  |         LocMast locMast=locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",param.getStartPoint())); | 
 |  |  |         int workNo1 = commonService.getWorkNo(WorkNoType.PAKOUT.type);//获取入库工作号 | 
 |  |  |         int workNo1 = 0;//获取入库工作号 | 
 |  |  |         if (param.getIoType() .equals(1)){ | 
 |  |  |             workNo1 = commonService.getWorkNo(WorkNoType.PAKIN.type); | 
 |  |  |         } else if (param.getIoType() .equals(2)){ | 
 |  |  |             workNo1 = commonService.getWorkNo(WorkNoType.PAKOUT.type); | 
 |  |  |         } else { | 
 |  |  |             workNo1 = commonService.getWorkNo(WorkNoType.PICK.type); | 
 |  |  |         } | 
 |  |  |         taskWrk.setTaskNo(param.getTaskNo());//任务号 | 
 |  |  |         taskWrk.setWrkNo(workNo1); | 
 |  |  |         taskWrk.setStatus(TaskStatusType.RECEIVE.id);//任务状态:接收 | 
 |  |  |         taskWrk.setCreateTime(now); | 
 |  |  |         taskWrk.setModiTime(now); | 
 |  |  |         taskWrk.setAssignTime(new Date()); | 
 |  |  |         taskWrk.setModiUser(6666L); | 
 |  |  | //        try{ | 
 |  |  | //            if (param.getIoType()>1){ | 
 |  |  | //                LocMast locMast=locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",param.getStartPoint())); | 
 |  |  | //                if (Utils.locNoRowBoolean(locMast.getRow1())){ | 
 |  |  | //                      param.setTaskPriority(11); | 
 |  |  | //                } | 
 |  |  | //            } | 
 |  |  | //        }catch (Exception e){ | 
 |  |  | //        } | 
 |  |  |         taskWrk.setIoPri(param.getTaskPriority()); | 
 |  |  |  | 
 |  |  |         taskWrk.setIoType(param.getIoType());//任务类型 | 
 |  |  |         taskWrk.setIoPri(param.getTaskPriority());//优先级 | 
 |  |  |         taskWrk.setBarcode(param.getBarcode());//条码 | 
 |  |  |         taskWrk.setCrnNo(locMast.getCrnNo()); | 
 |  |  |         taskWrk.setCrnNo(param.getCrn()); | 
 |  |  |         if(param.getIoType() == 1){ | 
 |  |  |             taskWrk.setWrkSts(1); | 
 |  |  |             if (!Cools.isEmpty(param.getTargetPoint())) { | 
 |  |  |                 taskWrk.setTargetPoint(Utils.getWcsLocNo(param.getTargetPoint()));//终点 | 
 |  |  |                 taskWrk.setOriginTargetPoint(param.getTargetPoint()); | 
 |  |  | //                taskWrk.setTargetPoint(Utils.getWcsLocNo(param.getTargetPoint()));//终点  转换下 | 
 |  |  |                 taskWrk.setTargetPoint(param.getTargetPoint());//终点 | 
 |  |  |                 taskWrk.setStartPoint(param.getStartPoint()); | 
 |  |  |                 taskWrk.setOriginStartPoint(param.getStartPointSta().toString()); | 
 |  |  |                 taskWrk.setOriginTargetPoint(param.getTargetPointSta().toString()); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } else if (param.getIoType() == 2) { | 
 |  |  | 
 |  |  |                 taskWrk.setTargetPoint(param.getTargetPoint()); | 
 |  |  |             } | 
 |  |  |             taskWrk.setTargetPoint(param.getTargetPoint()); | 
 |  |  |             taskWrk.setOriginStartPoint(param.getStartPointSta().toString()); | 
 |  |  |             taskWrk.setOriginTargetPoint(param.getTargetPointSta().toString()); | 
 |  |  |         }else if (param.getIoType() == 3){ | 
 |  |  |             taskWrk.setWrkSts(11); | 
 |  |  |             if (!Cools.isEmpty(param.getStartPoint())) { | 
 |  |  |                 taskWrk.setStartPoint(param.getStartPoint());//起点 | 
 |  |  |                 taskWrk.setTargetPoint(param.getTargetPoint()); | 
 |  |  |                 taskWrk.setOriginStartPoint("0"); | 
 |  |  |                 taskWrk.setOriginTargetPoint("0"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (!taskWrkService.insert(taskWrk)) { | 
 |  |  |             try{ | 
 |  |  |                 DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); | 
 |  |  |                 deviceErrorService.addDeviceError("wmsErr", 1, "创建任务失败!,param:"+JSON.toJSONString(param)); | 
 |  |  |             } catch (Exception e2){ | 
 |  |  | //                    log.error("e2:"+e2.getMessage()); | 
 |  |  |             } | 
 |  |  |             return R.error("创建任务失败"); | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  | 
 |  |  |                 ,true | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |         if (jsonObject.getInteger("code").equals(200)) { | 
 |  |  |         if (!Cools.isEmpty(jsonObject.getInteger("code")) && jsonObject.getInteger("code").equals(200)) { | 
 |  |  |             //解析 | 
 |  |  |             List<WMSAndAGVInterfaceParam> params = new ArrayList<>(); | 
 |  |  |             params.add(param); | 
 |  |  | 
 |  |  |             } else { | 
 |  |  |                 staProtocol = staProtocol.clone(); | 
 |  |  |             } | 
 |  |  |             Short workNo = staProtocol.getWorkNo(); | 
 |  |  |             Integer workNo = staProtocol.getWorkNo(); | 
 |  |  |             if (wharfCode1.contains(param.getWharfCode())){ | 
 |  |  |                 if (!staProtocol.isLoading() && !staProtocol.isCar() && staProtocol.getWorkNo() >0){ | 
 |  |  |                 if (!staProtocol.isLoading() && staProtocol.getWorkNo() >0){ | 
 |  |  |                     //AGV出库完成以后 | 
 |  |  |                     staProtocol.setWorkNo((short) 0); | 
 |  |  |                     staProtocol.setStaNo((short)0); | 
 |  |  |                     staProtocol.setWorkNo( 0); | 
 |  |  |                     staProtocol.setStaNo(0); | 
 |  |  |                     boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); | 
 |  |  |                     if (result) { | 
 |  |  |  | 
 |  |  | 
 |  |  |                 for (DevpSlave.Sta inSta : devp.getInSta()) { | 
 |  |  |                     if (inSta.getBackSta().equals(staDesc.getStnNo())){ | 
 |  |  |  | 
 |  |  |                         if (staProtocol.isLoading() && !staProtocol.isCar() && workNo == 0){ | 
 |  |  |                         if (staProtocol.isLoading() && workNo == 0){ | 
 |  |  |                             //AGV入库完成以后 | 
 |  |  |                             staProtocol.setWorkNo((short) 9999); | 
 |  |  |                             staProtocol.setStaNo(inSta.getStaNo().shortValue()); | 
 |  |  |                             staProtocol.setWorkNo(9999); | 
 |  |  |                             staProtocol.setStaNo(inSta.getStaNo()); | 
 |  |  |                             boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, staProtocol)); | 
 |  |  |                             if (result) { | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public R getAgvPickAndPlaceV1(TaskOverParam param) { | 
 |  |  |         BasDevp basDevp = basDevpService.selectById(param.getStaNo()); | 
 |  |  |         if (Cools.isEmpty(basDevp)){ | 
 |  |  |             return R.error("站点号有误"+param.getStaNo()); | 
 |  |  |         } | 
 |  |  |         if (param.getType()==0 && basDevp.getAgvStartPick()==1){ | 
 |  |  |             return R.ok(); | 
 |  |  |         }else if (param.getType()==1 && basDevp.getAgvStartPlace()==1){ | 
 |  |  |             return R.ok(); | 
 |  |  |         }else { | 
 |  |  |             return R.error(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | //    @Override | 
 |  |  | //    public R getAgvPickAndPlaceV1(TaskOverParam param) { | 
 |  |  | //        BasDevp basDevp = basDevpService.selectById(param.getStaNo()); | 
 |  |  | //        if (Cools.isEmpty(basDevp)){ | 
 |  |  | //            return R.error("站点号有误"+param.getStaNo()); | 
 |  |  | //        } | 
 |  |  | //        if (param.getType()==0 && basDevp.getAgvStartPick()==1){ | 
 |  |  | //            return R.ok(); | 
 |  |  | //        }else if (param.getType()==1 && basDevp.getAgvStartPlace()==1){ | 
 |  |  | //            return R.ok(); | 
 |  |  | //        }else { | 
 |  |  | //            return R.error("不允许"); | 
 |  |  | //        } | 
 |  |  | //    } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public R getAgvPickAndPlaceV2(TaskOverParam param) { | 
 |  |  |         BasDevp basDevp = basDevpService.selectById(param.getStaNo()); | 
 |  |  |         if (Cools.isEmpty(basDevp)){ | 
 |  |  |             return R.error("站点号有误"+param.getStaNo()); | 
 |  |  |         } | 
 |  |  |         if (param.getType()==0){ | 
 |  |  |             basDevp.setAgvTargetPick(1); | 
 |  |  |             basDevpService.updateById(basDevp); | 
 |  |  |             return R.ok(); | 
 |  |  |         }else if (param.getType()==1){ | 
 |  |  |             basDevp.setAgvTargetPlace(1); | 
 |  |  |             basDevpService.updateById(basDevp); | 
 |  |  |             return R.ok(); | 
 |  |  |         }else { | 
 |  |  |             return R.error("请求类型异常"+param.getType()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | //    @Override | 
 |  |  | //    public R getAgvPickAndPlaceV2(TaskOverParam param) { | 
 |  |  | //        BasDevp basDevp = basDevpService.selectById(param.getStaNo()); | 
 |  |  | //        if (Cools.isEmpty(basDevp)){ | 
 |  |  | //            return R.error("站点号有误"+param.getStaNo()); | 
 |  |  | //        } | 
 |  |  | //        if (param.getType()==0){ | 
 |  |  | //            basDevp.setAgvTargetPick(1); | 
 |  |  | //            basDevpService.updateById(basDevp); | 
 |  |  | //            return R.ok(); | 
 |  |  | //        }else if (param.getType()==1){ | 
 |  |  | //            basDevp.setAgvTargetPlace(1); | 
 |  |  | //            basDevpService.updateById(basDevp); | 
 |  |  | //            return R.ok(); | 
 |  |  | //        }else { | 
 |  |  | //            return R.error("请求类型异常"+param.getType()); | 
 |  |  | //        } | 
 |  |  | //    } | 
 |  |  |  | 
 |  |  |     public List<Integer> getInEnableRoadway(){ | 
 |  |  |         int[] roadway = null; | 
 |  |  | 
 |  |  |                 } else { | 
 |  |  |                     staProtocol = staProtocol.clone(); | 
 |  |  |                 } | 
 |  |  |                 Short workNo = staProtocol.getWorkNo(); | 
 |  |  |                 Integer workNo = staProtocol.getWorkNo(); | 
 |  |  |                 if (workNo == 0 && !staProtocol.isLoading()){ | 
 |  |  |                     if (Cools.isEmpty( map.get(inSta.getStaNo()))){ | 
 |  |  |                         continue; | 
 |  |  | 
 |  |  |                 } else { | 
 |  |  |                     staProtocol = staProtocol.clone(); | 
 |  |  |                 } | 
 |  |  |                 Short workNo = staProtocol.getWorkNo(); | 
 |  |  |                 Integer workNo = staProtocol.getWorkNo(); | 
 |  |  |                 if (workNo == 0 && !staProtocol.isLoading()){ | 
 |  |  |                     if (Cools.isEmpty( map.get(inSta.getStaNo()))){ | 
 |  |  |                         continue; |