sangwenwei пре 6 месеци
родитељ
комит
51b80445f2
41 измењених фајлова са 2586 додато и 280 уклоњено
  1. 5 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/AssessApiFallbackFactory.java
  2. 24 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/ConsultApiFallbackFactory.java
  3. 5 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/FinanceApiFallbackFactory.java
  4. 24 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/ZsApiFallbackFactory.java
  5. 7 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IAssessApi.java
  6. 21 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IConsultApi.java
  7. 6 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IFinanceApi.java
  8. 20 0
      jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IZsApi.java
  9. 8 0
      jeeplus-common/jeeplus-common-core/src/main/java/com/jeeplus/common/constant/AppNameConstants.java
  10. 10 0
      jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/controller/ReimbursementInfoController.java
  11. 22 0
      jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/domain/ReimbursementAmountInfo.java
  12. 4 0
      jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/mapper/ReimbursementInfoMapper.java
  13. 18 0
      jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/mapper/xml/ReimbursementInfoMapper.xml
  14. 369 64
      jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/service/ReimbursementInfoService.java
  15. 161 0
      jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/service/dto/ReimAmountAndFileDto.java
  16. 1 1
      jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/service/dto/SaveInfoDto.java
  17. 54 16
      jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/CcpmReimbursementInfoService.java
  18. 10 0
      jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/controller/ZsReimbursementInfoController.java
  19. 22 0
      jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/domain/ZsReimbursementAmountInfo.java
  20. 4 0
      jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/mapper/ZsReimbursementInfoMapper.java
  21. 18 0
      jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/mapper/xml/ZsReimbursementInfoMapper.xml
  22. 369 64
      jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/service/ZsReimbursementInfoService.java
  23. 161 0
      jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/service/dto/ZsReimAmountAndFileDto.java
  24. 1 1
      jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/service/dto/ZsSaveInfoDto.java
  25. 9 0
      jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/controller/ConsultancyReimbursementInfoController.java
  26. 22 0
      jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/domain/ConsultancyReimbursementAmountInfo.java
  27. 4 0
      jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/mapper/ConsultancyReimbursementInfoMapper.java
  28. 18 0
      jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/mapper/xml/ConsultancyReimbursementInfoMapper.xml
  29. 373 68
      jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/service/ConsultancyReimbursementInfoService.java
  30. 161 0
      jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/service/dto/ConsultancyReimAmountAndFileDto.java
  31. 1 1
      jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/service/dto/ConsultancySaveInfoDto.java
  32. 9 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/controller/CwReimbursementInfoController.java
  33. 21 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/domain/CwReimbursementAmountInfo.java
  34. 2 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/mapper/CwReimbursementInfoMapper.java
  35. 18 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/mapper/xml/CwReimbursementInfoMapper.xml
  36. 371 64
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/service/CwReimbursementInfoService.java
  37. 161 0
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/service/dto/CwReimAmountAndFileDto.java
  38. 1 1
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/service/dto/SaveInfoDto.java
  39. 14 0
      jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/feign/ConsultancyFeignApi.java
  40. 14 0
      jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/feign/ZsFeignApi.java
  41. 43 0
      jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java

+ 5 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/AssessApiFallbackFactory.java

@@ -49,6 +49,11 @@ public class AssessApiFallbackFactory implements FallbackFactory<IAssessApi> {
                 return null;
             }
 
+            @Override
+            public String updateOldData() {
+                return null;
+            }
+
 
         };
     }

+ 24 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/ConsultApiFallbackFactory.java

@@ -0,0 +1,24 @@
+package com.jeeplus.flowable.factory;
+
+import com.jeeplus.flowable.feign.IConsultApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * 项目降级处理
+ */
+@Slf4j
+@Component
+public class ConsultApiFallbackFactory implements FallbackFactory<IConsultApi> {
+    @Override
+    public IConsultApi create(Throwable cause) {
+        log.error ( "财务服务调用失败:{}", cause.getMessage ( ) );
+        return new IConsultApi() {
+            @Override
+            public void updateOldData() {
+
+            }
+        };
+    }
+}

+ 5 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/FinanceApiFallbackFactory.java

@@ -62,6 +62,11 @@ public class FinanceApiFallbackFactory implements FallbackFactory<IFinanceApi> {
                 return null;
             }
 
+            @Override
+            public void updateOldData() {
+
+            }
+
         };
     }
 }

+ 24 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/factory/ZsApiFallbackFactory.java

@@ -0,0 +1,24 @@
+package com.jeeplus.flowable.factory;
+
+import com.jeeplus.flowable.feign.IZsApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+/**
+ * 项目降级处理
+ */
+@Slf4j
+@Component
+public class ZsApiFallbackFactory implements FallbackFactory<IZsApi> {
+    @Override
+    public IZsApi create(Throwable cause) {
+        log.error ( "财务服务调用失败:{}", cause.getMessage ( ) );
+        return new IZsApi() {
+            @Override
+            public void updateOldData() {
+
+            }
+        };
+    }
+}

+ 7 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IAssessApi.java

@@ -55,4 +55,11 @@ public interface IAssessApi {
     @GetMapping(value = "/finance/invoice/getExceedFinance")
     String getExceedFinance();
 
+
+    /**
+     * 修改数电发票报销数据
+     */
+    @GetMapping(value = "/reimbursement/info/updateOldData")
+    String updateOldData();
+
 }

+ 21 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IConsultApi.java

@@ -0,0 +1,21 @@
+package com.jeeplus.flowable.feign;
+
+import com.jeeplus.common.constant.AppNameConstants;
+import com.jeeplus.flowable.factory.ConsultApiFallbackFactory;
+import com.jeeplus.flowable.factory.ZsApiFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+
+/**
+ * @author: 王强
+ * @create: 2023-07-26 17:01
+ **/
+@FeignClient(contextId = "consultApi", name = AppNameConstants.APP_CONSULT_MODULES, fallbackFactory = ConsultApiFallbackFactory.class)
+public interface IConsultApi {
+
+    /**
+     * 修改数电发票报销数据
+     */
+    @GetMapping(value = "/consultancyReimbursement/info/updateOldData")
+    void updateOldData();
+}

+ 6 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IFinanceApi.java

@@ -57,4 +57,10 @@ public interface IFinanceApi {
     @GetMapping(value = "/reimbursementApproval/info/getCwProjectNameByIds")
     String getCwProjectNameByIds(@RequestParam(value = "ids") String ids);
 
+    /**
+     * 修改数电发票报销数据
+     */
+    @GetMapping(value = "/reimbursementApproval/info/updateOldData")
+    void updateOldData();
+
 }

+ 20 - 0
jeeplus-api/jeeplus-system-api/src/main/java/com/jeeplus/flowable/feign/IZsApi.java

@@ -0,0 +1,20 @@
+package com.jeeplus.flowable.feign;
+
+import com.jeeplus.common.constant.AppNameConstants;
+import com.jeeplus.flowable.factory.ZsApiFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+
+/**
+ * @author: 王强
+ * @create: 2023-07-26 17:01
+ **/
+@FeignClient(contextId = "zsApi", name = AppNameConstants.APP_CENTRECAREFUL_MODULES, fallbackFactory = ZsApiFallbackFactory.class)
+public interface IZsApi {
+
+    /**
+     * 修改数电发票报销数据
+     */
+    @GetMapping(value = "/zsReimbursement/info/updateOldData")
+    void updateOldData();
+}

+ 8 - 0
jeeplus-common/jeeplus-common-core/src/main/java/com/jeeplus/common/constant/AppNameConstants.java

@@ -37,4 +37,12 @@ public interface AppNameConstants {
      * 项目模块
      */
     String APP_CCPM_MODULES = "jeeplus-ccpm";
+    /**
+     * 中审模块
+     */
+    String APP_CENTRECAREFUL_MODULES = "jeeplus-centrecareful";
+    /**
+     * 培训模块
+     */
+    String APP_CONSULT_MODULES = "jeeplus-consultancy";
 }

+ 10 - 0
jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/controller/ReimbursementInfoController.java

@@ -405,4 +405,14 @@ public class ReimbursementInfoController {
         service.updateFileStatusById(dto);
     }
 
+
+
+    /**
+     * 修改数电发票报销数据(对老数据进行调整)
+     */
+    @ApiOperation(value = "修改数电发票报销数据(对老数据进行调整)")
+    @GetMapping(value = "updateOldData")
+    public void updateOldData(){
+        service.updateOldData();
+    }
 }

+ 22 - 0
jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/domain/ReimbursementAmountInfo.java

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

+ 4 - 0
jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/mapper/ReimbursementInfoMapper.java

@@ -109,4 +109,8 @@ public interface ReimbursementInfoMapper extends BaseMapper<ReimbursementInfo> {
     void updatePaymentById(@Param("id") String id,@Param("paymentStatus") String paymentStatus);
     @InterceptorIgnore(tenantLine = "true")
     List<TreeUserDto> findZhglgsUserList3(@Param("name")String name, @Param("officeId")String officeId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<WorkAttachmentInfo> findReimFiles(@Param("infoId") String infoId,@Param("attachmentFlag") String attachmentFlag);
+
 }

+ 18 - 0
jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/mapper/xml/ReimbursementInfoMapper.xml

@@ -530,4 +530,22 @@
 		</where>
 	</delete>
 
+	<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 = #{attachmentFlag}
+	</select>
+
 </mapper>

+ 369 - 64
jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/service/ReimbursementInfoService.java

@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.jeeplus.assess.reimbursement.reimbursementInfo.service.dto.*;
+import com.jeeplus.assess.workContract.mapper.WorkContractInfoMapper;
 import com.jeeplus.common.TokenProvider;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.flowable.feign.IFlowableApi;
@@ -41,6 +42,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
@@ -96,6 +98,9 @@ public class ReimbursementInfoService {
 
     @Resource
     private ReimbursementFileSupplementMapper reimbursementFileSupplementMapper;
+
+    @Resource
+    private WorkContractInfoMapper mapper;
     /**
      * 列表查询
      */
@@ -385,21 +390,35 @@ public class ReimbursementInfoService {
                 amountInfoMapper.delete(deleteInfo);
             }else if("1".equals(dto.getReimbursementType())){
                 // 保存电子发票列表信息
-                if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                    for (ReimbursementAmountInfo 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 (ReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                        if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                            ReimbursementAmountInfo reimbursementAmountInfo = new ReimbursementAmountInfo();
+                            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);
+                        }
+
                     }
                 }
                 //清除专用发票信息
@@ -410,7 +429,7 @@ public class ReimbursementInfoService {
 
                 // 保存电子发票附件列表信息
                 if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                    workContractService.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
+                    this.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
                 }
             }
         }
@@ -421,6 +440,50 @@ public class ReimbursementInfoService {
         return info;
     }
 
