xiexiang há 1 ano atrás
pai
commit
7cb1965335

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/business/ProductCategoryDTO.java

@@ -33,4 +33,6 @@ public class ProductCategoryDTO {
     private String description;
     @Schema(description = "可见类型的人员id")
     private List<String> showPersonIds;
+    @Schema(description = "管理人员ids")
+    private List<String> adminIds;
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/business/ProductDTO.java

@@ -35,4 +35,6 @@ public class ProductDTO {
     private String description;
     @Schema(description = "可见类型的人员id")
     private List<String> showPersonIds;
+    @Schema(description = "管理人员ids")
+    private List<String> adminIds;
 }

+ 5 - 0
src/main/java/cn/cslg/pas/common/dto/business/TreeNodeDTO.java

@@ -48,4 +48,9 @@ public class TreeNodeDTO {
      */
     private Integer level;
 
+    /**
+     * 说明
+     */
+    private String description;
+
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/business/UpdateProductCategoryDTO.java

@@ -33,4 +33,6 @@ public class UpdateProductCategoryDTO {
     private List<String> showPersonIds;
     @Schema(description = "文件guid")
     private List<String> guids;
+    @Schema(description = "管理人员ids")
+    private List<String> adminIds;
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/business/UpdateProductDTO.java

@@ -36,4 +36,6 @@ public class UpdateProductDTO {
     private List<String> showPersonIds;
     @Schema(description = "文件guid")
     private List<String> guids;
+    @Schema(description = "管理人员ids")
+    private List<String> adminIds;
 }

+ 1 - 1
src/main/java/cn/cslg/pas/common/model/cronModel/Personnel.java

@@ -20,7 +20,7 @@ public class Personnel  {
      * 人员账号
      */
      private  Integer id;
-     private Integer guid;
+     private String guid;
     private String personnelUserName;
 
     /**

+ 2 - 0
src/main/java/cn/cslg/pas/common/vo/business/ProductCategoryVO.java

@@ -27,6 +27,8 @@ public class ProductCategoryVO {
     private Integer showType;
     @Schema(description = "可见人员ids")
     private List<String> showPersonIds;
+    @Schema(description = "管理员ids")
+    private List<String> adminIds;
     @Schema(description = "描述")
     private String description;
     @Schema(description = "创建人")

+ 9 - 2
src/main/java/cn/cslg/pas/controller/ProductController.java

@@ -2,8 +2,11 @@ package cn.cslg.pas.controller;
 
 import cn.cslg.pas.common.core.base.Constants;
 import cn.cslg.pas.common.dto.business.ProductDTO;
+import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.exception.ConditionException;
+import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
@@ -35,8 +38,8 @@ public class ProductController {
     @PostMapping("/queryProduct")
     public Response queryProduct(StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("eventService");
-        business.queryMessage(stringRequest);
-        return null;
+        Records records = (Records) business.queryMessage(stringRequest);
+        return Response.success(records);
     }
 
     @Operation(summary = "添加产品")
@@ -51,6 +54,10 @@ public class ProductController {
             } catch (Exception e){
                 if(e instanceof XiaoShiException){
                     return Response.error(e.getMessage());
+                } else if (e instanceof UnLoginException) {
+                    return Response.unLogin(e.getMessage());
+                } else if (e instanceof ConditionException) {
+                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 6 - 0
src/main/java/cn/cslg/pas/controller/TreeNodeController.java

@@ -4,6 +4,8 @@ import cn.cslg.pas.common.core.base.Constants;
 import cn.cslg.pas.common.dto.business.TreeNodeDTO;
 import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.exception.ConditionException;
+import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
@@ -50,6 +52,10 @@ public class TreeNodeController {
             } catch (Exception e){
                 if(e instanceof XiaoShiException) {
                     return Response.error(e.getMessage());
+                } else if (e instanceof UnLoginException) {
+                    return Response.unLogin(e.getMessage());
+                } else if (e instanceof ConditionException) {
+                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 6 - 0
src/main/java/cn/cslg/pas/domain/business/TreeNode.java

@@ -67,4 +67,10 @@ public class TreeNode extends BaseEntity<TreeNode> {
     @TableField(value = "create_time")
     private DateTime createTime;
 
+    /**
+     * 说明
+     */
+    @TableField(value = "description")
+    private String description;
+
 }

+ 104 - 28
src/main/java/cn/cslg/pas/service/business/ProductCategoryService.java

@@ -8,9 +8,7 @@ import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.common.vo.business.ProductCategoryVO;
-import cn.cslg.pas.domain.business.AssoProductCategoryFile;
-import cn.cslg.pas.domain.business.AssoProductCategoryPerson;
-import cn.cslg.pas.domain.business.ProductCategory;
+import cn.cslg.pas.domain.business.*;
 import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
@@ -66,6 +64,9 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     @Autowired
     private PermissionService permissionService;
 
+    @Autowired
+    private ProductService productService;
+
     /**
      * 查询产品类别
      * @param queryRequest
@@ -119,28 +120,39 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         //产品类别入表
         ProductCategory productCategory = new ProductCategory();
         BeanUtils.copyProperties(productCategoryDTO, productCategory);
-        productCategory.setCreateId(personnelVO.getGuid());
+        productCategory.setCreateId(personnelVO.getId());
         productCategory.setTenant(personnelVO.getTenantId());
         productCategory.insert();
-        //将创建人默认设置为管理员插入到产品类别与可见人员类型表中
+        //插入产品类别与可见人员类型表
+        List<AssoProductCategoryPerson> assoProductCategoryPeople = new ArrayList<>();
+        //默认管理员
         AssoProductCategoryPerson assoProductCategoryAdmin = new AssoProductCategoryPerson();
         assoProductCategoryAdmin.setProductCategoryId(productCategory.getId());
-        assoProductCategoryAdmin.setPersonId(personnelVO.getGuid());
+        assoProductCategoryAdmin.setPersonId(personnelVO.getId());
         assoProductCategoryAdmin.setRole(0);
-        assoProductCategoryAdmin.setCreateId(personnelVO.getGuid());
-        assoProductCategoryAdmin.insert();
+        assoProductCategoryAdmin.setCreateId(personnelVO.getId());
+        assoProductCategoryPeople.add(assoProductCategoryAdmin);
+        //设置的管理员
+        List<String> adminIds = productCategoryDTO.getAdminIds();
+        for (String adminId : adminIds) {
+            AssoProductCategoryPerson admin = new AssoProductCategoryPerson();
+            admin.setProductCategoryId(productCategory.getId());
+            admin.setPersonId(adminId);
+            admin.setRole(0);
+            admin.setCreateId(personnelVO.getId());
+            assoProductCategoryPeople.add(admin);
+        }
         //判断可见类型:
         Integer showType = productCategoryDTO.getShowType();
         if(showType != 0 && showType != 1){
             List<String> showPersonIds = productCategoryDTO.getShowPersonIds();
             //0所有人可见,1本人可见
             if(showPersonIds != null && showPersonIds.size() != 0){
-                List<AssoProductCategoryPerson> assoProductCategoryPeople = new ArrayList<>();
                 for (String showPersonId : showPersonIds) {
                     AssoProductCategoryPerson assoProductCategoryPerson = new AssoProductCategoryPerson();
                     assoProductCategoryPerson.setProductCategoryId(productCategory.getId());
                     assoProductCategoryPerson.setPersonId(showPersonId);
-                    assoProductCategoryPerson.setCreateId(personnelVO.getGuid());
+                    assoProductCategoryPerson.setCreateId(personnelVO.getId());
                     //2仅选定人可见
                     if (showType == 2) {
                         assoProductCategoryPerson.setRole(1);
@@ -166,7 +178,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                     AssoProductCategoryFile assoProductCategoryFile = new AssoProductCategoryFile();
                     assoProductCategoryFile.setProductCategoryId(productCategory.getId());
                     assoProductCategoryFile.setFileGuid(item);
-                    assoProductCategoryFile.setCreateId(personnelVO.getGuid());
+                    assoProductCategoryFile.setCreateId(personnelVO.getId());
                     assoProductCategoryFiles.add(assoProductCategoryFile);
                 }
                 if (assoProductCategoryFiles != null && assoProductCategoryFiles.size() != 0) {
@@ -188,12 +200,18 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Object deleteMessage(List<Integer> ids) throws IOException {
+        //TODO 若产品类别下有产品,或者产品类别的架构有关联的专利,或专题库,则系统提示
+        LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(Product::getCategoryId, ids);
+        List<Product> products = productService.list(queryWrapper);
+        if (products != null && products.size() != 0) {
+            throw new XiaoShiException("该产品分类下有产品");
+        }
         //根据产品类别id删除产品类别和文件关联表
-        LambdaQueryWrapper<AssoProductCategoryFile> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.in(AssoProductCategoryFile::getProductCategoryId, ids);
-        List<AssoProductCategoryFile> assoProductCategoryFiles = assoProductCategoryFileService.list(queryWrapper);
+        LambdaQueryWrapper<AssoProductCategoryFile> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(AssoProductCategoryFile::getProductCategoryId, ids);
+        List<AssoProductCategoryFile> assoProductCategoryFiles = assoProductCategoryFileService.list(wrapper);
         List<String> guids = assoProductCategoryFiles.stream().map(AssoProductCategoryFile::getFileGuid).collect(Collectors.toList());
-        //TODO 根据guids删除文件
         if (guids.size() != 0) {
             fileManagerService.deleteFileFromFMS(guids);
         }
@@ -217,6 +235,13 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         if(updateProductCategoryDTO == null || updateProductCategoryDTO.getId() == null){
             throw new XiaoShiException("参数错误");
         }
+        //获取登陆人信息 用于设置创建人
+        PersonnelVO personnelVO = new PersonnelVO();
+        try {
+            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        } catch (Exception e) {
+            throw new UnLoginException("未登录");
+        }
         ProductCategory productCategory = this.getById(updateProductCategoryDTO.getId());
         //检测名称是否不规范
         updateProductCategoryDTO.setName(updateProductCategoryDTO.getName().trim());
@@ -225,11 +250,65 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(ProductCategory::getName, name);
         List<ProductCategory> productCategories = this.list(queryWrapper);
-        if(updateProductCategoryDTO.getName() != productCategory.getName() && productCategories.size() != 0){
+        if(!updateProductCategoryDTO.getName().equals(productCategory.getName()) && productCategories.size() != 0){
             throw new XiaoShiException("名称重复");
         }
         BeanUtils.copyProperties(updateProductCategoryDTO, productCategory);
         productCategory.updateById();
+        /**
+         * 与产品类别有关的可见人员的处理
+         */
+        LambdaQueryWrapper<AssoProductCategoryPerson> personWrapper = new LambdaQueryWrapper<>();
+        personWrapper.eq(AssoProductCategoryPerson::getProductCategoryId, productCategory.getId());
+        assoProductCategoryPersonService.remove(personWrapper);
+        //插入产品类别与可见人员类型表
+        List<AssoProductCategoryPerson> assoProductCategoryPeople = new ArrayList<>();
+        //默认管理员
+        AssoProductCategoryPerson assoProductCategoryAdmin = new AssoProductCategoryPerson();
+        assoProductCategoryAdmin.setProductCategoryId(productCategory.getId());
+        assoProductCategoryAdmin.setPersonId(personnelVO.getId());
+        assoProductCategoryAdmin.setRole(0);
+        assoProductCategoryAdmin.setCreateId(personnelVO.getId());
+        assoProductCategoryPeople.add(assoProductCategoryAdmin);
+        //设置的管理员
+        List<String> adminIds = updateProductCategoryDTO.getAdminIds();
+        for (String adminId : adminIds) {
+            AssoProductCategoryPerson admin = new AssoProductCategoryPerson();
+            admin.setProductCategoryId(productCategory.getId());
+            admin.setPersonId(adminId);
+            admin.setRole(0);
+            admin.setCreateId(personnelVO.getId());
+            assoProductCategoryPeople.add(admin);
+        }
+        //判断可见类型:
+        Integer showType = updateProductCategoryDTO.getShowType();
+        if(showType != 0 && showType != 1){
+            List<String> showPersonIds = updateProductCategoryDTO.getShowPersonIds();
+            //0所有人可见,1本人可见
+            if(showPersonIds != null && showPersonIds.size() != 0){
+                for (String showPersonId : showPersonIds) {
+                    AssoProductCategoryPerson assoProductCategoryPerson = new AssoProductCategoryPerson();
+                    assoProductCategoryPerson.setProductCategoryId(productCategory.getId());
+                    assoProductCategoryPerson.setPersonId(showPersonId);
+                    assoProductCategoryPerson.setCreateId(personnelVO.getId());
+                    //2仅选定人可见
+                    if (showType == 2) {
+                        assoProductCategoryPerson.setRole(1);
+                    } else if (showType == 3) {//3选定人不可见
+                        assoProductCategoryPerson.setRole(2);
+                    } else {
+                        throw new XiaoShiException("可见类型错误");
+                    }
+                    assoProductCategoryPeople.add(assoProductCategoryPerson);
+                }
+                if(assoProductCategoryPeople != null && assoProductCategoryPeople.size() != 0){
+                    assoProductCategoryPersonService.saveBatch(assoProductCategoryPeople);
+                }
+            }
+        }
+        /**
+         * 与产品类别有关的文件的处理
+         */
         //根据产品类别id查询对应的附件id
         LambdaQueryWrapper<AssoProductCategoryFile> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(AssoProductCategoryFile::getProductCategoryId, updateProductCategoryDTO.getId());
@@ -254,13 +333,6 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
 
             }
         }
-        //获取登陆人信息 用于设置创建人
-        PersonnelVO personnelVO = new PersonnelVO();
-        try {
-            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
-        } catch (Exception e) {
-            throw new UnLoginException("未登录");
-        }
         //添加文件
         if (files != null && files.size() != 0) {
             try {
@@ -270,7 +342,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                     AssoProductCategoryFile assoProductCategoryFile = new AssoProductCategoryFile();
                     assoProductCategoryFile.setProductCategoryId(productCategory.getId());
                     assoProductCategoryFile.setFileGuid(item);
-                    assoProductCategoryFile.setCreateId(personnelVO.getGuid());
+                    assoProductCategoryFile.setCreateId(personnelVO.getId());
                     assoProductCategoryFiles.add(assoProductCategoryFile);
                 }
                 if (assoProductCategoryFiles != null && assoProductCategoryFiles.size() != 0) {
@@ -316,7 +388,6 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                     }
                 }
         );
