ソースを参照

显示栏位管理

lwhhszx 1 年間 前
コミット
771cdae5da

+ 8 - 6
src/main/java/cn/cslg/pas/common/core/base/RedisConf.java

@@ -17,10 +17,12 @@ public class RedisConf {
     public final static String USER_FIELD = "user-field";
     public final static String FIELD_ORDER = "field-order";
     public final static String USER_IMPORT = "user-import";
-    public final static String PROJECT_FIELD_ORDER="project_field_order";
-    public final static String TASK_FIELD_ORDER="task_field_order";
-    public final static  String PATENT_COUNT="patent-count";
-    public final static String TASK_FIELD_COUNT="task_field_count";
-    public final static String PROJECT_FIELD_COUNT="project_field_count";
-    public final static String FIELD_COUNT="field_count";
+    public final static String PROJECT_FIELD_ORDER = "project_field_order";
+    public final static String TASK_FIELD_ORDER = "task_field_order";
+    public final static String PATENT_COUNT = "patent-count";
+    public final static String TASK_FIELD_COUNT = "task_field_count";
+    public final static String PROJECT_FIELD_COUNT = "project_field_count";
+    public final static String FIELD_COUNT = "field_count";
+    public final static String PROJECT = "project";
+    public final static String PRODUCT = "product";
 }

+ 1 - 0
src/main/java/cn/cslg/pas/common/dto/AddSelfFieldDTO.java

@@ -13,5 +13,6 @@ public class AddSelfFieldDTO {
     private String tableName;
     private List<PersonSelfFieldVO> value;
     private Integer projectId;
+    private Integer productId;
 
 }

+ 19 - 1
src/main/java/cn/cslg/pas/controller/ProjectShareController.java

@@ -14,6 +14,7 @@ import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.AssoProjectPersonService;
 import cn.cslg.pas.service.business.AvoidDesignService;
 import cn.cslg.pas.service.business.AvoidDesignWholeService;
+import cn.cslg.pas.service.business.ProjectService;
 import io.swagger.v3.oas.annotations.Operation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 项目分享管理
@@ -37,7 +39,8 @@ import java.util.List;
 public class ProjectShareController {
     @Autowired
     private AssoProjectPersonService assoProjectPersonService;
-
+@Autowired
+private ProjectService projectService;
 
     @Operation(summary = "新增项目分享")
     @PostMapping("/addProjectShare")
@@ -86,4 +89,19 @@ public class ProjectShareController {
 
         return Response.success(records);
     }
+
+    @Operation(summary = "查询人员在项目里的角色")
+    @PostMapping("/getProjectPermissions")
+    public Response getProjectPermissions(@RequestBody List<Integer> projectIds) throws Exception {
+        Records records = new Records();
+        try {
+            Map<Integer,List<String>> map= projectService.getProjectPermissions(projectIds);
+        records.setData(map);
+        } catch (Exception e) {
+            return Response.error(e.getMessage());
+
+        }
+
+        return Response.success(records);
+    }
 }

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

