Commit f9eaccf1 authored by Data-王博's avatar Data-王博

湖北消金 - 文件中提示语 以及定时任务运行时间。

parent ccee45b8
...@@ -40,7 +40,7 @@ public class MyBatisConfig { ...@@ -40,7 +40,7 @@ public class MyBatisConfig {
@Bean @Bean
public DataSource apiDBDataSource() throws Exception { public DataSource apiDBDataSource() throws Exception {
try { try {
logger.error("api jdbc url={}",env.getProperty("api.jdbc.url")); logger.error("finance api config-------------------api jdbc url={}",env.getProperty("api.jdbc.url"));
Properties props = new Properties(); Properties props = new Properties();
props.put("driverClassName", env.getProperty("api.jdbc.driverClassName")); props.put("driverClassName", env.getProperty("api.jdbc.driverClassName"));
props.put("url", env.getProperty("api.jdbc.url")); props.put("url", env.getProperty("api.jdbc.url"));
...@@ -60,7 +60,7 @@ public class MyBatisConfig { ...@@ -60,7 +60,7 @@ public class MyBatisConfig {
@Bean @Bean
public DataSource systemDBDataSource() throws Exception { public DataSource systemDBDataSource() throws Exception {
try { try {
logger.error("system jdbc url={}",env.getProperty("system.jdbc.url")); logger.error("finance api config-------------------system jdbc url={}",env.getProperty("system.jdbc.url"));
Properties props = new Properties(); Properties props = new Properties();
props.put("driverClassName", env.getProperty("system.jdbc.driverClassName")); props.put("driverClassName", env.getProperty("system.jdbc.driverClassName"));
props.put("url", env.getProperty("system.jdbc.url")); props.put("url", env.getProperty("system.jdbc.url"));
......
...@@ -109,16 +109,19 @@ public class HubeiCFCField { ...@@ -109,16 +109,19 @@ public class HubeiCFCField {
*/ */
public static final String tradeCodeSuccess = "0000"; public static final String tradeCodeSuccess = "0000";
public static final String tradeCodeNoTrade = "1111"; public static final String tradeCodeNoTrade = "1111";
public static final String tradeCodeWrongPrice = "1111";
/** /**
* 交易结果 * 交易结果
*/ */
public static final String tradeMsgSuccess = "交易成功"; public static final String tradeMsgSuccess = "交易成功";
public static final String tradeMsgNoTrade = "未还款"; public static final String tradeMsgNoTrade = "未还款";
public static final String tradeMsgWrongPrice = "金额不正确";
public static final Map<String,String> codeMappingMsg = new HashMap<String,String>(){ public static final Map<String,String> codeMappingMsg = new HashMap<String,String>(){
{ {
put(tradeCodeSuccess,tradeMsgSuccess); put(tradeCodeSuccess,tradeMsgSuccess);
put(tradeCodeNoTrade,tradeMsgNoTrade); put(tradeCodeNoTrade,tradeMsgNoTrade);
put(tradeCodeWrongPrice,tradeMsgWrongPrice);
} }
}; };
......
package cn.quantgroup.financial.init; package cn.quantgroup.financial.init;
import cn.quantgroup.financial.service.sys.ICompensationDayService; import cn.quantgroup.financial.service.sys.ICompensationDayService;
import cn.quantgroup.financial.service.sys.IScheduledJudgeService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -17,10 +18,19 @@ public class InitRunner implements CommandLineRunner { ...@@ -17,10 +18,19 @@ public class InitRunner implements CommandLineRunner {
@Autowired @Autowired
private ICompensationDayService compensationDayService; private ICompensationDayService compensationDayService;
@Autowired
private IScheduledJudgeService scheduledJudgeService;
@Override @Override
public void run(String... strings) throws Exception { public void run(String... strings) throws Exception {
logger.info("start prepare compenstationDaysData "); logger.info("start prepare compenstationDaysData ");
compensationDayService.prepareCompenstationDaysData(); compensationDayService.prepareCompenstationDaysData();
logger.info("end prepare compenstationDaysData "); logger.info("end prepare compenstationDaysData ");
if(scheduledJudgeService.isOpenScheduled()){
logger.error("finance api config-------------------scheduled task is opened");
}else {
logger.error("finance api config-------------------scheduled task is closed");
}
} }
} }
...@@ -2,6 +2,7 @@ package cn.quantgroup.financial.scheduler; ...@@ -2,6 +2,7 @@ package cn.quantgroup.financial.scheduler;
import cn.quantgroup.financial.constant.HubeiCFCDataType; import cn.quantgroup.financial.constant.HubeiCFCDataType;
import cn.quantgroup.financial.constant.HubeiCFCField; import cn.quantgroup.financial.constant.HubeiCFCField;
import cn.quantgroup.financial.constant.SysConstant;
import cn.quantgroup.financial.dao.IHuBeiCFCDao; import cn.quantgroup.financial.dao.IHuBeiCFCDao;
import cn.quantgroup.financial.handler.IHuBeiDispatcher; import cn.quantgroup.financial.handler.IHuBeiDispatcher;
import cn.quantgroup.financial.model.huibeicfc.HuBeiCFCResponse; import cn.quantgroup.financial.model.huibeicfc.HuBeiCFCResponse;
...@@ -72,6 +73,8 @@ public class HuBeiReturnDiscScheduler { ...@@ -72,6 +73,8 @@ public class HuBeiReturnDiscScheduler {
iHuBeiService.sendErrorMailNotice(e.getMessage()); iHuBeiService.sendErrorMailNotice(e.getMessage());
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
} }
}else {
logger.info("scheduled is closed");
} }
} }
...@@ -133,6 +136,8 @@ class ScheduleAdvanceRepay implements Runnable{ ...@@ -133,6 +136,8 @@ class ScheduleAdvanceRepay implements Runnable{
private IHuBeiDispatcher huBeiHandlerDispatcher; private IHuBeiDispatcher huBeiHandlerDispatcher;
private IHuBeiService iHuBeiService; private IHuBeiService iHuBeiService;
private IHuBeiCFCDao iHuBeiCFCDao; private IHuBeiCFCDao iHuBeiCFCDao;
//启动时间
private Long startTime;
private static final Logger logger = LoggerFactory.getLogger(ScheduleAdvanceRepay.class); private static final Logger logger = LoggerFactory.getLogger(ScheduleAdvanceRepay.class);
...@@ -140,6 +145,7 @@ class ScheduleAdvanceRepay implements Runnable{ ...@@ -140,6 +145,7 @@ class ScheduleAdvanceRepay implements Runnable{
this.currentReqNo = currentReqNo; this.currentReqNo = currentReqNo;
this.maxReqNo = maxReqNo; this.maxReqNo = maxReqNo;
this.advanceIdMap = advanceIdMap; this.advanceIdMap = advanceIdMap;
this.startTime = System.currentTimeMillis();
} }
public void registerService(IApiScheduledExecutorService scheduledExecutorService,IHuBeiService iHuBeiService, public void registerService(IApiScheduledExecutorService scheduledExecutorService,IHuBeiService iHuBeiService,
IHuBeiCFCDao iHuBeiCFCDao,IHuBeiDispatcher huBeiHandlerDispatcher){ IHuBeiCFCDao iHuBeiCFCDao,IHuBeiDispatcher huBeiHandlerDispatcher){
...@@ -149,12 +155,25 @@ class ScheduleAdvanceRepay implements Runnable{ ...@@ -149,12 +155,25 @@ class ScheduleAdvanceRepay implements Runnable{
this.huBeiHandlerDispatcher = huBeiHandlerDispatcher; this.huBeiHandlerDispatcher = huBeiHandlerDispatcher;
} }
public boolean isOutTime(){
Long spendtime = System.currentTimeMillis()-startTime;
if(spendtime>1000*60*60*23){
//运行超时 自动停止
return true;
}else {
return false;
}
}
@Override @Override
public void run() { public void run() {
try { try {
logger.info("ScheduleAdvanceRepay method start"); logger.info("ScheduleAdvanceRepay method start");
logger.info("currentReqNo={},maxReqNo={}",currentReqNo,maxReqNo); logger.info("currentReqNo={},maxReqNo={}",currentReqNo,maxReqNo);
if(isOutTime()){
logger.info("ScheduleAdvanceRepay has run over than 23 hours, auto stop");
return;
}
//先前的reqNo //先前的reqNo
String docName = HubeiCFCUtil.getDocName(HubeiCFCDataType.RETURN_ADVANCE_REPAYMENT,currentReqNo); String docName = HubeiCFCUtil.getDocName(HubeiCFCDataType.RETURN_ADVANCE_REPAYMENT,currentReqNo);
HuBeiCFCResponse response = iHuBeiService.handleDiscData(HubeiCFCDataType.SEND_ADVANCE_REPAYMENT_CHECK,docName,null,currentReqNo); HuBeiCFCResponse response = iHuBeiService.handleDiscData(HubeiCFCDataType.SEND_ADVANCE_REPAYMENT_CHECK,docName,null,currentReqNo);
......
...@@ -451,7 +451,7 @@ public class HuBeiServiceImpl implements IHuBeiService { ...@@ -451,7 +451,7 @@ public class HuBeiServiceImpl implements IHuBeiService {
BigDecimal hubeiOverdueInterest = HubeiCFCUtil.caculateOverDueFee(repaymentPlanDetail.getDeadLine(),repayXyqbDetail.getPayCenterRepayAt(),repaymentPlanDetail.getPrincipal()); BigDecimal hubeiOverdueInterest = HubeiCFCUtil.caculateOverDueFee(repaymentPlanDetail.getDeadLine(),repayXyqbDetail.getPayCenterRepayAt(),repaymentPlanDetail.getPrincipal());
//批扣 //批扣
BigDecimal reallyRepayAmount = repaymentPlanDetail.getPrincipal().add(repaymentPlanDetail.getInterest()).add(hubeiOverdueInterest); BigDecimal reallyRepayAmount = repaymentPlanDetail.getPrincipal().add(repaymentPlanDetail.getInterest()).add(hubeiOverdueInterest);
returnHuBeiHistoryList.add(deitHuiBeiHistory(history, sendHuBeiDocName.getCreateTime(),reallyRepayAmount,HubeiCFCField.tradeCodeSuccess)); returnHuBeiHistoryList.add(deitHuiBeiHistory(history, sendHuBeiDocName.getCreateTime(),reallyRepayAmount));
} }
}else { }else {
//这部分 //这部分
...@@ -476,7 +476,7 @@ public class HuBeiServiceImpl implements IHuBeiService { ...@@ -476,7 +476,7 @@ public class HuBeiServiceImpl implements IHuBeiService {
} }
//未还款 批扣 实际还款金额零 //未还款 批扣 实际还款金额零
returnHuBeiHistoryList.add(deitHuiBeiHistory(history, sendHuBeiDocName.getCreateTime(),BigDecimal.ZERO,HubeiCFCField.tradeCodeNoTrade)); returnHuBeiHistoryList.add(deitHuiBeiHistory(history, sendHuBeiDocName.getCreateTime(),BigDecimal.ZERO));
} }
...@@ -620,7 +620,7 @@ public class HuBeiServiceImpl implements IHuBeiService { ...@@ -620,7 +620,7 @@ public class HuBeiServiceImpl implements IHuBeiService {
* @param reallyRepayAmount * @param reallyRepayAmount
* @return * @return
*/ */
private HuBeiHistory deitHuiBeiHistory(HuBeiHistory history,Date happenTime,BigDecimal reallyRepayAmount,String tradeCode){ private HuBeiHistory deitHuiBeiHistory(HuBeiHistory history,Date happenTime,BigDecimal reallyRepayAmount){
HuBeiHistory deitHuiBeiHistory = HubeiCFCUtil.replicateBase(history); HuBeiHistory deitHuiBeiHistory = HubeiCFCUtil.replicateBase(history);
deitHuiBeiHistory.setDataType(HubeiCFCDataType.RETURN_BATCH_DEBIT.get()); deitHuiBeiHistory.setDataType(HubeiCFCDataType.RETURN_BATCH_DEBIT.get());
HuBeiJsonBean huBeiJsonBean = new HuBeiJsonBean(); HuBeiJsonBean huBeiJsonBean = new HuBeiJsonBean();
...@@ -629,8 +629,19 @@ public class HuBeiServiceImpl implements IHuBeiService { ...@@ -629,8 +629,19 @@ public class HuBeiServiceImpl implements IHuBeiService {
huBeiJsonBean.setRepayAmount(history.getData().getRepayAmount()); huBeiJsonBean.setRepayAmount(history.getData().getRepayAmount());
//实扣金额 0 //实扣金额 0
huBeiJsonBean.setReallyRepayAmount(reallyRepayAmount); huBeiJsonBean.setReallyRepayAmount(reallyRepayAmount);
huBeiJsonBean.setTradeCode(tradeCode); if(history.getData().getRepayAmount()!=null
huBeiJsonBean.setTradeMsg(HubeiCFCField.codeMappingMsg.get(tradeCode)); &&reallyRepayAmount.compareTo(BigDecimal.ZERO)!=0
&&history.getData().getRepayAmount().compareTo(reallyRepayAmount)==0){
huBeiJsonBean.setTradeCode(HubeiCFCField.tradeCodeSuccess);
huBeiJsonBean.setTradeMsg(HubeiCFCField.codeMappingMsg.get(HubeiCFCField.tradeCodeSuccess));
}else if(reallyRepayAmount.compareTo(BigDecimal.ZERO)==0){
huBeiJsonBean.setTradeCode(HubeiCFCField.tradeCodeNoTrade);
huBeiJsonBean.setTradeMsg(HubeiCFCField.codeMappingMsg.get(HubeiCFCField.tradeCodeWrongPrice));
}else {
huBeiJsonBean.setTradeCode(HubeiCFCField.tradeCodeWrongPrice);
huBeiJsonBean.setTradeMsg(HubeiCFCField.codeMappingMsg.get(HubeiCFCField.tradeCodeWrongPrice));
}
deitHuiBeiHistory.setHappenTime(happenTime); deitHuiBeiHistory.setHappenTime(happenTime);
deitHuiBeiHistory.setData(huBeiJsonBean); deitHuiBeiHistory.setData(huBeiJsonBean);
deitHuiBeiHistory.setSeqNo(new Integer(1).byteValue()); deitHuiBeiHistory.setSeqNo(new Integer(1).byteValue());
......
...@@ -27,7 +27,11 @@ public class ScheduledJudgeServiceImpl implements IScheduledJudgeService { ...@@ -27,7 +27,11 @@ public class ScheduledJudgeServiceImpl implements IScheduledJudgeService {
public Boolean isOpenScheduled(){ public Boolean isOpenScheduled(){
try { try {
String trigger = System.getenv(scheduled_trigger_name); String trigger = System.getenv(scheduled_trigger_name);
if(!StringUtils.isEmpty(trigger)&&"-1".equals(trigger)){ if(StringUtils.isEmpty(trigger)){
trigger = System.getProperty(scheduled_trigger_name);
}
logger.info("trigger name={}, value={}",scheduled_trigger_name,trigger);
if(!StringUtils.isEmpty(trigger)&&"2".equals(trigger)){
return false; return false;
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -2,5 +2,5 @@ hubei.mail.touser=bo.wang@quantgroup.cn ...@@ -2,5 +2,5 @@ hubei.mail.touser=bo.wang@quantgroup.cn
#存储每次请求响应的日志文件 #存储每次请求响应的日志文件
hubei.history.filepath=E:/hubeitest/ hubei.history.filepath=E:/hubeitest/
log_dir=quant_group log_dir=quant_group
#定时任务环境变量的名 系统变量为-1表示关闭定时任务 其他为开启 #定时任务环境变量的名 系统变量为2表示关闭定时任务 其他为开启
scheduled_trigger=scheduled_trigger scheduled_trigger=scheduled_trigger
\ No newline at end of file
...@@ -2,5 +2,5 @@ hubei.mail.touser=bo.wang@quantgroup.cn ...@@ -2,5 +2,5 @@ hubei.mail.touser=bo.wang@quantgroup.cn
#存储每次请求响应的日志文件 #存储每次请求响应的日志文件
hubei.history.filepath=/vpants/hubeifiles/ hubei.history.filepath=/vpants/hubeifiles/
log_dir=quant_group log_dir=quant_group
#定时任务环境变量的名 系统变量为-1表示关闭定时任务 其他为开启 #定时任务环境变量的名 系统变量为2表示关闭定时任务 其他为开启
scheduled_trigger=scheduled_trigger scheduled_trigger=scheduled_trigger
\ No newline at end of file
...@@ -2,5 +2,5 @@ hubei.mail.touser=bo.wang@quantgroup.cn ...@@ -2,5 +2,5 @@ hubei.mail.touser=bo.wang@quantgroup.cn
#存储每次请求响应的日志文件 #存储每次请求响应的日志文件
hubei.history.filepath=/home/results/ hubei.history.filepath=/home/results/
log_dir=quant_group log_dir=quant_group
#定时任务环境变量的名 系统变量为-1表示关闭定时任务 其他为开启 #定时任务环境变量的名 系统变量为2表示关闭定时任务 其他为开启
scheduled_trigger=scheduled_trigger scheduled_trigger=scheduled_trigger
\ No newline at end of file
...@@ -11,8 +11,8 @@ maven打包 三种选项: ...@@ -11,8 +11,8 @@ maven打包 三种选项:
手动指定日志目录文件夹 如: 手动指定日志目录文件夹 如:
``` -Dlog_dir=financial_system_api``` ``` -Dlog_dir=financial_system_api```
指定是否开启定时任务 集群状态下配置 -1为不开启 默认都是开启 指定是否开启定时任务 集群状态下配置 2为不开启 默认都是开启 只开启一台
```-Dscheduled_trigger=-1``` ```-Dscheduled_trigger=2```
启动命令 启动命令
```SCREEN -Am -S financialapi java -Dfile.encoding=UTF-8 -server -Dserver.port=9010 -Dlog_dir=financial_system_api -Xmx1024m -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -XX:ErrorFile=/home/test_financial_system_api/jars/gclog/get_data_error.log -XX:HeapDumpPath=/home/test_financial_system_api/jars/gclog/heapdump.hprof -XX:-OmitStackTraceInFastThrow -Xloggc:/home/test_financial_system_api/jars/gclog/jvmgc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -Djava.security.egd=file:/dev/./urandom -Djdk.tls.allowUnsafeServerCertChange=true -Dsun.security.ssl.allowUnsafeRenegotiation=true -jar /home/test_financial_system_api/testfinance-api-0.0.1-SNAPSHOT.jar``` ```SCREEN -Am -S financialapi java -Dfile.encoding=UTF-8 -server -Dserver.port=9010 -Dlog_dir=financial_system_api -Xmx1024m -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -XX:ErrorFile=/home/test_financial_system_api/jars/gclog/get_data_error.log -XX:HeapDumpPath=/home/test_financial_system_api/jars/gclog/heapdump.hprof -XX:-OmitStackTraceInFastThrow -Xloggc:/home/test_financial_system_api/jars/gclog/jvmgc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -Djava.security.egd=file:/dev/./urandom -Djdk.tls.allowUnsafeServerCertChange=true -Dsun.security.ssl.allowUnsafeRenegotiation=true -jar /home/test_financial_system_api/testfinance-api-0.0.1-SNAPSHOT.jar```
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment