Prechádzať zdrojové kódy

签章文件上传bug修复

user5 2 rokov pred
rodič
commit
34a5a168db

+ 1 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/controller/CwProjectReportController.java

@@ -93,7 +93,7 @@ public class CwProjectReportController {
         if (CollectionUtil.isEmpty(reportData.getCwFileInfoList())) {
             reportData.setCwFileInfoList(new ArrayList<>());
         }
-        projectReportService.updateFiles(reportData.getCwFileInfoList(),userDTO,reportData.getId());
+        projectReportService.updateSignatureFiles(reportData.getCwFileInfoList(),userDTO,reportData.getId());
         return ResponseEntity.ok("操作成功");
     }
 

+ 2 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/mapper/CwProjectReportMapper.java

@@ -38,6 +38,8 @@ public interface CwProjectReportMapper extends BaseMapper<CwProjectReport> {
 
     Integer findIsExit(@Param("id") String id, @Param("name")String name);
 
+    Integer deleteAttachement(@Param("id") String id,@Param("attachmentFlag") String attachmentFlag);
+
     CwProjectReportData queryById(@Param("id") String id);
 
     /**

+ 9 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/mapper/xml/CwProjectReportMapper.xml

@@ -298,6 +298,7 @@
         left join cw_project_report_file b on a.id = b.report_file_id
         WHERE a.del_flag = 0 AND a.attachment_id = #{id} and b.file_affiliation = 0
     </select>
+
     <select id="findIsExit" resultType="java.lang.Integer">
         SELECT
 			COUNT( 0 )
@@ -309,6 +310,14 @@
 			AND attachment_name = #{name}
     </select>
 
+    <delete id="deleteAttachement">
+        delete from work_attachment
+		WHERE
+			del_flag = 0
+			AND attachment_id = #{id}
+			AND attachment_flag = #{attachmentFlag}
+    </delete>
+
     <select id="getProcessInstanceIdById" resultType="java.lang.String">
         select proc_ins_id as "procInsId" from cw_project_report_signature where id = #{id}
     </select>

+ 1 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/mapper/xml/ProjectReportWorkAttachmentMapper.xml

@@ -12,7 +12,7 @@
     </select>
     <select id="selectByInfoId"
             resultType="com.jeeplus.test.cw.projectReport.service.dto.ProjectReportWorkAttachmentDTO">
-        select id,url,file_size as size,attachment_name as name from work_attachment where attachment_id = #{id}
+        select id,url,file_size as size,attachment_name as name from work_attachment where del_flag = 0 and attachment_id = #{id}
     </select>
 
     <select id="selectInfoByFileId" resultType="com.jeeplus.test.cw.projectReport.domain.CwProjectReportFile">

+ 32 - 13
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/service/CwProjectReportService.java

@@ -513,7 +513,10 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
         if ( null != reportData){
             List<ProjectReportWorkAttachmentDTO> dtos = attachmentMapper.selectByInfoId(reportData.getId());
             if (null != dtos){
-                dtos.forEach(d->{
+
+                Iterator<ProjectReportWorkAttachmentDTO> it = dtos.iterator();
+                while(it.hasNext()){
+                    ProjectReportWorkAttachmentDTO d = it.next();
                     //根据id查出cw_project_report_file文件表的其他信息
                     //未签章附件
                     CwProjectReportFile file = attachmentMapper.selectInfoByFileId(d.getId(),"0");
@@ -532,6 +535,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
                         d.setCreateBy(userDTO);
                         d.setCreateDate(file.getCreateDate());
                         dtoList.add(d);
+                        it.remove();
                     }
 
                     //已签章附件
@@ -551,20 +555,33 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
                         d.setCreateBy(userDTO2);
                         d.setCreateDate(signatureFile.getCreateDate());
                         signatureList.add(d);
+                        it.remove();
                     }
-                });
+                }
                 reportData.setCwFileInfoList(dtoList);
                 reportData.setSignatureFileList(signatureList);
             }
+
             //将附件信息查出
             // 查询附件信息
             List<WorkAttachmentDto> fileInfo2 = reportMapper.findDtos(id);
+            List<WorkAttachmentDto> reportFileList = Lists.newArrayList();
+            if(CollectionUtils.isNotEmpty(dtos) && CollectionUtils.isNotEmpty(fileInfo2)){
+                for (ProjectReportWorkAttachmentDTO dto : dtos) {
+                    for (WorkAttachmentDto workAttachmentDto : fileInfo2) {
+                        if(dto.getId().equals(workAttachmentDto.getId())){
+                            reportFileList.add(workAttachmentDto);
+                        }
+                    }
+                }
+            }
+
             if (CollectionUtils.isNotEmpty(dtos)) {
-                for (WorkAttachmentDto i : fileInfo2) {
+                for (WorkAttachmentDto i : reportFileList) {
                     i.setCreateBy(UserUtils.get(i.getBy()));
                 }
             }
-            reportData.setCwFileInfoList2(fileInfo2);
+            reportData.setCwFileInfoList2(reportFileList);
             //设置历史报告列表
             //根据项目id查出所有的信息
             List<CwProjectReportData> byProjectList = reportMapper.getByProjectId(reportData.getProjectId());
@@ -2331,6 +2348,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
         return reportData;
     }
 
+
     /**
      * 修改附件信息
      * @param list 待修改的附件列表
@@ -2404,16 +2422,16 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
      * @param id 关联id
      */
     @Transactional(rollbackFor = Exception.class)
-    public void updateFiles2(List<WorkAttachmentDto> list, UserDTO userDTO, String id) {
+    public void updateSignatureFiles(List<ProjectReportWorkAttachmentDTO> list, UserDTO userDTO, String id) {
         int j = 1;
         String names = new String();
         //表中存在,但是传过来不存在,说明已删除,表中数据也要删除
-        for (WorkAttachmentDto dto : list) {
+        for (ProjectReportWorkAttachmentDTO dto : list) {
             names = names + "," +dto.getUrl();
         }
         //查询保存的附件信息
         List<WorkAttachment> infoList = reportMapper.findFileList(id);
-        if (CollectionUtils.isNotEmpty(infoList)) {
+        if (org.flowable.editor.language.json.converter.util.CollectionUtils.isNotEmpty(infoList)) {
             for (WorkAttachment i : infoList) {
                 if (!names.contains(i.getUrl())) {
                     ossServiceMapper.deleteById(i.getId());
@@ -2425,11 +2443,9 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
                 }
             }
         }
+        reportMapper.deleteAttachement(id,"cwReportSignature");
         //保存信息
-        for (WorkAttachmentDto dto : list) {
-            //判断是否存在
-            Integer isExit = reportMapper.findIsExit(id, dto.getName());
-            if (isExit == 0) {
+        for (ProjectReportWorkAttachmentDTO dto : list) {
                 WorkAttachment i = new WorkAttachment();
                 //包含了url、size、name
                 i.setId(UUID.randomUUID().toString().replace("-", ""));
@@ -2446,12 +2462,15 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
                 }
                 i.setAttachmentId(id);
                 i.setAttachmentName(dto.getName());
-                i.setAttachmentFlag("cwWorkContract");
+                i.setAttachmentFlag("cwReportSignature");
                 i.setFileSize(dto.getSize());
                 i.setSort(j);
                 ossServiceMapper.insertWorkAttachment(i, userDTO);
+                CwProjectReportFile reportFile = new CwProjectReportFile();
+                BeanUtils.copyProperties(dto, reportFile);
+                reportFile.setReportFileId(i.getId());
+                attachmentMapper.insert(reportFile);
                 j++;
-            }
         }
     }