|
@@ -1,23 +1,27 @@
|
|
|
package com.sundata.product.rwa.calc.service.implement.units;
|
|
|
|
|
|
-import cn.hutool.core.math.MathUtil;
|
|
|
+import cn.hutool.core.convert.NumberChineseFormatter;
|
|
|
+import cn.hutool.core.convert.NumberWordFormatter;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
-import cn.hutool.extra.template.TemplateUtil;
|
|
|
import com.sundata.common.util.DBExecutor;
|
|
|
import com.sundata.product.rwa.calc.service.CalcResult;
|
|
|
import com.sundata.product.rwa.calc.service.CalcUnit;
|
|
|
import com.sundata.product.rwa.calc.service.finals.CalcType;
|
|
|
import com.sundata.product.rwa.calc.utils.FinalStrs;
|
|
|
import com.sundata.product.rwa.calc.utils.UnitStaticFun;
|
|
|
+import com.sundata.product.rwa.resultList.model.DiffconfigListModel;
|
|
|
import com.sundata.product.rwa.resultList.model.RuleListModel;
|
|
|
+import com.sundata.product.rwa.resultList.service.DiffconfigListService;
|
|
|
import com.sundata.product.rwa.resultList.service.RuleListService;
|
|
|
import org.apache.commons.text.StringSubstitutor;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -102,9 +106,20 @@ public class GeneralLedgerUnit extends CalcUnit {
|
|
|
StringSubstitutor sub = new StringSubstitutor(context);
|
|
|
RuleListService ruleListService = SpringUtil.getBean(RuleListService.class);
|
|
|
List<RuleListModel> ruleListModels = ruleListService.rule_list(new RuleListModel());
|
|
|
+ DiffconfigListService diffconfigListService = SpringUtil.getBean(DiffconfigListService.class);
|
|
|
+ List<DiffconfigListModel> diffconfigListModels = diffconfigListService.rule_querylist(new DiffconfigListModel());
|
|
|
+ Map<String, DiffconfigListModel> subjectDiffConfig = new HashMap<>();
|
|
|
+
|
|
|
+ for (DiffconfigListModel diffconfigListModel : diffconfigListModels) {
|
|
|
+ List<RuleListModel> ruleListModelList = diffconfigListService.rule_queryone2(diffconfigListModel.getRuleNo());
|
|
|
+ for (RuleListModel ruleListModel : ruleListModelList) {
|
|
|
+ subjectDiffConfig.put(ruleListModel.getGlCode(), diffconfigListModel);
|
|
|
+ }
|
|
|
+ }
|
|
|
// TODO 需要获取容忍度处理逻辑,并将容忍度处理逻辑处理为一个基于科目编号的map,下面的处理过程中,根据实际容忍度处理结果
|
|
|
// TODO 这两个表不存在 select * from RWA_LEART_INS_LEDGRESULT; select * from RWA_APM_BUS_RS_ACCADJUSTMENT;
|
|
|
for (RuleListModel ruleListModel : ruleListModels) {
|
|
|
+
|
|
|
String subjectSql = sub.replace(ruleListModel.getSubjectSql());
|
|
|
String productSql = sub.replace(ruleListModel.getProductSql());
|
|
|
String subjectSum = DBExecutor.doQuery(subjectSql);
|
|
@@ -115,23 +130,57 @@ public class GeneralLedgerUnit extends CalcUnit {
|
|
|
if (!NumberUtil.isNumber(productSum)) {
|
|
|
continue;
|
|
|
}
|
|
|
-// Double subjectSumDouble = Double.valueOf(subjectSum);
|
|
|
-// Double productSumDouble = Double.valueOf(productSum);
|
|
|
- BigDecimal subjectSumBigDecimal = new BigDecimal(subjectSum);
|
|
|
- BigDecimal productSumBigDecimal = new BigDecimal(productSum);
|
|
|
- BigDecimal result = subjectSumBigDecimal.subtract(productSumBigDecimal);// 取 总账-勾稽明细
|
|
|
-
|
|
|
- if (result.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ BigDecimal subjectSumBigDecimal = new BigDecimal(subjectSum); // 总账汇总金额(万元)
|
|
|
+ BigDecimal productSumBigDecimal = new BigDecimal(productSum); // 勾稽汇总金额(万元)
|
|
|
+ BigDecimal differAmt = subjectSumBigDecimal.subtract(productSumBigDecimal);// 取 总账-勾稽明细 // 核对差异金额 不是万元
|
|
|
+
|
|
|
+
|
|
|
+// String
|
|
|
+ String riskType = null;
|
|
|
+ String offProjectType = null;
|
|
|
+// private String calcMethod; //计算方式
|
|
|
+// private String positiveRiskType; //正差异风险暴露分类
|
|
|
+// private String negativeRiskType; //负差异风险暴露分类
|
|
|
+// private String positiveOffProjectType; //正差异表外项目分类
|
|
|
+// private String negativeOffProjectType; //负差异表外项目分类
|
|
|
+ if (differAmt.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
// 如果 为负数 总账 小于 勾稽明细
|
|
|
-
|
|
|
- }else if(result.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ riskType = ruleListModel.getNegativeRiskType();
|
|
|
+ offProjectType = ruleListModel.getNegativeOffProjectType();
|
|
|
+ } else if (differAmt.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
// 如果 为正数 总账 大于 勾稽明细
|
|
|
-
|
|
|
- }else {
|
|
|
+ riskType = ruleListModel.getPositiveRiskType();
|
|
|
+ offProjectType = ruleListModel.getPositiveOffProjectType();
|
|
|
+ } else {
|
|
|
// 如果 为 0 总账等于勾稽明细
|
|
|
-
|
|
|
+ riskType = "";
|
|
|
+ offProjectType = "";
|
|
|
}
|
|
|
|
|
|
+ DiffconfigListModel diffconfigListModel = subjectDiffConfig.get(ruleListModel.getGlCode());
|
|
|
+ boolean isInDiff = true;
|
|
|
+// BigDecimal differAmt = BigDecimal.ZERO; // 核对差异金额(万元)
|
|
|
+ BigDecimal differRate = differAmt.divide(subjectSumBigDecimal); // 核对差异率%
|
|
|
+ String percThreshold = "[0.0-0.0]"; // 差异容忍度%
|
|
|
+ if (diffconfigListModel != null) {
|
|
|
+// close - close
|
|
|
+// close - open
|
|
|
+// open - close
|
|
|
+// open - open
|
|
|
+
|
|
|
+ String intervalType = diffconfigListModel.getIntervalType();
|
|
|
+
|
|
|
+ if (StrUtil.isBlank(intervalType) || intervalType.indexOf("-")!=6) {// 默认 闭-闭区间
|
|
|
+ intervalType = "[close-close]";
|
|
|
+ }
|
|
|
+ intervalType = StrUtil.replace(intervalType,"[close","[");
|
|
|
+ intervalType = StrUtil.replace(intervalType,"close]","]");
|
|
|
+ intervalType = StrUtil.replace(intervalType,"open]",")");
|
|
|
+ intervalType = StrUtil.replace(intervalType,"[open","(");
|
|
|
+ String[] split = intervalType.split("-");
|
|
|
+ DecimalFormat df = new DecimalFormat("#,##0.00");
|
|
|
+ percThreshold = split[0]+ df.format(diffconfigListModel.getUpperLimit()) + "-" + df.format(diffconfigListModel.getLowerLimit()) + split[1];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|