Selaa lähdekoodia

1.4代码提交

“lqy 1 kuukausi sitten
vanhempi
commit
7b3c71df1a

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

@@ -69,4 +69,6 @@ public class KdYdTransfer implements Serializable {
     private String fkfs;
 
     private String ddbh;
+
+    private String fhtzdbh;
 }

+ 3 - 2
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdDeliveryServiceImpl.java

@@ -119,13 +119,14 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
 
         Long id = kdYdDelivery.getId();
         System.out.println("id:"+id);
-        int count = 1;
+//        int count = 1;
         for (Map item : tableField) {
             String wlbm = safeGetString(item, "textField_mejnamff");
             String wlmc = safeGetString(item, "textField_mejnamfg");
             String ggxh = safeGetString(item, "textField_mejnamfh");
             String xsdw = safeGetString(item, "textField_mejnamfk");
             int jjsl = parseInt(safeGetString(item, "numberField_mf6a0h6r"), 0); // 如果为空或格式错误,返回 0
+            int count = parseInt(safeGetString(item, "numberField_mjzg06br"), 0); // 如果为空或格式错误,返回 0
             String ssxl = safeGetString(item, "textField_mejnamfx");
             String sfzp = safeGetString(item, "radioField_mf6a0h6h");
             String ckck = safeGetString(item, "textField_mf6a0h6l");
@@ -167,7 +168,7 @@ public class KdYdDeliveryServiceImpl extends ServiceImpl<KdYdDeliveryMapper, KdY
                 kdYdDeliveryDetailMapper.insert(kdYdDeliveryDetail);
             }
 
-            count++;
+//            count++;
 //save(kdYdDeliveryDetail);
         }
 //        ydClient.operateData(

+ 120 - 67
mjava-huagao/src/main/java/com/malk/huagao/service/impl/KdYdOrderServiceImpl.java

@@ -66,6 +66,14 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
             kdYdOrderMapper.update(kdYdOrder, new LambdaQueryWrapper<KdYdOrder>().eq(KdYdOrder::getDjbh, bm));
             return; // 或者根据你的业务逻辑返回相应的结果
         }
+        if ("4".equals(type)) {
+            String bm = UtilMap.getString(map, "bm");
+            KdYdOrder kdYdOrder = new KdYdOrder();
+            kdYdOrder.setOperationType("4");
+            kdYdOrder.setSyncStatus("0");
+            kdYdOrderMapper.update(kdYdOrder, new LambdaQueryWrapper<KdYdOrder>().eq(KdYdOrder::getDjbh, bm));
+            return; // 或者根据你的业务逻辑返回相应的结果
+        }
         DDR_New ddrNew = ydClient.queryData(YDParam.builder()
                 .formInstId(formInstId)
                 .build(), YDConf.FORM_QUERY.retrieve_id);
@@ -177,7 +185,7 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
             // 重新遍历,使用 index 作为 detailId
             for (int i = 0; i < tableField.size(); i++) {
                 Map item = tableField.get(i);
-                int detailId = i + 1; // 使用 1-based 序号作为 detailId(必须与前端一致)
+                int detailId = parseInt(safeGetString(item, "numberField_mjzfodew"), 0);
                 incomingDetailIds.add(detailId);
 
                 String wlbm = safeGetString(item, "textField_mfbx1pqt");
@@ -365,31 +373,22 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
             }
 
             Map formData1 = ddrNew.getFormData();
-            String ddje = UtilMap.getString(formData1, "numberField_mewfgzkv");
-            String dddateTimestamp = UtilMap.getString(formData1, "dateField_mejowmnb");
+            String ddje = UtilMap.getString(formData1, "numberField_mfxv2vgj");
 
             // 参数校验
             if (ddje == null || ddje.trim().isEmpty()) {
                 throw new RuntimeException("订单金额不能为空");
             }
