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("开始推当日新增网银到账明细条数");
//从9月12号开始执行定时任务 String tranDate = DateUtil.getThisDay();
if (DateUtil.getCurrentDateString().compareTo("2024-09-12") < 0 ) { // todo 测试时改为查10天内的,上线改为查当天内的
return R.ok(); String beginDate = DateUtil.addDay(-10).replace("-","");
String endDate = tranDate;
return getIcbcTransactionFlowCommon(tranDate,beginDate,endDate);
} }
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 = @Override
new MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1(); public R getIcbcTransactionFlowYesterdayInner() throws IcbcApiException {
MybankEnterpriseTradeQhisdRequestV1 request = new MybankEnterpriseTradeQhisdRequestV1(); log.info("开始推昨日新增网银到账明细条数");
String tranDate = DateUtil.addDay(-1).replace("-","");
String beginDate = tranDate;
String endDate = tranDate;
return getIcbcTransactionFlowCommon(tranDate,beginDate,endDate);
}
/**
* 新增网银到账明细条数公共处理
*
* @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());
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());
// 查需要获取流水的账号
List<Map<String,String>> accountList = baseMapper.getAccountList();
if (accountList.isEmpty()) {
return R.ok();
}
// 查询当天的所有入账记录数据
List<String> serioList = baseMapper.getAllserioNo();
// 账号为key,账户名称作为value
Map<String,String> accountInfoMap = new HashMap<>();
// 账号为key,账号下的流水作为value
Map<String,List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1>> accountRecordListMap = new HashMap<>();
// 定义请求工行需要的传参对象
MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1 bizContent;
MybankEnterpriseTradeQhisdRequestV1 request;
for(Map<String,String> accountInfo: accountList) {
bizContent = new MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1();
request = new MybankEnterpriseTradeQhisdRequestV1();
bizContent.setTranDate(tranDate);
bizContent.setTranTime(formattedTime); bizContent.setTranTime(formattedTime);
bizContent.setTransCode("QHISD"); bizContent.setTransCode("QHISD");
bizContent.setLanguage("zh_CN"); bizContent.setLanguage("zh_CN");
String fSeqNo = "AHWX" + System.currentTimeMillis(); String fSeqNo = "AHWX" + System.currentTimeMillis();
bizContent.setfSeqno(fSeqNo); bizContent.setfSeqno(fSeqNo);
bizContent.setAccountNo("1302015209250019444"); bizContent.setAccountNo(accountInfo.get("bank_no"));
bizContent.setBeginDate(DateUtil.addDay(-10).replace("-","")); bizContent.setBeginDate(beginDate);
bizContent.setEndDate(DateUtil.getThisDay()); bizContent.setEndDate(endDate);
bizContent.setDrcrf("2"); bizContent.setDrcrf("2");
request.setServiceUrl(icbcConfigProperties.getServerUrl()); request.setServiceUrl(icbcConfigProperties.getServerUrl());
request.setBizContent(bizContent); request.setBizContent(bizContent);
MybankEnterpriseTradeQhisdResponseV1 response = client.execute(request); MybankEnterpriseTradeQhisdResponseV1 response = client.execute(request);
if(response.isSuccess()) { if(response.isSuccess()) {
//查询当天的所有入账记录数据 // 获取所有账号的流水,每个账号存一个流水
List<String> serioList = baseMapper.getAllserioNo(); accountRecordListMap.put(accountInfo.get("bank_no"),response.getRd());
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> list = response.getRd(); if(accountInfo.get("bank_no").equals(response.getAccountNo())){
String bankName = response.getAccountName(); accountInfoMap.put(accountInfo.get("bank_no"),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);
} }
} }
// 重新过滤已存入【入账记录】的流水信息
for (String account : accountRecordListMap.keySet()) {
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> flowRecordList = accountRecordListMap.get(account);
// 获取成功后根据流水号去重和根据借贷标志02筛选出所有数据
if (!flowRecordList.isEmpty()) {
List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> insertList =
flowRecordList.stream().filter(e-> e.getDrcrf().equals("2") && !serioList.contains(e.getOnlySequence())).collect(Collectors.toList());
if(!insertList.isEmpty()){
// 还有需要存的流水,重新存入账号流水Map里
accountRecordListMap.put(account, insertList);
} else {
// 没有需要存的流水,账号流水Map重置值为空列表
accountRecordListMap.put(account, new ArrayList<>());
} }
} }
return R.ok();
} }
public R getIcbcTransactionFlowYesterdayInner() throws IcbcApiException { // 存入过滤后的流水信息到【入账记录】
for (String account : accountRecordListMap.keySet()) {
//从9月13号开始执行定时任务 List<MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1> saveList = accountRecordListMap.get(account);
if (DateUtil.getCurrentDateString().compareTo("2024-09-13") <0 ) { // 封装数据
return R.ok(); if (!saveList.isEmpty()) {
} String bankName = accountInfoMap.get(account);
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 = log.info("到账明细条数:" + saveList.size());
new MybankEnterpriseTradeQhisdRequestV1.MybankEnterpriseTradeQhisdRequestBizV1();
MybankEnterpriseTradeQhisdRequestV1 request = new MybankEnterpriseTradeQhisdRequestV1();
// 获取当前时间
LocalTime currentTime = LocalTime.now();
// 使用DateTimeFormatter格式化
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HHmmssSSS");
String formattedTime = currentTime.format(formatter);
bizContent.setTranDate(DateUtil.addDay(-1).replace("-",""));
bizContent.setTranTime(formattedTime);
bizContent.setTransCode("QHISD");
bizContent.setLanguage("zh_CN");
String fSeqNo = "AHWX" + System.currentTimeMillis();
bizContent.setfSeqno(fSeqNo);
bizContent.setAccountNo("1302010109024596014");
bizContent.setBeginDate(DateUtil.addDay(-1).replace("-",""));
bizContent.setEndDate(DateUtil.addDay(-1).replace("-",""));
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 { try {
for (MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1 entry : insertList) { for (MybankEnterpriseTradeQhisdResponseV1.MybankEnterpriseTradeQhisdResponseRdV1 entry : saveList) {
EKPEntryPushParam pushParam = new EKPEntryPushParam(); EKPEntryPushParam pushParam = new EKPEntryPushParam();
initValue(entry, pushParam, bankName, bankNo); initValue(entry, pushParam, bankName, account);
String body = sendToEkp(pushParam); String body = sendToEkp(pushParam);
//重试 // 重试一次
if (StringUtils.isBlank(body)) { if (StringUtils.isBlank(body)) {
sendToEkp(pushParam); sendToEkp(pushParam);
} }
} }
}catch (Exception e) { }catch (Exception e) {
log.error("昨日新增到账明细推送失败",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