From e9543f18fbe81fb492df941fdc6fce59424f8f49 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期四, 05 二月 2026 08:39:36 +0800
Subject: [PATCH] RCS对接
---
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java | 137 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 122 insertions(+), 15 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java
index d1cfe78..c5c7240 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java
@@ -35,6 +35,8 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.utils.SerialRuleUtils;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -57,6 +59,8 @@
*/
@Service
public class MobileServiceImpl implements MobileService {
+
+ private static final Logger logger = LoggerFactory.getLogger(MobileServiceImpl.class);
@Value("${super.pwd}")
private String superPwd;
@@ -544,9 +548,9 @@
String batch = params.get("batch");
// String barcode = params.get("barcode");
- if (Objects.isNull(crushNo)) {
- throw new CoolException("绁ㄥ彿涓嶈兘涓虹┖锛侊紒");
- }
+// if (Objects.isNull(crushNo)) {
+// throw new CoolException("绁ㄥ彿涓嶈兘涓虹┖锛侊紒");
+// }
// if (Objects.isNull(code)) {
// throw new CoolException("瀹瑰櫒鍙蜂笉鑳戒负绌猴紒锛�");
// }
@@ -561,29 +565,132 @@
// }
// }
- String fieldIndex = null;
+ String fieldIndexTemp = null;
if (!Objects.isNull(crushNo)) {
FieldsItem fieldsItem = fieldsItemService.getOne(new LambdaQueryWrapper<FieldsItem>().eq(FieldsItem::getValue, crushNo).last("Limit 1"));
if (!Objects.isNull(fieldsItem)) {
- fieldIndex = fieldsItem.getUuid();
+ fieldIndexTemp = fieldsItem.getUuid();
}
}
- //TODO 鍚庣画闇�鏍规嵁绛栫暐閰嶇疆锛岃幏鍙栫粍鎷栨暟鎹�傚锛氭贩瑁咃紝鎸夋壒娆℃贩瑁呯瓑
- LambdaQueryWrapper<WarehouseAreasItem> queryWrapper = new LambdaQueryWrapper<WarehouseAreasItem>()
- .or().eq(!Cools.isEmpty(code), WarehouseAreasItem::getTrackCode, code)
- .or().eq(!Cools.isEmpty(batch), WarehouseAreasItem::getSplrBatch, batch)
- .or().eq(WarehouseAreasItem::getFieldsIndex, fieldIndex)
- .or().eq(!Cools.isEmpty(matnrCode), WarehouseAreasItem::getMatnrCode, matnrCode)
- .or().eq(!Cools.isEmpty(asnCode), WarehouseAreasItem::getAsnCode, asnCode);
- List<WarehouseAreasItem> list = warehouseAreasItemService.list(queryWrapper);
- if (!list.isEmpty()) {
- list.removeIf(e -> e.getAnfme() <= e.getWorkQty());
+ final String fieldIndex = fieldIndexTemp;
+
+ // 妫�鏌ユ槸鍚︽湁鑷冲皯涓�涓湁鏁堟煡璇㈡潯浠�
+ boolean hasValidCondition = !Cools.isEmpty(code) || !Cools.isEmpty(batch)
+ || !Objects.isNull(fieldIndex) || !Cools.isEmpty(matnrCode) || !Cools.isEmpty(asnCode);
+
+ if (!hasValidCondition) {
+ throw new CoolException("璇疯嚦灏戣緭鍏ヤ竴涓煡璇㈡潯浠讹細鐗╂枡缂栫爜銆丄SN鍗曞彿銆佽窡韪爜銆佹壒娆℃垨绁ㄥ彿");
}
+
+ //TODO 鍚庣画闇�鏍规嵁绛栫暐閰嶇疆锛岃幏鍙栫粍鎷栨暟鎹�傚锛氭贩瑁咃紝鎸夋壒娆℃贩瑁呯瓑
+ LambdaQueryWrapper<WarehouseAreasItem> queryWrapper = new LambdaQueryWrapper<>();
+
+ // 鏋勫缓OR鏌ヨ鏉′欢缁�
+ // 缁熻鏈夋晥鏉′欢鏁伴噺
+ int conditionCount = 0;
+ if (!Cools.isEmpty(code)) conditionCount++;
+ if (!Cools.isEmpty(batch)) conditionCount++;
+ if (!Objects.isNull(fieldIndex)) conditionCount++;
+ if (!Cools.isEmpty(matnrCode)) conditionCount++;
+ if (!Cools.isEmpty(asnCode)) conditionCount++;
+
+ // 濡傛灉鍙湁涓�涓潯浠讹紝鐩存帴浣跨敤eq锛涘鏋滄湁澶氫釜鏉′欢锛屼娇鐢╝nd鍖呰9or鏉′欢缁�
+ if (conditionCount == 1) {
+ // 鍗曚釜鏉′欢锛岀洿鎺ユ煡璇�
+ if (!Cools.isEmpty(code)) {
+ queryWrapper.eq(WarehouseAreasItem::getTrackCode, code);
+ } else if (!Cools.isEmpty(batch)) {
+ queryWrapper.eq(WarehouseAreasItem::getSplrBatch, batch);
+ } else if (!Objects.isNull(fieldIndex)) {
+ queryWrapper.eq(WarehouseAreasItem::getFieldsIndex, fieldIndex);
+ } else if (!Cools.isEmpty(matnrCode)) {
+ queryWrapper.eq(WarehouseAreasItem::getMatnrCode, matnrCode);
+ } else if (!Cools.isEmpty(asnCode)) {
+ queryWrapper.eq(WarehouseAreasItem::getAsnCode, asnCode);
+ }
+ } else {
+ // 澶氫釜鏉′欢锛屼娇鐢∣R杩炴帴
+ queryWrapper.and(wrapper -> {
+ boolean first = true;
+ if (!Cools.isEmpty(code)) {
+ wrapper.eq(WarehouseAreasItem::getTrackCode, code);
+ first = false;
+ }
+ if (!Cools.isEmpty(batch)) {
+ if (!first) wrapper.or();
+ wrapper.eq(WarehouseAreasItem::getSplrBatch, batch);
+ first = false;
+ }
+ if (!Objects.isNull(fieldIndex)) {
+ if (!first) wrapper.or();
+ wrapper.eq(WarehouseAreasItem::getFieldsIndex, fieldIndex);
+ first = false;
+ }
+ if (!Cools.isEmpty(matnrCode)) {
+ if (!first) wrapper.or();
+ wrapper.eq(WarehouseAreasItem::getMatnrCode, matnrCode);
+ first = false;
+ }
+ if (!Cools.isEmpty(asnCode)) {
+ if (!first) wrapper.or();
+ wrapper.eq(WarehouseAreasItem::getAsnCode, asnCode);
+ }
+ });
+ }
+
+ // 鎵撳嵃鏌ヨ鍙傛暟鍒版帶鍒跺彴
+ logger.info("=== 鏌ヨ鍙粍鎵樼墿鏂� ===");
+ logger.info("鏌ヨ鍙傛暟 - code: {}, matnrCode: {}, asnCode: {}, batch: {}, fieldIndex: {}",
+ code, matnrCode, asnCode, batch, fieldIndex);
+
+ List<WarehouseAreasItem> list = warehouseAreasItemService.list(queryWrapper);
+ logger.info("鏌ヨ鍒� {} 鏉℃敹璐у尯搴撳瓨鏁版嵁", list.size());
+
+ // 杩囨护鏉′欢锛氬彧杩斿洖鍙粍鎵樻暟閲� > 0 鐨勬暟鎹�
+ // 鍙粍鎵樻暟閲� = anfme - workQty - qty
+ if (!list.isEmpty()) {
+ int beforeFilterSize = list.size();
+ list.removeIf(e -> {
+ // 濡傛灉anfme涓簄ull锛岀Щ闄よ鏁版嵁
+ Double anfme = e.getAnfme();
+ if (Objects.isNull(anfme) || anfme <= 0) {
+ logger.debug("杩囨护鏁版嵁 - ID: {}, matnrCode: {}, anfme涓簄ull鎴�<=0: {}",
+ e.getId(), e.getMatnrCode(), anfme);
+ return true; // 绉婚櫎鏁伴噺涓簄ull鎴�<=0鐨勬暟鎹�
+ }
+
+ Double workQty = Objects.isNull(e.getWorkQty()) ? 0.0 : e.getWorkQty();
+ Double qty = Objects.isNull(e.getQty()) ? 0.0 : e.getQty();
+
+ // 鍙粍鎵樻暟閲� = 鎬绘暟閲� - 宸叉墽琛屾暟閲� - 宸叉敹璐ф暟閲�
+ Double availableQty = anfme - workQty - qty;
+ if (availableQty <= 0) {
+ logger.debug("杩囨护鏁版嵁 - ID: {}, matnrCode: {}, anfme: {}, workQty: {}, qty: {}, 鍙粍鎵樻暟閲�: {} <= 0",
+ e.getId(), e.getMatnrCode(), anfme, workQty, qty, availableQty);
+ }
+ return availableQty <= 0; // 绉婚櫎鍙粍鎵樻暟閲� <= 0 鐨勬暟鎹�
+ });
+
+ // 濡傛灉杩囨护鍚庢暟鎹负绌猴紝璇存槑鎵�鏈夋暟鎹兘琚繃婊ゆ帀浜�
+ if (list.isEmpty() && beforeFilterSize > 0) {
+ logger.warn("鏈壘鍒板彲缁勬墭鐨勭墿鏂欙紝璇锋鏌ワ細1.鐗╂枡缂栫爜鏄惁姝g‘ 2.鐗╂枡鏄惁宸叉敹璐ц嚦鏀惰揣鍖� 3.鏄惁杩樻湁鍙粍鎵樻暟閲�");
+ logger.warn("鏌ヨ鏉′欢 - code: {}, matnrCode: {}, asnCode: {}, batch: {}, fieldIndex: {}",
+ code, matnrCode, asnCode, batch, fieldIndex);
+ logger.warn("鏌ヨ鍒� {} 鏉℃暟鎹紝浣嗗叏閮ㄨ杩囨护锛堝彲缁勬墭鏁伴噺 <= 0锛�", beforeFilterSize);
+ }
+ } else {
+ logger.warn("鏈壘鍒板彲缁勬墭鐨勭墿鏂欙紝璇锋鏌ワ細1.鐗╂枡缂栫爜鏄惁姝g‘ 2.鐗╂枡鏄惁宸叉敹璐ц嚦鏀惰揣鍖� 3.鏄惁杩樻湁鍙粍鎵樻暟閲�");
+ logger.warn("鏌ヨ鏉′欢 - code: {}, matnrCode: {}, asnCode: {}, batch: {}, fieldIndex: {}",
+ code, matnrCode, asnCode, batch, fieldIndex);
+ logger.warn("鏁版嵁搴撴煡璇㈢粨鏋滀负绌猴紝鍙兘鍘熷洜锛�1.鐗╂枡缂栫爜涓嶅尮閰� 2.鐗╂枡鏈敹璐ц嚦鏀惰揣鍖� 3.鏁版嵁宸茶鍒犻櫎");
+ }
+
list.forEach(item -> {
Map<String, String> fields = FieldsUtils.getFields(item.getFieldsIndex());
item.setExtendFields(fields);
});
+ logger.info("杩斿洖 {} 鏉″彲缁勬墭鐗╂枡鏁版嵁", list.size());
return R.ok(list);
}
--
Gitblit v1.9.1