“lqy 3 тижнів тому
батько
коміт
72c8ead8bd
17 змінених файлів з 3288 додано та 1688 видалено
  1. 138 7
      mjava-huagao/src/main/java/com/malk/huagao/controller/KdYdCustomerController.java
  2. 6 0
      mjava-huagao/src/main/java/com/malk/huagao/controller/KdYdMaterialController.java
  3. 20 0
      mjava-huagao/src/main/java/com/malk/huagao/schedule/YdScheduleTask.java
  4. 2 0
      mjava-huagao/src/main/java/com/malk/huagao/service/IKdYdMaterialService.java
  5. 3 0
      mjava-huagao/src/main/java/com/malk/huagao/service/YdHuaGaoService.java
  6. 94 30
      mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdCustomerServiceImpl.java
  7. 221 81
      mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdDeliveryServiceImpl.java
  8. 197 29
      mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdMaterialServiceImpl.java
  9. 110 42
      mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdOrderServiceImpl.java
  10. 6 1
      mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdReceivableServiceImpl.java
  11. 1 0
      mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdTransferServiceImpl.java
  12. 282 0
      mjava-huagao/src/main/java/com/malk/huagao/service/impl/YdHuaGaoServiceImpl.java
  13. 1 1
      mjava-huagao/src/main/resources/application-dev.yml
  14. 2 2
      mjava-qiwang/src/main/java/com/malk/qiwang/Controller/InvoiceLibraryController.java
  15. 9 1
      mjava-qiwang/src/main/java/com/malk/qiwang/Controller/QiWangController.java
  16. 2193 1494
      mjava-qiwang/src/main/java/com/malk/qiwang/Service/impl/InvoiceLibraryServiceImpl.java
  17. 3 0
      mjava-qiwang/src/main/java/com/malk/qiwang/entity/InvoiceLibrary.java

+ 138 - 7
mjava-huagao/src/main/java/com/malk/huagao/controller/KdYdCustomerController.java

@@ -1,19 +1,26 @@
 package com.malk.huagao.controller;
 package com.malk.huagao.controller;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.malk.huagao.service.IKdYdCustomerService;
 import com.malk.huagao.service.IKdYdCustomerService;
 import com.malk.huagao.service.IKdYdZpService;
 import com.malk.huagao.service.IKdYdZpService;
 import com.malk.huagao.service.YdHuaGaoService;
 import com.malk.huagao.service.YdHuaGaoService;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDParam;
 import com.malk.server.aliwork.YDParam;
+import com.malk.server.aliwork.YDSearch;
+import com.malk.server.common.McException;
 import com.malk.server.common.McR;
 import com.malk.server.common.McR;
 import com.malk.server.dingtalk.DDR_New;
 import com.malk.server.dingtalk.DDR_New;
 import com.malk.service.aliwork.YDClient;
 import com.malk.service.aliwork.YDClient;
+import com.malk.service.aliwork.YDService;
 import com.malk.service.dingtalk.DDClient;
 import com.malk.service.dingtalk.DDClient;
 import com.malk.service.dingtalk.DDClient_Contacts;
 import com.malk.service.dingtalk.DDClient_Contacts;
+import com.malk.service.dingtalk.DDClient_Extension;
 import com.malk.service.dingtalk.DDClient_Workflow;
 import com.malk.service.dingtalk.DDClient_Workflow;
 import com.malk.utils.UtilMap;
 import com.malk.utils.UtilMap;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.slf4j.MDC;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -22,22 +29,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.stereotype.Controller;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 /**
 /**
  * <p>
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  * </p>
  *
  *
  * @author LQY
  * @author LQY
  * @since 2025-10-09
  * @since 2025-10-09
  */
  */
 @RestController
 @RestController
+@Slf4j
 @RequestMapping("/hg")
 @RequestMapping("/hg")
 public class KdYdCustomerController {
 public class KdYdCustomerController {
     @Autowired
     @Autowired
-    private IKdYdCustomerService  kdYdCustomerService;
+    private IKdYdCustomerService kdYdCustomerService;
     @Autowired
     @Autowired
     private YdHuaGaoService ydHuaGaoService;
     private YdHuaGaoService ydHuaGaoService;
     @Autowired
     @Autowired
@@ -46,11 +53,118 @@ public class KdYdCustomerController {
     private DDClient_Contacts ddClient_contacts;
     private DDClient_Contacts ddClient_contacts;
     @Autowired
     @Autowired
     private DDClient ddClient;
     private DDClient ddClient;
-@Autowired
-private YDClient ydClient;
+    @Autowired
+    private DDClient_Extension ddClientExtension;
+    @Autowired
+    private YDClient ydClient;
+    @Autowired
+    private YDService ydService;
+    @PostMapping("/test")
+    public McR sendGroupMsg(@RequestBody JSONObject param){
+        log.info("推送消息:{}",param);
+        McException.assertParamException_Null(param,"msgParam","msgKey","openConversationId","robotCode","coolAppCode");
+        Map map = ddClientExtension.sendGroupMessages(ddClient.getAccessToken(), param.getJSONObject("msgParam"), param.getString("msgKey"), param.getString("openConversationId")
+                , param.getString("robotCode"), param.getString("coolAppCode"));
+        return McR.success(map);
+    }
     @PostMapping("/test30")
     @PostMapping("/test30")
     McR test13(@RequestBody Map data) {
     McR test13(@RequestBody Map data) {
-        MDC.put("MDC_KEY_PID","1003");
+        MDC.put("MDC_KEY_PID", "1003");
+        //当前时间戳
+        long time = System.currentTimeMillis();
+        List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-29C510B098584EDAA303D7252082D447YGUS").searchFieldJson(
+                JSONObject.toJSONString(Arrays.asList(
+                        new YDSearch("dateField_meqpbxsj",
+                                time,
+                                "DateField",
+                                YDSearch.Type.DATE_FIELD,
+                                YDSearch.Operator.LT),
+                        new YDSearch("radioField_meqpbxsi",
+                                "否",
+                                "RadioField",
+                                YDSearch.Type.RADIO_FIELD,
+                                YDSearch.Operator.EQ),
+                        new YDSearch("selectField_mewmhnwj",
+                                "已逾期",
+                                "SelectField",
+                                YDSearch.Type.RADIO_FIELD,
+                                YDSearch.Operator.EQ)
+                ))
+        ).build());
+
+        if (list == null || list.isEmpty()) {
+            log.info("没有找到需要处理的单据");
+            return McR.success("无待处理数据");
+        }
+        log.info("共查询到 {} 条待处理单据", list.size());
+        for (Map item : list) {
+
+            String glbdjson = String.valueOf(item.get("associationFormField_me2kiw8j_id"));
+            String sqr = String.valueOf(item.get("employeeField_mdya1lol_id"));
+            String formInstanceId = String.valueOf(item.get("formInstanceId"));
+//            String xsy = String.valueOf(item.get("employeeField_mejnamf3_id"));
+            String xszg = String.valueOf(item.get("employeeField_mmsna3tn_id"));
+            String zssj = String.valueOf(item.get("employeeField_mmsna3tm_id"));
+//            String zt = String.valueOf(item.get("selectField_mewmhnwj"));
+//            String fhtzd = String.valueOf(item.get("serialNumberField_mheazm7w"));
+
+            // 解析关联字段 JSON
+            List<Map> sealjsonlist = parseJsonList(glbdjson);
+            HashMap<String, Object> updateMap = new HashMap<>();
+            for (Object obj : item.entrySet()) {
+                Map.Entry<String, Object> formEntry = (Map.Entry<String, Object>) obj;
+                String key = formEntry.getKey();
+                Object value = formEntry.getValue();
+
+                // 跳过需要特殊处理的主表关联字段
+                if (key.equals("associationFormField_me2kiw8j_id") ||
+                        key.equals("employeeField_mdya1lol_id") ||
+                        key.equals("employeeField_mmsna3tn_id") ||
+                        key.equals("employeeField_mmsna3tm_id")) {
+                    continue;
+                }
+
+                // 复制其他字段
+                updateMap.put(key, value);
+            }
+
+            // 2. 添加需要特殊处理的主表字段
+            updateMap.put("associationFormField_me2kiw8j", sealjsonlist);
+            updateMap.put("employeeField_mdya1lol", sqr);
+            updateMap.put("employeeField_mmsna3tn", xszg);
+            updateMap.put("employeeField_mmsna3tm", zssj);
+            // 3. 添加处理后的子表数据
+            String sqrid = sqr.substring(2, sqr.length() - 2);
+            String xszgid = xszg.substring(2, xszg.length() - 2);
+            String finalId = (sqrid == null || sqrid.trim().isEmpty()) ? xszgid : sqrid;
+            ydClient.operateData(
+                    YDParam.builder()
+                            .formUuid("FORM-54F26858BF574AF0838AEF4086C35FD5VDXJ")
+                            .processCode("TPROC--1VF66Z61YYX6RD04NCTOPAF5EFMD2DKJV8UQM2")
+                            .formDataJson(JSON.toJSONString(updateMap))
+                            .userId(finalId)
+                            .build(),
+                    YDConf.FORM_OPERATION.start
+            );
+            Map formData =new HashMap<>();
+            formData.put("selectField_mewmhnwj", "已申请逾期扣款");
+            ydClient.operateData(YDParam.builder()
+                    .formInstId(formInstanceId)
+                    .updateFormDataJson(JSON.toJSONString(formData))
+                    .build(), YDConf.FORM_OPERATION.update);
+//        }
+        }
+//        System.out.println("list=="+list);
+//        for (Map item : list) {
+//            String formInstanceId = String.valueOf(item.get("formInstanceId"));
+//            Map formData =new HashMap<>();
+//            formData.put("textField_mfxbtce5", "无");
+//            formData.put("dateField_ml4ikfa1", "4073040000000");
+//            ydClient.operateData(YDParam.builder()
+//                    .formInstId(formInstanceId)
+//                    .updateFormDataJson(JSON.toJSONString(formData))
+//                    .build(), YDConf.FORM_OPERATION.update);
+//        }
 //        Map userInfoByMobile1 = ddClient_contacts.getUserInfoById(ddClient.getAccessToken(), "yzsyzid2");
 //        Map userInfoByMobile1 = ddClient_contacts.getUserInfoById(ddClient.getAccessToken(), "yzsyzid2");
 //        if (userInfoByMobile1 != null && userInfoByMobile1.containsKey("mobile")) {
 //        if (userInfoByMobile1 != null && userInfoByMobile1.containsKey("mobile")) {
 //            mobile = String.valueOf(userInfoByMobile1.get("mobile"));
 //            mobile = String.valueOf(userInfoByMobile1.get("mobile"));
@@ -100,6 +214,23 @@ private YDClient ydClient;
 //        ydHuaGaoService.synckdYdOutbound();
 //        ydHuaGaoService.synckdYdOutbound();
         return McR.success();
         return McR.success();
     }
     }
+    private List<Map> parseJsonList(String jsonStr) {
+        if (jsonStr == null || "null".equals(jsonStr) || jsonStr.isEmpty()) {
+            return Collections.emptyList();
+        }
+        try {
+            // 宜搭有时返回的是 "\"[{...}]\"",需先 unescape
+            String clean = StringEscapeUtils.unescapeJava(jsonStr);
+            // 如果首尾是双引号,去掉
+            if (clean.startsWith("\"") && clean.endsWith("\"")) {
+                clean = clean.substring(1, clean.length() - 1);
+            }
+            return (List<Map>) JSONArray.parse(clean);
+        } catch (Exception e) {
+
+            return Collections.emptyList();
+        }
+    }
     @PostMapping("/kdYdCustomer")
     @PostMapping("/kdYdCustomer")
     Map<String, Object> insertCustomer(@RequestBody Map map) {
     Map<String, Object> insertCustomer(@RequestBody Map map) {
         Map<String, Object> stringObjectMap = kdYdCustomerService.insertCustomer(map);
         Map<String, Object> stringObjectMap = kdYdCustomerService.insertCustomer(map);

+ 6 - 0
mjava-huagao/src/main/java/com/malk/huagao/controller/KdYdMaterialController.java

@@ -38,4 +38,10 @@ public class KdYdMaterialController {
         Map<String, Object> stringObjectMap = kdYdMaterialService.addkdYdMaterial(map);
         Map<String, Object> stringObjectMap = kdYdMaterialService.addkdYdMaterial(map);
         return stringObjectMap;
         return stringObjectMap;
     }
     }
+
+    @PostMapping("/updatekdYdMaterial")
+    Map<String, Object> updatekdYdMaterial(@RequestBody Map map) {
+        Map<String, Object> stringObjectMap = kdYdMaterialService.updatekdYdMaterial(map);
+        return stringObjectMap;
+    }
 }
 }

