| | |
| | | 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.StaDesc; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | 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.zy.asrs.entity.param.CarryParam; |
| | | import com.zy.asrs.entity.param.TaskCreateParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | private TaskWrkService taskWrkService; |
| | | |
| | | @Autowired |
| | | private CommandInfoService commandInfoService; |
| | | private LocMastService locMastService; |
| | | |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | private OpenService openService; |
| | | |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | |
| | | @Value("${wms.taskStatusFeedbackPath}") |
| | | private String taskStatusFeedbackPath; |
| | |
| | | @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));} |
| | | return R.ok(taskWrkService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | |
| | | try{ |
| | | Integer wrkNo = null; |
| | | String taskNo = null; |
| | | Integer status = null; |
| | | Date modiTimeStart = null, modiTimeEnd = null; |
| | | for (Map.Entry<String, Object> entry : param.entrySet()) { |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (Cools.isEmpty(val)) { |
| | | continue; |
| | | } |
| | | if (val.contains(RANGE_TIME_LINK)) { |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | modiTimeStart = DateUtils.convert(dates[0]); |
| | | modiTimeEnd = DateUtils.convert(dates[1]); |
| | | } else if (entry.getKey().equals("wrk_no")) { |
| | | wrkNo = Integer.parseInt(val); |
| | | } else if (entry.getKey().equals("task_no")) { |
| | | taskNo = val; |
| | | } else if (entry.getKey().equals("status")) { |
| | | status = Integer.parseInt(val); |
| | | } |
| | | } |
| | | |
| | | EntityWrapper<TaskWrk> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | |
| | | List<TaskWrk> taskWrkList = taskWrkService.selectTaskWrkList(wrkNo,taskNo,status,modiTimeStart,modiTimeEnd, curr, limit); |
| | | Page<TaskWrk> page = new Page<TaskWrk>(curr, limit).setRecords(taskWrkList); |
| | | page.setTotal(taskWrkService.selectTaskWrkListTotal(wrkNo,taskNo,status,modiTimeStart,modiTimeEnd)); |
| | | return R.ok(page); |
| | | // return R.ok(taskWrkService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | |
| | | } catch (Exception e) { |
| | | return R.error("查询失败,请检查参数:"+e.getMessage()); |
| | | } |
| | | |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/addTask/auth") |
| | | @ManagerAuth |
| | | public R addTaskPoint(CarryParam param){ |
| | | try{ |
| | | param.updateIoTyoe(param.getIoType());//中航下发 1:出库,2:移库 3:入库 ====转换为====> 1:入库,2:出库,3:移库 |
| | | param.updateLocNo(); |
| | | 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("任务类型为空!"); |
| | | } |
| | | if (Cools.isEmpty(param.getStartPoint()) || Cools.isEmpty(param.getTargetPoint())){ |
| | | return R.error("初始目标或者目标位为空"); |
| | | } |
| | | |
| | | |
| | | String locNo=null; |
| | | if(param.getIoType()==1){ |
| | | locNo=param.getTargetPoint(); |
| | | }else{ |
| | | locNo=param.getStartPoint(); |
| | | } |
| | | LocMast locMast = locMastService.selectByLocNo(locNo); |
| | | if(Cools.isEmpty(locMast)){ |
| | | return R.error("初始库位无法找到"); |
| | | } |
| | | |
| | | R r = null; |
| | | |
| | | if(param.getIoType() == 1){ |
| | | //入库任务创建 |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("type_no",1) |
| | | .eq("crn_no",locMast.getCrnNo()) |
| | | .eq("stn_no",param.getStartPoint())); |
| | | if(Cools.isEmpty(staDesc)){ |
| | | return R.error("入库路劲不存在"); |
| | | } |
| | | r = openService.taskCreate(new TaskCreateParam(param,staDesc.getCrnNo(),staDesc.getCrnStn())); |
| | | |
| | | }else if(param.getIoType() == 2){ |
| | | //出库任务创建 |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("type_no",2) |
| | | .eq("crn_no",locMast.getCrnNo()) |
| | | .eq("stn_no",param.getTargetPoint())); |
| | | if(Cools.isEmpty(staDesc)){ |
| | | return R.error("出库路劲不存在"); |
| | | } |
| | | r = openService.taskCreate(new TaskCreateParam(param,staDesc.getCrnNo(),staDesc.getStnNo())); |
| | | }else if (param.getIoType() == 3){ |
| | | LocMast locMast2 = locMastService.selectByLocNo(param.getTargetPoint()); |
| | | if(Cools.isEmpty(locMast2)){ |
| | | return R.error("目标库位无法找到"); |
| | | } |
| | | if (!locMast2.getCrnNo().equals(locMast.getCrnNo())){ |
| | | return R.error("起始库位与目标库位不再同一巷道"); |
| | | } |
| | | //移库任务创建 |
| | | r = openService.taskCreate(new TaskCreateParam(param,locMast.getCrnNo())); |
| | | } |
| | | |
| | | apiLogService.save("wcs手动生成Wms任务" |
| | | ,request.getRemoteAddr()+request.getRequestURI() |
| | | ,null |
| | | ,request.getRemoteAddr() |
| | | ,JSON.toJSONString(param) |
| | | ,r.toString() |
| | | ,true |
| | | ); |
| | | } catch (Exception e){ |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | taskWrkService.deleteById(id); |
| | | public R delete(@RequestParam String taskNo){ |
| | | // for (Long id : ids){ |
| | | // taskWrkService.deleteById(id); |
| | | // } |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); |
| | | if (taskWrk == null) { |
| | | return R.error(); |
| | | } |
| | | Date now = new Date(); |
| | | taskWrk.setMemo("手动强制删除!!!"); |
| | | taskWrk.setModiTime(now); |
| | | taskWrk.setModiUser(getUserId()); |
| | | if (!taskWrkService.updateById(taskWrk)){ |
| | | log.error("删除失败" + taskWrk); |
| | | return R.error("删除失败" + taskWrk); |
| | | |
| | | } |
| | | if (taskWrkService.saveToHistoryD(taskWrk.getTaskNo()) == 0) { |
| | | log.error("任务档转任务历史档失败" + taskWrk); |
| | | return R.error("任务档转任务历史档失败" + taskWrk); |
| | | |
| | | } |
| | | //删除任务 |
| | | taskWrkService.delete(new EntityWrapper<TaskWrk>().eq("task_no", taskWrk.getTaskNo())); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @ManagerAuth(memo = "手动完成任务") |
| | | public R complete(@RequestParam String taskNo) { |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); |
| | | if (Cools.isEmpty(taskWrk) || taskWrk.getStatus()>=3){ |
| | | if ((Cools.isEmpty(taskWrk) || taskWrk.getStatus()>=3) && !taskWrk.getStatus().equals(TaskStatusType.OVER3.id)){ |
| | | return R.error("已完结或已取消") ; |
| | | } |
| | | LocMast locMast=new LocMast(); |
| | |
| | | |
| | | } |
| | | String response=""; |
| | | try{ |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("taskNo",taskWrk.getTaskNo()); |
| | | headParam.put("status",taskWrk.getStatus()); |
| | | headParam.put("ioType",taskWrk.getIoType()); |
| | | headParam.put("barcode",taskWrk.getBarcode()); |
| | | // headParam.put("reportTime",new Date()); |
| | | log.info("wcs手动完成任务上报wms={}", taskWrk); |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(taskStatusFeedbackPath) |
| | | .setJson(JSON.toJSONString(headParam)) |
| | | .build() |
| | | .doPost(); |
| | | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | apiLogService.save("wcs手动完成任务上报wms" |
| | | ,wmsUrl+taskStatusFeedbackPath |
| | | ,null |
| | | ,"127.0.0.1" |
| | | ,JSON.toJSONString(headParam) |
| | | ,response |
| | | ,true |
| | | ); |
| | | }catch (Exception e){ |
| | | log.error("wcs手动完成任务上报wms失{},返回值={}", taskWrk,response); |
| | | // throw new CoolException(e); |
| | | } |
| | | Date now = new Date(); |
| | | locMast.setModiTime(now); |
| | | locMastService.updateById(locMast); |
| | | taskWrk.setStatus(7);//手动完成任务 |
| | | taskWrk.setStatus(TaskStatusType.OVER2.id);//手动完成任务 |
| | | taskWrk.setModiTime(now); |
| | | taskWrk.setCompleteTime(now); |
| | | // try{ |
| | | // HashMap<String, Object> headParam = new HashMap<>(); |
| | | // headParam.put("taskNo",taskWrk.getTaskNo()); |
| | | // headParam.put("taskStatus",taskWrk.getStatusWms()); |
| | | // headParam.put("ioType",taskWrk.getIoTypeWms()); |
| | | // headParam.put("barCode",taskWrk.getBarcode()); |
| | | // headParam.put("reportTime", LocalDateTime.now()); |
| | | // headParam.put("weight",taskWrk.getScWeight().doubleValue()); |
| | | // |
| | | // log.info("wcs手动完成任务上报wms={}", taskWrk); |
| | | // response = new HttpHandler.Builder() |
| | | // // .setHeaders(headParam) |
| | | // .setUri(wmsUrl) |
| | | // .setPath(taskStatusFeedbackPath) |
| | | // .setJson(JSON.toJSONString(headParam)) |
| | | // .build() |
| | | // .doPost(); |
| | | // |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // apiLogService.save("wcs手动完成任务上报wms" |
| | | // ,wmsUrl+taskStatusFeedbackPath |
| | | // ,null |
| | | // ,"127.0.0.1" |
| | | // ,JSON.toJSONString(headParam) |
| | | // ,response |
| | | // ,true |
| | | // ); |
| | | // }catch (Exception e){ |
| | | // log.error("wcs手动完成任务上报wms失{},返回值={}", taskWrk,response); |
| | | //// throw new CoolException(e); |
| | | // } |
| | | locMastService.updateById(locMast); |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | | } |
| | |
| | | taskWrk.setModiUser(1111L);//操作员 |
| | | } |
| | | String response=""; |
| | | try{ |
| | | HashMap<String, Object> headParam = new HashMap<>(); |
| | | headParam.put("taskNo",taskWrk.getTaskNo()); |
| | | headParam.put("status",taskWrk.getStatus()); |
| | | headParam.put("ioType",taskWrk.getIoType()); |
| | | headParam.put("barcode",taskWrk.getBarcode()); |
| | | // headParam.put("reportTime",new Date()); |
| | | |
| | | log.info("wcs手动取消任务上报wm={}", taskWrk); |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(taskStatusFeedbackPath) |
| | | .setJson(JSON.toJSONString(headParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | apiLogService.save("wcs手动取消任务上报wms" |
| | | ,wmsUrl+taskStatusFeedbackPath |
| | | ,null |
| | | ,"127.0.0.1" |
| | | ,JSON.toJSONString(headParam) |
| | | ,response |
| | | ,true |
| | | ); |
| | | }catch (Exception e){ |
| | | log.error("wcs手动取消任务上报wms失败={},返回值={}", taskWrk,response); |
| | | // throw new CoolException(e); |
| | | } |
| | | // try{ |
| | | // HashMap<String, Object> headParam = new HashMap<>(); |
| | | // headParam.put("taskNo",taskWrk.getTaskNo()); |
| | | // headParam.put("taskStatus",taskWrk.getStatusWms()); |
| | | // headParam.put("ioType",taskWrk.getIoTypeWms()); |
| | | // headParam.put("barCode",taskWrk.getBarcode()); |
| | | // headParam.put("reportTime", LocalDateTime.now()); |
| | | // headParam.put("weight",taskWrk.getScWeight().doubleValue()); |
| | | // |
| | | // |
| | | // log.info("wcs手动取消任务上报wm={}", taskWrk); |
| | | // response = new HttpHandler.Builder() |
| | | // // .setHeaders(headParam) |
| | | // .setUri(wmsUrl) |
| | | // .setPath(taskStatusFeedbackPath) |
| | | // .setJson(JSON.toJSONString(headParam)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // apiLogService.save("wcs手动取消任务上报wms" |
| | | // ,wmsUrl+taskStatusFeedbackPath |
| | | // ,null |
| | | // ,"127.0.0.1" |
| | | // ,JSON.toJSONString(headParam) |
| | | // ,response |
| | | // ,true |
| | | // ); |
| | | // }catch (Exception e){ |
| | | // log.error("wcs手动取消任务上报wms失败={},返回值={}", taskWrk,response); |
| | | //// throw new CoolException(e); |
| | | // } |
| | | taskWrk.setCompleteTime(now);//完结时间 |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | |
| | | return R.ok(); |
| | | } else if (!Cools.isEmpty(taskWrk) && taskWrk.getWrkSts()==3) { |
| | | taskWrk.setWrkSts(2); |
| | | taskWrk.setStatus(TaskStatusType.RECEIVE.id);//派发状态 |
| | | taskWrkService.updateById(taskWrk); |
| | | if(!taskWrkService.updateById(taskWrk)){ |
| | | return R.error("更新任务状态失败"); |
| | |
| | | } |
| | | |
| | | } |
| | | @PostMapping(value = "/taskWrk/assign/auth") |
| | | @ManagerAuth(memo = "输送线下发完成") |
| | | public R returnAssign(@RequestParam String taskNo) { |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); |
| | | if (!Cools.isEmpty(taskWrk) && taskWrk.getWrkSts()==1){ |
| | | taskWrk.setStatus(TaskStatusType.RECEIVE.id);//派发状态 |
| | | taskWrk.setWrkSts(2); |
| | | if(!taskWrkService.updateById(taskWrk)){ |
| | | return R.error("更新任务状态失败"); |
| | | } |
| | | return R.ok(); |
| | | }else{ |
| | | return R.error("任务状态不对无法跳转"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |