| | |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import com.zy.system.service.impl.ConfigServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private StationRelaService stationRelaService; |
| | | @Autowired |
| | | private BasStationDetlService basStationDetlService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | wrkMastService.insert(wrkMast); |
| | | |
| | | for (OrderDetl orderDetl : param.getCombMats()) { |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", orderDetl.getMatnr())); |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("supp_code", orderDetl.getStandby1()) |
| | | .eq("matnr", orderDetl.getMatnr())); |
| | | if (mat == null) { |
| | | throw new CoolException("保存工作档失败,物料信息不存在:" + orderDetl.getMatnr()); |
| | | } |
| | |
| | | for (CombParam.CombMat combMat : combParam.getCombMats()) { |
| | | List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", combParam.getLocNo()) |
| | | .eq(!Cools.isEmpty(combMat.getStandby1()), "supp_code", combMat.getStandby1()) |
| | | .eq("matnr", combMat.getMatnr())); |
| | | if (locDetlList.isEmpty()) { |
| | | return R.error("未查询到库存数据"); |
| | |
| | | wrkMast.setModiUser(userId); |
| | | wrkMastService.insert(wrkMast); |
| | | |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", combMat.getMatnr())); |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq(!Cools.isEmpty(combMat.getStandby1()), "supp_code", combMat.getStandby1()) |
| | | .eq("matnr", combMat.getMatnr())); |
| | | if (mat == null) { |
| | | throw new CoolException("保存工作档失败,物料信息不存在:" + combMat.getMatnr()); |
| | | } |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void comb(CombParam param, Long userId) { |
| | | // if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | // throw new CoolException(BaseRes.PARAM); |
| | | // } |
| | | if (Objects.isNull(param.getBarcode())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | |
| | | Date now = new Date(); |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | if (param.getPakinType().equals("3")) { |
| | | //空板组托 |
| | | if (!Cools.isEmpty(param.getPakinType()) && param.getPakinType().equals("3")) { |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.setZpallet(param.getBarcode()); |
| | | waitPakin.setIoStatus("N"); |
| | |
| | | // elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3()); |
| | | OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_id", order.getId()) |
| | | .eq("supp_code", elem.getStandby1()) |
| | | .eq("matnr", elem.getMatnr())); |
| | | if (Objects.isNull(elem.getBoxType1())) { |
| | | throw new CoolException("格层编码不能为空!!"); |
| | |
| | | } |
| | | }); |
| | | |
| | | Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet()); |
| | | List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs)); |
| | | Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | 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<String> matnrs = tempMats.stream().map(Mat::getMatnr).collect(Collectors.toSet()); |
| | | Set<Long> tagIds = tempMats.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | if (tagIds.size() > 1) { |
| | | throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | |
| | | orderDetl.setUpdateBy(userId); |
| | | orderDetl.setUpdateTime(now); |
| | | Wrapper wrapper = new EntityWrapper<OrderDetl>().eq("order_no", orderNo) |
| | | .eq(!Cools.isEmpty(orderDetl.getStandby1()), "supp_code", orderDetl.getStandby1()) |
| | | .eq("matnr", orderDetl.getMatnr()); |
| | | if (!Cools.isEmpty(orderDetl.getBatch())) { |
| | | wrapper.eq("batch", orderDetl.getBatch()); |
| | |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(locDetl.getLocNo()); |
| | | // 获取路径 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", ioType) |
| | | .eq("stn_no", staNo.getDevNo()) |
| | | .eq("crn_no", locMast.getCrnNo()); |
| | | |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("出库路径不存在"); |
| | | } |
| | | // Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | // .eq("type_no", ioType) |
| | | // .eq("stn_no", staNo.getDevNo()) |
| | | // .eq("crn_no", locMast.getCrnNo()); |
| | | // |
| | | // StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | // if (Cools.isEmpty(staDesc)) { |
| | | // throw new CoolException("出库路径不存在"); |
| | | // } |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(2); |
| | | // 生成工作档 |
| | |
| | | wrkMast.setIoType(ioType); // 入出库状态 |
| | | wrkMast.setIoPri(13D); // 优先级:13 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站 |
| | | // wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 源站 |
| | | // wrkMast.setStaNo(staDesc.getStnNo() + ""); // 目标站 |
| | | wrkMast.setSourceLocNo(locDetl.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("frozen", 0) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | // .eq("loc_no", params.getTarSite()) |
| | | .orderAsc(Arrays.asList("loc_no")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | if (Objects.isNull(locCache)) { |
| | |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getOrderNo())) { |
| | | throw new CoolException("单号不能为空!!"); |
| | | } |
| | | OrderPakin orderPakin = orderPakinService |
| | | .selectOne(new EntityWrapper<OrderPakin>().eq("order_no", params.getOrderNo())); |
| | | if (Objects.isNull(orderPakin)) { |
| | | throw new CoolException("数据错误:单据不存在!!"); |
| | | } |
| | | |
| | | List<OrderDetlPakin> detlPakins = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>() |
| | | .eq(!Cools.isEmpty(params.getThreeCode()), "three_code", params.getThreeCode()) |
| | | .eq(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq("order_id", orderPakin.getId())); |
| | | .eq(!Cools.isEmpty(params.getThreeCode()), "three_code", params.getThreeCode()) |
| | | // .eq(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr()) |
| | | // .eq(!Cools.isEmpty(params.getOrderNo()), "order_no", params.getOrderNo()) |
| | | ); |
| | | if (Objects.isNull(detlPakins) || detlPakins.isEmpty()) { |
| | | throw new CoolException("数据错误: 单据明细不存在!!"); |
| | | } |
| | |
| | | .eq("area_id", basAreas.getId()) |
| | | .eq("loc_no", locCache.getLocNo())); |
| | | if (Objects.isNull(locDetls) || locDetls.isEmpty()) { |
| | | throw new CoolException("库存明细不存在!!"); |
| | | continue; |
| | | // throw new CoolException("库存明细不存在!!"); |
| | | } |
| | | |
| | | Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet()); |
| | |
| | | if (container.getMixMax() < detlDtos.size()) { |
| | | throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | } |
| | | Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet()); |
| | | List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs)); |
| | | Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | 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("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | |
| | | whsType = 2; |
| | | } |
| | | |
| | | log.info("WCS任务生成请求参数:{}", JSONObject.toJSONString(param)); |
| | | WrkMast barcode = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode())); |
| | | if (!Objects.isNull(barcode) && (barcode.getIoType() == 104 || barcode.getIoType() == 103 || barcode.getIoType() == 107) && barcode.getWrkSts() == 14L) { |
| | | // |
| | | workService.pickWrkMast(barcode.getWrkNo() + "", userId); |
| | | |
| | | BasDevp station = basDevpService.selectOne(new EntityWrapper<BasDevp>() |
| | | .eq("dev_no", param.getSourceStaNo())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("taskNo", barcode.getWrkNo()); |
| | | response.put("locNo", barcode.getLocNo()); |
| | | response.put("taskPri", barcode.getIoPri()); |
| | | |
| | | return R.ok("任务生成成功").add(response); |
| | | } else { |
| | | log.info("WCS任务生成请求参数:{}", JSONObject.toJSONString(param)); |
| | | |
| | | BasDevp station = basDevpService.selectOne(new EntityWrapper<BasDevp>() |
| | | .eq("dev_no", param.getSourceStaNo())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | Map<String, Object> response = new HashMap<>(); |
| | | |
| | | if (Objects.isNull(barcode)) { |
| | | List<WaitPakin> waitPakins = waitPakinService |
| | | .selectList(new EntityWrapper<WaitPakin>() |
| | | .eq("io_status", "N") |
| | | .eq("zpallet", param.getBarcode())); |
| | | if (Objects.isNull(waitPakins) || waitPakins.isEmpty()) { |
| | | throw new CoolException("数据错误,组拖档已不存在!!"); |
| | | } |
| | | |
| | | WrkMast wrkMast = generateCrnInTask(waitPakins, whsType, station, param.getLocType1(), userId); |
| | | |
| | | response.put("taskNo", wrkMast.getWrkNo()); |
| | | response.put("locNo", wrkMast.getLocNo()); |
| | | response.put("taskPri", wrkMast.getIoPri()); |
| | | } else { |
| | | response.put("taskNo", barcode.getWrkNo()); |
| | | response.put("locNo", barcode.getLocNo()); |
| | | response.put("taskPri", barcode.getIoPri()); |
| | | } |
| | | |
| | | return R.ok("任务生成成功").add(response); |
| | | } |
| | | |
| | | List<WaitPakin> waitPakins = waitPakinService |
| | | .selectList(new EntityWrapper<WaitPakin>() |
| | | .eq("io_status", "N") |
| | | .eq("zpallet", param.getBarcode())); |
| | | if (Objects.isNull(waitPakins) || waitPakins.isEmpty()) { |
| | | throw new CoolException("数据错误,组拖档已不存在!!"); |
| | | } |
| | | |
| | | WrkMast wrkMast = generateCrnInTask(waitPakins,whsType, station, param.getLocType1(), userId); |
| | | |
| | | Map<String, Object> response = new HashMap<>(); |
| | | response.put("taskNo", wrkMast.getWrkNo()); |
| | | response.put("locNo", wrkMast.getLocNo()); |
| | | response.put("taskPri", wrkMast.getIoPri()); |
| | | |
| | | return R.ok("任务生成成功").add(response); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | .eq("dev_no", basStation.getDevNo()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("batch", combMat.getBatch()) |
| | | .eq("standby1", combMat.getStandby1())); |
| | | .eq(!Cools.isEmpty(combMat.getStandby1()), "standby1", combMat.getStandby1())); |
| | | if (Cools.isEmpty(basStationDetl)) { |
| | | basStationDetl = new BasStationDetl(); |
| | | Mat mat = matService.selectByMatnr(combMat.getMatnr()); |
| | |
| | | OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_id", orderPakin.getId()) |
| | | .eq("matnr", combMat.getMatnr()) |
| | | .eq("batch", combMat.getBatch()) |
| | | .eq("standby1", combMat.getStandby1())); |
| | | .eq(!Cools.isEmpty(combMat.getBatch()),"batch", combMat.getBatch()) |
| | | .eq(!Cools.isEmpty(combMat.getStandby1()), "supp_code", combMat.getStandby1())); |
| | | if (Cools.isEmpty(orderDetlPakin)) { |
| | | throw new CoolException("检索单据明细数据失败"); |
| | | } |
| | |
| | | } |
| | | |
| | | } else { |
| | | StartupDto dto = commonService.getLocNo(1, sourceStaNo.getDevNo(), whsType, findLocNoAttributeVo, locTypeDto); |
| | | StartupDto dto = commonService.getLocNo(1, sourceStaNo.getDevNo(), whsType, findLocNoAttributeVo, locTypeDto); |
| | | |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } else { |
| | | wrkMast.setWrkSts(1L); |
| | | wrkMast.setWrkSts(2L); |
| | | wrkMast.setIoType(10); |
| | | |
| | | wrkMastService.updateById(wrkMast); |
| | | } |
| | | }); |
| | | |
| | | |
| | | // 更新入库通知档 ioStatus ===>> Y |
| | | Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>() |
| | | .eq("zpallet", pakin.getZpallet()); |
| | | |
| | | WaitPakin setParam = new WaitPakin(); |
| | | setParam.setLocNo(locNo); |
| | | setParam.setIoStatus("Y"); |
| | |
| | | if (container.getMixMax() > sets.size()) { |
| | | //余下可混放种类 |
| | | long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000; |
| | | Mat mats = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr)); |
| | | Mat mats = matService.selectOne(new EntityWrapper<Mat>() |
| | | .eq("supp_code", supId) |
| | | .eq("matnr", matnr)); |
| | | if (Objects.isNull(mats)) { |
| | | throw new CoolException("物料不存在!!"); |
| | | } |
| | |
| | | }); |
| | | }); |
| | | |
| | | // 判断根据分拣出库后,还需要出多少托盘或料箱;如果余料大于0, 出新托盘或料箱 |
| | | if (totalOut.get().compareTo(0.0) > 0) { |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | //TODO 细化区分,当前出库托盘是满足拣货数量 |
| | | } else { |
| | | /**是否优先空板出库*/ |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "OutStockOrderByEmpty")); |
| | | if (!Objects.isNull(config) && Boolean.parseBoolean(config.getValue())) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // todo 根据物料种类,区分库区类型 |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type) |
| | |
| | | if (Objects.isNull(locMast)) { |
| | | throw new CoolException("未查询到可用的空板信息!!"); |
| | | } |
| | | |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | } else { |
| | | // 判断根据分拣出库后,还需要出多少托盘或料箱;如果余料大于0, 出新托盘或料箱 |
| | | if (totalOut.get().compareTo(0.0) > 0) { |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | //TODO 细化区分,当前出库托盘是满足拣货数量 |
| | | } else { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // todo 根据物料种类,区分库区类型 |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type) |
| | | .orderAsc(Arrays.asList("row1", "bay1", "lev1")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | |
| | | if (Objects.isNull(locMast)) { |
| | | throw new CoolException("未查询到可用的空板信息!!"); |
| | | } |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (!taskDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | for (WaitPakin pakin : pakins) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R taskMove(CompleteParam combParam, long userId) { |
| | | if (Objects.isNull(combParam.getWorkNo())) { |
| | | if (Objects.isNull(combParam.getTaskNo())) { |
| | | return R.error("任务号不能为空"); |
| | | } |
| | | if (Objects.isNull(combParam.getSourceLocNo())) { |
| | |
| | | if (Objects.isNull(combParam.getLocNo())) { |
| | | return R.error("目标库位不能为空!"); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", combParam.getWorkNo())); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", combParam.getTaskNo())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | return R.error("任务档不存在!!"); |
| | | } |
| | | |
| | | |
| | | String body = JSON.toJSONString(combParam); |
| | | boolean success = false; |
| | | String response = ""; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(HIKApiConstant.AGV_IP) |
| | | .setUri(MesConstant.WCS_URL) |
| | | .setPath(MesConstant.MOVE_LOC_TASK) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMast.setWrkSts(2L); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("任务状态更新失败!!"); |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | if (!Objects.isNull(locMast)) { |
| | | locMast.setMoveStatus(1); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | success = true; |
| | | } else { |
| | |
| | | |
| | | /** |
| | | * 6.15WCS申请在库库位更换库位 |
| | | * |
| | | * @param combParam |
| | | * @param l |
| | | * @return |