-            if (dddateTimestamp == null || dddateTimestamp.trim().isEmpty()) {
-                throw new RuntimeException("订单日期不能为空");
-            }
-
-            System.out.println("获取到的时间戳:" + dddateTimestamp);
 
             // 2. 计算订单金额(保留两位小数)
             Double orderAmount = null;
             try {
                 orderAmount = Double.parseDouble(ddje);
-                // 保留两位小数
                 orderAmount = Math.round(orderAmount * 100.0) / 100.0;
             } catch (NumberFormatException e) {
                 throw new RuntimeException("订单金额格式错误: " + ddje);
             }
 
-            String ghcDateTimestamp = null;
-
             // 3. 查询客户历史信息
             List<Map> list = (List<Map>) ydClient.queryData(YDParam.builder()
                     .formUuid("FORM-F79B680547674A6BBD11C0D511E3C14B28FY")
@@ -402,19 +401,29 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
                     )))
                     .build(), YDConf.FORM_QUERY.retrieve_list_all).getData();
 
-            // 5. 计算累计金额和释放日期
-            Double historicalAmount = 0.0;
-            if (list.size() > 0) {
-                historicalAmount = UtilMap.getDouble(list.get(0), "numberField_mjm9k35k");
-                if (historicalAmount == null) {
-                    historicalAmount = 0.0;
-                } else {
-                    // 历史金额也保留两位小数
-                    historicalAmount = Math.round(historicalAmount * 100.0) / 100.0;
-                }
+            if (list == null || list.isEmpty()) {
+                throw new RuntimeException("未找到客户信息,客户编号:" + khbm);
             }
 
-            // 计算总金额 = 当前订单金额 + 历史累计金额(保留两位小数)
+            // 4. 获取客户现有信息
+            Map customerData = list.get(0);
+            Double historicalAmount = UtilMap.getDouble(customerData, "numberField_mjm9k35k");
+            String dddateTimestampStr = UtilMap.getString(customerData, "dateField_mjqkkcsg");
+            String sfdateTimestampStr = UtilMap.getString(customerData, "dateField_mjm9k35l");
+
+            // 参数校验
+            if (dddateTimestampStr == null || dddateTimestampStr.trim().isEmpty()) {
+                throw new RuntimeException("最后成交日期不能为空");
+            }
+
+            // 处理历史金额
+            if (historicalAmount == null) {
+                historicalAmount = 0.0;
+            } else {
+                historicalAmount = Math.round(historicalAmount * 100.0) / 100.0;
+            }
+
+            // 5. 计算总金额
             Double totalAmount = orderAmount + historicalAmount;
             totalAmount = Math.round(totalAmount * 100.0) / 100.0;
 
@@ -422,47 +431,93 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
                     ", 历史金额=" + historicalAmount +
                     ", 总金额=" + totalAmount);
 
