|
@@ -1,5 +1,6 @@
|
|
|
package com.jeeplus.ccpm.approvalInfo.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -789,8 +790,8 @@ public class CcpmReimbursementInfoService {
|
|
|
// dto.setInvoiceReimbursements(invoiceReimbursements);
|
|
|
// 查询附件信息
|
|
|
List<WorkAttachmentInfo> fileList = infoMapper.findFiles(id);
|
|
|
- List<WorkAttachmentInfo> files = com.google.common.collect.Lists.newArrayList();
|
|
|
- List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles = com.google.common.collect.Lists.newArrayList();
|
|
|
+ Set<CcpmReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>(); // 使用 Set 去重
|
|
|
+ List<WorkAttachmentInfo> files = new ArrayList<>();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fileList)) {
|
|
|
// 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
|
|
@@ -800,6 +801,11 @@ public class CcpmReimbursementInfoService {
|
|
|
reimbursementMap.put(invoiceReimbursement.getFileUrl(), invoiceReimbursement);
|
|
|
}
|
|
|
}
|
|
|
+ //查询数电发票解析后的数据
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
+ strings.add(id);
|
|
|
+ Map<String, String> map = SpringUtil.getBean(IWorkAttachmentApi.class).disposeElectronicEngineeringInvoiceNumber(strings, "3");
|
|
|
+
|
|
|
|
|
|
// 遍历 fileList 进行处理
|
|
|
for (WorkAttachmentInfo i : fileList) {
|
|
@@ -809,9 +815,25 @@ public class CcpmReimbursementInfoService {
|
|
|
if (invoiceReimbursement != null) {
|
|
|
// 处理有 URL 匹配的文件
|
|
|
processMatchingFiles(i, invoiceReimbursement, invoiceReimbursementFiles);
|
|
|
- } else {
|
|
|
- // 处理没有 URL 匹配的文件,针对老数据进行处理
|
|
|
- handleOldData(i, invoiceReimbursements, invoiceReimbursementFiles,id);
|
|
|
+ }else {
|
|
|
+ if (map !=null){
|
|
|
+ for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
+ for (CcpmReimbursementAmountInfo reimbursement : invoiceReimbursements) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
|
|
|
+ CcpmReimAmountAndFileDto ccpmReimAmountAndFileDto = new CcpmReimAmountAndFileDto();
|
|
|
+ BeanUtils.copyProperties(i, ccpmReimAmountAndFileDto);
|
|
|
+ BeanUtils.copyProperties(reimbursement, ccpmReimAmountAndFileDto);
|
|
|
+ ccpmReimAmountAndFileDto.setId(i.getId());
|
|
|
+ ccpmReimAmountAndFileDto.setCreateBy(SpringUtil.getBean(IUserApi.class).getById(i.getBy()));
|
|
|
+ invoiceReimbursementFiles.add(ccpmReimAmountAndFileDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
// 处理其他文件
|
|
@@ -820,19 +842,16 @@ public class CcpmReimbursementInfoService {
|
|
|
}
|
|
|
}
|
|
|
dto.setFiles(files);
|
|
|
- //进行一次去重
|
|
|
- List<CcpmReimAmountAndFileDto> uniqueFilesList = invoiceReimbursementFiles.stream()
|
|
|
- .collect(Collectors.collectingAndThen(
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CcpmReimAmountAndFileDto::getNumber))),
|
|
|
- ArrayList::new
|
|
|
- ));
|
|
|
+ // 将 Set 转换回 List
|
|
|
+ List<CcpmReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
|
|
|
dto.setInvoiceReimbursementFiles(uniqueFilesList);
|
|
|
}
|
|
|
return dto;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 针对 URL 匹配的文件进行处理的提取方法
|
|
|
- private void processMatchingFiles(WorkAttachmentInfo i, CcpmReimbursementAmountInfo invoiceReimbursement, List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles) {
|
|
|
+ private void processMatchingFiles(WorkAttachmentInfo i, CcpmReimbursementAmountInfo invoiceReimbursement, Set<CcpmReimAmountAndFileDto> invoiceReimbursementFiles) {
|
|
|
CcpmReimAmountAndFileDto ccpmReimAmountAndFileDto = new CcpmReimAmountAndFileDto();
|
|
|
BeanUtils.copyProperties(i, ccpmReimAmountAndFileDto);
|
|
|
BeanUtils.copyProperties(invoiceReimbursement, ccpmReimAmountAndFileDto);
|
|
@@ -842,30 +861,26 @@ public class CcpmReimbursementInfoService {
|
|
|
}
|
|
|
|
|
|
// 针对老数据的处理方法
|
|
|
- private void handleOldData(WorkAttachmentInfo i, List<CcpmReimbursementAmountInfo> invoiceReimbursements, List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles,String id) {
|
|
|
- ArrayList<String> strings = new ArrayList<>();
|
|
|
- strings.add(id);
|
|
|
- Map<String, String> map = SpringUtil.getBean(IWorkAttachmentApi.class).disposeElectronicEngineeringInvoiceNumber(strings, "3");
|
|
|
-
|
|
|
- if (map != null) {
|
|
|
- for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
- String key = entry.getKey();
|
|
|
- String value = entry.getValue();
|
|
|
- for (CcpmReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
|
|
|
- if (StringUtils.isNotBlank(value) && key.equals(invoiceReimbursement.getNumber())) {
|
|
|
- // 如果 value 非空且 key 匹配,则执行相关操作
|
|
|
- CcpmReimAmountAndFileDto ccpmReimAmountAndFileDto = new CcpmReimAmountAndFileDto();
|
|
|
- BeanUtils.copyProperties(i, ccpmReimAmountAndFileDto);
|
|
|
- BeanUtils.copyProperties(invoiceReimbursement, ccpmReimAmountAndFileDto);
|
|
|
- ccpmReimAmountAndFileDto.setId(i.getId());
|
|
|
- ccpmReimAmountAndFileDto.setCreateBy(SpringUtil.getBean(IUserApi.class).getById(i.getBy()));
|
|
|
- invoiceReimbursementFiles.add(ccpmReimAmountAndFileDto);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// private void handleOldData(WorkAttachmentInfo i, List<CcpmReimbursementAmountInfo> invoiceReimbursements, Set<CcpmReimAmountAndFileDto> invoiceReimbursementFiles,Map<String, String> map) {
|
|
|
+// if (map != null) {
|
|
|
+// for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
+// String key = entry.getKey();
|
|
|
+// String value = entry.getValue();
|
|
|
+// for (CcpmReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
|
|
|
+// if (StringUtils.isNotBlank(value) && key.equals(invoiceReimbursement.getNumber())) {
|
|
|
+// // 如果 value 非空且 key 匹配,则执行相关操作
|
|
|
+// CcpmReimAmountAndFileDto ccpmReimAmountAndFileDto = new CcpmReimAmountAndFileDto();
|
|
|
+// BeanUtils.copyProperties(i, ccpmReimAmountAndFileDto);
|
|
|
+// BeanUtils.copyProperties(invoiceReimbursement, ccpmReimAmountAndFileDto);
|
|
|
+// ccpmReimAmountAndFileDto.setId(i.getId());
|
|
|
+// ccpmReimAmountAndFileDto.setCreateBy(SpringUtil.getBean(IUserApi.class).getById(i.getBy()));
|
|
|
+// invoiceReimbursementFiles.add(ccpmReimAmountAndFileDto);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
// 处理其他文件的方法
|
|
|
private void processNonInvoiceFiles(WorkAttachmentInfo i, List<WorkAttachmentInfo> files) {
|
|
@@ -1172,7 +1187,7 @@ public class CcpmReimbursementInfoService {
|
|
|
// 查询附件信息
|
|
|
List<WorkAttachmentInfo> fileList = infoMapper.findFiles(reimId);
|
|
|
List<WorkAttachmentInfo> files = com.google.common.collect.Lists.newArrayList();
|
|
|
- List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles = com.google.common.collect.Lists.newArrayList();
|
|
|
+ Set<CcpmReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fileList)) {
|
|
|
// 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
|
|
@@ -1191,9 +1206,6 @@ public class CcpmReimbursementInfoService {
|
|
|
if (invoiceReimbursement != null) {
|
|
|
// 处理有 URL 匹配的文件
|
|
|
processMatchingFiles(i, invoiceReimbursement, invoiceReimbursementFiles);
|
|
|
- } else {
|
|
|
- // 处理没有 URL 匹配的文件,针对老数据进行处理
|
|
|
- handleOldData(i, invoiceReimbursements, invoiceReimbursementFiles,reimId);
|
|
|
}
|
|
|
} else {
|
|
|
// 处理其他文件
|
|
@@ -1203,11 +1215,7 @@ public class CcpmReimbursementInfoService {
|
|
|
}
|
|
|
dto.setFiles(files);
|
|
|
//进行一次去重
|
|
|
- List<CcpmReimAmountAndFileDto> uniqueFilesList = invoiceReimbursementFiles.stream()
|
|
|
- .collect(Collectors.collectingAndThen(
|
|
|
- Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CcpmReimAmountAndFileDto::getNumber))),
|
|
|
- ArrayList::new
|
|
|
- ));
|
|
|
+ List<CcpmReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
|
|
|
dto.setInvoiceReimbursementFiles(uniqueFilesList);
|
|
|
}
|
|
|
return dto;
|
|
@@ -1336,4 +1344,59 @@ public class CcpmReimbursementInfoService {
|
|
|
ccpmReimbursementFileSupplementMapper.updateFileStatusById(dto.getFileSuppleId(),dto.getFileStatus());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改数电发票报销数据(对老数据进行调整)
|
|
|
+ */
|
|
|
+ public void updateOldData() {
|
|
|
+ try {
|
|
|
+ Set<String> infoIds = new HashSet<>(); // 使用 Set 去重
|
|
|
+
|
|
|
+ // 查询所有的数电发票信息
|
|
|
+ LambdaQueryWrapper<CcpmReimbursementAmountInfo> invoiceReimbursementsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getReimbursementType, "1");
|
|
|
+ invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getDelFlag, "0");
|
|
|
+ invoiceReimbursementsLambdaQueryWrapper.orderByDesc(CcpmReimbursementAmountInfo::getCreateTime);
|
|
|
+ List<CcpmReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(invoiceReimbursements)) {
|
|
|
+ // 将所有的报销id进行存储
|
|
|
+ for (CcpmReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
|
|
|
+ infoIds.add(invoiceReimbursement.getInfoId());
|
|
|
+ }
|
|
|
+ if (infoIds != null && invoiceReimbursements != null){
|
|
|
+ ArrayList<String> list = new ArrayList<>(infoIds);
|
|
|
+ for (String id : list) {
|
|
|
+ //查询数电发票解析后的数据
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
+ strings.add(id);
|
|
|
+ Map<String, String> map = SpringUtil.getBean(IWorkAttachmentApi.class).disposeElectronicEngineeringInvoiceNumber(strings, "3");
|
|
|
+
|
|
|
+ List<WorkAttachmentInfo> fileList = infoMapper.findReimFiles(id, "invoiceReimbursement");
|
|
|
+ if (CollectionUtil.isNotEmpty(invoiceReimbursements) && CollectionUtil.isNotEmpty(fileList) && map !=null){
|
|
|
+ for (CcpmReimbursementAmountInfo amountInfo : invoiceReimbursements) {
|
|
|
+ for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
+ for (WorkAttachmentInfo i : fileList) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ if (amountInfo.getNumber().equals(key) && i.getUrl().equals(value)){
|
|
|
+ amountInfo.setFileUrl(i.getUrl());
|
|
|
+ amountInfo.setFileType(i.getType());
|
|
|
+ amountInfo.setAttachmentFlag("invoiceReimbursement");
|
|
|
+ amountInfo.setAttachmentName(i.getName());
|
|
|
+ amountInfo.setFileSize(i.getFileSize());
|
|
|
+ amountInfoMapper.updateById(amountInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|