Commit d513415f authored by hezhuozhi's avatar hezhuozhi

Merge branch 'developer_bw' of…

Merge branch 'developer_bw' of http://39.100.92.250:5000/moa/jxdj_zx/amos-boot-zx-biz into developer_bw # Conflicts: # amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/Enum/UploadStatusEnum.java
parents 3a5197fe 47531333
...@@ -14,5 +14,5 @@ import java.util.List; ...@@ -14,5 +14,5 @@ import java.util.List;
*/ */
public interface IcbcWithholdMapper extends BaseMapper<IcbcWithhold> { public interface IcbcWithholdMapper extends BaseMapper<IcbcWithhold> {
public List<IcbcWithholdDto> queryForIcbcWithholdPage( String uploader, String uploadStartTime, String uploadEndTime, String uploadStatus, String confirmator, String confirmationStartTime, String confirmationEndTime,String desc); public List<IcbcWithholdDto> queryForIcbcWithholdPage( String uploader, String uploadStartTime, String uploadEndTime, String uploadStatus, String confirmator, String confirmationStartTime, String confirmationEndTime,String desc, String withholdStatus);
} }
...@@ -922,9 +922,11 @@ public class SFTPUtil { ...@@ -922,9 +922,11 @@ public class SFTPUtil {
if (!fileName.equals(".") && !fileName.equals("..")) { // 排除当前和上级目录条目 if (!fileName.equals(".") && !fileName.equals("..")) { // 排除当前和上级目录条目
String fileContentAsString = getFileContentAsString(remotePath, fileName); String fileContentAsString = getFileContentAsString(remotePath, fileName);
List<String> contents = Arrays.asList(fileContentAsString.split("\r\n")); List<String> contents = Arrays.asList(fileContentAsString.split("\r\n"));
for (String content : contents) { if (null != contents && contents.size() > 0) {
ResultLinkField resultLinkField = contentHandle(content); for (String content : contents) {
allJsonData.add(resultLinkField); ResultLinkField resultLinkField = contentHandle(content);
allJsonData.add(resultLinkField);
}
} }
} }
} }
......
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
<select id="exportTotal" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordExportDTO"> <select id="exportTotal" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.HygfIcbcRecordExportDTO">
SELECT SELECT
MAX(ph.owners_name) AS custName, MAX(ph.owners_name) AS custName,
MAX(ph.telephone) AS idCard, MAX(ph.telephone) AS phone,
MAX(ph.id_card) AS idCard, MAX(ph.id_card) AS idCard,
MAX(ph.regional_companies_name) AS regionalCompaniesName, MAX(ph.regional_companies_name) AS regionalCompaniesName,
MAX(re.medium_id) AS mediumId, MAX(re.medium_id) AS mediumId,
......
...@@ -19,11 +19,14 @@ ...@@ -19,11 +19,14 @@
<if test="uploadStatus != null and uploadStatus != ''"> <if test="uploadStatus != null and uploadStatus != ''">
and upload_status = #{uploadStatus} and upload_status = #{uploadStatus}
</if> </if>
<if test="withholdStatus != null and withholdStatus != ''">
and withhold_status = #{withholdStatus}
</if>
<if test="confirmator != null and confirmator != ''"> <if test="confirmator != null and confirmator != ''">
and confirmator like concat('%',#{confirmator},'%') and confirmator like concat('%',#{confirmator},'%')
</if> </if>
<if test="desc != null and desc != ''"> <if test="desc != null and desc != ''">
and uploader like concat('%',#{desc},'%') and content like concat('%',#{desc},'%')
</if> </if>
<if test="confirmationStartTime != null and confirmationStartTime != ''"> <if test="confirmationStartTime != null and confirmationStartTime != ''">
and confirmation_time > #{confirmationStartTime} and confirmation_time > #{confirmationStartTime}
......
...@@ -48,7 +48,7 @@ public class IcbcWithholdController extends BaseController { ...@@ -48,7 +48,7 @@ public class IcbcWithholdController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增 聚富通代扣信息表", notes = "新增 聚富通代扣信息表") @ApiOperation(httpMethod = "POST", value = "新增 聚富通代扣信息表", notes = "新增 聚富通代扣信息表")
public ResponseModel save(@RequestBody IcbcWithhold model) { public ResponseModel save(@RequestBody IcbcWithhold model) throws Exception {
icbcWithholdServiceImpl.saveRecord(model); icbcWithholdServiceImpl.saveRecord(model);
return CommonResponseNewUtil.success(); return CommonResponseNewUtil.success();
} }
...@@ -115,9 +115,10 @@ public class IcbcWithholdController extends BaseController { ...@@ -115,9 +115,10 @@ public class IcbcWithholdController extends BaseController {
@RequestParam(value = "confirmator",required = false) String confirmator, @RequestParam(value = "confirmator",required = false) String confirmator,
@RequestParam(value = "confirmationStartTime",required = false) String confirmationStartTime, @RequestParam(value = "confirmationStartTime",required = false) String confirmationStartTime,
@RequestParam(value = "confirmationEndTime",required = false) String confirmationEndTime, @RequestParam(value = "confirmationEndTime",required = false) String confirmationEndTime,
@RequestParam(value = "withholdStatus",required = false) String withholdStatus,
@RequestParam(value = "desc",required = false) String desc) { @RequestParam(value = "desc",required = false) String desc) {
return ResponseHelper.buildResponse(icbcWithholdServiceImpl.queryForIcbcWithholdPage(current,size,uploader,uploadStartTime,uploadEndTime,uploadStatus,confirmator,confirmationStartTime,confirmationEndTime,desc)); return ResponseHelper.buildResponse(icbcWithholdServiceImpl.queryForIcbcWithholdPage(current,size,uploader,uploadStartTime,uploadEndTime,uploadStatus,confirmator,confirmationStartTime,confirmationEndTime,desc,withholdStatus));
} /** } /**
* 列表分页查询 * 列表分页查询
* *
......
...@@ -58,6 +58,7 @@ import java.nio.file.Paths; ...@@ -58,6 +58,7 @@ import java.nio.file.Paths;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
...@@ -90,7 +91,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -90,7 +91,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
@Value("${icbc.Withhold.sftpUserName}") @Value("${icbc.Withhold.sftpUserName}")
public String sftpUserName; public String sftpUserName;
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd"); private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
private static int sequence = 0; // 当天的序列号 private static final AtomicInteger sequence = new AtomicInteger(0);
private static String uploadPath = "/JftFeeWithhold/upload"; // 上传地址 private static String uploadPath = "/JftFeeWithhold/upload"; // 上传地址
private static String downLoadPath = "/JftFeeWithhold/download"; // 下载地址 private static String downLoadPath = "/JftFeeWithhold/download"; // 下载地址
private static String file =""; private static String file ="";
...@@ -126,7 +127,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -126,7 +127,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
int billNo = 0; int billNo = 0;
int totalAmt = 0; int totalAmt = 0;
//生成批次号 若已从保存生成取原有批次号 //生成批次号 若已从保存生成取原有批次号
String batchNo = StringUtil.isEmpty(model.getBatchNo())?generateBatchNumber():model.getBatchNo(); String batchNo = StringUtil.isEmpty(model.getBatchNo())?checkBatcnNumber():model.getBatchNo();
String loopField = ""; String loopField = "";
//判断接口调用来源 不为空时说明是先保存后在列表按钮上生成 可直取冗余数据 //判断接口调用来源 不为空时说明是先保存后在列表按钮上生成 可直取冗余数据
if (StringUtils.isNotEmpty(model.getIcbcRecordInfos())){ if (StringUtils.isNotEmpty(model.getIcbcRecordInfos())){
...@@ -213,8 +214,8 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -213,8 +214,8 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
* 生成文件 * 生成文件
* *
*/ */
public void saveRecord(IcbcWithhold model) { public void saveRecord(IcbcWithhold model) throws Exception {
String batch = generateBatchNumber(); String batch = checkBatcnNumber();
model.getRecordDTOS().forEach(e->{ model.getRecordDTOS().forEach(e->{
e.setSequenceNbr(null); e.setSequenceNbr(null);
e.setBatchNo(batch); e.setBatchNo(batch);
...@@ -262,21 +263,72 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -262,21 +263,72 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
} }
public synchronized String generateBatchNumber() { // public synchronized String generateBatchNumber() {
// LocalDate currentDate = LocalDate.now();
// // 如果是新的一天,重置序列号
// if (!currentDate.equals(lastDate)) {
// sequence = 0;
// lastDate = currentDate;
// }
// // 生成8位日期
// String datePart = currentDate.format(DATE_FORMATTER);
// // 生成5位序列号
// String sequencePart = String.format("%05d", sequence++);
// // 拼接成完整的批次号
// return checkBatcnNumber(sequencePart,datePart,partnerIdentification);
// }
public String checkBatcnNumber()throws Exception{
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
// 如果是新的一天,重置序列号 String datePart = currentDate.format(DATE_FORMATTER);
if (!currentDate.equals(lastDate)) { if (!currentDate.equals(lastDate)) {
sequence = 0; sequence.set(0); // 重置序列号从0开始
lastDate = currentDate; lastDate = currentDate;
} }
// 生成8位日期 // 定义序列号的最大值,这里设为五位数的最大值99999
String datePart = currentDate.format(DATE_FORMATTER); int maxSequence = 99999;
// 生成5位序列号
String sequencePart = String.format("%05d", sequence++); // 设置最大尝试次数,防止无限循环
// 拼接成完整的批次号 int maxAttempts = 10000;
return datePart + partnerIdentification + sequencePart;
// 构建批次号前缀,由日期部分和合作伙伴识别码组成
String batchNoPrefix = datePart + partnerIdentification;
// 使用 AtomicInteger 来管理序列号,保证线程安全
AtomicInteger attemptCounter = new AtomicInteger(0);
// 尝试生成唯一批次号,最多进行 maxAttempts 次尝试
while (attemptCounter.incrementAndGet() <= maxAttempts) {
// 获取当前序列号,并原子性地递增计数器
int currentSequence = sequence.getAndIncrement();
// 如果序列号超过了设定的最大值,则重置计数器
if (currentSequence > maxSequence) {
sequence.set(0); // 重置序列号从0开始
currentSequence = sequence.getAndIncrement(); // 再次获取新的序列号
}
// 格式化序列号为固定长度的字符串,不足的部分用零填充
String sequencePart = String.format("%05d", currentSequence);
// 组合完整的批次号
String batchNo = batchNoPrefix + sequencePart;
// 查询数据库以确认该批次号是否已经被占用
LambdaQueryWrapper<IcbcWithhold> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcbcWithhold::getBatchNo, batchNo);
List<IcbcWithhold> existingRecord = this.getBaseMapper().selectList(wrapper);
// 如果没有找到重复记录,则说明此批次号可用,直接返回
if (CollectionUtil.isEmpty(existingRecord)) {
return batchNo; // 当找到唯一批次号时返回
}
}
// 如果经过多次尝试后仍然未能生成唯一的批次号,则抛出异常
throw new Exception(" 如果经过多次尝试后仍然未能生成唯一的批次号");
} }
public static void writeStringToFile(String content, String filename) throws IOException { public static void writeStringToFile(String content, String filename) throws IOException {
createDirectoryIfNotExists(filename); createDirectoryIfNotExists(filename);
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "GBK"))) { try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "GBK"))) {
...@@ -424,17 +476,35 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -424,17 +476,35 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
if (sftp.isExist(downLoadPath)) { if (sftp.isExist(downLoadPath)) {
//获取回盘文件扣款状态 //获取回盘文件扣款状态
List<ResultLinkField> files = sftp.getAllResultFilesContentAsJson(downLoadPath); List<ResultLinkField> files = sftp.getAllResultFilesContentAsJson(downLoadPath);
for (ResultLinkField resultLinkField : files) { if (CollectionUtil.isNotEmpty(files)){
LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>(); Map<String, List<ResultLinkField>> collect = files.stream().collect(Collectors.groupingBy(ResultLinkField::getBatchNo));
if (resultLinkField.getStatus().equals("1")) { for (String batchNo : collect.keySet()) {
updateWrapper.set(IcbcWithhold::getPaymentErrorDesc,resultLinkField.getErrMsg()); LambdaQueryWrapper<IcbcWithhold> queryWrapper = new LambdaQueryWrapper<>();
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.失败.getName()); queryWrapper.eq(IcbcWithhold::getBatchNo,batchNo);
}else { IcbcWithhold model = this.getBaseMapper().selectOne(queryWrapper);
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.成功.getName()); List<IcbcWithholdRecord> icbcWithholdRecords = JSONArray.parseArray(model.getIcbcRecordInfos(), IcbcWithholdRecord.class);
Boolean isSuccess = true;
List<ResultLinkField> resultLinkFields = collect.get(batchNo);
//若失败 组装失败农户姓名及原因
String err ="";
for (ResultLinkField resultLinkField : resultLinkFields) {
if (!resultLinkField.getErrMsg().contains("成功")){
err = err+ icbcWithholdRecords.get(Integer.valueOf(resultLinkField.getBillNo())).getCustName() + ":" + resultLinkField.getErrMsg() + ";";
isSuccess = false;
}
}
LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>();
if (!isSuccess) {
updateWrapper.set(IcbcWithhold::getPaymentErrorDesc,err);
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.失败.getName());
}else {
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.成功.getName());
}
updateWrapper.eq(IcbcWithhold::getBatchNo,batchNo);
this.getBaseMapper().update(null,updateWrapper);
} }
updateWrapper.eq(IcbcWithhold::getBatchNo,resultLinkField.getBatchNo());
this.getBaseMapper().update(null,updateWrapper);
} }
} }
} }
...@@ -498,10 +568,10 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -498,10 +568,10 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
} }
public Page<IcbcWithholdDto> queryForIcbcWithholdPage(int current, int size, String uploader, String uploadStartTime, String uploadEndTime, String uploadStatus, String confirmator, String confirmationStartTime, String confirmationEndTime,String desc) { public Page<IcbcWithholdDto> queryForIcbcWithholdPage(int current, int size, String uploader, String uploadStartTime, String uploadEndTime, String uploadStatus, String confirmator, String confirmationStartTime, String confirmationEndTime,String desc,String withholdStatus) {
Page<IcbcWithholdDto> page = new Page<>(); Page<IcbcWithholdDto> page = new Page<>();
PageHelper.startPage(current,size); PageHelper.startPage(current,size);
List<IcbcWithholdDto> icbcWithholdDtos = this.getBaseMapper().queryForIcbcWithholdPage(uploader,uploadStartTime,uploadEndTime,uploadStatus,confirmator,confirmationStartTime,confirmationEndTime,desc); List<IcbcWithholdDto> icbcWithholdDtos = this.getBaseMapper().queryForIcbcWithholdPage(uploader,uploadStartTime,uploadEndTime,uploadStatus,confirmator,confirmationStartTime,confirmationEndTime,desc,withholdStatus);
PageInfo<IcbcWithholdDto> pageInfo = new PageInfo<>(icbcWithholdDtos); PageInfo<IcbcWithholdDto> pageInfo = new PageInfo<>(icbcWithholdDtos);
page.setSize(pageInfo.getSize()); page.setSize(pageInfo.getSize());
...@@ -547,7 +617,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -547,7 +617,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
response = client.execute(request, System.currentTimeMillis() + ""); response = client.execute(request, System.currentTimeMillis() + "");
if (response.isSuccess()) { if (response.isSuccess()) {
List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> tradeList = response.getTradeList(); List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> tradeList = response.getTradeList();
List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> filterList = tradeList.stream().filter(e -> batchNos.contains(e)).collect(Collectors.toList()); List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> filterList = tradeList.stream().filter(e -> batchNos.contains(e.getBatchNo())).collect(Collectors.toList());
filterList.forEach(e->{ filterList.forEach(e->{
LambdaUpdateWrapper<IcbcWithholdRecord> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IcbcWithholdRecord> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcbcWithholdRecord::getBatchNo,e.getBatchNo()); updateWrapper.eq(IcbcWithholdRecord::getBatchNo,e.getBatchNo());
......
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