五级分类优化
This commit is contained in:
parent
83f8094cea
commit
ab070845db
@ -74,19 +74,41 @@ public class AutoFiveGradeClassification implements Job {
|
||||
@Override
|
||||
public void execute(JobExecutionContext arg0) throws JobExecutionException{
|
||||
String startime = StringFunction.getTodayNow();
|
||||
|
||||
Object userId = arg0.getTrigger().getJobDataMap().get("CurUserId");
|
||||
String curUserId = userId == null? "system" : userId.toString();
|
||||
|
||||
try {
|
||||
autoFiveGradeClassification();
|
||||
autoFiveGradeClassificationNew();
|
||||
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.AutoFiveGradeClassification", "success", "³É¹¦", curUserId);
|
||||
} catch (Exception e) {
|
||||
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.AutoFiveGradeClassification", "error", "ʧ°Ü", curUserId);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void autoFiveGradeClassificationNew() throws Exception {
|
||||
Transaction sqlca = null;
|
||||
Transaction sqlca1 = null;
|
||||
try {
|
||||
sqlca = Transaction.createTransaction(JBOFactory.createJBOTransaction());
|
||||
//更新合同状态为100,105 分类状态
|
||||
sqlca.executeSQL("update LC_CALC_CONDITION_STATUS LCCS join lb_contract_info lci on LCCS.CONTRACT_ID = lci.ID set LCCS.FIVE_GRADE='ClassifyResult01',LCCS.FIVE_GRADE_DATE= date_format(curdate(),'%Y/%m/%d'),LCCS.FIVE_GRADE_DEMO=concat(date_format(curdate(),'%Y/%m/%d'),'日自动跑批') where lci.CONTRACT_STATUS in ('100','105') and LCCS.FIVE_GRADE <> 'ClassifyResult01'");
|
||||
|
||||
//更新合同状态为31分类状态
|
||||
sqlca.executeSQL("{call proc_autoFiveClassify()}");
|
||||
sqlca.commit();
|
||||
List<BizObject> diList = JBOFactory.getBizObjectManager(DISTRIBUTOR_INFO.CLASS_NAME).createQuery("1=1").getResultList(false);
|
||||
for (BizObject bo : diList) {
|
||||
sqlca1 = Transaction.createTransaction(JBOFactory.createJBOTransaction());
|
||||
new CreateFiveGradeDataAction(bo.getAttribute("distributor_no").getString(), bo, sqlca1).insertFiveGradeTable(sqlca1);
|
||||
sqlca1.commit();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (sqlca != null) sqlca.rollback();
|
||||
if (sqlca1 != null) sqlca1.rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ×Ô¶¯Îå¼¶·ÖÀà
|
||||
* @return
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
package com.tenwa.lease.flow.project.commbusiness;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import jbo.app.tenwa.customer.DISTRIBUTOR_INFO;
|
||||
import jbo.com.tenwa.entity.comm.own.LB_FIVEGRADEDETAILED_INFO;
|
||||
import jbo.sys.CODE_LIBRARY;
|
||||
|
||||
import com.amarsoft.are.jbo.BizObject;
|
||||
import com.amarsoft.are.jbo.BizObjectManager;
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.are.jbo.JBOFactory;
|
||||
import com.amarsoft.are.util.StringFunction;
|
||||
import com.amarsoft.awe.util.ASResultSet;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.amarsoft.dict.als.manage.NameManager;
|
||||
import jbo.app.tenwa.customer.DISTRIBUTOR_INFO;
|
||||
import jbo.com.tenwa.entity.comm.own.LB_FIVEGRADEDETAILED_INFO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class CreateFiveGradeDataAction {
|
||||
String contractId;
|
||||
|
||||
String distributorNo;
|
||||
BizObject BoDI;
|
||||
Integer contractNum;
|
||||
double TOTAL_OVERDUE_PRINCIPAL;
|
||||
double TOTAL_OVERDUE_INTEREST;
|
||||
double TOTAL_PENALTY;
|
||||
@ -50,60 +50,62 @@ public class CreateFiveGradeDataAction {
|
||||
String FINANCING_AMOUNT_SUSPICIOUS;
|
||||
String FINANCING_AMOUNT_LOSS;
|
||||
|
||||
public CreateFiveGradeDataAction(String distributorno,BizObject BoDI ,Transaction tx) throws Exception{
|
||||
try {
|
||||
distributorNo = distributorno;
|
||||
BoDI = BoDI;
|
||||
contractNum = Integer.valueOf(tx.getString("select count(1) from lb_contract_info where distributor_id = '"+distributorno+"'"));
|
||||
TOTAL_OVERDUE_PRINCIPAL = this.calcOverDuePrincipal(distributorNo,"CORPUS",true,null,tx);
|
||||
TOTAL_OVERDUE_INTEREST = this.calcOverDuePrincipal(distributorNo,"INTEREST",true,null,tx);
|
||||
TOTAL_PENALTY = this.calcOverDuePenalty(distributorNo,tx);
|
||||
TOTAL_OUTSTANDING_PRINCIPAL = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, null, tx);
|
||||
// ALL_TOTAL_OUTSTANDING_PRINCIPAL = this.calcAllOverDuePrincipal(tx);
|
||||
// TOTAL_OUTSTANDINGCUSTOMER_PRINCIPAL = this.calcOverDueCustomerAllCorpus(distributorNo, tx);
|
||||
|
||||
NO_DUE_CORPUS = this.getNoDueCORPUS(distributorno, tx);
|
||||
|
||||
NOTBACK_PRINCIPAL_NORMAL = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult01", tx);
|
||||
NOTBACK_PRINCIPAL_ATTENTION = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult02", tx);
|
||||
NOTBACK_PRINCIPAL_SECONDARY = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult03", tx);
|
||||
NOTBACK_PRINCIPAL_SUSPICIOUS = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult04", tx);
|
||||
NOTBACK_PRINCIPAL_LOSS = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult05", tx);
|
||||
|
||||
EXISTING_CUSTOMERS_NUM_NORMAL = this.getCustomerNumber(distributorNo,"ClassifyResult01","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_ATTENTION = this.getCustomerNumber(distributorNo,"ClassifyResult02","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_SECONDARY = this.getCustomerNumber(distributorNo,"ClassifyResult03","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_SUSPICIOUS = this.getCustomerNumber(distributorNo,"ClassifyResult04","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_LOSS = this.getCustomerNumber(distributorNo,"ClassifyResult05","custnum",tx);
|
||||
|
||||
FINANCING_AMOUNT_NORMAL = this.getCustomerNumber(distributorNo,"ClassifyResult01","qq",tx);
|
||||
FINANCING_AMOUNT_ATTENTION = this.getCustomerNumber(distributorNo,"ClassifyResult02","qq",tx);
|
||||
FINANCING_AMOUNT_SECONDARY = this.getCustomerNumber(distributorNo,"ClassifyResult03","qq",tx);
|
||||
FINANCING_AMOUNT_SUSPICIOUS = this.getCustomerNumber(distributorNo,"ClassifyResult04","qq",tx);
|
||||
FINANCING_AMOUNT_LOSS = this.getCustomerNumber(distributorNo,"ClassifyResult05","qq",tx);
|
||||
System.out.println("=====================================");
|
||||
System.out.println(this.toString());
|
||||
System.out.println("=====================================");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new Exception("³õʼ»¯¶ÔÏóÒì³£");
|
||||
}
|
||||
}
|
||||
|
||||
public CreateFiveGradeDataAction(String distributorno,Transaction tx) throws Exception{
|
||||
try {
|
||||
distributorNo = distributorno;
|
||||
TOTAL_OVERDUE_PRINCIPAL = this.calcOverDuePrincipal(distributorNo,"CORPUS",true,null,tx);
|
||||
TOTAL_OVERDUE_INTEREST = this.calcOverDuePrincipal(distributorNo,"INTEREST",true,null,tx);
|
||||
TOTAL_PENALTY = this.calcOverDuePenalty(distributorNo,tx);
|
||||
TOTAL_OUTSTANDING_PRINCIPAL = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, null, tx);
|
||||
ALL_TOTAL_OUTSTANDING_PRINCIPAL = this.calcAllOverDuePrincipal(tx);
|
||||
|
||||
TOTAL_OUTSTANDINGCUSTOMER_PRINCIPAL = this.calcOverDueCustomerAllCorpus(distributorNo, tx);
|
||||
|
||||
NO_DUE_CORPUS = this.getNoDueCORPUS(distributorno, tx);
|
||||
|
||||
NOTBACK_PRINCIPAL_NORMAL = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult01", tx);
|
||||
NOTBACK_PRINCIPAL_ATTENTION = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult02", tx);
|
||||
NOTBACK_PRINCIPAL_SECONDARY = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult03", tx);
|
||||
NOTBACK_PRINCIPAL_SUSPICIOUS = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult04", tx);
|
||||
NOTBACK_PRINCIPAL_LOSS = this.calcOverDuePrincipal(distributorNo, "CORPUS", false, "ClassifyResult05", tx);
|
||||
|
||||
EXISTING_CUSTOMERS_NUM_NORMAL = this.getCustomerNumber(distributorNo,"ClassifyResult01","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_ATTENTION = this.getCustomerNumber(distributorNo,"ClassifyResult02","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_SECONDARY = this.getCustomerNumber(distributorNo,"ClassifyResult03","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_SUSPICIOUS = this.getCustomerNumber(distributorNo,"ClassifyResult04","custnum",tx);
|
||||
EXISTING_CUSTOMERS_NUM_LOSS = this.getCustomerNumber(distributorNo,"ClassifyResult05","custnum",tx);
|
||||
|
||||
FINANCING_AMOUNT_NORMAL = this.getCustomerNumber(distributorNo,"ClassifyResult01","qq",tx);
|
||||
FINANCING_AMOUNT_ATTENTION = this.getCustomerNumber(distributorNo,"ClassifyResult02","qq",tx);
|
||||
FINANCING_AMOUNT_SECONDARY = this.getCustomerNumber(distributorNo,"ClassifyResult03","qq",tx);
|
||||
FINANCING_AMOUNT_SUSPICIOUS = this.getCustomerNumber(distributorNo,"ClassifyResult04","qq",tx);
|
||||
FINANCING_AMOUNT_LOSS = this.getCustomerNumber(distributorNo,"ClassifyResult05","qq",tx);
|
||||
System.out.println("=====================================");
|
||||
System.out.println(this.toString());
|
||||
System.out.println("=====================================");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new Exception("³õʼ»¯¶ÔÏóÒì³£");
|
||||
}
|
||||
this(distributorno,null,tx);
|
||||
}
|
||||
public boolean insertFiveGradeTable(Transaction tx) throws Exception{
|
||||
BizObjectManager bm;
|
||||
BizObjectManager bmDI;
|
||||
BizObjectManager bmCL;
|
||||
BigDecimal yibai = new BigDecimal(100);
|
||||
try {
|
||||
bmDI = JBOFactory.getBizObjectManager(DISTRIBUTOR_INFO.CLASS_NAME,tx);
|
||||
BizObject BoDI=bmDI.createQuery("DISTRIBUTOR_NO=:DISTRIBUTOR_NO").setParameter("DISTRIBUTOR_NO", distributorNo).getSingleResult(true);
|
||||
bmCL = JBOFactory.getBizObjectManager(CODE_LIBRARY.CLASS_NAME,tx);
|
||||
BizObject BoCL=bmCL.createQuery("codeno = 'dischanneltype' and itemno = '"+BoDI.getAttribute("channeltype").getString()+"'").setParameter("DISTRIBUTOR_NO", distributorNo).getSingleResult(true);
|
||||
|
||||
bm = JBOFactory.getBizObjectManager(LB_FIVEGRADEDETAILED_INFO.CLASS_NAME,tx);
|
||||
public boolean insertFiveGradeTable(Transaction tx) throws Exception{
|
||||
try {
|
||||
BigDecimal yibai = new BigDecimal(100);
|
||||
if (this.BoDI == null) {
|
||||
BizObjectManager bmDI = JBOFactory.getBizObjectManager(DISTRIBUTOR_INFO.CLASS_NAME, tx);
|
||||
BoDI = bmDI.createQuery("DISTRIBUTOR_NO=:DISTRIBUTOR_NO").setParameter("DISTRIBUTOR_NO", distributorNo).getSingleResult(true);
|
||||
}
|
||||
BizObjectManager bm = JBOFactory.getBizObjectManager(LB_FIVEGRADEDETAILED_INFO.CLASS_NAME,tx);
|
||||
BizObject newBo = bm.newObject();
|
||||
newBo.setAttributeValue(LB_FIVEGRADEDETAILED_INFO.DISTRIBUTOR_NO, distributorNo);
|
||||
newBo.setAttributeValue(LB_FIVEGRADEDETAILED_INFO.DISTRIBUTORNAME,BoDI.getAttribute("distributor_name"));
|
||||
newBo.setAttributeValue(LB_FIVEGRADEDETAILED_INFO.DISTRIBUTORTYPE,BoCL==null?"":BoCL.getAttribute("itemname"));
|
||||
newBo.setAttributeValue(LB_FIVEGRADEDETAILED_INFO.DISTRIBUTORTYPE,NameManager.getItemName("dischanneltype", BoDI.getAttribute("channeltype").getString()));
|
||||
newBo.setAttributeValue(LB_FIVEGRADEDETAILED_INFO.DISTRIBUTORQUOTA,BoDI.getAttribute("TOTAL"));
|
||||
newBo.setAttributeValue(LB_FIVEGRADEDETAILED_INFO.DEPOSITRATIO,BoDI.getAttribute("MARGIN_SCALE_SET"));
|
||||
newBo.setAttributeValue(LB_FIVEGRADEDETAILED_INFO.AGREEMENT,BoDI.getAttribute("LIMIT_END_DATE"));
|
||||
@ -155,29 +157,35 @@ public class CreateFiveGradeDataAction {
|
||||
//isOverdue : 是否逾期 ;true:为算出逾期对应的金额 false:为算出所有剩余未还的金额
|
||||
private double calcOverDuePrincipal(String distributorNo,String type,boolean isOverdue,String fivegrade,Transaction tx) throws Exception{
|
||||
double sumOverdueMoney = 0.00;
|
||||
String sql = " SELECT sum(lrp."+type+" - ifnull(lri."+type+",0) - ifnull(lri."+type+"_ADJUST,0)) sumovermoney "
|
||||
+ " FROM lc_rent_plan lrp "
|
||||
+ " LEFT JOIN (select sum("+type+") "+type+",sum("+type+"_adjust) "+type+"_adjust,CONTRACT_ID,PLAN_LIST from lc_rent_income group by CONTRACT_ID,PLAN_LIST ) lri ON lrp.PLAN_LIST = lri.PLAN_LIST and lri.CONTRACT_ID = lrp.CONTRACT_ID "
|
||||
+ " left join lb_contract_info lci on lci.ID = lrp.CONTRACT_ID "
|
||||
+ " @fivegrade@ "
|
||||
+ " where lci.distributor_id = '"+distributorNo+"' @overdue@ "
|
||||
+ " group by lci.distributor_id ";
|
||||
|
||||
String sql = "select round(sum("+("CORPUS".equals(type)?"getCorpusOverFormal":"getInterestOverFormal")+"(lrp.PAYMENT_NUMBER,lrp.PLAN_LIST)),2) as sumovermoney from lb_contract_info lci"
|
||||
+" @fivegrade@ "
|
||||
+" left join lc_rent_plan lrp on lci.id = lrp.CONTRACT_ID"
|
||||
+ " where lci.distributor_id = '"+distributorNo+"' and lci.CONTRACT_STATUS = '31' @overdue@ ";
|
||||
if (this.contractNum > 2000) {
|
||||
sql = " SELECT sum(lrp."+type+" - ifnull(lri."+type+",0) - ifnull(lri."+type+"_ADJUST,0)) sumovermoney "
|
||||
+ " FROM lc_rent_plan lrp "
|
||||
+ " LEFT JOIN (select sum("+type+") "+type+",sum("+type+"_adjust) "+type+"_adjust,CONTRACT_ID,PLAN_LIST from lc_rent_income group by CONTRACT_ID,PLAN_LIST ) lri ON lrp.PLAN_LIST = lri.PLAN_LIST and lri.CONTRACT_ID = lrp.CONTRACT_ID "
|
||||
+ " left join lb_contract_info lci on lci.ID = lrp.CONTRACT_ID "
|
||||
+ " @fivegrade@ "
|
||||
+ " where lci.distributor_id = '"+distributorNo+"' @overdue@ "
|
||||
+ " group by lci.distributor_id ";
|
||||
}
|
||||
if(true==isOverdue){
|
||||
sql=sql.replaceAll("@overdue@", "and lrp.PLAN_DATE<'"+StringFunction.getTodayNow().substring(0, 10)+"'");
|
||||
sql=sql.replaceAll("@overdue@", "and lrp.PLAN_DATE<'"+StringFunction.getTodayNow().substring(0, 10)+"'");
|
||||
}else{
|
||||
sql=sql.replaceAll("@overdue@", "");
|
||||
sql=sql.replaceAll("@overdue@", "");
|
||||
}
|
||||
if(fivegrade==null||fivegrade.length() == 0){
|
||||
sql=sql.replaceAll("@fivegrade@", "");
|
||||
sql=sql.replaceAll("@fivegrade@", "");
|
||||
}else{
|
||||
sql=sql.replaceAll("@fivegrade@", "inner join LC_CALC_CONDITION_STATUS lfg on lfg.five_grade ='"+fivegrade+"' and lfg.contract_id = lci.ID");
|
||||
sql=sql.replaceAll("@fivegrade@", "inner join LC_CALC_CONDITION_STATUS LCCS on lci.id = LCCS.CONTRACT_ID and LCCS.five_grade ='"+fivegrade+"'");
|
||||
}
|
||||
SqlObject sqlobj = new SqlObject(sql);
|
||||
ASResultSet rs = tx.getASResultSet(sqlobj);
|
||||
if(rs.next()){
|
||||
sumOverdueMoney = rs.getDouble("sumovermoney");
|
||||
}
|
||||
rs.close();
|
||||
return sumOverdueMoney;
|
||||
}
|
||||
private double calcAllOverDuePrincipal(Transaction tx) throws Exception{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user