-            // 6. 根据总金额计算释放公海池日期
-            long baseTimestamp = Long.parseLong(dddateTimestamp.trim());
-            // 7. 更新客户信息
-            Map<String, Object> formData = new HashMap<>();
-            if (totalAmount == null || totalAmount <= 0) {
-                // 情况4:无订单/金额为空或0 → +90天
-                ghcDateTimestamp = String.valueOf(calculateTimestamp(baseTimestamp, 90));
-                formData.put("selectField_l3nrjuq0", "未成交");
-                System.out.println("情况4:无金额,释放日期=" + ghcDateTimestamp);
-            } else if (totalAmount < 75000) {
-                // 情况1:金额 < 7.5万 → +180天
-                ghcDateTimestamp = String.valueOf(calculateTimestamp(baseTimestamp, 180));
-                formData.put("selectField_l3nrjuq0", "半年金额不足");
-                System.out.println("情况1:金额<7.5万,释放日期=" + ghcDateTimestamp);
-            } else if (totalAmount < 150000) {
-                // 情况2:7.5万 ≤ 金额 < 15万 → +360天
-                ghcDateTimestamp = String.valueOf(calculateTimestamp(baseTimestamp, 360));
-                formData.put("selectField_l3nrjuq0", "一年金额不足");
-                System.out.println("情况2:金额7.5-15万,释放日期=" + ghcDateTimestamp);
-            } else {
-                // 情况3:金额 ≥ 15万 → 空值(不释放)
-                ghcDateTimestamp = null;
-                System.out.println("情况3:金额≥15万,不释放公海池");
+            // 6. 时间戳转换
+            long dddateTimestamp = Long.parseLong(dddateTimestampStr.trim());
+            long currentTimestamp = System.currentTimeMillis();
+            long sfdateTimestamp = (sfdateTimestampStr != null && !sfdateTimestampStr.trim().isEmpty())
+                    ? Long.parseLong(sfdateTimestampStr.trim()) : 0;
+
+            // 计算时间差(天数)
+            long currentToDdDays = (currentTimestamp - dddateTimestamp) / (1000 * 60 * 60 * 24);
+            long sfToDdDays = (sfdateTimestamp > 0) ? (sfdateTimestamp - dddateTimestamp) / (1000 * 60 * 60 * 24) : 0;
+
+            System.out.println("时间计算:当前时间-" + timestampToDateString(String.valueOf(currentTimestamp)) +
+                    ", 成交日期-" + timestampToDateString(dddateTimestampStr) +
+                    ", 当前-成交相差=" + currentToDdDays + "天" +
+                    ", 公海-成交相差=" + sfToDdDays + "天");
+
+            String ghcDateTimestamp = null;
+            String selectFieldValue = "";
+            String khsx = "";
+
+// 1. 设置客户属性(单独判断)
+            if(totalAmount >= 75000 && sfToDdDays <= 180){
+                khsx = "自行开发";
             }
 
+// 2. 第一个条件:当前时间-成交日期<90天 且 总金额>0 且 公海日期-成交日期≈180天
+            if (currentToDdDays < 90 && totalAmount > 0 && Math.abs(sfToDdDays - 180) <= 1) {
+                // 在成交日期上加90天
+                ghcDateTimestamp = String.valueOf(calculateTimestamp(sfdateTimestamp, 90));
+                selectFieldValue = "半年金额不足";
+                System.out.println("条件1触发:公海池时间设为成交日期+90天=" +
+                        timestampToDateString(ghcDateTimestamp));
+            }
+// 3. 第二个条件:总金额≥7.5万 且 公海日期-成交日期≤180天
+            else if (totalAmount >= 75000 && sfToDdDays <= 180) {
+                // 在成交日期上加180天
+                ghcDateTimestamp = String.valueOf(calculateTimestamp(sfdateTimestamp, 180));
+                selectFieldValue = "半年金额不足";
+                System.out.println("条件2触发:公海池时间设为成交日期+180天=" +
+                        timestampToDateString(ghcDateTimestamp));
+            }
+// 4. 第三个条件:金额<15万 且 公海日期-成交日期>180天
+            else if (totalAmount < 150000 && sfToDdDays > 180) {
+                selectFieldValue = "一年金额不足";
+                System.out.println("条件3触发:金额<15万且公海日期>180天,设置一年金额不足");
+            }
+// 5. 其他情况
+            else {
+                if (totalAmount > 0) {
+                    // 基础情况:金额大于0
+                    ghcDateTimestamp = String.valueOf(calculateTimestamp(sfdateTimestamp, 90));
+                    selectFieldValue = "半年金额不足";
+                    System.out.println("基础情况:金额大于0,公海池时间+90天=" +
+                            timestampToDateString(ghcDateTimestamp));
+                } else if (totalAmount < 75000) {
+                    // 金额 < 7.5万
+                    selectFieldValue = "半年金额不足";
+                    System.out.println("金额<7.5万,但未设置公海池时间");
+                } else if (totalAmount < 150000) {
+                    // 7.5万 ≤ 金额 < 15万
+                    selectFieldValue = "一年金额不足";
+                    System.out.println("金额7.5-15万,但未设置公海池时间");
+                }
+            }
 
-            // 重要:直接保存时间戳格式,不是格式化后的日期
-            formData.put("dateField_mjm9k35j", dddateTimestamp); // 最后成交日期(时间戳格式)
+
+            // 8. 构建更新数据
+            Map<String, Object> formData = new HashMap<>();
+            formData.put("dateField_mjm9k35j", dddateTimestampStr); // 最后成交日期(保持原时间戳)
+
+            // 只有selectField有值时才设置
+            if (!selectFieldValue.isEmpty()) {
+                formData.put("selectField_l3nrjuq0", selectFieldValue);
+            }
 
             if (ghcDateTimestamp != null) {
-                formData.put("dateField_mjm9k35l", ghcDateTimestamp); // 释放公海日期(时间戳格式)
+                formData.put("dateField_mjm9k35l", ghcDateTimestamp); // 释放公海日期
             } else {
                 formData.put("dateField_mjm9k35l", ""); // 明确设置为空
             }
 
             // 更新累计金额(保留两位小数)
             formData.put("numberField_mjm9k35k", totalAmount);
+            formData.put("selectField_mjsco9d4", khsx);
 
             System.out.println("更新客户数据:" + formData);
 
-            // 执行更新操作
+            // 9. 执行更新操作
             ydClient.operateData(YDParam.builder()
                     .formUuid("FORM-F79B680547674A6BBD11C0D511E3C14B28FY")
                     .appType("APP_VQDMMWS6OR1VHL8VMFD3")
@@ -481,7 +536,6 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
             System.out.println("客户信息更新成功,客户编号:" + khbm);
 
         } catch (Exception e) {
-            // 添加错误日志
             System.err.println("处理订单失败: " + e.getMessage());
             e.printStackTrace();
             throw new RuntimeException("处理订单失败: " + e.getMessage(), e);
@@ -498,24 +552,11 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
      */
     private long calculateTimestamp(long baseTimestamp, int days) {
         try {
-            // 1天 = 24小时 * 60分钟 * 60秒 * 1000毫秒
             long oneDayMillis = 24L * 60L * 60L * 1000L;
-            long daysMillis = days * oneDayMillis;
-
-            long resultTimestamp = baseTimestamp + daysMillis;
-
-            // 输出调试信息
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-            String baseDate = sdf.format(new Date(baseTimestamp));
-            String resultDate = sdf.format(new Date(resultTimestamp));
-
-            System.out.println("时间戳计算:" + baseDate + " (" + baseTimestamp + ") + " +
-                    days + "天 = " + resultDate + " (" + resultTimestamp + ")");
-
-            return resultTimestamp;
+            long daysMillis = (long) days * oneDayMillis;
+            return baseTimestamp + daysMillis;
         } catch (Exception e) {
-            System.err.println("时间戳计算失败:" + baseTimestamp + ", 天数:" + days + ", 错误:" + e.getMessage());
-            // 如果计算失败,返回一个默认值(基础时间戳 + 大致的天数)
+            System.err.println("时间戳计算失败:" + baseTimestamp + ", 天数:" + days);
             return baseTimestamp + (days * 24L * 60L * 60L * 1000L);
         }
     }
@@ -526,13 +567,25 @@ public class KdYdOrderServiceImpl extends ServiceImpl<KdYdOrderMapper, KdYdOrder
     private String timestampToDateString(String timestamp) {
         try {
             long ts = Long.parseLong(timestamp.trim());
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             return sdf.format(new Date(ts));
         } catch (Exception e) {
             return "无效时间戳:" + timestamp;
         }
     }
 
+    /**
+     * 重载方法:直接接收long类型时间戳
+     */
+    private String timestampToDateString(long timestamp) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            return sdf.format(new Date(timestamp));
+        } catch (Exception e) {
+            return "无效时间戳:" + timestamp;
+        }
+    }
+
     private static LocalDateTime parseTimestamp(String timestampStr) {
         if (timestampStr == null || timestampStr.trim().isEmpty()) return null;
         try {

+ 29 - 3
mjava-huagao/src/main/java/com/malk/huagao/service/impl/YdHuaGaoServiceImpl.java

@@ -1455,8 +1455,11 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
 
                 }
                 String xsddbh = kdYdTransfer.getDdbh();
+                String fhtzdbh = kdYdTransfer.getFhtzdbh();
                 String ddformInstanceId = null;
+                String fhdformInstanceId = null;
                 String ddbh = null;
+                String fhdbh = null;
                 String jydate = null;
                 String ghrq = null;
                 String jyyy = null;
@@ -1472,11 +1475,31 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     List<Map<String, Object>> ddlist = (List<Map<String, Object>>) ydClient.queryData(
                             YDParam.builder()
                                     .formUuid("FORM-B62CAE3075CE4098B17BB86C90FFA21C9B7C")
-                                    .searchCondition(JSON.toJSONString(UtilMap.map("textField_mjs6fuwo", xsddbh)))
+                                    .searchCondition(JSON.toJSONString(UtilMap.map("serialNumberField_mheazm7w", fhtzdbh)))
                                     .build(),
                             YDConf.FORM_QUERY.retrieve_list_all
                     ).getData();
 
+                    List<Map<String, Object>> fhdlist = (List<Map<String, Object>>) ydClient.queryData(
+                            YDParam.builder()
+                                    .formUuid("FORM-A7F03ACEE01D4F609550C86BF7FE87D35M6I")
+                                    .searchCondition(JSON.toJSONString(UtilMap.map("textField_mjs6fuwo", xsddbh)))
+                                    .build(),
+                            YDConf.FORM_QUERY.retrieve_list_all
+                    ).getData();
+                    if (fhdlist != null && !fhdlist.isEmpty()) {
+                        for (Map<String, Object> fhditem : fhdlist) {
+                            Map<String, Object> fhdformData = (Map<String, Object>) fhditem.get("formData");
+                            if (fhdformData == null) continue;
+                            Object serialObj1 = fhdformData.get("serialNumberField_mheazm7w");
+                            String serialStr1 = serialObj1 != null ? serialObj1.toString() : null;
+                            if (fhtzdbh.equals(serialStr1)) {
+                                fhdformInstanceId = safeToString(fhditem.get("formInstanceId"));
+                                fhdbh = serialStr1;
+                                break;
+                            }
+                        }
+                    }
                     if (ddlist != null && !ddlist.isEmpty()) {
                         for (Map<String, Object> khitem : ddlist) {
                             Map<String, Object> khformData = (Map<String, Object>) khitem.get("formData");
@@ -1519,7 +1542,11 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     updateMap.put("associationFormField_mhubzsaf",
                             Collections.singletonList(getddAss(ddbh, ddformInstanceId)));
                 }
+                if (fhdbh != null && fhdformInstanceId != null) {
+                    updateMap.put("associationFormField_mjzervdt",
+                            Collections.singletonList(getddAss(fhdbh, fhdformInstanceId)));
 
+                }
 // 只有所有必要字段都非空时才填充关联字段
                 if (jydate != null && ghrq != null && jyyy != null && jtyy != null
                         && xsy != null && khxypj != null) {
@@ -1530,10 +1557,9 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
                     updateMap.put("textareaField_meqpbxsd", jtyy); // 注意:原代码这里写成了 jyyy,已修正为 jtyy
                     updateMap.put("employeeField_mejowmng", xsy);
                     updateMap.put("selectField_mewirdx4", khxypj);
-
                     updateMap.put("attachmentField_mfoqcctz", fj);
                 }
-
+                updateMap.put("textField_mjzervdu", kdYdTransfer.getFhtzdbh());
 // 基础字段同步(这些字段即使为空也会覆盖,符合原逻辑)
                 updateMap.put("textField_miquh5zj", ddformInstanceId);
                 updateMap.put("selectField_mhubzsa5", kdYdTransfer.getDjlx());

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

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: dev
+    active: prod
   servlet:
     multipart:
       max-file-size: 100MB