+ 20 - 0
mjava-huagao/src/main/java/com/malk/huagao/schedule/YdScheduleTask.java

@@ -37,7 +37,27 @@ private YdHuaGaoService ydHuaGaoService;
     private KdYdCustomerMapper kdYdCustomerMapper;
     private KdYdCustomerMapper kdYdCustomerMapper;
     @Autowired
     @Autowired
     private YDClient ydClient;
     private YDClient ydClient;
+//    @Scheduled(cron = "0 0 1 * * ?")
+    public void synckdYdMaterialxsy() {
+        log.info("定时同步-物料销售员信息");
+        try {
+            MDC.put("MDC_KEY_PID","1003");
+            ydHuaGaoService.synckdYdMaterialxsy();
+        } catch (Exception e) {
+            log.error("【物料销售员信息同步任务】执行过程中发生严重错误", e);
+        }
+    }
 
 
+    @Scheduled(cron = "0 0 9 1 * ?")
+    public void synckdyqsq() {
+        log.info("定时同步-自动创建逾期申请");
+        try {
+            MDC.put("MDC_KEY_PID","1003");
+            ydHuaGaoService.synckdyqsq();
+        } catch (Exception e) {
+            log.error("【自动创建逾期申请同步任务】执行过程中发生严重错误", e);
+        }
+    }
     /*@Scheduled(cron = "0 0/5 * * * ?")
     /*@Scheduled(cron = "0 0/5 * * * ?")
     public void sync() {
     public void sync() {
         log.info("定时同步-客户");
         log.info("定时同步-客户");

+ 2 - 0
mjava-huagao/src/main/java/com/malk/huagao/service/IKdYdMaterialService.java

@@ -18,4 +18,6 @@ public interface IKdYdMaterialService extends IService<KdYdMaterial> {
     void insertkdYdMaterial(Map map);
     void insertkdYdMaterial(Map map);
 
 
     Map<String, Object> addkdYdMaterial(Map map);
     Map<String, Object> addkdYdMaterial(Map map);
+
+    Map<String, Object> updatekdYdMaterial(Map map);
 }
 }

+ 3 - 0
mjava-huagao/src/main/java/com/malk/huagao/service/YdHuaGaoService.java

@@ -26,4 +26,7 @@ public interface YdHuaGaoService {
     void synckdYdTRANSFER();
     void synckdYdTRANSFER();
 
 
 
 
+    void synckdYdMaterialxsy();
+
+    void synckdyqsq();
 }
 }

+ 94 - 30
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdCustomerServiceImpl.java

@@ -212,7 +212,7 @@ public class KdYdCustomerServiceImpl extends ServiceImpl<KdYdCustomerMapper, KdY
                     response = HttpRequest.post(kdHost+"/xk/dyzn/WsBasedyzn.asmx/hgdjydtbcreatecust")
                     response = HttpRequest.post(kdHost+"/xk/dyzn/WsBasedyzn.asmx/hgdjydtbcreatecust")
                             .headerMap(headers, true)
                             .headerMap(headers, true)
                             .form(formParams)
                             .form(formParams)
-                            .timeout(30000)  // 30秒超时
+                            .timeout(60000)  // 60秒超时
                             .execute();
                             .execute();
                 } else {
                 } else {
                     response = HttpRequest.post(kdHost+"/xk/dyzn/WsBasedyzn.asmx/hgdjydtbupdatecust")
                     response = HttpRequest.post(kdHost+"/xk/dyzn/WsBasedyzn.asmx/hgdjydtbupdatecust")
@@ -301,73 +301,137 @@ public class KdYdCustomerServiceImpl extends ServiceImpl<KdYdCustomerMapper, KdY
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        Object result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.operateData(param, formOperation);
-
+                Object result = ydClient.operateData(param, formOperation);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次调用失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_OPERATION:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formOperation,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次, param:{}, FORM_OPERATION:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formOperation);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试睡眠被中断", ie);
+                        throw new RuntimeException("重试过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭操作失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}", JSONObject.toJSONString(param), formOperation,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formOperation, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_OPERATION:{}"+formOperation);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation);
     }
     }
 
 
-
     //自带重试的queryData方法
     //自带重试的queryData方法
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        DDR_New result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.queryData(param, formQuery);
-
+                DDR_New result = ydClient.queryData(param, formQuery);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试查询成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次查询失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试查询", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_QUERY:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formQuery,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次查询, param:{}, FORM_QUERY:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formQuery);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试查询睡眠被中断", ie);
+                        throw new RuntimeException("重试查询过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,查询直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭查询失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_QUERY:{},异常信息:{}", JSONObject.toJSONString(param), formQuery,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("查询操作失败,param:{},FORM_QUERY:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formQuery, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_QUERY:{}"+formQuery);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery);
+    }
+    /**
+     * 判断是否是可重试的错误
+     */
+    private boolean isRetryableError(String errorMsg) {
+        if (errorMsg == null) return false;
+
+        // 可重试的错误关键字列表(扩展了匹配范围)
+        String[] retryableKeywords = {
+                "temporary failure",
+                "未知异常",
+                "timeout",
+                "Timeout",
+                "Connection refused",
+                "Internal Server",
+                "服务不可用",
+                "Service Unavailable",
+                "Gateway Timeout",
+                "Bad Gateway"
+        };
+
+        for (String keyword : retryableKeywords) {
+            if (errorMsg.contains(keyword)) {
+                return true;
+            }
+        }
+        return false;
     }
     }
 
 
 }
 }

