79 lines
3.2 KiB
Java
79 lines
3.2 KiB
Java
package com.tenwa.reckon.adjustInterest;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.UUID;
|
|
|
|
import org.quartz.Job;
|
|
import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionException;
|
|
|
|
import com.amarsoft.app.awe.config.InitDBType;
|
|
import com.amarsoft.are.ARE;
|
|
import com.amarsoft.are.jbo.JBOException;
|
|
import com.amarsoft.are.jbo.JBOFactory;
|
|
import com.amarsoft.are.jbo.JBOTransaction;
|
|
import com.amarsoft.are.log.Log;
|
|
import com.base.util.QuartzUtil;
|
|
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
|
import com.tenwa.reckon.util.DateUtil;
|
|
|
|
public class AdjustStartDateYear implements Job {
|
|
|
|
private static Log logger=ARE.getLog();
|
|
@Override
|
|
public void execute(JobExecutionContext arg0) throws JobExecutionException{
|
|
JBOTransaction tx=null;
|
|
try {
|
|
tx=JBOFactory.createJBOTransaction();
|
|
AdjustInterestController aic=new AdjustInterestController();
|
|
|
|
String flowunid=UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
|
logger.info("起租日年调息开始 编号:"+flowunid);
|
|
String date=DateUtil.getSystemTimeByFormat("yyyy/MM/dd");
|
|
logger.info("调息日期:"+date);
|
|
aic.adjustStartDateYear(flowunid,date);
|
|
|
|
String sql;
|
|
if("MYSQL".equals(InitDBType.DBTYPE)){
|
|
sql="SELECT ifnull(ac.adjustdate,cc.start_date) ADJUSTDATE,TO_DAYS(NOW())-IFNULL(TO_DAYS(ac.adjustdate),TO_DAYS(cc.start_date)) DAYS FROM lc_calc_condition cc LEFT JOIN"
|
|
+" (SELECT MAX(adjust_date) adjustdate,payment_number FROM LC_ADJUST_CONTRACT WHERE STATUS='rate_change_in' GROUP BY payment_number) ac ON cc.payment_number=ac.payment_number "
|
|
+ "WHERE TO_DAYS(NOW())-IFNULL(TO_DAYS(ac.adjustdate),TO_DAYS(cc.start_date))>365 AND cc.ADJUST_TYPE<>'fixed' AND cc.ADJUST_STYLE='start_date_year'";
|
|
}else{
|
|
sql="SELECT nvl(ac.adjustdate,cc.start_date) ADJUSTDATE,to_date(trunc(sysdate))-nvl(to_date(ac.adjustdate,'yyyy/MM/dd'),to_date(cc.start_date,'yyyy/MM/dd')) days FROM lc_calc_condition cc LEFT JOIN"
|
|
+" ( SELECT MAX(adjust_date) adjustdate,payment_number FROM LC_ADJUST_CONTRACT WHERE STATUS='rate_change_in' GROUP BY payment_number ) ac ON cc.payment_number=ac.payment_number "
|
|
+ "WHERE to_date(trunc(sysdate))-nvl(to_date(ac.adjustdate,'yyyy/MM/dd'),to_date(cc.start_date,'yyyy/MM/dd'))>365 AND cc.ADJUST_TYPE<>'fixed' AND cc.ADJUST_STYLE='start_date_year'";
|
|
}
|
|
List<Map<String,String>>list= DataOperatorUtil.getDataBySql(tx, sql, null);
|
|
if(list.size()>0){
|
|
for(int i=0;i<list.size();i++){
|
|
int year=DateUtil.getTimeByFormat(list.get(i).get("ADJUSTDATE"),"yyyy/MM/dd").getYear();
|
|
if((year%4==0&&year%100!=0)||year%400==0){
|
|
if(Integer.parseInt(list.get(i).get("DAYS"))<366){
|
|
continue;
|
|
}
|
|
}
|
|
logger.info("补充以前未自动调息日期:"+list.get(i).get("ADJUSTDATE"));
|
|
aic.adjustStartDateYear(flowunid,list.get(i).get("ADJUSTDATE"));
|
|
}
|
|
}
|
|
|
|
logger.info("起租日年调息完成");
|
|
tx.commit();
|
|
QuartzUtil.insertLog("com.tenwa.reckon.adjustInterest.AdjustStartDateYear", "success", "成功");
|
|
} catch (Exception e) {
|
|
QuartzUtil.insertLog("com.tenwa.reckon.adjustInterest.AdjustStartDateYear", "success", "失败");
|
|
try {
|
|
if(tx!=null){
|
|
tx.rollback();
|
|
}
|
|
} catch (JBOException e1) {
|
|
// TODO Auto-generated catch block
|
|
e1.printStackTrace();
|
|
}
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|