Commit 562b1ef6 authored by 张俊's avatar 张俊

调整执行逻辑

parent 4dbb6839
...@@ -19,9 +19,8 @@ import java.sql.CallableStatement; ...@@ -19,9 +19,8 @@ import java.sql.CallableStatement;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator; import java.util.stream.Collectors;
import java.util.List;
/** /**
...@@ -153,23 +152,29 @@ public class DeptInfoUpdateService { ...@@ -153,23 +152,29 @@ public class DeptInfoUpdateService {
if (CollectionUtils.isEmpty(collDwxxbgList)) { if (CollectionUtils.isEmpty(collDwxxbgList)) {
return "0"; return "0";
} }
// 根据业务id分组
Map<String, List<BusinessProcessing>> listMap = collDwxxbgList.stream()
.collect(Collectors.groupingBy(vo -> vo.getBusId(), LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<String, List<BusinessProcessing>> listEntry : listMap.entrySet()) {
String busId = listEntry.getKey();
List<BusinessProcessing> processinglist = listEntry.getValue();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("state", "1"); jsonObject.put("state", "1");
jsonObject.put("timestamp", collDwxxbgList.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime()); jsonObject.put("timestamp", processinglist.stream().max(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
jsonObject.put("busId", collDwxxbgList.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId()); jsonObject.put("busId", busId);
jsonObject.put("departCode", "10"); jsonObject.put("departCode", "10");
jsonObject.put("nodeList", collDwxxbgList); jsonObject.put("nodeList", processinglist);
String str = jsonObject.toString(); String str = jsonObject.toString();
log.info("单位信息变更推送单位信息请求入参:{}", str); 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 status = "true".equals(jsonObj.getString("success")) ? 1 : 0;
String uscc = !CollectionUtils.isEmpty(collDwxxbgList) ? collDwxxbgList.get(0).getUscc() : "";
// 回写 // 回写
collDeptInfoUpdateRewrite(uscc, value); collDeptInfoUpdateRewrite(busId, status);
return forObject; }
return "1";
} }
/** /**
......
...@@ -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;
...@@ -20,9 +19,8 @@ import java.sql.CallableStatement; ...@@ -20,9 +19,8 @@ import java.sql.CallableStatement;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator; import java.util.stream.Collectors;
import java.util.List;
/** /**
...@@ -123,23 +121,30 @@ public class DeptLogoutService { ...@@ -123,23 +121,30 @@ public class DeptLogoutService {
if (CollectionUtils.isEmpty(collDwxhList)) { if (CollectionUtils.isEmpty(collDwxhList)) {
return "0"; return "0";
} }
// 根据业务id分组
Map<String, List<BusinessProcessing>> listMap = collDwxhList.stream()
.collect(Collectors.groupingBy(vo -> vo.getBusId(), LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<String, List<BusinessProcessing>> listEntry : listMap.entrySet()) {
String busId = listEntry.getKey();
List<BusinessProcessing> processinglist = listEntry.getValue();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("state", "1"); jsonObject.put("state", "1");
jsonObject.put("timestamp", collDwxhList.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime()); jsonObject.put("timestamp", processinglist.stream().max(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
jsonObject.put("busId", collDwxhList.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId()); jsonObject.put("busId", busId);
jsonObject.put("departCode", "10"); jsonObject.put("departCode", "10");
jsonObject.put("nodeList", collDwxhList); jsonObject.put("nodeList", processinglist);
String str = jsonObject.toString(); String str = jsonObject.toString();
log.info("单位开户推送单位信息请求入参:{}", str); 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 status = "true".equals(jsonObj.getString("success")) ? 1 : 0;
String uscc = !CollectionUtils.isEmpty(collDwxhList) ? collDwxhList.get(0).getUscc() : "";
// 回写 // 回写
collDeptLogoutRewrite(uscc, value); collDeptLogoutRewrite(busId, status);
return forObject; }
return "1";
} }
/** /**
......
...@@ -21,10 +21,8 @@ import javax.annotation.Resource; ...@@ -21,10 +21,8 @@ import javax.annotation.Resource;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator; import java.util.stream.Collectors;
import java.util.Date;
import java.util.List;
/** /**
...@@ -283,39 +281,34 @@ public class OpenAccountService { ...@@ -283,39 +281,34 @@ public class OpenAccountService {
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return "0"; return "0";
} }
// 根据业务id分组
Map<String, List<BusinessProcessing>> listMap = list.stream()
.collect(Collectors.groupingBy(vo -> vo.getBusId(), LinkedHashMap::new, Collectors.toList()));
for (Map.Entry<String, List<BusinessProcessing>> listEntry : listMap.entrySet()) {
String busId = listEntry.getKey();
List<BusinessProcessing> processinglist = listEntry.getValue();
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("state", "1"); jsonObject.put("state", "1");
jsonObject.put("timestamp", list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getTime()); jsonObject.put("timestamp", processinglist.stream().max(Comparator.comparing(BusinessProcessing::getTime)).get().getTime());
jsonObject.put("busId", list.stream().min(Comparator.comparing(BusinessProcessing::getTime)).get().getBusId()); jsonObject.put("busId", busId);
jsonObject.put("departCode", "10"); jsonObject.put("departCode", "10");
jsonObject.put("nodeList", list); jsonObject.put("nodeList", processinglist);
String str = jsonObject.toString(); String str = jsonObject.toString();
// 发起 post 请求 // 发起 post 请求
log.info("单位开户推送单位信息请求入参:{}", str); log.info("单位开户推送单位信息请求入参:{}", str);
String result = HttpUtil.sendPost(businessProcessing, str); String result = HttpUtil.sendPost(businessProcessing, str);
log.info("单位开户推送单位信息请求出参:{}", result); log.info("单位开户推送单位信息请求出参:{}", result);
if (result != null) { if (result != null) {
String uscc = "";
if (!list.isEmpty()) {
uscc = list.get(0).getUscc();
}
log.info(uscc);
JSONObject jsonObj = JSONObject.parseObject(result); JSONObject jsonObj = JSONObject.parseObject(result);
String success = jsonObj.getString("success"); Integer status = "true".equals(jsonObj.getString("success")) ? 1 : 0;
Integer value = 0;
if ("true".equals(success)) {
value = 1;
} else if ("false".equals(success)) {
value = 0;
}
try { try {
collOpenAccountRewrite(uscc, value); collOpenAccountRewrite(busId, status);
} catch (Exception e) { } catch (Exception e) {
log.error("{}", e); log.error("{}", e);
} }
log.info("success:{}", value);
} }
return result; }
return "1";
} }
/** /**
......
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