From f113fba5cf9e2c33a08da704e53d68da25d90e82 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期四, 07 八月 2025 09:16:15 +0800 Subject: [PATCH] 订单库口问题修复 --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/OrderServiceImpl.java | 53 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 46 insertions(+), 7 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/OrderServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/OrderServiceImpl.java index 302f67a..c8d37ea 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/OrderServiceImpl.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/OrderServiceImpl.java @@ -1,11 +1,13 @@ package com.zy.asrs.wms.asrs.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.exception.CoolException; import com.zy.asrs.wms.asrs.entity.*; import com.zy.asrs.wms.asrs.entity.dto.OrderInfoDto; import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType; +import com.zy.asrs.wms.asrs.entity.enums.OrderType; import com.zy.asrs.wms.asrs.entity.param.CreateOrderParam; import com.zy.asrs.wms.asrs.entity.param.UpdateOrderParam; import com.zy.asrs.wms.asrs.mapper.OrderMapper; @@ -19,10 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; +import java.util.*; @Service("orderService") public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { @@ -39,6 +38,10 @@ private OrderNoRuleService orderNoRuleService; @Autowired private OrderUtils orderUtils; + @Autowired + private WaitPakinService waitPakinService; + @Autowired + private LocDetlService locDetlService; @Override @Transactional @@ -67,6 +70,9 @@ Order order = new Order(); order.setOrderNo(orderNo); order.setOrderType(param.getOrderType()); + order.setCustomer(param.getCustomer()); + order.setPhone(param.getPhone()); + order.setAddress(param.getAddress()); order.setOrderSettle(OrderSettleType.INIT.val()); order.setIoPri(orderUtils.getIoPri()); order.setOrderTime(format.format(new Date())); @@ -78,7 +84,7 @@ } for (HashMap<String, Object> map : param.getList()) { - double anfme = Double.parseDouble(map.get("anfme").toString()); + Double anfme = Double.parseDouble(map.get("anfme").toString()); String batch = map.get("batch").toString(); String matnr = map.get("matnr").toString(); Double qty = 0D; @@ -89,6 +95,20 @@ if (map.containsKey("workQty")) { workQty = Double.parseDouble(map.get("workQty").toString()); } + + if (param.getOrderType() == 2) { + List<LocDetl> detls = locDetlService.list(new LambdaQueryWrapper<LocDetl>() + .eq(StringUtils.isNotBlank(batch), LocDetl::getBatch, batch) + .eq(StringUtils.isNotBlank(matnr), LocDetl::getMatnr, matnr)); + if (detls.isEmpty()) { + throw new CoolException("鐗╂枡锛�" + matnr + "鍓╀綑搴撳瓨浣欎笅锛�0" + "锛屾棤娉曠敓鎴愬嚭搴撳崟!!"); + } + Double sum = detls.stream().mapToDouble(LocDetl::getAnfme).sum(); + if (anfme.compareTo(sum) > 0) { + throw new CoolException("鐗╂枡锛�" + matnr + "鍓╀綑搴撳瓨浣欎笅锛�" + sum + "锛屾棤娉曠敓鎴愬嚭搴撳崟!!"); + } + } + String memo = map.getOrDefault("memo", "").toString(); Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, matnr)); if (mat == null) { @@ -132,6 +152,11 @@ throw new CoolException("鏇存柊鏄庣粏绱㈠紩澶辫触"); } + mat.setUtiliz(Objects.isNull(mat.getUtiliz()) ? 0 : mat.getUtiliz() + 1); + + if (!matService.updateById(mat)) { + throw new CoolException("鐗╂枡浣跨敤鐜囦慨鏀瑰け璐ワ紒锛�"); + } } return true; @@ -252,6 +277,10 @@ throw new CoolException("璁㈠崟宸茬粡鐢熸垚娉㈡锛屽垹闄ゅけ璐�"); } + List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getOrderId, orderId)); + if (!waitPakins.isEmpty()) { + throw new CoolException("鍗曟嵁宸茬敓鎴愮粍鎵橈紝涓嶅彲鎵ц鍒犻櫎鎿嶄綔锛侊紒"); + } //鍒犻櫎璁㈠崟 this.removeById(orderId); //鍒犻櫎鏄庣粏 @@ -292,7 +321,17 @@ } @Override - public List<OrderInfoDto> getDetlForOrderId(Long id) { - return this.baseMapper.getDetlForOrderId(id); + public List<OrderInfoDto> getDetlForOrderId(Long id, String matnr) { + if (!Objects.isNull(matnr)) { +// Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>() +// .eq(StringUtils.isNotBlank(matnr), Mat::getMatnr, matnr), false); + if (Objects.isNull(matnr)) { + return this.baseMapper.getDetlForOrderId(id, null); + } else { + return this.baseMapper.getDetlForOrderId(id, matnr); + } + } else { + return this.baseMapper.getDetlForOrderId(id, null); + } } } -- Gitblit v1.9.1