| | |
| | | package com.zy.common.web; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.param.StatusParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.web.param.SearchLocParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private RowLastnoService rowLastnoService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Value("${wcs-slave.url}") |
| | | private String url; |
| | | @Value("${wcs-slave.loc}") |
| | | private String loc; |
| | | |
| | | @PostMapping("/pakin/loc/v1") |
| | | @PostMapping("/fromwcs/inware-task") |
| | | @ResponseBody |
| | | public synchronized R getLocNo(@RequestBody SearchLocParam param) { |
| | | public synchronized Re getLocNo(@RequestBody SearchLocParam param) { |
| | | log.info("收到WCS入库接口请求====>>入参:{}", param); |
| | | if (Cools.isEmpty(param.getIoType())) { |
| | | return R.error("入出库类型不能为空"); |
| | | if (Cools.isEmpty(param.getCargoHeight())) { |
| | | return Re.error("入出库类型不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getSourceStaNo())) { |
| | | return R.error("源站编号不能为空"); |
| | | if (Cools.isEmpty(param.getFromPort())) { |
| | | return Re.error("源站编号不能为空"); |
| | | } |
| | | List<WaitPakin> waitPakins = null; |
| | | if (param.getIoType() == 1) { |
| | | if (Cools.isEmpty(param.getBarcode())) { |
| | | return R.error("条码不能为空"); |
| | | if (param.getFromPort().equals("100")) { |
| | | |
| | | //有空板出库时禁止入库 |
| | | int wrkCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type",110).eq("sta_no",100)); |
| | | if(wrkCount > 0){ |
| | | return Re.error("有空板出库到100站时时禁止入库"); |
| | | } |
| | | waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode())); |
| | | |
| | | if (Cools.isEmpty(param.getBarCode())) { |
| | | return Re.error("条码不能为空"); |
| | | } |
| | | waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarCode())); |
| | | if (Cools.isEmpty(waitPakins)) { |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode()); |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarCode()); |
| | | if (wrkMast != null && wrkMast.getIoType() == 103) { |
| | | return R.parse(CodeRes.PICK_600); |
| | | return Re.parse(CodeRes.PICK_600); |
| | | } |
| | | return R.parse(CodeRes.NO_COMB_700); |
| | | return Re.parse(CodeRes.NO_COMB_700); |
| | | } |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode())); |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarCode())); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarCode())); |
| | | if (countLoc > 0 || countWrk > 0) { |
| | | return R.error(CodeRes.EXIST_500); |
| | | return Re.error(CodeRes.EXIST_500); |
| | | } |
| | | }else { |
| | | //有满板出库时禁止空板入库 |
| | | int wrkCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type",101).or().eq("io_type",110)); |
| | | if(wrkCount > 0){ |
| | | return Re.error("有满板出库时禁止空板入库"); |
| | | } |
| | | |
| | | int countLoc = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 10)); |
| | | if (countLoc > 0 ) { |
| | | return Re.error("已有空板入库任务禁止在入空板"); |
| | | } |
| | | } |
| | | if (Cools.isEmpty(param.getLocType1())){ |
| | | return R.error("高低检测信号不能为空"); |
| | | if (Cools.isEmpty(param.getCargoHeight())) { |
| | | return Re.error("高低检测信号不能为空"); |
| | | } |
| | | |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getSourceStaNo(), true); |
| | | sourceStaNo.setLocType1(param.getLocType1()); |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(Integer.valueOf(param.getFromPort()), true); |
| | | sourceStaNo.setLocType1(param.getCargoHeight().shortValue()); |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | |
| | | StartupDto dto = null; |
| | | switch (param.getIoType()) { |
| | | case 1://满托盘入库 |
| | | switch (param.getFromPort()) { |
| | | case "100"://满托盘入库 |
| | | assert waitPakins != null; |
| | | dto = startupFullPutStore(param.getSourceStaNo(), param.getBarcode(), locTypeDto, waitPakins); |
| | | dto = startupFullPutStore(Integer.valueOf(param.getFromPort()), param.getBarCode(), locTypeDto, waitPakins); |
| | | break; |
| | | case 10://空托盘入库 |
| | | dto = emptyPlateIn(param.getSourceStaNo(), locTypeDto, param.getBarcode()); |
| | | case "200"://空托盘入库 |
| | | dto = emptyPlateIn(Integer.valueOf(param.getFromPort()), locTypeDto, param.getBarCode()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | log.info("WCS入库接口返参:{},托盘码:{}", dto, param.getBarcode()); |
| | | return R.ok().add(dto); |
| | | log.info("WCS入库接口返参:{},托盘码:{}", dto, param.getBarCode()); |
| | | return Re.ok(); |
| | | } |
| | | |
| | | @PostMapping("/auto/emptyIn/v1") |
| | |
| | | } |
| | | EmptyPlateOutParam emptyPlateOutParam = new EmptyPlateOutParam(); |
| | | emptyPlateOutParam.setOutSite(12); |
| | | emptyPlateOutParam.setLocNos(new ArrayList<String>(){{add(locMast.getLocNo()+"");}}); |
| | | emptyPlateOutParam.setLocNos(new ArrayList<String>() {{ |
| | | add(locMast.getLocNo() + ""); |
| | | }}); |
| | | WrkMast wrkMast = workService.emptyPlateOut(emptyPlateOutParam); |
| | | return R.ok(!Cools.isEmpty(wrkMast)? R.ok("自动空托出库成功,工作号:" + wrkMast.getWrkNo()) : R.error("生成自动空托出库失败")); |
| | | } |
| | |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:生成入库ID |
| | | wrkMast.setWrkSts(0L); // 工作状态:0.待接收 |
| | | wrkMast.setIoType(1); // 入出库状态:1.入库 |
| | | wrkMast.setIoPri(13D); // 优先级 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("Y"); |
| | | wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | wrkMast.setMk("N");//是否完成上报wcs |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:生成入库ID |
| | | wrkMast.setWrkSts(0L); // 工作状态:0.待接收 |
| | | wrkMast.setIoType(10); // 入出库状态:10.空板入库 |
| | | wrkMast.setIoPri(13D); // 优先级 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | |
| | | return dto; |
| | | } |
| | | |
| | | @PostMapping("/fromwcs/task") |
| | | @ResponseBody |
| | | public Re status(@RequestBody StatusParam statusParam) { |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", statusParam.getTaskId())); |
| | | if(Cools.isEmpty(wrkMast)){ |
| | | return Re.error("没有找到:"+statusParam.getTaskId()+"这条任务"); |
| | | } |
| | | /** |
| | | * 任务状态 |
| | | * 执行过程中 |
| | | * 的状态。 0- 已 接 |
| | | * 收 , 1- 任 务 开 |
| | | * 始,2-取货完成,3- |
| | | * 任务中断,4-放货 |
| | | * 完成,8-任务结束 |
| | | */ |
| | | if (statusParam.getTaskStatus()==0){ |
| | | wrkMast.setWrkSts(1L);//1.已接收 |
| | | }else if (statusParam.getTaskStatus()==1){ |
| | | wrkMast.setWrkSts(2L);//2.任务开始 |
| | | }else if (statusParam.getTaskStatus()==2){ |
| | | wrkMast.setWrkSts(3L);//3.取货完成 |
| | | }else if (statusParam.getTaskStatus()==3){ |
| | | wrkMast.setWrkSts(6L);//6.任务中断 |
| | | } else if (statusParam.getTaskStatus()==4){ |
| | | wrkMast.setWrkSts(7L);//6.放货完成 |
| | | }if (statusParam.getTaskStatus()==8){ |
| | | if(wrkMast.getIoType()==1 || wrkMast.getIoType() == 10){ |
| | | wrkMast.setWrkSts(4L);//4.入库完成 |
| | | }else if (wrkMast.getIoType()==101 || wrkMast.getIoType() == 110){ |
| | | wrkMast.setWrkSts(14L);//14.已出库未确认 |
| | | } |
| | | } |
| | | wrkMastService.updateById(wrkMast); |
| | | return Re.ok(); |
| | | } |
| | | |
| | | @GetMapping("loc") |
| | | public void loc(){ |
| | | List<LocMast> locMasts=locMastService.selectList(new EntityWrapper<LocMast>()); |
| | | List<HashMap<String,Object>> mapList=new ArrayList<>(); |
| | | for (LocMast locMast : locMasts) { |
| | | if (locMast.getLev1()!=4){ |
| | | HashMap<String,Object> map=new HashMap<>(); |
| | | map.put("warehouse","wzzy"); |
| | | map.put("posiX",locMast.getRow1()); |
| | | map.put("posiY",locMast.getBay1()); |
| | | map.put("posiZ",locMast.getLev1()); |
| | | map.put("cargoNo",locMast.getLocNo()); |
| | | map.put("type","0"); |
| | | mapList.add(map); |
| | | } |
| | | } |
| | | if(mapList.size()>0){ |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(url) |
| | | .setPath(loc) |
| | | .setJson(JSON.toJSONString(mapList)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("returnStatus").equals(0)) { |
| | | success = true; |
| | | } else { |
| | | log.error("wms同步wcs库位失败!!!url:{};request:{};response:{}", url+"/"+loc, JSON.toJSONString(mapList), response); |
| | | throw new CoolException("wms下发任务给wcs失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | // TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | throw new CoolException("wms下发任务给wcs失败"); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "wms同步wcs库位失败", |
| | | url+"/"+loc, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(mapList), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { log.error("", e); } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |