Explorar o código

2022-8-30 18:58:00 开发所属部门及专题库负责人

沈永艺 %!s(int64=3) %!d(string=hai) anos
pai
achega
acf473a567

+ 14 - 0
PAS/src/main/java/cn/cslg/pas/common/model/vo/ProjectVO.java

@@ -17,10 +17,24 @@ public class ProjectVO extends BaseVO {
     private Integer createBy;
     private String innerFile;
     private Sort sort;
+    private List<Department> departmentList;
+    private List<Personnel> personnelList;
 
     @Data
     public static class Sort {
         private String order;
         private String prop;
     }
+
+    @Data
+    public static class Department {
+        private String departmentName;
+        private Integer id;
+    }
+
+    @Data
+    public static class Personnel {
+        private String personnelName;
+        private Integer id;
+    }
 }

+ 4 - 5
PAS/src/main/java/cn/cslg/pas/common/utils/ApiUtils.java

@@ -1,7 +1,6 @@
 package cn.cslg.pas.common.utils;
 
-import com.alibaba.fastjson2.JSONArray;
-import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson.JSONObject;
 import okhttp3.MediaType;
 import okhttp3.OkHttpClient;
 import okhttp3.Request;
@@ -18,7 +17,7 @@ public class ApiUtils {
     private String url;
     public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
 
-    public JSONArray invokeApi(JSONObject params, String api, String type, String field) throws IOException {
+    public String invokeApi(JSONObject params, String api, String type, String field) throws IOException {
         RequestBody postParams = RequestBody.create(JSON, String.valueOf(params));
         OkHttpClient okHttpClient = new OkHttpClient();
         String resBody = null;
@@ -36,7 +35,7 @@ public class ApiUtils {
             resBody = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
         }
 
-       JSONObject jsonObject = JSONObject.parseObject(resBody,JSONObject.class);
-        return (JSONArray) jsonObject.get(field);
+        JSONObject jsonObject = JSONObject.parseObject(resBody, JSONObject.class);
+        return jsonObject.get(field).toString();
     }
 }

+ 9 - 0
PAS/src/main/java/cn/cslg/pas/domain/Project.java

@@ -103,6 +103,12 @@ public class Project extends BaseEntity<Project> {
     private Integer departmentId;
 
     /**
+     * 部门ID
+     */
+    @TableField("personnel_id")
+    private Integer personnelId;
+
+    /**
      * 创建时间
      */
     private Integer createTime;
@@ -130,4 +136,7 @@ public class Project extends BaseEntity<Project> {
 
     @TableField(exist = false)
     private String departmentName;
+
+    @TableField(exist = false)
+    private String personnelName;
 }

+ 3 - 2
PAS/src/main/java/cn/cslg/pas/service/PatentFieldService.java

@@ -88,7 +88,7 @@ public class PatentFieldService {
             patentFieldList.get(i).setHidden(null);
             patentFieldList.get(i).setOrder(i);
         }
-        cacheUtils.setUserSystemFieldSetting(params.getProjectId(), params.getType(), params.getView(), StpUtil.getLoginIdAsInt(), patentFieldList);
+        cacheUtils.setUserSystemFieldSetting(params.getProjectId(), params.getType(), params.getView(), 3, patentFieldList);
         params.setRefresh(false);
         return this.getUserSetting(params);
     }
@@ -231,7 +231,8 @@ public class PatentFieldService {
             add(new PatentField("caseDate", "委案日", Constants.SYSTEM_FIELD_PROJECT, 1));
             add(new PatentField("createName", "创建人", Constants.SYSTEM_FIELD_PROJECT, 1));
             add(new PatentField("createTime", "创建时间", Constants.SYSTEM_FIELD_PROJECT, 1));
-            add(new PatentField("departmentId", "所属部门", Constants.SYSTEM_FIELD_PROJECT, 1));
+            add(new PatentField("departmentName", "所属部门", Constants.SYSTEM_FIELD_PROJECT, 1));
+            add(new PatentField("personnelName", "专题库负责人", Constants.SYSTEM_FIELD_PROJECT, 1));
         }};
         return dataList;
     }

+ 42 - 24
PAS/src/main/java/cn/cslg/pas/service/ProjectService.java

@@ -3,18 +3,14 @@ package cn.cslg.pas.service;
 import cn.cslg.pas.common.core.base.Constants;
 import cn.cslg.pas.common.core.exception.CustomException;
 import cn.cslg.pas.common.model.PersonnelVO;
-import cn.cslg.pas.common.model.dto.TaskWebSocketDTO;
 import cn.cslg.pas.common.model.dto.UploadFileDTO;
+import cn.cslg.pas.common.model.params.*;
 import cn.cslg.pas.common.model.vo.*;
+import cn.cslg.pas.common.utils.*;
 import cn.cslg.pas.common.utils.SecurityUtils.SecurityUtils;
 import cn.cslg.pas.domain.*;
-import cn.cslg.pas.common.utils.*;
-import cn.cslg.pas.common.model.params.*;
-import cn.cslg.pas.common.utils.ExcelUtils;
-import cn.cslg.pas.common.utils.WebSocketServer;
 import cn.cslg.pas.mapper.ProjectMapper;
 import cn.dev33.satoken.stp.StpUtil;
-import cn.cslg.pas.common.utils.PatentUtils;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.IterUtil;
 import cn.hutool.core.date.DateField;