+
+    /**
+     * 保存附件信息
+     * @param list 待保存的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void saveFiles(List<ReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
+        int j = 1;
+        for (ReimAmountAndFileDto 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 ReimbursementInfo update(SaveInfoDto dto, UserDTO userDTO) throws Exception {
         boolean admin = userDTO.isAdmin();
         //判断当前登录人是否是管理员,管理员修改时需要生成一条历史记录
@@ -561,21 +624,35 @@ public class ReimbursementInfoService {
                 amountInfoMapper.delete(deleteInfo);
             }else if("1".equals(dto.getReimbursementType())){
                 // 保存电子发票列表信息
-                if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                    for (ReimbursementAmountInfo 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 (ReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                        if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                            ReimbursementAmountInfo reimbursementAmountInfo = new ReimbursementAmountInfo();
+                            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);
+                        }
+
                     }
                 }
                 //清除专用发票信息
@@ -587,7 +664,7 @@ public class ReimbursementInfoService {
 
                 // 保存电子发票附件列表信息
                 if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                    workContractService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
+                    this.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
                 }
             }
         }
@@ -614,6 +691,71 @@ public class ReimbursementInfoService {
         return info;
     }
 
+
+    /**
+     * 修改附件信息
+     * @param list 待修改的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateFiles(List<ReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
+        int j = 1;
+        String names = new String();
+        //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
+        for (ReimAmountAndFileDto 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 (ReimAmountAndFileDto 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);
@@ -686,28 +828,82 @@ public class ReimbursementInfoService {
             invoiceReimbursementsLambdaQueryWrapper.eq(ReimbursementAmountInfo::getInfoId, id);
             invoiceReimbursementsLambdaQueryWrapper.eq(ReimbursementAmountInfo::getReimbursementType, "1");
             List<ReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
-            dto.setInvoiceReimbursements(invoiceReimbursements);
+//            dto.setInvoiceReimbursements(invoiceReimbursements);
             // 查询附件信息
             List<WorkAttachmentInfo> fileList = infoMapper.findFiles(id);
             List<WorkAttachmentInfo> files = Lists.newArrayList();
-            List<WorkAttachmentInfo> invoiceReimbursementFiles = Lists.newArrayList();
+            Set<ReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>(); // 使用 Set 去重
 
             if (CollectionUtils.isNotEmpty(fileList)) {
+                // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
+                Map<String, ReimbursementAmountInfo> reimbursementMap = new HashMap<>();
+                for (ReimbursementAmountInfo 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())) {
+                        ReimbursementAmountInfo 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 (ReimbursementAmountInfo reimbursement : invoiceReimbursements) {
+                                        String key = entry.getKey();
+                                        String value = entry.getValue();
+                                        if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
+                                            ReimAmountAndFileDto ccpmReimAmountAndFileDto = new ReimAmountAndFileDto();
+                                            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<ReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
+            dto.setInvoiceReimbursementFiles(uniqueFilesList);
         }
         return dto;
     }
 
+    // 针对 URL 匹配的文件进行处理的提取方法
+    private void processMatchingFiles(WorkAttachmentInfo i, ReimbursementAmountInfo invoiceReimbursement, Set<ReimAmountAndFileDto> invoiceReimbursementFiles) {
+        ReimAmountAndFileDto ccpmReimAmountAndFileDto = new ReimAmountAndFileDto();
+        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<ReimbursementAmountInfo> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(ReimbursementAmountInfo::getNumber, number);
@@ -1465,24 +1661,62 @@ public class ReimbursementInfoService {
             invoiceReimbursementsLambdaQueryWrapper.eq(ReimbursementAmountInfo::getInfoId, reimId);
             invoiceReimbursementsLambdaQueryWrapper.eq(ReimbursementAmountInfo::getReimbursementType, "1");
             List<ReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
-            dto.setInvoiceReimbursements(invoiceReimbursements);
+//            dto.setInvoiceReimbursements(invoiceReimbursements);
             // 查询附件信息
             List<WorkAttachmentInfo> fileList = infoMapper.findFiles(reimId);
             List<WorkAttachmentInfo> files = Lists.newArrayList();
-            List<WorkAttachmentInfo> invoiceReimbursementFiles = Lists.newArrayList();
+            Set<ReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>(); // 使用 Set 去重
 
             if (CollectionUtils.isNotEmpty(fileList)) {
+                // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
+                Map<String, ReimbursementAmountInfo> reimbursementMap = new HashMap<>();
+                for (ReimbursementAmountInfo 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())) {
+                        ReimbursementAmountInfo 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 (ReimbursementAmountInfo reimbursement : invoiceReimbursements) {
+                                        String key = entry.getKey();
+                                        String value = entry.getValue();
+                                        if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
+                                            ReimAmountAndFileDto ccpmReimAmountAndFileDto = new ReimAmountAndFileDto();
+                                            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<ReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
+            dto.setInvoiceReimbursementFiles(uniqueFilesList);
         }
         return dto;
     }
@@ -1533,21 +1767,35 @@ public class ReimbursementInfoService {
                     amountInfoMapper.delete(deleteInfo);
                 }else if("1".equals(dto.getReimbursementType())){
                     // 保存电子发票列表信息
-                    if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                        for (ReimbursementAmountInfo 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 (ReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                            if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                                ReimbursementAmountInfo reimbursementAmountInfo = new ReimbursementAmountInfo();
+                                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);
+                            }
+
                         }
                     }
                     //清除专用发票信息
@@ -1559,7 +1807,7 @@ public class ReimbursementInfoService {
 
                     // 保存电子发票附件列表信息
                     if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                        workContractService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
+                        this.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
                     }
                 }
             }
@@ -1611,4 +1859,61 @@ public class ReimbursementInfoService {
         reimbursementFileSupplementMapper.updateFileStatusById(dto.getFileSuppleId(),dto.getFileStatus());
     }
 
+
+    /**
+     * 修改数电发票报销数据(对老数据进行调整)
+     */
+    public void updateOldData() {
+        try {
+            Set<String> infoIds = new HashSet<>(); // 使用 Set 去重
+
+            // 查询所有的数电发票信息
+            LambdaQueryWrapper<ReimbursementAmountInfo> invoiceReimbursementsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            invoiceReimbursementsLambdaQueryWrapper.eq(ReimbursementAmountInfo::getReimbursementType, "1");
+            invoiceReimbursementsLambdaQueryWrapper.eq(ReimbursementAmountInfo::getDelFlag, "0");
+            invoiceReimbursementsLambdaQueryWrapper.orderByDesc(ReimbursementAmountInfo::getCreateTime);
+            List<ReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
+
+            if (CollectionUtil.isNotEmpty(invoiceReimbursements)) {
+                // 将所有的报销id进行存储
+                for (ReimbursementAmountInfo 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 (ReimbursementAmountInfo 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();
+        }
+    }
+
 }

+ 161 - 0
jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/service/dto/ReimAmountAndFileDto.java

@@ -0,0 +1,161 @@
+package com.jeeplus.assess.reimbursement.reimbursementInfo.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 ReimAmountAndFileDto 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;
+
+    /*8
+    数电发票id
+     */
+    private String amountId;
+}

+ 1 - 1
jeeplus-modules/jeeplus-assess/src/main/java/com/jeeplus/assess/reimbursement/reimbursementInfo/service/dto/SaveInfoDto.java

@@ -73,7 +73,7 @@ public class SaveInfoDto extends BaseEntity {
     private List<ReimbursementAmountInfo> invoiceReimbursements;
 
     private List<WorkAttachmentInfo> files;
-    private List<WorkAttachmentInfo> invoiceReimbursementFiles; //电子发票报销
+    private List<ReimAmountAndFileDto> invoiceReimbursementFiles; //电子发票报销
     /**
      * 报销类型
      */

+ 54 - 16
jeeplus-modules/jeeplus-ccpm/src/main/java/com/jeeplus/ccpm/approvalInfo/service/CcpmReimbursementInfoService.java

@@ -1183,7 +1183,7 @@ public class CcpmReimbursementInfoService {
             invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getInfoId, reimId);
             invoiceReimbursementsLambdaQueryWrapper.eq(CcpmReimbursementAmountInfo::getReimbursementType, "1");
             List<CcpmReimbursementAmountInfo> 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();
@@ -1197,6 +1197,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) {
@@ -1206,6 +1211,25 @@ public class CcpmReimbursementInfoService {
                         if (invoiceReimbursement != null) {
                             // 处理有 URL 匹配的文件
                             processMatchingFiles(i, invoiceReimbursement, invoiceReimbursementFiles);
+                        }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 {
                         // 处理其他文件
@@ -1267,21 +1291,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);
+                            }
+
                         }
                     }
                     //清除专用发票信息