+ 221 - 81
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdDeliveryServiceImpl.java

@@ -62,38 +62,62 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
             String formInstId = UtilMap.getString(map, "formInstId");
             String formInstId = UtilMap.getString(map, "formInstId");
             String action = UtilMap.getString(map, "type");
             String action = UtilMap.getString(map, "type");
 
 
+            // 处理特殊操作类型
             // 处理特殊操作类型
             // 处理特殊操作类型
             if ("del".equals(action)) {
             if ("del".equals(action)) {
                 String bm = UtilMap.getString(map, "bm");
                 String bm = UtilMap.getString(map, "bm");
 
 
-                Map<String, String> headers = new HashMap<>();
-                headers.put("Content-Type", "application/x-www-form-urlencoded");
-                Map<String, Object> formParams = new HashMap<>();
-                Map<String, Object> djbh = new HashMap<>();
-                djbh.put("djbh", bm);
-                result.put("data", djbh);
-                String jsonStr = JSON.toJSONString(result);
-                formParams.put("jsons", jsonStr);
-
-                HttpResponse response = HttpRequest.post(kdHost+"/xk/dyzn/WsBasedyzn.asmx/hgdjydtbdeletefhtzd")
-                        .headerMap(headers, true)
-                        .form(formParams)
-                        .timeout(30000)  // 30秒超时
-                        .execute();
-
-                String responseBody = response.body();
-//                System.out.println("responseBody===="+responseBody);
-                log.info("删除返回值responseBody===="+responseBody);
-                // 返回删除操作的格式
+                int maxRetries = 3;
+                boolean success = false;
+                String lastResponse = "";
+
+                for (int i = 0; i < maxRetries; i++) {
+                    Map<String, String> headers = new HashMap<>();
+                    headers.put("Content-Type", "application/x-www-form-urlencoded");
+                    Map<String, Object> formParams = new HashMap<>();
+                    Map<String, Object> requestBody = new HashMap<>();
+                    Map<String, Object> djbh = new HashMap<>();
+                    djbh.put("djbh", bm);
+                    requestBody.put("data", djbh);
+                    String jsonStr = JSON.toJSONString(requestBody);
+                    formParams.put("jsons", jsonStr);
+
+                    HttpResponse response = HttpRequest.post(kdHost + "/xk/dyzn/WsBasedyzn.asmx/hgdjydtbdeletefhtzd")
+                            .headerMap(headers, true)
+                            .form(formParams)
+                            .timeout(30000)
+                            .execute();
+
+                    lastResponse = response.body();
+                    log.info("第{}次删除返回值: {}", i + 1, lastResponse);
+
+                    if (lastResponse != null && lastResponse.contains("\"code\":200")) {
+                        success = true;
+                        break;
+                    }
+
+                    if (i < maxRetries - 1) {
+                        try {
+                            long delay = 2000 + (i * 1000);
+                            log.info("等待 {} 秒后重试", delay / 1000);
+                            Thread.sleep(delay);
+                        } catch (InterruptedException e) {
+                            Thread.currentThread().interrupt();
+                        }
+                    }
+                }
+
                 result.put("table", "KD_YD_DELIVERY");
                 result.put("table", "KD_YD_DELIVERY");
                 result.put("action", "del");
                 result.put("action", "del");
-                result.put("data", new HashMap<String, Object>() {{
-                    put("bm", bm);  // 删除的主键或标识
-                    put("msg", "删除成功");
-                }});
+                Map<String, Object> dataMap = new HashMap<>();
+                dataMap.put("bm", bm);
+                dataMap.put("msg", success ? "删除成功" : "删除失败,已重试" + maxRetries + "次");
+                if (!success) {
+                    dataMap.put("error", lastResponse);
+                }
+                result.put("data", dataMap);
                 return result;
                 return result;
             }
             }
