Commit d6663397 authored by chenyuxi's avatar chenyuxi

feat:网银入账优化

parent 5eee6dd2
...@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 社保明细表 * 社保明细表
...@@ -40,4 +41,11 @@ public interface EkpSocialInfoMapper extends BaseMapper<EkpSocialInfo> { ...@@ -40,4 +41,11 @@ public interface EkpSocialInfoMapper extends BaseMapper<EkpSocialInfo> {
* @return * @return
*/ */
List<String> getAllserioNo(); List<String> getAllserioNo();
/**
* 获取需要拉流水的银行账户
* @param
* @return
*/
List<Map<String,String>> getAccountList();
} }
...@@ -37,7 +37,9 @@ import java.text.ParseException; ...@@ -37,7 +37,9 @@ import java.text.ParseException;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -115,132 +117,136 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn ...@@ -115,132 +117,136 @@ public class IcbcTransactionFlowQueryServiceImpl extends ServiceImpl<EkpSocialIn
} }
} }
@Override
public R getIcbcTransactionFlowNew() throws IcbcApiException { public R getIcbcTransactionFlowNew() throws IcbcApiException {
log.info("开始推当日新增网银到账明细条数");
String tranDate = DateUtil.getThisDay();
// todo 测试时改为查10天内的,上线改为查当天内的
String beginDate = DateUtil.addDay(-10).replace("-","");
String endDate = tranDate;
return getIcbcTransactionFlowCommon(tranDate,beginDate,endDate);
}
@Override
public R getIcbcTransactionFlowYesterdayInner() throws IcbcApiException {
log.info("开始推昨日新增网银到账明细条数");
String tranDate = DateUtil.addDay(-1).replace("-","");
String beginDate = tranDate;
String endDate = tranDate;
return getIcbcTransactionFlowCommon(tranDate,beginDate,endDate);
}
//从9月12号开始执行定时任务
if (DateUtil.getCurrentDateString().compareTo("2024-09-12") < 0 ) {
return R.ok();
}
DefaultIcbcClient client = new DefaultIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_CA_SM_ICBC,
icbcConfigProperties.getAppPrivateKey(), IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON, null,
null, null, icbcConfigProperties.getCaSm(), null);
client.setIcbc_ca(icbcConfigProperties.getCaSmIcbc());
MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1 bizContent = /**
new MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1(); * 新增网银到账明细条数公共处理
MybankEnterpriseTradeQhisdRequestV1 request = new MybankEnterpriseTradeQhisdRequestV1(); *
* @author cyx
* @date 2024-09-26
* @since mvp1.6.11
*/
private R getIcbcTransactionFlowCommon(String tranDate, String beginDate, String endDate) throws IcbcApiException {
// 获取当前时间 // 获取当前时间
LocalTime currentTime = LocalTime.now(); LocalTime currentTime = LocalTime.now();
// 使用DateTimeFormatter格式化 // 使用DateTimeFormatter格式化
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HHmmssSSS"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HHmmssSSS");
String formattedTime = currentTime.format(formatter); String formattedTime = currentTime.format(formatter);
bizContent.setTranDate(DateUtil.getThisDay());
bizContent.setTranTime(formattedTime);
bizContent.setTransCode("QHISD");
bizContent.setLanguage("zh_CN");
String fSeqNo = "AHWX" + System.currentTimeMillis();
bizContent.setfSeqno(fSeqNo);
bizContent.setAccountNo("1302015209250019444");
bizContent.setBeginDate(DateUtil.addDay(-10).replace("-",""));
bizContent.setEndDate(DateUtil.getThisDay());
bizContent.setDrcrf("2");
request.setServiceUrl(icbcConfigProperties.getServerUrl());
request.setBizContent(bizContent);
MybankEnterpriseTradeQhisdResponseV1 response = client.execute(request);
if(response.isSuccess()) {
//查询当天的所有入账记录数据
List<String> serioList = baseMapper.getAllserioNo();
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> list = response.getRd();
String bankName = response.getAccountName();
String bankNo = response.getAccountNo();
//获取成功后根据流水号去重和根据借贷标志02筛选出所有数据
if (!list.isEmpty()) {
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> insertList =
list.stream().filter(e-> e.getDrcrf().equals("2") && !serioList.contains(e.getOnlySequence())).collect(Collectors.toList());
//封装数据
if (!insertList.isEmpty()) {
log.error("到账明细条数:" + insertList.size());
try {
for (MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1 entry : insertList) {
EKPEntryPushParam pushParam = new EKPEntryPushParam();
initValue(entry, pushParam, bankName, bankNo);
String body = sendToEkp(pushParam);
//重试
if (StringUtils.isBlank(body)) {
sendToEkp(pushParam);
}
break;
}
}catch (Exception e) {
log.error("到账明细数据推送失败",e);
}
}
}
}
return R.ok();
}
public R getIcbcTransactionFlowYesterdayInner() throws IcbcApiException {
//从9月13号开始执行定时任务
if (DateUtil.getCurrentDateString().compareTo("2024-09-13") <0 ) {
return R.ok();
}
DefaultIcbcClient client = new DefaultIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_CA_SM_ICBC, DefaultIcbcClient client = new DefaultIcbcClient(icbcConfigProperties.getAppId(), IcbcConstants.SIGN_TYPE_CA_SM_ICBC,
icbcConfigProperties.getAppPrivateKey(), IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON, null, icbcConfigProperties.getAppPrivateKey(), IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON, null,
null, null, icbcConfigProperties.getCaSm(), null); null, null, icbcConfigProperties.getCaSm(), null);
client.setIcbc_ca(icbcConfigProperties.getCaSmIcbc()); client.setIcbc_ca(icbcConfigProperties.getCaSmIcbc());
MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1 bizContent = // 查需要获取流水的账号
new MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1(); List<Map<String,String>> accountList = baseMapper.getAccountList();
MybankEnterpriseTradeQhisdRequestV1 request = new MybankEnterpriseTradeQhisdRequestV1(); if (accountList.isEmpty()) {
// 获取当前时间 return R.ok();
LocalTime currentTime = LocalTime.now(); }
// 使用DateTimeFormatter格式化
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HHmmssSSS"); // 查询当天的所有入账记录数据
String formattedTime = currentTime.format(formatter); List<String> serioList = baseMapper.getAllserioNo();
bizContent.setTranDate(DateUtil.addDay(-1).replace("-","")); // 账号为key,账户名称作为value
bizContent.setTranTime(formattedTime); Map<String,String> accountInfoMap = new HashMap<>();
bizContent.setTransCode("QHISD"); // 账号为key,账号下的流水作为value
bizContent.setLanguage("zh_CN"); Map<String,List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1>> accountRecordListMap = new HashMap<>();
String fSeqNo = "AHWX" + System.currentTimeMillis();
bizContent.setfSeqno(fSeqNo); // 定义请求工行需要的传参对象
bizContent.setAccountNo("1302010109024596014"); MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1 bizContent;
bizContent.setBeginDate(DateUtil.addDay(-1).replace("-","")); MybankEnterpriseTradeQhisdRequestV1 request;
bizContent.setEndDate(DateUtil.addDay(-1).replace("-",""));
bizContent.setDrcrf("2"); for(Map<String,String> accountInfo: accountList) {
request.setServiceUrl(icbcConfigProperties.getServerUrl());
request.setBizContent(bizContent); bizContent = new MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1();
MybankEnterpriseTradeQhisdResponseV1 response = client.execute(request); request = new MybankEnterpriseTradeQhisdRequestV1();
if(response.isSuccess()) {
//查询当天的所有入账记录数据 bizContent.setTranDate(tranDate);
List<String> serioList = baseMapper.getAllserioNo(); bizContent.setTranTime(formattedTime);
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> list = response.getRd(); bizContent.setTransCode("QHISD");
String bankName = response.getAccountName(); bizContent.setLanguage("zh_CN");
String bankNo = response.getAccountNo(); String fSeqNo = "AHWX" + System.currentTimeMillis();
//获取成功后根据流水号去重和根据借贷标志02筛选出所有数据 bizContent.setfSeqno(fSeqNo);
if (!list.isEmpty()) { bizContent.setAccountNo(accountInfo.get("bank_no"));
bizContent.setBeginDate(beginDate);
bizContent.setEndDate(endDate);
bizContent.setDrcrf("2");
request.setServiceUrl(icbcConfigProperties.getServerUrl());
request.setBizContent(bizContent);
MybankEnterpriseTradeQhisdResponseV1 response = client.execute(request);
if(response.isSuccess()) {
// 获取所有账号的流水,每个账号存一个流水
accountRecordListMap.put(accountInfo.get("bank_no"),response.getRd());
if(accountInfo.get("bank_no").equals(response.getAccountNo())){
accountInfoMap.put(accountInfo.get("bank_no"),response.getAccountName());
}
}
}
// 重新过滤已存入【入账记录】的流水信息
for (String account : accountRecordListMap.keySet()) {
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> flowRecordList = accountRecordListMap.get(account);
// 获取成功后根据流水号去重和根据借贷标志02筛选出所有数据
if (!flowRecordList.isEmpty()) {
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> insertList = List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> insertList =
list.stream().filter(e-> e.getDrcrf().equals("2") && !serioList.contains(e.getOnlySequence())).collect(Collectors.toList()); flowRecordList.stream().filter(e-> e.getDrcrf().equals("2") && !serioList.contains(e.getOnlySequence())).collect(Collectors.toList());
//封装数据 if(!insertList.isEmpty()){
if (!insertList.isEmpty()) { // 还有需要存的流水,重新存入账号流水Map里
log.error("昨日新增到账明细条数:" + insertList.size()); accountRecordListMap.put(account, insertList);
try { } else {
for (MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1 entry : insertList) { // 没有需要存的流水,账号流水Map重置值为空列表
EKPEntryPushParam pushParam = new EKPEntryPushParam(); accountRecordListMap.put(account, new ArrayList<>());
initValue(entry, pushParam, bankName, bankNo); }
String body = sendToEkp(pushParam); }
//重试 }
if (StringUtils.isBlank(body)) {
sendToEkp(pushParam); // 存入过滤后的流水信息到【入账记录】
} for (String account : accountRecordListMap.keySet()) {
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> saveList = accountRecordListMap.get(account);
// 封装数据
if (!saveList.isEmpty()) {
String bankName = accountInfoMap.get(account);
log.info("到账明细条数:" + saveList.size());
try {
for (MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1 entry : saveList) {
EKPEntryPushParam pushParam = new EKPEntryPushParam();
initValue(entry, pushParam, bankName, account);
String body = sendToEkp(pushParam);
// 重试一次
if (StringUtils.isBlank(body)) {
sendToEkp(pushParam);
} }
}catch (Exception e) {
log.error("昨日新增到账明细推送失败",e);
} }
}catch (Exception e) {
log.error("到账明细数据推送失败",e);
} }
} }
} }
return R.ok(); return R.ok();
} }
......
...@@ -119,11 +119,13 @@ ...@@ -119,11 +119,13 @@
<!--查询社保明细信息--> <!--查询社保明细信息-->
<select id="getAllserioNo" resultType="java.lang.String"> <select id="getAllserioNo" resultType="java.lang.String">
SELECT SELECT fd_3b573843db30ce from ekp_79c234bf64d412294f23
fd_3b573843db30ce where DATE_FORMAT(fd_3aa4531d3b86e0, '%Y-%m-%d') between DATE_SUB(curdate(), INTERVAL 1 day) and DATE_ADD(now(), INTERVAL 1 day)
from ekp_79c234bf64d412294f23
where fd_3b62f3470beb30 = '1302010109024596014'
and DATE_FORMAT(fd_3aa4531d3b86e0, '%Y-%m-%d') between DATE_SUB(curdate(), INTERVAL 1 day) and DATE_ADD(now(), INTERVAL 1 day)
and fd_3b57f8de9df354 = '是' and fd_3b57f8de9df354 = '是'
</select> </select>
<!--查询付款账户信息-->
<select id="getAccountList" resultType="Map">
select fd_3b14a2430ac214 as bank_name,fd_3b14a24376d86a as bank_no from ekp_fe8247b4cbb4b27881dd where fd_3b14a24b9adb52='启用' and fd_3b56747b811872='是';
</select>
</mapper> </mapper>
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