佣金设置,五级分类执行定时

This commit is contained in:
liuzhao 2018-08-20 09:34:12 +08:00
parent ede97a61b3
commit 6b7e637830
5 changed files with 284 additions and 3 deletions

View File

@ -23,10 +23,22 @@
dwTemp.genHTMLObjectWindow("");
String sButtons[][] =new String[][] {
{"true","","Button","设置自动分类","设置自动分类","setAutoClassification()","","","","btn_icon_set"},
{"true","","Button","取消自动分类","取消自动分类","cancelAutoClassification()","","","","btn_icon_delete"}
{"true","","Button","取消自动分类","取消自动分类","cancelAutoClassification()","","","","btn_icon_delete"},
{"true","","Button","执行定时任务","执行定时任务","execute()","","","",""}
};
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
function execute(){
var Result = AsControl.RunJavaMethod("com.tenwa.lease.app.quartzmession.AutoFiveGradeClass", "execute","");
alert("执行成功!");
/* if(Result=='success'){
alert("执行成功!");
reloadSelf();
}else{
alert("执行失败!");
reloadSelf();
} */
}
function setAutoClassification(){
var contractId = getItemValue(0,getRow(),"ID");
var paymentNumber = getItemValue(0,getRow(),"PAYMENT_NUMBER");

View File

@ -40,7 +40,7 @@ $().ready(function(){
function newRecord(){
var sUrl = "/Tenwa/Lease/App/Interface/CarInfo/LbProductSalvageInfo.jsp";
AsControl.OpenView(sUrl,'','_self','');
AsControl.OpenView(sUrl,'add=add','_self','');
}
function viewAndEdit(){
var sUrl = "/Tenwa/Lease/App/Interface/CarInfo/LbProductSalvageInfo.jsp";
@ -49,7 +49,7 @@ $().ready(function(){
alert("参数不能为空!");
return ;
}
AsControl.OpenView(sUrl,'id=' +sPara ,'_self','');
AsControl.OpenView(sUrl,'id=' +sPara+'&edit=edit' ,'_self','');
}
</script>

View File

@ -6,11 +6,14 @@
History Log:
*/
String sPrevUrl = CurPage.getParameter("id");
String edit = CurPage.getParameter("edit");
String add = CurPage.getParameter("add");
/* if(sPrevUrl == null) sPrevUrl = ""; */
String sTempletNo = "LB_PRODUCT_SALVAGE_INFO";//--Ä£°åºÅ--
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
doTemp.setHtmlEvent("dis_attribute", "onchange", "selectcommission");
/* doTemp.setColTips("", "²âÊÔ"); */
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2";//freeform
@ -31,6 +34,14 @@
setItemValue(0,0,"UpdateOrgID","<%=CurUser.getOrgName()%>");
setItemValue(0,0,"UpdateTime","<%=StringFunction.getTodayNow()%>");
var edit='<%=edit%>';
if(edit=="edit"){
setItemReadOnly(0,0,"effect_start",true);
setItemReadOnly(0,0,"effect_end",true);
setItemReadOnly(0,0,"product_id",true);
setItemReadOnly(0,0,"dis_attribute",true);
}
var fix_amount = getItemValue(0,0,"fix_amount");
var dis_ratio = getItemValue(0,0,"dis_ratio");
if(fix_amount!=""){
@ -65,6 +76,57 @@
}
}
function save(){
debugger;
var oDate = new Date(); //实例一个时间对象;
var year = oDate.getFullYear(); //获取系统的年;
var month = oDate.getMonth()+1; //获取系统月份由于月份是从0开始计算所以要加1
if(month>=1 && month<=9){
month = ""+0+month;
}
var day = oDate.getDate(); // 获取系统日,
var time = ""+year+month+day;
time = parseInt(time);
var effect_start=getItemValue(0,0,"effect_start");
effect_start = effect_start.replace("/","");
effect_start = effect_start.replace("/","");
effect_start = parseInt(effect_start);
var effect_end=getItemValue(0,0,"effect_end");
effect_end = effect_end.replace("/",'');
effect_end = effect_end.replace("/",'');
effect_end = parseInt(effect_end);
/* if(effect_start<time || effect_end<=effect_start){
alert("您输入的生效开始日期或生效结束日期不对!");
return;
} */
var add = '<%=add%>';
if(add=="add"){
if(effect_start<=time){
alert("您输入的生效开始日期应大于当前日期");
return;
}
if(effect_end<effect_start){
alert("您输入的生效结束日期应大于或等于生效开始日期");
return;
}
var effectStart=getItemValue(0,0,"effect_start");
var leas_form=getItemValue(0,0,"product_id");
var Result = AsControl.RunJavaMethod("com.tenwa.apzl.commission.commissionSet", "commissionSet","effectStart="+effectStart+",leasForm="+leas_form);
if(Result=='success'){
alert("保存成功!");
//reloadSelf();
}else{
alert("您输入的生效开始日期重叠!");
return;
}
}
as_save("myiframe0","returnList()");
}
function returnList(){

View File

@ -0,0 +1,71 @@
package com.tenwa.apzl.commission;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import jbo.app.LB_PRODUCT_SALVAGE;
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.awe.util.ASResultSet;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
public class commissionSet {
public String effectStart;
public String leasForm;
public String getEffectStart() {
return effectStart;
}
public void setEffectStart(String effectStart) {
this.effectStart = effectStart;
}
public String getLeasForm() {
return leasForm;
}
public void setLeasForm(String leasForm) {
this.leasForm = leasForm;
}
public String commissionSet() throws Exception{
JBOTransaction tx=null;
Transaction Sqlca=null;
tx= JBOFactory.createJBOTransaction();
Sqlca=Transaction.createTransaction(tx);
/*BizObjectManager lpsManager = JBOFactory.getBizObjectManager(LB_PRODUCT_SALVAGE.CLASS_NAME);
BizObject lpsObject = lpsManager.createQuery("id=:id").setParameter("id", this.getId()).getSingleResult(false);
String leasForm = lpsObject.getAttribute("product_id").toString();*/
int end = 0;
String sql="SELECT MAX(effect_end) AS effect_end FROM LB_PRODUCT_SALVAGE where product_id=:product_id";
SqlObject asql = new SqlObject(sql).setParameter("product_id", leasForm);
try {
ASResultSet rs = Sqlca.getResultSet(asql);
if(rs.next()){
String effectEnd = rs.getString(1);
effectEnd = effectEnd.replaceAll("/", "");
end = Integer.parseInt(effectEnd);
}
} catch (Exception e) {
e.printStackTrace();
}
String startE = this.getEffectStart();
startE = startE.replaceAll("/", "");
int start = Integer.parseInt(startE);
if(start<=end){
return "fail";
}else{
return "success";
}
}
}

View File

@ -0,0 +1,136 @@
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();
// 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 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) {
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 "getGrade01";
}
}
}