| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.enums.CommonEnum; |
| | | 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.OrderInAndOutUtil; |
| | | 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 MatService matService; |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @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 |
| | |
| | | continue; |
| | | } |
| | | if (orderPakout.getSettle() == 1) { |
| | | OrderInAndOutUtil.updateOrder(false, orderPakout.getId(), 2L, 9527L); |
| | | orderPakoutService.updateSettle(orderPakout.getId(), 2L, 9527L); |
| | | } |
| | | OrderDetlPakout orderDetlPakout = orderDetlPakoutService.selectItem(orderPakout.getId(), combMat.getMatnr(), combMat.getBatch(), |
| | | combMat.getBrand(), combMat.getStandby1(), combMat.getStandby2(), combMat.getStandby3(), combMat.getBoxType1(), combMat.getBoxType2(), combMat.getBoxType3()); |
| | |
| | | typeList.add(docType.getDocId()); |
| | | } |
| | | |
| | | Wrapper<Order> wrapper = new EntityWrapper<>(); |
| | | Wrapper<OrderPakin> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("status", 1); |
| | | wrapper.in("doc_type", typeList); |
| | | List<Order> orders = orderService.selectList(wrapper); |
| | | List<OrderPakin> orders = orderPakinService.selectList(wrapper); |
| | | |
| | | ArrayList<Long> orderIds = new ArrayList<>(); |
| | | for (Order order : orders) { |
| | | for (OrderPakin order : orders) { |
| | | orderIds.add(order.getId()); |
| | | } |
| | | |
| | | //搜索明细 |
| | | Wrapper<OrderDetl> wrapper1 = new EntityWrapper<>(); |
| | | Wrapper<OrderDetlPakin> wrapper1 = new EntityWrapper<>(); |
| | | wrapper1.eq("status", 1); |
| | | wrapper1.in("order_id", orderIds); |
| | | wrapper1.orderBy("create_time", false); |
| | |
| | | if (!Cools.isEmpty(orderNo)) { |
| | | wrapper1.like("order_no", orderNo); |
| | | } |
| | | List<OrderDetl> list = orderDetlService.selectList(wrapper1); |
| | | List<OrderDetlPakin> list = orderDetlPakinService.selectList(wrapper1); |
| | | |
| | | ArrayList<PickMatParam> maps = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : list) { |
| | | for (OrderDetlPakin orderDetl : list) { |
| | | //剩余可用数量 |
| | | double count = orderDetl.getAnfme() - orderDetl.getWorkQty(); |
| | | if (count <= 0) { |
| | |
| | | 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()) |
| | |
| | | } |
| | | // 关联组托 |
| | | } else { |
| | | // Order order = orderService.selectByNo(param.getOrderNo()); |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, elem.getOrderNo()); |
| | | OrderPakin order = orderPakinService.selectByNo(elem.getOrderNo()); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | // 订单明细数量校验 |
| | | // OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), |
| | | // elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3()); |
| | | OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_id", order.getId()) |
| | | .eq("matnr", elem.getMatnr())); |
| | |
| | | if (elem.getAnfme() > detls.getEnableQty()) { |
| | | throw new CoolException(detls.getMatnr() + "入库数量不合法"); |
| | | } |
| | | OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), |
| | | orderDetlPakinService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), |
| | | elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), |
| | | elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme()); |
| | |
| | | } |
| | | }); |
| | | |
| | | 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(); |
| | |
| | | |
| | | Set<String> stringSet = param.getCombMats().stream().map(CombParam.CombMat::getOrderNo).collect(Collectors.toSet()); |
| | | stringSet.forEach(orderNo -> { |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, orderNo); |
| | | OrderInAndOutUtil.updateOrder(Boolean.TRUE, order.getId(), 2L, userId); |
| | | OrderPakin order = orderPakinService.selectByNo(orderNo); |
| | | orderPakinService.updateSettle(order.getId(), 2L, userId); |
| | | }); |
| | | } |
| | | |
| | |
| | | openParam.setOrderType("打包入库单"); |
| | | openParam.setOrderDetails(detlDtos); |
| | | openService.pakinOrderCreate(openParam); |
| | | // Order order = orderService.selectByNo(orderNo); |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getOrderNo()); |
| | | OrderPakin order = orderPakinService.selectByNo(param.getOrderNo()); |
| | | |
| | | if (null == order) { |
| | | throw new CoolException("生成单据失败"); |
| | | } |
| | | // if (!orderService.updateSettle(order.getId(), 2L, userId)) { |
| | | // throw new CoolException("修改单据状态失败"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(Boolean.TRUE, order.getId(), 2L, userId); |
| | | |
| | | if (!orderPakinService.updateSettle(order.getId(), 2L, userId)) { |
| | | throw new CoolException("修改单据状态失败"); |
| | | } |
| | | // 生成入库通知档 |
| | | for (DetlDto detlDto : detlDtos) { |
| | | |
| | | // 修改作业数量 ---------------------------------------- |
| | | // 订单明细数量校验 |
| | | // OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch()); |
| | | OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3() |
| | | OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3() |
| | | , detlDto.getBoxType1(), detlDto.getBoxType2(), detlDto.getBoxType3()); |
| | | if (detlDto.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | if (detlDto.getAnfme() > orderDetlPakin.getEnableQty()) { |
| | | throw new CoolException(orderDetlPakin.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单作业数量 |
| | | // if (!orderDetlService.increaseWorkQty(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme())) { |
| | | // throw new CoolException("修改单据作业数量失败"); |
| | | // } |
| | | OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3() |
| | | , detlDto.getBoxType1(), detlDto.getBoxType2(), detlDto.getBoxType3(), detlDto.getAnfme()); |
| | | if (!orderDetlPakinService.increaseWorkQty(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3() |
| | | , detlDto.getBoxType1(), detlDto.getBoxType2(), detlDto.getBoxType3(), detlDto.getAnfme())) { |
| | | throw new CoolException("修改单据作业数量失败"); |
| | | } |
| | | // 保存入库通知档 |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | |
| | | |
| | | BasDevp sta = basDevpService.checkSiteStatus(staNo); |
| | | //根据订单号生成出库任务工作档 |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.FALSE, orderNo); |
| | | // Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderNo)); |
| | | OrderPakout order = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>().eq("order_no", orderNo)); |
| | | if (order.getSettle() != 1 && order.getSettle() != 2) { |
| | | throw new CoolException("该订单已处理"); |
| | | } |
| | | |
| | | // List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", orderNo)); |
| | | List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(Boolean.FALSE, order.getId()); |
| | | List<OrderDetlPakout> orderDetls = orderDetlPakoutService.selectByOrderId(order.getId()); |
| | | |
| | | Date now = new Date(); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | for (OrderDetlPakout orderDetl : orderDetls) { |
| | | //查询所有库位状态为F的库位信息 |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, null); |
| | | if (locDetls.size() == 0) { |
| | |
| | | order.setSettle(2L); |
| | | order.setUpdateBy(userId); |
| | | order.setUpdateTime(now); |
| | | // if(!orderService.update(order, new EntityWrapper<Order>().eq("order_no", orderNo))){ |
| | | // throw new CoolException("更新订单状态失败"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(), order.getId(), 2L, userId); |
| | | if (!orderPakoutService.update(order, new EntityWrapper<OrderPakout>().eq("order_no", orderNo))) { |
| | | throw new CoolException("更新订单状态失败"); |
| | | } |
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() + curOutQty); |
| | | orderDetl.setUpdateBy(userId); |
| | | orderDetl.setUpdateTime(now); |
| | |
| | | if (!Cools.isEmpty(orderDetl.getBatch())) { |
| | | wrapper.eq("batch", orderDetl.getBatch()); |
| | | } |
| | | // if(!orderDetlService.update(orderDetl, wrapper)){ |
| | | // throw new CoolException("更新订单明细失败"); |
| | | // } |
| | | OrderInAndOutUtil.updateOrderDetl(order.getPakinPakoutStatus$(), order, orderDetl); |
| | | if (!orderDetlPakoutService.update(orderDetl, wrapper)) { |
| | | throw new CoolException("更新订单明细失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(OrderDetl orderDetl, BasDevp staNo, LocDetl locDetl, |
| | | public void stockOut(OrderDetlPakout orderDetl, BasDevp staNo, LocDetl locDetl, |
| | | Double curOutQty, Integer ioType, Long userId, Date now) { |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(locDetl.getLocNo()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 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: 获取缓冲区库位信息 |