Commit 4dbb6839 authored by 张俊's avatar 张俊

优化日志输出

parent dab23bd2
...@@ -38,7 +38,6 @@ public class AlarmTask { ...@@ -38,7 +38,6 @@ public class AlarmTask {
*/ */
@Scheduled(initialDelay = 5 * 1000, fixedDelayString = "${dwkhPullTaskDelay}") @Scheduled(initialDelay = 5 * 1000, fixedDelayString = "${dwkhPullTaskDelay}")
public void dwkhPullTask() { public void dwkhPullTask() {
log.debug("dwkhPullTask 开始时间:{}", InternalUtils.getCurrentTime());
try { try {
openAccountService.syncDeptInfo(); openAccountService.syncDeptInfo();
} catch (Exception e) { } catch (Exception e) {
...@@ -53,19 +52,16 @@ public class AlarmTask { ...@@ -53,19 +52,16 @@ public class AlarmTask {
*/ */
@Scheduled(initialDelay = 20 * 1000, fixedDelayString = "${dwkhPushTaskDelay}") @Scheduled(initialDelay = 20 * 1000, fixedDelayString = "${dwkhPushTaskDelay}")
public void dwkhPushTask() { public void dwkhPushTask() {
log.debug("dwkhPushTask 开始时间:{}", InternalUtils.getCurrentTime());
openAccountService.openAccountPush(); openAccountService.openAccountPush();
} }
@Scheduled(initialDelay = 40 * 1000, fixedDelayString = "${dwxxbgPushTaskDelay}") @Scheduled(initialDelay = 40 * 1000, fixedDelayString = "${dwxxbgPushTaskDelay}")
public void dwxxbgPushTask() { public void dwxxbgPushTask() {
log.debug("dwxxbgPushTask 开始时间:{}", InternalUtils.getCurrentTime());
deptInfoUpdateService.deptInfoUpdatePush(); deptInfoUpdateService.deptInfoUpdatePush();
} }
@Scheduled(initialDelay = 80 * 1000, fixedDelayString = "${dwxhPushTaskDelay}") @Scheduled(initialDelay = 80 * 1000, fixedDelayString = "${dwxhPushTaskDelay}")
public void dwxhPushTask() { public void dwxhPushTask() {
log.debug("dwxhPushTask 开始时间:{}", InternalUtils.getCurrentTime());
deptLogoutService.deptLogoutPush(); deptLogoutService.deptLogoutPush();
} }
......
...@@ -2,7 +2,6 @@ package net.cdkj.gjj.adapter.service; ...@@ -2,7 +2,6 @@ package net.cdkj.gjj.adapter.service;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.domain.BusinessProcessing; import net.cdkj.gjj.adapter.domain.BusinessProcessing;
import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation; import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation;
...@@ -52,6 +51,7 @@ public class DeptInfoUpdateService { ...@@ -52,6 +51,7 @@ public class DeptInfoUpdateService {
if (CollectionUtils.isEmpty(bills)) { if (CollectionUtils.isEmpty(bills)) {
return; return;
} }
log.info("执行 DWXXBG_IMP 过程入参:{}", bills);
// 2.内置机处理返回的业务数据,调用oracle存储过程 // 2.内置机处理返回的业务数据,调用oracle存储过程
Connection connection = null; Connection connection = null;
CallableStatement dwxxbgImp = null; CallableStatement dwxxbgImp = null;
...@@ -118,10 +118,8 @@ public class DeptInfoUpdateService { ...@@ -118,10 +118,8 @@ public class DeptInfoUpdateService {
// 获取出参 // 获取出参
String errcode = dwxxbgImp.getString(16); String errcode = dwxxbgImp.getString(16);
String errmsg = dwxxbgImp.getString(17); String errmsg = dwxxbgImp.getString(17);
log.info("DWXXBG_IMP 执行结果 errcode:{},errmsg :{}", errcode, errmsg);
if (StringUtils.isEmpty(errcode)) { if (StringUtils.isEmpty(errcode)) {
log.error("DWXXBG_IMP 执行结果 errcode:{},errmsg :{},对应数据为:{}", errcode, errmsg, JSON.toJSONString(uniInfom)); log.info("busId:{} 执行结果 errcode:{},errmsg :{}", busId, errcode, errmsg);
continue;
} else { } else {
// 避免批量插入高并发,此处设置每次停顿5秒 // 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000); Thread.currentThread().sleep(2000);
...@@ -162,13 +160,13 @@ public class DeptInfoUpdateService { ...@@ -162,13 +160,13 @@ public class DeptInfoUpdateService {
jsonObject.put("departCode", "10"); jsonObject.put("departCode", "10");
jsonObject.put("nodeList", collDwxxbgList); jsonObject.put("nodeList", collDwxxbgList);
String str = jsonObject.toString(); String str = jsonObject.toString();
log.info("单位信息变更推送单位信息请求入参:{}", str);
//(测试环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口 //(测试环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
String forObject = restTemplate.postForObject(businessProcessing, str, String.class); String forObject = restTemplate.postForObject(businessProcessing, str, String.class);
log.info("前置机返回第三方解压之后的进度推送结果:{}", forObject); log.info("单位信息变更推送单位信息请求出参:{}", forObject);
JSONObject jsonObj = JSONObject.parseObject(forObject); JSONObject jsonObj = JSONObject.parseObject(forObject);
Integer value = "true".equals(jsonObj.getString("success")) ? 1 : 0; Integer value = "true".equals(jsonObj.getString("success")) ? 1 : 0;
String uscc = !CollectionUtils.isEmpty(collDwxxbgList) ? collDwxxbgList.get(0).getUscc() : ""; String uscc = !CollectionUtils.isEmpty(collDwxxbgList) ? collDwxxbgList.get(0).getUscc() : "";
log.info("入参 uscc:{} value:{}", uscc, value);
// 回写 // 回写
collDeptInfoUpdateRewrite(uscc, value); collDeptInfoUpdateRewrite(uscc, value);
return forObject; return forObject;
...@@ -229,7 +227,7 @@ public class DeptInfoUpdateService { ...@@ -229,7 +227,7 @@ public class DeptInfoUpdateService {
} }
list.add(bp); list.add(bp);
} }
log.info("调用 DWXXBG_CX 返回数据:{}", JSONObject.toJSONString(list)); log.info("单位信息变更调用过程结果:{}", JSONObject.toJSONString(list));
} catch (Exception e) { } catch (Exception e) {
log.error("调用 DWXXBG_CX 异常:{}", e); log.error("调用 DWXXBG_CX 异常:{}", e);
} finally { } finally {
......
...@@ -51,6 +51,7 @@ public class DeptLogoutService { ...@@ -51,6 +51,7 @@ public class DeptLogoutService {
if (CollectionUtils.isEmpty(bills)) { if (CollectionUtils.isEmpty(bills)) {
return; return;
} }
log.info("执行 DWXH_IMP 过程入参:{}", bills);
// 2.内置机处理返回的业务数据,调用oracle存储过程 // 2.内置机处理返回的业务数据,调用oracle存储过程
Connection connection = null; Connection connection = null;
CallableStatement dwxhImp = null; CallableStatement dwxhImp = null;
...@@ -85,12 +86,10 @@ public class DeptLogoutService { ...@@ -85,12 +86,10 @@ public class DeptLogoutService {
// 执行数据库查询操作 // 执行数据库查询操作
dwxhImp.execute(); dwxhImp.execute();
// 获取出参 // 获取出参
String errcode = dwxhImp.getString(7); String errcode = dwxhImp.getString(6);
String errmsg = dwxhImp.getString(7); String errmsg = dwxhImp.getString(7);
log.info("DWXH_IMP 执行结果 errcode:{},errmsg :{}", errcode, errmsg);
if (StringUtils.isEmpty(errcode)) { if (StringUtils.isEmpty(errcode)) {
log.error("DWXH_IMP 执行结果 errcode:{},errmsg :{},对应数据为:{}", errcode, errmsg, JSON.toJSONString(uniInfom)); log.info("busId:{} 执行结果 errcode:{},errmsg :{}", busId, errcode, errmsg);
continue;
} else { } else {
// 避免批量插入高并发,此处设置每次停顿5秒 // 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000); Thread.currentThread().sleep(2000);
...@@ -131,13 +130,13 @@ public class DeptLogoutService { ...@@ -131,13 +130,13 @@ public class DeptLogoutService {
jsonObject.put("departCode", "10"); jsonObject.put("departCode", "10");
jsonObject.put("nodeList", collDwxhList); jsonObject.put("nodeList", collDwxhList);
String str = jsonObject.toString(); String str = jsonObject.toString();
log.info("单位开户推送单位信息请求入参:{}", str);
//(测试环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口 //(测试环境)调用前置机将业务机封装的业务json数据发给前置机,让前置机去请求第三方的公积金系统服务接口
String forObject = restTemplate.postForObject(businessProcessing, str, String.class); String forObject = restTemplate.postForObject(businessProcessing, str, String.class);
log.info("前置机返回第三方解压之后的进度推送结果:{}", forObject); log.info("单位开户推送单位信息请求出参:{}", forObject);
JSONObject jsonObj = JSONObject.parseObject(forObject); JSONObject jsonObj = JSONObject.parseObject(forObject);
Integer value = "true".equals(jsonObj.getString("success")) ? 1 : 0; Integer value = "true".equals(jsonObj.getString("success")) ? 1 : 0;
String uscc = !CollectionUtils.isEmpty(collDwxhList) ? collDwxhList.get(0).getUscc() : ""; String uscc = !CollectionUtils.isEmpty(collDwxhList) ? collDwxhList.get(0).getUscc() : "";
log.info("入参 uscc:{} value:{}", uscc, value);
// 回写 // 回写
collDeptLogoutRewrite(uscc, value); collDeptLogoutRewrite(uscc, value);
return forObject; return forObject;
...@@ -198,7 +197,7 @@ public class DeptLogoutService { ...@@ -198,7 +197,7 @@ public class DeptLogoutService {
} }
list.add(bp); list.add(bp);
} }
log.info("调用 DWXH_CX 返回数据:{}", JSONObject.toJSONString(list)); log.info("单位销户调用过程结果:{}", JSONObject.toJSONString(list));
} catch (Exception e) { } catch (Exception e) {
log.error("调用 DWXH_CX 异常:{}", e); log.error("调用 DWXH_CX 异常:{}", e);
} finally { } finally {
......
...@@ -2,6 +2,7 @@ package net.cdkj.gjj.adapter.service; ...@@ -2,6 +2,7 @@ package net.cdkj.gjj.adapter.service;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.domain.BusinessProcessing; import net.cdkj.gjj.adapter.domain.BusinessProcessing;
import net.cdkj.gjj.adapter.domain.Json; import net.cdkj.gjj.adapter.domain.Json;
...@@ -34,7 +35,7 @@ public class OpenAccountService { ...@@ -34,7 +35,7 @@ public class OpenAccountService {
// sl4j // sl4j
private static final Logger logger = LoggerFactory.getLogger(OpenAccountService.class); private static final Logger log = LoggerFactory.getLogger(OpenAccountService.class);
@Resource @Resource
...@@ -78,10 +79,10 @@ public class OpenAccountService { ...@@ -78,10 +79,10 @@ public class OpenAccountService {
jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186"); jsonObject.put("app_secret", "9a31b84878654a72a999e38ef55aa186");
String str = jsonObject.toString(); String str = jsonObject.toString();
// 发起 post 请求 // 发起 post 请求
log.info("拉取单位信息请求入参:{}", str);
String result = HttpUtil.sendPost(providentFundServices, str); String result = HttpUtil.sendPost(providentFundServices, str);
// String result = mockDwxxHttp(); // String result = mockDwxxHttp();
log.info("拉取单位信息请求出参:{}", result);
logger.info("拿到第一个接口返回的第三方数据,准备调第一个存储过程" + result);
Json jsonentity = JSONObject.parseObject(result, Json.class); Json jsonentity = JSONObject.parseObject(result, Json.class);
List<UnitAccountOpeningInformation> bills = new ArrayList<>(); List<UnitAccountOpeningInformation> bills = new ArrayList<>();
if (!InternalUtils.isNullOrEmpty(jsonentity)) { if (!InternalUtils.isNullOrEmpty(jsonentity)) {
...@@ -120,21 +121,20 @@ public class OpenAccountService { ...@@ -120,21 +121,20 @@ public class OpenAccountService {
if (CollectionUtils.isEmpty(bills)) { if (CollectionUtils.isEmpty(bills)) {
return; return;
} }
log.info("执行 DWXX_IMP 过程入参:{}", bills);
// 2.内置机处理返回的业务数据,调用oracle存储过程 // 2.内置机处理返回的业务数据,调用oracle存储过程
// 加载数据库驱动 // 加载数据库驱动
Connection connection = dataSource.getConnection(); Connection connection = dataSource.getConnection();
// 得到预编译的Statement对象 // 得到预编译的Statement对象
CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); CallableStatement pstm = connection.prepareCall("{call JGJ_KSYW_DWKH.DWXX_IMP(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
// 调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
CallableStatement pstm2 = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_SAVE()}");
for (UnitAccountOpeningInformation uniInfom : bills) { for (UnitAccountOpeningInformation uniInfom : bills) {
String oplocdistrict = uniInfom.getOplocdistrict(); String oplocdistrict = uniInfom.getOplocdistrict();
if (StringUtils.isEmpty(oplocdistrict)) { if (StringUtils.isEmpty(oplocdistrict)) {
continue; continue;
} }
logger.info("oplocdistrict" + "在规定的值里面,调imp过程"); String busId = uniInfom.getBusId();
if (!"".equals(uniInfom.getBusId()) && uniInfom.getBusId() != null) { if (!"".equals(busId) && busId != null) {
pstm.setString(1, uniInfom.getBusId()); pstm.setString(1, busId);
} else { } else {
pstm.setString(1, ""); pstm.setString(1, "");
} }
...@@ -245,24 +245,25 @@ public class OpenAccountService { ...@@ -245,24 +245,25 @@ public class OpenAccountService {
// 执行数据库查询操作 // 执行数据库查询操作
pstm.execute(); pstm.execute();
// 输出结果[第二个参数] // 输出结果[第二个参数]
logger.info(pstm.getString(19)); String errcode = pstm.getString(19);
logger.info(pstm.getString(20)); String errmsg = pstm.getString(20);
if ("".equals(pstm.getString(19)) || pstm.getString(19) == null) { if (StringUtils.isEmpty(errcode)) {
break; log.info("busId:{} 执行结果 errcode:{},errmsg :{}", busId, errcode, errmsg);
} else { } else {
try { try {
// 避免批量插入高并发,此处设置每次停顿5秒 // 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000); Thread.currentThread().sleep(2000);
logger.info("间隔2秒传一条数据调一次存储过程");
} catch (InterruptedException e) { } catch (InterruptedException e) {
logger.error("{}", e); log.error("{}", e);
} }
} }
} }
pstm2.execute();
// 释放资源 // 释放资源
pstm.close(); pstm.close();
// 调完第一个存储过程DWXX_IMP之后再调DWKH_SAVE存储过程
CallableStatement pstm2 = connection.prepareCall("{call JGJ_KSYW_DWKH.DWKH_SAVE()}");
pstm2.execute();
pstm2.close(); pstm2.close();
connection.close(); connection.close();
} }
...@@ -272,13 +273,12 @@ public class OpenAccountService { ...@@ -272,13 +273,12 @@ public class OpenAccountService {
* (第二个定时) * (第二个定时)
*/ */
public String openAccountPush() { public String openAccountPush() {
logger.info("调第二个接口了");
// 调oracle存储过程拿到进度推进的数据集合 // 调oracle存储过程拿到进度推进的数据集合
List<BusinessProcessing> list = null; List<BusinessProcessing> list = null;
try { try {
list = collOpenAccount(); list = collOpenAccount();
} catch (Exception e) { } catch (Exception e) {
logger.error("{}", e); log.error("{}", e);
} }
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return "0"; return "0";
...@@ -291,13 +291,15 @@ public class OpenAccountService { ...@@ -291,13 +291,15 @@ public class OpenAccountService {
jsonObject.put("nodeList", list); jsonObject.put("nodeList", list);
String str = jsonObject.toString(); String str = jsonObject.toString();
// 发起 post 请求 // 发起 post 请求
log.info("单位开户推送单位信息请求入参:{}", str);
String result = HttpUtil.sendPost(businessProcessing, str); String result = HttpUtil.sendPost(businessProcessing, str);
log.info("单位开户推送单位信息请求出参:{}", result);
if (result != null) { if (result != null) {
String uscc = ""; String uscc = "";
if (!list.isEmpty()) { if (!list.isEmpty()) {
uscc = list.get(0).getUscc(); uscc = list.get(0).getUscc();
} }
logger.info(uscc); log.info(uscc);
JSONObject jsonObj = JSONObject.parseObject(result); JSONObject jsonObj = JSONObject.parseObject(result);
String success = jsonObj.getString("success"); String success = jsonObj.getString("success");
Integer value = 0; Integer value = 0;
...@@ -309,9 +311,9 @@ public class OpenAccountService { ...@@ -309,9 +311,9 @@ public class OpenAccountService {
try { try {
collOpenAccountRewrite(uscc, value); collOpenAccountRewrite(uscc, value);
} catch (Exception e) { } catch (Exception e) {
logger.error("{}", e); log.error("{}", e);
} }
logger.info("success:{}", value); log.info("success:{}", value);
} }
return result; return result;
} }
...@@ -367,7 +369,7 @@ public class OpenAccountService { ...@@ -367,7 +369,7 @@ public class OpenAccountService {
} }
list.add(b); list.add(b);
} }
logger.info("获取结果:{}", list); log.info("单位开户调用过程结果:{}", JSON.toJSONString(list));
// 释放资源 // 释放资源
pstm.close(); pstm.close();
connection.close(); connection.close();
......
...@@ -12,7 +12,7 @@ import java.net.URL; ...@@ -12,7 +12,7 @@ import java.net.URL;
public class HttpUtil { public class HttpUtil {
private static final Logger logger = LoggerFactory.getLogger(InternalUtils.class); private static final Logger log = LoggerFactory.getLogger(InternalUtils.class);
/** /**
* 获取请求入参数据 * 获取请求入参数据
...@@ -26,10 +26,10 @@ public class HttpUtil { ...@@ -26,10 +26,10 @@ public class HttpUtil {
json.append(line); json.append(line);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("{}", e); log.error("{}", e);
} }
String str = json.toString(); String str = json.toString();
logger.info("要发送给第三方的公积金系统服务报文:" + str); log.info("要发送给第三方的公积金系统服务报文:" + str);
return str; return str;
} }
...@@ -79,13 +79,12 @@ public class HttpUtil { ...@@ -79,13 +79,12 @@ public class HttpUtil {
sb.append(readLine); sb.append(readLine);
} }
responseReader.close(); responseReader.close();
logger.info("前置机返回第三方解压之后数据:" + sb);
return sb.toString(); return sb.toString();
} else { } else {
logger.info("请求失败!!!"); log.info("请求失败!!!");
} }
} catch (IOException e) { } catch (IOException e) {
logger.error("{}", e); log.error("{}", e);
} finally { } finally {
if (out != null) { if (out != null) {
try { try {
......
...@@ -11,7 +11,7 @@ import java.util.Map; ...@@ -11,7 +11,7 @@ import java.util.Map;
public class InternalUtils { public class InternalUtils {
private static final Logger logger = LoggerFactory.getLogger(InternalUtils.class); private static final Logger log = LoggerFactory.getLogger(InternalUtils.class);
/** /**
* 判断一个实体对象是否为空 * 判断一个实体对象是否为空
...@@ -61,7 +61,6 @@ public class InternalUtils { ...@@ -61,7 +61,6 @@ public class InternalUtils {
curentDay.set(Calendar.SECOND, 0); curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime()); time = df2.format(curentDay.getTime().getTime());
logger.error("type == 0 time:{}", time);
} else if (type == 24) { } else if (type == 24) {
// 获取当天24点零分零秒的时间戳,即第二天零点时间 // 获取当天24点零分零秒的时间戳,即第二天零点时间
Calendar curentDay = Calendar.getInstance(); Calendar curentDay = Calendar.getInstance();
...@@ -71,7 +70,6 @@ public class InternalUtils { ...@@ -71,7 +70,6 @@ public class InternalUtils {
curentDay.set(Calendar.SECOND, 0); curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime()); time = df2.format(curentDay.getTime().getTime());
logger.error("type == 24 time:{}", time);
} }
return time; return time;
} }
......
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