| | |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.Task; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | private CommonService commonService; |
| | | @Autowired |
| | | private NotifyUtils notifyUtils; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | |
| | | private static final boolean auth = true; |
| | | |
| | |
| | | @RequestBody TaskCancelParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("参数为空!"); |
| | | } else if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("工作号为空!"); |
| | | } else if (Cools.isEmpty(param.getIoType())) { |
| | | return R.error("操作类型为空!"); |
| | | } else if (Cools.isEmpty(param.getBarcode())) { |
| | | return R.error("托盘码不能为空!"); |
| | | } |
| | | R result = null; |
| | | try { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("参数为空!"); |
| | | } else if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("工作号为空!"); |
| | | } else if (Cools.isEmpty(param.getIoType())) { |
| | | return R.error("操作类型为空!"); |
| | | } else if (Cools.isEmpty(param.getBarcode())) { |
| | | return R.error("托盘码不能为空!"); |
| | | } |
| | | |
| | | TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>() |
| | | .eq("task_no", param.getTaskNo()) |
| | | .eq("io_type", param.getIoType()) |
| | | .eq("barcode", param.getBarcode())); |
| | | if (Cools.isEmpty(taskWrk)){ |
| | | return R.error("未查到当前任务---" + param); |
| | | TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>() |
| | | .eq("task_no", param.getTaskNo()) |
| | | .eq("io_type", param.getIoType()) |
| | | .eq("barcode", param.getBarcode())); |
| | | if (Cools.isEmpty(taskWrk)){ |
| | | result = R.error("未查到当前任务---" + param); |
| | | return result; |
| | | } |
| | | boolean sign = false; |
| | | switch (param.getTaskStatus()) { |
| | | case 1://正常取消 |
| | | if (taskWrk.getStatus() > 1) { |
| | | if (taskWrk.getIoType() == 1 && taskWrk.getWrkSts() <= 2) {//入库 |
| | | break; |
| | | } |
| | | |
| | | result = R.error("任务已开始执行"); |
| | | return result; |
| | | } |
| | | break; |
| | | case 2://正常完成 |
| | | if (taskWrk.getStatus() > 1) { |
| | | result = R.error("任务已开始执行"); |
| | | return result; |
| | | } |
| | | sign = true; |
| | | break; |
| | | default: |
| | | result = R.error("未知操作"); |
| | | return result; |
| | | } |
| | | result = taskWrkOperate(taskWrk, sign); |
| | | return result; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | result = R.error(e.getMessage()); |
| | | return R.error(e.getMessage()); |
| | | }finally { |
| | | apiLogService.save("wms任务下发接口" |
| | | ,request.getRemoteAddr()+request.getRequestURI() |
| | | ,"" |
| | | ,request.getRemoteAddr() |
| | | ,JSON.toJSONString(param) |
| | | ,JSON.toJSONString(result) |
| | | ,true |
| | | ); |
| | | } |
| | | boolean sign =false; |
| | | switch (param.getTaskStatus()) { |
| | | case 1://正常取消 |
| | | if (taskWrk.getStatus() > 1) { |
| | | return R.error("任务已开始执行"); |
| | | } |
| | | break; |
| | | case 2://正常完成 |
| | | if (taskWrk.getStatus() > 1) { |
| | | return R.error("任务已开始执行"); |
| | | } |
| | | sign = true; |
| | | break; |
| | | default: |
| | | return R.error("未知操作"); |
| | | } |
| | | return taskWrkOperate(taskWrk, sign); |
| | | } |
| | | |
| | | //任务操作 |
| | |
| | | @GetMapping("/deviceStatus") |
| | | @Transactional |
| | | public R deviceStatus() { |
| | | List<CrnStatusParam> crnStatusParams=new ArrayList<>(); |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp:basCrnps){ |
| | | CrnStatusParam crnStatusParam=new CrnStatusParam(); |
| | | crnStatusParam.setCrnNo(basCrnp.getCrnNo()); |
| | | crnStatusParam.setCrnSts(basCrnp.getCrnSts()); |
| | | crnStatusParam.setErrorCode(basCrnp.getCrnErr()); |
| | | BasCrnError error=basCrnErrorService.selectOne(new EntityWrapper<BasCrnError>().eq("error_code",basCrnp.getCrnErr())); |
| | | if(Cools.isEmpty(error)){ |
| | | crnStatusParam.setErrorMsg(""); |
| | | }else { |
| | | crnStatusParam.setErrorMsg(error.getErrName()); |
| | | } |
| | | crnStatusParams.add(crnStatusParam); |
| | | } |
| | | return R.ok(crnStatusParams); |
| | | List<CrnStatusParam> crnStatusParams = openService.getCrnStatus(); |
| | | List<StationStatusParam> stationStatus = openService.getStationStatus(); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("crn", crnStatusParams); |
| | | map.put("station", stationStatus); |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | //输送站点状态查询接口 |
| | | @GetMapping("/stationStatus") |
| | | @Transactional |
| | | public R stationStatus() { |
| | | List<StationStatusParam> data = openService.getStationStatus(); |
| | | return R.ok().add(data); |
| | | } |
| | | |
| | | //模拟输送线入库 |