+ 10 - 0
jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/controller/ZsReimbursementInfoController.java

@@ -423,4 +423,14 @@ public class ZsReimbursementInfoController {
     }
 
 
+
+    /**
+     * 修改数电发票报销数据(对老数据进行调整)
+     */
+    @ApiOperation(value = "修改数电发票报销数据(对老数据进行调整)")
+    @GetMapping(value = "updateOldData")
+    public void updateOldData(){
+        service.updateOldData();
+    }
+
 }

+ 22 - 0
jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/domain/ZsReimbursementAmountInfo.java

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

+ 4 - 0
jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/mapper/ZsReimbursementInfoMapper.java

@@ -81,4 +81,8 @@ public interface ZsReimbursementInfoMapper extends BaseMapper<ZsReimbursementInf
     String findUserById(@Param("projectUser") String projectUser);
     @InterceptorIgnore(tenantLine = "true")
     String findOfficeById(@Param("projectOffice")String projectOffice);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<WorkAttachmentInfo> findReimFiles(@Param("infoId") String infoId,@Param("attachmentFlag") String attachmentFlag);
+
 }

+ 18 - 0
jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/mapper/xml/ZsReimbursementInfoMapper.xml

@@ -690,4 +690,22 @@
 		select name from sys_office where id = #{projectOffice}
 	</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 = #{attachmentFlag}
+	</select>
+
 </mapper>

+ 369 - 64
jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/service/ZsReimbursementInfoService.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.centrecareful.approvalType.mapper.ZsReimbursementTypeMapper;
 import com.jeeplus.centrecareful.approvalType.service.ZsReimbursementTypeService;
 import com.jeeplus.common.TokenProvider;
 import com.jeeplus.centrecareful.approvalInfo.domain.*;
@@ -31,6 +32,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import com.baomidou.mybatisplus.*;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -87,6 +89,9 @@ public class ZsReimbursementInfoService {
     @Resource
     private ZsReimbursementFileSupplementMapper zsReimbursementFileSupplementMapper;
 
+    @Resource
+    private ZsReimbursementTypeMapper mapper;
+
     /**
      * 报告号查询
      */
@@ -374,21 +379,35 @@ public class ZsReimbursementInfoService {
                 amountInfoMapper.delete(deleteInfo);
             }else if("1".equals(dto.getReimbursementType())){
                 // 保存电子发票列表信息
-                if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                    for (ZsReimbursementAmountInfo 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 (ZsReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                        if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                            ZsReimbursementAmountInfo reimbursementAmountInfo = new ZsReimbursementAmountInfo();
+                            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);
+                        }
+
                     }
                 }
                 //清除专用发票信息
@@ -399,7 +418,7 @@ public class ZsReimbursementInfoService {
 
                 // 保存电子发票附件列表信息
                 if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                    typeService.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
+                    saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
                 }
             }
         }
@@ -410,6 +429,50 @@ public class ZsReimbursementInfoService {
         return info;
     }
 
