自动五级分类执行

This commit is contained in:
liuzhao 2018-08-20 15:48:27 +08:00
parent 5b7b5032de
commit 195a5b322a
2 changed files with 13 additions and 102 deletions

View File

@ -30,14 +30,13 @@
<script type="text/javascript">
function execute(){
var Result = AsControl.RunJavaMethod("com.tenwa.lease.app.quartzmession.AutoFiveGradeClass", "execute","");
alert("执行成功!");
/* if(Result=='success'){
if(Result=='success'){
alert("执行成功!");
reloadSelf();
}else{
alert("执行失败!");
reloadSelf();
} */
}
}
function setAutoClassification(){
var contractId = getItemValue(0,getRow(),"ID");

View File

@ -1,107 +1,19 @@
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 org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
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.jbo.JBOTransaction;
import com.amarsoft.are.util.StringFunction;
import com.base.util.QuartzUtil;
import com.tenwa.comm.util.date.DateAssistant;
import com.tenwa.flow.comm.handler.flowmanage.OverdueProjectCache;
public class AutoFiveGradeClass {
public void execute() throws JobExecutionException{
String startime = StringFunction.getTodayNow();
try {
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();
BizObjectManager lccsManager = JBOFactory.getBizObjectManager(LC_CALC_CONDITION_STATUS.CLASS_NAME);
BizObjectManager lciManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.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());
//1.获取等级
String fiveGrade = getFiveConfig(overday);
//2.更新跑批状态表(最新)
lccsManager.createQuery("update o set FIVE_GRADE='"+fiveGrade+"',FIVE_GRADE_DATE=:fivegradedate 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);
}
}
}
}
tx.commit();
} catch (Exception e) {
public String execute(){
AutoFiveGradeClassification autoFive = new AutoFiveGradeClassification();
try {
if(tx!=null){
tx.rollback();
String result= autoFive.autoFiveGradeClassification();
if(result=="success"){
return "success";
}else{
return "error";
}
} catch (JBOException e1) {
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(overDays+" BETWEEN overdue_loan_min and overdue_loan_max").getSingleResult(false);
if(gradeConfg!=null){
return gradeConfg.getAttribute(LM_GRADE_CLASSIFICATION.loan_result).getString();
}else{
return "ClassifyResult01";
}
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
}