添加合同撤销定时任务

This commit is contained in:
jianghongdong 2018-07-18 19:48:34 +08:00
parent 0b8a871655
commit dc30f170c5

View File

@ -0,0 +1,102 @@
package com.tenwa.comm.message.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import jbo.com.tenwa.entity.comm.message.BT_BUSSINESS_MESSAGE_CONFIG;
import jbo.com.tenwa.lease.comm.LB_BUSINESS_OVERDATE;
import jbo.com.tenwa.lease.comm.LB_CANCLE_INFO;
import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO;
import org.quartz.Job;
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.tenwa.comm.util.jboutil.DataOperatorUtil;
/**
* 对业务审批结束后超过指定时间未合同制作的业务合同进行
* 业务撤销操作
* @author jianghd
*
*/
public class BusinessCancelJob implements Job {
private String overDate;
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
JBOTransaction tx=null;
try {
tx= JBOFactory.createJBOTransaction();
this.executeMessage(tx);
tx.commit();
} catch (Exception e) {
try {
if(tx!=null){
tx.rollback();
}
} catch (JBOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
}
}
/**
* 获取符合合同撤销条件的项目基本信息
* @param tx
* @return
* @throws Exception
*/
public List<Map<String, String>> loadMessageNo(JBOTransaction tx ) throws Exception{
//1.获取配置的超时天数
String sql1 = "SELECT max(INPUTTIME) inputtime,over_date FROM lb_business_overdate where inputtime is not null and over_date>0 group by INPUTTIME";
List<Map<String, String>> ds = DataOperatorUtil.getDataBySql(tx, sql1, null);
overDate = "";
if(ds.size()>0){
overDate = ds.get(0).get("over_date");
}
if(overDate ==""||Integer.parseInt(overDate)==0){
return null;
}
//2.获取超时的未制作合同的业务记录
String sql="select ID from lb_project_info O where O.project_status='13'"+
" and not EXISTS (select 1 from flow_bussiness_object fbo where fbo.proj_id=O.id and fbo.flow_name='合同制作流程')"+
" and not EXISTS (select 1 from lb_contract_info_temp lci where lci.project_id=O.id)"+
" and TO_DAYS(SYSDATE())-TO_DAYS(O.end_date)>"+overDate;
ds = DataOperatorUtil.getDataBySql(tx, sql, null);
if(ds.size()>0){
return ds;
}
return null;
}
public void executeMessage( JBOTransaction tx ) throws Exception{
List<Map<String,String>> ds=this.loadMessageNo(tx);
BizObjectManager lpibom = JBOFactory.getBizObjectManager(LB_PROJECT_INFO.CLASS_NAME, tx);
BizObjectManager lcibom = JBOFactory.getBizObjectManager(LB_CANCLE_INFO.CLASS_NAME, tx);
if(ds!=null){
for (Map<String, String> map : ds) {
//1.更新项目表状态为104
lpibom.createQuery("update O set project_status='104' where id=:id").setParameter("ID", map.get("ID")).executeUpdate();
//2.新增项目对应撤销详情
BizObject lcibo = lcibom.newObject();
lcibo.setAttributeValue(LB_CANCLE_INFO.CANCLE_DATE, StringFunction.getTodayNow());
lcibo.setAttributeValue(LB_CANCLE_INFO.CANCLE_RESON,"系统检测到该业务超过合同制作等待发起时间:"+overDate+"天,故自动撤销该业务。");
lcibo.setAttributeValue(LB_CANCLE_INFO.INPUTTIME,StringFunction.getTodayNow());
lcibo.setAttributeValue(LB_CANCLE_INFO.INPUTUSERID,"system");
lcibo.setAttributeValue(LB_CANCLE_INFO.INPUTORGID,"system");
lcibo.setAttributeValue(LB_CANCLE_INFO.PROJECT_ID,map.get("ID"));
// lcibo.setAttributeValue(LB_CANCLE_INFO.CANCLE_TYPE,"");
lcibom.saveObject(lcibo);
}
}
}
}