-
         List<Personnel> personnels = new ArrayList<>();
         List<String> guids = new ArrayList<>();
         List<SystemFile> systemFiles = new ArrayList<>();
@@ -340,8 +411,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         //查询文件
         if (guids.size() != 0) {
             String res = fileManagerService.getSystemFileFromFMS(guids);
-            JSONObject jsonObject = JSONObject.parseObject(res);
-            systemFiles = JSONObject.parseArray(jsonObject.getString("data"), SystemFile.class);
+            systemFiles = JSONObject.parseArray(res, SystemFile.class);
         }
 
         //装载信息
@@ -364,7 +434,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             }
             //根据showType到产品类别与可见人员关联表中查询可见人员
             Integer showType = productCategoryVO.getShowType();
-            if(showType == 2 && showType == 3){
+            if(showType.equals(2) || showType.equals(3)){
                 LambdaQueryWrapper<AssoProductCategoryPerson> queryWrapper = new LambdaQueryWrapper<>();
                 queryWrapper.eq(AssoProductCategoryPerson::getProductCategoryId, productCategoryVO.getId());
                 queryWrapper.eq(AssoProductCategoryPerson::getRole,showType);
@@ -372,6 +442,12 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
                 List<String> showPersonIds = assoProductCategoryPeople.stream().map(AssoProductCategoryPerson::getPersonId).collect(Collectors.toList());
                 productCategoryVO.setShowPersonIds(showPersonIds);
             }
+            LambdaQueryWrapper<AssoProductCategoryPerson> adminWrapper = new LambdaQueryWrapper<>();
+            adminWrapper.eq(AssoProductCategoryPerson::getProductCategoryId, productCategoryVO.getId());
+            adminWrapper.eq(AssoProductCategoryPerson::getRole,0);
+            List<AssoProductCategoryPerson> assoProductCategoryPeople = assoProductCategoryPersonService.list(adminWrapper);
+            List<String> adminIds = assoProductCategoryPeople.stream().map(AssoProductCategoryPerson::getPersonId).collect(Collectors.toList());
+            productCategoryVO.setAdminIds(adminIds);
         }
     }
 }

