浏览代码

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
5 年之前
父节点
当前提交
891084385a

+ 6 - 6
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldFileController.java

@@ -54,7 +54,6 @@ public class MouldFileController {
     private UserService userService;
 
 
-
 //    /**
 //     * 模具文档的下载
 //     * id 所要下载的文件id ,
@@ -90,6 +89,7 @@ public class MouldFileController {
 //        }
 //        return msg;
 //    }
+
     /**
      * 模具文档的上传
      * 参数: token 用户身份凭证,
@@ -169,7 +169,7 @@ public class MouldFileController {
     @RequestMapping("/list")
     @ResponseBody
     public HttpRespMsg list(@RequestParam Integer mouldId, @RequestParam Integer blongType, UserVO userVO) {
-        HttpRespMsg msg = mouldFileService.getFileList(mouldId, blongType, userVO,path);
+        HttpRespMsg msg = mouldFileService.getFileList(mouldId, blongType, userVO, path);
         return msg;
     }
 
@@ -203,15 +203,15 @@ public class MouldFileController {
 
     /**
      * 模具文档的删除
-     * 参数: id 文档id
+     * 参数: id 文档id token 用户身份凭证
      *
      * @return
      */
     @ApiOperation("项目文档的删除")
     @RequestMapping("/delFile")
     @ResponseBody
-    public HttpRespMsg delFile(MouldFile mouldFile) {
-        HttpRespMsg msg = mouldFileService.delFile(mouldFile);
+    public HttpRespMsg delFile(MouldFile mouldFile, String token) {
+        HttpRespMsg msg = mouldFileService.delFile(mouldFile,token);
         return msg;
     }
 
@@ -261,7 +261,7 @@ public class MouldFileController {
     public HttpRespMsg downloadFileListExcel(UserVO userVO, HttpServletResponse response) {
         HttpRespMsg msg = new HttpRespMsg();
         try {
-            msg = mouldFileService.downloadFileListExcel(userVO, response,path);
+            msg = mouldFileService.downloadFileListExcel(userVO, response, path);
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 3 - 7
cloud-model/src/main/java/com/hssx/cloudmodel/controller/ProjectFileController.java

@@ -20,10 +20,6 @@ import java.io.*;
 import java.util.UUID;
 
 /**
- * <p>
- *  前端控制器
- * </p>
- *
  * @author 吴涛涛
  * @since 2019-07-30
  */
@@ -121,15 +117,15 @@ public class ProjectFileController {
 
     /**
      * 项目文档的删除
-     * 参数: id 文档id
+     * 参数: id 文档id token 用户身份凭证
      *
      * @return
      */
     @ApiOperation("项目文档的删除")
     @RequestMapping("/delFile")
     @ResponseBody
-    public HttpRespMsg delFile(ProjectFile projectFile){
-        HttpRespMsg msg = projectFileService.delFile(projectFile);
+    public HttpRespMsg delFile(ProjectFile projectFile,String token){
+        HttpRespMsg msg = projectFileService.delFile(projectFile,token);
         return msg;
     }
 }

+ 0 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/controller/UserController.java

@@ -135,7 +135,6 @@ public class UserController {
     @RequestMapping("/getUserListByCompanyIds")
     @ResponseBody
     public HttpRespMsg getUserListByCompanyIds(String companyIds,Integer id,@RequestParam(required = false) Integer projectId){
-        System.out.println("companyIds"+companyIds);
         HttpRespMsg msg = projectService.getUserListByCompanyIds(companyIds,id,projectId);
         return msg;
     }

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/MouldFileService.java

@@ -27,7 +27,7 @@ public interface MouldFileService extends IService<MouldFile> {
     HttpRespMsg dowloadFile(MouldFile projectFile, String token);
     HttpRespMsg getAllFileList(int mouldId, UserVO userVO);
     HttpRespMsg getFileList(int mouldId, Integer blongType, UserVO userVO,String path);
-    HttpRespMsg delFile(MouldFile mouldFile);
+    HttpRespMsg delFile(MouldFile mouldFile,String token);
     HttpRespMsg getListByUserAndProjectId(UserVO userVO, PageUtil page);
     HttpRespMsg dowloadFileList(UserVO userVO, HttpServletRequest request, HttpServletResponse response,String downloadPath,String path) throws IOException;
     HttpRespMsg addPartFile(UserVO userVO, String path, MultipartFile[] files);

+ 1 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/ProjectFileService.java

@@ -26,5 +26,5 @@ public interface ProjectFileService extends IService<ProjectFile> {
 
     HttpRespMsg getFileList(UserVO userVO,String path);
 
-    HttpRespMsg delFile(ProjectFile projectFile);
+    HttpRespMsg delFile(ProjectFile projectFile,String token);
 }

+ 18 - 2
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/CompanyServiceImpl.java

@@ -205,17 +205,33 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
     public List<Company> getIdAndNamelist(User user) {
         QueryWrapper<Company> qw = new QueryWrapper<>();
         qw.select("id", "company_name", "company_type");
+        List <Integer> ides = new ArrayList<>();
         if (Constant.SYS_ID == user.getParentId()) {
             //此时是admin创建用户,返回可选的生产方公司,查询出当前admin的信息并获取他的公司id
             User admin = userMapper.selectOne(new QueryWrapper<User>().eq("id", user.getId()));
-            qw.eq("company_type", Constant.PRODUCER_COMPANY).or().eq("id", admin.getCompanyId());
+            ides = assetCustomCompanyMapper.selectList(new QueryWrapper<AssetCustomCompany>()
+                    .eq("assert_id", admin.getCompanyId()))
+                    .stream()
+                    .map(AssetCustomCompany::getCustomId)
+                    .collect(Collectors.toList());
+            ides.add(admin.getCompanyId());
+            ides.add(-1);
+            qw.in("id", ides);
         } else if (Constant.SYS_PARENT_ID == user.getParentId()) {
             //系统管理员创建admin,返回资产方公司
             qw.eq("company_type", Constant.ASSETS_COMPANY);
         } else {
             //此时是项目经理创建其他用户
             User admin = userMapper.selectOne(new QueryWrapper<User>().eq("id", user.getParentId()));
-            qw.eq("company_type", Constant.PRODUCER_COMPANY).or().eq("id", admin.getCompanyId());
+            //获取创建他的资产方管理员公司所关联的生产方
+            ides = assetCustomCompanyMapper.selectList(new QueryWrapper<AssetCustomCompany>()
+                    .eq("assert_id", admin.getCompanyId()))
+                    .stream()
+                    .map(AssetCustomCompany::getCustomId)
+                    .collect(Collectors.toList());
+            ides.add(admin.getCompanyId());
+            ides.add(-1);
+            qw.in("id", ides);
         }
         return companyMapper.selectList(qw);
     }

+ 12 - 2
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldFileServiceImpl.java

@@ -471,9 +471,19 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
     }
 
     @Override
-    public HttpRespMsg delFile(MouldFile mouldFile) {
+    public HttpRespMsg delFile(MouldFile mouldFile,String token) {
         HttpRespMsg msg = new HttpRespMsg();
-        msg.data = mouldFileMapper.deleteById(mouldFile.getId());
+        User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
+        if(currentUser == null){
+            msg.setError("用户不存在或者未登录");
+        }else{
+            if(Constant.SYS_ID == currentUser.getParentId()){
+                //判断是不是资产方管理员
+                msg.data = mouldFileMapper.deleteById(mouldFile.getId());
+            }else{
+                msg.setError("您没有该权限!");
+            }
+        }
         return msg;
     }
 

+ 65 - 50
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/ProjectFileServiceImpl.java

@@ -2,11 +2,13 @@ package com.hssx.cloudmodel.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.hssx.cloudmodel.constant.Constant;
+import com.hssx.cloudmodel.entity.Project;
 import com.hssx.cloudmodel.entity.ProjectFile;
 import com.hssx.cloudmodel.entity.ProjectOperationDynamics;
 import com.hssx.cloudmodel.entity.User;
 import com.hssx.cloudmodel.entity.vo.UserVO;
 import com.hssx.cloudmodel.mapper.ProjectFileMapper;
+import com.hssx.cloudmodel.mapper.ProjectMapper;
 import com.hssx.cloudmodel.mapper.ProjectOperationDynamicsMapper;
 import com.hssx.cloudmodel.mapper.UserMapper;
 import com.hssx.cloudmodel.service.ProjectFileService;
@@ -42,6 +44,8 @@ public class ProjectFileServiceImpl extends ServiceImpl<ProjectFileMapper, Proje
     ProjectFileMapper projectFileMapper;
     @Resource
     ProjectOperationDynamicsMapper projectOperationDynamicsMapper;
+    @Resource
+    ProjectMapper projectMapper;
 
     @Override
     public HttpRespMsg addFile(UserVO userVO, MultipartFile file, String path) {
@@ -118,7 +122,6 @@ public class ProjectFileServiceImpl extends ServiceImpl<ProjectFileMapper, Proje
     }
 
     public void downloadLocal(HttpServletResponse response, String downLoadpath, ProjectFile file, String path) throws FileNotFoundException, UnsupportedEncodingException {
-        System.out.println("123123");
 //        // 下载本地文件
 //        String fileName = file.getFileName().toString(); // 文件的默认保存名
 //        // 读到流中
@@ -147,62 +150,62 @@ public class ProjectFileServiceImpl extends ServiceImpl<ProjectFileMapper, Proje
 
 
 //        public static void downloadFile (HttpServletResponse response, String fileName, String path){
-            //下载本地文件
-            String fileName = file.getFileName().toString(); // 文件的默认保存名
-            // 读到流中
-            File dir = null;
-            dir = new File(downLoadpath);
-            // D://cloud/upload 文件上传后所存储的位置,部署到服务器上时配置服务器地址即可
-            if (!dir.exists()) {
-                dir.mkdirs();
-            }
-            if (fileName != null) {
-                //设置文件路径
-                File file1 = new File(path.substring(0, path.length() - "/upload/".length()) + file.getUrl());
-                if (file1.exists()) {
-                    response.setHeader("content-type", "application/octet-stream");
-                    response.setContentType("application/octet-stream");
-                    try {
-                        response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO-8859-1"));
-                    } catch (UnsupportedEncodingException e) {
-                        e.printStackTrace();
+        //下载本地文件
+        String fileName = file.getFileName().toString(); // 文件的默认保存名
+        // 读到流中
+        File dir = null;
+        dir = new File(downLoadpath);
+        // D://cloud/upload 文件上传后所存储的位置,部署到服务器上时配置服务器地址即可
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+        if (fileName != null) {
+            //设置文件路径
+            File file1 = new File(path.substring(0, path.length() - "/upload/".length()) + file.getUrl());
+            if (file1.exists()) {
+                response.setHeader("content-type", "application/octet-stream");
+                response.setContentType("application/octet-stream");
+                try {
+                    response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO-8859-1"));
+                } catch (UnsupportedEncodingException e) {
+                    e.printStackTrace();
+                }
+                byte[] buffer = new byte[1024];
+                FileInputStream fis = null;
+                BufferedInputStream bis = null;
+                try {
+                    fis = new FileInputStream(file1);
+                    bis = new BufferedInputStream(fis);
+                    OutputStream os = response.getOutputStream();
+                    int i = bis.read(buffer);
+                    while (i != -1) {
+                        os.write(buffer, 0, i);
+                        i = bis.read(buffer);
                     }
-                    byte[] buffer = new byte[1024];
-                    FileInputStream fis = null;
-                    BufferedInputStream bis = null;
-                    try {
-                        fis = new FileInputStream(file1);
-                        bis = new BufferedInputStream(fis);
-                        OutputStream os = response.getOutputStream();
-                        int i = bis.read(buffer);
-                        while (i != -1) {
-                            os.write(buffer, 0, i);
-                            i = bis.read(buffer);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                } finally {
+                    if (bis != null) {
+                        try {
+                            bis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
                         }
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                        if (bis != null) {
-                            try {
-                                bis.close();
-                            } catch (IOException e) {
-                                e.printStackTrace();
-                            }
-                        }
-                        if (fis != null) {
-                            try {
-                                fis.close();
-                            } catch (IOException e) {
-                                e.printStackTrace();
-                            }
+                    }
+                    if (fis != null) {
+                        try {
+                            fis.close();
+                        } catch (IOException e) {
+                            e.printStackTrace();
                         }
                     }
                 }
             }
         }
+    }
 
     @Override
-    public HttpRespMsg getFileList(UserVO userVO,String path) {
+    public HttpRespMsg getFileList(UserVO userVO, String path) {
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
         List<ProjectFile> list = projectFileMapper.selectList(new QueryWrapper<ProjectFile>().eq("project_id", userVO.getProjectId()).orderByDesc("id"));
@@ -214,9 +217,21 @@ public class ProjectFileServiceImpl extends ServiceImpl<ProjectFileMapper, Proje
     }
 
     @Override
-    public HttpRespMsg delFile(ProjectFile projectFile) {
+    public HttpRespMsg delFile(ProjectFile projectFile, String token) {
         HttpRespMsg msg = new HttpRespMsg();
-        msg.data = projectFileMapper.deleteById(projectFile.getId());
+        User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
+        Project project = projectMapper.selectById(projectFileMapper.selectById(projectFile.getId()).getProjectId());
+        if (user == null) {
+            msg.setError("当前用户不存在或者未登录");
+            return msg;
+        } else {
+            if((Constant.SYS_ID == user.getParentId() && user.getSubordinateType()==0)||project.getManagerId().equals(user.getId())){
+                msg.data = projectFileMapper.deleteById(projectFile.getId());
+            }else{
+                msg.setError("当前用户不存在或者未登录");
+                return msg;
+            }
+        }
         return msg;
     }
 }

+ 2 - 2
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/UserServiceImpl.java

@@ -345,7 +345,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                 if (count > 0) {
                     User existingUser = userMapper.selectOne(qw);
                     if(user.getCompanyId() != existingUser.getCompanyId() || existingUser.getParentId()==1){
-                        msg.setError("创建账号失败");
+                        msg.setError("公司信息不匹配,创建账号失败");
                         return msg;
                     }
                     List<Integer> pIds  = projectMapper.selectList(new QueryWrapper<Project>().eq("owner_company", parentUser.getCompanyId())).stream().map(Project::getId).collect(Collectors.toList());
@@ -451,7 +451,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
                     //当前账号已被创建
                     User existingUser = userMapper.selectOne(qw);
                     if(user.getCompanyId() != existingUser.getCompanyId() || existingUser.getParentId()==1){
-                        msg.setError("创建账号失败");
+                        msg.setError("公司信息不匹配,创建账号失败");
                         return msg;
                     }
                     //查询该账号是否已参与创建项目经理的admin公司下的项目

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

@@ -13,7 +13,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.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.druid.test-on-borrow=true