迁光大 五级分类逻辑

This commit is contained in:
jianghongdong 2018-08-14 15:17:00 +08:00
parent 157c29edcb
commit 7a9f88d771
2 changed files with 187 additions and 33 deletions

View File

@ -4301,6 +4301,53 @@
</managerProperties>
</manager>
</class>
<class name="LB_FIVE_GRADE" label="" keyAttributes="">
<attributes>
<attribute name="id" label="id" type="STRING" length="100"/>
<attribute name="summary_id" label="summary_id" type="STRING" length="100"/>
<attribute name="contract_id" label="contract_id" type="STRING" length="100"/>
<attribute name="five_grade" label="five_grade" type="STRING" length="100"/>
<attribute name="five_grade_date" label="five_grade_date" type="STRING" length="100"/>
<attribute name="five_grade_demo" label="five_grade_demo" type="STRING" length="4000"/>
<attribute name="inputuserid" label="inputuserid" type="STRING" length="100"/>
<attribute name="inputorgid" label="inputorgid" type="STRING" length="100"/>
<attribute name="inputtime" label="inputtime" type="STRING" length="100"/>
<attribute name="updateuserid" label="updateuserid" type="STRING" length="100"/>
<attribute name="updateorgid" label="updateorgid" type="STRING" length="100"/>
<attribute name="updatetime" label="updatetime" type="STRING" length="100"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="lb_five_grade" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
<class name="LB_FIVE_GRADE_SUMMARY" label="" keyAttributes="id">
<attributes>
<attribute name="id" label="id" type="STRING" length="100"/>
<attribute name="serialno" label="serialno" type="STRING" length="100"/>
<attribute name="excute_date" label="excute_date" type="STRING" length="100"/>
<attribute name="contract_total" label="contract_total" type="STRING" length="100"/>
<attribute name="normal_contract" label="normal_contract" type="STRING" length="100"/>
<attribute name="attention_contract" label="attention_contract" type="STRING" length="100"/>
<attribute name="secondary_contract" label="secondary_contract" type="STRING" length="100"/>
<attribute name="suspect_contract" label="suspect_contract" type="STRING" length="100"/>
<attribute name="loss_contract" label="loss_contract" type="STRING" length="100"/>
<attribute name="demo" label="demo" type="STRING" length="1000"/>
<attribute name="inputuserid" label="inputuserid" type="STRING" length="100"/>
<attribute name="inputorgid" label="inputorgid" type="STRING" length="100"/>
<attribute name="inputtime" label="inputtime" type="STRING" length="100"/>
<attribute name="updateuserid" label="updateuserid" type="STRING" length="100"/>
<attribute name="updatetime" label="updatetime" type="STRING" length="100"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="lb_five_grade_summary" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
</package>
<package name="jbo.com.tenwa.lease.carbrand" >
<class name="LB_CLAIMS_BOOK_DETAIL" label="索赔申请书详情表" keyAttributes="ID">

View File