+
+    /**
+     * 保存附件信息
+     * @param list 待保存的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void saveFiles(List<ZsReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
+        int j = 1;
+        for (ZsReimAmountAndFileDto 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 ZsReimbursementInfo update(ZsSaveInfoDto dto, UserDTO userDTO) {
         boolean admin = userDTO.isAdmin();
         //判断当前登录人是否是管理员,管理员修改时需要生成一条历史记录
@@ -545,21 +608,35 @@ public class ZsReimbursementInfoService {
                 amountInfoMapper.delete(deleteInfo);
             }else if("1".equals(dto.getReimbursementType())){
                 // 保存电子发票列表信息
-                if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                    for (ZsReimbursementAmountInfo 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 (ZsReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                        if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                            ZsReimbursementAmountInfo reimbursementAmountInfo = new ZsReimbursementAmountInfo();
+                            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);
+                        }
+
                     }
                 }
                 //清除专用发票信息
@@ -570,7 +647,7 @@ public class ZsReimbursementInfoService {
 
                 // 保存电子发票附件列表信息
                 if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                    typeService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
+                    updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
                 }
             }
         }
@@ -596,6 +673,71 @@ public class ZsReimbursementInfoService {
         return info;
     }
 
+
+    /**
+     * 修改附件信息
+     * @param list 待修改的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateFiles(List<ZsReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
+        int j = 1;
+        String names = new String();
+        //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
+        for (ZsReimAmountAndFileDto 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 (ZsReimAmountAndFileDto 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);
@@ -697,28 +839,83 @@ public class ZsReimbursementInfoService {
             invoiceReimbursementsLambdaQueryWrapper.eq(ZsReimbursementAmountInfo::getInfoId, id);
             invoiceReimbursementsLambdaQueryWrapper.eq(ZsReimbursementAmountInfo::getReimbursementType, "1");
             List<ZsReimbursementAmountInfo> 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<ZsReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>(); // 使用 Set 去重
 
             if (CollectionUtils.isNotEmpty(fileList)) {
+                // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
+                Map<String, ZsReimbursementAmountInfo> reimbursementMap = new HashMap<>();
+                for (ZsReimbursementAmountInfo 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())) {
+                        ZsReimbursementAmountInfo 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 (ZsReimbursementAmountInfo reimbursement : invoiceReimbursements) {
+                                        String key = entry.getKey();
+                                        String value = entry.getValue();
+                                        if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
+                                            ZsReimAmountAndFileDto ccpmReimAmountAndFileDto = new ZsReimAmountAndFileDto();
+                                            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<ZsReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
+            dto.setInvoiceReimbursementFiles(uniqueFilesList);
         }
         return dto;
     }
 
+
+    // 针对 URL 匹配的文件进行处理的提取方法
+    private void processMatchingFiles(WorkAttachmentInfo i, ZsReimbursementAmountInfo invoiceReimbursement, Set<ZsReimAmountAndFileDto> invoiceReimbursementFiles) {
+        ZsReimAmountAndFileDto ccpmReimAmountAndFileDto = new ZsReimAmountAndFileDto();
+        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<ZsReimbursementAmountInfo> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(ZsReimbursementAmountInfo::getNumber, number);
@@ -1021,24 +1218,62 @@ public class ZsReimbursementInfoService {
             invoiceReimbursementsLambdaQueryWrapper.eq(ZsReimbursementAmountInfo::getInfoId, reimId);
             invoiceReimbursementsLambdaQueryWrapper.eq(ZsReimbursementAmountInfo::getReimbursementType, "1");
             List<ZsReimbursementAmountInfo> 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<ZsReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>(); // 使用 Set 去重
 
             if (CollectionUtils.isNotEmpty(fileList)) {
+                // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
+                Map<String, ZsReimbursementAmountInfo> reimbursementMap = new HashMap<>();
+                for (ZsReimbursementAmountInfo 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())) {
+                        ZsReimbursementAmountInfo 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 (ZsReimbursementAmountInfo reimbursement : invoiceReimbursements) {
+                                        String key = entry.getKey();
+                                        String value = entry.getValue();
+                                        if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
+                                            ZsReimAmountAndFileDto ccpmReimAmountAndFileDto = new ZsReimAmountAndFileDto();
+                                            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<ZsReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
+            dto.setInvoiceReimbursementFiles(uniqueFilesList);
         }
         return dto;
     }
@@ -1089,21 +1324,35 @@ public class ZsReimbursementInfoService {
                     amountInfoMapper.delete(deleteInfo);
                 }else if("1".equals(dto.getReimbursementType())){
                     // 保存电子发票列表信息
-                    if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                        for (ZsReimbursementAmountInfo 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 (ZsReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                            if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                                ZsReimbursementAmountInfo reimbursementAmountInfo = new ZsReimbursementAmountInfo();
+                                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);
+                            }
+
                         }
                     }
                     //清除专用发票信息
@@ -1114,7 +1363,7 @@ public class ZsReimbursementInfoService {
 
                     // 保存电子发票附件列表信息
                     if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                        typeService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
+                        updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
                     }
                 }
             }
@@ -1166,4 +1415,60 @@ public class ZsReimbursementInfoService {
         zsReimbursementFileSupplementMapper.updateFileStatusById(dto.getFileSuppleId(),dto.getFileStatus());
     }
 
+
+    /**
+     * 修改数电发票报销数据(对老数据进行调整)
+     */
+    public void updateOldData() {
+        try {
+            Set<String> infoIds = new HashSet<>(); // 使用 Set 去重
+
+            // 查询所有的数电发票信息
+            LambdaQueryWrapper<ZsReimbursementAmountInfo> invoiceReimbursementsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            invoiceReimbursementsLambdaQueryWrapper.eq(ZsReimbursementAmountInfo::getReimbursementType, "1");
+            invoiceReimbursementsLambdaQueryWrapper.eq(ZsReimbursementAmountInfo::getDelFlag, "0");
+            invoiceReimbursementsLambdaQueryWrapper.orderByDesc(ZsReimbursementAmountInfo::getCreateTime);
+            List<ZsReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
+
+            if (CollectionUtil.isNotEmpty(invoiceReimbursements)) {
+                // 将所有的报销id进行存储
+                for (ZsReimbursementAmountInfo 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 (ZsReimbursementAmountInfo 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();
+        }
+    }
 }

+ 161 - 0
jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/service/dto/ZsReimAmountAndFileDto.java

@@ -0,0 +1,161 @@
+package com.jeeplus.centrecareful.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 ZsReimAmountAndFileDto 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;
+
+    /*8
+    数电发票id
+     */
+    private String amountId;
+}

+ 1 - 1
jeeplus-modules/jeeplus-centrecareful/src/main/java/com/jeeplus/centrecareful/approvalInfo/service/dto/ZsSaveInfoDto.java

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

+ 9 - 0
jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/controller/ConsultancyReimbursementInfoController.java

@@ -422,4 +422,13 @@ public class ConsultancyReimbursementInfoController {
         service.updateFileStatusById(dto);
     }
 
+
+    /**
+     * 修改数电发票报销数据(对老数据进行调整)
+     */
+    @ApiOperation(value = "修改数电发票报销数据(对老数据进行调整)")
+    @GetMapping(value = "updateOldData")
+    public void updateOldData(){
+        service.updateOldData();
+    }
 }

