付款单保存修改自定义项赋值

This commit is contained in:
lihao 2025-06-06 14:59:17 +08:00
parent 83222ff0d9
commit f77311c6c7
1 changed files with 21 additions and 12 deletions

View File

@ -145,23 +145,26 @@ public class N_F3_SAVE extends N_BASE_ACTION {
} else { } else {
char[] intChars = integerPart.toCharArray(); char[] intChars = integerPart.toCharArray();
int len = intChars.length; int len = intChars.length;
int index = 0; for (int i = 0; i < len; i++) {
for (int i = len - 1; i >= 0; i--) {
int digit = intChars[i] - '0'; int digit = intChars[i] - '0';
int digitPosition = len - i - 1; int digitPosition = len - i - 1;
int section = digitPosition / 4; int section = digitPosition / 4;
int positionInSection = digitPosition % 4; int positionInSection = digitPosition % 4;
if (digit != 0) { if (digit != 0) {
chineseInteger.insert(0, CHINESE_CHARS[digit]); chineseInteger.append(CHINESE_CHARS[digit]);
if (positionInSection > 0) { if (positionInSection > 0) {
chineseInteger.insert(0, DIGIT_UNITS[positionInSection]); chineseInteger.append(DIGIT_UNITS[positionInSection]);
} }
} }
if (positionInSection == 0 && digit != 0) { if (positionInSection == 0) {
chineseInteger.insert(0, LARGE_NUMBERS[section]); if (digit != 0 || chineseInteger.length() == 0) {
chineseInteger.append(LARGE_NUMBERS[section]);
}
}
if (digit == 0) {
chineseInteger.append(CHINESE_CHARS[digit]);
} }
index++;
} }
// 移除多余的零和重复的单位 // 移除多余的零和重复的单位
cleanUpChineseNumber(chineseInteger); cleanUpChineseNumber(chineseInteger);
@ -169,9 +172,9 @@ public class N_F3_SAVE extends N_BASE_ACTION {
// 处理小数部分 // 处理小数部分
StringBuilder chineseDecimal = new StringBuilder(); StringBuilder chineseDecimal = new StringBuilder();
int jiao = 0;
int fen = 0;
if (!decimalPart.isEmpty()) { if (!decimalPart.isEmpty()) {
int jiao = 0;
int fen = 0;
if (decimalPart.length() >= 1) { if (decimalPart.length() >= 1) {
jiao = Integer.parseInt(decimalPart.substring(0, 1)); jiao = Integer.parseInt(decimalPart.substring(0, 1));
} }
@ -181,6 +184,7 @@ public class N_F3_SAVE extends N_BASE_ACTION {
if (jiao != 0) { if (jiao != 0) {
chineseDecimal.append(CHINESE_CHARS[jiao]).append(AMOUNT_UNITS[1]); chineseDecimal.append(CHINESE_CHARS[jiao]).append(AMOUNT_UNITS[1]);
} }
// 如果分不为0才输出分部分
if (fen != 0) { if (fen != 0) {
chineseDecimal.append(CHINESE_CHARS[fen]).append(AMOUNT_UNITS[2]); chineseDecimal.append(CHINESE_CHARS[fen]).append(AMOUNT_UNITS[2]);
} }
@ -191,10 +195,14 @@ public class N_F3_SAVE extends N_BASE_ACTION {
chineseInteger.append(CHINESE_CHARS[0]); chineseInteger.append(CHINESE_CHARS[0]);
} }
chineseInteger.append(AMOUNT_UNITS[0]); chineseInteger.append(AMOUNT_UNITS[0]);
if (chineseDecimal.length() == 0) { if (jiao == 0 && fen == 0) {
chineseInteger.append(""); chineseInteger.append("");
} else { } else {
chineseInteger.append(chineseDecimal); if (fen == 0 && jiao != 0) {
chineseInteger.append(chineseDecimal).append("");
} else {
chineseInteger.append(chineseDecimal);
}
} }
// 特殊情况处理零元整 // 特殊情况处理零元整
@ -214,7 +222,7 @@ public class N_F3_SAVE extends N_BASE_ACTION {
if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '零') { if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '零') {
sb.deleteCharAt(sb.length() - 1); sb.deleteCharAt(sb.length() - 1);
} }
// ³ýµ¥Î»Ç°ÃæµÄÁã // 移除单位前面的零
for (String unit : DIGIT_UNITS) { for (String unit : DIGIT_UNITS) {
if (!unit.isEmpty()) { if (!unit.isEmpty()) {
while (sb.indexOf("" + unit) != -1) { while (sb.indexOf("" + unit) != -1) {
@ -232,4 +240,5 @@ public class N_F3_SAVE extends N_BASE_ACTION {
} }
} }
} }