-
             // 查询表单数据
             // 查询表单数据
             DDR_New ddrNew = ydClient.queryData(YDParam.builder()
             DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                     .formInstId(formInstId)
                     .formInstId(formInstId)
@@ -223,24 +247,74 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
             Map<String, Object> formParams = new HashMap<>();
             Map<String, Object> formParams = new HashMap<>();
             formParams.put("jsons", jsonStr);
             formParams.put("jsons", jsonStr);
             log.info("请求参数:" + formParams);
             log.info("请求参数:" + formParams);
-// 发送请求
-            HttpResponse response = null;
-            if ("add".equals(action)) {
-                response = HttpRequest.post(kdHost+"/xk/dyzn/WsBasedyzn.asmx/hgdjydtbcreatefhtzd")
-                        .headerMap(headers, true)
-                        .form(formParams)
-                        .timeout(30000)  // 30秒超时
-                        .execute();
-            } else {
-                response = HttpRequest.post(kdHost+"/xk/dyzn/WsBasedyzn.asmx/")
-                        .headerMap(headers, true)
-                        .form(formParams)
-                        .timeout(30000)  // 30秒超时
-                        .execute();
+// 发送请求(带重试功能)
+            String responseBody = null;
+            int maxRetries = 3;
+            boolean requestSuccess = false;
+
+            for (int retryCount = 0; retryCount < maxRetries; retryCount++) {
+                try {
+                    if (retryCount > 0) {
+                        log.info("第{}次重试新增请求...", retryCount);
+                        Thread.sleep(1500 * retryCount);
+                    }
+
+                    HttpResponse response = null;
+                    if ("add".equals(action)) {
+                        response = HttpRequest.post(kdHost + "/xk/dyzn/WsBasedyzn.asmx/hgdjydtbcreatefhtzd")
+                                .headerMap(headers, true)
+                                .form(formParams)
+                                .timeout(30000)
+                                .execute();
+                    } else {
+                        response = HttpRequest.post(kdHost + "/xk/dyzn/WsBasedyzn.asmx/")
+                                .headerMap(headers, true)
+                                .form(formParams)
+                                .timeout(30000)
+                                .execute();
+                    }
+
+                    responseBody = response.body();
+                    log.info("第{}次请求返回结果:{}", retryCount + 1, responseBody);
+
+                    if (responseBody != null && !responseBody.isEmpty()) {
+                        try {
+                            JSONArray jsonArray = JSONArray.parseArray(responseBody);
+                            if (jsonArray != null && !jsonArray.isEmpty()) {
+                                JSONObject jsonObject = jsonArray.getJSONObject(0);
+                                Integer code = jsonObject.getInteger("code");
+
+                                if (code != null && code == 200) {
+                                    requestSuccess = true;
+                                    log.info("新增发货通知单成功");
+                                    break;
+                                } else {
+                                    log.warn("请求返回错误码:{},第{}次尝试失败,将进行重试", code, retryCount + 1);
+                                }
+                            }
+                        } catch (Exception parseException) {
+                            log.error("解析返回结果异常:{}", parseException.getMessage());
+                            if (retryCount == maxRetries - 1) {
+                                throw new RuntimeException("解析返回结果失败", parseException);
+                            }
+                        }
+                    } else {
+                        log.warn("返回响应为空,第{}次尝试失败", retryCount + 1);
+                    }
+
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                    log.error("重试被中断", e);
+                    break;
+                } catch (Exception e) {
+                    log.error("请求异常,第{}次尝试失败:{}", retryCount + 1, e.getMessage());
+                    if (retryCount == maxRetries - 1) {
+                        throw new RuntimeException("新增请求失败,已重试" + maxRetries + "次", e);
+                    }
+                }
             }
             }
 
 
-            String responseBody = response.body();
-            log.info("返回结果responseBody:" + responseBody);
+
             try {
             try {
 
 
                 String msg = JSON.parseArray(responseBody)
                 String msg = JSON.parseArray(responseBody)
@@ -362,6 +436,8 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
             // 3. 添加处理后的子表数据
             // 3. 添加处理后的子表数据
             updateMap.put("tableField_mejnamfd", newSubTable);
             updateMap.put("tableField_mejnamfd", newSubTable);
             String sqrid = sqr.substring(2, sqr.length() - 2);
             String sqrid = sqr.substring(2, sqr.length() - 2);
+            String xszgid = xszg.substring(2, xszg.length() - 2);
+            String finalId = (sqrid == null || sqrid.trim().isEmpty()) ? xszgid : sqrid;
             System.out.println("sqrid==" + sqrid);
             System.out.println("sqrid==" + sqrid);
             // 创建新表单实例
             // 创建新表单实例
             try {
             try {
@@ -369,7 +445,7 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
                         YDParam.builder()
                         YDParam.builder()
                                 .formUuid("FORM-FAE2575E112644ED914CAB4FEC9309F32AVR")
                                 .formUuid("FORM-FAE2575E112644ED914CAB4FEC9309F32AVR")
                                 .formDataJson(JSON.toJSONString(updateMap))
                                 .formDataJson(JSON.toJSONString(updateMap))
-                                .userId(sqrid)
+                                .userId(finalId)
                                 .build(),
                                 .build(),
                         YDConf.FORM_OPERATION.create
                         YDConf.FORM_OPERATION.create
                 );
                 );
@@ -378,7 +454,7 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
                 log.error("创建新单据失败,dz=" + dz, e);
                 log.error("创建新单据失败,dz=" + dz, e);
             }
             }
             try {
             try {
-                Thread.sleep(2000);
+                Thread.sleep(3000);
             } catch (InterruptedException e) {
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
                 Thread.currentThread().interrupt();
                 log.error("线程被中断", e);
                 log.error("线程被中断", e);
@@ -440,98 +516,162 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
 
 
     public static BigDecimal toBigDecimal(String str) {
     public static BigDecimal toBigDecimal(String str) {
         if (str == null || str.trim().isEmpty()) {
         if (str == null || str.trim().isEmpty()) {
-            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+            return BigDecimal.ZERO.setScale(6, RoundingMode.HALF_UP);
         }
         }
         try {
         try {
             return new BigDecimal(str.trim())
             return new BigDecimal(str.trim())
-                    .setScale(2, RoundingMode.HALF_UP);
+                    .setScale(6, RoundingMode.HALF_UP);
         } catch (NumberFormatException e) {
         } catch (NumberFormatException e) {
             // 返回默认值而不是抛出异常,避免程序中断
             // 返回默认值而不是抛出异常,避免程序中断
-            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+            return BigDecimal.ZERO.setScale(6, RoundingMode.HALF_UP);
         }
         }
     }
     }
 
 
     /**
     /**
      * 重载方法,支持Number类型输入
      * 重载方法,支持Number类型输入
      */
      */
-    public static BigDecimal toBigDecimal(Number number) {
-        if (number == null) {
-            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
-        }
-        return new BigDecimal(number.toString())
-                .setScale(2, RoundingMode.HALF_UP);
-    }
+//    public static BigDecimal toBigDecimal(Number number) {
+//        if (number == null) {
+//            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+//        }
+//        return new BigDecimal(number.toString())
+//                .setScale(2, RoundingMode.HALF_UP);
+//    }
 
 
     //自带重试的operateData方法
     //自带重试的operateData方法
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        Object result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.operateData(param, formOperation);
-
+                Object result = ydClient.operateData(param, formOperation);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次调用失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_OPERATION:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formOperation,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次, param:{}, FORM_OPERATION:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formOperation);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试睡眠被中断", ie);
+                        throw new RuntimeException("重试过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭操作失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}", JSONObject.toJSONString(param), formOperation,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formOperation, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_OPERATION:{}"+formOperation);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation);
     }
     }
 
 
-
     //自带重试的queryData方法
     //自带重试的queryData方法
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        DDR_New result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.queryData(param, formQuery);
-
+                DDR_New result = ydClient.queryData(param, formQuery);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试查询成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次查询失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试查询", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_QUERY:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formQuery,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次查询, param:{}, FORM_QUERY:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formQuery);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试查询睡眠被中断", ie);
+                        throw new RuntimeException("重试查询过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,查询直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭查询失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_QUERY:{},异常信息:{}", JSONObject.toJSONString(param), formQuery,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("查询操作失败,param:{},FORM_QUERY:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formQuery, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_QUERY:{}"+formQuery);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery);
+    }
+    /**
+     * 判断是否是可重试的错误
+     */
+    private boolean isRetryableError(String errorMsg) {
+        if (errorMsg == null) return false;
+
+        // 可重试的错误关键字列表(扩展了匹配范围)
+        String[] retryableKeywords = {
+                "temporary failure",
+                "未知异常",
+                "timeout",
+                "Timeout",
+                "Connection refused",
+                "Internal Server",
+                "服务不可用",
+                "Service Unavailable",
+                "Gateway Timeout",
+                "Bad Gateway"
+        };
+
+        for (String keyword : retryableKeywords) {
+            if (errorMsg.contains(keyword)) {
+                return true;
+            }
+        }
+        return false;
     }
     }
 }
 }

+ 197 - 29
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdMaterialServiceImpl.java

@@ -1,5 +1,8 @@
 package com.malk.huagao.service.impl;
 package com.malk.huagao.service.impl;
 
 
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.malk.huagao.entity.KdYdCustomer;
 import com.malk.huagao.entity.KdYdCustomer;
@@ -17,10 +20,14 @@ import com.malk.utils.UtilMap;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.math.RoundingMode;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 
 
 /**
 /**
@@ -38,6 +45,8 @@ public class KdYdMaterialServiceImpl extends ServiceImpl<KdYdMaterialMapper, KdY
     private YDClient ydClient;
     private YDClient ydClient;
     @Autowired
     @Autowired
     private KdYdMaterialMapper kdYdMaterialMapper;
     private KdYdMaterialMapper kdYdMaterialMapper;
+    @Value(value = "${kd.host}")
+    private String kdHost;
     @Override
     @Override
     public void insertkdYdMaterial(Map map) {
     public void insertkdYdMaterial(Map map) {
         MDC.put("MDC_KEY_PID", "1003");
         MDC.put("MDC_KEY_PID", "1003");
@@ -355,6 +364,100 @@ public class KdYdMaterialServiceImpl extends ServiceImpl<KdYdMaterialMapper, KdY
         }
         }
     }
     }
 
 
+    @Override
+    public Map<String, Object> updatekdYdMaterial(Map map) {
+        MDC.put("MDC_KEY_PID", "1003");
+        Map<String, Object> result = new HashMap<>();
+
+        try {
+            // 1. 参数提取
+            String jdnm = UtilMap.getString(map, "jdnm");
+            String xsy = UtilMap.getString(map, "xsy");
+            String kssj = UtilMap.getString(map, "kssj");
+            String jssj = UtilMap.getString(map, "jssj");
+
+            // 2. 时间戳转年月日格式
+            String kssjFormatted = formatTimestamp(kssj);
+            String jssjFormatted = formatTimestamp(jssj);
+
+            // 3. 参数非空校验
+            if (isAnyBlank(jdnm, xsy, kssj, jssj)) {
+                result.put("code", 400);
+                result.put("message", "参数不能为空:jdnm、xsy、kssj、jssj 均为必填");
+                return result;
+            }
+
+            // 4. 参数 URL 编码(防止中文/特殊字符乱码)
+            String encodedJdnm = URLEncoder.encode(jdnm, "UTF-8");
+            String encodedXsy = URLEncoder.encode(xsy, "UTF-8");
+            String encodedKssj = URLEncoder.encode(kssjFormatted, "UTF-8");
+            String encodedJssj = URLEncoder.encode(jssjFormatted, "UTF-8");
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", "application/x-www-form-urlencoded");
+            // 5. 构建完整 URL(参数用 & 连接)
+            String url = kdHost + "/xk/dyzn/WsBasedyzn.asmx/Hggxwlxx?" +
+                    "FMATERIALID=" + encodedJdnm +
+                    "&F_HGSALE=" + encodedXsy +
+                    "&FSSXSYKSRQ=" + encodedKssj +
+                    "&F_HGSALEENDDATE=" + encodedJssj;
+            log.info("物料请求URL: {}", url);
+            // 6. 发送 GET 请求
+            HttpResponse response = HttpRequest.get(url)
+                    .timeout(30000)
+                    .execute();
+            System.out.println("response"+response);
+            // 7. 处理响应
+            String responseBody = response.body();
+            System.out.println("responseBody"+responseBody);
+            int statusCode = response.getStatus();
+
+            log.info("更新扣点物料响应状态: {}, 响应内容: {}", statusCode, responseBody);
+
+
+            return result;
+
+        } catch (UnsupportedEncodingException e) {
+            result.put("code", 500);
+            result.put("message", "参数编码异常:" + e.getMessage());
+            return result;
+        } catch (Exception e) {
+            result.put("code", 500);
+            result.put("message", "系统异常:" + e.getMessage());
+            return result;
+        } finally {
+            MDC.remove("MDC_KEY_PID");
+        }
+    }
+    // 格式化方法
+    private String formatTimestamp(String timestamp) {
+        if (timestamp == null || timestamp.isEmpty()) {
+            return "";
+        }
+        try {
+            long time = Long.parseLong(timestamp);
+            // 判断是秒级(10位)还是毫秒级(13位)
+            if (timestamp.length() == 10) {
+                time = time * 1000; // 秒级转毫秒级
+            }
+            Date date = new Date(time);
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            return sdf.format(date);
+        } catch (NumberFormatException e) {
+            log.error("时间戳格式错误: {}", timestamp, e);
+            return timestamp; // 转换失败返回原值
+        }
+    }
+    /**
+     * 判断是否有任意参数为空
+     */
+    private boolean isAnyBlank(String... strs) {
+        for (String str : strs) {
+            if (str == null || str.trim().isEmpty()) {
+                return true;
+            }
+        }
+        return false;
+    }
     // 辅助方法:安全获取字符串值
     // 辅助方法:安全获取字符串值
     private String safeGetStringValue(Map map, String key) {
     private String safeGetStringValue(Map map, String key) {
         if (map == null) return "";
         if (map == null) return "";
@@ -401,75 +504,140 @@ public class KdYdMaterialServiceImpl extends ServiceImpl<KdYdMaterialMapper, KdY
                 .setScale(2, RoundingMode.HALF_UP);
                 .setScale(2, RoundingMode.HALF_UP);
     }
     }
     //自带重试的operateData方法
     //自带重试的operateData方法
