Browse Source

项目-数电发票报销调整

sangwenwei 5 months ago
parent
commit
e564b456e6
12 changed files with 614 additions and 54 deletions
  1. 5 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/factory/WorkAttachmentApiFallbackFactory.java
  2. 10 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/feign/IWorkAttachmentApi.java
  3. 83 0
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/controller/updateOldData.java
  4. 21 0
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/domain/CcpmReimbursementAmountInfo.java
  5. 2 0
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/mapper/CcpmReimbursementInfoMapper.java
  6. 18 0
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/mapper/xml/CcpmReimbursementInfoMapper.xml
  7. 277 53
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/CcpmReimbursementInfoService.java
  8. 156 0
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/dto/CcpmReimAmountAndFileDto.java
  9. 1 1
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/dto/CcpmSaveInfoDto.java
  10. 9 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/controller/OssFileController.java
  11. 5 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/feign/WorkAttachmentApiImpl.java
  12. 27 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/service/OssService.java

+ 5 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/factory/WorkAttachmentApiFallbackFactory.java

@@ -131,6 +131,11 @@ public class WorkAttachmentApiFallbackFactory implements FallbackFactory <IWorkA
                 return null;
             }
 
+            @Override
+            public Map<String, String> disposeElectronicEngineeringInvoiceNumber(List<String> attachmentIdList, String type) {
+                return null;
+            }
+
         };
     }
 }

+ 10 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/feign/IWorkAttachmentApi.java

@@ -199,6 +199,16 @@ public interface IWorkAttachmentApi {
      */
     @RequestMapping(value = "/oss/file/disposeElectronicEngineeringInvoice", method = RequestMethod.GET)
     Map<String ,String > disposeElectronicEngineeringInvoice(@RequestParam(value = "attachmentIdList")List<String> attachmentIdList,@RequestParam(value = "type")String type);
+
+    /**
+     * 获取数电发票数据中的发票号信息
+     * @param attachmentIdList
+     * @param type
+     * @return
+     */
+    @RequestMapping(value = "/oss/file/disposeElectronicEngineeringInvoiceNumber", method = RequestMethod.GET)
+    Map<String ,String > disposeElectronicEngineeringInvoiceNumber(@RequestParam(value = "attachmentIdList")List<String> attachmentIdList,@RequestParam(value = "type")String type);
+
 }
 
 

+ 83 - 0
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/controller/updateOldData.java