@@ -44,7 +44,7 @@ public class ReportProjectController {
 
     @Operation(summary = "查询报告")
     @PostMapping("/queryReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response queryPatentProject(@RequestBody StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("reportProjectService");
         Records records = (Records) business.queryMessage(stringRequest);
@@ -54,7 +54,7 @@ public class ReportProjectController {
 
     @Operation(summary = "添加报告")
     @PostMapping("/addReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response addReportProject(@RequestBody ReportProjectDTO reportProjectDTO) throws Exception {
         if (reportProjectDTO != null) {
             Business business = businessFactory.getClass("reportProjectService");
@@ -78,7 +78,7 @@ public class ReportProjectController {
 
     @Operation(summary = "更新报告")
     @PostMapping("/updateReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response updatePatentProject(@RequestBody UpdateReportProjectDTO updateReportProjectDTO) throws Exception {
         if (updateReportProjectDTO != null) {
             Business business = businessFactory.getClass("reportProjectService");
@@ -91,7 +91,7 @@ public class ReportProjectController {
 
     @Operation(summary = "删除报告")
     @PostMapping("/deleteReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public String deletePatentProject(@RequestBody List<Integer> ids) throws Exception {
         Business business = businessFactory.getClass("reportProjectService");
         business.deleteMessage(ids);
@@ -100,7 +100,7 @@ public class ReportProjectController {
 
     @Operation(summary = "分组报告")
     @PostMapping("/groupReportProject")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response groupPatentProject(@RequestBody StringGroupRequest stringGroupRequest) throws Exception {
         Business business = businessFactory.getClass("reportProjectService");
         Records records = (Records) business.getGroup(stringGroupRequest, "reportProject");
@@ -110,7 +110,7 @@ public class ReportProjectController {
 
     @Operation(summary = "更新是否第二次无效")
     @PostMapping("/updateIfSecondInvalid")
-    @checkAuth(FunId = "xiaoshi/report")
+//    @checkAuth(FunId = "xiaoshi/report")
     public Response updateIfSecondInvalid(@RequestBody UpdateIfSecondInvalidDTO updateIfSecondInvalidDTO) throws Exception {
         try {
             reportProjectService.updateIfSecondInvalid(updateIfSecondInvalidDTO);

+ 2 - 2
src/main/java/cn/cslg/pas/service/business/InvalidStatutesService.java

@@ -82,7 +82,7 @@ public class InvalidStatutesService extends ServiceImpl<InvalidStatutesMapper, I
                     //涉及内容为说明书或者附图
                     InvalidStatutes invalidStatutes = new InvalidStatutes();
                     BeanUtils.copyProperties(invalidStatutesDTO, invalidStatutes);
-                    if (invalidStatutesDTO.getRelatedContent().equals(2)) {
+
                         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
                         PatentClaim patentClaim = new PatentClaim();
                         patentClaim.setCreateId(personnelVO.getId());
@@ -90,7 +90,7 @@ public class InvalidStatutesService extends ServiceImpl<InvalidStatutesMapper, I
                         patentClaim.setProjectId(projectId);
                         patentClaim.insert();
                         invalidStatutes.setClaimId(patentClaim.getId());
-                    }
+
 
                     invalidStatutes.insert();
                     Integer id = invalidStatutes.getId();

+ 54 - 1
src/main/java/cn/cslg/pas/service/business/ProjectService.java

@@ -1,14 +1,20 @@
 package cn.cslg.pas.service.business;
 
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
+import cn.cslg.pas.common.utils.CacheUtils;
+import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.domain.business.AssoProductPerson;
+import cn.cslg.pas.domain.business.AssoProjectPerson;
 import cn.cslg.pas.domain.business.Project;
 import cn.cslg.pas.mapper.AssoProductPersonMapper;
 import cn.cslg.pas.mapper.ProjectMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Optional;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 项目业务层
@@ -20,8 +26,55 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
     @Autowired
     private ProjectMapper projectMapper;
 
+    @Autowired
+    private CacheUtils cacheUtils;
+    @Autowired
+    private LoginUtils loginUtils;
+    @Autowired
+    private  AssoProjectPersonService assoProjectPersonService;
     public Optional<Project> getByIdOpt(Integer id) {
         Project project = projectMapper.selectById(id);
         return Optional.ofNullable(project);
     }
+
+    public Map<Integer,List<String>> getProjectPermissions(List<Integer> projectIds){
+        Map<Integer,List<String>> map =new HashMap<>();
+        if(projectIds==null||projectIds.size()==0){
+            return map;
+        }
+        projectIds.forEach(
+              item->{
+                  map.put(item,new ArrayList<>());
+              }
+        );
+        PersonnelVO personnelVO=cacheUtils.getLoginUser(loginUtils.getId());
+        String id =personnelVO.getId();
+        LambdaQueryWrapper<Project> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.select(Project::getId,Project::getCreateId,Project::getHeadId);
+        queryWrapper.in(Project::getId,projectIds);
+        List<Project> projects =this.list(queryWrapper);
+
+        projects.forEach(item->{
+            Integer projectId= item.getId();
+            String createId =item.getCreateId();
+            String headId =item.getHeadId();
+            List<String> roles =map.get(projectId);
+            if(id.equals(createId))
+            {roles.add("0");}
+            if(id.equals(headId)){
+                roles.add("1");
+            }
+        });
+        LambdaQueryWrapper<AssoProjectPerson> queryWrapper1 =new LambdaQueryWrapper<>();
+        queryWrapper1.in(AssoProjectPerson::getProjectId,projectIds);
+        queryWrapper1.eq(AssoProjectPerson::getPersonId,id);
+        List<AssoProjectPerson> assoProjectPersonList =assoProjectPersonService.list(queryWrapper1);
+        assoProjectPersonList.forEach(item->{
+            Integer projectId =item.getProjectId();
+            List<String> roles =map.get(projectId);
+            roles.add("2");
+        });
+
+return map;
+    }
 }

+ 45 - 61
src/main/java/cn/cslg/pas/service/common/PersonFieldService.java

@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -177,7 +178,7 @@ public class PersonFieldService {
                     });
                 }
                 //当是专利的配置时
-                if (item.getTableName().trim().equals(PatentDictionary.NAME)) {
+                if (item.getTableName().trim().equals(PatentDictionary.NAME)&&item.getProjectId()!=null) {
                     //根据专题库id 查询所有自定义字段
                     List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(item.getProjectId());
                     //遍历装载
@@ -254,6 +255,7 @@ public class PersonFieldService {
         Integer projectId = getTabelColumDTO.getProjectId();
         Integer taskId = getTabelColumDTO.getTaskId();
         String tableName = getTabelColumDTO.getTableName();
+        Integer productId = getTabelColumDTO.getProductId();
         //根据登录人id和type查询
         PersonnelVO personnelVO = new PersonnelVO();
         try {
@@ -265,19 +267,23 @@ public class PersonFieldService {
         String key = "";
 
         if (projectId == null) {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
+            if (productId != null) {
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId);
+            } else {
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
+            }
         } else {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId);
+            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId);
         }
+        String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
+        String json = redisUtil.get(redisKey);
 
-        String json = redisUtil.get(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key);
-
+        String fieldJson = "";
         //如果查到
+        List<PersonSelfFieldVO> reFieldVos =new ArrayList<>();
         if (StringUtils.isNotEmpty(json)) {
-            return JsonUtils.jsonToList(json, PersonSelfFieldVO.class);
+            reFieldVos =JsonUtils.jsonToList(json, PersonSelfFieldVO.class);
         }
-        String fieldJson = "";
-        //如果没查询到,则获取所有栏位添加到redis里
         try {
             fieldJson = CommonService.readJsonFile(tableName + ".json");
         } catch (Exception e) {
@@ -292,15 +298,14 @@ public class PersonFieldService {
         if (fieldVOS == null || fieldVOS.size() == 0) {
             throw new XiaoShiException("表中无字段");
         }
-        fieldVOS.forEach(item -> {
-            item.setCreateType(1);
-        });
+
+
 
         //当tableName是patent时
-        if (PatentDictionary.NAME.equals(tableName)) {
+        if (PatentDictionary.NAME.equals(tableName)&&projectId!=null) {
             //获得所有自定义字段
             List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId);
-            AllCustomFieldVO allCustomFieldVO =new AllCustomFieldVO();
+            AllCustomFieldVO allCustomFieldVO = new AllCustomFieldVO();
             allCustomFieldVO.setName("标签");
             allCustomFieldVO.setId(0);
             allCustomFieldVO.setType(10);
@@ -320,20 +325,25 @@ public class PersonFieldService {
 
         }
         //装载顺序
-        Integer order = 0;
         for (PersonSelfFieldVO item : fieldVOS) {
-            item.setOrder(order);
-            if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) {
-                item.setIfHidden(true);
-            } else {
-                item.setIfHidden(false);
+            PersonSelfFieldVO personSelfFieldVO =reFieldVos.stream().filter(t->t.getValue().equals(item.getValue())&&t.getType().equals(item.getType())).findFirst().orElse(null);
+
+            if(personSelfFieldVO==null) {
+                if(StringUtils.isNotEmpty(json))
+                {
+                    item.setIfHidden(true);
+                }
+                else {
+                    if (item.getDefaultHidden() != null && item.getDefaultHidden().equals(true)) {
+                        item.setIfHidden(true);
+                    } else {
+                        item.setIfHidden(false);
+                    }
+                }
+                reFieldVos.add(item);
             }
-            order++;
         }
-
-        //保存到redis
-        redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
-        return fieldVOS;
+        return reFieldVos;
     }
 
     public List<PersonSelfFieldVO> setTableColumns(AddSelfFieldDTO addSelfFieldDTO) {
@@ -346,49 +356,23 @@ public class PersonFieldService {
         String userId = personnelVO.getId();
         String tableName = addSelfFieldDTO.getTableName();
         Integer projectId = addSelfFieldDTO.getProjectId();
+        Integer productId =addSelfFieldDTO.getProductId();
+        List<PersonSelfFieldVO> personSelfFieldVOS =addSelfFieldDTO.getValue();
+        personSelfFieldVOS= personSelfFieldVOS.stream().filter(item->item.getIfHidden()!=null&&item.getIfHidden().equals(false)).collect(Collectors.toList());
         String key = "";
         if (projectId == null) {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
-        } else {
-            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + projectId);
-        }
-        String fieldJson = CommonService.readJsonFile(addSelfFieldDTO.getTableName() + ".json");
-        List<PersonSelfFieldVO> fieldVOS = JSON.parseArray(fieldJson, PersonSelfFieldVO.class);
-        fieldVOS = fieldVOS.stream().filter(item -> item.getIfShow().equals(true)).collect(Collectors.toList());
-        //当tableName是patent时
-        if (PatentDictionary.NAME.equals(tableName)) {
-            //获得所有自定义字段
-            List<AllCustomFieldVO> allCustomFieldVOS = customFieldService.getAllProjectCustomField(projectId);
-            if (allCustomFieldVOS.size() != 0) {
-                for (AllCustomFieldVO item : allCustomFieldVOS) {
-                    PersonSelfFieldVO personSelfFieldVO = new PersonSelfFieldVO();
-                    personSelfFieldVO.setIfHidden(true);
-                    personSelfFieldVO.setName(item.getName());
-                    personSelfFieldVO.setType(item.getType().toString());
-                    personSelfFieldVO.setValue(item.getId().toString());
-                    personSelfFieldVO.setDefaultHidden(true);
-                    fieldVOS.add(personSelfFieldVO);
-                }
-            }
-        }
-        for (PersonSelfFieldVO item : fieldVOS) {
-            PersonSelfFieldVO temVO = addSelfFieldDTO.getValue().stream().filter(tem -> tem.getValue().equals(item.getValue())).findFirst().orElse(null);
-            if (temVO == null) {
-                item.setIfHidden(true);
+            if (productId != null) {
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PRODUCT + RedisConf.SYMBOL_COLON + productId);
             } else {
-                item.setIfHidden(temVO.getIfHidden());
+                key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId);
             }
+        } else {
+            key = SecureUtil.md5(tableName + RedisConf.SYMBOL_COLON + userId + RedisConf.SYMBOL_COLON + RedisConf.PROJECT + RedisConf.SYMBOL_COLON + projectId);
         }
+        String redisKey = RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key;
+        redisUtil.set(redisKey, JsonUtils.objectToJson(personSelfFieldVOS));
 
-        Integer order = 0;
-
-        for (PersonSelfFieldVO item : fieldVOS) {
-            item.setOrder(order);
-            order++;
-        }
-        redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(fieldVOS));
-
-        return fieldVOS;
+        return personSelfFieldVOS;
     }
 
     /**

+ 6 - 9
src/test/java/cn/cslg/pas/service/CommonServiceTests.java

@@ -28,10 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -140,10 +137,10 @@ public class CommonServiceTests {
 //李仁杰<2232723707@qq.com>"
     @Test
     public void testEmail() throws Exception{
-//        mailSendService.sendSynery("李仁杰<2232623707@qq.com>",false,1,1,1);
-      //  mailSendService.sentToCCMail("李仁杰<2232623707@qq.com>",false,"刘德华");
-//        mailSendService.sentToCCMail("323",true,"张学友");
-        reportExportService.exportReport(1,1);
-        Thread.sleep(10000);
+ Map<String,List<String>> map =new HashMap<>();
+ map.put("a",new ArrayList<>());
+ List<String> aa =map.get("a");
+ aa.add("111");
+ System.out.println(aa);
     }
     }