Преглед на файлове

fix: 工作考核优化

zhangying преди 1 седмица
родител
ревизия
377aaf7626

+ 55 - 3
src/main/java/com/ghsc/partybuild/controller/CheckDataController.java

@@ -248,15 +248,15 @@ public class CheckDataController {
 
     @RequestMapping("/downCheckDataZip")
     public String downCheckDataZip(HttpServletResponse response,
-                                   String year,
-                                   HttpServletRequest request) {
+                                   HttpServletRequest request,
+                                   String year, String dzzdm, String remark, String roleID, String userid) {
         ZipOutputStream out = null;
         String fileName = String.format("%s年度考核材料.zip", year);
         try {
             ByteArrayOutputStream fileOStream = new ByteArrayOutputStream();
             out = new ZipOutputStream(fileOStream);
             out.setEncoding("gbk");
-            List<HashMap<String, Object>> dataList = checkDataService.getCheckDataFleList(year);
+            List<HashMap<String, Object>> dataList = checkDataService.getCheckDataFleList(year, dzzdm, remark, roleID, userid);
             FTPClient ftpClient = new FTPClient();
             ftpHelper.connectToServer(ftpClient);
             ftpClient.enterLocalPassiveMode();
@@ -309,4 +309,56 @@ public class CheckDataController {
         }
         return "";
     }
+
+    @RequestMapping(value = "/exportCheckScore", method = RequestMethod.GET)
+    public void exportCheckScore(HttpServletResponse response,
+                                 Integer year, Integer quarter, String dzzdm, String checkUserName, Float minScore, Float maxScore, Integer recordStatus, String roleID, String userid) throws Exception {
+
+        /**查询数据**/
+        final boolean isAdmin = isAdmin(userService.getLoginUser().getUserid());
+        String checkuserid=userService.getLoginUser().getUserid();
+        if(isAdmin){
+            checkuserid="";
+        }
+        List<HashMap<String, Object>> dataList = checkDataService.getCheckScoreList(1, 9999, year, quarter, dzzdm, checkUserName, minScore, maxScore, recordStatus,checkuserid, roleID, userid).getList();
+
+        ExcelHelper excelHelper = new ExcelHelper();
+        ExcelHelper.ExcelData data = excelHelper.new ExcelData();
+
+        //列名
+        data.setName("考核评分信息");
+        List<String> titles = new ArrayList();
+        titles.add("年度");
+        titles.add("季度");
+        titles.add("组织名称");
+        titles.add("评分");
+        titles.add("问题数量");
+        titles.add("核查工作人员");
+        titles.add("评分时间");
+        titles.add("状态");
+        data.setTitles(titles);
+
+        //数据
+        List<List<Object>> rows = new ArrayList();
+        for (Map<String, Object> item : dataList) {
+            List<Object> row = new ArrayList();
+            row.add(item.get("year"));
+            row.add(item.get("quarter"));
+            row.add(item.get("dzzmc"));
+            row.add(item.get("score") != null ? item.get("score") + "" : "");
+            row.add(item.get("questionnum") != null ? item.get("questionnum") + "" : "");
+            row.add(item.get("checkusername"));
+            if (item.containsKey("updatetime") && item.get("updatetime") != null && !item.get("updatetime").equals("")) {
+                row.add(dateUtils.strFormat(item.get("updatetime").toString()));
+            } else {
+                row.add("");
+            }
+            row.add(item.get("recordstatusname"));
+
+            rows.add(row);
+        }
+        data.setRows(rows);
+
+        excelHelper.exportExcel(response, "考核评分信息.xlsx", data);
+    }
 }

+ 1 - 1
src/main/java/com/ghsc/partybuild/mapper/PtCheckdataCQuery.java

@@ -15,7 +15,7 @@ public interface PtCheckdataCQuery {
 
     List<HashMap<String,Object>> selectCheckDataList(Integer year, String dzzdm, String remark, String dzzdmInStr);
 
-    List<HashMap<String,Object>> selectCheckDataFleList(@Param("year") String year);
+    List<HashMap<String,Object>> selectCheckDataFleList(@Param("year") String year, String dzzdm, String remark, String dzzdmInStr);
 
     List<HashMap<String,Object>> selectCheckScoreList(Integer year, Integer quarter, String dzzdm, String checkUserName, Float minScore,Float maxScore,Integer recordStatus,String checkuserid, String dzzdmInStr);
 }

+ 1 - 1
src/main/java/com/ghsc/partybuild/service/CheckDataService.java

@@ -22,7 +22,7 @@ public interface CheckDataService {
 
     PageInfo<HashMap<String, Object>> getCheckDataList(int pageIndex, int pageSize, Integer year, String dzzdm, String remark, String roleID, String userid);
 
-    List<HashMap<String, Object>> getCheckDataFleList( String year);
+    List<HashMap<String, Object>> getCheckDataFleList(String year, String dzzdm, String remark, String roleID, String userid);
 
     int saveCheckdata(PtCheckdata item,String userid,String username);
 

+ 62 - 37
src/main/java/com/ghsc/partybuild/service/impl/CheckDataServiceImpl.java

@@ -40,6 +40,9 @@ public class CheckDataServiceImpl implements CheckDataService {
     @Autowired
     StringUtils stringUtils;
 
+    @Autowired
+    private CfUserrolesMapper cfUserrolesMapper;
+
 
     @Override
     public PageInfo<HashMap<String, Object>> getCheckNameList(int pageIndex, int pageSize, Integer year, Integer quarter, String dzzdm, String checkUserName, String partyCode, Integer recordStatus) {
@@ -151,6 +154,39 @@ public class CheckDataServiceImpl implements CheckDataService {
         PtChecknamelistExample ckExp = new PtChecknamelistExample();
         ckExp.or().andNameidIn(nameIdList);
         checknamelistMapper.updateByExampleSelective(record, ckExp);
+        
+        // 设置核查人员角色
+        for (String nameId : nameIdList) {
+            PtChecknamelist checknamelist = checknamelistMapper.selectByPrimaryKey(nameId);
+            if (checknamelist != null) {
+                if (recordStatus == 1) {
+                    // 启用状态
+                    // 查询选择的用户是否有检查人员权限
+                    List<HashMap<String, Object>> userInfo = cfUsersCQuery.selectUserAllByUserID(checknamelist.getCheckuserid());
+                    if (!userInfo.isEmpty()) {
+                        // 查询该用户是否绑定了检查人员角色
+                        List<HashMap<String, Object>> roleList = cfUsersCQuery.GetRoleByUserId(checknamelist.getCheckuserid());
+                        HashMap<String, Object> jcRole = roleList.stream().filter(it -> it.get("ROLEID").equals("27f0fd61-3107-486f-9240-4f9ef909103e")).findFirst().orElse(null);
+                        if (jcRole == null) {
+                            // 没有检查人员角色的,绑定一个
+                            userService.saveUserRoleList("27f0fd61-3107-486f-9240-4f9ef909103e", checknamelist.getCheckuserid(), false);
+                        }
+                    }
+                } else {
+                    // 禁用状态
+                    // 查询该人员是否还有启用状态的记录
+                    PtChecknamelistExample example = new PtChecknamelistExample();
+                    example.or().andCheckuseridEqualTo(checknamelist.getCheckuserid()).andRecordstatusEqualTo(1);
+                    List<PtChecknamelist> list = checknamelistMapper.selectByExample(example);
+                    if (list.isEmpty()) {
+                        // 所有记录都是禁用,则删除该用户的核查人员角色
+                        CfUserrolesExample expUr2 = new CfUserrolesExample();
+                        expUr2.or().andUseridEqualTo(checknamelist.getCheckuserid()).andRoleidEqualTo("27f0fd61-3107-486f-9240-4f9ef909103e");
+                        cfUserrolesMapper.deleteByExample(expUr2);
+                    }
+                }
+            }
+        }
         return 1;
     }
 
@@ -167,23 +203,7 @@ public class CheckDataServiceImpl implements CheckDataService {
     @Override
     public PageInfo<HashMap<String, Object>> getCheckDataList(int pageIndex, int pageSize, Integer year, String dzzdm, String remark, String roleID, String userid) {
         // 如果是核查人员,只允许查询用户核查名单中存在的组织的材料数据
-        String dzzdmInStr = null;
-        if (!stringUtils.IsNullOrEmpty(roleID) && roleID.equals("27f0fd61-3107-486f-9240-4f9ef909103e")) {
-            List<HashMap<String, Object>> checkNameList = checkdataCQuery.selectCheckNameList(null, null, null, null, null, null, userid);
-            // 获取党组织代码
-            List<String> distinctDzzdmList = checkNameList.stream()
-                    .map(item -> item.get("partcodes"))            // 获取 partcodes 值(可能为单值或多值)
-                    .filter(Objects::nonNull)                      // 过滤 null
-                    .map(Object::toString)                         // 转为 String
-                    .flatMap(s -> Arrays.stream(s.split("\\s*,\\s*"))) // 按逗号分割(兼容前后空格)
-                    .filter(s -> !s.isEmpty())                     // 过滤空字符串(防止分割后产生空值)
-                    .distinct()                                    // 去重
-                    .collect(Collectors.toList());                 // 收集为 List
-            if (!distinctDzzdmList.isEmpty()) {
-                // 拼接in查询条件
-                dzzdmInStr = stringUtils.ListToInSql(distinctDzzdmList);
-            }
-        }
+        String dzzdmInStr = getDzzdmInStr(roleID, userid);
         PageHelper.startPage(pageIndex, pageSize);
         List<HashMap<String, Object>> list = checkdataCQuery.selectCheckDataList(year, dzzdm, remark, dzzdmInStr);
 
@@ -193,9 +213,10 @@ public class CheckDataServiceImpl implements CheckDataService {
     }
 
     @Override
-    public List<HashMap<String, Object>> getCheckDataFleList(String year) {
-
-        List<HashMap<String, Object>> list = checkdataCQuery.selectCheckDataFleList(year);
+    public List<HashMap<String, Object>> getCheckDataFleList(String year, String dzzdm, String remark, String roleID, String userid) {
+        // 如果是核查人员,只允许查询用户核查名单中存在的组织的材料数据
+        String dzzdmInStr = getDzzdmInStr(roleID, userid);
+        List<HashMap<String, Object>> list = checkdataCQuery.selectCheckDataFleList(year, dzzdm, remark, dzzdmInStr);
 
         return list;
     }
@@ -227,23 +248,7 @@ public class CheckDataServiceImpl implements CheckDataService {
     @Override
     public PageInfo<HashMap<String, Object>> getCheckScoreList(int pageIndex, int pageSize, Integer year, Integer quarter, String dzzdm, String checkUserName, Float minScore,Float maxScore,Integer recordStatus,String checkuserid, String roleID, String userid) {
         // 如果是核查人员,只允许查询用户核查名单中存在的组织的材料数据
-        String dzzdmInStr = null;
-        if (!stringUtils.IsNullOrEmpty(roleID) && roleID.equals("27f0fd61-3107-486f-9240-4f9ef909103e")) {
-            List<HashMap<String, Object>> checkNameList = checkdataCQuery.selectCheckNameList(null, null, null, null, null, null, userid);
-            // 获取党组织代码
-            List<String> distinctDzzdmList = checkNameList.stream()
-                    .map(item -> item.get("partcodes"))            // 获取 partcodes 值(可能为单值或多值)
-                    .filter(Objects::nonNull)                      // 过滤 null
-                    .map(Object::toString)                         // 转为 String
-                    .flatMap(s -> Arrays.stream(s.split("\\s*,\\s*"))) // 按逗号分割(兼容前后空格)
-                    .filter(s -> !s.isEmpty())                     // 过滤空字符串(防止分割后产生空值)
-                    .distinct()                                    // 去重
-                    .collect(Collectors.toList());                 // 收集为 List
-            if (!distinctDzzdmList.isEmpty()) {
-                // 拼接in查询条件
-                dzzdmInStr = stringUtils.ListToInSql(distinctDzzdmList);
-            }
-        }
+        String dzzdmInStr = getDzzdmInStr(roleID, userid);
         PageHelper.startPage(pageIndex, pageSize);
         List<HashMap<String, Object>> list = checkdataCQuery.selectCheckScoreList( year,  quarter,  dzzdm,  checkUserName,  minScore, maxScore, recordStatus,checkuserid,dzzdmInStr);
 
@@ -285,4 +290,24 @@ public class CheckDataServiceImpl implements CheckDataService {
         example.or().andScoreidEqualTo(scoreId);
        return checkquestionMapper.selectByExample(example);
     }
+
+    public String getDzzdmInStr(String roleID, String userID) {
+        if (!stringUtils.IsNullOrEmpty(roleID) && roleID.equals("27f0fd61-3107-486f-9240-4f9ef909103e")) {
+            List<HashMap<String, Object>> checkNameList = checkdataCQuery.selectCheckNameList(null, null, null, null, null, 1, userID);
+            // 获取党组织代码
+            List<String> distinctDzzdmList = checkNameList.stream()
+                    .map(item -> item.get("partcodes"))            // 获取 partcodes 值(可能为单值或多值)
+                    .filter(Objects::nonNull)                      // 过滤 null
+                    .map(Object::toString)                         // 转为 String
+                    .flatMap(s -> Arrays.stream(s.split("\\s*,\\s*"))) // 按逗号分割(兼容前后空格)
+                    .filter(s -> !s.isEmpty())                     // 过滤空字符串(防止分割后产生空值)
+                    .distinct()                                    // 去重
+                    .collect(Collectors.toList());                 // 收集为 List
+            if (!distinctDzzdmList.isEmpty()) {
+                // 拼接in查询条件
+                return stringUtils.ListToInSql(distinctDzzdmList);
+            }
+        }
+        return null;
+    }
 }

+ 9 - 0
src/main/resources/mapping/PtCheckdataCQuery.xml

@@ -79,6 +79,15 @@
             <if test="year != null and year != ''">
                 and pcd.year = #{year}
             </if>
+            <if test="remark != null and remark != ''">
+                and pcd.remark like concat('%',#{remark},'%')
+            </if>
+            <if test="dzzdm != null and dzzdm != ''">
+                and pcd.dzzdm like concat('%',#{dzzdm},'%')
+            </if>
+            <if test="dzzdmInStr != null and dzzdmInStr != ''">
+                and pcd.dzzdm in (${dzzdmInStr})
+            </if>
         </where>
     </select>
     <select id="selectCheckScoreList" resultType="java.util.HashMap" parameterType="java.lang.String">

+ 1 - 1
src/main/resources/static/app/main/party/checkScore/list.js

@@ -250,7 +250,7 @@
                     if ($scope.selectparams[p] !== '' && $scope.selectparams[p] !== null)
                         params += ("&" + p + "=" + encodeURI($scope.selectparams[p]));
                 }
-                window.open('../../api/checkdata/exportCheckData' + params);
+                window.open('../../api/checkdata/exportCheckScore' + params);
             }
         };