2 Комити 4cba3014b0 ... bc0002d0c5

Аутор SHA1 Порука Датум
  “lqy bc0002d0c5 Merge remote-tracking branch 'origin/master' пре 1 месец
  “lqy 9e74d69ff9 11.7代码提交 пре 1 месец

+ 6 - 2
mjava-huagao/src/main/java/com/malk/huagao/controller/KdYdCustomerController.java

@@ -2,6 +2,7 @@ package com.malk.huagao.controller;
 
 import com.alibaba.fastjson.JSONObject;
 import com.malk.huagao.service.IKdYdCustomerService;
+import com.malk.huagao.service.IKdYdZpService;
 import com.malk.huagao.service.YdHuaGaoService;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDParam;
@@ -33,6 +34,8 @@ public class KdYdCustomerController {
     private IKdYdCustomerService  kdYdCustomerService;
     @Autowired
     private YdHuaGaoService ydHuaGaoService;
+    @Autowired
+    private IKdYdZpService kdYdZpService;
 @Autowired
 private YDClient ydClient;
     @PostMapping("/test30")
@@ -50,8 +53,9 @@ private YDClient ydClient;
 //                .build(), YDConf.FORM_OPERATION.update);
 //        ydHuaGaoService.synckdYdMaterial();
 //        ydHuaGaoService.synckdYdPayment();
-        ydHuaGaoService.syncKdYdReceivable();
-//        ydHuaGaoService.synckdYdOutbound();
+//        ydHuaGaoService.syncKdYdReceivable();
+//        kdYdZpService.insertkdYdZp(data);
+        ydHuaGaoService.synckdYdOutbound();
         return McR.success();
     }
     @PostMapping("/kdYdCustomer")

+ 4 - 0
mjava-huagao/src/main/java/com/malk/huagao/entity/KdYdReceivablePayment.java

@@ -35,5 +35,9 @@ public class KdYdReceivablePayment {
 
     private String xsddh;
 
+    private String syncStatus;
+
+    private String operationType;
+
 
 }

+ 4 - 0
mjava-huagao/src/main/java/com/malk/huagao/entity/KdYdZp.java

@@ -33,6 +33,10 @@ public class KdYdZp implements Serializable {
 
     private String kpfs;
 
+    private String ysdbm;
+
+    private String ddbm;
+
     private String fph;
 
     private LocalDateTime ywrq;

+ 2 - 0
mjava-huagao/src/main/java/com/malk/huagao/entity/KdYdZpDetail.java

@@ -31,6 +31,8 @@ public class KdYdZpDetail implements Serializable {
 
     private String wlbm;
 
+    private Integer detailId;
+
     private String wlmc;
 
     private String ggxh;

+ 12 - 17
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdCustomerLiaisonServiceImpl.java

@@ -41,12 +41,14 @@ public class KdYdCustomerLiaisonServiceImpl extends ServiceImpl<KdYdCustomerLiai
     public void insertCustomerLiaison(Map map) {
         MDC.put("MDC_KEY_PID", "1003");
         String formInstId = UtilMap.getString(map, "formInstId");
+        String type = UtilMap.getString(map, "type");
         DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                 .formInstId(formInstId)
                 .build(), YDConf.FORM_QUERY.retrieve_id);
         Map formData = ddrNew.getFormData();
 
         String xm = UtilMap.getString(formData, "textField_l3s6ubhq");
+        String bm = UtilMap.getString(formData, "serialNumberField_mhk5zwzs");
         String zw = UtilMap.getString(formData, "textField_l3s6ubht");
         String gddh = UtilMap.getString(formData, "textField_mfxu5dnk");
         String yddh = UtilMap.getString(formData, "textField_lqbzc3gq");
@@ -60,25 +62,10 @@ public class KdYdCustomerLiaisonServiceImpl extends ServiceImpl<KdYdCustomerLiai
         YdCustomerLambdaQueryWrapper.eq(KdYdCustomer::getUuid, uuid);
         KdYdCustomer kdYdCustomer1 = kdYdCustomerMapper.selectOne(YdCustomerLambdaQueryWrapper);
         Long id = kdYdCustomer1.getId();
-//        String khbm = kdYdCustomer1.getKhbm();
-//        String khmc = kdYdCustomer1.getKhmc();
-
-
-//        if (customerId == null) {
-//            List<Map> xmdata = (List<Map>) ydClient.queryData(
-//                    YDParam.builder()
-//                            .formUuid("FORM-68154CC0A7054BF0B1C933752CD3881FB0SR")
-//                            .searchFieldJson(JSONObject.toJSONString(UtilMap.map("textField_mgowmnlf", uuid)))
-//                            .build(),
-//                    YDConf.FORM_QUERY.retrieve_list_all
-//            ).getData();
-//            if (xmdata.size() > 0) {
-//                customerId = UtilMap.getString(xmdata.get(0), "textField_mgowmnli");
-//            }
-//        }
         KdYdCustomerLiaison kdYdCustomerLiaison = new KdYdCustomerLiaison();
         kdYdCustomerLiaison.setXm(xm);
         kdYdCustomerLiaison.setZw(zw);
+        kdYdCustomerLiaison.setBm(bm);
         kdYdCustomerLiaison.setGddh(gddh);
         kdYdCustomerLiaison.setYddh(yddh);
         kdYdCustomerLiaison.setCz(cz);
@@ -88,7 +75,15 @@ public class KdYdCustomerLiaisonServiceImpl extends ServiceImpl<KdYdCustomerLiai
         kdYdCustomerLiaison.setCustomerId(id);
         kdYdCustomerLiaison.setSyncStatus("0");
         kdYdCustomerLiaison.setOperationType("1");
-        this.save(kdYdCustomerLiaison);
+        if (type.equals("2")) {
+            kdYdCustomerLiaison.setOperationType("2");
+            kdYdCustomerLiaisonMapper.update(kdYdCustomerLiaison, new LambdaQueryWrapper<KdYdCustomerLiaison>().eq(KdYdCustomerLiaison::getBm, bm));
+        }else if (type.equals("3")){
+            kdYdCustomerLiaison.setOperationType("3");
+            kdYdCustomerLiaisonMapper.update(kdYdCustomerLiaison, new LambdaQueryWrapper<KdYdCustomerLiaison>().eq(KdYdCustomerLiaison::getBm, bm));
+        }else {
+            this.save(kdYdCustomerLiaison);
+        }
 //        ydClient.operateData(
 //                YDParam.builder()
 //                        .formInstanceId(formInstId)

+ 13 - 3
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdCustomerReferrerServiceImpl.java

@@ -1,5 +1,7 @@
 package com.malk.huagao.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.malk.huagao.entity.KdYdCustomerLiaison;
 import com.malk.huagao.entity.KdYdCustomerReferrer;
 import com.malk.huagao.mapper.KdYdCustomerReferrerMapper;
 import com.malk.huagao.service.IKdYdCustomerReferrerService;
@@ -33,15 +35,15 @@ private KdYdCustomerReferrerMapper kdYdCustomerReferrerMapper;
     public void insertCustomerReferrer(Map map) {
         MDC.put("MDC_KEY_PID", "1003");
         String formInstId = UtilMap.getString(map, "formInstId");
+        String type = UtilMap.getString(map, "type");
         DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                 .formInstId(formInstId)
                 .build(), YDConf.FORM_QUERY.retrieve_id);
         Map formData = ddrNew.getFormData();
-        System.out.println(formData);
         String mc = UtilMap.getString(formData, "textField_mgqbiouh");
         String sfzh = UtilMap.getString(formData, "textField_mgqbioux");
         String sjh = UtilMap.getString(formData, "textField_mgqbioui");
-        String bm = UtilMap.getString(formData, "serialNumberField_mhk5zwzs");
+        String bm = UtilMap.getString(formData, "serialNumberField_mhiycezm");
 //        String skrmc = UtilMap.getString(formData, "textField_mgqbioun");
 //        String skzh = UtilMap.getString(formData, "textField_mgqbious");
 //        String khh = UtilMap.getString(formData, "textField_mgqbiov0");
@@ -63,6 +65,14 @@ private KdYdCustomerReferrerMapper kdYdCustomerReferrerMapper;
         kdYdCustomerReferrer.setOperationType("1");
         kdYdCustomerReferrer.setFormInstId(formInstId);
 
-        this.save(kdYdCustomerReferrer);
+        if (type.equals("2")) {
+            kdYdCustomerReferrer.setOperationType("2");
+            kdYdCustomerReferrerMapper.update(kdYdCustomerReferrer, new LambdaQueryWrapper<KdYdCustomerReferrer>().eq(KdYdCustomerReferrer::getBm, bm));
+        }else if (type.equals("3")){
+            kdYdCustomerReferrer.setOperationType("3");
+            kdYdCustomerReferrerMapper.update(kdYdCustomerReferrer, new LambdaQueryWrapper<KdYdCustomerReferrer>().eq(KdYdCustomerReferrer::getBm, bm));
+        }else {
+            this.save(kdYdCustomerReferrer);
+        }
     }
 }

