| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.param.CompleteParam; |
| | | import com.zy.asrs.enums.LocStsType; |
| | | import com.zy.asrs.mapper.LocMastMapper; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | 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 TaskService taskService; |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | @Autowired |
| | | private TaskDetlService taskDetlService; |
| | | @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(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 6.15WCS申请在库库位更换库位 |
| | | * |
| | | * @param combParam |
| | | * @param l |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R changeLoc(CompleteParam combParam, long l) { |
| | | if (Objects.isNull(combParam)) { |
| | | return R.error("参数不能为空!"); |
| | | } |
| | | if (Objects.isNull(combParam.getLocNo())) { |
| | | return R.error("库位号不能为空!!"); |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", combParam.getLocNo())); |
| | | if (Objects.isNull(locMast)) { |
| | | return R.error("库位信息不存在或库位状态非 F.在库 状态"); |
| | | } |
| | | |
| | | List<Integer> doubleLocs = slaveProperties.getDoubleLocs(); |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .in("row1", doubleLocs) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | LocMast selected = new LocMast(); |
| | | for (LocMast loc : locMasts) { |
| | | LocMast temLoc = locMastService.selectById(loc.getLocNo()); |
| | | if (Objects.isNull(temLoc)) { |
| | | throw new CoolException("数据错误, 原库位信息不存在!!"); |
| | | } |
| | | String shallowLoc = Utils.getShallowLoc(slaveProperties, temLoc.getLocNo()); |
| | | |
| | | LocMast locMast1 = locMastService.selectById(shallowLoc); |
| | | if (Objects.isNull(locMast1)) { |
| | | throw new CoolException("数据错误, 新库位信息不存在!!"); |
| | | } |
| | | if (!locMast1.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | continue; |
| | | } |
| | | selected = loc; |
| | | |
| | | break; |
| | | } |
| | | |
| | | WrkMast moveTask = generateMoveTask(selected, locMast); |
| | | result.put("locNo", selected.getLocNo()); |
| | | result.put("taskNo", moveTask.getWrkNo()); |
| | | |
| | | return R.ok().add(result); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 生成移库任务 |
| | | * |
| | | * @param result |
| | | * @param sourceLoc |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public WrkMast generateMoveTask(LocMast result, LocMast sourceLoc) { |
| | | WrkMast wrkMast = new WrkMast(); |
| | | int workNo = commonService.getWorkNo(0); |
| | | |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setLocNo(result.getLocNo()); |
| | | wrkMast.setSourceLocNo(sourceLoc.getLocNo()); |
| | | wrkMast.setWrkSts(11L); |
| | | wrkMast.setIoType(11); |
| | | wrkMast.setCrnNo(sourceLoc.getCrnNo()); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMast.setIoPri(13D); |
| | | wrkMast.setWrkDate(new Date()); |
| | | |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("任务保存失败!!"); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLoc.getLocNo())); |
| | | locDetls.forEach(detl -> { |
| | | detl.setLocNo(result.getLocNo()); |
| | | if (!locDetlService.updateById(detl)) { |
| | | throw new CoolException("明细更新失败!!"); |
| | | } |
| | | }); |
| | | |
| | | return wrkMast; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/22 |
| | | * @description: 获取缓冲区库位信息 |