1490 lines
60 KiB
Java
1490 lines
60 KiB
Java
package com.tenwa.lease.app.quartzmession;
|
||
import com.amarsoft.are.jbo.JBOException;
|
||
import com.amarsoft.awe.util.ASResultSet;
|
||
import com.amarsoft.awe.util.SqlObject;
|
||
import com.amarsoft.awe.util.Transaction;
|
||
import com.amarsoft.dict.als.cache.CacheLoaderFactory;
|
||
import com.tenwa.lease.app.quartzmession.audit.AuditOrderEnums;
|
||
import com.tenwa.reckon.util.DateUtil;
|
||
import org.apache.commons.lang3.StringUtils;
|
||
import org.apache.commons.lang3.time.DateUtils;
|
||
import org.apache.log4j.LogManager;
|
||
import org.apache.log4j.Logger;
|
||
import org.quartz.Job;
|
||
import org.quartz.JobExecutionContext;
|
||
import org.quartz.JobExecutionException;
|
||
import java.sql.SQLException;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* 初始化信审考核报表数据跑批
|
||
* @author xiezhiwen
|
||
*/
|
||
public class CreditAuditHolidayBatch implements Job{
|
||
private static final Logger logger = LogManager.getLogger(CreditAuditHolidayBatch.class);// 引入logger日志
|
||
|
||
public void execute(JobExecutionContext arg0) throws JobExecutionException {
|
||
logger.info("【信审考核统计】【CreditAuditHolidayBatch】【开始】<<<<<<<<<<<<<: CreditAuditHolidayBatch20211118");
|
||
long beginTime = System.currentTimeMillis();
|
||
String begin = DateUtil.getSystemDateDetailTime();
|
||
// insertStOrder();
|
||
int preDayCount = 30;//增量更新30天前数据
|
||
// int preDayCount = 345;//增量更新345天前数据
|
||
logger.info("【信审考核统计】【CreditAuditHolidayBatch】【开始】<<<<<<<<<<<<<: CreditAuditHolidayBatch20211124preDayCount=" + preDayCount);
|
||
deleteCreditAudit(preDayCount);
|
||
initDetail(preDayCount);
|
||
updateDetail(preDayCount);
|
||
initOrderAuditDay();
|
||
saveOrderAuditDay();
|
||
updateOrderAuditDay();
|
||
initPaymentOrderAuditDay();
|
||
savePaymentOrderAuditDay();
|
||
updatePaymentOrderAuditDay();
|
||
updateCreditAuditType();
|
||
long excuteTime = System.currentTimeMillis() - beginTime;
|
||
logger.info("【信审考核统计】【CreditAuditHolidayBatch】【完成】<<<<<<<<<<<<<: beginTime=【" + begin + "】 endTime=【" + DateUtil.getSystemDateDetailTime() +
|
||
"】 CreditAuditHolidayBatch20211118 -- excuteTime=" + excuteTime/60000);
|
||
}
|
||
|
||
/**
|
||
* 初始化或者修改审核统计报表-根据审单日期
|
||
* @return
|
||
*/
|
||
private void initPaymentOrderAuditDay(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//根据审批时间初始化信审考核表
|
||
String result1 = initPaymentOrderAuditDay(Sqlca);
|
||
Sqlca.commit();
|
||
logger.info("【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行完成<<<<<<<<<<<<<: "+result1);
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化或者修改审核统计报表-根据审单日期
|
||
* @return
|
||
*/
|
||
private void savePaymentOrderAuditDay(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//根据进单时间保存付款申请统计
|
||
String result1 = savePaymentOrderCreateDay(Sqlca);
|
||
Sqlca.commit();
|
||
logger.info("【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行完成<<<<<<<<<<<<<: "+result1);
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化或者修改审核统计报表-根据审单日期
|
||
* @return
|
||
*/
|
||
private void updatePaymentOrderAuditDay(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//修改审核通过数量,任意退回数量,一次性通过数量
|
||
String result1 = updatePaymentOrderAuditDay(Sqlca);
|
||
Sqlca.commit();
|
||
logger.info("【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行完成<<<<<<<<<<<<<: "+result1);
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【付款申请考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* 添加审核流程记录明细
|
||
* @return
|
||
*/
|
||
private void updateCreditAuditType(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【updateCreditAuditType】修改角色名称<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//初始化信审考核明细表
|
||
String updateSql="update st_credit_audit_order set auditFlowTypeDes='信审复审' where auditFlowType='0040'";
|
||
String updateSql2="update st_credit_audit_order set auditFlowTypeDes='信审经理终审' where auditFlowType='0050'";
|
||
String updateSql3="update st_credit_audit_order set auditFlowTypeDes='信审负责人' where auditFlowType='0060'";
|
||
Sqlca.executeSQL(new SqlObject(updateSql));
|
||
Sqlca.executeSQL(new SqlObject(updateSql2));
|
||
Sqlca.executeSQL(new SqlObject(updateSql3));
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【updateCreditAuditType】修改角色名称<<<<<<<<<<<<<");
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateCreditAuditType】修改角色名称>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateCreditAuditType】修改角色名称>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateCreditAuditType】修改角色名称>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 添加审核流程记录明细
|
||
* @return
|
||
*/
|
||
private void deleteCreditAudit(int preDayCount){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【deleteCreditAudit】数据清空执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//初始化信审考核明细表
|
||
String stBeginTime = queryStBeginTime(preDayCount);
|
||
String delSql="delete from st_credit_audit_order_detail where begintime > '"+ stBeginTime +"'";
|
||
String delSql2="truncate table st_credit_audit_order";
|
||
String delSql3="truncate table st_payment_audit_order";
|
||
Sqlca.executeSQL(new SqlObject(delSql));
|
||
Sqlca.executeSQL(new SqlObject(delSql2));
|
||
Sqlca.executeSQL(new SqlObject(delSql3));
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【deleteCreditAudit】数据清空执行完成<<<<<<<<<<<<<");
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【deleteCreditAudit】数据清空执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【deleteCreditAudit】数据清空执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【deleteCreditAudit】数据清空执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 增量更新st_order
|
||
* @return
|
||
*/
|
||
private void insertStOrder(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【insertStOrder】增量更新st_order<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//初始化信审考核明细表
|
||
insertStOrder(Sqlca);
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【insertStOrder】增量更新st_order<<<<<<<<<<<<");
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【insertStOrder】增量更新st_order>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【insertStOrder】增量更新st_order>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【insertStOrder】增量更新st_order>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 添加审核流程记录明细
|
||
* @return
|
||
*/
|
||
private void initDetail(int preDayCount){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【initDetail】初始化订单明细记录执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
Map<String, String> listHoliday = listHoliday(Sqlca);
|
||
logger.info("【考核统计】【initDetail】汇总假期信息列表<<<< listHoliday.size : " + listHoliday.keySet().size());
|
||
//初始化信审考核明细表
|
||
for(AuditOrderEnums.AuditTypeEnum auditTypeEnum : AuditOrderEnums.AuditTypeEnum.values()){
|
||
logger.info("【考核统计】【initDetail】初始化订单明细记录执行开始<<【"+auditTypeEnum.getFlowName()+"】<< :" + auditTypeEnum.getDesc());
|
||
initDetail(Sqlca, auditTypeEnum, preDayCount, listHoliday);
|
||
}
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【initDetail】初始化订单明细记录执行完成<<<<<<<<<<<<");
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【initDetail】初始化订单明细记录>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【initDetail】初始化订单明细记录>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【initDetail】初始化订单明细记录>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 修改审核明细的创建时间
|
||
* @return
|
||
*/
|
||
private void updateDetail(int preDayCount){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【updateDetail】修改订单明细中的创建时间执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//初始化信审考核明细表
|
||
List<AuditOrderEnums.AuditTypeEnum> typeEnumList = AuditOrderEnums.AuditTypeEnum.findCreditTypeList();
|
||
for(AuditOrderEnums.AuditTypeEnum auditTypeEnum : typeEnumList){
|
||
logger.info("【信审考核统计】【updateDetail】修改订单明细中的--创建时间开始<<【信审部分】");
|
||
updateDetail(Sqlca, auditTypeEnum, preDayCount);
|
||
logger.info("【信审考核统计】【updateDetail】修改订单明细中的--审核时间开始<<【信审部分】");
|
||
updateDetailAuditDay(Sqlca, auditTypeEnum, preDayCount);
|
||
}
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【updateDetail】修改订单明细中的创建时间执行完成<<<<<<<<<<<<<");
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateDetail】修改订单明细中的创建时间执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateDetail】修改订单明细中的创建时间执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateDetail】修改订单明细中的创建时间执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化审核统计报表-根据进单日期
|
||
* @return
|
||
*/
|
||
private void initOrderAuditDay(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【initOrderAuditDay】初始化订单表审核数据统计执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//初始化信审考核明细表
|
||
String result1 = initOrderAuditDay(Sqlca);
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【initOrderAuditDay】初始化订单表审核数据统计执行完成<<<<<<<<<<<<<: "+result1);
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【initOrderAuditDay】初始化订单表审核数据统计执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【initOrderAuditDay】初始化订单表审核数据统计执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【initOrderAuditDay】初始化订单表审核数据统计执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化或者修改审核统计报表-根据审单日期
|
||
* @return
|
||
*/
|
||
private void saveOrderAuditDay(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//初始化信审考核明细表
|
||
String result1 = saveOrderCreateDay(Sqlca);
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行完成<<<<<<<<<<<<<: "+result1);
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【saveOrderAuditDay】根据进单时间新增和修改订单统计表执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 初始化或者修改审核统计报表-根据审单日期
|
||
* @return
|
||
*/
|
||
private void updateOrderAuditDay(){
|
||
Transaction Sqlca=null;
|
||
try{
|
||
logger.info("【信审考核统计】【updateOrderAuditDay】计算信审考核统计表审核时间执行开始<<<<<<<<<<<<<");
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
//初始化信审考核明细表
|
||
String result1 = updateOrderAuditDay(Sqlca);
|
||
Sqlca.commit();
|
||
logger.info("【信审考核统计】【updateOrderAuditDay】计算信审考核统计表审核时间执行完成<<<<<<<<<<<<<: "+result1);
|
||
}catch(Exception e){
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateOrderAuditDay】计算信审考核统计表审核时间执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateOrderAuditDay】计算信审考核统计表审核时间执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
logger.error("<<<<<<<<<<<<<<<<<<<<<<【信审考核统计】【updateOrderAuditDay】计算信审考核统计表审核时间执行异常>>>>>>>>>>>>>>>>>>>>>>>");
|
||
try {
|
||
Sqlca.rollback();
|
||
} catch (JBOException e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
e.printStackTrace();
|
||
}finally {
|
||
if(Sqlca!=null) {
|
||
try {
|
||
Sqlca.commit();
|
||
Sqlca.disConnect();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 添加审核流程记录明细
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String initDetail(Transaction Sqlca, AuditOrderEnums.AuditTypeEnum auditTypeEnum, int preDayCount, Map<String, String> listHoliday) throws Exception {
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||
String ftBeginTime = queryFtBeginTime(preDayCount);
|
||
int con=0;
|
||
String nextAuditFlowType = ""; // 下阶段流程审核类型
|
||
String create_day = ""; // 流程创建日期
|
||
String audit_day = ""; // 流程审核日期
|
||
String auditTime = ""; // 审核时间
|
||
String jump_begintime = ""; // 跳过节假日之后流程开始时间
|
||
String jump_endtime = ""; // 跳过节假日之后流程结束时间
|
||
String createtime = ""; // 流程创建时间【第二个定时器进行修改】
|
||
String begintime = ""; // 流程开始时间
|
||
String endtime = ""; // 流程结束时间
|
||
|
||
String remark = "";
|
||
String auditOrderSts = "";
|
||
String auditOrderStsDes = "";
|
||
String uuidDetail = "";
|
||
String projectId = ""; // 用户id
|
||
String userid = ""; // 用户id
|
||
String username = ""; // 用户姓名
|
||
String objectno = ""; // 流程编号
|
||
String serialno = ""; // 流程处理流水
|
||
String auditFlowType = ""; // 流程审核类型
|
||
String auditFlowTypeDes = ""; // 流程审核类型说明
|
||
|
||
String auditResSts = ""; // 审核最终结果状态:0,审核中,1,审核通过,2,审核拒绝,3,退回到经销商
|
||
String auditChoiceSts = ""; // 审核最终结果状态:0,审核中,1,审核通过,2,审核拒绝,3,退回到经销商
|
||
String auditResStsDes = ""; // 流程审核结果说明
|
||
// 查询所有需要发送还款提醒的数据
|
||
String selSql="SELECT \n" +
|
||
" FBO.proj_id as project_id,\n" +
|
||
" FT.userid,\n" +
|
||
" FT.username,\n" +
|
||
" FT.objectno,\n" +
|
||
" FT.serialno,\n" +
|
||
" FT.phaseno AS auditFlowType,\n" +
|
||
" FT.phasename AS auditFlowTypeDes,\n" +
|
||
" FT.begintime,\n" +
|
||
" FT.endtime,\n" +
|
||
" FT.phaseopinion1 AS nextAuditFlowType,\n" +
|
||
" fob.phasechoice AS auditChoiceSts,\n" +
|
||
" fob.phaseopinion AS auditResSts,\n" +
|
||
" (SELECT itemname from code_library WHERE codeno='firstchoice' AND itemno=fob.phasechoice) AS auditChoiceStsDes, \n" +
|
||
" (SELECT itemname from code_library WHERE codeno='disagreeOP' AND itemno=fob.phaseopinion) AS auditResStsDes \n" +
|
||
"FROM FLOW_TASK FT\n" +
|
||
"LEFT JOIN FLOW_OPINION_BUSINESS FOB ON FT.SERIALNO=FOB.SERIALNO \n" +
|
||
"LEFT JOIN flow_bussiness_object FBO ON FT.objectno=FBO.flow_unid \n" +
|
||
"WHERE FT.flowname = '" + auditTypeEnum.getFlowName() +"'" +
|
||
" AND FT.phaseno='" + auditTypeEnum.getPhaseNo() +"'" +
|
||
" AND FT.begintime > '" + ftBeginTime +"'" +
|
||
" AND (FT.USERNAME IS NOT NULL OR FT.USERNAME <>'')";
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
while(rs.next()) {
|
||
// 获取接口推送所需数据
|
||
con++;
|
||
nextAuditFlowType = rs.getString("nextAuditFlowType"); // 下阶段流程审核类型
|
||
create_day = ""; // 流程创建日期
|
||
audit_day = ""; // 流程审核日期
|
||
auditTime = ""; // 审核时间
|
||
jump_begintime = ""; // 跳过节假日之后流程开始时间
|
||
jump_endtime = ""; // 跳过节假日之后流程结束时间
|
||
createtime = ""; // 流程创建时间【第二个定时器进行修改】
|
||
begintime = rs.getString("begintime"); // 流程开始时间
|
||
endtime = rs.getString("endtime"); // 流程结束时间
|
||
|
||
remark = "";
|
||
auditOrderSts = "";
|
||
auditOrderStsDes = "";
|
||
uuidDetail = UUID.randomUUID().toString().replace("-", "");
|
||
projectId = rs.getString("project_id"); // 用户id
|
||
userid = rs.getString("userid"); // 用户id
|
||
username = rs.getString("username"); // 用户姓名
|
||
objectno = rs.getString("objectno"); // 流程编号
|
||
serialno = rs.getString("serialno"); // 流程处理流水
|
||
auditFlowType = rs.getString("auditFlowType"); // 流程审核类型
|
||
auditFlowTypeDes = rs.getString("auditFlowTypeDes"); // 流程审核类型说明
|
||
|
||
auditResSts = rs.getString("auditResSts"); // 审核最终结果状态:0,审核中,1,审核通过,2,审核拒绝,3,退回到经销商
|
||
auditChoiceSts = rs.getString("auditChoiceSts"); // 审核最终结果状态:0,审核中,1,审核通过,2,审核拒绝,3,退回到经销商
|
||
auditResStsDes = rs.getString("auditResStsDes"); // 流程审核结果说明
|
||
if(AuditOrderEnums.CREDIT_AUDIT_TYPE.equals(auditTypeEnum.getFlowNo())){
|
||
// logger.info("【信审考核统计】【initDetail】信审统计明细--serialno=" + serialno);
|
||
if(StringUtils.isEmpty(endtime)){
|
||
auditOrderSts = "0"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核中";
|
||
}else if((StringUtils.isNotEmpty(nextAuditFlowType) && "任意退回".equals(nextAuditFlowType) )||
|
||
(StringUtils.isNotEmpty(auditChoiceSts) && "0040".equals(auditChoiceSts))){
|
||
auditOrderSts = "1"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "退回";
|
||
}else if((StringUtils.isNotEmpty(nextAuditFlowType) && "8000".equals(nextAuditFlowType)) ||
|
||
(StringUtils.isNotEmpty(auditChoiceSts) && "0010".equals(auditChoiceSts))){//
|
||
auditOrderSts = "2"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核拒绝";
|
||
}else if((StringUtils.isNotEmpty(nextAuditFlowType) && "1000".equals(nextAuditFlowType)) ||
|
||
(StringUtils.isNotEmpty(auditChoiceSts) && ("0020".equals(auditChoiceSts) || "0030".equals(auditChoiceSts)))
|
||
){//审核通过
|
||
auditOrderSts = "3"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核通过";
|
||
}else{
|
||
logger.error("【信审考核统计】【initDetail】信审统计明细初始化状态异常,查询总状态进行过滤--serialno=" + serialno);
|
||
String selSql2 ="SELECT FO.phaseno FROM FLOW_OBJECT FO WHERE FO.flowname = '" +
|
||
auditTypeEnum.getFlowName() +"'" +
|
||
" AND FO.objectno='" + objectno +"'";
|
||
ASResultSet rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
if(rs2.next()){
|
||
String phaseno = rs2.getString("phaseno");
|
||
if("1000".equals(phaseno)){
|
||
auditOrderSts = "3"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核通过";
|
||
}else if("8000".equals(phaseno)){
|
||
auditOrderSts = "2"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核拒绝";
|
||
}else {
|
||
logger.error("【信审考核统计】【initDetail】信审统计明细初始化状态异常,当前订单无法匹配对应状态--serialno=" + serialno);
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
}else if(AuditOrderEnums.FUND_AUDIT_TYPE.equals(auditTypeEnum.getFlowNo())){
|
||
//付款申请不存在拒绝,退回,或者通过提交到下一级
|
||
// logger.info("【付款申请考核统计】【initDetail】付款申请统计明细--serialno=" + serialno);
|
||
if(StringUtils.isEmpty(endtime)){
|
||
auditOrderSts = "0"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核中";
|
||
}else if(StringUtils.isNotEmpty(nextAuditFlowType) && "任意退回".equals(nextAuditFlowType)){
|
||
auditOrderSts = "1"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "退回";
|
||
}else if((StringUtils.isNotEmpty(nextAuditFlowType) && "1000".equals(nextAuditFlowType)) ||
|
||
(StringUtils.isNotEmpty(nextAuditFlowType) && AuditOrderEnums.AuditTypeEnum.ffs.getPhaseNo().equals(nextAuditFlowType))){
|
||
auditOrderSts = "3"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核通过";//当前流程订单为审核通过,并且数量等于一条,则为一次性通过
|
||
String selSql3 = "SELECT count(1) as countNum" +
|
||
" FROM FLOW_TASK " +
|
||
" WHERE objectno = '" + objectno + "'" +
|
||
" AND phaseno='" + auditFlowType + "'" +
|
||
" AND flowno ='FundPaymentCarFlow'";
|
||
ASResultSet rs3 = Sqlca.getASResultSet(new SqlObject(selSql3));
|
||
if (rs3.next()) {
|
||
if (rs3.getInt("countNum") == 1) {
|
||
remark="1";
|
||
}
|
||
}
|
||
}else{
|
||
logger.error("【付款申请考核统计】【initDetail】付款申请统计明细初始化状态异常,查询总状态进行过滤--serialno=" + serialno);
|
||
String selSql2 ="SELECT FO.phaseno FROM FLOW_OBJECT FO WHERE FO.flowname = '" +
|
||
auditTypeEnum.getFlowName() +"'" +
|
||
" AND FO.objectno='" + objectno +"'";
|
||
ASResultSet rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
if(rs2.next()){
|
||
String phaseno = rs2.getString("phaseno");
|
||
if("1000".equals(phaseno)){
|
||
auditOrderSts = "3"; // 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
auditOrderStsDes = "审核通过";
|
||
String selSql3 = "SELECT count(1) as countNum" +
|
||
" FROM FLOW_TASK " +
|
||
" WHERE objectno = '" + objectno + "'" +
|
||
" AND phaseno='" + auditFlowType + "'" +
|
||
" AND flowno ='FundPaymentCarFlow'";
|
||
ASResultSet rs3 = Sqlca.getASResultSet(new SqlObject(selSql3));
|
||
if (rs3.next()) {
|
||
if (rs3.getInt("countNum") == 1) {
|
||
remark="1";
|
||
}
|
||
}
|
||
} else {
|
||
logger.error("【付款申请考核统计】【initDetail】付款申请统计明细初始化状态异常,当前订单无法匹配对应状态--serialno=" + serialno);
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
}else {
|
||
logger.error("未知类型统计--serialno=" + serialno);
|
||
continue;
|
||
}
|
||
//开始时间处理
|
||
if(StringUtils.isNotEmpty(begintime)){
|
||
create_day = dayFormat.format(simpleDateFormat.parse(begintime));
|
||
jump_begintime = resJumpHoliday(Sqlca, begintime, listHoliday); // 跳过节假日之后流程开始时间
|
||
jump_begintime = sdf.format(simpleDateFormat.parse(jump_begintime));//格式化时间格式
|
||
createtime = sdf.format(simpleDateFormat.parse(begintime));
|
||
begintime = createtime;
|
||
}else {
|
||
logger.error("【信审考核统计】【initDetail】信审统计明细初始化状态异常,begintime为空--serialno=" + serialno);
|
||
continue;
|
||
}
|
||
//结束时间处理
|
||
if (StringUtils.isNotEmpty(endtime)){
|
||
// 2020-06-05 审核数量记录为当前时间,不跳过节假日
|
||
audit_day = dayFormat.format(simpleDateFormat.parse(endtime));
|
||
jump_endtime = resJumpHoliday(Sqlca, endtime, listHoliday); // 跳过节假日之后流程结束时间
|
||
jump_endtime = sdf.format(simpleDateFormat.parse(jump_endtime));
|
||
endtime = sdf.format(simpleDateFormat.parse(endtime));
|
||
//信审考核时间累加
|
||
auditTime = diffTime(Sqlca, jump_begintime, jump_endtime, listHoliday);
|
||
if("0".equals(auditTime)){//审核时间不足一分钟,按一分钟算
|
||
auditTime = "1";
|
||
}
|
||
}
|
||
String insertSql="INSERT INTO st_credit_audit_order_detail(id,serialno,objectno,userid,username, project_id," +
|
||
"auditFlowType," +
|
||
"auditFlowTypeDes," +
|
||
"auditType," +
|
||
"auditTypeDes," +
|
||
"createtime," +
|
||
"begintime," +
|
||
"endtime," +
|
||
"create_day," +
|
||
"audit_day," +
|
||
"jump_begintime," +
|
||
"jump_endtime," +
|
||
"auditResSts," +
|
||
"auditResStsDes," +
|
||
"auditOrderSts," +
|
||
"auditOrderStsDes," +
|
||
"audittime," +
|
||
"remark," +
|
||
"INPUTTIME, " +
|
||
"UPDATETIME " +
|
||
") " +
|
||
"VALUES ( " +
|
||
"'"+uuidDetail+"', " +
|
||
"'"+serialno+"', " +
|
||
"'"+objectno+"', " +
|
||
"'"+userid+"', " +
|
||
"'"+username+"', " +
|
||
"'"+projectId+"', " +
|
||
"'"+auditFlowType+"', " +
|
||
"'"+auditFlowTypeDes+"', " +
|
||
"'"+auditTypeEnum.getFlowNo()+"', " +
|
||
"'"+auditTypeEnum.getFlowName()+"', " +
|
||
" '"+createtime+"', " +
|
||
" '"+begintime+"', " +
|
||
" '"+endtime+"', " +
|
||
" '"+create_day+"', " +
|
||
" '"+audit_day+"', " +
|
||
" '"+jump_begintime+"', " +
|
||
" '"+jump_endtime+"', " +
|
||
"'"+auditResSts+"', " +
|
||
"'"+auditResStsDes+"', " +
|
||
"'"+auditOrderSts+"', " +
|
||
"'"+auditOrderStsDes+"', " +
|
||
"'"+auditTime+"', " +
|
||
"'"+remark+"', " +
|
||
"DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'), " +
|
||
"DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') " +
|
||
")";
|
||
Sqlca.executeSQL(new SqlObject(insertSql));
|
||
}
|
||
logger.info("【initDetail】明细初始化完成,--auditTypeEnum.getFlowName()=【" + auditTypeEnum.getFlowName() +"】 --countNum=" + con);
|
||
return String.valueOf(con);
|
||
}
|
||
|
||
/**
|
||
* 查询最小创建时间更改明细记录中对应的创建时间
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String updateDetail(Transaction Sqlca, AuditOrderEnums.AuditTypeEnum auditTypeEnum, int preDayCount) throws Exception {
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||
String ftBeginTime = queryFtBeginTime(preDayCount);
|
||
int con=0;
|
||
// 查询当前最小的审批时间
|
||
String selSql="SELECT \n" +
|
||
" FT.userid,\n" +
|
||
" FT.objectno,\n" +
|
||
" min(FT.begintime) AS begintime\n" +
|
||
" FROM FLOW_TASK FT\n" +
|
||
" LEFT JOIN FLOW_OPINION_BUSINESS FOB ON FT.SERIALNO=FOB.SERIALNO \n" +
|
||
" WHERE FT.flowname = '" + auditTypeEnum.getFlowName() +"'" +
|
||
" AND FT.phaseno='" + auditTypeEnum.getPhaseNo() +"'" +
|
||
" AND FT.begintime > '" + ftBeginTime +"'" +
|
||
" AND (FT.USERNAME IS NOT NULL OR FT.USERNAME <>'') group by FT.objectno";
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
String begintime = ""; // 流程编号
|
||
String objectno = ""; // 流程创建时间
|
||
String createtime = "";
|
||
//2020-06-05 进单时间不跳过节假日
|
||
String create_day = "";
|
||
while(rs.next()) {
|
||
// 获取接口推送所需数据
|
||
con++;
|
||
begintime = rs.getString("begintime"); // 流程编号
|
||
objectno = rs.getString("objectno"); // 流程创建时间
|
||
createtime = sdf.format(simpleDateFormat.parse(begintime));
|
||
//2020-06-05 进单时间不跳过节假日
|
||
create_day = dayFormat.format(simpleDateFormat.parse(begintime));
|
||
String updSql="UPDATE st_credit_audit_order_detail SET create_day='"+create_day+"', createtime='"+createtime+"'," +
|
||
"UPDATETIME=DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') WHERE objectno='"+objectno+"' ";
|
||
Sqlca.executeSQL(new SqlObject(updSql));
|
||
}
|
||
return String.valueOf(con);
|
||
}
|
||
|
||
/**
|
||
* 查询最小创建时间更改明细记录中对应的创建时间
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String updateDetailAuditDay(Transaction Sqlca, AuditOrderEnums.AuditTypeEnum auditTypeEnum, int preDayCount) throws Exception {
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||
String ftBeginTime = queryFtBeginTime(preDayCount);
|
||
int con=0;
|
||
// 查询当前最大的审批时间
|
||
String selSql="SELECT \n" +
|
||
" FT.userid,\n" +
|
||
" FT.objectno,\n" +
|
||
" max(FT.endtime) AS endtime\n" +
|
||
" FROM FLOW_TASK FT\n" +
|
||
" LEFT JOIN FLOW_OPINION_BUSINESS FOB ON FT.SERIALNO=FOB.SERIALNO \n" +
|
||
" WHERE FT.flowname = '" + auditTypeEnum.getFlowName() +"'" +
|
||
" AND FT.phaseno='" + auditTypeEnum.getPhaseNo() +"'" +
|
||
" AND FT.begintime > '" + ftBeginTime +"'" +
|
||
" AND (FT.endtime IS NOT NULL OR FT.endtime <>'') AND (FT.USERNAME IS NOT NULL OR FT.USERNAME <>'') group by FT.objectno, FT.userid";
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
while(rs.next()) {
|
||
// 获取接口推送所需数据
|
||
con++;
|
||
String endtime = rs.getString("endtime"); // 流程编号
|
||
String objectno = rs.getString("objectno"); // 流程创建时间2019121
|
||
String userid = rs.getString("userid"); // 当前用户
|
||
//2020-06-05 审核时间不跳过节假日
|
||
String audit_day = dayFormat.format(simpleDateFormat.parse(endtime));
|
||
String updSql="UPDATE st_credit_audit_order_detail SET audit_day='"+audit_day+"', " +
|
||
"UPDATETIME=DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') WHERE objectno='"+objectno+"' AND userid='"+userid+"' AND (endtime IS NOT NULL OR endtime <>'') ";
|
||
Sqlca.executeSQL(new SqlObject(updSql));
|
||
}
|
||
return String.valueOf(con);
|
||
}
|
||
|
||
/**
|
||
* 批量插入st_order
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String insertStOrder(Transaction Sqlca) throws Exception {
|
||
// 批量插入更新
|
||
String insertSql = "insert into st_order(\n" +
|
||
" project_id,\n" +
|
||
" project_num,\n" +
|
||
" project_name,\n" +
|
||
" contract_id,\n" +
|
||
" contract_num, \n" +
|
||
" product_id, \n" +
|
||
" product_name, \n" +
|
||
" distributor_id, \n" +
|
||
" distributor_num,\n" +
|
||
" distributor_name, \n" +
|
||
" subject_id,\n" +
|
||
" subject_name,\n" +
|
||
" customer_id,\n" +
|
||
" customer_name,\n" +
|
||
" customer_phone, \n" +
|
||
" customer_idcard,\n" +
|
||
" INPUTTIME,\n" +
|
||
" UPDATETIME\n" +
|
||
" )\n" +
|
||
" select \n" +
|
||
" lpi.id, \n" +
|
||
" lpi.PROJECT_NO, \n" +
|
||
" lpi.project_name,\n" +
|
||
" lci.id contractid, \n" +
|
||
" lci.CONTRACT_NUMBER, \n" +
|
||
" lpi.PRODUCT_ID, \n" +
|
||
" lpi.PRODUCT_NAME, \n" +
|
||
" di.id distributor_id, \n" +
|
||
" di.distributor_no,\n" +
|
||
" di.DISTRIBUTOR_NAME,\n" +
|
||
" lpi.SUBJECTID, \n" +
|
||
" lpi.SUBJECTNAME, \n" +
|
||
" ci.customerid, \n" +
|
||
" ci.fullname, \n" +
|
||
" ci.mobile, \n" +
|
||
" ci.certid,\n" +
|
||
" DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'),\n" +
|
||
" DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s')\n" +
|
||
" from lb_project_info lpi\n" +
|
||
" LEFT JOIN distributor_info di on di.distributor_no = lpi.distributor_id\n" +
|
||
" LEFT JOIN lb_union_lessee lul on lul.PROJECT_ID = lpi.id\n" +
|
||
" LEFT JOIN lb_contract_info lci on lci.id = lul.contract_id\n" +
|
||
" LEFT JOIN customer_person ci on ci.customerid = lul.CUSTOMER_ID\n" +
|
||
" LEFT JOIN st_order so on so.project_id = lpi.id " +
|
||
" WHERE so.project_id is null ";
|
||
Sqlca.executeSQL(new SqlObject(insertSql));
|
||
return "-1";
|
||
}
|
||
|
||
/**
|
||
* 初始化审核统计报表-保存审核日期相关订单
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String initOrderAuditDay(Transaction Sqlca) throws Exception {
|
||
String insertSql="INSERT INTO st_credit_audit_order( " +
|
||
" every_day, userid, username, auditFlowType, auditFlowTypeDes, count_audit, INPUTTIME, UPDATETIME)" +
|
||
" select " +
|
||
" audit_day, userid, username, auditFlowType, auditFlowTypeDes, count(1) auditCount, DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'), DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s')" +
|
||
" from ( " +
|
||
" select audit_day, userid, username, auditFlowType, auditFlowTypeDes " +
|
||
" from st_credit_audit_order_detail where auditType='BusinessApplyFlow' and auditOrderSts > 1 " +
|
||
" group by auditFlowType, userid, audit_day, objectno " +
|
||
" ) as a group by auditFlowType, userid, audit_day" ;
|
||
Sqlca.executeSQL(new SqlObject(insertSql));
|
||
return "-1";
|
||
}
|
||
|
||
|
||
/**
|
||
* 初始化付款申请审核统计报表-保存付款申请审核日期相关订单
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String initPaymentOrderAuditDay(Transaction Sqlca) throws Exception {
|
||
logger.info("【付款申请考核统计】【initPaymentOrderAuditDay】初始化保存审批数量<<<<<<<<<<<<<");
|
||
String insertSql="INSERT INTO st_payment_audit_order( " +
|
||
" every_day, userid, username, auditFlowType, auditFlowTypeDes, count_audit, audittime, INPUTTIME, UPDATETIME)" +
|
||
" select " +
|
||
" audit_day, userid, username, auditFlowType, auditFlowTypeDes, count(1) auditCount, sum(audittime) audittime, DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'), DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s')" +
|
||
" from st_credit_audit_order_detail where auditType='FundPaymentCarFlow' and auditOrderSts > 0 " +
|
||
" group by auditFlowType, userid, audit_day" ;
|
||
Sqlca.executeSQL(new SqlObject(insertSql));
|
||
return "-1";
|
||
}
|
||
|
||
|
||
/**
|
||
* 根据查询付款申请进单统计数据,添加或者更新统计订单数据
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String savePaymentOrderCreateDay(Transaction Sqlca) throws Exception {
|
||
// 定义全局对象
|
||
int con=0;
|
||
//查询订单创建时间的订单
|
||
String selSql = " select " +
|
||
" create_day AS every_day, userid, username, auditFlowType, auditFlowTypeDes, count(1) order_count " +
|
||
" from st_credit_audit_order_detail where auditType='FundPaymentCarFlow' " +
|
||
" group by auditFlowType, userid, create_day" ;
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
while(rs.next()) {
|
||
// 获取接口推送所需数据
|
||
con++;
|
||
String every_day = rs.getString("every_day"); // 流程编号
|
||
String order_count = rs.getString("order_count"); // 流程创建时间
|
||
String userid = rs.getString("userid"); // 流程创建时间
|
||
String username = rs.getString("username"); // 流程创建时间
|
||
String auditFlowType = rs.getString("auditFlowType"); // 流程创建时间
|
||
String auditFlowTypeDes = rs.getString("auditFlowTypeDes"); // 流程创建时间
|
||
// TODO: 2021/11/10 可优化,提取到循环外边
|
||
String selSql2="SELECT count(1) as countNum FROM st_payment_audit_order " +
|
||
"WHERE every_day ='" + every_day +"' and userid='" + userid +"' and auditFlowType='" + auditFlowType +"'";
|
||
ASResultSet rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
if(rs2.next()) {
|
||
if(rs2.getInt("countNum") > 0){
|
||
String updSql="UPDATE st_payment_audit_order SET order_count='"+order_count+"', " +
|
||
"UPDATETIME=DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') WHERE every_day='"+every_day +"' and userid='"
|
||
+ userid +"' and auditFlowType='" + auditFlowType +"'";
|
||
Sqlca.executeSQL(new SqlObject(updSql));
|
||
logger.info("【付款申请考核统计】【savePaymentOrderCreateDay】更新记录保存进单数量<<<<<<<<<<<<<");
|
||
}else {
|
||
String insertSql = "INSERT INTO st_payment_audit_order(\n" +
|
||
" every_day,\n" +
|
||
" userid,\n" +
|
||
" username,\n" +
|
||
" auditFlowType,\n" +
|
||
" auditFlowTypeDes,\n" +
|
||
" order_count,\n" +
|
||
" INPUTTIME, " +
|
||
" UPDATETIME " +
|
||
" ) " +
|
||
" VALUES ( " +
|
||
" '" + every_day + "', " +
|
||
" '" + userid + "', " +
|
||
" '" + username + "', " +
|
||
" '" + auditFlowType + "', " +
|
||
" '" + auditFlowTypeDes + "', " +
|
||
" '" + order_count + "', " +
|
||
"DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'), " +
|
||
"DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') " +
|
||
")";
|
||
Sqlca.executeSQL(new SqlObject(insertSql));
|
||
logger.info("【付款申请考核统计】【savePaymentOrderCreateDay】新增记录保存进单数量<<<<<<<<<<<<<");
|
||
}
|
||
}
|
||
}
|
||
return String.valueOf(con);
|
||
}
|
||
|
||
/**
|
||
* 更改主表付款申请考核通过拒绝和具体原因数量和审核时间
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String updatePaymentOrderAuditDay(Transaction Sqlca) throws Exception {
|
||
int con=0;
|
||
// 查询所有需要发送还款提醒的数据
|
||
String selSql="SELECT id, every_day, userid, auditFlowType, count_audit FROM st_payment_audit_order ";
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
while(rs.next()) {
|
||
// 获取接口推送所需数据
|
||
con++;
|
||
String id = rs.getString("id"); // 流程编号
|
||
String count_audit = rs.getString("count_audit"); // 审核数量
|
||
String auditFlowType = rs.getString("auditFlowType"); // 流程类型
|
||
int countAudit = 0;
|
||
if (StringUtils.isNotEmpty(count_audit) && !"null".equals(count_audit)) {
|
||
countAudit = Integer.parseInt(count_audit);
|
||
}
|
||
String every_day = rs.getString("every_day"); // 流程编号
|
||
String userid = rs.getString("userid"); // 流程创建时间
|
||
String countAuditOnePass = "0"; // 当日一次性通过数量
|
||
String countAuditPass = "0"; // 当日审批通过数量
|
||
String countAuditBack = "0"; // 当日审批通过数量
|
||
String selSql2 = "SELECT count(1) as countNum" +
|
||
" FROM st_credit_audit_order_detail " +
|
||
" WHERE userid = '" + userid + "'" +
|
||
" AND audit_day ='" + every_day + "'" +
|
||
" AND auditFlowType='" + auditFlowType + "'" +
|
||
" AND auditType ='FundPaymentCarFlow'" +
|
||
" AND auditOrderSts ='1'";// 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
ASResultSet rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
if (rs2.next()) {
|
||
if (rs2.getInt("countNum") > 0) {
|
||
countAuditBack = rs2.getString("countNum");
|
||
}
|
||
}
|
||
selSql2 = "SELECT count(1) as countNum" +
|
||
" FROM st_credit_audit_order_detail " +
|
||
" WHERE userid = '" + userid + "'" +
|
||
" AND audit_day ='" + every_day + "'" +
|
||
" AND auditFlowType='" + auditFlowType + "'" +
|
||
" AND auditType ='FundPaymentCarFlow'" +
|
||
" AND auditOrderSts ='3'";
|
||
rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
if (rs2.next()) {
|
||
if (rs2.getInt("countNum") > 0) {
|
||
countAuditPass = rs2.getString("countNum");
|
||
}
|
||
}
|
||
selSql2 = "SELECT count(1) as countNum" +
|
||
" FROM st_credit_audit_order_detail " +
|
||
" WHERE userid = '" + userid + "'" +
|
||
" AND audit_day ='" + every_day + "'" +
|
||
" AND auditFlowType='" + auditFlowType + "'" +
|
||
" AND auditType ='FundPaymentCarFlow'" +
|
||
" AND remark ='1'";
|
||
rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
if (rs2.next()) {
|
||
if (rs2.getInt("countNum") > 0) {
|
||
countAuditOnePass = rs2.getString("countNum");
|
||
}
|
||
}
|
||
String updSql="UPDATE st_payment_audit_order SET count_audit_pass='"+countAuditPass+"', " +
|
||
" count_audit_back='"+countAuditBack+"', " +
|
||
" count_audit_one_pass='"+countAuditOnePass+"', " +
|
||
"UPDATETIME=DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') WHERE id='"+id+"' ";
|
||
Sqlca.executeSQL(new SqlObject(updSql));
|
||
}
|
||
logger.info("【付款申请考核统计】【updateOrderAuditDay】付款申请考核统计订单执行 con=" + con);
|
||
return String.valueOf(con);
|
||
}
|
||
|
||
/**
|
||
* 根据查询进单统计数据,添加或者更新统计订单数据
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String saveOrderCreateDay(Transaction Sqlca) throws Exception {
|
||
// 定义全局对象
|
||
int con=0;
|
||
//查询订单创建时间的订单
|
||
String selSql = " select " +
|
||
" create_day AS every_day, userid, username, auditFlowType, auditFlowTypeDes, count(1) order_count " +
|
||
" from ( " +
|
||
" select * from st_credit_audit_order_detail where auditType='BusinessApplyFlow' " +
|
||
" group by auditFlowType, userid, objectno, create_day " +
|
||
" ) as a group by auditFlowType, userid, create_day" ;
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
String every_day = ""; // 流程编号
|
||
String order_count = ""; // 流程创建时间
|
||
String userid = ""; // 流程创建时间
|
||
String username = ""; // 流程创建时间
|
||
String auditFlowType = ""; // 流程创建时间
|
||
String auditFlowTypeDes = ""; // 流程创建时间
|
||
// TODO: 2021/11/10 可优化,提取到循环外边
|
||
// String selSql2="SELECT count(1) as countNum FROM st_credit_audit_order " +
|
||
// "WHERE auditFlowType='" + auditFlowType +"' group by every_day, userid";
|
||
while(rs.next()) {
|
||
// 获取接口推送所需数据
|
||
con++;
|
||
every_day = rs.getString("every_day"); // 流程编号
|
||
order_count = rs.getString("order_count"); // 流程创建时间
|
||
userid = rs.getString("userid"); // 流程创建时间
|
||
username = rs.getString("username"); // 流程创建时间
|
||
auditFlowType = rs.getString("auditFlowType"); // 流程创建时间
|
||
auditFlowTypeDes = rs.getString("auditFlowTypeDes"); // 流程创建时间
|
||
// TODO: 2021/11/10 可优化,提取到循环外边
|
||
String selSql2="SELECT count(1) as countNum FROM st_credit_audit_order " +
|
||
"WHERE every_day ='" + every_day +"' and userid='" + userid +"' and auditFlowType='" + auditFlowType +"'";
|
||
ASResultSet rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
if(rs2.next()) {
|
||
if(rs2.getInt("countNum") > 0 ){
|
||
String updSql="UPDATE st_credit_audit_order SET order_count='"+order_count+"', " +
|
||
"UPDATETIME=DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') WHERE every_day='"+every_day +"' and userid='"
|
||
+ userid +"' and auditFlowType='" + auditFlowType +"'";
|
||
Sqlca.executeSQL(new SqlObject(updSql));
|
||
}else {
|
||
String insertSql = "INSERT INTO st_credit_audit_order(\n" +
|
||
" every_day,\n" +
|
||
" userid,\n" +
|
||
" username,\n" +
|
||
" auditFlowType,\n" +
|
||
" auditFlowTypeDes,\n" +
|
||
" order_count,\n" +
|
||
" INPUTTIME, " +
|
||
" UPDATETIME " +
|
||
" ) " +
|
||
" VALUES ( " +
|
||
" '" + every_day + "', " +
|
||
" '" + userid + "', " +
|
||
" '" + username + "', " +
|
||
" '" + auditFlowType + "', " +
|
||
" '" + auditFlowTypeDes + "', " +
|
||
" '" + order_count + "', " +
|
||
"DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'), " +
|
||
"DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') " +
|
||
")";
|
||
Sqlca.executeSQL(new SqlObject(insertSql));
|
||
}
|
||
}
|
||
}
|
||
return String.valueOf(con);
|
||
}
|
||
|
||
|
||
/**
|
||
* 更改主表信审考核通过拒绝和具体原因数量和审核时间
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public String updateOrderAuditDay(Transaction Sqlca) throws Exception {
|
||
int con=0;
|
||
// 查询所有需要发送还款提醒的数据
|
||
String selSql="SELECT id, every_day, userid, auditFlowType, count_audit FROM st_credit_audit_order ";
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
Set<String> passSet = new HashSet<>();
|
||
Set<String> rejectSet = new HashSet<>();
|
||
Set<String> rejectSet1 = new HashSet<>();//拒绝数量:信用不良0010
|
||
Set<String> rejectSet2 = new HashSet<>();//拒绝数量:法院执行0020
|
||
Set<String> rejectSet3 = new HashSet<>();//拒绝数量:虚假信息0030
|
||
Set<String> rejectSet4 = new HashSet<>();//拒绝数量:身份核实异常0040
|
||
Set<String> rejectSet5 = new HashSet<>();//拒绝数量:购车目的异常0050
|
||
Set<String> rejectSet6 = new HashSet<>();//拒绝数量:综合评分不足0060
|
||
//排除同一条订单多种意见的情况
|
||
Map<String, String> resMap = new HashMap<>();
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
int audittime = 0;
|
||
while(rs.next()) {
|
||
|
||
// 获取接口推送所需数据
|
||
con++;
|
||
// logger.info("【信审考核统计】【updateOrderAuditDay】信审考核统计订单执行 con=" + con);
|
||
String id = rs.getString("id"); // 流程编号
|
||
String count_audit = rs.getString("count_audit"); // 审核数量
|
||
String auditFlowType = rs.getString("auditFlowType"); // 流程类型
|
||
int countAudit = 0;
|
||
if(StringUtils.isNotEmpty(count_audit) && !"null".equals(count_audit)){
|
||
countAudit = Integer.parseInt(count_audit);
|
||
}
|
||
String every_day = rs.getString("every_day"); // 流程编号
|
||
String userid = rs.getString("userid"); // 流程创建时间
|
||
|
||
String selSql2="SELECT audittime, auditOrderSts, auditResSts, objectno, endtime" +
|
||
" FROM st_credit_audit_order_detail " +
|
||
" WHERE userid = '" + userid +"'" +
|
||
" AND audit_day ='" + every_day +"'" +
|
||
" AND auditFlowType='" + auditFlowType +"'" +
|
||
" AND auditType ='BusinessApplyFlow'" ;
|
||
ASResultSet rs2 = Sqlca.getASResultSet(new SqlObject(selSql2));
|
||
passSet = new HashSet<>();
|
||
rejectSet = new HashSet<>();
|
||
rejectSet1 = new HashSet<>();//拒绝数量:信用不良0010
|
||
rejectSet2 = new HashSet<>();//拒绝数量:法院执行0020
|
||
rejectSet3 = new HashSet<>();//拒绝数量:虚假信息0030
|
||
rejectSet4 = new HashSet<>();//拒绝数量:身份核实异常0040
|
||
rejectSet5 = new HashSet<>();//拒绝数量:购车目的异常0050
|
||
rejectSet6 = new HashSet<>();//拒绝数量:综合评分不足0060
|
||
//排除同一条订单多种意见的情况
|
||
resMap = new HashMap<>();
|
||
audittime = 0;
|
||
while(rs2.next()) {
|
||
String objectno = rs2.getString("objectno");
|
||
String endtime = rs2.getString("endtime");
|
||
if(StringUtils.isEmpty(endtime) || "null".equals(endtime)){
|
||
logger.warn("【信审考核统计】【updateOrderAuditDay】endtime异常-当前订单为--objectno=" +objectno);
|
||
continue;
|
||
}
|
||
|
||
if(resMap.containsKey(objectno)){
|
||
String endtimeBak = resMap.get(objectno);
|
||
// logger.info("【信审考核统计】【updateOrderAuditDay】双结果订单-当前订单为--objectno=" +objectno);
|
||
// logger.info("【信审考核统计】【updateOrderAuditDay】双结果订单-当前订单为--endtimeBak=" +endtimeBak);
|
||
// logger.info("【信审考核统计】【updateOrderAuditDay】双结果订单-当前订单为--endtime=" +endtime);
|
||
Date endtimeBakDate = sdf.parse(endtimeBak);
|
||
Date endtimeDate = sdf.parse(endtime);
|
||
//以最新结果为准
|
||
if(endtimeBakDate.getTime() > endtimeDate.getTime()){//如果已处理的订单时间大于当前的时间,则不处理当前结果
|
||
logger.warn("【信审考核统计】【updateOrderAuditDay】双结果订单-以最新结果为准,不处理当前结果--objectno=" +objectno);
|
||
continue;
|
||
}else {//如果当前状态为最新状态,则清除之前的数量
|
||
passSet.remove(objectno);
|
||
rejectSet.remove(objectno);
|
||
rejectSet1.remove(objectno);
|
||
rejectSet2.remove(objectno);
|
||
rejectSet3.remove(objectno);
|
||
rejectSet4.remove(objectno);
|
||
rejectSet5.remove(objectno);
|
||
rejectSet6.remove(objectno);
|
||
}
|
||
}
|
||
// logger.info("【信审考核统计】【updateOrderAuditDay】当前订单为--objectno=" +objectno);
|
||
resMap.put(objectno, endtime);
|
||
//大状态:// 0,审核中,1,任意退回,2,审核拒绝,3,审核通过
|
||
String auditOrderSts = rs2.getString("auditOrderSts");
|
||
if(StringUtils.isNotEmpty(auditOrderSts) && !"null".equals(auditOrderSts)
|
||
&& !"0".equals(auditOrderSts) && !"1".equals(auditOrderSts)){
|
||
//取值
|
||
String audittimeStr = rs2.getString("audittime"); // 审核时间
|
||
//审核时间计算
|
||
if(StringUtils.isNotEmpty(audittimeStr) && !"null".equals(audittimeStr)){
|
||
audittime = audittime + Integer.parseInt(audittimeStr);
|
||
}
|
||
}
|
||
//小状态:信用不良0010,法院执行0020,虚假信息0030,身份核实异常0040,购车目的异常0050,综合评分不足0060
|
||
String auditResSts = rs2.getString("auditResSts");
|
||
|
||
if(StringUtils.isNotEmpty(auditOrderSts) && !"null".equals(auditOrderSts)){
|
||
if("3".equals(auditOrderSts)){//通过
|
||
passSet.add(objectno);
|
||
}else if("2".equals(auditOrderSts)){//拒绝
|
||
rejectSet.add(objectno);
|
||
if("0010".equals(auditResSts)){//信用不良:0010
|
||
rejectSet1.add(objectno);
|
||
}else if("0020".equals(auditResSts)){//法院执行0020
|
||
rejectSet2.add(objectno);
|
||
}else if("0030".equals(auditResSts)){//虚假信息0030
|
||
rejectSet3.add(objectno);
|
||
}else if("0040".equals(auditResSts)){//身份核实异常0040
|
||
rejectSet4.add(objectno);
|
||
}else if("0050".equals(auditResSts)){//购车目的异常0050
|
||
rejectSet5.add(objectno);
|
||
}else if("0060".equals(auditResSts)) {//综合评分不足0060
|
||
rejectSet6.add(objectno);
|
||
}else {
|
||
logger.warn("【信审考核统计】【updateOrderAuditDay】信审考核状态异常--auditResSts=" + auditResSts);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* count_audit_refuse` int(11) DEFAULT NULL COMMENT '当日审批拒绝数量',
|
||
* `count_audit_refuse1` int(11) DEFAULT NULL COMMENT '当日审批拒绝数量-分类1:信用不良',
|
||
* `count_audit_refuse2` int(11) DEFAULT NULL COMMENT '当日审批拒绝数量-分类2:法院执行',
|
||
* `count_audit_refuse3` int(11) DEFAULT NULL COMMENT '当日审批拒绝数量-分类3:虚假信息',
|
||
* `count_audit_refuse4` int(11) DEFAULT NULL COMMENT '当日审批拒绝数量-分类4:身份核实异常',
|
||
* `count_audit_refuse5` int(11) DEFAULT NULL COMMENT '当日审批拒绝数量-分类5:购车目的异常',
|
||
* `count_audit_refuse6` int(11) DEFAULT NULL COMMENT '当日审批拒绝数量-分类6:综合评分不足',
|
||
*/
|
||
String updSql="UPDATE st_credit_audit_order SET count_audit_pass='"+passSet.size()+"', " +
|
||
" count_audit_refuse='"+rejectSet.size()+"', " +
|
||
" count_audit_refuse1='"+rejectSet1.size()+"', " +
|
||
" count_audit_refuse2='"+rejectSet2.size()+"', " +
|
||
" count_audit_refuse3='"+rejectSet3.size()+"', " +
|
||
" count_audit_refuse4='"+rejectSet4.size()+"', " +
|
||
" count_audit_refuse5='"+rejectSet5.size()+"', " +
|
||
" count_audit_refuse6='"+rejectSet6.size()+"', " +
|
||
" audittime='"+audittime+"', " +
|
||
"UPDATETIME=DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s') WHERE id='"+id+"' ";
|
||
Sqlca.executeSQL(new SqlObject(updSql));
|
||
}
|
||
return String.valueOf(con);
|
||
}
|
||
|
||
/**
|
||
* 根据当前时间获得跳过节假日的工作日时间
|
||
* @param date
|
||
* @return
|
||
*/
|
||
private String resJumpHoliday(Transaction Sqlca, String date, Map<String, String> listHoliday) throws SQLException, ParseException {
|
||
//查询当前时间是否在工作时间
|
||
// logger.info("resJumpHoliday --【开始】--查询当前时间是否在工作时间:date=" + date);
|
||
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||
int hour = Integer.parseInt(date.substring(11, 13));
|
||
int minute = Integer.parseInt(date.substring(14, 16));
|
||
if(hour < 9){//时间小于当天9点,则调整时间为上午九点
|
||
date = date.substring(0, 11) + "09:00:00";
|
||
}else if((hour == 17 && minute > 30) || (hour > 17)){//时间小于当天17:30点,则调整时间为第二天的上午九点
|
||
Date time = simpleDateFormat.parse(date);
|
||
Calendar calendar = Calendar.getInstance();
|
||
calendar.setTime(time);
|
||
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||
date = simpleDateFormat.format(calendar.getTime()).substring(0, 11) + "09:00:00";
|
||
}
|
||
//查询当前时间是否在节假日时间
|
||
String day = date.substring(0, 10);
|
||
//logger.info("resJumpHoliday 查询当前时间是否在节假日时间 day=" + day);
|
||
int count = 0;
|
||
while (listHoliday.containsKey(day) && count < 15) {
|
||
//logger.info("resJumpHoliday 节假日时间 day=" + day);
|
||
count ++;
|
||
Date time = simpleDateFormat.parse(date);
|
||
Calendar calendar = Calendar.getInstance();
|
||
calendar.setTime(time);
|
||
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||
date = simpleDateFormat.format(calendar.getTime()).substring(0, 11) + "09:00:00";
|
||
day = date.substring(0, 10);
|
||
logger.info("resJumpHoliday 节假日时间 + 1 day=" + day);
|
||
}
|
||
//logger.info("resJumpHoliday --【结束】--查询当前时间是否在工作时间:date=" + date);
|
||
return date;
|
||
}
|
||
|
||
|
||
/**
|
||
* 查询所有节假日
|
||
* @param Sqlca
|
||
* @return
|
||
* @throws SQLException
|
||
*/
|
||
private Map<String, String> listHoliday(Transaction Sqlca) throws SQLException {
|
||
String selSql="SELECT c_date " +
|
||
" FROM st_credit_audit_holiday st" +
|
||
" WHERE st.otype='休'" ;
|
||
ASResultSet rs = Sqlca.getASResultSet(new SqlObject(selSql));
|
||
Map<String, String> holidayMap = new HashMap<>();
|
||
while(rs.next()) {
|
||
holidayMap.put(rs.getString("c_date"), "1");
|
||
}
|
||
return holidayMap;
|
||
}
|
||
|
||
/**
|
||
* 根据时间段相差时间获得跳过节假日的工作日时间
|
||
* @param begintime 开始时间
|
||
* @param endtime 结束时间
|
||
* @return
|
||
*/
|
||
private String diffTime(Transaction Sqlca, String begintime, String endtime, Map<String, String> listHoliday) throws SQLException, ParseException {
|
||
//如果结束时间小于或者等于开始时间
|
||
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
Date beginDate = sdf.parse(begintime);
|
||
Date endDate = sdf.parse(endtime);
|
||
long diff = 0;
|
||
if(beginDate.getTime() >= endDate.getTime()){//开始时间大于结束时间
|
||
return "0";
|
||
}else if (dayFormat.format(beginDate).equals(dayFormat.format(endDate))){//开始时间和结束时间年月日相同
|
||
logger.info("diffTime2111182 开始时间和结束时间年月日相同 beginDate=" + dayFormat.format(beginDate) + "--> endDate=" + dayFormat.format(endDate));
|
||
diff = diffMinute(beginDate.getTime(), endDate.getTime());
|
||
return String.valueOf(diff);
|
||
}else {
|
||
long diffBeginAfter = diffBeginDateAfterNew(begintime, beginDate);
|
||
long diffEndDateBefore = diffEndDateBeforeNew(endtime, endDate);
|
||
diff = diffBeginAfter + diffEndDateBefore;
|
||
//得到相差的天数 betweenDate
|
||
beginDate = dayFormat.parse(dayFormat.format(beginDate));
|
||
endDate = dayFormat.parse(dayFormat.format(endDate));
|
||
long betweenDate = (endDate.getTime() - beginDate.getTime())/(60*60*24*1000);
|
||
logger.info("diffTime211118 begintime=" + begintime + "相差天数:betweenDateCX" + betweenDate);
|
||
if (betweenDate == 1){
|
||
return String.valueOf(diff);
|
||
}else {//中间相隔大于一天查询数据库相隔天数中有几天是假期,
|
||
begintime = dayFormat.format(beginDate);
|
||
endtime = dayFormat.format(endDate);
|
||
//时间段内假期天数
|
||
int countNum = holidayNum(begintime, endtime, listHoliday);
|
||
logger.info("diffTime211118 begintime=" + begintime + "非工作天数:holidayNumCX" + countNum);
|
||
diff += (betweenDate - countNum - 1)*8*60;
|
||
return String.valueOf(diff);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 计算该时间中间的假期时间
|
||
* @param beginDate yyyy/MM/dd
|
||
* @param endDate yyyy/MM/dd
|
||
* @param listHoliday yyyy/MM/dd,1
|
||
* @return
|
||
*/
|
||
private int holidayNum(String beginDate, String endDate, Map<String, String> listHoliday) throws ParseException {
|
||
SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||
int hilidayNum = 0;
|
||
if(beginDate.equals(endDate)){
|
||
return hilidayNum;
|
||
}
|
||
Date begin = dayFormat.parse(beginDate);
|
||
Date end = dayFormat.parse(endDate);
|
||
if(end.getTime() <= begin.getTime()){
|
||
return hilidayNum;
|
||
}
|
||
String tempDate = beginDate;
|
||
//日期加一,不等于结束日期
|
||
while (!tempDate.equals(endDate)){
|
||
//当前日期存在于假期之中,假期加1
|
||
if(listHoliday.containsKey(tempDate)){
|
||
hilidayNum++;
|
||
}
|
||
Date time = dayFormat.parse(tempDate);
|
||
Calendar calendar = Calendar.getInstance();
|
||
calendar.setTime(time);
|
||
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||
tempDate = dayFormat.format(calendar.getTime());
|
||
}
|
||
return hilidayNum;
|
||
}
|
||
|
||
|
||
private long diffEndDateBeforeNew(String endTime, Date endDate) throws ParseException {
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
String endtimeBefore = endTime.substring(0, 8) + "090000";
|
||
Date endDateBefore = simpleDateFormat.parse(endtimeBefore);
|
||
return diffMinute(endDateBefore.getTime(), endDate.getTime());
|
||
}
|
||
|
||
private long diffBeginDateAfterNew(String beginTime, Date beginDate) throws ParseException {
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
||
String begintimeAfter = beginTime.substring(0, 8) + "173000";
|
||
Date beginDateAfter = simpleDateFormat.parse(begintimeAfter);
|
||
return diffMinute(beginDate.getTime(), beginDateAfter.getTime());
|
||
}
|
||
|
||
private long diffEndDateBefore(String endTime, Date endDate) throws ParseException {
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||
String endtimeBefore = endTime.substring(0, 11) + "09:00:00";
|
||
Date endDateBefore = simpleDateFormat.parse(endtimeBefore);
|
||
return diffMinute(endDateBefore.getTime(), endDate.getTime());
|
||
}
|
||
|
||
private long diffBeginDateAfter(String beginTime, Date beginDate) throws ParseException {
|
||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||
String begintimeAfter = beginTime.substring(0, 11) + "17:30:00";
|
||
Date beginDateAfter = simpleDateFormat.parse(begintimeAfter);
|
||
return diffMinute(beginDate.getTime(), beginDateAfter.getTime());
|
||
}
|
||
|
||
/**
|
||
* 经过处理过的时间开始和结束时间在一天
|
||
* @param begin
|
||
* @param end
|
||
* @return
|
||
* @throws ParseException
|
||
*/
|
||
private long diffMinute(long begin, long end) throws ParseException {
|
||
Date beginDate = new Date(begin);
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||
String timeBefore = sdf.format(beginDate).substring(0, 11) + "12:00:00";
|
||
String timeAfter = sdf.format(beginDate).substring(0, 11) + "12:30:00";
|
||
Date timeBeforeDate = sdf.parse(timeBefore);
|
||
Date timeAfterDate = sdf.parse(timeAfter);
|
||
//确认是否需要扣除午休30分钟
|
||
boolean b = false;
|
||
//如果开始时间小于12:00 并且 结束时间大于12:30
|
||
if(begin <= timeBeforeDate.getTime() && end >= timeAfterDate.getTime()){
|
||
b = true;
|
||
}
|
||
//如果开始时间,大于12 小于 12:30 则 开始时间为 12:30
|
||
if(begin > timeBeforeDate.getTime() && begin < timeAfterDate.getTime()){
|
||
begin = timeAfterDate.getTime();
|
||
}
|
||
//如果结束时间,大于12 小于 12:30 则 开始时间为 12:00
|
||
if(end > timeBeforeDate.getTime() && end < timeAfterDate.getTime()){
|
||
end = timeBeforeDate.getTime();
|
||
}
|
||
long res = (end - begin)/1000/60;
|
||
if(b){
|
||
res = res - 30;
|
||
}
|
||
return res <= 0 ? 1 : res;
|
||
}
|
||
|
||
/**
|
||
* 查询st相关表中时间
|
||
* @param preDayCount 多少天前数据,增量更新
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private String queryStBeginTime(int preDayCount) throws Exception {
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||
Date date = new Date();
|
||
Calendar cal = Calendar.getInstance();
|
||
cal.setTime(date);
|
||
cal.add(Calendar.DATE, -preDayCount);
|
||
logger.info("queryStBeginTime 查询st相关表中时间:" + sdf.format(cal.getTime()));
|
||
return sdf.format(cal.getTime()) + "000000";
|
||
}
|
||
|
||
/**
|
||
* 查询flow相关表中时间
|
||
* @param preDayCount 多少天前数据,增量更新
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private String queryFtBeginTime(int preDayCount) throws Exception {
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
||
Date date = new Date();
|
||
Calendar cal = Calendar.getInstance();
|
||
cal.setTime(date);
|
||
cal.add(Calendar.DATE, -preDayCount);
|
||
logger.info("queryFtBeginTime 查询flow相关表中时间:" + sdf.format(cal.getTime()));
|
||
return sdf.format(cal.getTime());
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|