+ 10 - 4
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdCustomerServiceImpl.java

@@ -37,11 +37,11 @@ public class KdYdCustomerServiceImpl extends ServiceImpl<KdYdCustomerMapper, KdY
     public void insertCustomer(Map map) {
         MDC.put("MDC_KEY_PID", "1003");
         String formInstId = UtilMap.getString(map, "formInstId");
+        String type = UtilMap.getString(map, "type");
         DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                 .formInstId(formInstId)
                 .build(), YDConf.FORM_QUERY.retrieve_id);
         Map formData = ddrNew.getFormData();
-        System.out.println(formData);
         String khmc = UtilMap.getString(formData, "textField_lqanqe6j");
         String khbm = UtilMap.getString(formData, "textField_meqhqqvg");
         String xssx = UtilMap.getString(formData, "selectField_megi74y7");
@@ -99,10 +99,16 @@ public class KdYdCustomerServiceImpl extends ServiceImpl<KdYdCustomerMapper, KdY
         kdYdCustomer.setTjruuid(tjruuid);
         kdYdCustomer.setSyncStatus("0");
         kdYdCustomer.setOperationType("1");
+        if (type.equals("2")) {
+            kdYdCustomer.setOperationType("2");
+            kdYdCustomerMapper.update(kdYdCustomer, new LambdaQueryWrapper<KdYdCustomer>().eq(KdYdCustomer::getKhbm, khbm));
+        }else if (type.equals("3")){
+            kdYdCustomer.setOperationType("3");
+            kdYdCustomerMapper.update(kdYdCustomer, new LambdaQueryWrapper<KdYdCustomer>().eq(KdYdCustomer::getKhbm, khbm));
+        }else {
+            this.save(kdYdCustomer);
+        }
 
-
-
-        boolean save = this.save(kdYdCustomer);
 //        LambdaQueryWrapper<KdYdCustomer> YdCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
 //        YdCustomerLambdaQueryWrapper.eq(KdYdCustomer::getFormInstId, formInstId);
 //        KdYdCustomer kdYdCustomer1 = kdYdCustomerMapper.selectOne(YdCustomerLambdaQueryWrapper);

+ 24 - 6
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdDeliveryServiceImpl.java

@@ -1,10 +1,8 @@
 package com.malk.huagao.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.malk.huagao.entity.KdYdDelivery;
-import com.malk.huagao.entity.KdYdDeliveryDetail;
-import com.malk.huagao.entity.KdYdOrder;
-import com.malk.huagao.entity.KdYdOrderDetail;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.malk.huagao.entity.*;
 import com.malk.huagao.mapper.KdYdDeliveryDetailMapper;
 import com.malk.huagao.mapper.KdYdDeliveryMapper;
 import com.malk.huagao.mapper.KdYdOrderDetailMapper;
@@ -48,6 +46,7 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
     public void insertDelivery(Map map) {
         MDC.put("MDC_KEY_PID", "1003");
         String formInstId = UtilMap.getString(map, "formInstId");
+        String type = UtilMap.getString(map, "type");
         DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                 .formInstId(formInstId)
                 .build(), YDConf.FORM_QUERY.retrieve_id);
@@ -99,7 +98,15 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
         kdYdDelivery.setKdgs(kdgs);
         kdYdDelivery.setFkfs(fkfs);
         kdYdDelivery.setForminstid(formInstId);
-        kdYdDeliveryMapper.insert(kdYdDelivery);
+        if (type.equals("2")) {
+            kdYdDelivery.setOperationType("2");
+            kdYdDeliveryMapper.update(kdYdDelivery, new LambdaQueryWrapper<KdYdDelivery>().eq(KdYdDelivery::getDjbh, djbh));
+        }else if (type.equals("3")){
+            kdYdDelivery.setOperationType("3");
+            kdYdDeliveryMapper.update(kdYdDelivery, new LambdaQueryWrapper<KdYdDelivery>().eq(KdYdDelivery::getDjbh, djbh));
+        }else {
+            kdYdDeliveryMapper.insert(kdYdDelivery);
+        }
 
         Long id = kdYdDelivery.getId();
         System.out.println("id:"+id);
@@ -142,7 +149,18 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
             kdYdDeliveryDetail.setZbq(zbq);
             kdYdDeliveryDetail.setKddh(kddh);
             kdYdDeliveryDetail.setMdh(mdh);