+    //自带重试的operateData方法
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        Object result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.operateData(param, formOperation);
-
+                Object result = ydClient.operateData(param, formOperation);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次调用失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_OPERATION:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formOperation,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次, param:{}, FORM_OPERATION:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formOperation);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试睡眠被中断", ie);
+                        throw new RuntimeException("重试过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭操作失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}", JSONObject.toJSONString(param), formOperation,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formOperation, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_OPERATION:{}"+formOperation);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation);
     }
     }
 
 
-
     //自带重试的queryData方法
     //自带重试的queryData方法
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        DDR_New result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.queryData(param, formQuery);
-
+                DDR_New result = ydClient.queryData(param, formQuery);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试查询成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次查询失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试查询", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_QUERY:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formQuery,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次查询, param:{}, FORM_QUERY:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formQuery);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试查询睡眠被中断", ie);
+                        throw new RuntimeException("重试查询过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,查询直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭查询失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_QUERY:{},异常信息:{}", JSONObject.toJSONString(param), formQuery,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("查询操作失败,param:{},FORM_QUERY:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formQuery, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_QUERY:{}"+formQuery);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery);
+    }
+    /**
+     * 判断是否是可重试的错误
+     */
+    private boolean isRetryableError(String errorMsg) {
+        if (errorMsg == null) return false;
+
+        // 可重试的错误关键字列表(扩展了匹配范围)
+        String[] retryableKeywords = {
+                "temporary failure",
+                "未知异常",
+                "timeout",
+                "Timeout",
+                "Connection refused",
+                "Internal Server",
+                "服务不可用",
+                "Service Unavailable",
+                "Gateway Timeout",
+                "Bad Gateway"
+        };
+
+        for (String keyword : retryableKeywords) {
+            if (errorMsg.contains(keyword)) {
+                return true;
+            }
+        }
+        return false;
     }
     }
 }
 }

+ 110 - 42
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdOrderServiceImpl.java

@@ -125,7 +125,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
                 String code = JSON.parseArray(responseBody)
                 String code = JSON.parseArray(responseBody)
                         .getJSONObject(0)
                         .getJSONObject(0)
                         .getString("code");
                         .getString("code");
-                retryOperateData(
+                ydClient.operateData(
                         YDParam.builder()
                         YDParam.builder()
                                 .formInstanceId(formInstId)
                                 .formInstanceId(formInstId)
                                 .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_ml08nk3y, textareaField_mkxqgrvq", code, msg)))
                                 .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_ml08nk3y, textareaField_mkxqgrvq", code, msg)))
@@ -205,6 +205,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
                     String wlbm = safeGetString(item, "textField_mfbx1pqt");
                     String wlbm = safeGetString(item, "textField_mfbx1pqt");
 //                    String wlbm = "010101010003";
 //                    String wlbm = "010101010003";
                     String wlmc = safeGetString(item, "textField_mfbx1pqs");
                     String wlmc = safeGetString(item, "textField_mfbx1pqs");
+//                    String kzfh = safeGetString1(item, "radioField_mqyje8pg");
                     String sku = safeGetString(item, "textField_mqg2b2g6");
                     String sku = safeGetString(item, "textField_mqg2b2g6");
                     String tcfpfs = safeGetString(item, "textField_mpqmsz2q");
                     String tcfpfs = safeGetString(item, "textField_mpqmsz2q");
                     String yjfpfs = safeGetString(item, "textField_mpqmsz2r");
                     String yjfpfs = safeGetString(item, "textField_mpqmsz2r");
@@ -234,6 +235,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
                     table1Map.put("detailId", detailId);
                     table1Map.put("detailId", detailId);
                     table1Map.put("wlbm", wlbm);
                     table1Map.put("wlbm", wlbm);
                     table1Map.put("sku", sku);
                     table1Map.put("sku", sku);
+//                    table1Map.put("kzfh", kzfh);
                     table1Map.put("wlmc", wlmc);
                     table1Map.put("wlmc", wlmc);
                     table1Map.put("ggxh", ggxh);
                     table1Map.put("ggxh", ggxh);
                     table1Map.put("xsdw", xsdw);
                     table1Map.put("xsdw", xsdw);
@@ -774,17 +776,20 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
         Object val = formData.get(key);
         Object val = formData.get(key);
         return val == null ? "" : String.valueOf(val);
         return val == null ? "" : String.valueOf(val);
     }
     }
-
+    private String safeGetString1(Map formData, String key) {
+        Object val = formData.get(key);
+        return val == null ? "否" : String.valueOf(val);
+    }
     public static BigDecimal toBigDecimal(String str) {
     public static BigDecimal toBigDecimal(String str) {
         if (str == null || str.trim().isEmpty()) {
         if (str == null || str.trim().isEmpty()) {
-            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+            return BigDecimal.ZERO.setScale(6, RoundingMode.HALF_UP);
         }
         }
         try {
         try {
             return new BigDecimal(str.trim())
             return new BigDecimal(str.trim())
-                    .setScale(2, RoundingMode.HALF_UP);
+                    .setScale(6, RoundingMode.HALF_UP);
         } catch (NumberFormatException e) {
         } catch (NumberFormatException e) {
             // 返回默认值而不是抛出异常,避免程序中断
             // 返回默认值而不是抛出异常,避免程序中断
-            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+            return BigDecimal.ZERO.setScale(6, RoundingMode.HALF_UP);
         }
         }
     }
     }
     public static BigDecimal toBigDecimal1(String str) {
     public static BigDecimal toBigDecimal1(String str) {
@@ -802,84 +807,147 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
     /**
     /**
      * 重载方法,支持Number类型输入
      * 重载方法,支持Number类型输入
      */
      */
-    public static BigDecimal toBigDecimal(Number number) {
-        if (number == null) {
-            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
-        }
-        return new BigDecimal(number.toString())
-                .setScale(2, RoundingMode.HALF_UP);
-    }
+//    public static BigDecimal toBigDecimal(Number number) {
+//        if (number == null) {
+//            return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+//        }
+//        return new BigDecimal(number.toString())
+//                .setScale(2, RoundingMode.HALF_UP);
+//    }
 
 
-    //自带重试的operateData方法
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
     private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        Object result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.operateData(param, formOperation);
-
+                Object result = ydClient.operateData(param, formOperation);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次调用失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_OPERATION:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formOperation,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次, param:{}, FORM_OPERATION:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formOperation);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试睡眠被中断", ie);
+                        throw new RuntimeException("重试过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭操作失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}", JSONObject.toJSONString(param), formOperation,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formOperation, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_OPERATION:{}"+formOperation);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation);
     }
     }
 
 
-
     //自带重试的queryData方法
     //自带重试的queryData方法
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
     private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
         int maxAttempts = 3; // 尝试的最大次数
         int maxAttempts = 3; // 尝试的最大次数
         int attempt = 0;
         int attempt = 0;