+ 22 - 0
jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/domain/ConsultancyReimbursementAmountInfo.java

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

+ 4 - 0
jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/mapper/ConsultancyReimbursementInfoMapper.java

@@ -74,4 +74,8 @@ public interface ConsultancyReimbursementInfoMapper extends BaseMapper<Consultan
     List<ConsultancyReimbursementAmountInfoDTO> 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,@Param("attachmentFlag") String attachmentFlag);
+
 }

+ 18 - 0
jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/mapper/xml/ConsultancyReimbursementInfoMapper.xml

@@ -724,4 +724,22 @@ WHERE
 		</where>
 	</delete>
 
+	<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 = #{attachmentFlag}
+	</select>
+
 </mapper>

+ 373 - 68
jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/service/ConsultancyReimbursementInfoService.java

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

+ 161 - 0
jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/service/dto/ConsultancyReimAmountAndFileDto.java

@@ -0,0 +1,161 @@
+package com.jeeplus.consultancy.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 ConsultancyReimAmountAndFileDto 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;
+
+    /*8
+    数电发票id
+     */
+    private String amountId;
+}

+ 1 - 1
jeeplus-modules/jeeplus-consult/src/main/java/com/jeeplus/consultancy/approvalInfo/service/dto/ConsultancySaveInfoDto.java

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

+ 9 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/controller/CwReimbursementInfoController.java

@@ -554,6 +554,15 @@ public class CwReimbursementInfoController {
     }
 
 
+    /**
+     * 修改数电发票报销数据(对老数据进行调整)
+     */
+    @ApiOperation(value = "修改数电发票报销数据(对老数据进行调整)")
+    @GetMapping(value = "updateOldData")
+    public void updateOldData(){
+        service.updateOldData();
+    }
+
 
 
 }

+ 21 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/domain/CwReimbursementAmountInfo.java

@@ -77,4 +77,25 @@ public class CwReimbursementAmountInfo 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-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/mapper/CwReimbursementInfoMapper.java

@@ -85,5 +85,7 @@ public interface CwReimbursementInfoMapper extends BaseMapper<CwReimbursementInf
 
     void updateCwReimbursementAmountInfo(@Param("number") String number,@Param("buyerName") String buyerName,@Param("type") String type);
 
+    @InterceptorIgnore(tenantLine = "true")
+    List<WorkAttachmentInfo> findReimFiles(@Param("infoId") String infoId,@Param("attachmentFlag") String attachmentFlag);
 
 }

+ 18 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/mapper/xml/CwReimbursementInfoMapper.xml

@@ -737,4 +737,22 @@ select
 		set buyer_name = #{buyerName}
 		where number = #{number}
 	</update>
+
+	<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 = #{attachmentFlag}
+	</select>
 </mapper>

+ 371 - 64
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/service/CwReimbursementInfoService.java

@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.common.TokenProvider;
 import com.jeeplus.core.query.QueryWrapperGenerator;
+import com.jeeplus.finance.contractRegistration.mapper.ContractInfoMapper;
 import com.jeeplus.finance.contractRegistration.service.ContractInfoService;
 import com.jeeplus.finance.projectRecords.domain.CwProjectRecords;
 import com.jeeplus.finance.projectRecords.service.CwProjectRecordsService;
@@ -92,6 +93,9 @@ public class CwReimbursementInfoService {
     @Resource
     private CwReimbursementFileSupplementMapper cwReimbursementFileSupplementMapper;
 
+    @Resource
+    private ContractInfoMapper mapper;
+
     /**
      * 报告号查询
      */
@@ -595,21 +599,35 @@ public class CwReimbursementInfoService {
                 amountInfoMapper.delete(deleteInfo);
             }else if("1".equals(dto.getReimbursementType())){
                 // 保存电子发票列表信息
-                if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                    for (CwReimbursementAmountInfo 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 (CwReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                        if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                            CwReimbursementAmountInfo reimbursementAmountInfo = new CwReimbursementAmountInfo();
+                            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);
+                        }
+
                     }
                 }
                 //清除专用发票信息