-            kdYdDeliveryDetailMapper.insert(kdYdDeliveryDetail);
+            if (type.equals("2")) {
+                kdYdDeliveryDetail.setOperationType("2");
+                kdYdDeliveryDetailMapper.update(kdYdDeliveryDetail, new LambdaQueryWrapper<KdYdDeliveryDetail>().eq(KdYdDeliveryDetail::getWlbm, wlbm)
+                        .eq(KdYdDeliveryDetail::getDeliveryId, id));
+            }else if (type.equals("3")){
+                kdYdDeliveryDetail.setOperationType("3");
+                kdYdDeliveryDetailMapper.update(kdYdDeliveryDetail, new LambdaQueryWrapper<KdYdDeliveryDetail>().eq(KdYdDeliveryDetail::getWlbm, wlbm)
+                        .eq(KdYdDeliveryDetail::getDeliveryId, id));
+            }else {
+                kdYdDeliveryDetailMapper.insert(kdYdDeliveryDetail);
+            }
+
             count++;
 //save(kdYdDeliveryDetail);
         }

+ 43 - 7
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdOrderServiceImpl.java

@@ -4,6 +4,8 @@ package com.malk.huagao.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.malk.huagao.entity.KdYdDelivery;
 import com.malk.huagao.entity.KdYdOrder;
 import com.malk.huagao.entity.KdYdOrderDetail;
 import com.malk.huagao.entity.KdYdOrderPayment;
@@ -34,7 +36,7 @@ import java.util.Map;
 
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author LQY
@@ -56,6 +58,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
     public void insertkdYdOrder(Map map) {
         MDC.put("MDC_KEY_PID", "1003");
         String formInstId = UtilMap.getString(map, "formInstId");
+        String type = UtilMap.getString(map, "type");
         DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                 .formInstId(formInstId)
                 .build(), YDConf.FORM_QUERY.retrieve_id);
@@ -124,7 +127,16 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
         kdYdOrder.setSyncStatus("0");
         kdYdOrder.setOperationType("1");
         kdYdOrder.setForminstid(formInstId);
-        kdYdOrderMapper.insert(kdYdOrder);
+        if (type.equals("2")) {
+            kdYdOrder.setOperationType("2");
+            kdYdOrderMapper.update(kdYdOrder, new LambdaQueryWrapper<KdYdOrder>().eq(KdYdOrder::getDjbh, djbh));
+        } else if (type.equals("3")) {
+            kdYdOrder.setOperationType("3");
+            kdYdOrderMapper.update(kdYdOrder, new LambdaQueryWrapper<KdYdOrder>().eq(KdYdOrder::getDjbh, djbh));
+        } else {
+            kdYdOrderMapper.insert(kdYdOrder);
+        }
+
         Long id = kdYdOrder.getId();
         int count = 1;
         for (Map item : tableField) {
@@ -173,11 +185,20 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
             kdYdOrderDetail.setSyncStatus("0");
             kdYdOrderDetail.setOperationType("1");
             kdYdOrderDetail.setForminstid(formInstId);
-
-            kdYdOrderDetailMapper.insert(kdYdOrderDetail);
+            if (type.equals("2")) {
+                kdYdOrderDetail.setOperationType("2");
+                kdYdOrderDetailMapper.update(kdYdOrderDetail, new LambdaQueryWrapper<KdYdOrderDetail>().eq(KdYdOrderDetail::getWlbm, wlbm)
+                        .eq(KdYdOrderDetail::getOrderId, id));
+            } else if (type.equals("3")) {
+                kdYdOrderDetail.setOperationType("3");
+                kdYdOrderDetailMapper.update(kdYdOrderDetail, new LambdaQueryWrapper<KdYdOrderDetail>().eq(KdYdOrderDetail::getWlbm, wlbm)
+                        .eq(KdYdOrderDetail::getOrderId, id));
+            } else {
+                kdYdOrderDetailMapper.insert(kdYdOrderDetail);
+            }
             count++;
         }
-        if (tableFieldPayment != null){
+        if (tableFieldPayment != null) {
             for (int i = 0; i < tableFieldPayment.size(); i++) {
                 Map row = tableFieldPayment.get(i);
                 String sfys = safeGetString(row, "radioField_mhiui6v7");
@@ -185,6 +206,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
                 BigDecimal ysbl = toBigDecimal(UtilMap.getString(row, "numberField_mhiui6v6"));
                 BigDecimal ysje = toBigDecimal(UtilMap.getString(row, "numberField_mhiui6v8"));
                 BigDecimal ssje = toBigDecimal(UtilMap.getString(row, "numberField_mhiui6vb"));
+                int detailId = i + 1;
                 LocalDateTime endTime = parseTimestamp(UtilMap.getString(row, "dateField_mhiui6v9"));
                 KdYdOrderPayment kdYdOrderPayment = new KdYdOrderPayment();
                 kdYdOrderPayment.setOrderId(id);
@@ -193,11 +215,21 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
                 kdYdOrderPayment.setYsbl(ysbl);
                 kdYdOrderPayment.setYsje(ysje);
                 kdYdOrderPayment.setSsje(ssje);
-                kdYdOrderPayment.setDetailId(i + 1);
+                kdYdOrderPayment.setDetailId(detailId);
                 kdYdOrderPayment.setEndTime(endTime);
                 kdYdOrderPayment.setSyncStatus("0");
                 kdYdOrderPayment.setOperationType("1");
-                kdYdOrderPaymentMapper.insert(kdYdOrderPayment);
+                if (type.equals("2")) {
+                    kdYdOrderPayment.setOperationType("2");
+                    kdYdOrderPaymentMapper.update(kdYdOrderPayment, new LambdaQueryWrapper<KdYdOrderPayment>().eq(KdYdOrderPayment::getDetailId, detailId)
+                            .eq(KdYdOrderPayment::getOrderId, id));
+                } else if (type.equals("3")) {
+                    kdYdOrderPayment.setOperationType("3");
+                    kdYdOrderPaymentMapper.update(kdYdOrderPayment, new LambdaQueryWrapper<KdYdOrderPayment>().eq(KdYdOrderPayment::getDetailId, detailId)
+                            .eq(KdYdOrderPayment::getOrderId, id));
+                } else {
+                    kdYdOrderPaymentMapper.insert(kdYdOrderPayment);
+                }
             }
         }
 //        ydClient.operateData(
@@ -207,6 +239,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
 //                        .useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
 
     }
+
     private static LocalDateTime parseTimestamp(String timestampStr) {
         if (timestampStr == null || timestampStr.trim().isEmpty()) return null;
         try {
@@ -219,6 +252,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
             return null;
         }
     }
