From c6c9b7d3baa822765768c110304d27623f946286 Mon Sep 17 00:00:00 2001
From: pjb <123456>
Date: 星期二, 15 七月 2025 14:29:09 +0800
Subject: [PATCH] `1`
---
zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java | 204 +++++++++++++++++++++++++++-----------------------
1 files changed, 111 insertions(+), 93 deletions(-)
diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java
index 57b933e..72ca1a7 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WaitPakinServiceImpl.java
@@ -1,93 +1,111 @@
-package com.zy.asrs.wms.asrs.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.zy.asrs.framework.exception.CoolException;
-import com.zy.asrs.wms.asrs.entity.*;
-import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
-import com.zy.asrs.wms.asrs.mapper.WaitPakinMapper;
-import com.zy.asrs.wms.asrs.service.*;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Date;
-import java.util.List;
-
-@Service("waitPakinService")
-public class WaitPakinServiceImpl extends ServiceImpl<WaitPakinMapper, WaitPakin> implements WaitPakinService {
-
- @Autowired
- private OrderService orderService;
- @Autowired
- private OrderDetlService orderDetlService;
- @Autowired
- private LocService locService;
- @Autowired
- private TaskService taskService;
- @Autowired
- private WaitPakinRuleService waitPakinRuleService;
-
- @Override
- public List<WaitPakin> getByOrderDetlId(Long orderDetlId) {
- return this.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getDetlId, orderDetlId));
- }
-
- @Override
- @Transactional
- public boolean comb(WaitPakin waitPakin) {
- //缁勬墭瑙勫垯鏍¢獙
- waitPakinRuleService.rule(waitPakin);
-
- if (waitPakin.getAnfme() <= 0) {
- throw new CoolException("缁勬墭鏁伴噺閿欒");
- }
-
- List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
- if (!locList.isEmpty()) {
- throw new CoolException("鎵樼洏宸插湪搴�");
- }
-
- List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, waitPakin.getBarcode()));
- if (!taskList.isEmpty()) {
- throw new CoolException("鎵樼洏姝e湪鍏ュ簱涓�");
- }
-
- //鏌ヨ鏄惁瀛樺湪鐩稿悓鏄庣粏鍜屾墭鐩樼爜鐨勭粍鎵橀�氱煡妗�
- WaitPakin waitPakin1 = this.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, waitPakin.getBarcode()).eq(WaitPakin::getDetlId, waitPakin.getDetlId()));
- if (waitPakin1 == null) {
- //涓嶅瓨鍦ㄧ粍鎵橀�氱煡妗o紝鍒涘缓
- if (!this.save(waitPakin)) {
- throw new CoolException("娣诲姞澶辫触");
- }
- }else {
- //瀛樺湪缁勬墭閫氱煡妗o紝鏇存柊
- waitPakin1.setAnfme(waitPakin1.getAnfme() + waitPakin.getAnfme());
- waitPakin1.setUpdateTime(new Date());
- if (!this.updateById(waitPakin1)) {
- throw new CoolException("娣诲姞澶辫触");
- }
- }
-
- OrderDetl orderDetl = orderDetlService.getById(waitPakin.getDetlId());
- if (orderDetl == null) {
- throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
- }
-
- //鑾峰彇璁㈠崟
- Order order = orderService.getById(orderDetl.getOrderId());
- if(order == null){
- throw new CoolException("璁㈠崟涓嶅瓨鍦�");
- }
-
- //鏇存柊璁㈠崟鐘舵��
- if (order.getOrderSettle().equals(OrderSettleType.INIT.val())) {
- order.setOrderSettle(OrderSettleType.WAIT.val());
- order.setUpdateTime(new Date());
- if (!orderService.updateById(order)) {
- throw new CoolException("璁㈠崟鏁版嵁鏇存柊澶辫触");
- }
- }
- return true;
- }
-}
+package com.zy.asrs.wms.asrs.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.framework.exception.CoolException;
+import com.zy.asrs.wms.asrs.entity.*;
+import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType;
+import com.zy.asrs.wms.asrs.entity.enums.OrderType;
+import com.zy.asrs.wms.asrs.mapper.WaitPakinMapper;
+import com.zy.asrs.wms.asrs.service.*;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+@Service("waitPakinService")
+public class WaitPakinServiceImpl extends ServiceImpl<WaitPakinMapper, WaitPakin> implements WaitPakinService {
+
+ @Autowired
+ private OrderService orderService;
+ @Autowired
+ private OrderDetlService orderDetlService;
+ @Autowired
+ private LocService locService;
+ @Autowired
+ private TaskService taskService;
+ @Autowired
+ private WaitPakinRuleService waitPakinRuleService;
+
+ @Override
+ public List<WaitPakin> getByOrderDetlId(Long orderDetlId) {
+ return this.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getDetlId, orderDetlId));
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public boolean comb(WaitPakin waitPakin) {
+ //缁勬墭瑙勫垯鏍¢獙
+ waitPakinRuleService.rule(waitPakin);
+
+ if (waitPakin.getAnfme() <= 0) {
+ throw new CoolException("缁勬墭鏁伴噺閿欒");
+ }
+
+ List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, waitPakin.getBarcode()));
+ if (!locList.isEmpty()) {
+ throw new CoolException("鎵樼洏宸插湪搴�");
+ }
+
+ List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, waitPakin.getBarcode()));
+ if (!taskList.isEmpty()) {
+ throw new CoolException("鎵樼洏姝e湪鍏ュ簱涓�");
+ }
+
+ OrderDetl orderDetl = orderDetlService.getById(waitPakin.getDetlId());
+ if (orderDetl == null) {
+ throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦�");
+ }
+
+ //鍙敤鏁伴噺
+// Double count = orderDetl.getAnfme() - orderDetl.getQty() - orderDetl.getWorkQty() - orderDetl.getWaitQty();
+ Double count = Math.round((orderDetl.getAnfme() - orderDetl.getWorkQty() - orderDetl.getQty()) * 1000) / 1000.0;
+ if (waitPakin.getAnfme().compareTo(count) > 0) {
+ throw new CoolException("缁勬墭鏁伴噺瓒呰繃鍓╀綑鍙敤鏁伴噺");
+ }
+
+ //鏌ヨ鏄惁瀛樺湪鐩稿悓鏄庣粏鍜屾墭鐩樼爜鐨勭粍鎵橀�氱煡妗�
+ WaitPakin waitPakin1 = this.getOne(new LambdaQueryWrapper<WaitPakin>()
+ .eq(WaitPakin::getBarcode, waitPakin.getBarcode())
+ .eq(WaitPakin::getDetlId, waitPakin.getDetlId()));
+ if (waitPakin1 == null) {
+ //涓嶅瓨鍦ㄧ粍鎵橀�氱煡妗o紝鍒涘缓
+ waitPakin.setMatnr(orderDetl.getMat$().getMatnr());
+ waitPakin.setBatch(orderDetl.getBatch());
+ if (!this.save(waitPakin)) {
+ throw new CoolException("娣诲姞澶辫触");
+ }
+ }else {
+ //瀛樺湪缁勬墭閫氱煡妗o紝鏇存柊
+ waitPakin1.setAnfme(waitPakin1.getAnfme() + waitPakin.getAnfme());
+ waitPakin1.setUpdateTime(new Date());
+ if (!this.updateById(waitPakin1)) {
+ throw new CoolException("娣诲姞澶辫触");
+ }
+ }
+
+ //鑾峰彇璁㈠崟
+ Order order = orderService.getById(orderDetl.getOrderId());
+ if(order == null){
+ throw new CoolException("璁㈠崟涓嶅瓨鍦�");
+ }
+
+ //濡傛灉鏄钩搴撳叆搴撳崟锛屼慨鏀硅鍗曟槑缁嗘墽琛屾暟閲�
+ if (order.getOrderType() == OrderType.PK_IN_ORDER.id) {
+ orderDetl.setWorkQty(waitPakin.getAnfme());
+ orderDetlService.updateById(orderDetl);
+ }
+
+ //鏇存柊璁㈠崟鐘舵��
+ if (order.getOrderSettle().equals(OrderSettleType.INIT.val())) {
+ order.setOrderSettle(OrderSettleType.WAIT.val());
+ order.setUpdateTime(new Date());
+ if (!orderService.updateById(order)) {
+ throw new CoolException("璁㈠崟鏁版嵁鏇存柊澶辫触");
+ }
+ }
+ return true;
+ }
+}
--
Gitblit v1.9.1