Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

lizhenhao 2 лет назад
Родитель
Сommit
9284ea03da

+ 70 - 32
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/controller/CwProjectReportSignatureCallBackController.java

@@ -14,11 +14,13 @@ import com.jeeplus.flowable.model.Flow;
 import com.jeeplus.flowable.service.FlowTaskService;
 import com.jeeplus.sys.utils.Global;
 import com.jeeplus.sys.utils.SpringContextHolder;
+import com.jeeplus.sys.utils.UserUtils;
 import com.jeeplus.test.cw.common.flowable.dto.CommitParamDTO;
 import com.jeeplus.test.cw.projectRecords.domain.CwProjectRecords;
 import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReport;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReportData;
+import com.jeeplus.test.cw.projectReport.domain.CwProjectReportFile;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReportSignature;
 import com.jeeplus.test.cw.projectReport.mapper.CwProjectReportMapper;
 import com.jeeplus.test.cw.projectReport.mapper.CwProjectReportSignatureMapper;
@@ -26,6 +28,7 @@ import com.jeeplus.test.cw.projectReport.mapper.ProjectReportWorkAttachmentMappe
 import com.jeeplus.test.cw.projectReport.service.CwProjectReportService;
 import com.jeeplus.test.cw.projectReport.service.dto.CwProjectReportSignatureDTO;
 import com.jeeplus.test.oss.domain.WorkAttachment;
+import com.jeeplus.test.oss.mapper.OssServiceMapper;
 import com.jeeplus.test.oss.service.OSSClientService;
 import com.jeeplus.test.signature.domain.PresignCallBack;
 import com.jeeplus.test.signature.utils.SignaturePostUtil;