+
     private static int parseInt(String str, int defaultValue) {
         if (str == null || str.trim().isEmpty()) {
             return defaultValue;
@@ -229,10 +263,12 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
             return defaultValue;
         }
     }
+
     private String safeGetString(Map formData, String key) {
         Object val = formData.get(key);
         return val == null ? "" : String.valueOf(val);
     }
+
     public static BigDecimal toBigDecimal(String str) {
         if (str == null || str.trim().isEmpty()) {
             return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);

+ 50 - 25
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdZpServiceImpl.java

@@ -1,10 +1,8 @@
 package com.malk.huagao.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.malk.huagao.entity.KdYdReceivable;
-import com.malk.huagao.entity.KdYdReceivableDetail;
-import com.malk.huagao.entity.KdYdZp;
-import com.malk.huagao.entity.KdYdZpDetail;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.malk.huagao.entity.*;
 import com.malk.huagao.mapper.KdYdReceivableDetailMapper;
 import com.malk.huagao.mapper.KdYdReceivableMapper;
 import com.malk.huagao.mapper.KdYdZpDetailMapper;
@@ -49,40 +47,58 @@ public class KdYdZpServiceImpl extends ServiceImpl<KdYdZpMapper, KdYdZp> impleme
     public void insertkdYdZp(Map map) {
         MDC.put("MDC_KEY_PID", "1003");
         String formInstId = UtilMap.getString(map, "formInstId");
+        String type = UtilMap.getString(map, "type");
         DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                 .formInstId(formInstId)
                 .build(), YDConf.FORM_QUERY.retrieve_id);
         Map formData = ddrNew.getFormData();
 
         String djlx = UtilMap.getString(formData, "radioField_mg3cexkm");
-        long receivableId = UtilMap.getLong(formData, "textField_mgt4w4ip");
-        String kh = UtilMap.getString(formData, "textField_mejmml3k");
+//        long receivableId = UtilMap.getLong(formData, "textField_mgt4w4ip");
+        String kh = UtilMap.getString(formData, "textField_mhn5h4mo");
         String kpfs = UtilMap.getString(formData, "selectField_mg3cexke");
         String fph = UtilMap.getString(formData, "textField_mejmml3a");
         LocalDateTime ywrq = parseTimestamp(UtilMap.getString(formData, "dateField_mejmml39"));
         String bb = UtilMap.getString(formData, "selectField_mg3fuqvn");
         String bz = UtilMap.getString(formData, "textareaField_mejmml3e");
+        String djbh = UtilMap.getString(formData, "serialNumberField_mhn4661d");
         String spdzyx = UtilMap.getString(formData, "textField_mejmml3d");
+        String dddjbh = UtilMap.getString(formData, "textField_mg3cexkf");
+        String ysddjbh = UtilMap.getString(formData, "textField_mejmml3k");
         String jshjstr = UtilMap.getString(formData, "numberField_mejmml38");
         BigDecimal jshj = toBigDecimal(jshjstr);
         List<Map> tableField = (List<Map>) formData.get("tableField_mf6el3zx");
         KdYdZp kdYdZp = new KdYdZp();
-          kdYdZp.setDjlx(djlx);
-          kdYdZp.setKpfs(kpfs);
-          kdYdZp.setFph(fph);
-          kdYdZp.setYwrq(ywrq);
-          kdYdZp.setReceivableId(receivableId);
-          kdYdZp.setBb(bb);
-          kdYdZp.setJshj(jshj);
-          kdYdZp.setBz(bz);
-          kdYdZp.setKh(kh);
-          kdYdZp.setSpdzyx(spdzyx);
-          kdYdZp.setCreateTime(LocalDateTime.now());
-          kdYdZp.setForminstid(formInstId);
-          kdYdZpMapper.insert(kdYdZp);
+        kdYdZp.setDjlx(djlx);
+        kdYdZp.setKpfs(kpfs);
+        kdYdZp.setDjbh(djbh);
+        kdYdZp.setFph(fph);
+        kdYdZp.setYwrq(ywrq);
+//          kdYdZp.setReceivableId(receivableId);
+        kdYdZp.setBb(bb);
+        kdYdZp.setJshj(jshj);
+        kdYdZp.setBz(bz);
+        kdYdZp.setKh(kh);
+        kdYdZp.setSyncStatus("0");
+        kdYdZp.setOperationType("1");
+        kdYdZp.setSpdzyx(spdzyx);
+        kdYdZp.setCreateTime(LocalDateTime.now());
+        kdYdZp.setForminstid(formInstId);
+        if (type.equals("2")) {
+            kdYdZp.setOperationType("2");
+            kdYdZpMapper.update(kdYdZp, new LambdaQueryWrapper<KdYdZp>().eq(KdYdZp::getDjbh, djbh));
+        } else if (type.equals("3")) {
+            kdYdZp.setOperationType("3");
+            kdYdZpMapper.update(kdYdZp, new LambdaQueryWrapper<KdYdZp>().eq(KdYdZp::getDjbh, djbh));
+        } else {
+            kdYdZpMapper.insert(kdYdZp);
+        }
+
 
         Long id = kdYdZp.getId();
+        int count = 1;
         for (Map item : tableField) {
+
             String wlbm = safeGetString(item, "textField_mf6el3zy");
             String wlmc = safeGetString(item, "textField_mf6el3zz");
             String ggxh = safeGetString(item, "textField_mejmtic5");
@@ -101,6 +117,7 @@ public class KdYdZpServiceImpl extends ServiceImpl<KdYdZpMapper, KdYdZp> impleme
             BigDecimal rjdj = toBigDecimal(safeGetString(item, "numberField_mg3cexkl"));
             String gg = safeGetString(item, "textField_mf6el40b");
             String xxddbm = safeGetString(item, "textField_mf6el408");
+//            String ysdjbh = safeGetString(item, "textField_mhn5h4mi");
             KdYdZpDetail kdYdZpDetail = new KdYdZpDetail();
             kdYdZpDetail.setZpId(id);
             kdYdZpDetail.setWlbm(wlbm);
@@ -121,13 +138,21 @@ public class KdYdZpServiceImpl extends ServiceImpl<KdYdZpMapper, KdYdZp> impleme
             kdYdZpDetail.setRjdj(rjdj);
             kdYdZpDetail.setGg(gg);
             kdYdZpDetail.setXxddbh(xxddbm);
-            kdYdZpDetailMapper.insert(kdYdZpDetail);
+            kdYdZpDetail.setDetailId(count);
+            kdYdZpDetail.setSyncStatus("0");
+            kdYdZpDetail.setOperationType("1");
+            if (type.equals("2")) {
+                kdYdZpDetail.setOperationType("2");
+                kdYdZpDetailMapper.update(kdYdZpDetail, new LambdaQueryWrapper<KdYdZpDetail>().eq(KdYdZpDetail::getDetailId, count));
+            } else if (type.equals("3")) {
+                kdYdZpDetail.setOperationType("3");
+                kdYdZpDetailMapper.update(kdYdZpDetail, new LambdaQueryWrapper<KdYdZpDetail>().eq(KdYdZpDetail::getDetailId, count));
+            } else {
+                kdYdZpDetailMapper.insert(kdYdZpDetail);
+            }
+            count++;
         }
-        ydClient.operateData(
-                YDParam.builder()
-                        .formInstanceId(formInstId)
-                        .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_mgt6lcqq", id)))
-                        .useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
+
     }
 
     private static LocalDateTime parseTimestamp(String timestampStr) {

+ 325 - 15
mjava-huagao/src/main/java/com/malk/huagao/service/impl/YdHuaGaoServiceImpl.java

@@ -9,6 +9,7 @@ import com.malk.huagao.mapper.*;
 import com.malk.huagao.service.YdHuaGaoService;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDParam;
+import com.malk.server.aliwork.YDSearch;
 import com.malk.server.dingtalk.DDConf;
 import com.malk.service.aliwork.YDClient;
 import com.malk.utils.UtilMap;
@@ -233,6 +234,78 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
     @Override
     public void synckdYdOutbound() {
         log.info("定时同步-出库单");
+        // 查询需要删除的数据
+        LambdaQueryWrapper<KdYdOutbound> outbounddel = new LambdaQueryWrapper<>();
+        outbounddel.eq(KdYdOutbound::getOperationType, 3)
+                .eq(KdYdOutbound::getSyncStatus, "0");
+        List<KdYdOutbound> kdYdOutbounddels = kdYdOutboundMapper.selectList(outbounddel);
+
+        // 批量删除处理
+        if (!kdYdOutbounddels.isEmpty()) {
+            log.info("开始处理出库单删除操作,共{}条数据", kdYdOutbounddels.size());
+            ArrayList<String> deleteList = new ArrayList<>();
+            int deleteSuccessCount = 0;
+
+            for (KdYdOutbound kdYdOutbound : kdYdOutbounddels) {
+                try {
+                    String djbh = kdYdOutbound.getDjbh();
+
+                    List<Map> list1 = (List<Map>) ydClient.queryData(YDParam.builder()
+                            .formUuid("FORM-AADBCDA8126F41A0ADDEE3353828583192M8")
+                            .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mg34txgm", djbh)))
+                            .build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
+
+                    if (list1 != null && !list1.isEmpty()) {
+                        for (Map map : list1) {
+                            String formInstanceId = UtilMap.getString(map, "formInstanceId");
+                            if (formInstanceId != null) {
+                                deleteList.add(formInstanceId);
+                            }
+                        }
+                        deleteSuccessCount++;
+
+                        // 同时删除对应的子表数据
+                        Long outboundId = kdYdOutbound.getId();
+                        LambdaQueryWrapper<KdYdOutboundDetail> detailDelqw = new LambdaQueryWrapper<>();
+                        detailDelqw.eq(KdYdOutboundDetail::getOutboundId, outboundId);
+                        List<KdYdOutboundDetail> detailDels = kdYdOutboundDetailMapper.selectList(detailDelqw);
+
+                        if (!detailDels.isEmpty()) {
+                            for (KdYdOutboundDetail detail : detailDels) {
+                                detail.setSyncStatus("1");
+                                kdYdOutboundDetailMapper.updateById(detail);
+                            }
+                        }
+                    } else {
+                        log.warn("未找到对应的出库单数据: djbh={}", djbh);
+                    }
+
+                    // 删除操作完成后更新状态
+                    kdYdOutbound.setSyncStatus("1");
+                    kdYdOutboundMapper.updateById(kdYdOutbound);
+
+                } catch (Exception e) {
+                    log.error("删除出库单数据查询异常: djbh={}", kdYdOutbound.getDjbh(), e);
+                }
+            }
+
+            // 执行批量删除
+            if (!deleteList.isEmpty()) {
+                try {
+                    ydClient.operateData(YDParam.builder()
+                            .formUuid("FORM-AADBCDA8126F41A0ADDEE3353828583192M8")
+                            .formInstanceIdList(deleteList)
+                            .build(), YDConf.FORM_OPERATION.delete_batch);
+                    log.info("出库单批量删除完成,共删除{}条数据", deleteList.size());
+                } catch (Exception e) {
+                    log.error("出库单批量删除操作异常", e);
+                }
+            }
+
+            return;
+        } else {
+            log.info("【出库单删除任务】无需要删除的数据");
+        }
         LambdaQueryWrapper<KdYdOutbound> outboundqw = new LambdaQueryWrapper<>();
         outboundqw.eq(KdYdOutbound::getSyncStatus, "0");
         List<KdYdOutbound> kdYdOutbounds = kdYdOutboundMapper.selectList(outboundqw);
@@ -292,6 +365,8 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     tablemap.put("textField_mf6a0h6y", kdYdOutboundDetail.getJx());
 //                    tablemap.put("radioField_mf6a0h6h", kdYdOutboundDetail.getSfzp());
                     tableList.add(tablemap);
+                    kdYdOutboundDetail.setSyncStatus("1");
+                    kdYdOutboundDetailMapper.updateById(kdYdOutboundDetail);
 
                 }
 
@@ -336,7 +411,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                 updateMap.put("tableField_mejnamfd", tableList);
                 if (fhdbh != null && fhdformInstanceId != null) {
                     updateMap.put("associationFormField_mejmml36",
-                            Arrays.asList(getfhdAss(fhdbh,fhdformInstanceId)));
+                            Arrays.asList(getfhdAss(fhdbh, fhdformInstanceId)));
                 }
                 updateMap.put("dateField_krbgloam", kdYdOutbound.getDateTime() != null ? String.valueOf(kdYdOutbound.getDateTime().atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli()) : "");
                 updateMap.put("textField_krnn5bmr", kdYdOutbound.getXsDept());
@@ -370,16 +445,108 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
             } catch (Exception e) {
                 failCount++;
                 log.error("同步单条出库单数据异常: 单据编号={}, 错误信息={}",
-                         kdYdOutbound.getDjbh(), e.getMessage(), e);
+                        kdYdOutbound.getDjbh(), e.getMessage(), e);
             }
         }
 
         log.info("【出库单同步任务】完成: 成功={}, 失败={}, 总计={}",
                 successCount, failCount, kdYdOutbounds.size());
     }
