|
@@ -15,11 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -119,11 +116,10 @@ public class FImplService implements FService {
|
|
|
setMap.put(unique, formData);
|
|
|
}
|
|
|
|
|
|
-// textField_mbk6z3us
|
|
|
log.info("催款函, {}", setMap.size());
|
|
|
for (String unique : setMap.keySet()) {
|
|
|
Map formData = UtilMap.getMap(setMap, unique);
|
|
|
- double sum = UtilMap.getDouble(formData, "numberField_m06lmogz");
|
|
|
+ BigDecimal sum = BigDecimal.valueOf(UtilMap.getDouble(formData, "numberField_m06lmogz"));
|
|
|
String numberToChinese = numberToChinese(sum);
|
|
|
formData.put("textField_m4qxo07x", unique + "_" + sum);
|
|
|
formData.put("textField_mbk6z3us", numberToChinese);
|
|
@@ -199,94 +195,95 @@ 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;
|
|
|
- }
|
|
|
- // 主表字段匹配 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) {
|
|
|
+ //子表唯一标识
|
|
|
+ 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 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"));
|
|
|
+ // 主表字段匹配 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;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
} else {
|
|
|
- dataForm.put(key, tm);
|
|
|
+ if (key.equals("textField_m5297e3q")) {
|
|
|
+ uuid = UtilMap.getString(detail, arrCompId.get(i));
|
|
|
+ }
|
|
|
+ dataForm.put(key, detail.get(arrCompId.get(i)));
|
|
|
}
|
|
|
- } else {
|
|
|
- if (key.equals("textField_m5297e3q")) {
|
|
|
- uuid = UtilMap.getString(detail, arrCompId.get(i));
|
|
|
+ // 避免判断条件被覆盖, 如工程订单重复写入
|
|
|
+ if (key.equals("textField_m25j5gxv")) {
|
|
|
+ dataForm.put(key, UtilDateTime.format(new Date(kpzq), "yyyy-MM"));
|
|
|
}
|
|
|
- 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")
|
|
|
- ));
|
|
|
- // 回款状态与未回款金额记录, 用于催款函查询
|
|
|
- float figure = UtilMap.getFloat(dataForm, "numberField_lvdnme0z") - UtilMap.getFloat(dataForm, "numberField_lvg084l9");
|
|
|
- dataForm.put("radioField_m4qrz687", figure == 0 ? "是" : "否");
|
|
|
- dataForm.put("numberField_m4qrz685", figure);
|
|
|
+ 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")
|
|
|
+ ));
|
|
|
+ // 回款状态与未回款金额记录, 用于催款函查询
|
|
|
+ float figure = UtilMap.getFloat(dataForm, "numberField_lvdnme0z") - UtilMap.getFloat(dataForm, "numberField_lvg084l9");
|
|
|
+ dataForm.put("radioField_m4qrz687", 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);
|
|
|
- }
|
|
|
+ ydClient.operateData(_initLYParam()
|
|
|
+ .searchCondition(JSON.toJSONString(searchCondition))
|
|
|
+ .formUuid("FORM-EC785A5AB2B9432C892062823EB7C62A9NTL")
|
|
|
+ .formDataJson(JSON.toJSONString(dataForm))
|
|
|
+ .useLatestVersion(true)
|
|
|
+ .build(), YDConf.FORM_OPERATION.upsert_v2);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public String numberToChinese(double number) {
|
|
|
- boolean isNegative = number < 0;
|
|
|
- number = Math.abs(number);
|
|
|
+ public String numberToChinese(BigDecimal number) {
|
|
|
+ int compareTo = number.compareTo(BigDecimal.ZERO);
|
|
|
+ boolean isNegative = compareTo < 0;
|
|
|
+ number = number.abs();
|
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(String.valueOf(number));
|
|
|
long integerPart = bigDecimal.longValue();
|