CreditModel.java
7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package com.lhcredit.project.business.calculateRatings;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lhcredit.common.utils.DataHandleUtils2;
import com.lhcredit.common.utils.JsonPathUtils;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.project.business.creditGrantingInfo.domain.CreditGrantingInfo;
import com.lhcredit.project.business.creditGrantingInfo.domain.HistoricalTransactions;
import com.lhcredit.project.business.financeInfo.domain.FinanceInfo;
import com.lhcredit.project.business.scorecardScoreDetailed.domain.ScorecardScoreDetailed;
import com.lhcredit.project.business.scorecardScoreDetailed.service.IScorecardScoreDetailedService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Data
@Component
public class CreditModel {
private FinanceInfo cur;
private FinanceInfo last;
private FinanceInfo llast;
private JSONObject basicInfo;
private String ename;
private FinanceIndex financeIndex;
private String creditLv;
private String companyScale;//企业规模
private Integer createYearCom;//企业成立年份
//行业平均值
public static CreditModel CAUtils(CreditGrantingInfo creditGrantingInfo,FinanceInfo curi,FinanceInfo lasti, FinanceInfo llasti){
CreditModel caUtils = new CreditModel();caUtils.setCur(curi);caUtils.setLast(lasti);caUtils.setLlast(llasti);
caUtils.setCreditLv(creditGrantingInfo.getCreditLv());
caUtils.setEname(creditGrantingInfo.getEname());
caUtils.setFinanceIndex(FinanceIndex.of(curi,lasti,llasti));
caUtils.setBasicInfo(JSONObject.parseObject(creditGrantingInfo.getBasicInfo()));
caUtils.createDateCompany();
return caUtils;
}
public void createDateCompany(){
// Key5 经营时长
Date date = basicInfo.getDate("establishDate");
Double estiblishTime=FinanceIndex.getCompanyEstablishYear(date);
this.createYearCom=estiblishTime.intValue();
}
//创建贸易模型
public BigDecimal createTradeModel(CreditGrantingInfo creditGrantingInfo) {
//1、企业规模
this.companyScale=financeIndex.getCompanyScale("贸易类企业");
//2.销售增长率
Double xszzl=financeIndex.idx_xszzl();
//3.流动资产周转率
Double ldzczzl=financeIndex.idx_ldzczzl();
//4 营运资金需求量=营业收入×(1+销售增长率)÷流动资产周转率
Double yyzjxql=cur.getOperRev().doubleValue() * (1+xszzl) / ldzczzl;
//5存货
Double ch= financeIndex.idx_ch();
//6速动比率
Double sdbl= financeIndex.idx_sdbl();
// 流动资产=营业收入÷流动资产周转率,该部分参数在营运资金需求量中已说明;
// 流动负债=(流动资产-存货)÷速动比率
Double ldlc=cur.getOperRev().doubleValue()/ldzczzl;
Double ldfz=(ldlc-ch)/sdbl;
//营运资金来源=流动资产-流动负债,其中,
Double yyzjly=ldlc-ldfz;
yyzjly=yyzjly<0?0:yyzjly;//营运资金来源计算结果若为负数,计为0
//级别调整系数
Double jbtzxs=financeIndex.idx_jbtzxs(creditLv);
//资产负债率调整系数
Double zcfzltzxs=financeIndex.idx_zcfzltzxs();
//去年单月最大交易规模
Double monthMaxTransactionSize=null;
if (StringUtils.isNotEmpty(creditGrantingInfo.getHistoricalTransactions())){
BigDecimal val3 = JSONObject.parseObject(creditGrantingInfo.getHistoricalTransactions(), HistoricalTransactions.class).getMonthMaxTransactionSize();
if (null!=val3)monthMaxTransactionSize=val3.doubleValue()*(120/100.0);
}
//抵押信息=抵押物评估价值*折扣率
Double dyw=financeIndex.idx_dyw( creditGrantingInfo);
//保证额*30%
Double dbe=financeIndex.idx_dbe(creditGrantingInfo);
Double score=0D;
// 授信额度=MAX{净利润,去年单月最大交易规模*120%,MIN[(营运资金需求量-营运资金来源)×级别调整系数,营业收入×20%,总资产×15%,所有者权益×级别调整系数]}×资产负债率调整系数+抵押物评估价值*折扣率+保证额*30%
//MIN[(营运资金需求量-营运资金来源)×级别调整系数,营业收入×20%,总资产×15%,所有者权益×级别调整系数]
Double min = Arrays.asList((yyzjxql - yyzjly) * jbtzxs, cur.getOperRev().doubleValue() * (20 / 100.0), cur.getTotAssets().doubleValue() * (15 / 100.0), cur.getTotalEquity().doubleValue() * jbtzxs).stream().min(Double::compareTo).get();
Double max = Arrays.asList(cur.getNetProfit().doubleValue(), (null != monthMaxTransactionSize ? monthMaxTransactionSize : Double.MIN_VALUE), min).stream().max(Double::compareTo).get();
//中小型 没有资产负债率调整系数
score=(companyScale.equals("大型")?max*zcfzltzxs:max)+dyw+dbe;
score=score<50?0:score;//若计算得出的授信额度<50,按照授信额度为0处理
return new BigDecimal(score).setScale(2,BigDecimal.ROUND_HALF_UP);
}
//创建制造模型
public BigDecimal createManufactureModel(CreditGrantingInfo creditGrantingInfo) {
//1、企业规模
this.companyScale=financeIndex.getCompanyScale("制造类企业");
//1.有效净资产ENA
Double ENA=cur.getTotalEquity().doubleValue();
//2.信用等级调整系数CR
Double CR=financeIndex.calculation_indicators(creditLv,"信用等级调整系数",null);
//3.所有制类型调整系数OS
Double OS=financeIndex.calculation_indicators(creditGrantingInfo.getCompanyNature(),"所有制类型调整系数",null);
//4.上市调整系数LT
Double LT=financeIndex.idx_sstzxs(creditGrantingInfo.getBasicInfo());
//5.资产负债率调整系数DT
Double zcfzl = financeIndex.idx_zcfzl();
Double DT=financeIndex.calculation_indicators(zcfzl,"资产负债率调整系数",null);
//还本能力上限CE
Double CE=last.getOperRev().doubleValue();
//
//抵押信息=抵押物评估价值*折扣率
Double dyw=financeIndex.idx_dyw( creditGrantingInfo);
//保证额*30%
Double dbe=financeIndex.idx_dbe(creditGrantingInfo);
Double establishDate = financeIndex.getCompanyEstablishYear(JsonPathUtils.jsonPathDate(JSONObject.parseObject(creditGrantingInfo.getBasicInfo()), "establishDate"));
boolean newCompany=false; //如果新建企业 则不计算ce (是新企业赋值最大值)
Double score=Math.min((ENA*CR*OS*LT*DT),newCompany?Double.MAX_VALUE:CE)+dyw+dbe;
return new BigDecimal(score).setScale(2,BigDecimal.ROUND_HALF_UP);
}
public static enum Index{
XXX("")
;
public String name;
Index(String name) {
this.name = name;
}
}
}