From 3e7ddfed8f28fda861710fda62cb485e393244c5 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期一, 12 五月 2025 08:13:48 +0800
Subject: [PATCH] no message
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java | 121 ++++++++++++++++++++++++++++++---------
1 files changed, 92 insertions(+), 29 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java
index ea34d24..287576c 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/QlyIsptItemServiceImpl.java
@@ -8,18 +8,22 @@
import com.vincent.rsf.server.manager.controller.params.QlyInspectAndItem;
import com.vincent.rsf.server.manager.entity.AsnOrderItem;
import com.vincent.rsf.server.manager.entity.QlyInspect;
+import com.vincent.rsf.server.manager.entity.QlyInspectResult;
import com.vincent.rsf.server.manager.enums.QlyIsptResult;
import com.vincent.rsf.server.manager.enums.QlyIsptStatus;
import com.vincent.rsf.server.manager.mapper.QlyIsptItemMapper;
import com.vincent.rsf.server.manager.entity.QlyIsptItem;
import com.vincent.rsf.server.manager.service.AsnOrderItemService;
+import com.vincent.rsf.server.manager.service.QlyInspectResultService;
import com.vincent.rsf.server.manager.service.QlyInspectService;
import com.vincent.rsf.server.manager.service.QlyIsptItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -30,13 +34,17 @@
@Autowired
private QlyInspectService qlyInspectService;
+ @Autowired
private AsnOrderItemService asnOrderItemService;
+ @Autowired
+ private QlyInspectResultService qlyInspectResultService;
+
/**
- * @author Ryan
- * @description 鎵归噺淇敼
* @param
* @return
+ * @author Ryan
+ * @description 鎵归噺淇敼
* @time 2025/4/1 09:40
*/
@Override
@@ -45,23 +53,67 @@
if (Objects.isNull(params.getIsptItem()) || params.getIsptItem().isEmpty()) {
throw new CoolException("ID涓嶈兘涓虹┖锛侊紒");
}
- List<QlyIsptItem> isptItem = params.getIsptItem();
+ List<QlyIsptItem> isptItem = params.getIsptItem();
List<Long> list = isptItem.stream().map(QlyIsptItem::getId).collect(Collectors.toList());
+
+ List<QlyIsptItem> isptItems = this.list(new LambdaQueryWrapper<QlyIsptItem>().in(QlyIsptItem::getId, list));
+ if (isptItems.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒锛氭槑缁嗕笉瀛樺湪锛侊紒");
+ }
+
+ for (QlyIsptItem item : isptItems) {
+ List<QlyInspectResult> results = qlyInspectResultService.list(new LambdaQueryWrapper<QlyInspectResult>()
+ .eq(QlyInspectResult::getIsptId, item.getIspectId())
+ .eq(QlyInspectResult::getIsptItemId, item.getId()));
+ if (!results.isEmpty()) {
+ //涓嶄负绌哄仛鏇存柊鎿嶄綔
+
+
+ } else {
+ //涓虹┖鍋氭柊澧炴搷浣�
+ QlyInspectResult result = new QlyInspectResult();
+ result.setIsptId(item.getIspectId())
+ .setAnfme(item.getSafeQty())
+ .setIsptItemId(item.getId());
+ if (item.getDisQty().compareTo(0.00) < 1) {
+ continue;
+ }
+ result.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val);
+ result.setAnfme(item.getDisQty());
+
+ if (!qlyInspectResultService.save(result)) {
+ throw new CoolException("璐ㄦ缁撹淇濆瓨澶辫触锛侊紒");
+ }
+
+ if (item.getSafeQty().compareTo(0.00) < 1) {
+ continue;
+ }
+ result.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val)
+ .setAnfme(item.getSafeQty());
+
+ if (!qlyInspectResultService.save(result)) {
+ throw new CoolException("璐ㄦ缁撹淇濆瓨澶辫触锛侊紒");
+ }
+ }
+
+ }
+
+
if (Short.parseShort(params.getType()) == QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val || Short.parseShort(params.getType()) == QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val) {
//1锛氬悎鏍硷紝 2锛氫笉鍚堟牸, 0: 鍏跺畠锛堥粯璁わ級
isptItem.forEach(item -> {
if (Short.parseShort(params.getType()) == QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val) {
//TODO 鍏堟崱鍚庢敹涓洪�佽揣鏁伴噺锛屽厛鏀跺悗鎹′负鏀惰揣鏁伴噺
- item.setSafeQty(item.getDlyQty());
- item.setDisQty(0.0);
+// item.setSafeQty(item.getDlyQty());
+// item.setDisQty(0.0);
} else {
- item.setSafeQty(0.0);
- item.setDisQty(item.getDlyQty());
+// item.setSafeQty(0.0);
+// item.setDisQty(item.getDlyQty());
}
if (!this.update(new LambdaUpdateWrapper<QlyIsptItem>()
- .set(QlyIsptItem::getSafeQty, item.getSafeQty())
+// .set(QlyIsptItem::getSafeQty, item.getSafeQty())
.set(QlyIsptItem::getIsptResult, Short.parseShort(params.getType()))
- .set(QlyIsptItem::getDisQty, item.getDisQty())
+// .set(QlyIsptItem::getDisQty, item.getDisQty())
.in(QlyIsptItem::getId, item.getId()))) {
throw new CoolException("淇敼澶辫触锛侊紒");
}
@@ -71,34 +123,45 @@
throw new CoolException("鏄庣粏淇敼澶辫触");
}
}
- List<QlyIsptItem> isptItems = this.list(new LambdaQueryWrapper<QlyIsptItem>().in(QlyIsptItem::getId, list));
- if (isptItems.isEmpty()) {
- throw new CoolException("鏁版嵁閿欒锛氭槑缁嗕笉瀛樺湪锛侊紒");
- }
+
Map<Long, List<QlyIsptItem>> listMap = isptItems.stream().collect(Collectors.groupingBy(QlyIsptItem::getIspectId));
for (Long key : listMap.keySet()) {
QlyInspect inspect = qlyInspectService.getById(key);
List<QlyIsptItem> items = listMap.get(key);
items.forEach(qlyIsptItem -> {
AsnOrderItem orderItem = asnOrderItemService.getById(qlyIsptItem.getAsnItemId());
- if (qlyIsptItem.getSafeQty().compareTo(orderItem.getAnfme()) >= 0.00) {
- orderItem.setIsptResult()
- }
+// if (qlyIsptItem.getSafeQty().compareTo(orderItem.getAnfme()) >= 0.00) {
+// orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val)
+// .setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val);
+// } else if (qlyIsptItem.getSafeQty().compareTo(0.00) > 0.00 && qlyIsptItem.getSafeQty().compareTo(orderItem.getAnfme()) < 0.00) {
+// orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_SECTION.val);
+// if (Double.compare(qlyIsptItem.getSafeQty() + qlyIsptItem.getDisQty(), orderItem.getAnfme()) >= 0.00 ) {
+// orderItem.setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val);
+// } else {
+// orderItem.setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_ING.val);
+// }
+// } else {
+// orderItem.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_DEFECT.val)
+// .setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val);
+// }
+ if (!asnOrderItemService.updateById(orderItem)) {
+ throw new CoolException("鏀惰揣鍗曟槑缁嗕慨鏀瑰け璐ワ紒锛�");
+ }
});
- Double safeQty = items.stream().mapToDouble(QlyIsptItem::getSafeQty).sum();
- Double disQty = items.stream().mapToDouble(QlyIsptItem::getDisQty).sum();
- Double qlyQty = safeQty + disQty;
- //瀹夊叏鏁伴噺锛岃川妫�鏁伴噺
- inspect.setSafeQty(safeQty)
- .setIsptQty(qlyQty);
- if (Double.compare(disQty, 0) > 0) {
- inspect.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_SECTION.val);
- }
- if (Double.compare(safeQty, inspect.getDlyQty()) == 0) {
-// inspect.setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val);
- inspect.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val);
- }
+// Double safeQty = items.stream().mapToDouble(QlyIsptItem::getSafeQty).sum();
+// Double disQty = items.stream().mapToDouble(QlyIsptItem::getDisQty).sum();
+// Double qlyQty = safeQty + disQty;
+// //瀹夊叏鏁伴噺锛岃川妫�鏁伴噺
+// inspect.setSafeQty(safeQty)
+// .setIsptQty(qlyQty);
+// if (Double.compare(disQty, 0) > 0) {
+// inspect.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_SECTION.val);
+// }
+// if (Double.compare(safeQty, inspect.getDlyQty()) == 0) {
+//// inspect.setIsptStatus(QlyIsptStatus.QLY_ISPT_STAS_DONE.val);
+// inspect.setIsptResult(QlyIsptResult.QLY_ISPT_RESULT_EXCELLENT.val);
+// }
if (!qlyInspectService.updateById(inspect)) {
throw new CoolException("璐ㄦ鏁伴噺淇敼澶辫触锛侊紒");
}
--
Gitblit v1.9.1