Explorar o código

Merge branch 'master' of http://47.100.37.243:10080/ZHOU/yunsu

# Conflicts:
#	cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldFileServiceImpl.java
%!s(int64=5) %!d(string=hai) anos
pai
achega
eaabf71795

+ 71 - 39
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldFileServiceImpl.java

@@ -154,27 +154,27 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                     }
                     mouldFileMapper.insert(projectFile);
                     //上传完,需要生成pdf
-                    String dFile1 = path+UUID.randomUUID().toString().replaceAll("-", "")+".pdf";
+                    String dFile1 = path + UUID.randomUUID().toString().replaceAll("-", "") + ".pdf";
                     openOfficeService.start();
                     File testFile = new File(dFile1);
-                    if(!testFile .exists()){
-                        openOfficeService.office2PDF(path + fileName,dFile1);
+                    if (!testFile.exists()) {
+                        openOfficeService.office2PDF(path + fileName, dFile1);
                     }
                     PdfFile pdfFile = new PdfFile();
-                    pdfFile.setPdfUrl("/upload/"+dFile1.substring(path.length()));
+                    pdfFile.setPdfUrl("/upload/" + dFile1.substring(path.length()));
                     pdfFile.setFileId(projectFile.getId());
                     pdfFile.setType(0);
                     pdfFile.setRafId(projectFile.getModelId());
                     pdfFile.setSourceFileUrl(projectFile.getFileUrl());
                     pdfFileMapper.insert(pdfFile);
-                    if(blongType == 5 && file2 != null && !file2.isEmpty()){
-                        dFile2 = path+UUID.randomUUID().toString().replaceAll("-", "")+".pdf";
+                    if (blongType == 5 && file2 != null && !file2.isEmpty()) {
+                        dFile2 = path + UUID.randomUUID().toString().replaceAll("-", "") + ".pdf";
                         testFile = new File(dFile2);
-                        if(!testFile .exists()){
-                            openOfficeService.office2PDF(path + fileName,dFile2);
+                        if (!testFile.exists()) {
+                            openOfficeService.office2PDF(path + fileName, dFile2);
                         }
                         pdfFile = new PdfFile();
-                        pdfFile.setPdfUrl("/upload/"+dFile2.substring(path.length()));
+                        pdfFile.setPdfUrl("/upload/" + dFile2.substring(path.length()));
                         pdfFile.setFileId(projectFile.getId());
                         pdfFile.setType(0);
                         pdfFile.setRafId(projectFile.getModelId());
@@ -254,7 +254,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                         } else if (blongType == 5) {
                             content = "模具报废文档";
                         }
-                        newsNotice.setContent("有新的" + content +"上传,待您审批。");
+                        newsNotice.setContent("有新的" + content + "上传,待您审批。");
                         newsNoticeMapper.insert(newsNotice);
                         for (ProjectApprove projectApprove : projectApproves) {
                             NewsNoticeUser newsNoticeUser = new NewsNoticeUser();
@@ -455,19 +455,51 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
     public HttpRespMsg dowloadFile(MouldFile projectFile, String token) {
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
-        //添加上传记录
-        MouldFile file = mouldFileMapper.selectById(projectFile.getId());
-        MouldOperationDynamics dynamics = new MouldOperationDynamics();
-        dynamics.setContent(Constant.DOWNLOAD);
-        dynamics.setApplicantId(file.getUplodtorId());
-        dynamics.setApplicantName(file.getUploadtor());
-        dynamics.setFileName(file.getFileName());
-        dynamics.setOperatorId(user.getId());
-        dynamics.setOperatorName(user.getUsername());
-        dynamics.setMouldId(file.getModelId());
-        dynamics.setFileId(file.getId());
-        dynamics.setBelongType(file.getBlongType());
-        mouldOperationDynamicsMapper.insert(dynamics);
+        if (null != projectFile.getId()) {
+            //添加上传记录
+            MouldFile file = mouldFileMapper.selectById(projectFile.getId());
+            MouldOperationDynamics dynamics = new MouldOperationDynamics();
+            dynamics.setContent(Constant.DOWNLOAD);
+            dynamics.setApplicantId(file.getUplodtorId());
+            dynamics.setApplicantName(file.getUploadtor());
+            dynamics.setFileName(file.getFileName());
+            dynamics.setOperatorId(user.getId());
+            dynamics.setOperatorName(user.getUsername());
+            dynamics.setMouldId(file.getModelId());
+            dynamics.setFileId(file.getId());
+            dynamics.setBelongType(file.getBlongType());
+            mouldOperationDynamicsMapper.insert(dynamics);
+            if(null != file.getFileName2()){
+                dynamics.setContent(Constant.DOWNLOAD);
+                dynamics.setApplicantId(file.getUplodtorId());
+                dynamics.setApplicantName(file.getUploadtor());
+                dynamics.setFileName(file.getFileName2());
+                dynamics.setOperatorId(user.getId());
+                dynamics.setOperatorName(user.getUsername());
+                dynamics.setMouldId(file.getModelId());
+                dynamics.setFileId(file.getId());
+                dynamics.setBelongType(file.getBlongType());
+                mouldOperationDynamicsMapper.insert(dynamics);
+            }
+        }else{
+            if(null != projectFile.getPartId()){
+                //零件文档
+                List<MouldFile> mouldFiles = mouldFileMapper.selectList(new QueryWrapper<>(projectFile));
+                for (MouldFile file : mouldFiles) {
+                    MouldOperationDynamics dynamics = new MouldOperationDynamics();
+                    dynamics.setContent(Constant.DOWNLOAD);
+                    dynamics.setApplicantId(file.getUplodtorId());
+                    dynamics.setApplicantName(file.getUploadtor());
+                    dynamics.setFileName(file.getFileName());
+                    dynamics.setOperatorId(user.getId());
+                    dynamics.setOperatorName(user.getUsername());
+                    dynamics.setMouldId(file.getModelId());
+                    dynamics.setFileId(file.getId());
+                    dynamics.setBelongType(file.getBlongType());
+                    mouldOperationDynamicsMapper.insert(dynamics);
+                }
+            }
+        }
         return msg;
     }
 
@@ -507,16 +539,16 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
     }
 
     @Override
-    public HttpRespMsg delFile(MouldFile mouldFile,String token) {
+    public HttpRespMsg delFile(MouldFile mouldFile, String token) {
         HttpRespMsg msg = new HttpRespMsg();
         User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
-        if(currentUser == null){
+        if (currentUser == null) {
             msg.setError("用户不存在或者未登录");
-        }else{
-            if(Constant.SYS_ID .equals(currentUser.getParentId())){
+        } else {
+            if (Constant.SYS_ID.equals(currentUser.getParentId())) {
                 //判断是不是资产方管理员
                 msg.data = mouldFileMapper.deleteById(mouldFile.getId());
-            }else{
+            } else {
                 msg.setError("您没有该权限!");
             }
         }
@@ -532,7 +564,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
         User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
         PageHelper.startPage(page.getPageNum(), page.getPageSize());
         if (currentUser != null) {
-            if (Constant.SYS_ID .equals(currentUser.getParentId())) {
+            if (Constant.SYS_ID.equals(currentUser.getParentId())) {
                 //此时是admin,查询他所创建的项目
                 QueryWrapper<Project> qw = new QueryWrapper<>();
                 List<Project> projects = projectMapper.selectList(qw.eq("creator_id", currentUser.getId()));
@@ -540,7 +572,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                     proIds.add(pro.getId());
                 }
                 list = mouldFileMapper.getFileListByProjectId(userVO, proIds);
-            } else if (Constant.SYS_PARENT_ID .equals(currentUser.getParentId())) {
+            } else if (Constant.SYS_PARENT_ID.equals(currentUser.getParentId())) {
                 //系统管理员
                 List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>());
                 for (Project pro : projects) {
@@ -608,7 +640,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                 } else {
                     mouldFiles = mouldFileMapper.selectList(new QueryWrapper<MouldFile>().eq("model_id", id).eq("state", 3).eq("blong_type", 3));
                 }
-                if(mouldFiles.size()==0){
+                if (mouldFiles.size() == 0) {
                     continue;
                 }
 //                feedBackDirectMultiDownload(request, response, downloadPath, mould, mouldFiles, path);
@@ -636,7 +668,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
 
             try {
                 // 生成的压缩文件
-                if(newFolders.size() > 0){
+                if (newFolders.size() > 0) {
                     ZipFile zipFile = null;
                     SimpleDateFormat dateSdf2 = new SimpleDateFormat("yyyy年MM月dd+HH时mm分ss秒");
                     String fileName = dateSdf2.format(new Date()) + ".zip";
@@ -647,13 +679,13 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                     // 压缩级别
                     parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
                     // 要打包的文件夹
-                    if(newFolders.size()>0){
+                    if (newFolders.size() > 0) {
                         for (String newFolder : newFolders) {
                             zipFile.addFolder(newFolder, parameters);
                         }
                     }
-                    msg.data = "/upload/"+fileName;
-                }else{
+                    msg.data = "/upload/" + fileName;
+                } else {
                     msg.setError("暂无文件");
                     return msg;
                 }
@@ -735,13 +767,13 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                     saveFile.createNewFile();
                     file.transferTo(saveFile);
                     //上传完,需要生成pdf
-                    String dFile1 = path+UUID.randomUUID().toString().replaceAll("-", "")+".pdf";
+                    String dFile1 = path + UUID.randomUUID().toString().replaceAll("-", "") + ".pdf";
 
                     File newFile = new File(dFile1);
-                    if(!newFile .exists()){
-                        openOfficeService.office2PDF(path + fileName,dFile1);
+                    if (!newFile.exists()) {
+                        openOfficeService.office2PDF(path + fileName, dFile1);
                         PdfFile pdfFile = new PdfFile();
-                        pdfFile.setPdfUrl("/upload/"+dFile1.substring(path.length()));
+                        pdfFile.setPdfUrl("/upload/" + dFile1.substring(path.length()));
                         pdfFile.setFileId(partFile.getId());
                         pdfFile.setType(1);
                         pdfFile.setRafId(partFile.getModelId());

+ 1 - 1
cloud-model/src/main/resources/application-prod.properties

@@ -15,7 +15,7 @@ spring.thymeleaf.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.url=jdbc:mysql://118.190.47.230:3306/cloud_model?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 spring.datasource.username=root
-spring.datasource.password=p011430seya10
+spring.datasource.password=p011430seya1026
 #spring.datasource.druid.test-on-borrow=true
 #spring.datasource.druid.test-while-idle=true
 # ####################################################################################################

+ 1 - 1
cloud-model/src/main/resources/application.properties

@@ -15,7 +15,7 @@ spring.thymeleaf.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.url=jdbc:mysql://118.190.47.230:3306/new_cloud_model?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 spring.datasource.username=root
-spring.datasource.password=p011430seya10
+spring.datasource.password=p011430seya1026
 #spring.datasource.druid.test-on-borrow=true
 #spring.datasource.druid.test-while-idle=true
 # ####################################################################################################