|
@@ -1,5 +1,6 @@
|
|
|
package com.jeeplus.consultancy.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;
|
|
@@ -13,6 +14,7 @@ import com.jeeplus.common.TokenProvider;
|
|
|
import com.jeeplus.consultancy.approvalInfo.domain.*;
|
|
|
import com.jeeplus.consultancy.approvalInfo.mapper.*;
|
|
|
import com.jeeplus.consultancy.approvalInfo.service.dto.*;
|
|
|
+import com.jeeplus.consultancy.approvalType.mapper.ConsultancyReimbursementTypeMapper;
|
|
|
import com.jeeplus.consultancy.approvalType.service.ConsultancyReimbursementTypeService;
|
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
import com.jeeplus.flowable.feign.IFlowableApi;
|
|
@@ -26,12 +28,10 @@ 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 com.jeeplus.finance.contractRegistration.service.ContractInfoService;
|
|
|
//import com.jeeplus.finance.reimbursementApproval.approvalInfo.service.dto.QueryListDto;
|
|
@@ -88,6 +88,9 @@ public class ConsultancyReimbursementInfoService {
|
|
|
@Resource
|
|
|
private ConsultancyReimbursementFileSupplementMapper consultancyReimbursementFileSupplementMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ConsultancyReimbursementTypeMapper mapper;
|
|
|
+
|
|
|
/**
|
|
|
* 报告号查询
|
|
|
*/
|
|
@@ -357,21 +360,35 @@ public class ConsultancyReimbursementInfoService {
|
|
|
amountInfoMapper.delete(deleteInfo);
|
|
|
}else if("1".equals(dto.getReimbursementType())){
|
|
|
// 保存电子发票列表信息
|
|
|
- if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
|
|
|
- for (ConsultancyReimbursementAmountInfo 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 (ConsultancyReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
|
|
|
+ if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
|
|
|
+ ConsultancyReimbursementAmountInfo reimbursementAmountInfo = new ConsultancyReimbursementAmountInfo();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//清除专用发票信息
|
|
@@ -382,7 +399,7 @@ public class ConsultancyReimbursementInfoService {
|
|
|
|
|
|
// 保存电子发票附件列表信息
|
|
|
if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
- typeService.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
|
|
|
+ saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -393,6 +410,50 @@ public class ConsultancyReimbursementInfoService {
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存附件信息
|
|
|
+ * @param list 待保存的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void saveFiles(List<ConsultancyReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
|
|
|
+ int j = 1;
|
|
|
+ for (ConsultancyReimAmountAndFileDto dto : list) {
|
|
|
+ if (com.jeeplus.utils.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 ConsultancyReimbursementInfo update(ConsultancySaveInfoDto dto, UserDTO userDTO) {
|
|
|
boolean admin = userDTO.isAdmin();
|
|
|
//判断当前登录人是否是管理员,管理员修改时需要生成一条历史记录
|
|
@@ -528,21 +589,35 @@ public class ConsultancyReimbursementInfoService {
|
|
|
amountInfoMapper.delete(deleteInfo);
|
|
|
}else if("1".equals(dto.getReimbursementType())){
|
|
|
// 保存电子发票列表信息
|
|
|
- if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
|
|
|
- for (ConsultancyReimbursementAmountInfo 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 (ConsultancyReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
|
|
|
+ if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
|
|
|
+ ConsultancyReimbursementAmountInfo reimbursementAmountInfo = new ConsultancyReimbursementAmountInfo();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//清除专用发票信息
|
|
@@ -553,7 +628,7 @@ public class ConsultancyReimbursementInfoService {
|
|
|
|
|
|
// 保存电子发票附件列表信息
|
|
|
if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
- typeService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
+ updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -579,6 +654,71 @@ public class ConsultancyReimbursementInfoService {
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改附件信息
|
|
|
+ * @param list 待修改的附件列表
|
|
|
+ * @param userDTO 当前登录用户
|
|
|
+ * @param id 关联id
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateFiles(List<ConsultancyReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
|
|
|
+ int j = 1;
|
|
|
+ String names = new String();
|
|
|
+ //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
|
|
|
+ for (ConsultancyReimAmountAndFileDto 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 (ConsultancyReimAmountAndFileDto dto : list) {
|
|
|
+ //判断是否存在
|
|
|
+ Integer isExit = mapper.findIsExit(id, dto.getName());
|
|
|
+ if (isExit == 0) {
|
|
|
+ if (com.jeeplus.utils.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);
|
|
@@ -651,28 +791,83 @@ public class ConsultancyReimbursementInfoService {
|
|
|
invoiceReimbursementsLambdaQueryWrapper.eq(ConsultancyReimbursementAmountInfo::getInfoId, id);
|
|
|
invoiceReimbursementsLambdaQueryWrapper.eq(ConsultancyReimbursementAmountInfo::getReimbursementType, "1");
|
|
|
List<ConsultancyReimbursementAmountInfo> 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();
|
|
|
+ Set<ConsultancyReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>(); // 使用 Set 去重
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fileList)) {
|
|
|
+ // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
|
|
|
+ Map<String, ConsultancyReimbursementAmountInfo> reimbursementMap = new HashMap<>();
|
|
|
+ for (ConsultancyReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
|
|
|
+ if (com.jeeplus.utils.StringUtils.isNotBlank(invoiceReimbursement.getFileUrl())) {
|
|
|
+ reimbursementMap.put(invoiceReimbursement.getFileUrl(), invoiceReimbursement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询数电发票解析后的数据
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
+ strings.add(id);
|
|
|
+ Map<String, String> map = SpringUtil.getBean(IWorkAttachmentApi.class).disposeElectronicEngineeringInvoiceNumber(strings, "3");
|
|
|
+
|
|
|
+
|
|
|
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())) {
|
|
|
+ ConsultancyReimbursementAmountInfo invoiceReimbursement = reimbursementMap.get(i.getUrl());
|
|
|
+
|
|
|
+ if (invoiceReimbursement != null) {
|
|
|
+ // 处理有 URL 匹配的文件
|
|
|
+ processMatchingFiles(i, invoiceReimbursement, invoiceReimbursementFiles);
|
|
|
+ }else {
|
|
|
+ if (map !=null){
|
|
|
+ for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
+ for (ConsultancyReimbursementAmountInfo reimbursement : invoiceReimbursements) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
|
|
|
+ ConsultancyReimAmountAndFileDto ccpmReimAmountAndFileDto = new ConsultancyReimAmountAndFileDto();
|
|
|
+ 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 {
|
|
|
+ // 处理其他文件
|
|
|
+ processNonInvoiceFiles(i, files);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dto.setFiles(files);
|
|
|
- dto.setInvoiceReimbursementFiles(invoiceReimbursementFiles);
|
|
|
+ List<ConsultancyReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
|
|
|
+ dto.setInvoiceReimbursementFiles(uniqueFilesList);
|
|
|
}
|
|
|
return dto;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // 针对 URL 匹配的文件进行处理的提取方法
|
|
|
+ private void processMatchingFiles(WorkAttachmentInfo i, ConsultancyReimbursementAmountInfo invoiceReimbursement, Set<ConsultancyReimAmountAndFileDto> invoiceReimbursementFiles) {
|
|
|
+ ConsultancyReimAmountAndFileDto ccpmReimAmountAndFileDto = new ConsultancyReimAmountAndFileDto();
|
|
|
+ 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<ConsultancyReimbursementAmountInfo> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(ConsultancyReimbursementAmountInfo::getNumber, number);
|
|
@@ -974,24 +1169,62 @@ public class ConsultancyReimbursementInfoService {
|
|
|
invoiceReimbursementsLambdaQueryWrapper.eq(ConsultancyReimbursementAmountInfo::getInfoId, reimId);
|
|
|
invoiceReimbursementsLambdaQueryWrapper.eq(ConsultancyReimbursementAmountInfo::getReimbursementType, "1");
|
|
|
List<ConsultancyReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
|
|
|
- dto.setInvoiceReimbursements(invoiceReimbursements);
|
|
|
+// dto.setInvoiceReimbursements(invoiceReimbursements);
|
|
|
// 查询附件信息
|
|
|
List<WorkAttachmentInfo> fileList = infoMapper.findFiles(reimId);
|
|
|
List<WorkAttachmentInfo> files = com.google.common.collect.Lists.newArrayList();
|
|
|
- List<WorkAttachmentInfo> invoiceReimbursementFiles = com.google.common.collect.Lists.newArrayList();
|
|
|
+ Set<ConsultancyReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>(); // 使用 Set 去重
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(fileList)) {
|
|
|
+ // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
|
|
|
+ Map<String, ConsultancyReimbursementAmountInfo> reimbursementMap = new HashMap<>();
|
|
|
+ for (ConsultancyReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
|
|
|
+ if (com.jeeplus.utils.StringUtils.isNotBlank(invoiceReimbursement.getFileUrl())) {
|
|
|
+ reimbursementMap.put(invoiceReimbursement.getFileUrl(), invoiceReimbursement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询数电发票解析后的数据
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
+ strings.add(id);
|
|
|
+ Map<String, String> map = SpringUtil.getBean(IWorkAttachmentApi.class).disposeElectronicEngineeringInvoiceNumber(strings, "3");
|
|
|
+
|
|
|
+
|
|
|
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())) {
|
|
|
+ ConsultancyReimbursementAmountInfo invoiceReimbursement = reimbursementMap.get(i.getUrl());
|
|
|
+
|
|
|
+ if (invoiceReimbursement != null) {
|
|
|
+ // 处理有 URL 匹配的文件
|
|
|
+ processMatchingFiles(i, invoiceReimbursement, invoiceReimbursementFiles);
|
|
|
+ }else {
|
|
|
+ if (map !=null){
|
|
|
+ for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
+ for (ConsultancyReimbursementAmountInfo reimbursement : invoiceReimbursements) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
|
|
|
+ ConsultancyReimAmountAndFileDto ccpmReimAmountAndFileDto = new ConsultancyReimAmountAndFileDto();
|
|
|
+ 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 {
|
|
|
+ // 处理其他文件
|
|
|
+ processNonInvoiceFiles(i, files);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
dto.setFiles(files);
|
|
|
- dto.setInvoiceReimbursementFiles(invoiceReimbursementFiles);
|
|
|
+ List<ConsultancyReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
|
|
|
+ dto.setInvoiceReimbursementFiles(uniqueFilesList);
|
|
|
}
|
|
|
return dto;
|
|
|
}
|
|
@@ -1042,21 +1275,35 @@ public class ConsultancyReimbursementInfoService {
|
|
|
amountInfoMapper.delete(deleteInfo);
|
|
|
}else if("1".equals(dto.getReimbursementType())){
|
|
|
// 保存电子发票列表信息
|
|
|
- if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
|
|
|
- for (ConsultancyReimbursementAmountInfo 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 (ConsultancyReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
|
|
|
+ if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
|
|
|
+ ConsultancyReimbursementAmountInfo reimbursementAmountInfo = new ConsultancyReimbursementAmountInfo();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
//清除专用发票信息
|
|
@@ -1067,7 +1314,7 @@ public class ConsultancyReimbursementInfoService {
|
|
|
|
|
|
// 保存电子发票附件列表信息
|
|
|
if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
|
|
|
- typeService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
+ updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1119,4 +1366,62 @@ public class ConsultancyReimbursementInfoService {
|
|
|
consultancyReimbursementFileSupplementMapper.updateFileStatusById(dto.getFileSuppleId(),dto.getFileStatus());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改数电发票报销数据(对老数据进行调整)
|
|
|
+ */
|
|
|
+ public void updateOldData() {
|
|
|
+ try {
|
|
|
+ Set<String> infoIds = new HashSet<>(); // 使用 Set 去重
|
|
|
+
|
|
|
+ // 查询所有的数电发票信息
|
|
|
+ LambdaQueryWrapper<ConsultancyReimbursementAmountInfo> invoiceReimbursementsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ invoiceReimbursementsLambdaQueryWrapper.eq(ConsultancyReimbursementAmountInfo::getReimbursementType, "1");
|
|
|
+ invoiceReimbursementsLambdaQueryWrapper.eq(ConsultancyReimbursementAmountInfo::getDelFlag, "0");
|
|
|
+ invoiceReimbursementsLambdaQueryWrapper.orderByDesc(ConsultancyReimbursementAmountInfo::getCreateTime);
|
|
|
+ List<ConsultancyReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(invoiceReimbursements)) {
|
|
|
+ // 将所有的报销id进行存储
|
|
|
+ for (ConsultancyReimbursementAmountInfo 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 (ConsultancyReimbursementAmountInfo 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|