@@ -0,0 +1,83 @@
+package com.jeeplus.ccpm.approvalInfo.controller;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.jeeplus.ccpm.approvalInfo.domain.CcpmReimbursementAmountInfo;
+import com.jeeplus.ccpm.approvalInfo.mapper.CcpmReimbursementAmountInfoMapper;
+import com.jeeplus.ccpm.approvalInfo.mapper.CcpmReimbursementInfoMapper;
+import com.jeeplus.ccpm.approvalInfo.service.dto.CcpmReimAmountAndFileDto;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
+import com.jeeplus.sys.feign.IUserApi;
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
+import com.jeeplus.utils.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class updateOldData {
+    @Resource
+    private CcpmReimbursementInfoMapper infoMapper;
+    @Resource
+    private CcpmReimbursementAmountInfoMapper amountInfoMapper;
+
+
+    @PostConstruct
+    public void init() {
+        executeFileProcessing();
+    }
+    @Transactional
+    public void executeFileProcessing() {
+        //查询所有的数电发票信息
+        LambdaQueryWrapper<CcpmReimbursementAmountInfo> invoiceReimbursementsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getReimbursementType, "1");
+        invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getDelFlag, "0");
+        List<CcpmReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
+        if (CollectionUtil.isNotEmpty(invoiceReimbursements)){
+            for (CcpmReimbursementAmountInfo invoiceReimbursement : invoiceReimbursements) {
+                // 查询附件信息
+                List<WorkAttachmentInfo> fileList = infoMapper.findReimFiles(invoiceReimbursement.getInfoId());
+                // 用于存储所有的 attachmentId
+                List<String> attachmentIds = new ArrayList<>();
+                if (CollectionUtil.isNotEmpty(fileList)) {
+                    // 首先收集所有的 attachmentId
+                    for (WorkAttachmentInfo workAttachmentInfo : fileList) {
+                        attachmentIds.add(workAttachmentInfo.getAttachmentId());
+                    }
+                    if (CollectionUtil.isNotEmpty(attachmentIds)) {
+                        Map<String, String> map = SpringUtil.getBean(IWorkAttachmentApi.class).disposeElectronicEngineeringInvoiceNumber(attachmentIds, "3");
+                        // 处理结果的逻辑
+                        if (map != null && !map.isEmpty()) {
+                            for (WorkAttachmentInfo workAttachmentInfo : fileList) {
+                                for (Map.Entry<String, String> entry : map.entrySet()) {
+                                    String key = entry.getKey();
+                                    String value = entry.getValue();
+
+                                    if (StringUtils.isNotBlank(value) && key.equals(invoiceReimbursement.getNumber())) {
+                                        // 如果 value 非空且 key 匹配,则执行修改操作
+                                        invoiceReimbursement.setFileUrl(workAttachmentInfo.getUrl());
+                                        invoiceReimbursement.setFileType(workAttachmentInfo.getType());
+                                        invoiceReimbursement.setAttachmentName(workAttachmentInfo.getName());
+                                        invoiceReimbursement.setAttachmentFlag("invoiceReimbursement");
+                                        invoiceReimbursement.setFileSize(workAttachmentInfo.getFileSize());
+                                        amountInfoMapper.updateById(invoiceReimbursement);
+
+                                    }
+
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

+ 21 - 0
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/domain/CcpmReimbursementAmountInfo.java

@@ -78,4 +78,25 @@ public class CcpmReimbursementAmountInfo extends BaseEntity {
      */
     private String remarks;
 
+    /**
+     * 对应附件url
+     */
+    private String fileUrl;
+    /**
+     * 文件类型-后缀名
+     */
+    private String fileType;
+    /**
+     * 文件名
+     */
+    private String attachmentName;
+    /**
+     * 文件所属业务模块
+     */
+    private String attachmentFlag;
+    /**
+     * 文件大小
+     */
+    private String fileSize;
+
 }

+ 2 - 0
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/mapper/CcpmReimbursementInfoMapper.java

@@ -74,4 +74,6 @@ public interface CcpmReimbursementInfoMapper extends BaseMapper<CcpmReimbursemen
     List<CcpmReimbursementAmountInfoDTO> getInvoiceReimbursementAmountList(@Param("idList") List<String> idList);
 
     void updatePaymentById(@Param("id") String id,@Param("paymentStatus") String paymentStatus);
+    @InterceptorIgnore(tenantLine = "true")
+    List<WorkAttachmentInfo> findReimFiles(@Param("infoId") String infoId);
 }

+ 18 - 0
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/mapper/xml/CcpmReimbursementInfoMapper.xml

@@ -188,6 +188,24 @@
 			del_flag = 0
 			AND attachment_id = #{id}
 	</select>
+	<select id="findReimFiles" resultType="com.jeeplus.sys.domain.WorkAttachmentInfo">
+		SELECT
+			id,
+			url,
+			type,
+			file_size as `fileSize`,
+			attachment_name AS `name`,
+			create_by_id AS `by`,
+			attachment_flag AS `attachmentFlag`,
+			attachment_id AS `attachmentId`,
+			create_time
+		FROM
+			work_attachment
+		WHERE
+			del_flag = 0
+			AND attachment_id = #{infoId} and attachment_flag = 'invoiceReimbursement'
+	</select>
+
 	<select id="findOfficeList"
 			resultType="com.jeeplus.ccpm.approvalInfo.service.dto.CcpmTreeUserDto">
 		SELECT id,`name`,parent_id FROM sys_office WHERE del_flag = 0

+ 277 - 53
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/CcpmReimbursementInfoService.java

@@ -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");
                     }
                 }
             }

+ 156 - 0
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/dto/CcpmReimAmountAndFileDto.java

@@ -0,0 +1,156 @@
+package com.jeeplus.ccpm.approvalInfo.service.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.sys.service.dto.UserDTO;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * 数电发票信息及附件
+ */
+@Data
+public class CcpmReimAmountAndFileDto extends BaseEntity {
+
+    /**
+     * 关联id
+     */
+    private String infoId;
+
+    /**
+     * 发票代码
+     */
+    private String code;
+
+    /**
+     * 发票编号
+     */
+    private String number;
+
+    /**
+     * 金额
+     */
+    private String amount;
+
+    /**
+     * 税额
+     */
+    private String taxAmount;
+
+    /**
+     * 价税合计
+     */
+    private String count;
+
+    /**
+     * 报销类型(0:普通报销;1:电子发票报销)
+     */
+    private String reimbursementType;
+
+    /**
+     * 发票类型(01:增值税发票;02:普通发票)
+     */
+    private String invoiceType;
+
+    /**
+     * 发票项目名
+     */
+    private String invoiceProjectName;
+
+    /**
+     * 开票时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+    private String invoiceDate;
+
+    /**
+     * 开票单位
+     */
+    private String invoiceUnit;
+
+    /**
+     * 购买方名称
+     */
+    private String buyerName;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
+     * 对应附件url
+     */
+    private String fileUrl;
+
+
+    /**
+     * 附件信息
+      */
+    private String by;
+
+    private UserDTO createBy;
+
+    private String name;
+
+    private String size;
+
+    /**
+     * 附件地址
+     */
+    private String url;
+
+    /**
+     * 文件类型(文件后缀名)
+     */
+    private String type;
+
+    /**
+     * 附件对应父节点id(记录是谁的id)
+     */
+    private String attachmentId;
+
+    /**
+     * 文件名
+     */
+    private String attachmentName;
+
+    /**
+     * 文件所属业务模块(数据字典配置)
+     */
+    private String attachmentFlag;
+
+    /**
+     * 所属模块子模块
+     */
+    private String moduleType;
+
+    /**
+     * 附件类型
+     */
+    private String attachmentType;
+
+    /**
+     * 附件大小
+     */
+    private String fileSize;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 文件描述
+     */
+    private String description;
+
+    /**
+     * 附件临时地址
+     *该属性不是实体字段
+     */
+    @TableField(exist = false)
+    private String temporaryUrl;
+}

+ 1 - 1
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/dto/CcpmSaveInfoDto.java

@@ -73,7 +73,7 @@ public class CcpmSaveInfoDto extends BaseEntity {
     private List<CcpmReimbursementAmountInfo> invoiceReimbursements;
 
     private List<WorkAttachmentInfo> files;
-    private List<WorkAttachmentInfo> invoiceReimbursementFiles;
+    private List<CcpmReimAmountAndFileDto> invoiceReimbursementFiles;
 
     /**
      * 报销类型

+ 9 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/controller/OssFileController.java

@@ -670,4 +670,13 @@ public class OssFileController {
 
         return map;
     }
+
+    @ApiOperation("获取数电发票数据中的发票号信息")
+    @GetMapping("/disposeElectronicEngineeringInvoiceNumber")
+    public Map<String,String> disposeElectronicEngineeringInvoiceNumber(@RequestParam List<String> attachmentIdList, @RequestParam String type){
+        //首先获取所有数电发票报销信息
+        Map<String, String> map = ossService.disposeElectronicEngineeringInvoiceNumber(attachmentIdList, type);
+
+        return map;
+    }
 }

+ 5 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/feign/WorkAttachmentApiImpl.java

@@ -129,4 +129,9 @@ public class WorkAttachmentApiImpl implements IWorkAttachmentApi {
         return null;
     }
 
+    @Override
+    public Map<String, String> disposeElectronicEngineeringInvoiceNumber(List<String> attachmentIdList, String type) {
+        return null;
+    }
+
 }

+ 27 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/service/OssService.java

@@ -723,4 +723,31 @@ public class OssService extends ServiceImpl<OssServiceMapper, WorkAttachment> {
         }
         return map;
     }
+
+    /**
+     *
+     * @param attachmentIdList
+     * @param type  代表处理类型,不同类型代表不同的分公司的报销数据:1、评估;2、会计;3、ccpm;4、中审;5、咨询
+     */
+    public Map<String,String> disposeElectronicEngineeringInvoiceNumber(List<String> attachmentIdList, String type){
+        Map<String,String> map = new HashMap<>();
+        //首先获取所有数电发票报销信息
+        List<WorkAttachmentInfo> attachmentList = ossServiceMapper.getElectronicEngineeringInvoiceAttachmentList(attachmentIdList,"");
+        //遍历所有附件发票信息,并将其下载到本地固定文件夹,并对下载的文件进行数据解析
+        try{
+            for (WorkAttachmentInfo attachmentInfo : attachmentList) {
+                if(attachmentInfo.getUrl().contains(".xml")){
+                    Map<String, Object> stringObjectMap = this.downLoadFileDisposeXmlFile(attachmentInfo.getUrl());
+                    String invoiceNumber = (String) stringObjectMap.get("InvoiceNumber");
+                    String buyerInformationBuyerName = (String) stringObjectMap.get("BuyerInformationBuyerName");
+                    if(StringUtils.isNotBlank(invoiceNumber) && StringUtils.isNotBlank(buyerInformationBuyerName)){
+                        map.put(invoiceNumber,invoiceNumber);
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.getMessage();
+        }
+        return map;
+    }
 }