|
|
@@ -153,6 +153,54 @@ public class FImplService implements FService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncAgingToProject() {
|
|
|
+ List<Map> dataList = ydService.queryFormData_all(_initLYParam()
|
|
|
+ .formUuid("FORM-EC785A5AB2B9432C892062823EB7C62A9NTL")
|
|
|
+ .build());
|
|
|
+ // 2. 核心代码:双层分组汇总
|
|
|
+ // 第一级按 "项目点编号" 分组
|
|
|
+ // 第二级按 "开票周期文本" 分组,并对 "含税小计" 求和
|
|
|
+ Map<String, Map<String, Double>> result = dataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ map -> (String) map.get("textField_m25j5gxk"), // 第一级分类器
|
|
|
+ Collectors.groupingBy(
|
|
|
+ map -> (String) map.get("textField_m25j5gxv"), // 第二级分类器
|
|
|
+ Collectors.summingDouble(
|
|
|
+ map -> ((Number) map.get("numberField_lvdnme0z_value")).doubleValue() // 汇总器,处理不同的Number类型
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ List<Map> projectList = ydService.queryFormData_all(_initLYParam()
|
|
|
+ .formUuid("FORM-97BA6C6C8C50416A9E5854F2F4B5C3F3R4WC")
|
|
|
+ .build());
|
|
|
+ result.forEach((k,v)->{
|
|
|
+ projectList.forEach(p->{
|
|
|
+ if (p.get("textField_ltxrn8h1").equals(k)){
|
|
|
+ Map<String, Double> stringDoubleMap = result.get(k);
|
|
|
+ List<Map> sonList = ydService.queryDetails(_initLYParam()
|
|
|
+ .formInstanceId(p.get("formInstanceId").toString())
|
|
|
+ .formUuid("FORM-97BA6C6C8C50416A9E5854F2F4B5C3F3R4WC")
|
|
|
+ .tableFieldId("tableField_lrru2tnq")
|
|
|
+ .build());
|
|
|
+ stringDoubleMap.forEach((k1,v1)->{
|
|
|
+ sonList.forEach(s->{
|
|
|
+ if (s.get("textField_luh0k82j").equals(k1)){
|
|
|
+ s.put("numberField_lrru2to2",stringDoubleMap.get(k1));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ ydClient.operateData(_initLYParam()
|
|
|
+ .formInstanceId(p.get("formInstanceId").toString())
|
|
|
+ //类型,名称,成本编号
|
|
|
+ .updateFormDataJson(JSON.toJSONString(UtilMap.map("tableField_lrru2tnq", sonList)))
|
|
|
+ .useLatestVersion(true)
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 蓝云, 全量同步账龄表 [todo 后续可调整为同步前一天更新数据]
|
|
|
@@ -195,88 +243,88 @@ public class FImplService implements FService {
|
|
|
|
|
|
// 明细处理为主表记录, 以明细形式写入
|
|
|
for (Map formData : dataList) {
|
|
|
- //子表唯一标识
|
|
|
- String compId_type = UtilMap.getString(compIds, UtilMap.getString(formData, "selectField_lvc9x4vn"));
|
|
|
- List<Map> details = UtilMap.getList(formData, compId_type);
|
|
|
- log.info("账龄表同步, {}, {}, {}", UtilMap.getString(formData, "selectField_lvc9x4vn"), formData.get("formInstanceId"), details.size());
|
|
|
- if (details.isEmpty()) {
|
|
|
- continue;
|
|
|
+ //子表唯一标识
|
|
|
+ String compId_type = UtilMap.getString(compIds, UtilMap.getString(formData, "selectField_lvc9x4vn"));
|
|
|
+ List<Map> details = UtilMap.getList(formData, compId_type);
|
|
|
+ log.info("账龄表同步, {}, {}, {}", UtilMap.getString(formData, "selectField_lvc9x4vn"), formData.get("formInstanceId"), details.size());
|
|
|
+ if (details.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 主表字段匹配 kpdh_gl
|
|
|
+ Map dataForm = UtilMap.empty();
|
|
|
+ for (Object key : compId_main.keySet()) {
|
|
|
+ if ("kpdh_gl".equals(compId_main.get(key))) {
|
|
|
+ dataForm.put(key, YDConf.associationForm("APP_ERBDTFS82HOVBPL3NFH0", "FORM-6603375ED27B4D059CBB919C2BEFA44BZVOL", UtilMap.getString(formData, "formInstanceId"), UtilMap.getString(formData, "textField_lvdosccc"), null, false));
|
|
|
+ } else {
|
|
|
+ dataForm.put(key, formData.get(compId_main.get(key)));
|
|
|
}
|
|
|
- // 主表字段匹配 kpdh_gl
|
|
|
- Map dataForm = UtilMap.empty();
|
|
|
- for (Object key : compId_main.keySet()) {
|
|
|
- if ("kpdh_gl".equals(compId_main.get(key))) {
|
|
|
- dataForm.put(key, YDConf.associationForm("APP_ERBDTFS82HOVBPL3NFH0", "FORM-6603375ED27B4D059CBB919C2BEFA44BZVOL", UtilMap.getString(formData, "formInstanceId"), UtilMap.getString(formData, "textField_lvdosccc"), null, false));
|
|
|
- } else {
|
|
|
- dataForm.put(key, formData.get(compId_main.get(key)));
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 子表数据匹配 _wb
|
|
|
+ for (Map detail : details) {
|
|
|
+ // 唯一条件: 单据编号 + 业务类型 + 开票周期 + UUID + 物料名称 (ppExt: 同一个开票周期下, 会有不同物料名称) [作废重开编号不一样]
|
|
|
+ String compId_date = (String) UtilMap.getList(compIds_tab, compId_type).get(0);
|
|
|
+ long kpzq = UtilMap.getLong(detail, compId_date);
|
|
|
+ if (kpzq == 0) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- // 子表数据匹配 _wb
|
|
|
- for (Map detail : details) {
|
|
|
- // 唯一条件: 单据编号 + 业务类型 + 开票周期 + UUID + 物料名称 (ppExt: 同一个开票周期下, 会有不同物料名称) [作废重开编号不一样]
|
|
|
- String compId_date = (String) UtilMap.getList(compIds_tab, compId_type).get(0);
|
|
|
- long kpzq = UtilMap.getLong(detail, compId_date);
|
|
|
- if (kpzq == 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- String material = "", uuid = ""; // 物料取值关联表单, uuid为避免重复
|
|
|
- List<String> arrCompId = UtilMap.getList(compIds_tab, compId_type);
|
|
|
- for (int i = 0; i < arrCompId.size(); i++) {
|
|
|
- String key = compId_detail.get(i);
|
|
|
- if (key.equals("textField_m5aes96o")) {
|
|
|
- String cId = arrCompId.get(i) + "_id";
|
|
|
- if (!detail.containsKey(cId)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- List<Map> associations = (List<Map>) JSON.parse(String.valueOf(JSON.parse(UtilMap.getString(detail, cId))));
|
|
|
- material = UtilMap.getString(associations.get(0), "title");
|
|
|
- dataForm.put(key, material);
|
|
|
- } else if (arrCompId.get(i).contains("dateField_")) {
|
|
|
- String cId = arrCompId.get(i).replace("_wb", "");
|
|
|
- if (!detail.containsKey(cId)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- long tm = UtilMap.getLong(detail, cId);
|
|
|
- if (tm == 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (arrCompId.get(i).contains("_wb")) {
|
|
|
- dataForm.put(key, UtilDateTime.format(new Date(tm), "yyyy-MM"));
|
|
|
- } else {
|
|
|
- dataForm.put(key, tm);
|
|
|
- }
|
|
|
+ String material = "", uuid = ""; // 物料取值关联表单, uuid为避免重复
|
|
|
+ List<String> arrCompId = UtilMap.getList(compIds_tab, compId_type);
|
|
|
+ for (int i = 0; i < arrCompId.size(); i++) {
|
|
|
+ String key = compId_detail.get(i);
|
|
|
+ if (key.equals("textField_m5aes96o")) {
|
|
|
+ String cId = arrCompId.get(i) + "_id";
|
|
|
+ if (!detail.containsKey(cId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Map> associations = (List<Map>) JSON.parse(String.valueOf(JSON.parse(UtilMap.getString(detail, cId))));
|
|
|
+ material = UtilMap.getString(associations.get(0), "title");
|
|
|
+ dataForm.put(key, material);
|
|
|
+ } else if (arrCompId.get(i).contains("dateField_")) {
|
|
|
+ String cId = arrCompId.get(i).replace("_wb", "");
|
|
|
+ if (!detail.containsKey(cId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ long tm = UtilMap.getLong(detail, cId);
|
|
|
+ if (tm == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (arrCompId.get(i).contains("_wb")) {
|
|
|
+ dataForm.put(key, UtilDateTime.format(new Date(tm), "yyyy-MM"));
|
|
|
} else {
|
|
|
- if (key.equals("textField_m5297e3q")) {
|
|
|
- uuid = UtilMap.getString(detail, arrCompId.get(i));
|
|
|
- }
|
|
|
- dataForm.put(key, detail.get(arrCompId.get(i)));
|
|
|
+ dataForm.put(key, tm);
|
|
|
}
|
|
|
- // 避免判断条件被覆盖, 如工程订单重复写入
|
|
|
- if (key.equals("textField_m25j5gxv")) {
|
|
|
- dataForm.put(key, UtilDateTime.format(new Date(kpzq), "yyyy-MM"));
|
|
|
+ } else {
|
|
|
+ if (key.equals("textField_m5297e3q")) {
|
|
|
+ uuid = UtilMap.getString(detail, arrCompId.get(i));
|
|
|
}
|
|
|
+ dataForm.put(key, detail.get(arrCompId.get(i)));
|
|
|
+ }
|
|
|
+ // 避免判断条件被覆盖, 如工程订单重复写入
|
|
|
+ if (key.equals("textField_m25j5gxv")) {
|
|
|
+ dataForm.put(key, UtilDateTime.format(new Date(kpzq), "yyyy-MM"));
|
|
|
}
|
|
|
- String kpzq_wb = UtilDateTime.format(new Date(kpzq), "yyyy-MM");
|
|
|
- List<Map> searchCondition = new ArrayList<>();
|
|
|
- searchCondition.addAll(Arrays.asList(
|
|
|
- YDConf.searchCondition_TextFiled("textField_lvdosccc", UtilMap.getString(formData, "textField_lvdosccc"), "eq"),
|
|
|
- YDConf.searchCondition_TextFiled("selectField_lvc9x4vn", UtilMap.getString(formData, "selectField_lvc9x4vn"), "eq"),
|
|
|
- YDConf.searchCondition_TextFiled("textField_m25j5gxv", kpzq_wb, "eq"),
|
|
|
- YDConf.searchCondition_TextFiled("textField_m5aes96o", material, "eq"),
|
|
|
- YDConf.searchCondition_TextFiled("textField_m5297e3q", uuid, "eq")
|
|
|
- ));
|
|
|
- // 回款状态与未回款金额记录, 用于催款函查询
|
|
|
- BigDecimal figure = BigDecimal.valueOf(UtilMap.getDouble(dataForm, "numberField_lvdnme0z")).subtract(BigDecimal.valueOf(UtilMap.getDouble(dataForm, "numberField_lvg084l9")));
|
|
|
- dataForm.put("radioField_m4qrz687", BigDecimal.ZERO.compareTo(figure) == 0 ? "是" : "否");
|
|
|
- dataForm.put("numberField_m4qrz685", figure);
|
|
|
-// Thread.sleep(30); // QPS上限 40
|
|
|
- ydClient.operateData(_initLYParam()
|
|
|
- .searchCondition(JSON.toJSONString(searchCondition))
|
|
|
- .formUuid("FORM-EC785A5AB2B9432C892062823EB7C62A9NTL")
|
|
|
- .formDataJson(JSON.toJSONString(dataForm))
|
|
|
- .useLatestVersion(true)
|
|
|
- .build(), YDConf.FORM_OPERATION.upsert_v2);
|
|
|
}
|
|
|
+ String kpzq_wb = UtilDateTime.format(new Date(kpzq), "yyyy-MM");
|
|
|
+ List<Map> searchCondition = new ArrayList<>();
|
|
|
+ searchCondition.addAll(Arrays.asList(
|
|
|
+ YDConf.searchCondition_TextFiled("textField_lvdosccc", UtilMap.getString(formData, "textField_lvdosccc"), "eq"),
|
|
|
+ YDConf.searchCondition_TextFiled("selectField_lvc9x4vn", UtilMap.getString(formData, "selectField_lvc9x4vn"), "eq"),
|
|
|
+ YDConf.searchCondition_TextFiled("textField_m25j5gxv", kpzq_wb, "eq"),
|
|
|
+ YDConf.searchCondition_TextFiled("textField_m5aes96o", material, "eq"),
|
|
|
+ YDConf.searchCondition_TextFiled("textField_m5297e3q", uuid, "eq")
|
|
|
+ ));
|
|
|
+ // 回款状态与未回款金额记录, 用于催款函查询
|
|
|
+ BigDecimal figure = BigDecimal.valueOf(UtilMap.getDouble(dataForm, "numberField_lvdnme0z")).subtract(BigDecimal.valueOf(UtilMap.getDouble(dataForm, "numberField_lvg084l9")));
|
|
|
+ dataForm.put("radioField_m4qrz687", BigDecimal.ZERO.compareTo(figure) == 0 ? "是" : "否");
|
|
|
+ dataForm.put("numberField_m4qrz685", figure);
|
|
|
+// Thread.sleep(30); // QPS上限 40
|
|
|
+ ydClient.operateData(_initLYParam()
|
|
|
+ .searchCondition(JSON.toJSONString(searchCondition))
|
|
|
+ .formUuid("FORM-EC785A5AB2B9432C892062823EB7C62A9NTL")
|
|
|
+ .formDataJson(JSON.toJSONString(dataForm))
|
|
|
+ .useLatestVersion(true)
|
|
|
+ .build(), YDConf.FORM_OPERATION.upsert_v2);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|