-
-        DDR_New result = null;
+        long baseWaitTime = 3000; // 基础等待时间3秒
 
 
         while (attempt < maxAttempts) {
         while (attempt < maxAttempts) {
             try {
             try {
-                result = ydClient.queryData(param, formQuery);
-
+                DDR_New result = ydClient.queryData(param, formQuery);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试查询成功", attempt + 1);
+                }
                 return result;
                 return result;
             } catch (McException e) {
             } catch (McException e) {
-                log.info("错误信息:{}",e.getMessage());
-                if (e.getMessage().equals("The request has failed due to a temporary failure of the server.")) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次查询失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
                     attempt++;
                     attempt++;
-                    // 线程睡眠3秒
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试查询", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
                     try {
                     try {
-                        Thread.sleep(5000);
-                        log.info("尝试第{}次,param:{},FORM_QUERY:{},异常信息:{}", attempt, JSONObject.toJSONString(param), formQuery,e.getMessage());
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次查询, param:{}, FORM_QUERY:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formQuery);
+                        Thread.sleep(waitTime);
                     } catch (InterruptedException ie) {
                     } catch (InterruptedException ie) {
                         Thread.currentThread().interrupt(); // 重新设置中断状态
                         Thread.currentThread().interrupt(); // 重新设置中断状态
-                        System.err.println("Sleep interrupted: " + ie.getMessage());
+                        log.error("重试查询睡眠被中断", ie);
+                        throw new RuntimeException("重试查询过程被中断", ie);
                     }
                     }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,查询直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭查询失败: " + errorMsg, e);
                 }
                 }
             } catch (Exception e) {
             } catch (Exception e) {
-                log.error("操作失败,param:{},FORM_QUERY:{},异常信息:{}", JSONObject.toJSONString(param), formQuery,e.getMessage());
-
+                // 非McException异常,直接抛出,不重试
+                log.error("查询操作失败,param:{},FORM_QUERY:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formQuery, e.getMessage());
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
-
         }
         }
 
 
-        throw new RuntimeException("超出最大重试次数,param:"+JSONObject.toJSONString(param)+",FORM_QUERY:{}"+formQuery);
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery);
+    }
+    /**
+     * 判断是否是可重试的错误
+     */
+    private boolean isRetryableError(String errorMsg) {
+        if (errorMsg == null) return false;
+
+        // 可重试的错误关键字列表(扩展了匹配范围)
+        String[] retryableKeywords = {
+                "temporary failure",
+                "未知异常",
+                "timeout",
+                "Timeout",
+                "Connection refused",
+                "Internal Server",
+                "服务不可用",
+                "Service Unavailable",
+                "Gateway Timeout",
+                "Bad Gateway"
+        };
+
+        for (String keyword : retryableKeywords) {
+            if (errorMsg.contains(keyword)) {
+                return true;
+            }
+        }
+        return false;
     }
     }
 }
 }

+ 6 - 1
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdReceivableServiceImpl.java

@@ -150,7 +150,7 @@ public class KdYdReceivableServiceImpl extends ServiceImpl<KdYdReceivableMapper,
 
 
 
 
     @Override
     @Override
-    public Map<String, Object> insertkdYdReceivable1(Map json) {
+    public Map<String, Object>   insertkdYdReceivable1(Map json) {
         HashMap<String, Object> result = new HashMap<>();
         HashMap<String, Object> result = new HashMap<>();
 
 
         try {
         try {
@@ -299,7 +299,9 @@ public class KdYdReceivableServiceImpl extends ServiceImpl<KdYdReceivableMapper,
                             Object endTimeObj = paymentItem.get("endTime");
                             Object endTimeObj = paymentItem.get("endTime");
                             tablemap1.put("dateField_mhiui6v9", safeConvertDateTimeToString(endTimeObj));
                             tablemap1.put("dateField_mhiui6v9", safeConvertDateTimeToString(endTimeObj));
                             tablemap1.put("textField_mhiui6va", String.valueOf(paymentItem.get("xsddh")));
                             tablemap1.put("textField_mhiui6va", String.valueOf(paymentItem.get("xsddh")));
+                            tablemap1.put("textField_mqt5s81f", String.valueOf(paymentItem.get("uuid")));
                             tablemap1.put("numberField_mhiui6v8", safeFormatBigDecimal(paymentItem.get("ysje")));
                             tablemap1.put("numberField_mhiui6v8", safeFormatBigDecimal(paymentItem.get("ysje")));
+                            tablemap1.put("numberField_mrczs2dk", safeFormatBigDecimal(paymentItem.get("wsje")));
                             tablemap1.put("numberField_mhiui6v6", safeFormatBigDecimal(paymentItem.get("ysbl")));
                             tablemap1.put("numberField_mhiui6v6", safeFormatBigDecimal(paymentItem.get("ysbl")));
                             tablemap1.put("numberField_mhiui6vb", safeFormatBigDecimal(paymentItem.get("ysjebwb")));
                             tablemap1.put("numberField_mhiui6vb", safeFormatBigDecimal(paymentItem.get("ysjebwb")));
                             tablemap1.put("numberField_mhjy9hzj", safeFormatBigDecimal(paymentItem.get("stkdglje")));
                             tablemap1.put("numberField_mhjy9hzj", safeFormatBigDecimal(paymentItem.get("stkdglje")));
@@ -378,6 +380,7 @@ public class KdYdReceivableServiceImpl extends ServiceImpl<KdYdReceivableMapper,
                     Object operationResult = ydClient.operateData(YDParam.builder()
                     Object operationResult = ydClient.operateData(YDParam.builder()
                             .formUuid("FORM-4E1CE4550339494A9BE5498FB119FF2E9ERU")
                             .formUuid("FORM-4E1CE4550339494A9BE5498FB119FF2E9ERU")
                             .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mg3a0tgs", djbh)))
                             .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mg3a0tgs", djbh)))
+                            .noExecuteExpression(false)
                             .formDataJson(JSONObject.toJSONString(updateData))
                             .formDataJson(JSONObject.toJSONString(updateData))
                             .build(), YDConf.FORM_OPERATION.upsert
                             .build(), YDConf.FORM_OPERATION.upsert
                     );
                     );
@@ -609,6 +612,7 @@ public class KdYdReceivableServiceImpl extends ServiceImpl<KdYdReceivableMapper,
                     updateMap.put("textField_mh9woamt", djbh);
                     updateMap.put("textField_mh9woamt", djbh);
                     updateMap.put("textField_mh9woamz", String.valueOf(paymentItem.get("skgld")));
                     updateMap.put("textField_mh9woamz", String.valueOf(paymentItem.get("skgld")));
                     updateMap.put("textField_mh9woano", String.valueOf(paymentItem.get("bb")));
                     updateMap.put("textField_mh9woano", String.valueOf(paymentItem.get("bb")));
+                    updateMap.put("textField_mqt5wtda", xsddbh);
 
 
                     // 处理日期字段
                     // 处理日期字段
                     Object ywrqObj = paymentItem.get("ywrq");
                     Object ywrqObj = paymentItem.get("ywrq");
@@ -628,6 +632,7 @@ public class KdYdReceivableServiceImpl extends ServiceImpl<KdYdReceivableMapper,
                             .formUuid("FORM-0569C06E47074C2981ADEEAFCE083EDAK5AM")
                             .formUuid("FORM-0569C06E47074C2981ADEEAFCE083EDAK5AM")
                             .appType("APP_VQDMMWS6OR1VHL8VMFD3")
                             .appType("APP_VQDMMWS6OR1VHL8VMFD3")
                             .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
                             .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
+                            .noExecuteExpression(false)
                             .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mh9woamt", djbh)))
                             .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mh9woamt", djbh)))
                             .formDataJson(JSONObject.toJSONString(updateMap))
                             .formDataJson(JSONObject.toJSONString(updateMap))
                             .build(), YDConf.FORM_OPERATION.upsert);
                             .build(), YDConf.FORM_OPERATION.upsert);

+ 1 - 0
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdTransferServiceImpl.java

@@ -279,6 +279,7 @@ public class KdYdTransferServiceImpl extends ServiceImpl<KdYdTransferMapper, KdY
                         HashMap<String, String> tablemap = new HashMap<>();
                         HashMap<String, String> tablemap = new HashMap<>();
                         tablemap.put("textField_mhubzsav", String.valueOf(detailItem.get("wlbm")));
                         tablemap.put("textField_mhubzsav", String.valueOf(detailItem.get("wlbm")));
                         tablemap.put("textField_mhubzsaw", String.valueOf(detailItem.get("wlmc")));
                         tablemap.put("textField_mhubzsaw", String.valueOf(detailItem.get("wlmc")));
+                        tablemap.put("textField_mqudgs70", String.valueOf(detailItem.get("jx")));
                         tablemap.put("textField_mhubzsax", String.valueOf(detailItem.get("ggxh")));
                         tablemap.put("textField_mhubzsax", String.valueOf(detailItem.get("ggxh")));
                         tablemap.put("textField_mhubzsay", String.valueOf(detailItem.get("dw")));
                         tablemap.put("textField_mhubzsay", String.valueOf(detailItem.get("dw")));
                         tablemap.put("textareaField_mjshnw4c", String.valueOf(detailItem.get("kddh")));
                         tablemap.put("textareaField_mjshnw4c", String.valueOf(detailItem.get("kddh")));

+ 282 - 0
mjava-huagao/src/main/java/com/malk/huagao/service/impl/YdHuaGaoServiceImpl.java

@@ -2,6 +2,7 @@ package com.malk.huagao.service.impl;
 
 
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.malk.huagao.entity.*;
 import com.malk.huagao.entity.*;
@@ -10,11 +11,15 @@ import com.malk.huagao.service.YdHuaGaoService;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDParam;
 import com.malk.server.aliwork.YDParam;
 import com.malk.server.aliwork.YDSearch;
 import com.malk.server.aliwork.YDSearch;
+import com.malk.server.common.McException;
 import com.malk.server.common.McR;
 import com.malk.server.common.McR;
 import com.malk.server.dingtalk.DDConf;
 import com.malk.server.dingtalk.DDConf;
+import com.malk.server.dingtalk.DDR_New;
 import com.malk.service.aliwork.YDClient;
 import com.malk.service.aliwork.YDClient;
+import com.malk.service.aliwork.YDService;
 import com.malk.utils.UtilMap;
 import com.malk.utils.UtilMap;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.slf4j.MDC;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -34,6 +39,8 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
     @Autowired
     @Autowired
     private YDClient ydClient;
     private YDClient ydClient;
     @Autowired
     @Autowired
+    private YDService ydService;
+    @Autowired
     private KdYdCustomerReferrerMapper kdYdCustomerReferrerMapper;
     private KdYdCustomerReferrerMapper kdYdCustomerReferrerMapper;
     @Autowired
     @Autowired
     private KdYdOrderMapper kdYdOrderMapper;
     private KdYdOrderMapper kdYdOrderMapper;
@@ -1632,6 +1639,281 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                 successCount, failCount, kdYdTRANSFERdels.size());
                 successCount, failCount, kdYdTRANSFERdels.size());
     }
     }
 
 