@@ -27,8 +23,9 @@ import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.poi.excel.ExcelReader;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
-import com.alibaba.fastjson2.JSONArray;
-import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -113,10 +110,10 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
     }
 
     public IPage<Project> getPageList(ProjectVO params) {
-        Map<String,Object> m =new HashMap<>();
-        m.put("token",params.getToken());
-        m.put("loginId",4);
-        m.put("functionId",8);
+        Map<String, Object> m = new HashMap<>();
+        m.put("token", params.getToken());
+        m.put("loginId", 4);
+        m.put("functionId", 8);
         PersonnelVO user = cacheUtils.getLoginUserPersonnel(3);
         List<Integer> projectIds = new ArrayList<Integer>() {{
             add(-1);
@@ -132,18 +129,39 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         SecurityUtils.startDataScope(m);
         IPage<Project> pageList = baseMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
         List<Project> dataList = pageList.getRecords();
-        Map<String, Object> map = new HashMap<>();
-        map.put("departmentId", dataList.stream().map(Project::getDepartmentId).collect(Collectors.toList()));
-//        try {
-//            JSONArray jsonObject = apiUtils.invokeApi(new JSONObject(map), "/permission/api/system/getDepartmentById", "post", "data");
-//            for (int i = 0; i < dataList.size(); i++) {
-//                dataList.get(i).setDepartmentName((String) jsonObject.get(i));
-//            }
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
-//        this.setDataList(dataList);
-//        pageList.setRecords(dataList);
+
+        try {
+            Map<String, Object> map = new HashMap<>();
+            map.put("departmentId", dataList.stream().map(Project::getDepartmentId).collect(Collectors.toList()));
+            String jsonObject = apiUtils.invokeApi(new JSONObject(map), "/permission/api/system/getDepartmentById", "post", "data");
+            JSONArray jsonArray1 = JSON.parseArray(jsonObject);
+            List<ProjectVO.Department> departmentList = jsonArray1.toJavaList(ProjectVO.Department.class);
+            for (Project project : dataList) {
+                for (ProjectVO.Department department : departmentList) {
+                    if (project.getDepartmentId().equals(department.getId())) {
+                        project.setDepartmentName(department.getDepartmentName());
+                    }
+                }
+            }
+
+            Map<String, Object> map1 = new HashMap<>();
+            map1.put("personnelId", dataList.stream().map(Project::getPersonnelId).collect(Collectors.toList()));
+            String jsonObject1 = apiUtils.invokeApi(new JSONObject(map1), "/permission/api/system/getPersonnelById", "post", "data");
+            JSONArray jsonArray = JSON.parseArray(jsonObject1);
+            List<ProjectVO.Personnel> personnelList = jsonArray.toJavaList(ProjectVO.Personnel.class);
+            for (Project project : dataList) {
+                for (ProjectVO.Personnel personnel : personnelList) {
+                    if (project.getPersonnelId().equals(personnel.getId())) {
+                        project.setPersonnelName(personnel.getPersonnelName());
+                    }
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        this.setDataList(dataList);
+        pageList.setRecords(dataList);
         return pageList;
     }
 

+ 10 - 9
PAS/src/main/resources/mapper/ProjectMapper.xml

@@ -2,11 +2,12 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.cslg.pas.mapper.ProjectMapper">
 
-    <select id="getPageList" parameterType="cn.cslg.pas.common.model.vo.ProjectVO" resultType="cn.cslg.pas.domain.Project">
+    <select id="getPageList" parameterType="cn.cslg.pas.common.model.vo.ProjectVO"
+            resultType="cn.cslg.pas.domain.Project">
         select a.id, a.`name`, a.creat_id as create_by, a.technical_theme,
         a.innerfile as inner_file, a.`update`, a.`status`, a.contract_no,
         a.`case` as case_date, a.update_time, a.sort, a.clientid as client_id,
-        a.scenarioid as scenario, a.typeid as type, a.remark, a.create_time,a.department_id,
+        a.scenarioid as scenario, a.typeid as type, a.remark, a.create_time,a.department_id,a.personnel_id,
         b.`name` as client_name, u.`name` as create_name,
         (select count(*) from os_thematic_file where zid = a.id and type = 1) as report_num
         from os_thematic a
@@ -25,12 +26,12 @@
             <if test="params.clientName != '' and params.clientName != null">
                 and b.name like concat('%', #{params.clientName}, '%')
             </if>
-<!--            <if test="params.myself == true">-->
-<!--                and ((a.id in-->
-<!--                <foreach item="item" index="index" collection="params.proIds" open="(" separator="," close=")">-->
-<!--                    #{item}-->
-<!--                </foreach>) or a.creat_id = #{params.createBy})-->
-<!--            </if>-->
+            <if test="params.myself == true">
+                and ((a.id in
+                <foreach item="item" index="index" collection="params.proIds" open="(" separator="," close=")">
+                    #{item}
+                </foreach>) or a.creat_id = #{params.createBy})
+            </if>
             <if test="params.type != null and params.type.size() != 0">
                 <foreach item="item" index="index" collection="params.type" open=" and (" separator="or" close=")">
                     FIND_IN_SET(#{item}, a.typeid)
@@ -41,7 +42,7 @@
                     FIND_IN_SET(#{item}, a.scenarioid)
                 </foreach>
             </if>
-        1=1
+            1=1
         </where>
         order by a.`${params.sort.prop}` ${params.sort.order}
     </select>