@ -3,7 +3,10 @@ package com.tenwa.lease.app.quartzmession;
import java.util.List;
import jbo.app.tenwa.calc.LC_CALC_CONDITION_STATUS;
import jbo.app.tenwa.customer.LM_GRADE_CLASSIFICATION;
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
import jbo.com.tenwa.lease.comm.LB_FIVE_GRADE;
import jbo.com.tenwa.lease.comm.LB_FIVE_GRADE_SUMMARY;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
@ -22,54 +25,158 @@ import com.tenwa.flow.comm.handler.flowmanage.OverdueProjectCache;
public class AutoFiveGradeClassification implements Job {
// @Override
// public void execute(JobExecutionContext arg0) throws JobExecutionException{
// JBOTransaction tx=null;
// String startime = StringFunction.getTodayNow();
// try {
// tx= JBOFactory.createJBOTransaction();
// BizObjectManager lccsManager = JBOFactory.getBizObjectManager(LC_CALC_CONDITION_STATUS.CLASS_NAME);
// BizObjectManager lciManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);
// tx.join(lccsManager);
// tx.join(lciManager);
// List<BizObject> lccss = lccsManager.createQuery("IS_AUTO='Y' ").getResultList(false);
// if(lccss.size()>0){
// for(BizObject lccs:lccss){
// BizObject lci = lciManager.createQuery("ID=:id ").setParameter("id",lccs.getAttribute("CONTRACT_ID").getString()).getSingleResult(false);
// if (lci == null) {
// continue;
// }
// String productId = lci.getAttribute("PRODUCT_ID").getString();
// if(productId!=null){
// String overdays = OverdueProjectCache.getOverDays(lccs.getAttribute("CONTRACT_ID").getString(), lccs.getAttribute("PAYMENT_NUMBER").getString());
// //String fiveResult = ProductParamUtil.getFiveGradeClassification(productId,overdays,"OverDueDays","ClassifyResult");
// String fivegrade = getFiveConfig(overdays);//lccs.getAttribute("FIVE_GRADE").toString().trim();
// lccsManager.createQuery("update o set FIVE_GRADE=:fivegrade,FIVE_GRADE_DATE=:fivegradedate where ID=:id ").setParameter("fivegrade",fivegrade).setParameter("fivegradedate",DateAssistant.getToday()).setParameter("id",lccs.getAttribute("ID").getString()).executeUpdate();
// }
// }
// }
// tx.commit();
// QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.AutoFiveGradeClassification", "success", "成功");
// } catch (Exception e) {
// QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.AutoFiveGradeClassification", "success", "失败");
// try {
// if(tx!=null){
// tx.rollback();
// }
// } catch (JBOException e1) {
// e1.printStackTrace();
// }
// e.printStackTrace();
// }
// }
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException{
JBOTransaction tx=null;
String startime = StringFunction.getTodayNow();
try {
tx= JBOFactory.createJBOTransaction();
BizObjectManager lccsManager = JBOFactory.getBizObjectManager(LC_CALC_CONDITION_STATUS.CLASS_NAME);
BizObjectManager lciManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);
tx.join(lccsManager);
tx.join(lciManager);
List<BizObject> lccss = lccsManager.createQuery("IS_AUTO='Y' ").getResultList(false);
if(lccss.size()>0){
for(BizObject lccs:lccss){
BizObject lci = lciManager.createQuery("ID=:id ").setParameter("id",lccs.getAttribute("CONTRACT_ID").getString()).getSingleResult(false);
if (lci == null) {
continue;
}
String productId = lci.getAttribute("PRODUCT_ID").getString();
if(productId!=null){
String overdays = OverdueProjectCache.getOverDays(lccs.getAttribute("CONTRACT_ID").getString(), lccs.getAttribute("PAYMENT_NUMBER").getString());
String fiveResult = ProductParamUtil.getFiveGradeClassification(productId,overdays,"OverDueDays","ClassifyResult");
String fivegrade = lccs.getAttribute("FIVE_GRADE").toString().trim();
if (!"".equals(fivegrade)) {
int i = Integer.valueOf(fiveResult.replace("ClassifyResult", ""));
int j = Integer.valueOf(fivegrade.replace("ClassifyResult", ""));
//Îå¼·ÖÀà·¢Éúϵ÷
if (i > j) {
lccsManager.createQuery("update o set IS_REMIND=:isremind,FIVE_GRADE=:fivegrade,FIVE_GRADE_DATE=:fivegradedate where ID=:id ").setParameter("isremind","Y").setParameter("fivegrade",fiveResult).setParameter("fivegradedate",DateAssistant.getToday()).setParameter("id",lccs.getAttribute("ID").getString()).executeUpdate();
}
}else{
lccsManager.createQuery("update o set FIVE_GRADE=:fivegrade,FIVE_GRADE_DATE=:fivegradedate where ID=:id ").setParameter("fivegrade",fiveResult).setParameter("fivegradedate",DateAssistant.getToday()).setParameter("id",lccs.getAttribute("ID").getString()).executeUpdate();
}
}
}
}
tx.commit();
autoFiveGradeClassification();
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.AutoFiveGradeClassification", "success", "³É¹¦");
} catch (Exception e) {
QuartzUtil.insertLog(startime,"com.tenwa.lease.app.quartzmession.AutoFiveGradeClassification", "success", "ʧ°Ü");
e.printStackTrace();
}
}
/**
* 自动五级分类
* @return
* @throws Exception
*/
public String autoFiveGradeClassification() throws Exception{
JBOTransaction tx=null;
try {
tx= JBOFactory.createJBOTransaction();
int a=0;//正常合同数
int b=0;//关注合同数
int c=0;//次级合同数
int d=0;//可疑合同数
int e=0;//损失合同数
BizObjectManager lccsManager = JBOFactory.getBizObjectManager(LC_CALC_CONDITION_STATUS.CLASS_NAME);
BizObjectManager lciManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);
BizObjectManager five_grade = JBOFactory.getBizObjectManager(LB_FIVE_GRADE_SUMMARY.CLASS_NAME);
BizObjectManager five_gr = JBOFactory.getBizObjectManager(LB_FIVE_GRADE.CLASS_NAME);
tx.join(lccsManager);
tx.join(lciManager);
tx.join(five_gr);
List<BizObject> lccss = lccsManager.createQuery("select CONTRACT_ID,PAYMENT_NUMBER from O where O.is_auto = 'Y' and PLAN_STATUS = '31'").getResultList(false);
if(lccss.size()>0){
for(BizObject lccs:lccss){
String FIVE_GRADE;
BizObject lci = lciManager.createQuery("ID=:id ").setParameter("id",lccs.getAttribute("CONTRACT_ID").getString()).getSingleResult(false);
String productId = lci.getAttribute("PRODUCT_ID").getString();
if(productId!=null){
//0.获取逾期天数和期次
String overday = OverdueProjectCache.getOverDays(lccs.getAttribute("CONTRACT_ID").getString(), lccs.getAttribute("PAYMENT_NUMBER").getString());
// Integer overdays=Integer.parseInt(overday.replaceAll("\\.0", ""));
String outlist = OverdueProjectCache.getOutList(lccs.getAttribute("CONTRACT_ID").getString(), lccs.getAttribute("PAYMENT_NUMBER").getString());
outlist=outlist.replaceAll("\\.0", "");
//1.获取等级
String fiveGrade = getFiveConfig(overday);//ProductParamUtil.getFiveGradeClassification(productId, overdays);
//2.更新跑批状态表(最新)
lccsManager.createQuery("update o set FIVE_GRADE='"+fiveGrade+"',FIVE_GRADE_DATE=:fivegradedate,overduedays='"+overday+"',overdue='"+outlist+"' where CONTRACT_ID=:id ").setParameter("fivegradedate",DateAssistant.getToday()).setParameter("id",lccs.getAttribute("CONTRACT_ID").getString()).executeUpdate();
FIVE_GRADE=fiveGrade;
BizObject singleResult = five_gr.createQuery("select * from o where FIVE_GRADE_DATE=:fivegradedate and CONTRACT_ID=:id ").setParameter("fivegradedate",DateAssistant.getToday()).setParameter("id",lccs.getAttribute("CONTRACT_ID").getString()).getSingleResult(false);
//3.入分类等级明细表(累计)
if(null==singleResult){
BizObject fgbo=five_gr.newObject();
fgbo.setAttributeValue("CONTRACT_ID", lccs.getAttribute("CONTRACT_ID").getString());
fgbo.setAttributeValue("FIVE_GRADE",FIVE_GRADE);
fgbo.setAttributeValue("FIVE_GRADE_DATE", DateAssistant.getToday());
fgbo.setAttributeValue("FIVE_GRADE_DEMO", DateAssistant.getToday()+"||日自动跑批");
fgbo.setAttributeValue("INPUTUSERID", "admin");
fgbo.setAttributeValue("INPUTUSERID", "admin");
fgbo.setAttributeValue("INPUTTIME", DateAssistant.getToday());
five_gr.saveObject(fgbo);
}
//3.对各个等级进行统计
switch(fiveGrade){
case "ClassifyResult01":a++;break;
case "ClassifyResult02":b++;break;
case "ClassifyResult03":c++;break;
case "ClassifyResult04":d++;break;
case "ClassifyResult05":e++;break;
}
}
}
//入汇总表
BizObject bo=five_grade.newObject();
bo.setAttributeValue("EXCUTE_DATE", DateAssistant.getToday());
bo.setAttributeValue("CONTRACT_TOTAL",a+b+c+d+e);
bo.setAttributeValue("NORMAL_CONTRACT",a);
bo.setAttributeValue("ATTENTION_CONTRACT",b);
bo.setAttributeValue("SECONDARY_CONTRACT",c);
bo.setAttributeValue("SUSPECT_CONTRACT",d);
bo.setAttributeValue("LOSS_CONTRACT",e);
bo.setAttributeValue("DEMO",DateAssistant.getToday()+",自动跑批");
bo.setAttributeValue("INPUTUSERID","admin");
five_grade.saveObject(bo);
}
tx.commit();
} catch (Exception e) {
try {
if(tx!=null){
tx.rollback();
}
} catch (JBOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
e.printStackTrace();
return "error";
}
return "success";
}
public String getFiveConfig(String overDays) throws JBOException{
BizObject gradeConfg = JBOFactory.getBizObjectManager(LM_GRADE_CLASSIFICATION.CLASS_NAME).createQuery("select * from O where "+overDays+" BETWEEN overdue_loan_min and overdue_loan_max").getSingleResult(false);
if(gradeConfg!=null){
return gradeConfg.getAttribute(LM_GRADE_CLASSIFICATION.loan_result).getString();
}
throw new JBOException("五级分类未配置……");
}
}