|
@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
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.*;
|
|
@@ -23,7 +24,9 @@ import java.util.stream.Stream;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class FImplService implements FService {
|
|
|
-
|
|
|
+ private static final String[] NUMBERS = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
|
|
+ private static final String[] UNITS = {"", "拾", "佰", "仟"};
|
|
|
+ private static final String[] BIG_UNITS = {"", "万", "亿", "兆"};
|
|
|
@Autowired
|
|
|
private YDService ydService;
|
|
|
|
|
@@ -76,7 +79,8 @@ public class FImplService implements FService {
|
|
|
Map formData = UtilMap.getMap(setMap, unique); // 累计标识
|
|
|
if (!setMap.containsKey(unique)) {
|
|
|
// 主表信息: 由 --> 至, 合计金额
|
|
|
- formData = UtilMap.map("textField_m06ij3z7, textField_m06ij3z8, numberField_m06lmogz", kpgs, khmc, UtilMap.getFloat(data, "numberField_m4qrz685"));
|
|
|
+ formData = UtilMap.map("textField_m06ij3z7, textField_m06ij3z8, numberField_m06lmogz", kpgs, khmc, BigDecimal.valueOf(UtilMap.getDouble(data, "numberField_m4qrz685")));
|
|
|
+// formData = UtilMap.map("textField_m06ij3z7, textField_m06ij3z8, numberField_m06lmogz", kpgs, khmc, UtilMap.getFloat(data, "numberField_m4qrz685"));
|
|
|
List<Map> subjects = subjectList.stream().filter(item -> kpgs.equals(UtilMap.getString(item, "textField_lrintpap"))).collect(Collectors.toList()); // 精准匹配
|
|
|
if (subjects.size() == 0) {
|
|
|
continue;
|
|
@@ -100,22 +104,27 @@ public class FImplService implements FService {
|
|
|
table.add(sub);
|
|
|
formData.put("tableField_m06ij3zd", table);
|
|
|
// 累计合计金额
|
|
|
- formData.put("numberField_m06lmogz", UtilMap.getFloat(formData, "numberField_m06lmogz") + UtilMap.getFloat(data, "numberField_m4qrz685"));
|
|
|
+ formData.put("numberField_m06lmogz", BigDecimal.valueOf(UtilMap.getDouble(formData, "numberField_m06lmogz")).add(BigDecimal.valueOf(UtilMap.getDouble(data, "numberField_m4qrz685"))));
|
|
|
+// formData.put("numberField_m06lmogz", UtilMap.getFloat(formData, "numberField_m06lmogz") + UtilMap.getFloat(data, "numberField_m4qrz685"));
|
|
|
}
|
|
|
List<Map> mapList = (List<Map>) formData.get("tableField_m06ij3zd");
|
|
|
List<Map> collect = mapList.stream().sorted(Comparator.comparing(m -> UtilMap.getString((Map) m, "textField_m06ij3zh")).reversed()).collect(Collectors.toList());
|
|
|
// List<Map> collect = mapList.stream().sorted(Comparator.comparing(m -> LocalDate.parse(UtilMap.getString((Map) m, "textField_m06ij3zh")+"-01", DateTimeFormatter.ISO_LOCAL_DATE)).reversed()).collect(Collectors.toList());
|
|
|
for (int i = 0; i < collect.size(); i++) {
|
|
|
- collect.get(i).put("textField_m06ij3ze",i+1);
|
|
|
+ collect.get(i).put("textField_m06ij3ze", i + 1);
|
|
|
}
|
|
|
formData.put("tableField_m06ij3zd", collect);
|
|
|
setMap.put(unique, formData);
|
|
|
}
|
|
|
|
|
|
+// textField_mbk6z3us
|
|
|
log.info("催款函, {}", setMap.size());
|
|
|
for (String unique : setMap.keySet()) {
|
|
|
Map formData = UtilMap.getMap(setMap, unique);
|
|
|
- formData.put("textField_m4qxo07x", unique + "_" + UtilMap.getFloat(formData, "numberField_m06lmogz"));
|
|
|
+ double sum = UtilMap.getDouble(formData, "numberField_m06lmogz");
|
|
|
+ String numberToChinese = numberToChinese(sum);
|
|
|
+ formData.put("textField_m4qxo07x", unique + "_" + sum);
|
|
|
+ formData.put("textField_mbk6z3us", numberToChinese);
|
|
|
ydClient.operateData(_initLYParam()
|
|
|
.formUuid("FORM-738D89FEC34740EC92B08BF6D7B9470DEQY6")
|
|
|
.processCode("TPROC--IMD665A1KDXNJ2V47QQ9UCM9I9F827DEEI60M6")
|
|
@@ -132,8 +141,8 @@ public class FImplService implements FService {
|
|
|
// .searchFieldJson(JSON.toJSONString(UtilMap.map("textField_lvdosccc", "KP_2024120201435")))
|
|
|
.build());
|
|
|
Map<Object, List<Map>> dataStream = dataList.stream().collect(Collectors.groupingBy(map -> map.get("textField_m5297e3q")));
|
|
|
- dataStream.forEach((k,v)->{
|
|
|
- if (v.size()>1){
|
|
|
+ dataStream.forEach((k, v) -> {
|
|
|
+ if (v.size() > 1) {
|
|
|
for (int i = v.size() - 1; i > 0; i--) {
|
|
|
ydClient.operateData(_initLYParam()
|
|
|
// .searchCondition(JSON.toJSONString(searchCondition))
|
|
@@ -217,11 +226,11 @@ public class FImplService implements FService {
|
|
|
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";
|
|
|
+ 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))));
|
|
|
+ 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_")) {
|
|
@@ -240,7 +249,7 @@ public class FImplService implements FService {
|
|
|
}
|
|
|
} else {
|
|
|
if (key.equals("textField_m5297e3q")) {
|
|
|
- uuid = UtilMap.getString(detail, arrCompId.get(i));
|
|
|
+ uuid = UtilMap.getString(detail, arrCompId.get(i));
|
|
|
}
|
|
|
dataForm.put(key, detail.get(arrCompId.get(i)));
|
|
|
}
|
|
@@ -272,4 +281,115 @@ public class FImplService implements FService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ public String numberToChinese(double number) {
|
|
|
+ boolean isNegative = number < 0;
|
|
|
+ number = Math.abs(number);
|
|
|
+
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(String.valueOf(number));
|
|
|
+ long integerPart = bigDecimal.longValue();
|
|
|
+ int decimalPart = (bigDecimal.subtract(new BigDecimal(integerPart)).multiply(new BigDecimal(100))).intValue();
|
|
|
+
|
|
|
+ if (integerPart == 0 && decimalPart == 0) {
|
|
|
+ return isNegative ? "负零元整" : "零元整";
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder result = new StringBuilder();
|
|
|
+ int unitIndex = 0;
|
|
|
+ boolean zeroFlag = false;
|
|
|
+ while (integerPart > 0) {
|
|
|
+ long group = integerPart % 10000;
|
|
|
+ if (group != 0) {
|
|
|
+ if (zeroFlag) {
|
|
|
+ result.insert(0, "零");
|
|
|
+ }
|
|
|
+ result.insert(0, BIG_UNITS[unitIndex]);
|
|
|
+ result.insert(0, groupToChinese(group));
|
|
|
+ zeroFlag = false;
|
|
|
+ } else {
|
|
|
+ zeroFlag = true;
|
|
|
+ }
|
|
|
+ integerPart /= 10000;
|
|
|
+ unitIndex++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 去除多余的零
|
|
|
+ while (result.length() > 0 && result.charAt(0) == '零') {
|
|
|
+ result.deleteCharAt(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果小数部分为 0,直接添加“元整”
|
|
|
+ if (decimalPart == 0) {
|
|
|
+ // 避免出现“零元整”情况,这里判断结果最后是否是大单位,如果是直接加“整”
|
|
|
+ if (result.length() > 0 && isBigUnit(result.charAt(result.length() - 1))) {
|
|
|
+ result.append("整");
|
|
|
+ } else if ("零".equals(result.substring(result.length() - 1, result.length()))) {
|
|
|
+ result.replace(result.length() - 1, result.length(), "").append("元整");
|
|
|
+ } else {
|
|
|
+ result.append("元整");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.append("元");
|
|
|
+ String decimalStr = decimalToChinese(decimalPart);
|
|
|
+ if (!decimalStr.isEmpty()) {
|
|
|
+ result.append(decimalStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (isNegative) {
|
|
|
+ result.insert(0, "负");
|
|
|
+ }
|
|
|
+
|
|
|
+ return result.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String groupToChinese(long group) {
|
|
|
+ StringBuilder groupResult = new StringBuilder();
|
|
|
+ boolean zeroFlag = false;
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ int digit = (int) (group / (long) Math.pow(10, 3 - i) % 10);
|
|
|
+ if (digit != 0) {
|
|
|
+ if (zeroFlag) {
|
|
|
+ groupResult.append("零");
|
|
|
+ }
|
|
|
+ groupResult.append(NUMBERS[digit]).append(UNITS[3 - i]);
|
|
|
+ zeroFlag = false;
|
|
|
+ } else {
|
|
|
+ zeroFlag = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String result = groupResult.toString();
|
|
|
+ if (result.endsWith("零")) {
|
|
|
+ result = result.substring(0, result.length() - 1);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String decimalToChinese(int decimalPart) {
|
|
|
+ StringBuilder decimalResult = new StringBuilder();
|
|
|
+ int jiao = decimalPart / 10;
|
|
|
+ int fen = decimalPart % 10;
|
|
|
+
|
|
|
+ if (jiao != 0) {
|
|
|
+ decimalResult.append(NUMBERS[jiao]).append("角");
|
|
|
+ } else if (fen != 0) {
|
|
|
+ decimalResult.append("零");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fen != 0) {
|
|
|
+ decimalResult.append(NUMBERS[fen]).append("分");
|
|
|
+ }
|
|
|
+
|
|
|
+ return decimalResult.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isBigUnit(char c) {
|
|
|
+ for (String unit : BIG_UNITS) {
|
|
|
+ if (unit.length() > 0 && unit.charAt(0) == c) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+}
|