+
     @Override
     public void syncKdYdReceivable() {
         log.info("定时同步-应收单");
+        // 查询需要删除的数据
+        LambdaQueryWrapper<KdYdReceivable> receivabledel = new LambdaQueryWrapper<>();
+        receivabledel.eq(KdYdReceivable::getOperationType, 3)
+                .eq(KdYdReceivable::getSyncStatus, "0");
+        List<KdYdReceivable> kdYdReceivabledels = kdYdReceivableMapper.selectList(receivabledel);
+
+        // 批量删除处理
+        if (!kdYdReceivabledels.isEmpty()) {
+            log.info("开始处理应收单删除操作,共{}条数据", kdYdReceivabledels.size());
+            ArrayList<String > deleteList = new ArrayList<>();
+            int deleteSuccessCount = 0;
+
+            for (KdYdReceivable kdYdReceivable : kdYdReceivabledels) {
+                try {
+                    String djbh = kdYdReceivable.getDjbh();
+
+                    List<Map> list1 = (List<Map>) ydClient.queryData(YDParam.builder()
+                            .formUuid("FORM-4E1CE4550339494A9BE5498FB119FF2E9ERU")
+                            .appType("APP_VQDMMWS6OR1VHL8VMFD3")
+                            .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
+                            .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mg3a0tgs", djbh)))
+                            .build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
+
+                    if (list1 != null && !list1.isEmpty()) {
+                        for (Map map : list1) {
+                            String formInstanceId = UtilMap.getString(map, "formInstanceId");
+                            if (formInstanceId != null) {
+                                deleteList.add(formInstanceId);
+                            }
+                        }
+                        deleteSuccessCount++;
+
+                        // 同时删除对应的子表数据
+                        Long receivableId = kdYdReceivable.getId();
+
+                        // 删除应收单明细
+                        LambdaQueryWrapper<KdYdReceivableDetail> detailDelqw = new LambdaQueryWrapper<>();
+                        detailDelqw.eq(KdYdReceivableDetail::getReceivableId, receivableId);
+                        List<KdYdReceivableDetail> detailDels = kdYdReceivableDetailMapper.selectList(detailDelqw);
+                        if (!detailDels.isEmpty()) {
+                            for (KdYdReceivableDetail detail : detailDels) {
+                                detail.setSyncStatus("1");
+                                kdYdReceivableDetailMapper.updateById(detail);
+                            }
+                            log.debug("更新了{}条应收单明细删除状态", detailDels.size());
+                        }
+
+                        // 删除收款计划
+                        LambdaQueryWrapper<KdYdReceivablePayment> paymentDelqw = new LambdaQueryWrapper<>();
+                        paymentDelqw.eq(KdYdReceivablePayment::getReceivableId, receivableId);
+                        List<KdYdReceivablePayment> paymentDels = kdYdReceivalablePaymentMapper.selectList(paymentDelqw);
+                        if (!paymentDels.isEmpty()) {
+                            for (KdYdReceivablePayment payment : paymentDels) {
+                                payment.setSyncStatus("1");
+                                kdYdReceivalablePaymentMapper.updateById(payment);
+                            }
+                            log.debug("更新了{}条收款计划删除状态", paymentDels.size());
+                        }
+                    } else {
+                        log.warn("未找到对应的应收单数据: djbh={}", djbh);
+                    }
+
+                    // 删除操作完成后更新状态
+                    kdYdReceivable.setSyncStatus("1");
+                    kdYdReceivableMapper.updateById(kdYdReceivable);
+
+                } catch (Exception e) {
+                    log.error("删除应收单数据查询异常: djbh={}", kdYdReceivable.getDjbh(), e);
+                }
+            }
+
+            // 执行批量删除
+            if (!deleteList.isEmpty()) {
+                try {
+                    ydClient.operateData(YDParam.builder()
+                            .formUuid("FORM-4E1CE4550339494A9BE5498FB119FF2E9ERU")
+                            .appType("APP_VQDMMWS6OR1VHL8VMFD3")
+                            .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
+                            .formInstanceIdList(deleteList)
+                            .build(), YDConf.FORM_OPERATION.delete_batch);
+                    log.info("应收单批量删除完成,共删除{}条数据", deleteList.size());
+                } catch (Exception e) {
+                    log.error("应收单批量删除操作异常", e);
+                }
+            }
+
+            log.info("应收单删除操作处理完成: 成功查询={}, 待删除={}", deleteSuccessCount, deleteList.size());
+            return;
+        } else {
+            log.info("【应收单删除任务】无需要删除的数据");
+        }
         LambdaQueryWrapper<KdYdReceivable> receivableqw = new LambdaQueryWrapper<>();
         receivableqw.eq(KdYdReceivable::getSyncStatus, "0");
         List<KdYdReceivable> kdYdReceivables = kdYdReceivableMapper.selectList(receivableqw);
@@ -408,7 +575,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     log.info("【应收单{}】无需要同步的明细数据", djbh);
                     continue;
                 }
-
+                int count = 1;
                 ArrayList<Object> tableList = new ArrayList<>();
                 for (KdYdReceivableDetail kdYdReceivableDetail : kdYdReceivabledetails) {
                     HashMap<Object, Object> tablemap = new HashMap<>();
@@ -438,6 +605,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     String detailId = kdYdReceivableDetail.getDetailId();
 
                     // 优化:确保所有金额字段保留两位小数
+                    tablemap.put("textField_mgt4w4ip", count);
                     tablemap.put("textField_mf6el3zy", wlbm);
                     tablemap.put("textField_mf6el3zz", wlmc);
                     tablemap.put("textField_mejmtic5", ggxh);
@@ -460,6 +628,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     tablemap.put("textField_mf6el40d", jx);
                     tablemap.put("textField_mf6el40b", gg);
                     tablemap.put("numberField_mf6el405", zke != null ? zke.setScale(2, java.math.RoundingMode.HALF_UP) : java.math.BigDecimal.ZERO.setScale(2, java.math.RoundingMode.HALF_UP));
+                    count++;
                     tableList.add(tablemap);
 
                     kdYdReceivableDetail.setSyncStatus("1");
@@ -491,6 +660,8 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                         tablemap1.put("numberField_mhiui6vb", ysjebwb != null ? ysjebwb.setScale(2, java.math.RoundingMode.HALF_UP) : java.math.BigDecimal.ZERO.setScale(2, java.math.RoundingMode.HALF_UP));
                         tablemap1.put("numberField_mhjy9hzj", stkdglje != null ? stkdglje.setScale(2, java.math.RoundingMode.HALF_UP) : java.math.BigDecimal.ZERO.setScale(2, java.math.RoundingMode.HALF_UP));
                         tableListPay.add(tablemap1);
+                        kdYdReceivablePayment.setSyncStatus("1");
+                        kdYdReceivalablePaymentMapper.updateById(kdYdReceivablePayment);
                     }
                 }
                 String ckddjbh = kdYdReceivable.getCkddjbh();