@@ -64,6 +67,7 @@ public class CwProjectReportSignatureCallBackController {
 
     private CwProjectReportService cwProjectReportService = SpringContextHolder.getBean(CwProjectReportService.class);
     private OSSClientService ossClientService = SpringContextHolder.getBean(OSSClientService.class);
+    private OssServiceMapper ossServiceMapper = SpringContextHolder.getBean(OssServiceMapper.class);
     private CwProjectReportSignatureMapper cwProjectReportSignatureMapper = SpringContextHolder.getBean(CwProjectReportSignatureMapper.class);
     private ProjectReportWorkAttachmentMapper attachmentMapper = SpringContextHolder.getBean(ProjectReportWorkAttachmentMapper.class);
     private CwProjectReportMapper reportMapper = SpringContextHolder.getBean(CwProjectReportMapper.class);
@@ -267,40 +271,74 @@ public class CwProjectReportSignatureCallBackController {
 
             File[] unZipFileList = unZipFile.listFiles();
 
-            for (File f : unZipFileList) {
-                String filepath = "";
-                //取得上传文件
-                //将文件上传到oss云盘中
-                MultipartFile cMultiFile = new MockMultipartFile("file", f.getName(), null, new FileInputStream(f));
-                if (cMultiFile != null && !cMultiFile.isEmpty()) {
-                    // 文件保存路径
-                    String realPath =DIRECTORY.replace("/","")+"/cw_project_report_file"+ossClientService.datePath()+"/"+ System.currentTimeMillis();
-                    //文件原名称
-                    String newName = cMultiFile.getOriginalFilename();
-                    newName = newName.substring(13, newName.length());
-                    ossClientService.uploadFile2OSS(cMultiFile.getInputStream(),realPath,newName);
-                    filepath = "/" + realPath + newName;
-                }
-
-                System.out.println(f.getName());
-                //截取文件后缀名
-                String substring = f.getName().substring(f.getName().lastIndexOf(".")+1, f.getName().length());
-                //遍历该contractId对应的报告信息,将报告信息中的附件地址进行替换
-
-                //查询报告文件信息(电子章)
-                List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(projectReportData.getId());
-                if(fileList.size()>0){
-                    for (WorkAttachment workattachment : fileList) {
-                        //根据url截取文件名成
-                        String workattachmentName = workattachment.getUrl().substring(workattachment.getUrl().lastIndexOf("/")+1, workattachment.getUrl().length());
-
-                        if(f.getName().contains(workattachmentName)){
-                            workattachment.setUrl(filepath);
-                            workattachment.setType(substring);
-                            workattachment.setAttachmentName(f.getName());
-                            attachmentMapper.updateByIdOnSignature(workattachment);
+            if(null != unZipFileList && unZipFileList.length>0){
+                for (File f : unZipFileList) {
+                    String filepath = "";
+                    //取得上传文件
+                    //将文件上传到oss云盘中
+                    MultipartFile cMultiFile = new MockMultipartFile("file", f.getName(), null, new FileInputStream(f));
+                    if (!cMultiFile.isEmpty()) {
+                        // 文件保存路径
+                        String realPath =DIRECTORY.replace("/","")+"/cw_project_report_file"+ossClientService.datePath()+"/"+ System.currentTimeMillis();
+                        //文件原名称
+                        String newName = cMultiFile.getOriginalFilename();
+                        if(StringUtils.isNotBlank(newName)){
+                            newName = newName.substring(13, newName.length());
+                            ossClientService.uploadFile2OSS(cMultiFile.getInputStream(),realPath,newName);
+                            filepath = "/" + realPath + newName;
                         }
                     }
+
+                    System.out.println(f.getName());
+                    //截取文件后缀名
+                    String substring = f.getName().substring(f.getName().lastIndexOf(".")+1, f.getName().length());
+
+                    String newFileName = f.getName().substring(13, f.getName().length());
+
+                    //将签章完成的附件进行保存到附件表中
+                    WorkAttachment workattachment = new WorkAttachment();
+                    workattachment.setDelFlag(0);
+                    workattachment.setUrl(filepath);
+                    workattachment.setType(substring);
+                    workattachment.setAttachmentName(newFileName);
+                    workattachment.setAttachmentFlag("cw_project_report_file");
+                    workattachment.setFileSize(String.valueOf(f.length()));
+                    workattachment.setAttachmentId(projectReportData.getId());
+                    workattachment.setAttachmentType("");
+                    String id = UUID.randomUUID().toString().replace("-", "");
+                    workattachment.setId(id);
+                    workattachment.setCreateDate(new Date());
+                    workattachment.setUpdateDate(new Date());
+                    ossServiceMapper.insert(workattachment);
+
+                    //将附件信息添加到签章附件信息表中
+                    CwProjectReportFile cwProjectReportFile = new CwProjectReportFile();
+                    cwProjectReportFile.setDelFlag(0);
+                    cwProjectReportFile.setId(UUID.randomUUID().toString().replace("-", ""));
+                    cwProjectReportFile.setCreateBy(UserUtils.getByLoginName("admin").getId());
+                    cwProjectReportFile.setUpdateBy(UserUtils.getByLoginName("admin").getId());
+                    cwProjectReportFile.setCreateDate(new Date());
+                    cwProjectReportFile.setUpdateDate(new Date());
+                    cwProjectReportFile.setReportFileId(id);
+                    cwProjectReportFile.setFileAffiliation("1");
+                    cwProjectReportService.insertProjectReportFile(cwProjectReportFile);
+                    //遍历该contractId对应的报告信息,将报告信息中的附件地址进行替换
+
+                    //查询报告文件信息(电子章)
+                    /*List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(projectReportData.getId());
+                    if(fileList.size()>0){
+                        for (WorkAttachment workattachment : fileList) {
+                            //根据url截取文件名成
+                            String workattachmentName = workattachment.getUrl().substring(workattachment.getUrl().lastIndexOf("/")+1, workattachment.getUrl().length());
+
+                            if(f.getName().contains(workattachmentName)){
+                                workattachment.setUrl(filepath);
+                                workattachment.setType(substring);
+                                workattachment.setAttachmentName(f.getName());
+                                attachmentMapper.updateByIdOnSignature(workattachment);
+                            }
+                        }
+                    }*/
                 }
             }
 

+ 5 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/domain/CwProjectReportFile.java

@@ -58,4 +58,9 @@ public class CwProjectReportFile extends BaseEntity {
      * 备注信息
      */
     private String remarks;
+
+    /**
+     * 附件归属(0:未盖章签章文件;1:已盖章签章文件)
+     */
+    private String fileAffiliation;
 }

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

@@ -9,6 +9,7 @@ import com.jeeplus.test.cw.projectRecords.domain.CwProjectRecords;
 import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReport;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReportData;
+import com.jeeplus.test.cw.projectReport.domain.CwProjectReportFile;
 import com.jeeplus.test.cw.projectReport.domain.CwProjectReportSignature;
 import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBase;
 import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
@@ -107,4 +108,10 @@ public interface CwProjectReportMapper extends BaseMapper<CwProjectReport> {
      * @return
      */
     CwProjectReportSignature getReportSignatureById(String id);
+
+    /**
+     * 新增签章附件信息
+     * @param cwProjectReportFile
+     */
+    void insertProjectReportFile(CwProjectReportFile cwProjectReportFile);
 }

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

@@ -320,4 +320,34 @@
           cw_project_report_signature
         where id = #{id}
     </select>
+
+    <insert id="insertProjectReportFile">
+        insert into cw_project_report_file (
+        id,
+        create_by,
+        create_date,
+        update_by,
+        update_date,
+        del_flag,
+        report_file_id,
+        file_type,
+        seal_type,
+        remarks,
+        file_affiliation
+        )
+        values
+        (
+        #{id},
+       #{createBy},
+       #{createDate},
+       #{updateBy},
+       #{updateDate},
+       #{delFlag},
+       #{reportFileId},
+       #{fileType},
+       #{sealType},
+       #{remarks},
+       #{fileAffiliation}
+        )
+    </insert>
 </mapper>

+ 24 - 14
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/service/CwProjectReportService.java

@@ -417,20 +417,22 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
                 dtos.forEach(d->{
                     //根据id查出cw_project_report_file文件表的其他信息
                     CwProjectReportFile file = attachmentMapper.selectInfoByFileId(d.getId());
-                    d.setFileType(file.getFileType());
-                    d.setSealType(file.getSealType());
-                    d.setSealedFile(file.getSealedFile());
-                    d.setSealUser(file.getSealUser());
-                    d.setSealDate(file.getSealDate());
-                    d.setRemarks(file.getRemarks());
-                    UserDTO userDTO = new UserDTO();
-                    //根据创建人id查出创建人名称
-                    String name = reportMapper.getUserNameById(file.getCreateBy());
-                    userDTO.setId(file.getCreateBy());
-                    userDTO.setName(name);
-                    d.setCreateBy(userDTO);
-                    d.setCreateDate(file.getCreateDate());
-                    dtoList.add(d);
+                    if(null != file){
+                        d.setFileType(file.getFileType());
+                        d.setSealType(file.getSealType());
+                        d.setSealedFile(file.getSealedFile());
+                        d.setSealUser(file.getSealUser());
+                        d.setSealDate(file.getSealDate());
+                        d.setRemarks(file.getRemarks());
+                        UserDTO userDTO = new UserDTO();
+                        //根据创建人id查出创建人名称
+                        String name = reportMapper.getUserNameById(file.getCreateBy());
+                        userDTO.setId(file.getCreateBy());
+                        userDTO.setName(name);
+                        d.setCreateBy(userDTO);
+                        d.setCreateDate(file.getCreateDate());
+                        dtoList.add(d);
+                    }
                 });
                 reportData.setCwFileInfoList(dtoList);
             }
@@ -1104,4 +1106,12 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
         }
         return map;
     }
+
+    /**
+     * 新增签章附件信息
+     * @param cwProjectReportFile
+     */
+    public void insertProjectReportFile(CwProjectReportFile cwProjectReportFile){
+        reportMapper.insertProjectReportFile(cwProjectReportFile);
+    }
 }