+ 80 - 18
src/main/java/cn/cslg/pas/service/business/ProductService.java

@@ -112,28 +112,38 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         //产品入库
         Product product = new Product();
         BeanUtils.copyProperties(productDTO, product);
-        product.setCreateId(personnelVO.getGuid());
+        product.setCreateId(personnelVO.getId());
         product.setTenantId(personnelVO.getTenantId());
         product.insert();
-        //将创建人默认设置为管理员插入到产品类别与可见人员类型表中
+        //插入产品与可见人员类型表
+        List<AssoProductPerson> assoProductPeople = new ArrayList<>();
         AssoProductPerson assoProductAdmin = new AssoProductPerson();
         assoProductAdmin.setProductId(product.getId());
-        assoProductAdmin.setPersonId(personnelVO.getGuid());
+        assoProductAdmin.setPersonId(personnelVO.getId());
         assoProductAdmin.setRole(0);
-        assoProductAdmin.setCreateId(personnelVO.getGuid());
-        assoProductAdmin.insert();
+        assoProductAdmin.setCreateId(personnelVO.getId());
+        assoProductPeople.add(assoProductAdmin);
+        //设置的管理员
+        List<String> adminIds = productDTO.getAdminIds();
+        for (String adminId : adminIds) {
+            AssoProductPerson admin = new AssoProductPerson();
+            admin.setProductId(product.getId());
+            admin.setPersonId(adminId);
+            admin.setRole(0);
+            admin.setCreateId(personnelVO.getId());
+            assoProductPeople.add(admin);
+        }
         //判断可见类型:
         Integer showType = productDTO.getShowType();
         if(showType != 0 && showType != 1){
             List<String> showPersonIds = productDTO.getShowPersonIds();
             //0所有人可见,1本人可见
             if(showPersonIds != null && showPersonIds.size() != 0){
-                List<AssoProductPerson> assoProductPeople = new ArrayList<>();
                 for (String showPersonId : showPersonIds) {
                     AssoProductPerson assoProductPerson = new AssoProductPerson();
                     assoProductPerson.setProductId(product.getId());
                     assoProductPerson.setPersonId(showPersonId);
-                    assoProductPerson.setCreateId(personnelVO.getGuid());
+                    assoProductPerson.setCreateId(personnelVO.getId());
                     //2仅选定人可见
                     if (showType == 2) {
                         assoProductPerson.setRole(1);
@@ -158,7 +168,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
                     AssoProductFile assoProductFile = new AssoProductFile();
                     assoProductFile.setProductId(product.getId());
                     assoProductFile.setFileGuid(item);
-                    assoProductFile.setCreateId(personnelVO.getGuid());
+                    assoProductFile.setCreateId(personnelVO.getId());
                     assoProductFiles.add(assoProductFile);
                 }
                 if (assoProductFiles != null && assoProductFiles.size() != 0) {
@@ -207,6 +217,13 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         if(updateProductDTO == null || updateProductDTO.getId() == null){
             throw new XiaoShiException("参数错误");
         }
+        //获取登陆人信息 用于设置创建人
+        PersonnelVO personnelVO;
+        try {
+            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        } catch (Exception e) {
+            throw new UnLoginException("未登录");
+        }
         Product product = this.getById(updateProductDTO.getId());
         //检测名称是否不规范
         updateProductDTO.setName(updateProductDTO.getName().trim());
@@ -220,6 +237,59 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         }
         BeanUtils.copyProperties(updateProductDTO, product);
         product.updateById();
+        /**
+         * 与产品有关的可见人员的处理
+         */
+        LambdaQueryWrapper<AssoProductPerson> personWrapper = new LambdaQueryWrapper<>();
+        personWrapper.eq(AssoProductPerson::getProductId, product.getId());
+        assoProductPersonService.remove(personWrapper);
+        //插入产品与可见人员类型表
+        List<AssoProductPerson> assoProductPeople = new ArrayList<>();
+        AssoProductPerson assoProductAdmin = new AssoProductPerson();
+        assoProductAdmin.setProductId(product.getId());
+        assoProductAdmin.setPersonId(personnelVO.getId());
+        assoProductAdmin.setRole(0);
+        assoProductAdmin.setCreateId(personnelVO.getId());
+        assoProductPeople.add(assoProductAdmin);
+        //设置的管理员
+        List<String> adminIds = updateProductDTO.getAdminIds();
+        for (String adminId : adminIds) {
+            AssoProductPerson admin = new AssoProductPerson();
+            admin.setProductId(product.getId());
+            admin.setPersonId(adminId);
+            admin.setRole(0);
+            admin.setCreateId(personnelVO.getId());
+            assoProductPeople.add(admin);
+        }
+        //判断可见类型:
+        Integer showType = updateProductDTO.getShowType();
+        if(showType != 0 && showType != 1){
+            List<String> showPersonIds = updateProductDTO.getShowPersonIds();
+            //0所有人可见,1本人可见
+            if(showPersonIds != null && showPersonIds.size() != 0){
+                for (String showPersonId : showPersonIds) {
+                    AssoProductPerson assoProductPerson = new AssoProductPerson();
+                    assoProductPerson.setProductId(product.getId());
+                    assoProductPerson.setPersonId(showPersonId);
+                    assoProductPerson.setCreateId(personnelVO.getId());
+                    //2仅选定人可见
+                    if (showType == 2) {
+                        assoProductPerson.setRole(1);
+                    } else if (showType == 3) {//3选定人不可见
+                        assoProductPerson.setRole(2);
+                    } else {
+                        throw new XiaoShiException("可见类型错误");
+                    }
+                    assoProductPeople.add(assoProductPerson);
+                }
+                if(assoProductPeople != null && assoProductPeople.size() != 0){
+                    assoProductPersonService.saveBatch(assoProductPeople);
+                }
+            }
+        }
+        /**
+         * 与产品有关的文件的处理
+         */
         //根据产品id查询对应的附件id
         LambdaQueryWrapper<AssoProductFile> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(AssoProductFile::getProductId, updateProductDTO.getId());
@@ -243,13 +313,6 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
 
             }
         }
-        //获取登陆人信息 用于设置创建人
-        PersonnelVO personnelVO;
-        try {
-            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
-        } catch (Exception e) {
-            throw new UnLoginException("未登录");
-        }
         //添加文件
         if (files != null && files.size() != 0) {
             try {
@@ -259,7 +322,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
                     AssoProductFile assoProductFile = new AssoProductFile();
                     assoProductFile.setProductId(product.getId());
                     assoProductFile.setFileGuid(item);
-                    assoProductFile.setCreateId(personnelVO.getGuid());
+                    assoProductFile.setCreateId(personnelVO.getId());
                     assoProductFiles.add(assoProductFile);
                 }
                 if (assoProductFiles != null && assoProductFiles.size() != 0) {
@@ -329,8 +392,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         //查询文件
         if (guids.size() != 0) {
             String res = fileManagerService.getSystemFileFromFMS(guids);
-            JSONObject jsonObject = JSONObject.parseObject(res);
-            systemFiles = JSONObject.parseArray(jsonObject.getString("data"), SystemFile.class);
+            systemFiles = JSONObject.parseArray(res, SystemFile.class);
         }
 
         //装载信息

+ 14 - 17
src/main/java/cn/cslg/pas/service/business/TreeNodeService.java

@@ -84,15 +84,7 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     public Object addMessage(Object object, List<MultipartFile> files) {
         //object to treeNode
         TreeNodeDTO treeNodeDTO = (TreeNodeDTO)object;
-        //获取登录人信息
-        PersonnelVO personnelVO = new PersonnelVO();
-        try {
-            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
-        }
-        catch (Exception e)
-        {
-            throw  new UnLoginException("未登录");
-        }
+        //检测名称是否规范
         treeNodeDTO.setName(treeNodeDTO.getName().trim());
         //根据名称查询是否重复
         String name = treeNodeDTO.getName();
@@ -102,11 +94,17 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
         if(treeNodes != null && treeNodes.size() != 0){
             throw new XiaoShiException("参数错误");
         }
+        //获取登录人信息
+        PersonnelVO personnelVO = new PersonnelVO();
+        try {
+            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        } catch (Exception e) {
+            throw  new UnLoginException("未登录");
+        }
         //赋值
         TreeNode treeNode = new TreeNode();
         BeanUtils.copyProperties(treeNodeDTO, treeNode);
-        treeNode.setCreateId("1");
-        //数据入表
+        treeNode.setCreateId(personnelVO.getId());
         treeNode.insert();
         //处理文件
         if(files != null && files.size() != 0){
@@ -117,7 +115,7 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
                         AssoTreeNodeFile assoTreeNodeFile = new AssoTreeNodeFile();
                         assoTreeNodeFile.setTreeNodeId(treeNode.getId());
                         assoTreeNodeFile.setFileGuid(item);
-                        assoTreeNodeFile.setCreateId(personnelVO.getGuid());
+                        assoTreeNodeFile.setCreateId(personnelVO.getId());
                         assoTreeNodeFiles.add(assoTreeNodeFile);
                     }
                     if(assoTreeNodeFiles != null && assoTreeNodeFiles.size() != 0){
@@ -271,11 +269,10 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
         //装载信息
         for(TreeNodeVO treeNodeVO:treeNodeVOS){
             //装载人员信息
-            //TODO
-//            Personnel personnel = personnels.stream().filter(item -> item.getId().equals(treeNodeVO.getCreateId())).findFirst().orElse(null);
-//            if(personnel != null){
-//                treeNodeVO.setCreateName(personnel.getPersonnelName());
-//            }
+            Personnel personnel = personnels.stream().filter(item -> item.getGuid().equals(treeNodeVO.getCreateId())).findFirst().orElse(null);
+            if(personnel != null){
+                treeNodeVO.setCreateName(personnel.getPersonnelName());
+            }
             //装载文件信息
             List<AssoTreeNodeFile> assoTreeNodeFilesTemp = assoTreeNodeFiles.stream().filter(item -> item.getTreeNodeId().equals(treeNodeVO.getId())).collect(Collectors.toList());
             if(assoTreeNodeFilesTemp.size() != 0){

src/main/resources/mapper/ProductCategortMapper.xml → src/main/resources/mapper/ProductCategoryMapper.xml


+ 31 - 0
src/test/java/cn/cslg/pas/service/ProductCategoryServiceTests.java

@@ -0,0 +1,31 @@
+package cn.cslg.pas.service;
+
+import cn.cslg.pas.common.model.request.OrderDTO;
+import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.controller.ProductCategoryController;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/11/1
+ */
+@SpringBootTest
+public class ProductCategoryServiceTests {
+    @Autowired
+    private ProductCategoryController productCategoryController;
+    @Test
+    void test() throws Exception {
+        StringRequest queryRequest = new StringRequest();
+        queryRequest.setSearchQuery("");
+        queryRequest.setCurrent(Long.parseLong("1"));
+        queryRequest.setSize(Long.parseLong("10"));
+        Response response = productCategoryController.queryProductCategory(queryRequest);
+        System.out.println(response); }
+
+}