|
|
@@ -146,11 +146,11 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
try {
|
|
|
String bm = kdYdOrder.getDjbh();
|
|
|
// String tjruuid = kdYdOrder.getTjruuid();
|
|
|
- String formInstId = kdYdOrder.getForminstid();
|
|
|
- if (ObjectUtil.hasEmpty(formInstId, bm)) {
|
|
|
- log.warn("跳过同步: formInstId 或 khbm 为空, customer={}", kdYdOrder.getId());
|
|
|
- continue;
|
|
|
- }
|
|
|
+// String formInstId = kdYdOrder.getForminstid();
|
|
|
+// if (ObjectUtil.hasEmpty(formInstId, bm)) {
|
|
|
+// log.warn("跳过同步: formInstId 或 khbm 为空, customer={}", kdYdOrder.getId());
|
|
|
+// continue;
|
|
|
+// }
|
|
|
// if (tjruuid == null) {
|
|
|
// List<Map> khdata = (List<Map>) ydClient.queryData(
|
|
|
// YDParam.builder()
|
|
|
@@ -174,12 +174,12 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
// .useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
|
|
|
ydClient.operateData(
|
|
|
YDParam.builder()
|
|
|
- .formInstanceId(formInstId)
|
|
|
+// .formInstanceId(formInstId)
|
|
|
.updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_mg327tqe", bm)))
|
|
|
.useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- log.error("同步单条订单数据异常: formInstId={}", kdYdOrder.getForminstid(), e);
|
|
|
+// log.error("同步单条订单数据异常: formInstId={}", kdYdOrder.getForminstid(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -207,20 +207,20 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
try {
|
|
|
String djbh = kdYdDelivery.getDjbh();
|
|
|
// String tjruuid = kdYdOrder.getTjruuid();
|
|
|
- String formInstId = kdYdDelivery.getForminstid();
|
|
|
- if (ObjectUtil.hasEmpty(formInstId, djbh)) {
|
|
|
- log.warn("跳过同步: formInstId 或 khbm 为空, customer={}", kdYdDelivery.getId());
|
|
|
- continue;
|
|
|
- }
|
|
|
+// String formInstId = kdYdDelivery.getForminstid();
|
|
|
+// if (ObjectUtil.hasEmpty(formInstId, djbh)) {
|
|
|
+// log.warn("跳过同步: formInstId 或 khbm 为空, customer={}", kdYdDelivery.getId());
|
|
|
+// continue;
|
|
|
+// }
|
|
|
|
|
|
ydClient.operateData(
|
|
|
YDParam.builder()
|
|
|
- .formInstanceId(formInstId)
|
|
|
+// .formInstanceId(formInstId)
|
|
|
.updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_mg3fuqvh", djbh)))
|
|
|
.useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- log.error("同步单条发货单数据异常: formInstId={}", kdYdDelivery.getForminstid(), e);
|
|
|
+// log.error("同步单条发货单数据异常: formInstId={}", kdYdDelivery.getForminstid(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -332,8 +332,10 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
List<KdYdOutboundDetail> kdYdOutboundDetails = kdYdOutboundDetailMapper.selectList(outbounddetailqw);
|
|
|
|
|
|
ArrayList<Object> tableList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> tableListxlh = new ArrayList<>();
|
|
|
for (KdYdOutboundDetail kdYdOutboundDetail : kdYdOutboundDetails) {
|
|
|
HashMap<String, String> tablemap = new HashMap<>();
|
|
|
+ HashMap<String, String> tablemapxlh = new HashMap<>();
|
|
|
tablemap.put("textField_mejnamff", kdYdOutboundDetail.getWlbm());
|
|
|
tablemap.put("textField_mejnamfg", kdYdOutboundDetail.getWlmc());
|
|
|
tablemap.put("textField_mg34txh1", kdYdOutboundDetail.getTpsb());
|
|
|
@@ -363,7 +365,19 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
tablemap.put("textField_mhlqeoat", kdYdOutboundDetail.getZbqsf());
|
|
|
tablemap.put("textField_mf6a0h6x", kdYdOutboundDetail.getKddh());
|
|
|
tablemap.put("textField_mf6a0h6y", kdYdOutboundDetail.getJx());
|
|
|
-// tablemap.put("radioField_mf6a0h6h", kdYdOutboundDetail.getSfzp());
|
|
|
+ String xlhjh = kdYdOutboundDetail.getXlh();
|
|
|
+ if (xlhjh != null && !xlhjh.trim().isEmpty()) {
|
|
|
+ tableListxlh = Arrays.stream(xlhjh.split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .filter(item -> !item.isEmpty())
|
|
|
+ .map(item -> {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("textField_mf6a0h6w", item);
|
|
|
+ return map;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ tablemap.put("radioField_mf6a0h6h", kdYdOutboundDetail.getSfzp());
|
|
|
tableList.add(tablemap);
|
|
|
kdYdOutboundDetail.setSyncStatus("1");
|
|
|
kdYdOutboundDetailMapper.updateById(kdYdOutboundDetail);
|
|
|
@@ -409,11 +423,12 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
}
|
|
|
HashMap<Object, Object> updateMap = new HashMap<>();
|
|
|
updateMap.put("tableField_mejnamfd", tableList);
|
|
|
+ updateMap.put("tableField_migw33w7", tableListxlh);
|
|
|
if (fhdbh != null && fhdformInstanceId != null) {
|
|
|
updateMap.put("associationFormField_mejmml36",
|
|
|
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("dateField_krbgloam", kdYdOutbound.getDateTime() != null ? String.valueOf(kdYdOutbound.getDateTime().atZone(java.time.ZoneId.systemDefault()).toInstant().toEpochMilli()) : "");
|
|
|
updateMap.put("textField_krnn5bmr", kdYdOutbound.getXsDept());
|
|
|
updateMap.put("textField_mhjxw689", kdYdOutbound.getFhDept());
|
|
|
updateMap.put("textField_mhjxw686", kdYdOutbound.getCgy());
|
|
|
@@ -427,6 +442,7 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
updateMap.put("selectField_megi74y8", kdYdOutbound.getKhsx());
|
|
|
updateMap.put("textField_mg34txgy", kdYdOutbound.getKhtjr());
|
|
|
updateMap.put("textField_mg34txgz", kdYdOutbound.getYsdh());
|
|
|
+ updateMap.put("textField_migw33w6", deliveryId);
|
|
|
|
|
|
// 添加同步操作(根据您的实际需求添加)
|
|
|
ydClient.operateData(YDParam.builder()
|
|
|
@@ -769,20 +785,20 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
try {
|
|
|
String djbh = kdYdZp.getDjbh();
|
|
|
String fph = kdYdZp.getFph();
|
|
|
- String formInstId = kdYdZp.getForminstid();
|
|
|
- if (ObjectUtil.hasEmpty(formInstId, djbh, fph)) {
|
|
|
- log.warn("跳过同步: formInstId 或 khbm 为空, customer={}", kdYdZp.getId());
|
|
|
- continue;
|
|
|
- }
|
|
|
+// String formInstId = kdYdZp.getForminstid();
|
|
|
+// if (ObjectUtil.hasEmpty(formInstId, djbh, fph)) {
|
|
|
+// log.warn("跳过同步: formInstId 或 khbm 为空, customer={}", kdYdZp.getId());
|
|
|
+// continue;
|
|
|
+// }
|
|
|
|
|
|
ydClient.operateData(
|
|
|
YDParam.builder()
|
|
|
- .formInstanceId(formInstId)
|
|
|
+// .formInstanceId(formInstId)
|
|
|
.updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_mgt6lcqq, textField_mejmml3a", djbh, fph)))
|
|
|
.useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- log.error("同步单条发票单数据异常: formInstId={}", kdYdZp.getForminstid(), e);
|
|
|
+// log.error("同步单条发票单数据异常: formInstId={}", kdYdZp.getForminstid(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -973,89 +989,89 @@ public class YdHuaGaoServiceImpl implements YdHuaGaoService {
|
|
|
.collect(Collectors.toMap(KdYdDelivery::getId, d -> d));
|
|
|
|
|
|
// 4. 按 formInstId 分组,减少 API 调用次数
|
|
|
- Map<String, List<KdYdDeliveryDetail>> detailsByFormInstId = kdYdDeliveryDetails.stream()
|
|
|
- .filter(detail -> deliveryMap.containsKey(detail.getDeliveryId()))
|
|
|
- .collect(Collectors.groupingBy(detail -> {
|
|
|
- KdYdDelivery main = deliveryMap.get(detail.getDeliveryId());
|
|
|
- return main != null ? main.getForminstid() : null;
|
|
|
- }));
|
|
|
+// Map<String, List<KdYdDeliveryDetail>> detailsByFormInstId = kdYdDeliveryDetails.stream()
|
|
|
+// .filter(detail -> deliveryMap.containsKey(detail.getDeliveryId()))
|
|
|
+// .collect(Collectors.groupingBy(detail -> {
|
|
|
+// KdYdDelivery main = deliveryMap.get(detail.getDeliveryId());
|
|
|
+// return main != null ? main.getForminstid() : null;
|
|
|
+// }));
|
|
|
|
|
|
int successCount = 0;
|
|
|
int errorCount = 0;
|
|
|
|
|
|
// 5. 遍历每个 formInstId,只调用一次 query + 一次 update
|
|
|
- for (Map.Entry<String, List<KdYdDeliveryDetail>> entry : detailsByFormInstId.entrySet()) {
|
|
|
- String formInstId = entry.getKey();
|
|
|
- if (formInstId == null || formInstId.trim().isEmpty()) {
|
|
|
- log.warn("跳过空 formInstId 的记录");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- // 查询当前表单数据
|
|
|
- Map formData = ydClient.queryData(
|
|
|
- YDParam.builder()
|
|
|
- .formInstId(formInstId)
|
|
|
- .appType(ydConf.getAppType())
|
|
|
- .systemToken(ydConf.getSystemToken())
|
|
|
- .userId(ddConf.getOperator())
|
|
|
- .build(),
|
|
|
- YDConf.FORM_QUERY.retrieve_id
|
|
|
- ).getFormData();
|
|
|
-
|
|
|
- if (formData == null) {
|
|
|
- log.warn("formInstId={} 的 formData 为空", formInstId);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- List<Map<String, Object>> tableData = (List<Map<String, Object>>) formData.get("tableField_mejnamfd");
|
|
|
- if (tableData == null || tableData.isEmpty()) {
|
|
|
- log.warn("formInstId={} 的子表 tableField_mejnamfd 为空", formInstId);
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 标记是否需要更新
|
|
|
- boolean modified = false;
|
|
|
-
|
|
|
- // 处理当前 formInstId 下的所有待同步 detail
|
|
|
- for (KdYdDeliveryDetail detail : entry.getValue()) {
|
|
|
- String wlbm = detail.getWlbm();
|
|
|
- String mdh = detail.getMdh();
|
|
|
-
|
|
|
- for (Map<String, Object> row : tableData) {
|
|
|
- Object wlbmIdObj = row.get("textField_mejnamff");
|
|
|
- if (wlbmIdObj != null && wlbm.equals(wlbmIdObj.toString())) {
|
|
|
- row.put("textField_mf6a0h6y", mdh);
|
|
|
- modified = true;
|
|
|
- successCount++;
|
|
|
- break; // 找到匹配行即可跳出
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 只有修改了才提交
|
|
|
- if (modified) {
|
|
|
- ydClient.operateData(
|
|
|
- YDParam.builder()
|
|
|
- .formInstanceId(formInstId)
|
|
|
- .updateFormDataJson(JSON.toJSONString(Collections.singletonMap("tableField_mejnamfd", tableData)))
|
|
|
- .useLatestVersion(true)
|
|
|
- .build(),
|
|
|
- YDConf.FORM_OPERATION.update
|
|
|
- );
|
|
|
- log.debug("已更新 formInstId={} 的子表数据", formInstId);
|
|
|
- } else {
|
|
|
- log.debug("formInstId={} 无需更新", formInstId);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- errorCount += entry.getValue().size(); // 统计失败数量
|
|
|
- log.error("同步 formInstId={} 时发生异常", formInstId, e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- log.info("【发货详情单同步任务】执行完成,共处理 {} 条记录,成功 {} 条,失败 {} 条",
|
|
|
- kdYdDeliveryDetails.size(), successCount, errorCount);
|
|
|
-
|
|
|
+// for (Map.Entry<String, List<KdYdDeliveryDetail>> entry : detailsByFormInstId.entrySet()) {
|
|
|
+// String formInstId = entry.getKey();
|
|
|
+// if (formInstId == null || formInstId.trim().isEmpty()) {
|
|
|
+// log.warn("跳过空 formInstId 的记录");
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// try {
|
|
|
+// // 查询当前表单数据
|
|
|
+// Map formData = ydClient.queryData(
|
|
|
+// YDParam.builder()
|
|
|
+// .formInstId(formInstId)
|
|
|
+// .appType(ydConf.getAppType())
|
|
|
+// .systemToken(ydConf.getSystemToken())
|
|
|
+// .userId(ddConf.getOperator())
|
|
|
+// .build(),
|
|
|
+// YDConf.FORM_QUERY.retrieve_id
|
|
|
+// ).getFormData();
|
|
|
+//
|
|
|
+// if (formData == null) {
|
|
|
+// log.warn("formInstId={} 的 formData 为空", formInstId);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<Map<String, Object>> tableData = (List<Map<String, Object>>) formData.get("tableField_mejnamfd");
|
|
|
+// if (tableData == null || tableData.isEmpty()) {
|
|
|
+// log.warn("formInstId={} 的子表 tableField_mejnamfd 为空", formInstId);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// // 标记是否需要更新
|
|
|
+// boolean modified = false;
|
|
|
+//
|
|
|
+// // 处理当前 formInstId 下的所有待同步 detail
|
|
|
+// for (KdYdDeliveryDetail detail : entry.getValue()) {
|
|
|
+// String wlbm = detail.getWlbm();
|
|
|
+// String mdh = detail.getMdh();
|
|
|
+//
|
|
|
+// for (Map<String, Object> row : tableData) {
|
|
|
+// Object wlbmIdObj = row.get("textField_mejnamff");
|
|
|
+// if (wlbmIdObj != null && wlbm.equals(wlbmIdObj.toString())) {
|
|
|
+// row.put("textField_mf6a0h6y", mdh);
|
|
|
+// modified = true;
|
|
|
+// successCount++;
|
|
|
+// break; // 找到匹配行即可跳出
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 只有修改了才提交
|
|
|
+// if (modified) {
|
|
|
+// ydClient.operateData(
|
|
|
+// YDParam.builder()
|
|
|
+// .formInstanceId(formInstId)
|
|
|
+// .updateFormDataJson(JSON.toJSONString(Collections.singletonMap("tableField_mejnamfd", tableData)))
|
|
|
+// .useLatestVersion(true)
|
|
|
+// .build(),
|
|
|
+// YDConf.FORM_OPERATION.update
|
|
|
+// );
|
|
|
+// log.debug("已更新 formInstId={} 的子表数据", formInstId);
|
|
|
+// } else {
|
|
|
+// log.debug("formInstId={} 无需更新", formInstId);
|
|
|
+// }
|
|
|
+//
|
|
|
+// } catch (Exception e) {
|
|
|
+// errorCount += entry.getValue().size(); // 统计失败数量
|
|
|
+// log.error("同步 formInstId={} 时发生异常", formInstId, e);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// log.info("【发货详情单同步任务】执行完成,共处理 {} 条记录,成功 {} 条,失败 {} 条",
|
|
|
+// kdYdDeliveryDetails.size(), successCount, errorCount);
|
|
|
+//
|
|
|
} catch (Exception e) {
|
|
|
log.error("【发货单同步任务】执行过程中发生严重错误", e);
|
|
|
}
|