付款单保存修改自定义项赋值
This commit is contained in:
parent
845b3c766a
commit
24ce82f463
|
@ -17,7 +17,9 @@ import nc.vo.arap.pub.BillEnumCollection.ApproveStatus;
|
||||||
import nc.vo.fipub.exception.ExceptionHandler;
|
import nc.vo.fipub.exception.ExceptionHandler;
|
||||||
import nc.vo.pub.AggregatedValueObject;
|
import nc.vo.pub.AggregatedValueObject;
|
||||||
import nc.vo.pub.BusinessException;
|
import nc.vo.pub.BusinessException;
|
||||||
|
import nc.vo.pub.CircularlyAccessibleValueObject;
|
||||||
import nc.vo.pub.compiler.PfParameterVO;
|
import nc.vo.pub.compiler.PfParameterVO;
|
||||||
|
import nc.vo.pub.lang.UFDouble;
|
||||||
import nccloud.bs.arap.util.commit.ArapCommitUtil;
|
import nccloud.bs.arap.util.commit.ArapCommitUtil;
|
||||||
import nccloud.pubitf.arap.arappub.IArapBillPubUtilService;
|
import nccloud.pubitf.arap.arappub.IArapBillPubUtilService;
|
||||||
|
|
||||||
|
@ -63,6 +65,7 @@ public class N_F3_SAVE extends N_BASE_ACTION {
|
||||||
this.setParameter("context", paraVo.m_preValueVos);
|
this.setParameter("context", paraVo.m_preValueVos);
|
||||||
this.beforeCheck();
|
this.beforeCheck();
|
||||||
String primaryKey = paraVo.m_preValueVos[0].getParentVO().getPrimaryKey();
|
String primaryKey = paraVo.m_preValueVos[0].getParentVO().getPrimaryKey();
|
||||||
|
paraVo = this.def10Change(paraVo);
|
||||||
if (this.hasBill(primaryKey)) {
|
if (this.hasBill(primaryKey)) {
|
||||||
obj = this.runClass("nc.bs.arap.actions.PaybillEditSaveBatchBSAction", "updateVOs", "&context:nc.vo.pub.AggregatedValueObject[]", paraVo, this.m_keyHas);
|
obj = this.runClass("nc.bs.arap.actions.PaybillEditSaveBatchBSAction", "updateVOs", "&context:nc.vo.pub.AggregatedValueObject[]", paraVo, this.m_keyHas);
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,10 +107,129 @@ public class N_F3_SAVE extends N_BASE_ACTION {
|
||||||
|
|
||||||
private PfParameterVO def10Change(PfParameterVO paraVo) {
|
private PfParameterVO def10Change(PfParameterVO paraVo) {
|
||||||
for(AggregatedValueObject vo : paraVo.m_preValueVos) {
|
for(AggregatedValueObject vo : paraVo.m_preValueVos) {
|
||||||
vo.getParentVO().setAttributeValue("approvestatus", ApproveStatus.NOSTATE.VALUE);
|
UFDouble money_de = UFDouble.ZERO_DBL;
|
||||||
|
for(CircularlyAccessibleValueObject childVO : vo.getChildrenVO()) {
|
||||||
|
money_de =money_de.add((UFDouble) childVO.getAttributeValue("money_de")) ;
|
||||||
|
}
|
||||||
|
vo.getParentVO().setAttributeValue("def10",toChineseAmount(money_de.toBigDecimal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return paraVo;
|
return paraVo;
|
||||||
}
|
}
|
||||||
|
// 数字大写汉字映射表
|
||||||
|
private static final String[] CHINESE_CHARS = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
||||||
|
// 数位映射表
|
||||||
|
private static final String[] DIGIT_UNITS = {"", "拾", "佰", "仟"};
|
||||||
|
// 数映射表
|
||||||
|
private static final String[] LARGE_NUMBERS = {"", "万", "亿", "万亿", "亿亿"};
|
||||||
|
// 金额单位
|
||||||
|
private static final String[] AMOUNT_UNITS = {"元", "角", "分"};
|
||||||
|
// 特殊情况处理
|
||||||
|
private static final String ZERO_YUAN = "零元整";
|
||||||
|
|
||||||
|
public static String toChineseAmount(BigDecimal number) {
|
||||||
|
if (number == null || number.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
throw new IllegalArgumentException("请输入非负数字");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将数字分为整数部分和小数部分
|
||||||
|
String numStr = number.stripTrailingZeros().toPlainString();
|
||||||
|
String[] parts = numStr.split("\\.");
|
||||||
|
String integerPart = parts[0];
|
||||||
|
String decimalPart = parts.length > 1 ? parts[1] : "";
|
||||||
|
|
||||||
|
// 处理整数部分
|
||||||
|
StringBuilder chineseInteger = new StringBuilder();
|
||||||
|
if ("0".equals(integerPart)) {
|
||||||
|
chineseInteger.append(CHINESE_CHARS[0]);
|
||||||
|
} else {
|
||||||
|
char[] intChars = integerPart.toCharArray();
|
||||||
|
int len = intChars.length;
|
||||||
|
int index = 0;
|
||||||
|
for (int i = len - 1; i >= 0; i--) {
|
||||||
|
int digit = intChars[i] - '0';
|
||||||
|
int digitPosition = len - i - 1;
|
||||||
|
int section = digitPosition / 4;
|
||||||
|
int positionInSection = digitPosition % 4;
|
||||||
|
|
||||||
|
if (digit != 0) {
|
||||||
|
chineseInteger.insert(0, CHINESE_CHARS[digit]);
|
||||||
|
if (positionInSection > 0) {
|
||||||
|
chineseInteger.insert(0, DIGIT_UNITS[positionInSection]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (positionInSection == 0 && digit != 0) {
|
||||||
|
chineseInteger.insert(0, LARGE_NUMBERS[section]);
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
// 移除多余的零和重复的单位
|
||||||
|
cleanUpChineseNumber(chineseInteger);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理小数部分
|
||||||
|
StringBuilder chineseDecimal = new StringBuilder();
|
||||||
|
if (!decimalPart.isEmpty()) {
|
||||||
|
int jiao = 0;
|
||||||
|
int fen = 0;
|
||||||
|
if (decimalPart.length() >= 1) {
|
||||||
|
jiao = Integer.parseInt(decimalPart.substring(0, 1));
|
||||||
|
}
|
||||||
|
if (decimalPart.length() >= 2) {
|
||||||
|
fen = Integer.parseInt(decimalPart.substring(1, 2));
|
||||||
|
}
|
||||||
|
if (jiao != 0) {
|
||||||
|
chineseDecimal.append(CHINESE_CHARS[jiao]).append(AMOUNT_UNITS[1]);
|
||||||
|
}
|
||||||
|
if (fen != 0) {
|
||||||
|
chineseDecimal.append(CHINESE_CHARS[fen]).append(AMOUNT_UNITS[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 整合整数部分和小数部分
|
||||||
|
if (chineseInteger.length() == 0) {
|
||||||
|
chineseInteger.append(CHINESE_CHARS[0]);
|
||||||
|
}
|
||||||
|
chineseInteger.append(AMOUNT_UNITS[0]);
|
||||||
|
if (chineseDecimal.length() == 0) {
|
||||||
|
chineseInteger.append("整");
|
||||||
|
} else {
|
||||||
|
chineseInteger.append(chineseDecimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 特殊情况处理:零元整
|
||||||
|
if (chineseInteger.toString().equals("零元")) {
|
||||||
|
return ZERO_YUAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return chineseInteger.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void cleanUpChineseNumber(StringBuilder sb) {
|
||||||
|
// 移除连续的零,只保留一个零
|
||||||
|
while (sb.indexOf("零零") != -1) {
|
||||||
|
sb.replace(sb.indexOf("零零"), sb.indexOf("零零") + 2, "零");
|
||||||
|
}
|
||||||
|
// 移除末尾的零
|
||||||
|
if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '零') {
|
||||||
|
sb.deleteCharAt(sb.length() - 1);
|
||||||
|
}
|
||||||
|
// 除单位前面的零
|
||||||
|
for (String unit : DIGIT_UNITS) {
|
||||||
|
if (!unit.isEmpty()) {
|
||||||
|
while (sb.indexOf("零" + unit) != -1) {
|
||||||
|
sb.replace(sb.indexOf("零" + unit), sb.indexOf("零" + unit) + 2, unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 移除大数单位前面的零
|
||||||
|
for (String largeNum : LARGE_NUMBERS) {
|
||||||
|
if (!largeNum.isEmpty()) {
|
||||||
|
while (sb.indexOf("零" + largeNum) != -1) {
|
||||||
|
sb.replace(sb.indexOf("零" + largeNum), sb.indexOf("零" + largeNum) + 2, largeNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue