From 33686e35470b3548053d03532fbefa40f2470a2b Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期四, 07 五月 2026 09:56:04 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/task/kingdee/handler/InboundOrderHandler.java |   71 +++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 21 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/kingdee/handler/InboundOrderHandler.java b/src/main/java/com/zy/asrs/task/kingdee/handler/InboundOrderHandler.java
index a0e3a33..6a46b23 100644
--- a/src/main/java/com/zy/asrs/task/kingdee/handler/InboundOrderHandler.java
+++ b/src/main/java/com/zy/asrs/task/kingdee/handler/InboundOrderHandler.java
@@ -155,7 +155,7 @@
                     path = orgAddress;
                     break;
                 case "PUR_RECEIVEBIll": //宸插鏍告敹鏂欏崟鏌ヨ
-                    jsonObject.put("start_biztime",  latestUpdateTime);//涓氬姟璧峰鏃ユ湡
+                    jsonObject.put("start_biztime",  "2026-03-28");//涓氬姟璧峰鏃ユ湡
                     jsonObject.put("end_biztime", sdf1.format(now));//涓氬姟缁撴潫鏃ユ湡
                     jsonObject.put("billno", null);
                     jsonObject.put("billstatus", Arrays.asList("C"));//鏁版嵁鐘舵�� [A:鏆傚瓨, B:宸叉彁浜�, C:宸插鏍竇
@@ -262,20 +262,36 @@
                         .setJson(add)
                         .build()
                         .doPost();
+                if (response == null || response.trim().isEmpty()) {
+                    log.error("妫�绱㈠け璐ワ細杩斿洖绌哄搷搴旓紝path={}", path);
+                    continue;
+                }
                 JSONObject jsonResponse = JSON.parseObject(response);
-                if(jsonResponse.getString("errorCode").equals("401")){
+                if (jsonResponse == null) {
+                    log.error("妫�绱㈠け璐ワ細鍝嶅簲鏃犳硶瑙f瀽涓篔SON锛宲ath={}锛宺esponse={}", path, response);
+                    continue;
+                }
+                if ("401".equals(jsonResponse.getString("errorCode"))) {
                     log.error("妫�绱㈠け璐ラ敊璇俊鎭細{}", jsonResponse.getString("message"));
                     loginAuthenticationHandler.start();
                     continue;
                 }
-                JSONArray data = jsonResponse.getJSONObject("data").getJSONArray("rows");
+                JSONObject dataObj = jsonResponse.getJSONObject("data");
+                if (dataObj == null) {
+                    log.error("妫�绱㈠け璐ワ細鍝嶅簲data涓虹┖锛宲ath={}锛宺esponse={}", path, response);
+                    continue;
+                }
+                JSONArray data = dataObj.getJSONArray("rows");
+                if (data == null) {
+                    continue;
+                }
                 if(data.size()<=0)  continue;
                 //鍟嗗搧妗f鍚屾
                 if(kingDeeUtilType.formId.equals("BD_MATERIAL")) {
                     Tag tag = tagService.selectByName("鍏ㄩ儴", 1);
                     // 澶勭悊鍒嗛〉锛氭牴鎹繑鍥炵殑totalCount鍜宲ageSize璁$畻椤垫暟
-                    int pageSize = jsonResponse.getJSONObject("data").getIntValue("pageSize");
-                    int totalCount = jsonResponse.getJSONObject("data").getIntValue("totalCount");
+                    int pageSize = dataObj.getIntValue("pageSize");
+                    int totalCount = dataObj.getIntValue("totalCount");
                     int totalPages = (int) Math.ceil((double) totalCount / pageSize);
 
                     for (int page = 1; page <= totalPages; page++) {
@@ -290,8 +306,24 @@
                                 .build()
                                 .doPost();
 
+                        if (response == null || response.trim().isEmpty()) {
+                            log.error("妫�绱㈠け璐ワ細鍒嗛〉杩斿洖绌哄搷搴旓紝path={}锛宲ageNo={}", path, page);
+                            continue;
+                        }
                         jsonResponse = JSON.parseObject(response);
-                        data = jsonResponse.getJSONObject("data").getJSONArray("rows");
+                        if (jsonResponse == null) {
+                            log.error("妫�绱㈠け璐ワ細鍒嗛〉鍝嶅簲鏃犳硶瑙f瀽涓篔SON锛宲ath={}锛宲ageNo={}锛宺esponse={}", path, page, response);
+                            continue;
+                        }
+                        dataObj = jsonResponse.getJSONObject("data");
+                        if (dataObj == null) {
+                            log.error("妫�绱㈠け璐ワ細鍒嗛〉鍝嶅簲data涓虹┖锛宲ath={}锛宲ageNo={}锛宺esponse={}", path, page, response);
+                            continue;
+                        }
+                        data = dataObj.getJSONArray("rows");
+                        if (data == null) {
+                            continue;
+                        }
                         for (int j = 0; j < data.size(); j++) {
                             JSONObject jsonObjectNew = data.getJSONObject(j);
                             Date modifyTime = sdf1.parse(jsonObjectNew.get("modifytime").toString());
@@ -463,11 +495,11 @@
                             String ownerUuid = jsonObjectNew.get("org_number").toString();//erp璐т富缂栧彿
                             String orderId = jsonObjectNew.get("id").toString();
                             JSONObject detailParam = new JSONObject();
-                            JSONObject dataObj = new JSONObject();
-                            dataObj.put("billno", billNo);
+                            JSONObject billnoParam = new JSONObject();
+                            billnoParam.put("billno", billNo);
                             detailParam.put("pageNo", 1);
                             detailParam.put("pageSize", 100);
-                            detailParam.put("data", dataObj);
+                            detailParam.put("data", billnoParam);
                             boolean hasNext = true;
                             while (hasNext) {
                                 String reqJson = detailParam.toJSONString();
@@ -577,17 +609,14 @@
                                         }
                                         Double erpAnfme = anfme*mat.getSafeQty();
                                         Order order1 = orderService.selectByNo( billNo);
-                                        List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order1.getId());
-                                        boolean sign = false;
-                                        for (OrderDetl orderDetl : orderDetls){
-                                            if (orderDetl.getMatnr().equals(matnr)){
-                                                sign = true;
-                                                break;
-                                            }
-                                        }
-                                        if (sign){
-                                            continue;
-                                        }
+                                        List<OrderDetl> orderDetls =
+                                                orderDetlService.selectByOrderId(order.getId());
+                                        boolean exists = orderDetls.stream()
+                                                .anyMatch(o ->
+                                                        o.getMatnr().equals(matnr) &&
+                                                                o.getBoxType3().equals(pOrderNo)
+                                                );
+                                        if (exists) continue;
                                         LocSupp locSupp = null;
                                         String supp =null;
                                         locSupp = locSuppService.selectByUuid(suppCode);
@@ -1924,4 +1953,4 @@
     }
 
 
-}
\ No newline at end of file
+}

--
Gitblit v1.9.1