From fc2afc38a9eefaba1bb2f3fad0b793b4ea846cb3 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期一, 16 三月 2026 13:50:11 +0800
Subject: [PATCH] 销售-pda
---
src/main/java/com/zy/asrs/controller/SaleOrderController.java | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 105 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/SaleOrderController.java b/src/main/java/com/zy/asrs/controller/SaleOrderController.java
index f9906f7..b979bd3 100644
--- a/src/main/java/com/zy/asrs/controller/SaleOrderController.java
+++ b/src/main/java/com/zy/asrs/controller/SaleOrderController.java
@@ -7,7 +7,9 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.DateUtils;
import com.zy.asrs.entity.SaleOrder;
+import com.zy.asrs.entity.WaitPakin;
import com.zy.asrs.service.SaleOrderService;
+import com.zy.asrs.service.WaitPakinService;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
import com.core.common.Cools;
@@ -16,6 +18,8 @@
import com.zy.common.web.BaseController;
import org.apache.poi.xssf.usermodel.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -31,8 +35,12 @@
@RestController
public class SaleOrderController extends BaseController {
+ private static final Logger logger = LoggerFactory.getLogger(SaleOrderController.class);
+
@Autowired
private SaleOrderService saleOrderService;
+ @Autowired
+ private WaitPakinService waitPakinService;
@RequestMapping(value = "/saleOrder/{id}/auth")
@ManagerAuth
@@ -234,6 +242,7 @@
}
int successCount = 0;
int updateCount = 0;
+ int skipCount = 0;
for (Map<String, Object> data : dataList) {
try {
// 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堟牴鎹鍗曞彿鍜岀墿鏂欑紪鐮侊級
@@ -242,11 +251,39 @@
SaleOrder saleOrder;
boolean isUpdate = false;
+ boolean hasQtyChange = false;
+
if (existOrder != null) {
- // 宸插瓨鍦紝鏇存柊鏁版嵁
- saleOrder = existOrder;
- isUpdate = true;
- updateCount++;
+ // 宸插瓨鍦紝妫�鏌ユ暟閲忓瓧娈垫槸鍚︽湁鍙樺寲
+ Double newOrderQty = parseDoubleSafely(data.get("orderQty"));
+ Double newProductQty = parseDoubleSafely(data.get("productQty"));
+ Double newInQty = parseDoubleSafely(data.get("inQty"));
+ Double newOutQty = parseDoubleSafely(data.get("outQty"));
+ Double newOutAmount = parseDoubleSafely(data.get("outAmount"));
+ Double newOutPrice = parseDoubleSafely(data.get("outPrice"));
+ Double newIcsbeqty = parseDoubleSafely(data.get("icsbeqty"));
+ Double newSeoseqty = parseDoubleSafely(data.get("seoseqty"));
+
+ // 姣旇緝鏁伴噺瀛楁鏄惁鏈夊彉鍖�
+ hasQtyChange = !isDoubleEqual(existOrder.getOrderQty(), newOrderQty)
+ || !isDoubleEqual(existOrder.getProductQty(), newProductQty)
+ || !isDoubleEqual(existOrder.getInQty(), newInQty)
+ || !isDoubleEqual(existOrder.getOutQty(), newOutQty)
+ || !isDoubleEqual(existOrder.getOutAmount(), newOutAmount)
+ || !isDoubleEqual(existOrder.getOutPrice(), newOutPrice)
+ || !isDoubleEqual(existOrder.getIcsbeqty(), newIcsbeqty)
+ || !isDoubleEqual(existOrder.getSeoseqty(), newSeoseqty);
+
+ // 鍙湁褰撴暟閲忔湁鍙樺寲鏃舵墠鏇存柊
+ if (hasQtyChange) {
+ saleOrder = existOrder;
+ isUpdate = true;
+ updateCount++;
+ } else {
+ // 鏁伴噺娌℃湁鍙樺寲锛岃烦杩囨洿鏂�
+ skipCount++;
+ continue;
+ }
} else {
// 涓嶅瓨鍦紝鍒涘缓鏂拌褰�
saleOrder = new SaleOrder();
@@ -285,6 +322,8 @@
// 淇濆瓨鎴栨洿鏂�
if (isUpdate) {
saleOrderService.updateById(saleOrder);
+ // 閿�鍞鍗曟洿鏂板悗锛岄『甯︽洿鏂� xtyasrs 搴� cust_wait_pakin 鐨勬暟閲忥紙mobile/bill/query 鐨� count 鍙栬嚜 anfme锛夛紝浠呮洿鏂般�佷笉鎻掑叆锛屽け璐ヤ笉褰卞搷涓绘祦绋�
+ updateWaitPakinQuantity(data);
} else {
saleOrderService.insert(saleOrder);
}
@@ -293,7 +332,68 @@
e.printStackTrace();
}
}
- return R.ok("鎴愬姛淇濆瓨 " + successCount + " 鏉℃柊鏁版嵁锛屾洿鏂� " + updateCount + " 鏉″凡瀛樺湪鏁版嵁");
+ String message = "鎴愬姛淇濆瓨 " + successCount + " 鏉℃柊鏁版嵁锛屾洿鏂� " + updateCount + " 鏉″凡瀛樺湪鏁版嵁";
+ if (skipCount > 0) {
+ message += "锛岃烦杩� " + skipCount + " 鏉℃暟閲忔湭鍙樺寲鐨勬暟鎹�";
+ }
+ return R.ok(message);
+ }
+
+ /**
+ * 姣旇緝涓や釜Double鍊兼槸鍚︾浉绛夛紙澶勭悊null鍊煎拰0鍊硷級
+ * 閲嶈锛歯ull鍜�0琚涓烘槸涓嶅悓鐨勫�硷紝闇�瑕佹洿鏂�
+ * @param d1 绗竴涓狣ouble鍊�
+ * @param d2 绗簩涓狣ouble鍊�
+ * @return true-鐩哥瓑锛宖alse-涓嶇浉绛�
+ */
+ private boolean isDoubleEqual(Double d1, Double d2) {
+ // 涓や釜閮芥槸null锛岃涓虹浉绛�
+ if (d1 == null && d2 == null) {
+ return true;
+ }
+ // 涓�涓负null锛屽彟涓�涓笉涓簄ull锛岃涓轰笉鐩哥瓑锛堥渶瑕佹洿鏂帮級
+ // 娉ㄦ剰锛歯ull鍜�0鏄笉鍚岀殑锛宯ull鍜�0.0浼氳繑鍥瀎alse锛岃Е鍙戞洿鏂�
+ if (d1 == null || d2 == null) {
+ return false;
+ }
+ // 涓や釜閮戒笉涓簄ull锛屼娇鐢ㄨ宸寖鍥存瘮杈冿紝閬垮厤娴偣鏁扮簿搴﹂棶棰�
+ // 娉ㄦ剰锛�0鍊间細琚纭瘮杈冿紝渚嬪锛�0.0鍜�0.0浼氳繑鍥瀟rue锛�100.0鍜�0.0浼氳繑鍥瀎alse
+ return Math.abs(d1 - d2) < 0.0001;
+ }
+
+ /**
+ * 閿�鍞鍗曟暟閲忔洿鏂板悗锛岄『甯︽洿鏂� cust_wait_pakin 鐨� anfme/nqty锛坢obile/bill/query 鐨� count 鍙栬嚜 anfme锛夈��
+ * 浠呮寜 matnr+mnemonic 鏇存柊锛屼笉鎻掑叆锛涙棤鍖归厤鎴栧紓甯镐笉褰卞搷涓绘祦绋嬨��
+ */
+ private void updateWaitPakinQuantity(Map<String, Object> data) {
+ try {
+ String invCode = data.get("invCode") != null ? String.valueOf(data.get("invCode")).trim() : null;
+ String orderCode = data.get("orderCode") != null ? String.valueOf(data.get("orderCode")).trim() : null;
+ if (Cools.isEmpty(invCode) || Cools.isEmpty(orderCode)) {
+ logger.debug("cust_wait_pakin 璺宠繃鏇存柊锛氳鍗曞彿鎴栫墿鏂欑紪鐮佷负绌猴紝orderCode={}锛宨nvCode={}", orderCode, invCode);
+ return;
+ }
+ Double productQty = parseDoubleSafely(data.get("productQty"));
+ if (productQty == null) {
+ productQty = parseDoubleSafely(data.get("orderQty"));
+ }
+ logger.info("cust_wait_pakin 寮�濮嬫洿鏂帮細璁㈠崟鍙�={}锛岀墿鏂欑紪鐮�={}锛屾暟閲�={}", orderCode, invCode, productQty);
+ String invName = data.get("invName") != null ? String.valueOf(data.get("invName")) : null;
+ WaitPakin updateEntity = new WaitPakin();
+ updateEntity.setMaktx(invName);
+ updateEntity.setAnfme(productQty);
+ updateEntity.setNqty(productQty);
+ updateEntity.setModiTime(new Date());
+ Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>().eq("matnr", invCode).eq("mnemonic", orderCode);
+ boolean updated = waitPakinService.update(updateEntity, wrapper);
+ if (updated) {
+ logger.info("cust_wait_pakin 鏇存柊鎴愬姛锛氳鍗曞彿={}锛岀墿鏂欑紪鐮�={}锛屾暟閲�={}", orderCode, invCode, productQty);
+ } else {
+ logger.warn("cust_wait_pakin 鏇存柊鏈奖鍝嶈锛堝彲鑳芥棤鍖归厤璁板綍锛夛細璁㈠崟鍙�={}锛岀墿鏂欑紪鐮�={}", orderCode, invCode);
+ }
+ } catch (Exception e) {
+ logger.error("cust_wait_pakin 鏇存柊寮傚父锛歰rderCode={}锛宨nvCode={}锛宔rror={}", data.get("orderCode"), data.get("invCode"), e.getMessage(), e);
+ }
}
@RequestMapping(value = "/saleOrder/update/auth")
--
Gitblit v1.9.1