| | |
| | | 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 lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | 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()); |
| | | } |
| | |
| | | // 无单组托 |
| | | 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("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | |
| | | // todo 盘点记录、保存调整记录 |
| | | // 修改明细 |
| | | if (!wrkDetlService.updateAnfme(wrkDetl1.getAnfme(), wrkMast.getWrkNo(), wrkDetl.getMatnr(), |
| | | wrkDetl.getBatch())) { |
| | | wrkDetl.getSuppCode())) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," |
| | | + wrkDetl.getBatch() + "批号修改数量失败"); |
| | | + wrkDetl.getSuppCode() + "批号修改数量失败"); |
| | | } |
| | | } |
| | | iterator.remove(); |
| | |
| | | // 删除明细 |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | // todo 盘点记录、保存调整记录 |
| | | if (!wrkDetlService.updateAnfme(-1.0D, wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) { |
| | | if (!wrkDetlService.updateAnfme(-1.0D, wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getSuppCode())) { |
| | | throw new CoolException("删除" + wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," |
| | | + wrkDetl.getBatch() + "批号任务明细失败"); |
| | | } |
| | |
| | | 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()); |
| | |
| | | .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)) { |
| | | throw new CoolException("请检查目标库位是否闲置中!!"); |
| | | } |
| | | |
| | | String taskType = "M2"; |
| | | if (!params.getIsNewIn().isEmpty()) { |
| | | taskType = "M1"; |
| | | } |
| | | try { |
| | | generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId); |
| | | generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId, taskType); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | |
| | | 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("数据错误: 单据明细不存在!!"); |
| | | } |
| | |
| | | Task task = new Task(); |
| | | task.setWrkNo(workNo) |
| | | .setIoTime(new Date()) |
| | | .setWrkSts(1L) // 工作状态:11.生成出库ID |
| | | .setWrkSts(201L) // 工作状态:11.生成入库库ID |
| | | .setIoType(1) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | |
| | | if (Objects.isNull(param.getBarcode())) { |
| | | throw new CoolException("托盘码不能为空!!"); |
| | | } |
| | | |
| | | if (Objects.isNull(param.getCombMats()) || param.getCombMats().isEmpty()) { |
| | | throw new CoolException("组托明细不能为空!!"); |
| | | } |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()) |
| | | .eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("wrk_sts", 14) |
| | | .eq("io_type", 104) |
| | | .eq("barcode", param.getBarcode())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | throw new CoolException("任务档信息不存在!!"); |
| | | } |
| | | |
| | | 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() + "!!"); |
| | | } |
| | | 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()); |
| | | 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() + ", 超出当前托盘装载上限!!"); |
| | | } |
| | | |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>() |
| | | .eq("zpallet", param.getCarBarcode()) |
| | | .eq("three_code", detlDto.getThreeCode())); |
| | | .eq("three_code", combMat.getThreeCode())); |
| | | if (Objects.isNull(stationDetl)) { |
| | | throw new CoolException("明细内容不存在!!"); |
| | | } |
| | | WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>() |
| | | .eq("matnr", stationDetl.getMatnr()) |
| | | .eq("wrk_no", wrkMast.getWrkNo()) |
| | | .eq("suppCode", combMat.getSuppCode())); |
| | | |
| | | 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); |
| | | } |
| | | if (Objects.isNull(wrkDetl)) { |
| | | //TODO 新插入 |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", stationDetl.getMatnr()) |
| | | .eq("supp_code", combMat.getSuppCode())); |
| | | if (Objects.isNull(mat)) { |
| | | throw new CoolException("物料基础信息已不存在!!"); |
| | | } |
| | | WrkDetl detl = new WrkDetl(); |
| | | BeanUtils.copyProperties(stationDetl, detl); |
| | | detl.setAnfme(combMat.getAnfme()); |
| | | detl.setBarcode(wrkMast.getBarcode()); |
| | | detl.setBoxType1(combMat.getBoxType1()); |
| | | detl.setStandby1(combMat.getSuppCode()); |
| | | detl.setWrkNo(wrkMast.getWrkNo()); |
| | | |
| | | 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("原始数据移除失败!"); |
| | | if (!wrkDetlService.insert(detl)) { |
| | | throw new CoolException("任务明细保存失败!!"); |
| | | } |
| | | } else { |
| | | double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0; |
| | | if (!wrkDetlService.updateAnfme(val, wrkMast.getWrkNo(), wrkDetl.getMatnr(), |
| | | wrkDetl.getSuppCode())) { |
| | | throw new CoolException(wrkMast.getWrkNo() + "盘点任务," + wrkDetl.getMatnr() + "商品," |
| | | + wrkDetl.getBatch() + "批号修改数量失败"); |
| | | } |
| | | } |
| | | |
| | | 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("站点状态更新失败!!"); |
| | | } |
| | | } |
| | | } |
| | | // // 判断是否有相同条码的数据 |
| | | // 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("站点状态更新失败!!"); |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | throw new CoolException("容器编码未维护,请维护后再操作!!"); |
| | | } |
| | | |
| | | Integer whsType = 1; |
| | | Integer whsType = 2; |
| | | Short lcoType = 1; |
| | | //用于判断料箱托盘,料箱,笼框 |
| | | if (container.getType().equals(ContainerType.CONTAINER_TYPE_SALVER.type)) { |
| | | whsType = 3; |
| | | } else if (container.getType().equals(ContainerType.CONTAINER_TYPE_CAGE.type)) { |
| | | if (!container.getType().equals(ContainerType.CONTAINER_TYPE_BOX.type)) { |
| | | whsType = 2; |
| | | if (container.getType().equals(ContainerType.CONTAINER_TYPE_SALVER.type)) { |
| | | lcoType = 2; |
| | | } |
| | | } |
| | | |
| | | WrkMast barcode = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode())); |
| | |
| | | throw new CoolException("数据错误,组拖档已不存在!!"); |
| | | } |
| | | |
| | | WrkMast wrkMast = generateCrnInTask(waitPakins, whsType, station, param.getLocType1(), userId); |
| | | WrkMast wrkMast = generateCrnInTask(waitPakins, whsType, station, lcoType, userId); |
| | | |
| | | response.put("taskNo", wrkMast.getWrkNo()); |
| | | response.put("locNo", wrkMast.getLocNo()); |
| | |
| | | .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("检索单据明细数据失败"); |
| | | } |
| | |
| | | if (!Objects.isNull(mast)) { |
| | | if (mast.getIoType().equals(TaskIOType.MERGE_OUT.type) || mast.getIoType().equals(TaskIOType.PICK_OUT.type) || mast.getIoType().equals(TaskIOType.CHECK_OUT.type)) { |
| | | int ioType = mast.getIoType() - 50; |
| | | |
| | | List<WrkDetl> wrkDetls103 = wrkDetlService |
| | | .selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); |
| | | if (wrkDetls103.isEmpty()) { |
| | | ioType = 10; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | if (!Objects.isNull(locDetls) && !locDetls.isEmpty()) { |
| | | Double sum = wrkDetls103.stream().mapToDouble(WrkDetl::getAnfme).sum(); |
| | | Double summed = locDetls.stream().mapToDouble(LocDetl::getAnfme).sum(); |
| | | if (summed.compareTo(sum) <= 0) { |
| | | ioType = 10; |
| | | } |
| | | } |
| | | mast.setIoType(ioType); |
| | | mast.setWrkSts(2L); |
| | | mast.setSourceStaNo(mast.getSourceStaNo()); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | if (Cools.isEmpty(wrkMast1)) { |
| | | Integer outSta = devp.getDevNo(); |
| | | // Integer outSta = devp.getDevNo(); |
| | | // 获取路径 |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta); |
| | | // StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta); |
| | | |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | |
| | | 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(locMast.getLocNo()); // 源库位 |
| | | //小松项目,缓存出库AGV站点,用于清空缓存区库存 |
| | | wrkMast.setPauseMk(station.getDevNo()); |
| | |
| | | * @version 1.0 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) { |
| | | public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId, String isNewIn) { |
| | | List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode)); |
| | | if (!tasks.isEmpty()) { |
| | | throw new CoolException("托盘已在任务执行中.."); |
| | |
| | | .setIoType(1) // 入出库状态: 11.库格移载 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setIsNewIn(isNewIn) |
| | | .setLocNo(loc.getLocNo()) // 目标库位 |
| | | .setFullPlt("Y") // 满板:Y |
| | | .setPicking("N") // 拣料 |
| | |
| | | if (!taskDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | for (WaitPakin pakin : pakins) { |
| | |
| | | |
| | | try { |
| | | //空台车回库 |
| | | generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId); |
| | | generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(e.getMessage()); |
| | |
| | | @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 { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取缓存站点信息 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getCacheSites(String type) { |
| | | BasAreas areas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", type)); |
| | | if (Objects.isNull(areas)) { |
| | | return R.error("库区不存在!"); |
| | | } |
| | | List<BasStation> stations = basStationService.selectList(new EntityWrapper<BasStation>().eq("area_id", areas.getId())); |
| | | if (Objects.isNull(stations) || stations.isEmpty()) { |
| | | return R.error("站点不存在!"); |
| | | } |
| | | return R.ok("查询成功").add(stations); |
| | | } |
| | | |
| | | /** |
| | | * 生成移库任务 |
| | | * |
| | | * @param result |