+    @Override
+    public void synckdYdMaterialxsy() {
+        MDC.put("MDC_KEY_PID", "1003");
+        //当前时间戳
+        long time = System.currentTimeMillis();
+        List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-E64114E9F2C9426E91F92886EDFFA2C08Q90").searchFieldJson(
+                JSONObject.toJSONString(Arrays.asList(
+                        new YDSearch("dateField_ml4ikfa1",
+                                time,
+                                "DateField",
+                                YDSearch.Type.DATE_FIELD,
+                                YDSearch.Operator.LT)
+//                        new YDSearch("textField_misfb2ft",
+//                                "137804",
+//                                "TextField",
+//                                YDSearch.Type.TEXT_FIELD,
+//                                YDSearch.Operator.EQ)
+                ))
+        ).build());
+
+        if (list == null || list.isEmpty()) {
+            log.info("没有找到需要处理的单据");
+        }
+        for (Map item : list) {
+            String formInstanceId = String.valueOf(item.get("formInstanceId"));
+            Map formData =new HashMap<>();
+            formData.put("textField_mfxbtce5", "无");
+            formData.put("dateField_ml4ikfa1", "4073040000000");
+            retryOperateData(YDParam.builder()
+                    .formInstId(formInstanceId)
+                    .updateFormDataJson(JSON.toJSONString(formData))
+                    .build(), YDConf.FORM_OPERATION.update);
+        }
+        log.info("【物料同步任务】完成: 总计={}", list.size());
+    }
+
+    @Override
+    public void synckdyqsq() {
+        MDC.put("MDC_KEY_PID", "1003");
+        //当前时间戳
+        long time = System.currentTimeMillis();
+        List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-29C510B098584EDAA303D7252082D447YGUS").searchFieldJson(
+                JSONObject.toJSONString(Arrays.asList(
+                        new YDSearch("dateField_meqpbxsj",
+                                time,
+                                "DateField",
+                                YDSearch.Type.DATE_FIELD,
+                                YDSearch.Operator.LT),
+                        new YDSearch("radioField_meqpbxsi",
+                                "否",
+                                "RadioField",
+                                YDSearch.Type.RADIO_FIELD,
+                                YDSearch.Operator.EQ),
+                        new YDSearch("selectField_mewmhnwj",
+                                "已逾期",
+                                "SelectField",
+                                YDSearch.Type.RADIO_FIELD,
+                                YDSearch.Operator.EQ)
+                ))
+        ).build());
+
+        if (list == null || list.isEmpty()) {
+            log.info("没有找到需要处理的单据");
+        }
+        log.info("共查询到 {} 条待处理单据", list.size());
+        for (Map item : list) {
+
+            String glbdjson = String.valueOf(item.get("associationFormField_me2kiw8j_id"));
+            String sqr = String.valueOf(item.get("employeeField_mdya1lol_id"));
+            String formInstanceId = String.valueOf(item.get("formInstanceId"));
+//            String xsy = String.valueOf(item.get("employeeField_mejnamf3_id"));
+            String xszg = String.valueOf(item.get("employeeField_mmsna3tn_id"));
+            String zssj = String.valueOf(item.get("employeeField_mmsna3tm_id"));
+            String yjlcbh = String.valueOf(item.get("serialNumberField_mdya1lon"));
+//            String fhtzd = String.valueOf(item.get("serialNumberField_mheazm7w"));
+
+            // 解析关联字段 JSON
+            List<Map> sealjsonlist = parseJsonList(glbdjson);
+            HashMap<String, Object> updateMap = new HashMap<>();
+            for (Object obj : item.entrySet()) {
+                Map.Entry<String, Object> formEntry = (Map.Entry<String, Object>) obj;
+                String key = formEntry.getKey();
+                Object value = formEntry.getValue();
+
+                // 跳过需要特殊处理的主表关联字段
+                if (key.equals("associationFormField_me2kiw8j_id") ||
+                        key.equals("employeeField_mdya1lol_id") ||
+                        key.equals("employeeField_mmsna3tn_id") ||
+                        key.equals("employeeField_mmsna3tm_id") ) {
+                    continue;
+                }
+
+                // 复制其他字段
+                updateMap.put(key, value);
+            }
+
+            // 2. 添加需要特殊处理的主表字段
+            updateMap.put("associationFormField_me2kiw8j", sealjsonlist);
+            updateMap.put("employeeField_mdya1lol", sqr);
+            updateMap.put("employeeField_mmsna3tn", xszg);
+            updateMap.put("employeeField_mmsna3tm", zssj);
+            updateMap.put("textField_mr1e0bpc", yjlcbh);
+            // 3. 添加处理后的子表数据
+            String sqrid = sqr.substring(2, sqr.length() - 2);
+            String xszgid = xszg.substring(2, xszg.length() - 2);
+            String finalId = (sqrid == null || sqrid.trim().isEmpty()) ? xszgid : sqrid;
+            retryOperateData(
+                    YDParam.builder()
+                            .formUuid("FORM-54F26858BF574AF0838AEF4086C35FD5VDXJ")
+                            .processCode("TPROC--1VF66Z61YYX6RD04NCTOPAF5EFMD2DKJV8UQM2")
+                            .formDataJson(JSON.toJSONString(updateMap))
+                            .userId(finalId)
+                            .build(),
+                    YDConf.FORM_OPERATION.start
+            );
+            Map formData =new HashMap<>();
+            formData.put("selectField_mewmhnwj", "已申请逾期扣款");
+            retryOperateData(YDParam.builder()
+                    .formInstId(formInstanceId)
+                    .updateFormDataJson(JSON.toJSONString(formData))
+                    .build(), YDConf.FORM_OPERATION.update);
+        }
+    }
+    private Object retryOperateData(YDParam param, YDConf.FORM_OPERATION formOperation) {
+        int maxAttempts = 3; // 尝试的最大次数
+        int attempt = 0;
+        long baseWaitTime = 3000; // 基础等待时间3秒
+
+        while (attempt < maxAttempts) {
+            try {
+                Object result = ydClient.operateData(param, formOperation);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试成功", attempt + 1);
+                }
+                return result;
+            } catch (McException e) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次调用失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
+                    attempt++;
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
+                    try {
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次, param:{}, FORM_OPERATION:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formOperation);
+                        Thread.sleep(waitTime);
+                    } catch (InterruptedException ie) {
+                        Thread.currentThread().interrupt(); // 重新设置中断状态
+                        log.error("重试睡眠被中断", ie);
+                        throw new RuntimeException("重试过程被中断", ie);
+                    }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭操作失败: " + errorMsg, e);
+                }
+            } catch (Exception e) {
+                // 非McException异常,直接抛出,不重试
+                log.error("操作失败,param:{},FORM_OPERATION:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formOperation, e.getMessage());
+                throw new RuntimeException(e);
+            }
+        }
+
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_OPERATION:" + formOperation);
+    }
+
+    //自带重试的queryData方法
+    private DDR_New retryQueryData(YDParam param, YDConf.FORM_QUERY formQuery) {
+        int maxAttempts = 3; // 尝试的最大次数
+        int attempt = 0;
+        long baseWaitTime = 3000; // 基础等待时间3秒
+
+        while (attempt < maxAttempts) {
+            try {
+                DDR_New result = ydClient.queryData(param, formQuery);
+                // 成功调用后,如果有之前失败的重试日志,记录成功
+                if (attempt > 0) {
+                    log.info("第{}次重试查询成功", attempt + 1);
+                }
+                return result;
+            } catch (McException e) {
+                String errorMsg = e.getMessage();
+                log.warn("第{}次查询失败,错误信息:{}", attempt + 1, errorMsg);
+
+                // 判断是否是可重试的异常
+                if (isRetryableError(errorMsg)) {
+                    attempt++;
+                    // 如果已达到最大尝试次数,不再重试,直接抛出异常
+                    if (attempt >= maxAttempts) {
+                        log.error("已达最大重试次数{}次,放弃重试查询", maxAttempts);
+                        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery, e);
+                    }
+
+                    // 线程睡眠,使用指数退避策略
+                    try {
+                        long waitTime = baseWaitTime * (long) Math.pow(2, attempt - 1);
+                        log.info("等待{}ms后重试第{}次查询, param:{}, FORM_QUERY:{}",
+                                waitTime, attempt + 1, JSONObject.toJSONString(param), formQuery);
+                        Thread.sleep(waitTime);
+                    } catch (InterruptedException ie) {
+                        Thread.currentThread().interrupt(); // 重新设置中断状态
+                        log.error("重试查询睡眠被中断", ie);
+                        throw new RuntimeException("重试查询过程被中断", ie);
+                    }
+                } else {
+                    // 不可重试的异常,直接抛出
+                    log.error("发生不可重试的异常,查询直接失败: {}", errorMsg);
+                    throw new RuntimeException("宜搭查询失败: " + errorMsg, e);
+                }
+            } catch (Exception e) {
+                // 非McException异常,直接抛出,不重试
+                log.error("查询操作失败,param:{},FORM_QUERY:{},异常信息:{}",
+                        JSONObject.toJSONString(param), formQuery, e.getMessage());
+                throw new RuntimeException(e);
+            }
+        }
+
+        // 理论上不会执行到这里,但为了安全保留
+        throw new RuntimeException("超出最大重试次数, param:" + JSONObject.toJSONString(param) + ", FORM_QUERY:" + formQuery);
+    }
+    /**
+     * 判断是否是可重试的错误
+     */
+    private boolean isRetryableError(String errorMsg) {
+        if (errorMsg == null) return false;
+
+        // 可重试的错误关键字列表(扩展了匹配范围)
+        String[] retryableKeywords = {
+                "temporary failure",
+                "未知异常",
+                "timeout",
+                "Timeout",
+                "Connection refused",
+                "Internal Server",
+                "服务不可用",
+                "Service Unavailable",
+                "Gateway Timeout",
+                "Bad Gateway"
+        };
+
+        for (String keyword : retryableKeywords) {
+            if (errorMsg.contains(keyword)) {
+                return true;
+            }
+        }
+        return false;
+    }
+    private List<Map> parseJsonList(String jsonStr) {
+        if (jsonStr == null || "null".equals(jsonStr) || jsonStr.isEmpty()) {
+            return Collections.emptyList();
+        }
+        try {
+            // 宜搭有时返回的是 "\"[{...}]\"",需先 unescape
+            String clean = StringEscapeUtils.unescapeJava(jsonStr);
+            // 如果首尾是双引号,去掉
+            if (clean.startsWith("\"") && clean.endsWith("\"")) {
+                clean = clean.substring(1, clean.length() - 1);
+            }
+            return (List<Map>) JSONArray.parse(clean);
+        } catch (Exception e) {
+
+            return Collections.emptyList();
+        }
+    }
     private static String safeToString(Object obj) {
     private static String safeToString(Object obj) {
         return obj == null ? null : obj.toString();
         return obj == null ? null : obj.toString();
     }
     }

