| | |
| | | throw new CoolException("任务档不存在!!"); |
| | | } |
| | | log.info("任务执行参数回写:{}", JSON.toJSONString(params)); |
| | | if (params.getMsgType().equals("task_complete") || params.getMsgType().equals("station_out_task_run_complete") || params.getMsgType().equals("station_out_task_run")) { |
| | | if (params.getMsgType().equals("task_complete") || params.getMsgType().equals("station_out_task_run_complete")) { |
| | | if (mast.getIoType() == 1 || mast.getIoType() == 11 || mast.getIoType() == 10 || mast.getIoType() == 53 || mast.getIoType() == 54 || mast.getIoType() == 57) { |
| | | mast.setWrkSts(4L); |
| | | } else if (mast.getIoType() == 101 || mast.getIoType() == 110 || mast.getIoType() == 103 || mast.getIoType() == 104 || mast.getIoType() == 107) { |
| | |
| | | private WaitPakinService waitPakinService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 组托查询接口 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 任务查询接口 |
| | | */ |
| | | @PostMapping("/queryTask") |
| | | public synchronized R queryTask(@RequestBody QueryTaskParam param) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("任务号[taskNo]不能为空"); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no",param.getTaskNo())); |
| | | if (wrkMast == null) { |
| | | return R.error("任务不存在"); |
| | | } |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(Integer.valueOf(param.getTaskNo())); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("taskNo", param.getTaskNo()); |
| | | map.put("ioType", wrkMast.getIoType()); |
| | | map.put("wrkDetls", wrkDetls); |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | /** |
| | | * 库存信息查询接口 |
| | | */ |
| | | @GetMapping("/queryLoc") |
| | |
| | | package com.zy.asrs.entity.param; |
| | | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | |
| | | // 数量 |
| | | private Double count; |
| | | |
| | | private String brand; |
| | | |
| | | /** |
| | | * 备用1 |
| | | */ |
| | | @ApiModelProperty(value= "备用1") |
| | | private String standby1 = ""; |
| | | |
| | | /** |
| | | * 备用2 |
| | | */ |
| | | @ApiModelProperty(value= "备用2") |
| | | private String standby2 = ""; |
| | | |
| | | /** |
| | | * 备用3 |
| | | */ |
| | | @ApiModelProperty(value= "备用3") |
| | | private String standby3 = ""; |
| | | |
| | | /** |
| | | * 备用1 |
| | | */ |
| | | @ApiModelProperty(value= "备用1") |
| | | @TableField("box_type1") |
| | | private String boxType1 = "1"; |
| | | |
| | | /** |
| | | * 备用2 |
| | | */ |
| | | @ApiModelProperty(value= "备用2") |
| | | @TableField("box_type2") |
| | | private String boxType2 = "1"; |
| | | |
| | | /** |
| | | * 备用3 |
| | | */ |
| | | @ApiModelProperty(value= "备用3") |
| | | @TableField("box_type3") |
| | | private String boxType3 = "1"; |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>() |
| | | .eq("matnr", stationDetl.getMatnr()) |
| | | .eq("wrk_no", wrkMast.getWrkNo()) |
| | | .eq("suppCode", combMat.getSuppCode())); |
| | | .eq("supp_code", combMat.getSuppCode())); |
| | | |
| | | if (Objects.isNull(wrkDetl)) { |
| | | //TODO 新插入 |
| | |
| | | } |
| | | |
| | | } |
| | | // // 判断是否有相同条码的数据 |
| | | // if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()) |
| | | // .eq("io_status", "N")) > 0) { |
| | | // throw new CoolException(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 (countWrk > 0 || countLoc > 0) { |
| | | // WrkMast wrkDetl = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode())); |
| | | // if (!wrkDetl.getIoType().equals(TaskIOType.MERGE_OUT.type)) { |
| | | // throw new CoolException("组托档/工作档/库存条码数据已存在===>>" + param.getBarcode()); |
| | | // } |
| | | // } |
| | | // int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode())); |
| | | // if (countwait > 0) { |
| | | // throw new CoolException("组托档/工作档/库存条码数据已存在===>>" + param.getBarcode()); |
| | | // } |
| | | // |
| | | // // 生成入库通知档 |
| | | // List<DetlDto> detlDtos = new ArrayList<>(); |
| | | // param.getCombMats().forEach(elem -> { |
| | | // DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), |
| | | // elem.getStandby2(), elem.getStandby3(), |
| | | // elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme(), elem.getThreeCode()); |
| | | // if (DetlDto.has(detlDtos, detlDto)) { |
| | | // DetlDto one = DetlDto.findDto(detlDtos, detlDto); |
| | | // assert one != null; |
| | | // one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | // } else { |
| | | // detlDtos.add(detlDto); |
| | | // } |
| | | // }); |
| | | // BasContainer container = basContainerService |
| | | // .selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode())); |
| | | // if (Objects.isNull(container)) { |
| | | // throw new CoolException("数据错误:容器码不存在!!"); |
| | | // } |
| | | // if (container.getMixMax() < detlDtos.size()) { |
| | | // throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | // } |
| | | // List<Mat> tempMats = new ArrayList<>(); |
| | | // for (DetlDto detlDto : detlDtos) { |
| | | // Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", detlDto.getMatnr()) |
| | | // .eq("supp_code", detlDto.getStandby1())); |
| | | // tempMats.add(mat); |
| | | // } |
| | | // Set<Long> tagIds = tempMats.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | // if (tagIds.size() > 1) { |
| | | // throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | // } |
| | | // // 还可以放入多少种物料 |
| | | // Double suplus = container.getMixMax(); |
| | | // Date now = new Date(); |
| | | // for (DetlDto detlDto : detlDtos) { |
| | | // Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | // if (Cools.isEmpty(mat)) { |
| | | // throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | // } |
| | | // // 最多可放数量 |
| | | // Double singleMax = mat.getUpQty() * suplus; |
| | | // if (singleMax.compareTo(detlDto.getAnfme()) < 0) { |
| | | // throw new CoolException("物料:" + detlDto.getMatnr() + "单次组托上限为:" + mat.getUpQty() + ",当前总量超出托盘装载上限!!"); |
| | | // } |
| | | // BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty()); |
| | | // // 当前物料需要占用料箱格数 |
| | | // Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue(); |
| | | // suplus = suplus - curr; |
| | | // if (suplus < 0) { |
| | | // throw new CoolException("物料:" + detlDto.getMatnr() + ", 超出当前托盘装载上限!!"); |
| | | // } |
| | | // |
| | | // BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | // .eq("zpallet", param.getCarBarcode()) |
| | | // .eq("three_code", detlDto.getThreeCode())); |
| | | // if (Objects.isNull(stationDetl)) { |
| | | // throw new CoolException("明细内容不存在!!"); |
| | | // } |
| | | // |
| | | // Double v = Math.round((stationDetl.getAnfme() - stationDetl.getWorkQty()) * 10000) / 10000.0; |
| | | // if (detlDto.getAnfme().compareTo(v) > 0) { |
| | | // throw new CoolException("组托上限为:" + stationDetl.getAnfme() + ", 已组托:" + stationDetl.getWorkQty() + ", 还可组托:" + v); |
| | | // } |
| | | // |
| | | // WaitPakin waitPakin = new WaitPakin(); |
| | | // BeanUtils.copyProperties(mat, waitPakin); |
| | | // waitPakin.setBatch(detlDto.getBatch()); |
| | | // waitPakin.setType(param.getType()); |
| | | // waitPakin.setZpallet(param.getBarcode()); |
| | | // // 设置组托类型 |
| | | // waitPakin.setType(param.getType()); |
| | | // waitPakin.setIoStatus("N"); |
| | | // waitPakin.setAnfme(detlDto.getAnfme()); |
| | | // waitPakin.setThreeCode(detlDto.getThreeCode()); |
| | | // waitPakin.setStatus("Y"); |
| | | // waitPakin.setSuppCode(detlDto.getStandby1()); |
| | | // waitPakin.setStandby1(detlDto.getStandby1()); |
| | | // waitPakin.setStandby2(detlDto.getStandby2()); |
| | | // waitPakin.setStandby3(detlDto.getStandby3()); |
| | | // waitPakin.setBoxType1(detlDto.getBoxType1()); |
| | | // waitPakin.setBoxType2(detlDto.getBoxType2()); |
| | | // waitPakin.setBoxType3(detlDto.getBoxType3()); |
| | | // waitPakin.setAppeUser(userId); |
| | | // waitPakin.setAppeTime(now); |
| | | // waitPakin.setModiUser(userId); |
| | | // waitPakin.setModiTime(now); |
| | | // if (!waitPakinService.insert(waitPakin)) { |
| | | // throw new CoolException("保存入库通知档失败"); |
| | | // } |
| | | // |
| | | // Double v1 = Math.round((stationDetl.getWorkQty() + detlDto.getAnfme()) * 10000) / 10000.0; |
| | | // stationDetl.setWorkQty(v1); |
| | | // |
| | | // if (!basStationDetlService.updateById(stationDetl)) { |
| | | // throw new CoolException("站点明细修改失败"); |
| | | // } |
| | | // |
| | | // if (v1.compareTo(stationDetl.getAnfme()) >= 0) { |
| | | // if (!basStationDetlService.deleteById(stationDetl)) { |
| | | // throw new CoolException("原始数据移除失败!"); |
| | | // } |
| | | // } |
| | | // |
| | | // List<BasStationDetl> stas = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>() |
| | | // .eq("dev_no", stationDetl.getDevNo())); |
| | | // if (Objects.isNull(stas) || stas.isEmpty()) { |
| | | // BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", stationDetl.getDevNo())); |
| | | // if (Objects.isNull(station)) { |
| | | // throw new CoolException("数据错误,站点不存在!!"); |
| | | // } |
| | | // station.setLocSts(LocStsType.LOC_STS_TYPE_O.type); |
| | | // station.setBarcode(""); |
| | | // if (!basStationService.updateById(station)) { |
| | | // throw new CoolException("站点状态更新失败!!"); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private TagMapper tagMapper; |
| | | @Autowired |
| | | private CheckOrderService checkOrderService; |
| | | @Autowired |
| | | private CheckOrderDetlService checkOrderDetlService; |
| | | |
| | | |
| | |
| | | if (Objects.isNull(material)) { |
| | | throw new CoolException(material.getMatnr() + "物料不存在"); |
| | | } |
| | | //TODO 正常完结需要打开 |
| | | // TaskDetlLog detlLog = taskDetlLogService.selectOne(new EntityWrapper<TaskDetlLog>() |
| | | // .eq("matnr", detl.getMatnr()) |
| | | // .eq("supp_code", detl.getStandby1()) |
| | | // .eq("order_no", detl.getOrderNo())); |
| | | // if (Objects.isNull(detlLog)) { |
| | | // throw new CoolException("数据错误 ,请检查AGV任务档是否已完成!!"); |
| | | // } |
| | | WrkDetlLog detlLog = wrkDetlLogService.selectOne(new EntityWrapper<WrkDetlLog>() |
| | | TaskDetlLog detlLog = taskDetlLogService.selectOne(new EntityWrapper<TaskDetlLog>() |
| | | .eq("matnr", detl.getMatnr()) |
| | | .eq("supp_code", detl.getStandby1()) |
| | | .eq("order_no", detl.getOrderNo())); |
| | | if (Objects.isNull(detlLog)) { |
| | | throw new CoolException("数据错误 ,请检查AGV任务档是否已完成!!"); |
| | | } |
| | | /* WrkDetlLog detlLog = wrkDetlLogService.selectOne(new EntityWrapper<WrkDetlLog>() |
| | | .eq("matnr", detl.getMatnr()) |
| | | .eq("supp_code", detl.getStandby1()) |
| | | .eq("order_no", detl.getOrderNo())); |
| | | if (Objects.isNull(detlLog)) { |
| | | throw new CoolException("物料编码:" + detl.getMatnr() + "数据错误 ,请检查堆垛机任务档是否已完成!!"); |
| | | } |
| | | }*/ |
| | | //目标库区 |
| | | orderParam.setTarget_location("2"); |
| | | // orderParam.setTarget_location(detlLog.getAreaType()); |
| | | // orderParam.setTarget_location("2"); |
| | | orderParam.setTarget_location(detlLog.getAreaType()); |
| | | OrderItemsParam itemParam = new OrderItemsParam(); |
| | | // BS Code |
| | | itemParam |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // OrderPakin orderPakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", pakin.getOrderNo())); |
| | | // if (Objects.isNull(orderPakin)) { |
| | | // throw new CoolException("数据错误,订单信息不存在!!"); |
| | | // } |
| | | // |
| | | // if (!orderPakin.getDocType().equals(0)) { |
| | | // // 更新订单完成数量 |
| | | // OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectItem(pakin.getOrderNo(), |
| | | // pakin.getMatnr(), pakin.getBatch(), pakin.getBrand(), pakin.getStandby1(), |
| | | // pakin.getStandby2(), pakin.getStandby3(), |
| | | // pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3()); |
| | | // if (orderDetlPakin == null) { |
| | | // orderDetlPakin = orderDetlPakinService.selectItem(pakin.getOrderNo(), pakin.getMatnr(), |
| | | // pakin.getBatch(), |
| | | // pakin.getBrand(), pakin.getStandby1(), pakin.getStandby2(), |
| | | // pakin.getStandby3(), |
| | | // pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3()); |
| | | // } |
| | | // try { |
| | | // if (!Cools.isEmpty(orderDetlPakin)) { |
| | | // if (!orderDetlPakinService.increaseQtyByOrderNo(pakin.getOrderNo(), |
| | | // pakin.getMatnr(), |
| | | // orderDetlPakin.getBatch(), pakin.getBrand(), pakin.getStandby1(), |
| | | // pakin.getStandby2(), pakin.getStandby3(), |
| | | // pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3(), |
| | | // pakin.getAnfme())) { |
| | | // throw new CoolException("AGV全板入库 ===>> 更新订单完成数量失败; [workNo=" + wrkMast.getWrkNo() |
| | | // + "],[locNo=" + wrkMast.getLocNo() + "]"); |
| | | // } |
| | | // } |
| | | // } catch (Exception ignore) { |
| | | // |
| | | // } |
| | | // } |
| | | |
| | | // 更新订单完成数量 |
| | | OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectItem(wrkDetl.getOrderNo(), |
| | | wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getBrand(), wrkDetl.getStandby1(), |
| | |
| | | throw new CoolException("库位明细保存失败!!"); |
| | | } |
| | | |
| | | OrderPakin orderPakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", pakin.getOrderNo())); |
| | | if (Objects.isNull(orderPakin)) { |
| | | throw new CoolException("数据错误,订单信息不存在!!"); |
| | | } |
| | | |
| | | if (!orderPakin.getDocType().equals(0)) { |
| | | // 更新订单完成数量 |
| | | OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectItem(pakin.getOrderNo(), |
| | | pakin.getMatnr(), pakin.getBatch(), pakin.getBrand(), pakin.getStandby1(), |
| | | pakin.getStandby2(), pakin.getStandby3(), |
| | | pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3()); |
| | | if (orderDetlPakin == null) { |
| | | orderDetlPakin = orderDetlPakinService.selectItem(pakin.getOrderNo(), pakin.getMatnr(), |
| | | pakin.getBatch(), |
| | | pakin.getBrand(), pakin.getStandby1(), pakin.getStandby2(), |
| | | pakin.getStandby3(), |
| | | pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3()); |
| | | } |
| | | try { |
| | | if (!Cools.isEmpty(orderDetlPakin)) { |
| | | if (!orderDetlPakinService.increaseQtyByOrderNo(pakin.getOrderNo(), |
| | | pakin.getMatnr(), |
| | | orderDetlPakin.getBatch(), pakin.getBrand(), pakin.getStandby1(), |
| | | pakin.getStandby2(), pakin.getStandby3(), |
| | | pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3(), |
| | | pakin.getAnfme())) { |
| | | throw new CoolException("AGV全板入库 ===>> 更新订单完成数量失败; [workNo=" + wrkMast.getWrkNo() |
| | | + "],[locNo=" + wrkMast.getLocNo() + "]"); |
| | | } |
| | | } |
| | | } catch (Exception ignore) { |
| | | |
| | | } |
| | | } |
| | | // OrderPakin orderPakin = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", pakin.getOrderNo())); |
| | | // if (Objects.isNull(orderPakin)) { |
| | | // throw new CoolException("数据错误,订单信息不存在!!"); |
| | | // } |
| | | // |
| | | // if (!orderPakin.getDocType().equals(0)) { |
| | | // // 更新订单完成数量 |
| | | // OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectItem(pakin.getOrderNo(), |
| | | // pakin.getMatnr(), pakin.getBatch(), pakin.getBrand(), pakin.getStandby1(), |
| | | // pakin.getStandby2(), pakin.getStandby3(), |
| | | // pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3()); |
| | | // if (orderDetlPakin == null) { |
| | | // orderDetlPakin = orderDetlPakinService.selectItem(pakin.getOrderNo(), pakin.getMatnr(), |
| | | // pakin.getBatch(), |
| | | // pakin.getBrand(), pakin.getStandby1(), pakin.getStandby2(), |
| | | // pakin.getStandby3(), |
| | | // pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3()); |
| | | // } |
| | | // try { |
| | | // if (!Cools.isEmpty(orderDetlPakin)) { |
| | | // if (!orderDetlPakinService.increaseQtyByOrderNo(pakin.getOrderNo(), |
| | | // pakin.getMatnr(), |
| | | // orderDetlPakin.getBatch(), pakin.getBrand(), pakin.getStandby1(), |
| | | // pakin.getStandby2(), pakin.getStandby3(), |
| | | // pakin.getBoxType1(), pakin.getBoxType2(), pakin.getBoxType3(), |
| | | // pakin.getAnfme())) { |
| | | // throw new CoolException("AGV全板入库 ===>> 更新订单完成数量失败; [workNo=" + wrkMast.getWrkNo() |
| | | // + "],[locNo=" + wrkMast.getLocNo() + "]"); |
| | | // } |
| | | // } |
| | | // } catch (Exception ignore) { |
| | | // |
| | | // } |
| | | // } |
| | | }); |
| | | |
| | | locCache.setLocSts(LocStsType.LOC_STS_TYPE_F.type); |
| | |
| | | public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) { |
| | | int row = getRow(deepLoc); |
| | | int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount()); |
| | | int shallowRow = remainder == 1 ? (row + 1) : (row - 1); |
| | | // 奇数排(1, 3...)对应的浅库位是 row + 1 |
| | | // 偶数排(2, 4...)对应的浅库位是 row - 1 |
| | | int shallowRow = (remainder % 2 != 0) ? (row + 1) : (row - 1); |
| | | return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2); |
| | | } |
| | | |
| | |
| | | */ |
| | | public static Integer getShallowRow(SlaveProperties slaveProperties, Integer deepRow) { |
| | | int remainder = (int) Arith.remainder(deepRow, slaveProperties.getGroupCount()); |
| | | return remainder == 1 ? (deepRow + 1) : (deepRow - 1); |
| | | return (remainder % 2 != 0) ? (deepRow + 1) : (deepRow - 1); |
| | | } |
| | | |
| | | /** |
| | |
| | | public DetlDto() { |
| | | } |
| | | |
| | | public DetlDto(String matnr, Double anfme) { |
| | | this.matnr = matnr; |
| | | this.anfme = anfme; |
| | | } |
| | | |
| | | public DetlDto(String matnr, String batch) { |
| | | this.matnr = matnr; |
| | | this.batch = batch; |
| | | } |
| | | |
| | | public DetlDto(String matnr, String batch, Double anfme) { |
| | | this.matnr = matnr; |
| | | this.batch = batch; |
| | | this.anfme = anfme; |
| | | } |
| | | |
| | | public DetlDto(String orderNo, String matnr, String batch, Double anfme) { |
| | | this.orderNo = orderNo; |
| | | this.matnr = matnr; |
| | | this.batch = batch; |
| | | this.anfme = anfme; |
| | | } |
| | | |
| | | public DetlDto(String matnr, String batch, String brand, String standby1, String standby2, String standby3, String boxType1, String boxType2, String boxType3, String threeCode) { |
| | | this.matnr = matnr; |
| | | this.batch = batch; |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static DetlDto find(List<DetlDto> detlDtos, String matnr, String batch) { |
| | | if (Cools.isEmpty(matnr)) { |
| | | return null; |
| | | } |
| | | for (DetlDto detlDto : detlDtos) { |
| | | if (matnr.equals(detlDto.getMatnr()) && Cools.eq(batch, detlDto.getBatch())) { |
| | | return detlDto; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| | |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | public StartupDto getDoubleLocNoRun(Integer whsType, Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, Integer moveCrnNo, LocTypeDto locTypeDto, int times) { |
| | | // 初始化参数 |
| | | int crnNo = 6; //堆垛机号 |
| | | int nearRow = 11; //最浅库位排 |
| | | int curRow = 14; //最深库位排 |
| | | int rowCount = 0; //轮询轮次 |
| | | LocMast locMast = null; // 目标库位 |
| | | // 1. 初始化参数 |
| | | int crnNo = 6; // 堆垛机号 |
| | | int deepRow, shallowRow; |
| | | int rowCount = 2; // 轮询两组货架 (11/12 对 和 14/13 对) |
| | | |
| | | // 根据轮询次数切换排,严格保证深位优先 |
| | | if (times % 2 == 0) { |
| | | deepRow = 11; |
| | | shallowRow = 12; |
| | | } else { |
| | | deepRow = 14; |
| | | shallowRow = 13; |
| | | } |
| | | |
| | | StartupDto startupDto = new StartupDto(); |
| | | RowLastno rowLastno = rowLastnoService.selectById(whsType); |
| | |
| | | if (Cools.isEmpty(rowLastnoType)) { |
| | | throw new CoolException("数据异常,请联系管理员===》库位规则类型未知"); |
| | | } |
| | | int sRow = rowLastno.getsRow(); |
| | | int eRow = rowLastno.geteRow(); |
| | | int crnNumber = rowLastno.getCrnQty(); |
| | | |
| | | LocMast locMast = null; |
| | | |
| | | // ===============>>>> 开始执行 |
| | | curRow = rowLastno.getCurrentRow(); |
| | | // 2. 开始检索 (优先级:深位堆叠 > 深位空位 > 浅位空位) |
| | | |
| | | if (!Cools.isEmpty(moveCrnNo) && moveCrnNo != 0) { |
| | | crnNumber = moveCrnNo; |
| | | if (times == 0) { |
| | | curRow = moveCrnNo * 4 - 1; |
| | | } else { |
| | | curRow = moveCrnNo * 4 - 2; |
| | | } |
| | | } |
| | | // A. 优先尝试:深位为空,且其对应的浅位已经存放了相同物料 (实现 signRule1 的核心逻辑) |
| | | if (Utils.BooleanWhsTypeStaIoType(rowLastno) && !Cools.isEmpty(findLocNoAttributeVo.getMatnr())) { |
| | | List<LocMast> shallowMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", shallowRow) |
| | | .eq("loc_sts", "F") |
| | | .eq("crn_no", crnNo)); |
| | | |
| | | // //此程序用于优化堆垛机异常时的运行时间 |
| | | // for (int i = times; i < crnNumber * 2; i++) { |
| | | // int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRow, crnNumber); |
| | | // curRow = locNecessaryParameters[1]; |
| | | // crnNo = locNecessaryParameters[2]; |
| | | // if (basCrnpService.checkSiteError(crnNo, true)) { |
| | | // rowCount = locNecessaryParameters[0]; |
| | | // nearRow = locNecessaryParameters[3]; |
| | | // List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | // .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); |
| | | // int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).le("io_type", 100)); |
| | | // if (locMasts.size() - crnCountO <= 2) { |
| | | // log.error(crnNo + "号堆垛机没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); |
| | | // nearRow = 0; |
| | | // times++; |
| | | // continue; |
| | | // } |
| | | // break; |
| | | // } else { |
| | | // times++; |
| | | // } |
| | | // } |
| | | if (nearRow == 0) { |
| | | throw new CoolException("无可用堆垛机"); |
| | | } |
| | | for (LocMast sLoc : shallowMasts) { |
| | | LocDetl detl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", sLoc.getLocNo())); |
| | | if (detl != null && detl.getMatnr().equals(findLocNoAttributeVo.getMatnr()) |
| | | && detl.getBatch().equals(findLocNoAttributeVo.getBatch())) { |
| | | |
| | | boolean signRule1 = false; |
| | | boolean signRule2 = false; |
| | | String dLocNo = Utils.getDeepLoc(slaveProperties, sLoc.getLocNo()); |
| | | LocMast dLoc = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", dLocNo) |
| | | .eq("loc_sts", "O")); |
| | | |
| | | |
| | | if (Utils.BooleanWhsTypeStaIoType(rowLastno)) { |
| | | // 靠近摆放规则 --- 同天同规格物料 //分离版 |
| | | if (!Cools.isEmpty(findLocNoAttributeVo.getMatnr()) && staDescId == 1) { |
| | | signRule1 = true; |
| | | } |
| | | // 靠近摆放规则 --- 同天同规格物料 //互通版 |
| | | if (!Cools.isEmpty(findLocNoAttributeVo.getMatnr()) && staDescId == 1) { |
| | | signRule2 = true; |
| | | } |
| | | |
| | | if (!Cools.isEmpty(findLocNoAttributeVo.getMatnr()) && (staDescId == 11 || staDescId == 111)) { |
| | | signRule1 = true; |
| | | } |
| | | } |
| | | |
| | | if (signRule1) { |
| | | if (nearRow != curRow) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", nearRow).eq("loc_sts", "O").eq("crn_no", crnNo)); |
| | | for (LocMast locMast1 : locMasts) { |
| | | //获取巷道 |
| | | // List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,locMast1.getLocNo(), curRow>nearRow); |
| | | // LocMast locMastGro = locMastService.selectById(wrkMast.getLocNo()); |
| | | //获取目标库位所在巷道最浅非空库位 |
| | | LocMast locMastF = locMastService.selectLocByLocStsPakInF(curRow, nearRow, locMast1, rowLastnoType.getType().longValue()); |
| | | if (!Cools.isEmpty(locMastF) && locMastF.getLocSts().equals("F")) { |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locMastF.getLocNo())); |
| | | if (!Cools.isEmpty(locDetl) && findLocNoAttributeVo.getMatnr().equals(locDetl.getMatnr()) |
| | | && findLocNoAttributeVo.getBatch().equals(locDetl.getBatch()) |
| | | && findLocNoAttributeVo.getBrand().equals(locDetl.getBrand())) { |
| | | //获取目标库位所在巷道最深空库位 |
| | | locMast = locMastService.selectLocByLocStsPakInO(curRow, nearRow, locMast1, rowLastnoType.getType().longValue()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else if (signRule2) { |
| | | List<String> locNos = locDetlService.getSameDetlToday(findLocNoAttributeVo.getMatnr(), sRow, eRow); |
| | | for (String locNo : locNos) { |
| | | if (Utils.isShallowLoc(slaveProperties, locNo)) { |
| | | continue; |
| | | } |
| | | String shallowLocNo = Utils.getShallowLoc(slaveProperties, locNo); |
| | | // 检测目标库位是否为空库位 |
| | | LocMast shallowLoc = locMastService.selectById(shallowLocNo); |
| | | if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { |
| | | if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) { |
| | | if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { |
| | | locMast = shallowLoc; |
| | | crnNo = locMast.getCrnNo(); |
| | | break; |
| | | } |
| | | if (dLoc != null && VersionUtils.locMoveCheckLocTypeComplete(dLoc, locTypeDto)) { |
| | | locMast = dLoc; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // // 靠近摆放规则 --- 空托 //分离版 |
| | | // if (staDescId == 10 && Utils.BooleanWhsTypeStaIoType(whsType)) { |
| | | // List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("row1", nearRow).eq("loc_sts", "O")); |
| | | // for (LocMast locMast1:locMasts){ |
| | | // if (VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { |
| | | // continue; |
| | | // } |
| | | // String shallowLoc = Utils.getDeepLoc(slaveProperties,locMast1.getLocNo()); |
| | | // LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",shallowLoc)); |
| | | // if (!Cools.isEmpty(locMast2) && locMast2.getLocSts().equals("D")){ |
| | | // locMast = locMast1; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // // 靠近摆放规则 --- 空托 //互通版 |
| | | // if (staDescId == 10 && Utils.BooleanWhsTypeStaIoType(rowLastno)) { |
| | | // List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | // .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue())); |
| | | // if (!locMasts.isEmpty()) { |
| | | // for (LocMast loc : locMasts) { |
| | | // if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) { |
| | | // continue; |
| | | // } |
| | | // String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo()); |
| | | // // 检测目标库位是否为空库位 |
| | | // LocMast shallowLoc = locMastService.selectById(shallowLocNo); |
| | | // if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { |
| | | // if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) { |
| | | // if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { |
| | | // locMast = shallowLoc; |
| | | // crnNo = locMast.getCrnNo(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | Wrapper<StaDesc> wrapper = null; |
| | | StaDesc staDesc = null; |
| | | BasDevp staNo = null; |
| | | |
| | | // if (Utils.BooleanWhsTypeSta(rowLastno, staDescId)) { |
| | | // // 获取目标站 |
| | | // wrapper = new EntityWrapper<StaDesc>() |
| | | // .eq("type_no", staDescId) |
| | | // .eq("stn_no", sourceStaNo) |
| | | // .eq("crn_no", crnNo); |
| | | // staDesc = staDescService.selectOne(wrapper); |
| | | // if (Cools.isEmpty(staDesc)) { |
| | | // log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo); |
| | | //// throw new CoolException("入库路径不存在"); |
| | | // crnNo = 0; |
| | | // } else { |
| | | // staNo = basDevpService.selectById(staDesc.getCrnStn()); |
| | | // if (!staNo.getAutoing().equals("Y")) { |
| | | // log.error("目标站" + staDesc.getCrnStn() + "不可用"); |
| | | //// throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用"); |
| | | // crnNo = 0; |
| | | // } |
| | | // startupDto.setStaNo(staNo.getDevNo()); |
| | | // } |
| | | // // 更新库位排号 |
| | | // if (Cools.isEmpty(locMast)) { |
| | | // rowLastno.setCurrentRow(curRow); |
| | | // rowLastnoService.updateById(rowLastno); |
| | | // } |
| | | // } |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | // 1.按规则查找库位 |
| | | if (Cools.isEmpty(locMast) && crnNo != 0) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", nearRow) |
| | | .eq("loc_sts", "O").eq("crn_no", crnNo) |
| | | // B. 次优先:深位为空,且浅位也为空 (入深位) |
| | | if (locMast == null) { |
| | | List<LocMast> deepMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", deepRow) |
| | | .eq("loc_sts", "O") |
| | | .eq("crn_no", crnNo) |
| | | .orderBy("lev1", true).orderBy("bay1", true)); |
| | | // for (LocMast locMast1 : locMasts) { |
| | | // if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { |
| | | // continue; |
| | | // } |
| | | // if (Utils.BooleanWhsTypeStaIoType(rowLastno)) { |
| | | // String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo()); |
| | | // LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("crn_no", crnNo)); |
| | | // if (!Cools.isEmpty(locMast2)) { |
| | | // locMast = locMast2; |
| | | // break; |
| | | // } |
| | | // } else { |
| | | // if (!Cools.isEmpty(locMast1)) { |
| | | // locMast = locMast1; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | if (Cools.isEmpty(locMast) && Utils.BooleanWhsTypeStaIoType(rowLastno)) { |
| | | for (LocMast locMast1 : locMasts) { |
| | | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { |
| | | continue; |
| | | } |
| | | if (Utils.BooleanWhsTypeStaIoType(rowLastno)) { |
| | | String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo()); |
| | | LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("crn_no", crnNo)); |
| | | if (!Cools.isEmpty(locMast2)) { |
| | | locMast = locMast2; |
| | | break; |
| | | } else { |
| | | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc).eq("loc_sts", "F").eq("crn_no", crnNo)); |
| | | if (!Cools.isEmpty(locMast2)) { |
| | | locMast = locMast1; |
| | | break; |
| | | } else { |
| | | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc).eq("loc_sts", "D").eq("crn_no", crnNo)); |
| | | if (!Cools.isEmpty(locMast2)) { |
| | | locMast = locMast1; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | if (!Cools.isEmpty(locMast1)) { |
| | | locMast = locMast1; |
| | | break; |
| | | } |
| | | } |
| | | for (LocMast dLoc : deepMasts) { |
| | | String sLocNo = Utils.getShallowLoc(slaveProperties, dLoc.getLocNo()); |
| | | LocMast sLoc = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", sLocNo) |
| | | .eq("loc_sts", "O")); |
| | | |
| | | if (sLoc != null && VersionUtils.locMoveCheckLocTypeComplete(dLoc, locTypeDto)) { |
| | | locMast = dLoc; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!Cools.isEmpty(locMast) && !basCrnpService.checkSiteError(crnNo, true)) { |
| | | locMast = null; |
| | | // C. 最后:如果深位实在没法放(深位已满或浅位挡路且物料不同),再考虑浅位为空 |
| | | if (locMast == null) { |
| | | List<LocMast> shallowMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", shallowRow) |
| | | .eq("loc_sts", "O") |
| | | .eq("crn_no", crnNo) |
| | | .orderBy("lev1", true).orderBy("bay1", true)); |
| | | |
| | | for (LocMast sLoc : shallowMasts) { |
| | | if (VersionUtils.locMoveCheckLocTypeComplete(sLoc, locTypeDto)) { |
| | | locMast = sLoc; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 递归查询 |
| | | if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) { |
| | | // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归 |
| | | // 3. 递归与异常处理 |
| | | if (Cools.isEmpty(locMast)) { |
| | | // 当前这组货架找完了,递归尝试下一组 |
| | | if (times < rowCount * 2) { |
| | | times = times + 1; |
| | | return getDoubleLocNoRun(whsType, 1, sourceStaNo, findLocNoAttributeVo, moveCrnNo, locTypeDto, times); |
| | | return getDoubleLocNoRun(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, moveCrnNo, locTypeDto, times + 1); |
| | | } |
| | | // // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位 |
| | | // if (locTypeDto.getLocType1() < 2) { |
| | | // int i = locTypeDto.getLocType1() + 1; |
| | | // locTypeDto.setLocType1((short)i); |
| | | // return getLocNo(1, staDescId, sourceStaNo, matnr,batch,grade, locTypeDto, 0); |
| | | // } |
| | | log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); |
| | | throw new CoolException("没有空库位"); |
| | | } |
| | | String locNo = locMast.getLocNo(); |
| | | |
| | | // 生成工作号 |
| | | // 4. 返回结果 |
| | | String locNo = locMast.getLocNo(); |
| | | int workNo = getWorkNo(0); |
| | | // 返回dto |
| | | startupDto.setWorkNo(workNo); |
| | | startupDto.setCrnNo(crnNo); |
| | | startupDto.setSourceStaNo(sourceStaNo); |