Commit 3824b779 authored by 郝彦辉's avatar 郝彦辉

数据同步修改,增加钉钉报警

parent 6d785121
...@@ -19,7 +19,7 @@ package cn.quantgroup.report.constant;/** ...@@ -19,7 +19,7 @@ package cn.quantgroup.report.constant;/**
*/ */
public class BaiHangHistoryConstant { public class BaiHangHistoryConstant {
public static final int MAX_COMMIT_COUT = 20000;//大于2万条会出现事务提交过长报错 public static final int MAX_COMMIT_COUT = 24000;//大于2万条会出现事务提交过长报错
public static final String SQL_COMMONE_TEMPLATE_HISTORY = "INSERT xyqb_i_loan_a_m_history_bak " + public static final String SQL_COMMONE_TEMPLATE_HISTORY = "INSERT xyqb_i_loan_a_m_history_bak " +
" select * from xyqb_i_loan_application_manifest_history b " + " select * from xyqb_i_loan_application_manifest_history b " +
...@@ -39,20 +39,23 @@ public class BaiHangHistoryConstant { ...@@ -39,20 +39,23 @@ public class BaiHangHistoryConstant {
public static final String SQL_COMMONE_TEMPLATE_HISTORY_BAK_MAX_ID = "select MAX(b.id) as bakMaxId from xyqb_i_loan_a_m_history_bak b; "; public static final String SQL_COMMONE_TEMPLATE_HISTORY_BAK_MAX_ID = "select MAX(b.id) as bakMaxId from xyqb_i_loan_a_m_history_bak b; ";
public static final String SQL_COMMONE_TEMPLATE_HISTORY_MAX_ID = " select MAX(b2.id) from xyqb_i_loan_application_manifest_history b2 " +
" where b2.funding_corp_id in (420,520,580,650,670,810,240,640,700) ";
//借款清单表xyqb_i_loan_application_manifest_history
public static final String SQL_COMMONE_TEMPLATE_HISTORY_SYN_COUNT = "select count(b.id) from xyqb_i_loan_application_manifest_history b " + public static final String SQL_COMMONE_TEMPLATE_HISTORY_SYN_COUNT = "select count(b.id) from xyqb_i_loan_application_manifest_history b " +
" where b.funding_corp_id in (420,520,580,650,670,810,240,640,700) " + " where b.funding_corp_id in (420,520,580,650,670,810,240,640,700) " +
" and b.id > ##BAKMAXID## ;"; " and b.id > ##BAKMAXID## AND b.id <= ##NEWMAXID## ;";
public static final String SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA = " INSERT xyqb_i_loan_a_m_history_bak " + public static final String SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA = "REPLACE INTO xyqb_i_loan_a_m_history_bak " + //"INSERT xyqb_i_loan_a_m_history_bak "
" select b.* from xyqb_i_loan_application_manifest_history b " + " select b.* from xyqb_i_loan_application_manifest_history b " +
" where b.funding_corp_id in (420,520,580,650,670,810,240,640,700) " + " where b.funding_corp_id in (420,520,580,650,670,810,240,640,700) " +
" and b.id > ##STARTID## ";//AND b.id <= ##ENDID## " and b.id > ##STARTID## ";//AND b.id <= ##ENDID##
//还款计划表还款计划表xyqb_i_repayment_plan
public static final String SQL_COMMONE_TEMPLATE_PLAN_SYN_COUNT = "select count(a.id) from xyqb_i_repayment_plan a " + public static final String SQL_COMMONE_TEMPLATE_PLAN_SYN_COUNT = "select count(a.id) from xyqb_i_repayment_plan a " +
" join xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id = b.loan_application_history_id " + " join xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id = b.loan_application_history_id " +
" where b.id > ##BAKMAXID##;"; " where b.id > ##BAKMAXID## AND b.id <= ##NEWMAXID## ;";
public static final String SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA = "INSERT xyqb_i_repayment_plan_bak " + public static final String SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA = "REPLACE INTO xyqb_i_repayment_plan_bak " + //"INSERT xyqb_i_repayment_plan_bak "
"select a.* from xyqb_i_repayment_plan a " + "select a.* from xyqb_i_repayment_plan a " +
" join xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id = b.loan_application_history_id " + " join xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id = b.loan_application_history_id " +
" where b.id > ##STARTID## ";//AND b.id <= ##ENDID## " where b.id > ##STARTID## ";//AND b.id <= ##ENDID##
......
...@@ -767,7 +767,7 @@ public class ManualToolService implements CommonSuperService { ...@@ -767,7 +767,7 @@ public class ManualToolService implements CommonSuperService {
public static void writeLog(String msg) { public static void writeLog(String msg) {
System.out.println(msg); System.out.println(msg);
try { try {
String fileName = "D:\\用户目录\\Downloads\\out_log.txt"; String fileName = "D:\\JavaTeam\\D3_build\\out_log.txt";
FileUtils.write(new File(fileName), msg+"\r\n", "UTF-8", true); FileUtils.write(new File(fileName), msg+"\r\n", "UTF-8", true);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -933,6 +933,66 @@ public class ManualToolService implements CommonSuperService { ...@@ -933,6 +933,66 @@ public class ManualToolService implements CommonSuperService {
System.err.println("build data finTechAgencyBusiness end."); System.err.println("build data finTechAgencyBusiness end.");
} }
public static void buildD3_logicerror() {
List<String> logicerrorList = ReadOrWriteTxt.readTxtList("D:\\JavaTeam\\D3_build\\d3_041_errData.txt");
Map<String,String> err_log_loanIdMap = new HashMap<>(logicerrorList.size());
for (String strs : logicerrorList){
String[] tmpArr = strs.split("[|]");
err_log_loanIdMap.put(tmpArr[1],strs);
}
System.out.println("err_log_loanIdMap 大小:"+err_log_loanIdMap.size());
List<String> lineList = ReadOrWriteTxt.readTxtList("D:\\JavaTeam\\D3_build\\D3_04.txt");
System.out.println("lineList:"+lineList.size());
String fileName = "D:\\JavaTeam\\D3_build\\new_D3_04.txt";
int totalCount = 0,removeCount=0;
for(int i=0;i<lineList.size();i++){
System.out.println("START:"+i);
String str = lineList.get(i);
if(str.length() < 30 ){//#applyInfo #singleLoanAccountInfo
continue;
}
RepaymentInfoZhuDai repaymentLoanInfo = new Gson().fromJson(str, new TypeToken<RepaymentInfoZhuDai>(){}.getType());
String loanId = repaymentLoanInfo.getLoanId();
if(err_log_loanIdMap.containsKey(loanId)){
//2|100011189|9|2019-02-22T00:00:00|
String[] errMsgArr = err_log_loanIdMap.get(loanId).split("[|]");
if(repaymentLoanInfo.getTermNo()==Integer.parseInt(errMsgArr[2]) && repaymentLoanInfo.getStatusConfirmAt().equals(errMsgArr[3])){
if(repaymentLoanInfo.getRealRepayment()==null || repaymentLoanInfo.getRealRepayment().intValue()==0){
if(repaymentLoanInfo.getRealRepaymentDate()==null || repaymentLoanInfo.getRealRepaymentDate().equals("")){
writeLog(JSON.toJSONString(repaymentLoanInfo));
removeCount++;
continue;
}
}
}
}
try {
FileUtils.write(new File(fileName), JSON.toJSONString(repaymentLoanInfo)+"\r\n", "UTF-8", true);
} catch (IOException e) {
System.err.println("build D3 data,"+e);
}
totalCount++;
}
System.out.println("build D3 end, lineList="+lineList.size()+",totalCount="+totalCount+",removeCount="+removeCount+", 合="+(totalCount+removeCount));
}
public static void main(String[] args) { public static void main(String[] args) {
// List<String> lineList = ReadOrWriteTxt.readTxtList("D:\\用户目录\\Downloads\\D2_M_01.txt"); // List<String> lineList = ReadOrWriteTxt.readTxtList("D:\\用户目录\\Downloads\\D2_M_01.txt");
// System.out.println("lineList:"+lineList.size()); // System.out.println("lineList:"+lineList.size());
...@@ -950,7 +1010,9 @@ public class ManualToolService implements CommonSuperService { ...@@ -950,7 +1010,9 @@ public class ManualToolService implements CommonSuperService {
//buildD2_inputerror(); //buildD2_inputerror();
buildD2_logicerror(); // buildD2_logicerror();
buildD3_logicerror();
} }
} }
package cn.quantgroup.report.utils.dingtalk;
import cn.quantgroup.report.service.http.IHttpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
/**
* @author :dongjianhua
* @date :Created in 2019/11/1 10:34
* @description:钉钉提醒
* @modified By:
* @version: 1.0
*/
@Component
@Slf4j
public class DingTalk {
@Autowired
private IHttpService iHttpService;
public static final String talkUri = "https://alertserv-dataservice.quantgroup.cn/common/alert/dingtalk";
public static final String webHook = "https://oapi.dingtalk.com/robot/send?access_token=ef3cafb299ec6cb7442b2795d4d0c48e940756f7f267cfa895dbb419adb00128";
@Async
public void talk(String alarmLevel, String msgTitle, String msgContent) {
try{
Map<String, String> param = new HashMap<>();
param.put("webhook", webHook);
param.put("alarmLevel", alarmLevel);//"Warn"
param.put("msgTitle", "量化派2百行:" + msgTitle);
param.put("msgContent", msgContent);
// param.put("toUsers", "15542661376,18612632691");
String resp = iHttpService.post(talkUri, param);
log.info("钉钉报警接口调用结束, resp: {} ", resp);
}catch (Exception e){
log.warn("钉钉报警接口调用异常! ",e);
}
}
@Async
public void talk(String alarmLevel, String msgTitle, Exception e) {
try{
if (e == null) {
return;
}
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
Map<String, String> param = new HashMap<>();
param.put("webhook", webHook);
param.put("alarmLevel", alarmLevel);//"Warn"
param.put("msgTitle", "量化派2百行:" + msgTitle);
param.put("msgContent", sw.toString().length() > 500 ? sw.toString().substring(0, 499) : sw.toString());
// param.put("toUsers", "15542661376,18612632691");
String resp = iHttpService.post(talkUri, param);
log.info("测试钉钉报警接口结果!resp:{}", resp);
log.info("钉钉报警接口调用结束, resp: {} ", resp);
}catch (Exception e2){
log.warn("钉钉报警接口调用异常! ",e2);
}
}
@Async
public void talk_ToUser(String msgContent) {
try{
Map<String, String> param = new HashMap<>();
param.put("webhook", webHook);
param.put("alarmLevel", "ERROE");//
param.put("msgTitle", "量化派2百行:数据同步失败");
param.put("msgContent", msgContent);
param.put("toUsers", "18010105506");
String resp = iHttpService.post(talkUri, param);
log.info("钉钉报警接口调用结束, resp: {} ", resp);
}catch (Exception e){
log.warn("钉钉报警接口调用异常! ",e);
}
}
@Async
public void talk(String alarmLevel, String msgTitle, QgException e) {
Map<String, String> param = new HashMap<>();
param.put("webhook", webHook);
param.put("alarmLevel", alarmLevel);//"Warn"
param.put("msgTitle", "量化派2百行:" + msgTitle);
param.put("msgContent", exceptionToString(e));
// param.put("toUsers", "15542661376,18612632691");
String resp = iHttpService.post(talkUri, param);
log.info("测试钉钉报警接口结果!resp:{}", resp);
}
public String exceptionToString(QgException e) {
return new StringBuffer()
.append(e.alarm)
.append(":")
.append(e.message == null ? "" : (e.message.length() > 500 ? e.message.substring(0, 499) : e.message)).toString();
}
}
package cn.quantgroup.report.utils.dingtalk;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
* @author :dongjianhua
* @date :Created in 2019/11/4 10:38
* @description:异常类
* @modified By:
* @version: 1.0
*/
public class QgException extends RuntimeException {
//提醒标题
public String alarm;
//堆栈信息 或者报错信息
public String message;
public QgException(String exMsg) {
alarm = exMsg;
}
public QgException(String exMsg, String message) {
super(message,null);
alarm = exMsg;
this.message = message;
}
public QgException(String exMsg, Exception e) {
super(e);
alarm = exMsg;
message = getStackTrace(e);
}
public static String getStackTrace(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
t.printStackTrace(pw);
return sw.toString();
} finally {
pw.close();
}
}
}
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