+ 1 - 1
mjava-huagao/src/main/resources/application-dev.yml

@@ -73,7 +73,7 @@ eqb:
 
 
 #金蝶方开发服务
 #金蝶方开发服务
 kd:
 kd:
-  host: https://61.174.28.154:70
+  host: http://61.174.28.154:70
 
 
 
 
 
 

+ 2 - 2
mjava-qiwang/src/main/java/com/malk/qiwang/Controller/InvoiceLibraryController.java

@@ -52,8 +52,8 @@ public class InvoiceLibraryController {
     @Autowired
     @Autowired
     private InvoiceLibraryMapper baseMapper;
     private InvoiceLibraryMapper baseMapper;
     private static final String url = "http://47.103.203.2:9092/qiwang/";
     private static final String url = "http://47.103.203.2:9092/qiwang/";
-            //员工报销
-//private static final String url = "http://5862d6b4.r39.cpolar.top/qiwang/";
+// private static final String url = "http://410a09c5.r39.cpolar.top/qiwang/"
+//员工报销
     @PostMapping("/invoiceLibrary")
     @PostMapping("/invoiceLibrary")
     public McR test(@RequestBody Map map)  {
     public McR test(@RequestBody Map map)  {
         log.info("map:{}", map);
         log.info("map:{}", map);

+ 9 - 1
mjava-qiwang/src/main/java/com/malk/qiwang/Controller/QiWangController.java

@@ -1,10 +1,13 @@
 package com.malk.qiwang.Controller;
 package com.malk.qiwang.Controller;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.malk.qiwang.Service.QiWangService;
 import com.malk.qiwang.Service.QiWangService;
 import com.malk.qiwang.Service.TXYInvoice;
 import com.malk.qiwang.Service.TXYInvoice;
+import com.malk.qiwang.entity.CompanyTitle;
+import com.malk.qiwang.entity.InvoiceLibrary;
 import com.malk.qiwang.model.McInvoiceDto;
 import com.malk.qiwang.model.McInvoiceDto;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDParam;
 import com.malk.server.aliwork.YDParam;
@@ -45,6 +48,8 @@ import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -71,7 +76,7 @@ public class QiWangController {
     private static final String bdurl = "D://qiwang//files//";
     private static final String bdurl = "D://qiwang//files//";
     private static final String url = "http://47.103.203.2:9092/qiwang/";
     private static final String url = "http://47.103.203.2:9092/qiwang/";
 //    private static final String bdurl = "C:\\Users\\EDY\\Desktop\\项目\\琦王\\files\\";
 //    private static final String bdurl = "C:\\Users\\EDY\\Desktop\\项目\\琦王\\files\\";
-//private static final String url = "http://5862d6b4.r39.cpolar.top/qiwang/";
+//private static final String url = "http://410a09c5.r39.cpolar.top/qiwang/";
     @PostMapping("/test")
     @PostMapping("/test")
 
 
     public McR test(@RequestBody Map map) {
     public McR test(@RequestBody Map map) {
@@ -914,4 +919,7 @@ public McR test4(@RequestBody Map map) {
         return McR.success(McInvoiceDto.formatResponse(result));
         return McR.success(McInvoiceDto.formatResponse(result));
     }
     }
 
 
+
+
+
 }
 }

Різницю між файлами не показано, бо вона завелика
+ 2193 - 1494
mjava-qiwang/src/main/java/com/malk/qiwang/Service/impl/InvoiceLibraryServiceImpl.java


+ 3 - 0
mjava-qiwang/src/main/java/com/malk/qiwang/entity/InvoiceLibrary.java

@@ -143,6 +143,9 @@ public class InvoiceLibrary implements Serializable {
     //是否有发票
     //是否有发票
     private String hasInvoice;
     private String hasInvoice;
 
 
+    //备注
+    private String note;
+
     //子表报销金额
     //子表报销金额
     private BigDecimal detailAmount;
     private BigDecimal detailAmount;