Commit 78f73f40 authored by chenzhao's avatar chenzhao

代扣优化项 问题处理

parent 079670c4
...@@ -8,12 +8,12 @@ import lombok.Getter; ...@@ -8,12 +8,12 @@ import lombok.Getter;
public enum UploadStatusEnum { public enum UploadStatusEnum {
未上传("未上传","未上传"), 未上传("未上传","未上传"),
已上传("上传中","上传中"), 已上传("上传中","上传中"),
未生成("未生成","未生成"), 未生成("未上传","未上传"),
成功("成功","成功"), 成功("成功","成功"),
失败("失败","失败"), 失败("失败","失败"),
代扣成功("成功","0"), 代扣成功("成功","0"),
代扣失败("失败","1"), 代扣失败("失败","1"),
代扣中("处理中","99"), 代扣中("","99"),
代扣处理中("代扣处理中","代扣处理中"); 代扣处理中("代扣处理中","代扣处理中");
private String name; private String name;
......
...@@ -133,7 +133,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -133,7 +133,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
*/ */
public void fileGeneration(IcbcWithhold model) throws Exception { public void fileGeneration(IcbcWithhold model) throws Exception {
model.setUploadStatus(UploadStatusEnum.上传.getName()); model.setUploadStatus(UploadStatusEnum.上传.getName());
int billNo = 0; int billNo = 0;
int totalAmt = 0; int totalAmt = 0;
//生成批次号 若已从保存生成取原有批次号 //生成批次号 若已从保存生成取原有批次号
...@@ -197,6 +197,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -197,6 +197,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
if (result != null) { if (result != null) {
for (String url : result.getResult().keySet()) { for (String url : result.getResult().keySet()) {
model.setUploadFile(url); model.setUploadFile(url);
sftpUploadAndUnzip(url,batchNo,model.getConfirmator());
} }
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -211,6 +212,9 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -211,6 +212,9 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
model.setIcbcRecordInfos(JSONObject.toJSONString(model.getRecordDTOS())); model.setIcbcRecordInfos(JSONObject.toJSONString(model.getRecordDTOS()));
model.setBatchNo(batchNo); model.setBatchNo(batchNo);
model.setUploadFileName(fileName); model.setUploadFileName(fileName);
model.setUploader(model.getConfirmator());
model.setUploadTime(new Date());
model.setProjectNumber(model.getRecordDTOS().get(0).getProjectId()); model.setProjectNumber(model.getRecordDTOS().get(0).getProjectId());
model.getRecordDTOS().stream().forEach(e->e.setSequenceNbr(null)); model.getRecordDTOS().stream().forEach(e->e.setSequenceNbr(null));
if (Objects.isNull(model.getSequenceNbr())){ if (Objects.isNull(model.getSequenceNbr())){
...@@ -389,7 +393,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -389,7 +393,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
public void downLoadicbcFile(String batchNo,Long sequenceNbr,HttpServletResponse response) throws Exception { public void downLoadicbcFile(String batchNo,Long sequenceNbr,HttpServletResponse response) throws Exception {
IcbcWithhold model = this.getBaseMapper().selectById(sequenceNbr); IcbcWithhold model = this.getBaseMapper().selectById(sequenceNbr);
if (StringUtils.isNotEmpty(model.getReceiptFile())){ if (StringUtils.isNotEmpty(model.getReceiptFile())){
this.downloadAndSaveZipFile(model.getReceiptFile(),batchNo,"回盘文件",response); this.downloadAndSaveZipFile(model.getReceiptFile(),batchNo,"批扣回单",response);
}else { }else {
String path = new ClassPathResource(file+"secretKey/登录-gxjrid_rsa").getPath(); String path = new ClassPathResource(file+"secretKey/登录-gxjrid_rsa").getPath();
...@@ -509,6 +513,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -509,6 +513,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
} }
@Scheduled(cron = "${withholdStatusCron}") @Scheduled(cron = "${withholdStatusCron}")
@Async
public void updateWithholdStatus() throws Exception { public void updateWithholdStatus() throws Exception {
//获取所有已上传但代扣状态为空的数据 //获取所有已上传但代扣状态为空的数据
LambdaQueryWrapper<IcbcWithhold> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IcbcWithhold> wrapper = new LambdaQueryWrapper<>();
...@@ -545,7 +550,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -545,7 +550,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
if (CollectionUtil.isNotEmpty(successFilesContentAsJson)){ if (CollectionUtil.isNotEmpty(successFilesContentAsJson)){
LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(IcbcWithhold::getBatchNo,successFilesContentAsJson); updateWrapper.in(IcbcWithhold::getBatchNo,successFilesContentAsJson);
updateWrapper.isNotNull(IcbcWithhold::getWithholdStatus); updateWrapper.isNull(IcbcWithhold::getWithholdStatus);
updateWrapper.set(IcbcWithhold::getUploadStatus,UploadStatusEnum.成功.getName()); updateWrapper.set(IcbcWithhold::getUploadStatus,UploadStatusEnum.成功.getName());
updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.代扣处理中.getName()); updateWrapper.set(IcbcWithhold::getWithholdStatus,UploadStatusEnum.代扣处理中.getName());
this.getBaseMapper().update(null,updateWrapper); this.getBaseMapper().update(null,updateWrapper);
...@@ -618,13 +623,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -618,13 +623,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
// sftp.uploadAndUnzip(uploadPath, "testupload.zip", dirPath.toString()+ "/" + fileUrl.substring(fileUrl.lastIndexOf('/') + 1)); // sftp.uploadAndUnzip(uploadPath, "testupload.zip", dirPath.toString()+ "/" + fileUrl.substring(fileUrl.lastIndexOf('/') + 1));
sftp.unzipAndUpload(uploadPath, dirPath.toString()+ "/" + fileUrl.substring(fileUrl.lastIndexOf('/') + 1)); sftp.unzipAndUpload(uploadPath, dirPath.toString()+ "/" + fileUrl.substring(fileUrl.lastIndexOf('/') + 1));
logger.info("上传并解压成功"); logger.info("上传并解压成功");
//修改代扣信息表状态
LambdaUpdateWrapper<IcbcWithhold> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IcbcWithhold::getBatchNo,batchNo);
updateWrapper.set(IcbcWithhold::getUploadStatus,UploadStatusEnum.已上传.getName());
updateWrapper.set(IcbcWithhold::getUploader,uploader);
updateWrapper.set(IcbcWithhold::getUploadTime,new Date());
this.getBaseMapper().update(null,updateWrapper);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("异常信息:" + e.getMessage()); logger.error("异常信息:" + e.getMessage());
...@@ -668,9 +667,9 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -668,9 +667,9 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
} }
public void upIcbcWithholdRecordWithholdStatus() { public void upIcbcWithholdRecordWithholdStatus() {
int current = 1;
LambdaQueryWrapper<IcbcWithholdRecord> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IcbcWithholdRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.isNull(IcbcWithholdRecord::getWithholdStatus).or().eq(IcbcWithholdRecord::getWithholdStatus,"处理中"); wrapper.isNull(IcbcWithholdRecord::getWithholdStatus).or().eq(IcbcWithholdRecord::getWithholdStatus,"");
Set<String> batchNos = icbcWithholdRecordService.getBaseMapper().selectList(wrapper).stream() Set<String> batchNos = icbcWithholdRecordService.getBaseMapper().selectList(wrapper).stream()
.map(IcbcWithholdRecord::getBatchNo) .map(IcbcWithholdRecord::getBatchNo)
.collect(Collectors.toSet());; .collect(Collectors.toSet());;
...@@ -696,12 +695,12 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -696,12 +695,12 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
// bizContent.setBillNo("1");//序号 // bizContent.setBillNo("1");//序号
bizContent.setTrxDate(DateUtils.getDateNowShortStr());//交易日期 bizContent.setTrxDate(DateUtils.getDateNowShortStr());//交易日期
// bizContent.setBusiCode("14948822"); // bizContent.setBusiCode("14948822");
bizContent.setCurPage("1");//查询页码 bizContent.setCurPage(String.valueOf(current));//查询页码
request.setBizContent(bizContent); request.setBizContent(bizContent);
JftApiPayFeewithholdQuerydetailResponseV1 response; JftApiPayFeewithholdQuerydetailResponseV1 response;
try { try {
response = client.execute(request, System.currentTimeMillis() + ""); response = client.execute(request, System.currentTimeMillis() + "");
if (response.isSuccess()) { while (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.getBatchNo())).collect(Collectors.toList()); List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> filterList = tradeList.stream().filter(e -> batchNos.contains(e.getBatchNo())).collect(Collectors.toList());
filterList.forEach(e->{ filterList.forEach(e->{
...@@ -713,10 +712,27 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -713,10 +712,27 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
updateWrapper.set(IcbcWithholdRecord::getPaymentTime,e.getTrxTime()); updateWrapper.set(IcbcWithholdRecord::getPaymentTime,e.getTrxTime());
icbcWithholdRecordService.getBaseMapper().update(null,updateWrapper); icbcWithholdRecordService.getBaseMapper().update(null,updateWrapper);
}); });
} else { current = ++current;
System.out.println("ReturnCode:" + response.getReturnCode()); bizContent.setCurPage(String.valueOf(current));
System.out.println("ReturnMsg:" + response.getReturnMsg()); request.setBizContent(bizContent);
response = client.execute(request, System.currentTimeMillis() + "");
} }
// if (response.isSuccess()) {
// List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> tradeList = response.getTradeList();
// List<JftApiPayFeewithholdQuerydetailResponseV1.TradeInfo> filterList = tradeList.stream().filter(e -> batchNos.contains(e.getBatchNo())).collect(Collectors.toList());
// filterList.forEach(e->{
// LambdaUpdateWrapper<IcbcWithholdRecord> updateWrapper = new LambdaUpdateWrapper<>();
// updateWrapper.eq(IcbcWithholdRecord::getBatchNo,e.getBatchNo());
// updateWrapper.eq(IcbcWithholdRecord::getOutUserId,e.getBusiCode());
// updateWrapper.set(IcbcWithholdRecord::getWithholdStatus,UploadStatusEnum.getNodeByCode(e.getStatus()).getName());
// updateWrapper.set(IcbcWithholdRecord::getWithholdTime,e.getTrxTime());
// updateWrapper.set(IcbcWithholdRecord::getPaymentTime,e.getTrxTime());
// icbcWithholdRecordService.getBaseMapper().update(null,updateWrapper);
// });
// } else {
// System.out.println("ReturnCode:" + response.getReturnCode());
// System.out.println("ReturnMsg:" + response.getReturnMsg());
// }
} catch (IcbcApiException e) { } catch (IcbcApiException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -742,16 +758,16 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit ...@@ -742,16 +758,16 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
if (StringUtils.isNotEmpty(icbcWithhold.getPaymentEndTime())){ if (StringUtils.isNotEmpty(icbcWithhold.getPaymentEndTime())){
dto.setPaymentEndTime(icbcWithhold.getPaymentEndTime()); dto.setPaymentEndTime(icbcWithhold.getPaymentEndTime());
} }
if (StringUtils.isNotEmpty(icbcWithhold.getIcbcId())){
if (StringUtils.isNotEmpty(icbcWithhold.getWithholdStatus())){ if (StringUtils.isNotEmpty(icbcWithhold.getWithholdStatus())){
dto.setWithholdStatus(icbcWithhold.getWithholdStatus()); dto.setWithholdStatus(icbcWithhold.getWithholdStatus());
} }
if (StringUtils.isNotEmpty(icbcWithhold.getIcbcId())){
dto.setAmosUserId(icbcWithhold.getIcbcId()); dto.setAmosUserId(icbcWithhold.getIcbcId());
dto.setShow("1"); dto.setShow("1");
} }
List<IcbcWithholdRecordDto> dtos = icbcWithholdRecordMapper.exportData(dto); List<IcbcWithholdRecordDto> dtos = icbcWithholdRecordMapper.exportData(dto);
if (CollectionUtil.isNotEmpty(dtos)) { if (CollectionUtil.isNotEmpty(dtos)) {
for (IcbcWithholdRecordDto icbcWithholdRecordDto : dtos) { for (IcbcWithholdRecordDto icbcWithholdRecordDto : dtos) {
HygfIcbcWithholdRecordExportDTO exportDTO = new HygfIcbcWithholdRecordExportDTO(); HygfIcbcWithholdRecordExportDTO exportDTO = new HygfIcbcWithholdRecordExportDTO();
BeanUtil.copyProperties(icbcWithholdRecordDto, exportDTO); BeanUtil.copyProperties(icbcWithholdRecordDto, exportDTO);
......
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