Commit 882ed6be by 林冲

Merge branch 'v5.8.1' into 'master'

上线合并

See merge request !4
2 parents 82c3abea 10855914
......@@ -10,7 +10,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "QueryNbCbAccDetailReceiptJob", cron = "0 0 18 * * ?", description = "定时查询宁波银行交易明细和回单定时任务", overwrite = false)
@ElasticJobConf(name = "QueryNbCbAccDetailReceiptJob", cron = "0 0 10,12,14,16,18 * * ?", description = "定时查询宁波银行交易明细和回单定时任务", overwrite = false)
public class QueryNbCbAccDetailReceiptJob implements SimpleJob {
@Autowired
......
......@@ -10,7 +10,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "QueryNbCbAccDetailTodayJob", cron = "0 5 18 * * ?", description = "定时查询宁波银行交易明细和回单定时任务", overwrite = false)
@ElasticJobConf(name = "QueryNbCbAccDetailTodayJob", cron = "0 10 10,12,14,16,18 * * ?", description = "定时查询宁波银行交易明细和回单定时任务", overwrite = false)
public class QueryNbCbAccDetailTodayJob implements SimpleJob {
@Autowired
......
......@@ -10,7 +10,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "QueryNbCbYJAccDetailReceiptJob", cron = "0 0 18 * * ?", description = "优加-定时查询宁波银行交易明细和回单定时任务", overwrite = false)
@ElasticJobConf(name = "QueryNbCbYJAccDetailReceiptJob", cron = "0 0 10,12,14,16,18 * * ?", description = "优加-定时查询宁波银行交易明细和回单定时任务", overwrite = false)
public class QueryNbCbYJAccDetailReceiptJob implements SimpleJob {
@Autowired
......
......@@ -10,7 +10,7 @@ import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "QueryNbCbYJAccDetailTodayJob", cron = "0 5 18 * * ?", description = "优加-定时查询宁波银行交易明细和回单定时任务", overwrite = false)
@ElasticJobConf(name = "QueryNbCbYJAccDetailTodayJob", cron = "0 10 10,12,14,16,18 * * ?", description = "优加-定时查询宁波银行交易明细和回单定时任务", overwrite = false)
public class QueryNbCbYJAccDetailTodayJob implements SimpleJob {
@Autowired
......
......@@ -54,6 +54,9 @@ public class ThirdPartyNiBoBatchStrategy implements ThirdPartyStrategy{
@Override
public Object buildRequestParams(ApprovalRecords approvalRecord,String custId, Integer custType) {
int remarksLengthMax = 35;
String glskTemplateId = environment.getProperty("vcp.car.glsk.templateId");
String yjzhTemplateId = environment.getProperty("vcp.car.yjzh.templateId");
NbCbBatchTransferParamDTO batchTransferParam= new NbCbBatchTransferParamDTO();
batchTransferParam.setPayName(approvalRecord.getPayerEntity());
// 转化收款账号
......@@ -87,6 +90,32 @@ public class ThirdPartyNiBoBatchStrategy implements ThirdPartyStrategy{
purpose = bankSummary;
}
}
//如果是二手车模版
if (StringUtils.isNotBlank(glskTemplateId) || StringUtils.isNotBlank(yjzhTemplateId)) {
if (StringUtils.isNotBlank(approvalRecord.getTemplateId()) &&
(Objects.equals(approvalRecord.getTemplateId(), glskTemplateId) || Objects.equals(approvalRecord.getTemplateId(), yjzhTemplateId))) {
log.info("custId:{},bankSummary:{}",custId,bankSummary);
if (StringUtils.isNotBlank(bankSummary)) {
if (bankSummary.startsWith("其他(") && bankSummary.endsWith(")")) {
String remarks = approvalRecord.getRemarks();
log.info("custId:{},bankSummary:{},remarks:{}",custId,bankSummary,remarks);
if (StringUtils.isNotBlank(remarks)) {
remarks = remarks.trim().replaceAll("\n", " ").replaceAll("\r\n", " ");
purpose = remarks;
int length = purpose.length();
if (length > remarksLengthMax) {
purpose = purpose.substring(0, remarksLengthMax);
}
} else {
purpose = "采购款";
}
} else {
purpose = bankSummary;
}
log.info("custId:{},bankSummary:{},purpose:{}",custId,bankSummary,purpose);
}
}
}
batchTransferParam.setSpNo(approvalRecord.getSpNo());
batchTransferParam.setCustType(custType);
batchTransferParam.setCustId(custId);
......@@ -113,6 +142,7 @@ public class ThirdPartyNiBoBatchStrategy implements ThirdPartyStrategy{
batchTransferParam.setDjSerialNo(approvalRecord.getMerchantSpNo());
batchTransferParam.setBusinessCode("nis_batch_transfer");
batchTransferParam.setPaymentMethod(approvalRecord.getPaymentMethod());
log.info("custId:{},bankSummary:{},batchTransferParam:{}",custId,bankSummary,batchTransferParam);
return batchTransferParam;
}
......
......@@ -3,7 +3,7 @@ package cn.com.glsx.dj.financial.service.nb;
import cn.com.glsx.dj.financial.constants.CommonConstants;
import cn.com.glsx.dj.financial.dto.*;
import cn.com.glsx.dj.financial.enums.*;
import cn.com.glsx.dj.financial.mapper.*;
import cn.com.glsx.dj.financial.mapper.NbCbBatchTransferMapper;
import cn.com.glsx.dj.financial.model.*;
import cn.com.glsx.dj.financial.model.nbcb.BatchTransferResult;
import cn.com.glsx.dj.financial.model.qw.CallbackData;
......@@ -44,9 +44,10 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -584,7 +585,7 @@ public class NbCbBatchTransferService {
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = RpcServiceException.class)
public void transferSchedule(String jobParameter, String updatedBy,Integer custType) throws Exception {
log.info("调用宁波银行批量转账接口任务,jobParameter:{}", jobParameter);
log.info("调用宁波银行批量转账接口任务,jobParameter:{}", JSON.toJSONString(jobParameter));
List<Long> idList = Lists.newArrayList();
if (StringUtils.isNotBlank(jobParameter)) {
idList = Arrays.stream(jobParameter.split(",")).map(Long::parseLong).collect(Collectors.toList());
......
......@@ -297,6 +297,8 @@ public class OaApplyBatchTransferService {
applyInfo.setValue(record.getInvoiceRemark());
} else if (Objects.equals(propertyInfo.getTitle(), "附件")) {
applyInfo.setValue(record.getAttachmentUrl());
}else if (Objects.equals(propertyInfo.getTitle(), "备注说明")) {
applyInfo.setValue(record.getRemark());
}
resultList.add(applyInfo);
}
......
package cn.com.glsx.dj.financial.util;
import cn.com.glsx.dj.financial.enums.NbCbCustEnum;
import cn.com.glsx.dj.financial.enums.TransferErrorEnum;
import cn.com.glsx.dj.financial.mapper.NbCbCustInfoMapper;
import cn.com.glsx.dj.financial.model.NbCbCustInfo;
......@@ -33,25 +32,25 @@ public class NbCbCommonUtil {
public JSONObject getNbCbResponseData(String productId, String serviceID, String jsonString) throws Exception {
log.info("查询宁波银行接口 productId:{}, serviceID:{}, parma:{}", productId, serviceID, jsonString);
log.info("getNbCbResponseData查询宁波银行接口productId:{}, serviceID:{}, parma:{}", productId, serviceID, jsonString);
String appKey = getAppKey(jsonString);
String res = OpenSDK.send(appKey,productId, serviceID, jsonString);
log.info("查询宁波银行接口 response" + res);
log.info("getNbCbResponseData查询宁波银行接口productId:{}, serviceID:{}, parma:{},response:{}", productId, serviceID, jsonString, res);
JSONObject resonseJSON = JSONObject.parseObject(res);
JSONObject jsonData = resonseJSON.getJSONObject("Data");
String retCode= (String) jsonData.get("retCode");
if (retCode.equals("0000")) {
return jsonData;
}
log.warn("查询宁波银行接口状态码异常 retCode" + retCode);
log.warn("getNbCbResponseData查询宁波银行接口状态码异常productId:{}, serviceID:{}, parma:{},retCode:{}", productId, serviceID, jsonString,retCode);
return null;
}
public JSONObject getNbCbResponseData2(String productId, String serviceID, String jsonString) throws Exception {
log.info("查询宁波银行接口 productId:{}, serviceID:{}, parma:{}", productId, serviceID, jsonString);
log.info("getNbCbResponseData2查询宁波银行接口productId:{}, serviceID:{}, parma:{}", productId, serviceID, jsonString);
String appKey = getAppKey(jsonString);
String res = OpenSDK.send(appKey,productId, serviceID, jsonString);
log.info("查询宁波银行接口 response" + res);
log.info("getNbCbResponseData2查询宁波银行接口productId:{}, serviceID:{}, parma:{}, response:{}", productId, serviceID, jsonString , res);
JSONObject resonseJSON = JSONObject.parseObject(res);
return resonseJSON.getJSONObject("Data");
}
......
......@@ -111,7 +111,7 @@
inner join nb_cb_transfer ct on ct.dj_serial_no = ar.merchant_sp_no
inner join nb_cb_acc_detail d on d.serial_no = ct.serial_no
inner join nb_cb_receipt r on r.sub_serial_no = d.sub_serial_no and r.match_code = d.match_code
<where>and FIND_IN_SET(#{qwUserId}, ar.sp_user)
<where> and (FIND_IN_SET(#{qwUserId}, ar.sp_user) or ar.applyer_userid=#{qwUserId})
and ct.transfer_source = 0
and r.deleted_flag = 'N'
and d.deleted_flag = 'N'
......@@ -153,7 +153,7 @@
inner join nb_cb_acc_detail d on d.serial_no = cbtd.acc_detail_serial_no and d.deleted_flag = 'N' and d.cd_sign = 1
inner join nb_cb_receipt r on r.sub_serial_no = d.sub_serial_no and r.match_code = d. match_code and r.deleted_flag = 'N' and r.cd_sign = '2'
<where>
and FIND_IN_SET(#{qwUserId}, ar.sp_user)
and (FIND_IN_SET(#{qwUserId}, ar.sp_user) or ar.applyer_userid=#{qwUserId})
and cbt.deleted_flag = 'N'
<if test="keyword != null and keyword != ''">
and (
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 3)

    1. 逻辑漏洞:字符串换行符替换逻辑存在缺陷

    • 问题描述:在 ThirdPartyNiBoBatchStrategy.java 中,处理备注信息的代码为 remarks.trim().replaceAll("\n", " ").replaceAll("\r\n", " ")。由于 String.replaceAll 按顺序执行,先将 \n 替换为空格后,原有的 \r\n 会变成 \r(回车符+空格),导致后续的 replaceAll("\r\n", " ") 永远无法匹配,最终字符串中会残留无用的 \r 字符。
    • 影响分析:若银行接口对传入的特殊控制字符校验严格,残留的 \r 可能导致报文解析报错或转账失败。
    • 优化建议:使用正则表达式一次性替换,或者先替换 \r\n 再替换 \n。 java // 建议修改为使用正则一次性匹配所有换行符(包含 \r\n, \n, \r) remarks = remarks.trim().replaceAll("\\r?\\n|\\r", " ");

    2. 可维护性:代码嵌套层级过深(箭头型代码)

    • 问题描述:在 ThirdPartyNiBoBatchStrategy.java 的 buildRequestParams 方法中,新增的二手车模板逻辑使用了多达 6 层的 if 嵌套。
    • 影响分析:严重降低了代码的可读性,增加了圈复杂度(Cyclomatic Complexity),后续维护或增加新条件时极易出错。
    • 优化建议:使用卫语句(Guard Clauses)提前返回或跳过,减少嵌套层级。 java // 优化示例: if (StringUtils.isBlank(glskTemplateId) && StringUtils.isBlank(yjzhTemplateId)) { return; // 或继续后续逻辑 } if (!Objects.equals(approvalRecord.getTemplateId(), glskTemplateId) && !Objects.equals(approvalRecord.getTemplateId(), yjzhTemplateId)) { return; } if (StringUtils.isBlank(bankSummary) || !bankSummary.startsWith("其他(") || !bankSummary.endsWith(")")) { purpose = bankSummary; return; } // 处理 remarks 逻辑...

    3. 最佳实践:不必要的 JSON 序列化

    • 问题描述:在 NbCbBatchTransferService.java 中,日志打印修改为 log.info("..., jobParameter:{}", JSON.toJSONString(jobParameter))。根据方法签名,jobParameter 本身就是一个 String 类型的变量。
    • 影响分析:对 String 进行 JSON 序列化是多余的操作,不仅会增加无意义的性能开销,还会导致打印出的日志被多余的双引号包裹(例如原字符串为 1,2,3,打印出来会变成 "1,2,3"),降低日志直观性。
    • 优化建议:直接打印字符串变量即可。 java log.info("调用宁波银行批量转账接口任务,jobParameter:{}", jobParameter);

    二、评分明细

    • 功能实现的正确性与健壮性(36/40分)

      • 扣分理由:备注字符串的换行符替换逻辑存在顺序漏洞,可能导致 \r 字符残留。
      • 加分项/规则检查:MyBatis XML 中未引入子查询,符合强制规定;未涉及 Dubbo 接口参数变更。定时任务频率调整及普通字段映射逻辑正确。
    • 安全性与潜在风险(30/30分)

      • 评分理由:本次变动主要为业务逻辑和定时任务频率的调整,MyBatis 的 Mapper 文件正确使用了 #{} 参数化查询,未引入 SQL 注入、越权等安全风险。
    • 最佳实践与可维护性(14/20分)

      • 扣分理由:ThirdPartyNiBoBatchStrategy 中引入了深层嵌套(If-Arrow Anti-pattern),代码结构极不优雅;对 String 对象使用了多余的 JSON 序列化工具。
    • 性能与资源利用(3/5分)

      • 扣分理由:在 approvalRecordsMapper.xml 中,查询条件使用了 FIND_IN_SET(#{qwUserId}, ar.sp_user) or ar.applyer_userid=#{qwUserId}。FIND_IN_SET 本身会导致全表扫描/索引失效,结合 OR 条件会进一步恶化查询性能。考虑到这可能是历史表结构设计的妥协,酌情扣 2 分。
    • 提交信息质量(4/5分)

      • 扣分理由:部分提交信息非常规范(如 wanglq 的 fix(approvalRecordsMapper)... 采用了 Conventional Commits 规范),但存在多条完全重复的无意义提交(如 cuiyf 连续提交了 3 次 "修改发起财资封装二手车模版参数逻辑"),建议在 push 前进行 git rebase -i 合并 commit。

    总分:87分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!