@@ -535,7 +706,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                 updateData.put("tableField_mf6el3zx", tableList);
                 if (ckdbh != null && ckdformInstanceId != null) {
                     updateData.put("associationFormField_mejmtick",
-                            Arrays.asList(getysdAss(ckdbh,ckdformInstanceId)));
+                            Arrays.asList(getysdAss(ckdbh, ckdformInstanceId)));
                 }
                 updateData.put("tableField_mhiui6v5", tableListPay);
                 updateData.put("textField_mg3a0tgs", kdYdReceivable.getDjbh());
@@ -624,13 +795,76 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
     @Override
     public void synckdYdMaterial() {
         log.info("定时同步-物料单");
+        // 查询需要删除的数据
+        LambdaQueryWrapper<KdYdMaterial> materialdel = new LambdaQueryWrapper<>();
+        materialdel.eq(KdYdMaterial::getOperationType, 3)  // 修正:使用 materialdel 而不是 materialqw
+                .eq(KdYdMaterial::getSyncStatus, "0");
+        List<KdYdMaterial> kdYdMaterialdels = kdYdMaterialMapper.selectList(materialdel);
+
+        // 批量删除处理
+        if (!kdYdMaterialdels.isEmpty()) {
+            log.info("开始处理删除操作,共{}条数据", kdYdMaterialdels.size());
+            ArrayList<String> list = new ArrayList<>();
+            int deleteSuccessCount = 0;
+
+            for (KdYdMaterial kdYdMaterial : kdYdMaterialdels) {
+                try {
+                    String wlbm = kdYdMaterial.getWlbm();
+                    List<Map> list1 = (List<Map>) ydClient.queryData(YDParam.builder()
+                            .formUuid("FORM-E132ECE2BED94BCF81D9842B3F2054E7XWQ7")
+                            .appType("APP_VQDMMWS6OR1VHL8VMFD3")  // 新增:添加应用参数
+                            .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")  // 新增:添加系统令牌
+                            .searchFieldJson(JSONObject.toJSONString(UtilMap.map("textField_mfxbtcdh", wlbm)))
+                            .build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
+
+                    if (list1 != null && !list1.isEmpty()) {
+                        for (Map map : list1) {
+                            String formInstanceId = UtilMap.getString(map, "formInstanceId");
+                            if (formInstanceId != null) {
+                                list.add(formInstanceId);
+                                log.debug("找到待删除的表单实例: formInstanceId={}", formInstanceId);
+                            }
+                        }
+                        deleteSuccessCount++;
+                    } else {
+                        log.warn("未找到对应的物料数据: wlbm={}", wlbm);
+                    }
+
+                    // 删除操作完成后更新状态
+                    kdYdMaterial.setSyncStatus("1");
+                    kdYdMaterialMapper.updateById(kdYdMaterial);
+
+                } catch (Exception e) {
+                    log.error("删除物料数据查询异常: wlbm={}", kdYdMaterial.getWlbm(), e);
+                }
+            }
+
+            // 执行批量删除
+            if (!list.isEmpty()) {
+                try {
+                    ydClient.operateData(YDParam.builder()
+                            .formUuid("FORM-E132ECE2BED94BCF81D9842B3F2054E7XWQ7")
+                            .appType("APP_VQDMMWS6OR1VHL8VMFD3")
+                            .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
+                            .formInstanceIdList(list)
+                            .build(), YDConf.FORM_OPERATION.delete_batch);
+                    log.info("批量删除完成,共删除{}条数据", list.size());
+                } catch (Exception e) {
+                    log.error("批量删除操作异常", e);
+                }
+            }
+
+            return;
+        }
         LambdaQueryWrapper<KdYdMaterial> materialqw = new LambdaQueryWrapper<>();
         materialqw.eq(KdYdMaterial::getSyncStatus, "0");
-//                .or()
-//                .eq(KdYdMaterial::getOperationType, 2);
         List<KdYdMaterial> kdYdMaterials = kdYdMaterialMapper.selectList(materialqw);
-
         log.info("本次需要同步的物料单数量: {}", kdYdMaterials.size());
+        // 同步新增/更新数据
+        if (kdYdMaterials.isEmpty()) {
+            log.info("【物料单同步任务】无需要同步的数据,结束");
+            return;
+        }
         int successCount = 0;
         int failCount = 0;
 
@@ -688,8 +922,8 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                         .formUuid("FORM-E132ECE2BED94BCF81D9842B3F2054E7XWQ7")
                         .appType("APP_VQDMMWS6OR1VHL8VMFD3")
                         .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
-                        .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mg4h6mz5", wlbt)))
-//                        .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mfxbtcdh", wlbm)))
+//                        .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mg4h6mz5", wlbt)))
+                        .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mfxbtcdh", wlbm)))
                         .formDataJson(JSONObject.toJSONString(updateFormData))
                         .build(), YDConf.FORM_OPERATION.upsert);
 
@@ -830,6 +1064,83 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
     @Override
     public void synckdYdPayment() {
         log.info("定时同步-收款单");
+        LambdaQueryWrapper<KdYdPaymentReceipt> paymentdel = new LambdaQueryWrapper<>();
+        paymentdel.eq(KdYdPaymentReceipt::getOperationType, 3)
+                .eq(KdYdPaymentReceipt::getSyncStatus, "0");
+        List<KdYdPaymentReceipt> kdYdPaymentReceiptdels = kdYdPaymentReceiptMapper.selectList(paymentdel);
+
+        // 批量删除处理
+        if (!kdYdPaymentReceiptdels.isEmpty()) {
+            log.info("开始处理收款单删除操作,共{}条数据", kdYdPaymentReceiptdels.size());
+            ArrayList<String> deleteList = new ArrayList<>();
+            int deleteSuccessCount = 0;
+
+            for (KdYdPaymentReceipt kdYdPaymentReceipt : kdYdPaymentReceiptdels) {
+                try {
+                    String djbh = kdYdPaymentReceipt.getDjbh();
+                    log.debug("查询需要删除的收款单: djbh={}", djbh);
+
+                    List<Map> list1 = (List<Map>) ydClient.queryData(YDParam.builder()
+                            .formUuid("FORM-0569C06E47074C2981ADEEAFCE083EDAK5AM")
+                            .appType("APP_VQDMMWS6OR1VHL8VMFD3")
+                            .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
+                            .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mh9woamt", djbh)))
+                            .build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
+
+                    if (list1 != null && !list1.isEmpty()) {
+                        for (Map map : list1) {
+                            String formInstanceId = UtilMap.getString(map, "formInstanceId");
+                            if (formInstanceId != null) {
+                                deleteList.add(formInstanceId);
+                            }
+                        }
+                        deleteSuccessCount++;
+
+                        // 同时删除对应的子表数据
+                        Long paymentReceiptId = kdYdPaymentReceipt.getId();
+                        LambdaQueryWrapper<KdYdPaymentReceiptDetail> detailDelqw = new LambdaQueryWrapper<>();
+                        detailDelqw.eq(KdYdPaymentReceiptDetail::getPayreceiptId, paymentReceiptId);
+                        List<KdYdPaymentReceiptDetail> detailDels = kdYdPaymentReceiptDetailMapper.selectList(detailDelqw);
+
+                        if (!detailDels.isEmpty()) {
+                            for (KdYdPaymentReceiptDetail detail : detailDels) {
+                                detail.setSyncStatus("1");
+                                kdYdPaymentReceiptDetailMapper.updateById(detail);
+                            }
+                        }
+                    } else {
+                        log.warn("未找到对应的收款单数据: djbh={}", djbh);
+                    }
+
+                    // 删除操作完成后更新状态
+                    kdYdPaymentReceipt.setSyncStatus("1");
+                    kdYdPaymentReceiptMapper.updateById(kdYdPaymentReceipt);
+
+                } catch (Exception e) {
+                    log.error("删除收款单数据查询异常: djbh={}", kdYdPaymentReceipt.getDjbh(), e);
+                }
+            }
+
+            // 执行批量删除
+            if (!deleteList.isEmpty()) {
+                try {
+                    ydClient.operateData(YDParam.builder()
+                            .formUuid("FORM-0569C06E47074C2981ADEEAFCE083EDAK5AM")
+                            .appType("APP_VQDMMWS6OR1VHL8VMFD3")
+                            .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
+                            .formInstanceIdList(deleteList)
+                            .build(), YDConf.FORM_OPERATION.delete_batch);
+                    log.info("收款单批量删除完成,共删除{}条数据", deleteList.size());
+                } catch (Exception e) {
+                    log.error("收款单批量删除操作异常", e);
+                }
+            }
+
+            log.info("收款单删除操作处理完成: 成功查询={}, 待删除={}", deleteSuccessCount, deleteList.size());
+            return;
+        } else {
+            log.info("【收款单删除任务】无需要删除的数据");
+        }
         LambdaQueryWrapper<KdYdPaymentReceipt> paymentqw = new LambdaQueryWrapper<>();
         paymentqw.eq(KdYdPaymentReceipt::getSyncStatus, "0");
         List<KdYdPaymentReceipt> kdYdPaymentReceipts = kdYdPaymentReceiptMapper.selectList(paymentqw);
@@ -868,7 +1179,8 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     tablemap.put("textField_mh9woao1", kdYdPaymentReceiptDetail.getFyxm());
                     tablemap.put("numberField_mh9woanz", kdYdPaymentReceiptDetail.getSsje() != null ? kdYdPaymentReceiptDetail.getSsje().setScale(2, java.math.RoundingMode.HALF_UP).toString() : java.math.BigDecimal.ZERO.setScale(2, java.math.RoundingMode.HALF_UP).toString());
                     tablemap.put("numberField_mh9woao0", kdYdPaymentReceiptDetail.getZhje() != null ? kdYdPaymentReceiptDetail.getZhje().setScale(2, java.math.RoundingMode.HALF_UP).toString() : java.math.BigDecimal.ZERO.setScale(2, java.math.RoundingMode.HALF_UP).toString());
-
+                    kdYdPaymentReceiptDetail.setSyncStatus("1");
+                    kdYdPaymentReceiptDetailMapper.updateById(kdYdPaymentReceiptDetail);
 //                    tablemap.put("radioField_mf6a0h6h", kdYdOutboundDetail.getSfzp());
                     tableList.add(tablemap);
 
@@ -883,8 +1195,6 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     List<Map> ddlist = (List<Map>) ydClient.queryData(
                             YDParam.builder()
                                     .formUuid("FORM-B62CAE3075CE4098B17BB86C90FFA21C9B7C")
-                                    .appType("APP_VQDMMWS6OR1VHL8VMFD3")
-                                    .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
                                     .searchCondition(JSON.toJSONString(UtilMap.map("serialNumberField_mewfgzku", xsddbh)))
                                     .build(),
                             YDConf.FORM_QUERY.retrieve_list_all
@@ -915,7 +1225,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                 updateMap.put("tableField_mh9woanl", tableList);
                 if (ddbh != null && ddformInstanceId != null) {
                     updateMap.put("associationFormField_mh9woamy",
-                            Arrays.asList(getddAss(ddbh,ddformInstanceId)));
+                            Arrays.asList(getddAss(ddbh, ddformInstanceId)));
                 }
                 updateMap.put("textField_mh9woanm", kdYdPaymentReceipt.getDjlx());
                 updateMap.put("textField_mh9woann", kdYdPaymentReceipt.getFkdwlx());
@@ -936,8 +1246,6 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                 // 添加同步操作(根据您的实际需求添加)
                 ydClient.operateData(YDParam.builder()
                         .formUuid("FORM-0569C06E47074C2981ADEEAFCE083EDAK5AM")
-                        .appType("APP_VQDMMWS6OR1VHL8VMFD3")
-                        .systemToken("XE766X81JHKXK4Z27SYOI86CPCLQ3J1LV7ODMH2")
                         .searchCondition(JSONObject.toJSONString(UtilMap.map("textField_mh9woamt", kdYdPaymentReceipt.getDjbh())))
                         .formDataJson(JSONObject.toJSONString(updateMap))
                         .build(), YDConf.FORM_OPERATION.upsert);
@@ -959,6 +1267,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
         log.info("【收款单同步任务】完成: 成功={}, 失败={}, 总计={}",
                 successCount, failCount, kdYdPaymentReceipts.size());
     }
+
     private Object getddAss(String title, String id) {
         return UtilMap.map("appType, formUuid, formType, instanceId, title, subTitle", "APP_VQDMMWS6OR1VHL8VMFD3", "FORM-B62CAE3075CE4098B17BB86C90FFA21C9B7C", "receipt", id, title, "");
     }
@@ -966,6 +1275,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
     private Object getfhdAss(String title, String id) {
         return UtilMap.map("appType, formUuid, formType, instanceId, title, subTitle", "APP_VQDMMWS6OR1VHL8VMFD3", "FORM-A7F03ACEE01D4F609550C86BF7FE87D35M6I", "receipt", id, title, "");
     }
+
     private Object getysdAss(String title, String id) {
         return UtilMap.map("appType, formUuid, formType, instanceId, title, subTitle", "APP_VQDMMWS6OR1VHL8VMFD3", "FORM-AADBCDA8126F41A0ADDEE3353828583192M8", "receipt", id, title, "");
     }