|
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.jeeplus.ccpm.approvalInfo.domain.*;
|
|
|
import com.jeeplus.ccpm.approvalInfo.mapper.*;
|
|
|
import com.jeeplus.ccpm.approvalInfo.service.dto.*;
|
|
|
+import com.jeeplus.ccpm.approvalType.mapper.CcpmReimbursementTypeMapper;
|
|
|
import com.jeeplus.ccpm.approvalType.service.CcpmReimbursementTypeService;
|
|
|
import com.jeeplus.common.TokenProvider;
|
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
@@ -26,12 +27,11 @@ import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.utils.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
//import com.jeeplus.finance.contractRegistration.service.ContractInfoService;
|
|
|
//import com.jeeplus.finance.reimbursementApproval.approvalInfo.service.dto.QueryListDto;
|
|
@@ -67,6 +67,9 @@ public class CcpmReimbursementInfoService {
|
|
|
@Resource
|
|
|
private CcpmReimbursementInfoUpHiMapper reimbursementInfoUpHiMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CcpmReimbursementTypeMapper mapper;
|
|
|
+
|
|
|
// @Resource
|
|
|
// private OssServiceMapper ossServiceMapper;
|
|
|
|
|
@@ -356,21 +359,35 @@ public class CcpmReimbursementInfoService {
|
|
|
amountInfoMapper.delete(deleteInfo);
|
|
|
}else if("1".equals(dto.getReimbursementType())){
|
|
|
// 保存电子发票列表信息
|
|
|
- if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
|
|
|
- for (CcpmReimbursementAmountInfo amountInfo : dto.getInvoiceReimbursements()) {
|
|
|
- //电子发票报销 发票信息
|
|
|
- amountInfo.setReimbursementType("1");
|
|
|
- // 生成id
|
|
|
- String amountId = UUID.randomUUID().toString().replace("-", "");
|
|
|
- amountInfo.setId(amountId);
|
|
|
- amountInfo.setCreateById(userDTO.getId());
|
|
|
- amountInfo.setCreateTime(new Date());
|
|
|
- amountInfo.setUpdateById(userDTO.getId());
|
|
|
- amountInfo.setUpdateTime(new Date());
|
|
|
- amountInfo.setDelFlag(0);
|
|
|
- // 保存基础表信息主键值
|
|
|
- amountInfo.setInfoId(id);
|
|
|
- amountInfoMapper.insert(amountInfo);
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
+ for (CcpmReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
|
|
|
+ if (StringUtils.isNotBlank(amountInfo.getUrl())){
|
|
|
+ CcpmReimbursementAmountInfo reimbursementAmountInfo = new CcpmReimbursementAmountInfo();
|
|
|
+ BeanUtils.copyProperties(amountInfo,reimbursementAmountInfo);
|
|
|
+ //电子发票报销 发票信息
|
|
|
+ reimbursementAmountInfo.setReimbursementType("1");
|
|
|
+ // 生成id
|
|
|
+ String amountId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ reimbursementAmountInfo.setId(amountId);
|
|
|
+ reimbursementAmountInfo.setCreateById(userDTO.getId());
|
|
|
+ reimbursementAmountInfo.setCreateTime(new Date());
|
|
|
+ reimbursementAmountInfo.setUpdateById(userDTO.getId());
|
|
|
+ reimbursementAmountInfo.setUpdateTime(new Date());
|
|
|
+ reimbursementAmountInfo.setDelFlag(0);
|
|
|
+ // 保存基础表信息主键值
|
|
|
+ reimbursementAmountInfo.setInfoId(id);
|
|
|
+ reimbursementAmountInfo.setFileUrl(amountInfo.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(amountInfo.getName().split("\\."));
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ reimbursementAmountInfo.setFileType(strings.get(1));
|
|
|
+ }
|
|
|
+ reimbursementAmountInfo.setAttachmentName(amountInfo.getName());
|
|
|
+ reimbursementAmountInfo.setAttachmentFlag("invoiceReimbursement");
|
|
|
+ reimbursementAmountInfo.setFileSize(amountInfo.getSize());
|
|
|
+ amountInfoMapper.insert(reimbursementAmountInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//清除专用发票信息
|
|
@@ -381,7 +398,7 @@ public class CcpmReimbursementInfoService {
|
|
|
|
|
|
// 保存电子发票附件列表信息
|
|
|
if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
- typeService.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
|
|
|
+ this.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -392,6 +409,48 @@ public class CcpmReimbursementInfoService {
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存附件信息
|
|
|
+ * @param list 待保存的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void saveFiles(List<CcpmReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
|
|
|
+ int j = 1;
|
|
|
+ for (CcpmReimAmountAndFileDto dto : list) {
|
|
|
+ if (StringUtils.isNotBlank(dto.getUrl())){
|
|
|
+ WorkAttachmentInfo i = new WorkAttachmentInfo();
|
|
|
+ //包含了url、size、name
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
+ i.setCreateTime(new Date());
|
|
|
+// i.getUpdateBy().setId(userDTO.getId());
|
|
|
+ i.setUpdateTime(new Date());
|
|
|
+ i.setDelFlag(0);
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ i.setType(strings.get(1));
|
|
|
+ }
|
|
|
+ i.setAttachmentId(id);
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
+ i.setAttachmentFlag(attachmentFlag);
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
+ i.setSort(j);
|
|
|
+// ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ String workAttachment = JSON.toJSONString((i));
|
|
|
+ String userDTOInfo = JSON.toJSONString((userDTO));
|
|
|
+ map.put("workAttachment",workAttachment);
|
|
|
+ map.put("userDTO",userDTOInfo);
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).insertWorkAttachment(map);
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public CcpmReimbursementInfo update(CcpmSaveInfoDto dto, UserDTO userDTO) {
|
|
|
boolean admin = userDTO.isAdmin();
|
|
|
//判断当前登录人是否是管理员,管理员修改时需要生成一条历史记录
|
|
@@ -527,21 +586,35 @@ public class CcpmReimbursementInfoService {
|
|
|
amountInfoMapper.delete(deleteInfo);
|
|
|
}else if("1".equals(dto.getReimbursementType())){
|
|
|
// 保存电子发票列表信息
|
|
|
- if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
|
|
|
- for (CcpmReimbursementAmountInfo amountInfo : dto.getInvoiceReimbursements()) {
|
|
|
- //电子发票报销 发票信息
|
|
|
- amountInfo.setReimbursementType("1");
|
|
|
- // 生成id
|
|
|
- String amountId = UUID.randomUUID().toString().replace("-", "");
|
|
|
- amountInfo.setId(amountId);
|
|
|
- amountInfo.setCreateById(userDTO.getId());
|
|
|
- amountInfo.setCreateTime(new Date());
|
|
|
- amountInfo.setUpdateById(userDTO.getId());
|
|
|
- amountInfo.setUpdateTime(new Date());
|
|
|
- amountInfo.setDelFlag(0);
|
|
|
- // 保存基础表信息主键值
|
|
|
- amountInfo.setInfoId(dto.getId());
|
|
|
- amountInfoMapper.insert(amountInfo);
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
+ for (CcpmReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
|
|
|
+ if (StringUtils.isNotBlank(amountInfo.getUrl())){
|
|
|
+ CcpmReimbursementAmountInfo reimbursementAmountInfo = new CcpmReimbursementAmountInfo();
|
|
|
+ BeanUtils.copyProperties(amountInfo,reimbursementAmountInfo);
|
|
|
+ //电子发票报销 发票信息
|
|
|
+ reimbursementAmountInfo.setReimbursementType("1");
|
|
|
+ // 生成id
|
|
|
+ String amountId = UUID.randomUUID().toString().replace("-", "");
|
|
|
+ reimbursementAmountInfo.setId(amountId);
|
|
|
+ reimbursementAmountInfo.setCreateById(userDTO.getId());
|
|
|
+ reimbursementAmountInfo.setCreateTime(new Date());
|
|
|
+ reimbursementAmountInfo.setUpdateById(userDTO.getId());
|
|
|
+ reimbursementAmountInfo.setUpdateTime(new Date());
|
|
|
+ reimbursementAmountInfo.setDelFlag(0);
|
|
|
+ // 保存基础表信息主键值
|
|
|
+ reimbursementAmountInfo.setInfoId(dto.getId());
|
|
|
+ reimbursementAmountInfo.setFileUrl(amountInfo.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(amountInfo.getName().split("\\."));
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ reimbursementAmountInfo.setFileType(strings.get(1));
|
|
|
+ }
|
|
|
+ reimbursementAmountInfo.setAttachmentName(amountInfo.getName());
|
|
|
+ reimbursementAmountInfo.setAttachmentFlag("invoiceReimbursement");
|
|
|
+ reimbursementAmountInfo.setFileSize(amountInfo.getSize());
|
|
|
+ amountInfoMapper.insert(reimbursementAmountInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//清除专用发票信息
|
|
@@ -552,7 +625,7 @@ public class CcpmReimbursementInfoService {
|
|
|
|
|
|
// 保存电子发票附件列表信息
|
|
|
if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
- typeService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
+ this.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -573,11 +646,74 @@ public class CcpmReimbursementInfoService {
|
|
|
}*/
|
|
|
// 修改附件信息列表
|
|
|
if (CollectionUtils.isNotEmpty(dto.getFiles())) {
|
|
|
- typeService.updateFiles(dto.getFiles(), userDTO, dto.getId());
|
|
|
+ typeService.updateFiles(dto.getFiles(), userDTO, dto.getId(),"cwWorkContract");
|
|
|
}
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改附件信息
|
|
|
+ * @param list 待修改的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateFiles(List<CcpmReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
|
|
|
+ int j = 1;
|
|
|
+ String names = new String();
|
|
|
+ //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
|
|
|
+ for (CcpmReimAmountAndFileDto dto : list) {
|
|
|
+ names = names + "," +dto.getUrl();
|
|
|
+ }
|
|
|
+ //查询保存的附件信息
|
|
|
+ List<WorkAttachmentInfo> infoList = mapper.findListByIdAndAttachmentFlag(id,attachmentFlag);
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(infoList)) {
|
|
|
+ for (WorkAttachmentInfo i : infoList) {
|
|
|
+ if (!names.contains(i.getUrl())) {
|
|
|
+// ossServiceMapper.deleteById(i.getId());
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).deleteById(i.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存信息
|
|
|
+ for (CcpmReimAmountAndFileDto dto : list) {
|
|
|
+ //判断是否存在
|
|
|
+ Integer isExit = mapper.findIsExit(id, dto.getName());
|
|
|
+ if (isExit == 0) {
|
|
|
+ if (StringUtils.isNotBlank(dto.getUrl())){
|
|
|
+ WorkAttachmentInfo i = new WorkAttachmentInfo();
|
|
|
+ //包含了url、size、name
|
|
|
+ i.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+// i.getCreateBy().setId(userDTO.getId());
|
|
|
+ i.setCreateTime(new Date());
|
|
|
+// i.getUpdateBy().setId(userDTO.getId());
|
|
|
+ i.setUpdateTime(new Date());
|
|
|
+ i.setDelFlag(0);
|
|
|
+ i.setUrl(dto.getUrl());
|
|
|
+ //文件类型处理
|
|
|
+ List<String> strings = Arrays.asList(dto.getName().split("\\."));
|
|
|
+ if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(strings)) {
|
|
|
+ i.setType(strings.get(1));
|
|
|
+ }
|
|
|
+ i.setAttachmentId(id);
|
|
|
+ i.setAttachmentName(dto.getName());
|
|
|
+ i.setAttachmentFlag(attachmentFlag);
|
|
|
+ i.setFileSize(dto.getSize());
|
|
|
+ i.setSort(j);
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ String workAttachment = JSON.toJSONString((i));
|
|
|
+ String userDTOInfo = JSON.toJSONString((userDTO));
|
|
|
+ map.put("workAttachment",workAttachment);
|
|
|
+ map.put("userDTO",userDTOInfo);
|
|
|
+ SpringUtil.getBean ( IWorkAttachmentApi.class ).insertWorkAttachment(map);
|
|
|
+// ossServiceMapper.insertWorkAttachment(i, userDTO);
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public String remove(String id) {
|
|
|
// 删除基础信息表
|
|
|
infoMapper.deleteById(id);
|
|
@@ -650,28 +786,93 @@ public class CcpmReimbursementInfoService {
|
|
|
invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getInfoId, id);
|
|
|
invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getReimbursementType, "1");
|
|
|
List<CcpmReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
|
|
|
- dto.setInvoiceReimbursements(invoiceReimbursements);
|
|
|
+// dto.setInvoiceReimbursements(invoiceReimbursements);
|
|
|
// 查询附件信息
|
|
|
List<WorkAttachmentInfo> fileList = infoMapper.findFiles(id);
|
|
|
List<WorkAttachmentInfo> files = com.google.common.collect.Lists.newArrayList();
|
|
|
- List<WorkAttachmentInfo> invoiceReimbursementFiles = com.google.common.collect.Lists.newArrayList();
|
|
|
+ List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles = com.google.common.collect.Lists.newArrayList();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fileList)) {
|
|
|
+ // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
|
|
|
+ Map<String, CcpmReimbursementAmountInfo> reimbursementMap = new HashMap<>();
|
|
|
+ for (CcpmReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
|
|
|
+ if (StringUtils.isNotBlank(invoiceReimbursement.getFileUrl())) {
|
|
|
+ reimbursementMap.put(invoiceReimbursement.getFileUrl(), invoiceReimbursement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 遍历 fileList 进行处理
|
|
|
for (WorkAttachmentInfo i : fileList) {
|
|
|
- i.setCreateBy(SpringUtil.getBean ( IUserApi.class ).getById(i.getBy()));
|
|
|
- if("invoiceReimbursement".equals(i.getAttachmentFlag())){
|
|
|
- invoiceReimbursementFiles.add(i);
|
|
|
- }else{
|
|
|
- files.add(i);
|
|
|
+ if ("invoiceReimbursement".equals(i.getAttachmentFlag())) {
|
|
|
+ CcpmReimbursementAmountInfo invoiceReimbursement = reimbursementMap.get(i.getUrl());
|
|
|
+
|
|
|
+ if (invoiceReimbursement != null) {
|
|
|
+ // 处理有 URL 匹配的文件
|
|
|
+ processMatchingFiles(i, invoiceReimbursement, invoiceReimbursementFiles);
|
|
|
+ } else {
|
|
|
+ // 处理没有 URL 匹配的文件,针对老数据进行处理
|
|
|
+ handleOldData(i, invoiceReimbursements, invoiceReimbursementFiles,id);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 处理其他文件
|
|
|
+ processNonInvoiceFiles(i, files);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dto.setFiles(files);
|
|
|
- dto.setInvoiceReimbursementFiles(invoiceReimbursementFiles);
|
|
|
+ //进行一次去重
|
|
|
+ List<CcpmReimAmountAndFileDto> uniqueFilesList = invoiceReimbursementFiles.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(
|
|
|
+ Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CcpmReimAmountAndFileDto::getNumber))),
|
|
|
+ ArrayList::new
|
|
|
+ ));
|
|
|
+ dto.setInvoiceReimbursementFiles(uniqueFilesList);
|
|
|
}
|
|
|
return dto;
|
|
|
}
|
|
|
|
|
|
+ // 针对 URL 匹配的文件进行处理的提取方法
|
|
|
+ private void processMatchingFiles(WorkAttachmentInfo i, CcpmReimbursementAmountInfo invoiceReimbursement, List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles) {
|
|
|
+ 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, 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 processNonInvoiceFiles(WorkAttachmentInfo i, List<WorkAttachmentInfo> files) {
|
|
|
+ i.setCreateBy(SpringUtil.getBean(IUserApi.class).getById(i.getBy()));
|
|
|
+ files.add(i);
|
|
|
+ }
|
|
|
+
|
|
|
public Boolean checkNumber(String number) {
|
|
|
LambdaQueryWrapper<CcpmReimbursementAmountInfo> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(CcpmReimbursementAmountInfo::getNumber, number);
|
|
@@ -971,20 +1172,43 @@ public class CcpmReimbursementInfoService {
|
|
|
// 查询附件信息
|
|
|
List<WorkAttachmentInfo> fileList = infoMapper.findFiles(reimId);
|
|
|
List<WorkAttachmentInfo> files = com.google.common.collect.Lists.newArrayList();
|
|
|
- List<WorkAttachmentInfo> invoiceReimbursementFiles = com.google.common.collect.Lists.newArrayList();
|
|
|
+ List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles = com.google.common.collect.Lists.newArrayList();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fileList)) {
|
|
|
+ // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
|
|
|
+ Map<String, CcpmReimbursementAmountInfo> reimbursementMap = new HashMap<>();
|
|
|
+ for (CcpmReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
|
|
|
+ if (StringUtils.isNotBlank(invoiceReimbursement.getFileUrl())) {
|
|
|
+ reimbursementMap.put(invoiceReimbursement.getFileUrl(), invoiceReimbursement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 遍历 fileList 进行处理
|
|
|
for (WorkAttachmentInfo i : fileList) {
|
|
|
- i.setCreateBy(SpringUtil.getBean ( IUserApi.class ).getById(i.getBy()));
|
|
|
- if("invoiceReimbursement".equals(i.getAttachmentFlag())){
|
|
|
- invoiceReimbursementFiles.add(i);
|
|
|
- }else{
|
|
|
- files.add(i);
|
|
|
+ if ("invoiceReimbursement".equals(i.getAttachmentFlag())) {
|
|
|
+ CcpmReimbursementAmountInfo invoiceReimbursement = reimbursementMap.get(i.getUrl());
|
|
|
+
|
|
|
+ if (invoiceReimbursement != null) {
|
|
|
+ // 处理有 URL 匹配的文件
|
|
|
+ processMatchingFiles(i, invoiceReimbursement, invoiceReimbursementFiles);
|
|
|
+ } else {
|
|
|
+ // 处理没有 URL 匹配的文件,针对老数据进行处理
|
|
|
+ handleOldData(i, invoiceReimbursements, invoiceReimbursementFiles,reimId);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 处理其他文件
|
|
|
+ processNonInvoiceFiles(i, files);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dto.setFiles(files);
|
|
|
- dto.setInvoiceReimbursementFiles(invoiceReimbursementFiles);
|
|
|
+ //进行一次去重
|
|
|
+ List<CcpmReimAmountAndFileDto> uniqueFilesList = invoiceReimbursementFiles.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(
|
|
|
+ Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CcpmReimAmountAndFileDto::getNumber))),
|
|
|
+ ArrayList::new
|
|
|
+ ));
|
|
|
+ dto.setInvoiceReimbursementFiles(uniqueFilesList);
|
|
|
}
|
|
|
return dto;
|
|
|
}
|
|
@@ -1060,7 +1284,7 @@ public class CcpmReimbursementInfoService {
|
|
|
|
|
|
// 保存电子发票附件列表信息
|
|
|
if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
- typeService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
+ this.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
}
|
|
|
}
|
|
|
}
|