@@ -620,7 +638,7 @@ public class CwReimbursementInfoService {
 
                 // 保存电子发票附件列表信息
                 if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                    infoService.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
+                    this.saveFiles(dto.getInvoiceReimbursementFiles(), userDTO, id,"invoiceReimbursement");
                 }
             }
         }
@@ -631,6 +649,50 @@ public class CwReimbursementInfoService {
         return info;
     }
 
+
+    /**
+     * 保存附件信息
+     * @param list 待保存的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void saveFiles(List<CwReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
+        int j = 1;
+        for (CwReimAmountAndFileDto 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 CwReimbursementInfo update(SaveInfoDto dto, UserDTO userDTO) {
         boolean admin = userDTO.isAdmin();
         //判断当前登录人是否是管理员,管理员修改时需要生成一条历史记录
@@ -789,21 +851,35 @@ public class CwReimbursementInfoService {
                 amountInfoMapper.delete(deleteInfo);
             }else if("1".equals(dto.getReimbursementType())){
                 // 保存电子发票列表信息
-                if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                    for (CwReimbursementAmountInfo 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 (CwReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                        if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                            CwReimbursementAmountInfo reimbursementAmountInfo = new CwReimbursementAmountInfo();
+                            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);
+                        }
+
                     }
                 }
                 //清除专用发票信息
@@ -814,7 +890,7 @@ public class CwReimbursementInfoService {
 
                 // 保存电子发票附件列表信息
                 if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                    infoService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
+                    this.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
                 }
             }
         }
@@ -825,6 +901,71 @@ public class CwReimbursementInfoService {
         return info;
     }
 
+
+    /**
+     * 修改附件信息
+     * @param list 待修改的附件列表
+     * @param userDTO 当前登录用户
+     * @param id 关联id
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void updateFiles(List<CwReimAmountAndFileDto> list, UserDTO userDTO, String id, String attachmentFlag) {
+        int j = 1;
+        String names = new String();
+        //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
+        for (CwReimAmountAndFileDto 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 (CwReimAmountAndFileDto 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);
@@ -938,28 +1079,84 @@ public class CwReimbursementInfoService {
             invoiceReimbursementsLambdaQueryWrapper.eq(CwReimbursementAmountInfo::getInfoId, id);
             invoiceReimbursementsLambdaQueryWrapper.eq(CwReimbursementAmountInfo::getReimbursementType, "1");
             List<CwReimbursementAmountInfo> 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<CwReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>();
 
             if (CollectionUtils.isNotEmpty(fileList)) {
+                // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
+                Map<String, CwReimbursementAmountInfo> reimbursementMap = new HashMap<>();
+                for (CwReimbursementAmountInfo 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())) {
+                        CwReimbursementAmountInfo 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 (CwReimbursementAmountInfo reimbursement : invoiceReimbursements) {
+                                        String key = entry.getKey();
+                                        String value = entry.getValue();
+                                        if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
+                                            CwReimAmountAndFileDto ccpmReimAmountAndFileDto = new CwReimAmountAndFileDto();
+                                            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<CwReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
+            dto.setInvoiceReimbursementFiles(uniqueFilesList);
         }
         return dto;
     }
 
+    // 针对 URL 匹配的文件进行处理的提取方法
+    private void processMatchingFiles(WorkAttachmentInfo i, CwReimbursementAmountInfo invoiceReimbursement, Set<CwReimAmountAndFileDto> invoiceReimbursementFiles) {
+        CwReimAmountAndFileDto ccpmReimAmountAndFileDto = new CwReimAmountAndFileDto();
+        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);
+    }
+
+
     /**
      * 根据项目id查询项目名称
      * @param ids 以逗号分隔的多个项目id字符串
@@ -1415,24 +1612,63 @@ public class CwReimbursementInfoService {
             invoiceReimbursementsLambdaQueryWrapper.eq(CwReimbursementAmountInfo::getInfoId, reimId);
             invoiceReimbursementsLambdaQueryWrapper.eq(CwReimbursementAmountInfo::getReimbursementType, "1");
             List<CwReimbursementAmountInfo> 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<CwReimAmountAndFileDto> invoiceReimbursementFiles = new HashSet<>();
 
             if (CollectionUtils.isNotEmpty(fileList)) {
+                // 提前为 invoiceReimbursements 构建 URL 到 invoiceReimbursement 的映射,减少嵌套循环
+                Map<String, CwReimbursementAmountInfo> reimbursementMap = new HashMap<>();
+                for (CwReimbursementAmountInfo 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())) {
+                        CwReimbursementAmountInfo 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 (CwReimbursementAmountInfo reimbursement : invoiceReimbursements) {
+                                        String key = entry.getKey();
+                                        String value = entry.getValue();
+                                        if (reimbursement.getNumber().equals(key) && i.getUrl().equals(value)){
+                                            CwReimAmountAndFileDto ccpmReimAmountAndFileDto = new CwReimAmountAndFileDto();
+                                            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<CwReimAmountAndFileDto> uniqueFilesList = new ArrayList<>(invoiceReimbursementFiles);
+            dto.setInvoiceReimbursementFiles(uniqueFilesList);
         }
         return dto;
     }
@@ -1483,21 +1719,35 @@ public class CwReimbursementInfoService {
                     amountInfoMapper.delete(deleteInfo);
                 }else if("1".equals(dto.getReimbursementType())){
                     // 保存电子发票列表信息
-                    if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursements())) {
-                        for (CwReimbursementAmountInfo 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 (CwReimAmountAndFileDto amountInfo : dto.getInvoiceReimbursementFiles()) {
+                            if (com.jeeplus.utils.StringUtils.isNotBlank(amountInfo.getUrl())){
+                                CwReimbursementAmountInfo reimbursementAmountInfo = new CwReimbursementAmountInfo();
+                                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);
+                            }
+
                         }
                     }
                     //清除专用发票信息
@@ -1508,7 +1758,7 @@ public class CwReimbursementInfoService {
 
                     // 保存电子发票附件列表信息
                     if (CollectionUtils.isNotEmpty(dto.getInvoiceReimbursementFiles())) {
-                        infoService.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
+                        this.updateFiles(dto.getInvoiceReimbursementFiles(), userDTO, dto.getId(),"invoiceReimbursement");
                     }
                 }
             }
@@ -1560,4 +1810,61 @@ public class CwReimbursementInfoService {
         cwReimbursementFileSupplementMapper.updateFileStatusById(dto.getFileSuppleId(),dto.getFileStatus());
     }
 
+
+    /**
+     * 修改数电发票报销数据(对老数据进行调整)
+     */
+    public void updateOldData() {
+        try {
+            Set<String> infoIds = new HashSet<>(); // 使用 Set 去重
+
+            // 查询所有的数电发票信息
+            LambdaQueryWrapper<CwReimbursementAmountInfo> invoiceReimbursementsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            invoiceReimbursementsLambdaQueryWrapper.eq(CwReimbursementAmountInfo::getReimbursementType, "1");
+            invoiceReimbursementsLambdaQueryWrapper.eq(CwReimbursementAmountInfo::getDelFlag, "0");
+            invoiceReimbursementsLambdaQueryWrapper.orderByDesc(CwReimbursementAmountInfo::getCreateTime);
+            List<CwReimbursementAmountInfo> invoiceReimbursements = amountInfoMapper.selectList(invoiceReimbursementsLambdaQueryWrapper);
+
+            if (CollectionUtil.isNotEmpty(invoiceReimbursements)) {
+                // 将所有的报销id进行存储
+                for (CwReimbursementAmountInfo 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 (CwReimbursementAmountInfo 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();
+        }
+    }
+
 }

+ 161 - 0
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/service/dto/CwReimAmountAndFileDto.java

@@ -0,0 +1,161 @@
+package com.jeeplus.finance.reimbursementApproval.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 CwReimAmountAndFileDto 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;
+
+    /*8
+    数电发票id
+     */
+    private String amountId;
+}

+ 1 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/reimbursementApproval/approvalInfo/service/dto/SaveInfoDto.java

@@ -74,7 +74,7 @@ public class SaveInfoDto extends BaseEntity {
     private List<CwReimbursementAmountInfo> invoiceReimbursements;
 
     private List<WorkAttachmentInfo> files;
-    private List<WorkAttachmentInfo> invoiceReimbursementFiles; //电子发票报销
+    private List<CwReimAmountAndFileDto> invoiceReimbursementFiles; //电子发票报销
 
     /**
      * 报销类型

+ 14 - 0
jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/feign/ConsultancyFeignApi.java

@@ -0,0 +1,14 @@
+package com.xxl.job.executor.feign;
+
+import com.jeeplus.common.constant.AppNameConstants;
+import com.jeeplus.flowable.feign.IConsultApi;
+import com.jeeplus.flowable.feign.IZsApi;
+import org.springframework.cloud.openfeign.FeignClient;
+
+/**
+ * @author: 王强
+ * @create: 2023-07-27 08:48
+ **/
+@FeignClient(contextId = "consultancyFeignApi", name = AppNameConstants.APP_CONSULT_MODULES)
+public interface ConsultancyFeignApi extends IConsultApi {
+}

+ 14 - 0
jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/feign/ZsFeignApi.java

@@ -0,0 +1,14 @@
+package com.xxl.job.executor.feign;
+
+import com.jeeplus.common.constant.AppNameConstants;
+import com.jeeplus.flowable.feign.IAssessApi;
+import com.jeeplus.flowable.feign.IZsApi;
+import org.springframework.cloud.openfeign.FeignClient;
+
+/**
+ * @author: 王强
+ * @create: 2023-07-27 08:48
+ **/
+@FeignClient(contextId = "zsFeignApi", name = AppNameConstants.APP_CENTRECAREFUL_MODULES)
+public interface ZsFeignApi extends IZsApi {
+}

+ 43 - 0
jeeplus-modules/jeeplus-xxl-job-executor-sample/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java

@@ -478,6 +478,49 @@ public class SampleXxlJob {
         SpringUtil.getBean ( CcpmFeignApi.class ).updateOldData();
     }
 
+
+    /**
+     * 会计-数电发票报销-修改老数据
+
+     */
+    @XxlJob("updateCwReimbursement")
+    public void updateCwReimbursement(){
+        SpringUtil.getBean ( FinanceFeignApi.class ).updateOldData();
+    }
+
+
+    /**
+     * 评估-数电发票报销-修改老数据
+
+     */
+    @XxlJob("updateAssessReimbursement")
+    public void updateAssessReimbursement(){
+        SpringUtil.getBean ( AssessFeignApi.class ).updateOldData();
+    }
+
+
+    /**
+     * 中审-数电发票报销-修改老数据
+
+     */
+    @XxlJob("updateZsReimbursement")
+    public void updateZsReimbursement(){
+        SpringUtil.getBean ( ZsFeignApi.class ).updateOldData();
+    }
+
+
+    /**
+     * 培训-数电发票报销-修改老数据
+
+     */
+    @XxlJob("updateConsultancyReimbursement")
+    public void updateConsultancyReimbursement(){
+        SpringUtil.getBean ( ConsultancyFeignApi.class ).updateOldData();
+    }
+
+
+
+
     public static String dateToString(Date date) {
         SimpleDateFormat sformat = new SimpleDateFormat("yyyy-MM-dd");//日期格式
         return sformat.format(date);