| | |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.system.timer.LoadingConfigTimer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private BasContainerService basContainerService; |
| | | @Autowired |
| | | private LoadingConfigTimer loadingConfigTimer; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | if (param.getCombMats().size() < 1) { |
| | | throw new CoolException("请提取一个商品,或者刷新重新组托!"); |
| | | Integer suplus = null; |
| | | if (loadingConfigTimer.getZpalletManage()) { |
| | | BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode())); |
| | | if (Objects.isNull(container)) { |
| | | throw new CoolException("数据错误:容器码不存在!!"); |
| | | } |
| | | if (container.getMixMax() < param.getCombMats().size()) { |
| | | throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | } |
| | | Set<String> matnrs = param.getCombMats().stream().map(CombParam.CombMat::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("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | | suplus = container.getMixMax(); |
| | | } |
| | | |
| | | // 判断是否有相同条码的数据 |
| | | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). |
| | | eq("zpallet", param.getBarcode()) |
| | |
| | | } |
| | | }); |
| | | |
| | | 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("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | | |
| | | //还可以放入多少种物料 |
| | | Integer suplus = container.getMixMax(); |
| | | |
| | | |
| | | 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() + ", 超出当前托盘装载上限!!"); |
| | | //最多可放数量,该功能需要开启容器管理 |
| | | if (suplus != null) { |
| | | 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() + ", 超出当前托盘装载上限!!"); |
| | | } |
| | | } |
| | | |
| | | WaitPakin waitPakin = new WaitPakin(); |