ソースを参照

作者:张哲
时间:2023/08/31
类型:优化
描述:测试环境bug修改

zizg 1 年間 前
コミット
bbed0b99f5

+ 12 - 2
src/main/java/com/redxun/knowledge/album/service/AlbumApproveServiceImpl.java

@@ -139,6 +139,10 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
             AlbumApproveVo albumApproveVo = new AlbumApproveVo();
             BeanUtils.copyProperties(albumApproveList.get(i), albumApproveVo);
             albumApproveVo.setComment(albumApproveList.get(i).getRemark());
+            //如果实际审核人是空,采用待审核人
+            if (StringUtils.isEmpty(albumApproveVo.getActualApproverName())){
+                albumApproveVo.setActualApproverName(albumApproveList.get(i).getApproverName());
+            }
             if (albumApproveList.get(i).getResult() == null) {
                 if (flag) {
                     albumApproveVo.setApprovalStatus("提交审核");
@@ -287,11 +291,17 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
             queryWrapper.orderByAsc("SORT");
             AlbumApprove albumApproveBySort = albumApproveMapper.selectOne(queryWrapper);
             if (albumApproveBySort != null) {
-                String actualApproverName = albumApproveBySort.getActualApproverName();
-                albumApproveListVo.setPreviousApproverName(actualApproverName);
+                //String actualApproverName = albumApproveBySort.getActualApproverName();
+                //albumApproveListVo.setPreviousApproverName(actualApproverName);
                 Date approvalTime = albumApproveBySort.getApprovalTime();
                 albumApproveListVo.setPreviousApproverTime(approvalTime);
             }
+            //如果实际审核人是空,采用待审核人
+            if (StringUtils.isEmpty(albumApprove.getActualApproverName())){
+                albumApproveListVo.setPreviousApproverName(albumApprove.getApproverName());
+            } else {
+                albumApproveListVo.setPreviousApproverName(albumApprove.getActualApproverName());
+            }
         }
         return albumApproveListVo;
 

+ 16 - 12
src/main/java/com/redxun/knowledge/album/service/AlbumCategoryServiceImpl.java

@@ -216,13 +216,15 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
         AlbumCategory albumCategory = albumCategoryMapper.selectById(ids);
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(albumCategory.getCreateBy())){
-            throw new RuntimeException("您没有权限进行此操作");
-        }
+        //创建人校验
+        boolean createbybol = userId.equals(albumCategory.getCreateBy());
+        //维护人校验
+        boolean maintainerbol = false;
         if (StringUtils.isNotEmpty(albumCategory.getMaintainer())){
-            if (!Arrays.asList(albumCategory.getMaintainer().split(",")).contains(userId)){
-                throw new RuntimeException("您没有权限进行此操作");
-            }
+            maintainerbol = Arrays.asList(albumCategory.getMaintainer().split(",")).contains(userId);
+        }
+        if (!createbybol && !maintainerbol){
+            throw new RuntimeException("您没有权限进行此操作");
         }
         List<AlbumInfo> albumInfoList = albumInfoMapper.
                 selectList(new QueryWrapper<AlbumInfo>().eq("CATEGORY_ID", ids));
@@ -257,13 +259,15 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
         }
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(albumCategoryBefore.getCreateBy())){
-            throw new RuntimeException("您没有权限进行此操作");
-        }
+        //创建人校验
+        boolean createbybol = userId.equals(albumCategoryBefore.getCreateBy());
+        //维护人校验
+        boolean maintainerbol = false;
         if (StringUtils.isNotEmpty(albumCategoryBefore.getMaintainer())){
-            if (!Arrays.asList(albumCategoryBefore.getMaintainer().split(",")).contains(userId)){
-                throw new RuntimeException("您没有权限进行此操作");
-            }
+            maintainerbol = Arrays.asList(albumCategoryBefore.getMaintainer().split(",")).contains(userId);
+        }
+        if (!createbybol && !maintainerbol){
+            throw new RuntimeException("您没有权限进行此操作");
         }
         if (albumCategory.getParent().isEmpty()) {
             albumCategory.setParent("0");

+ 6 - 0
src/main/java/com/redxun/knowledge/album/service/AlbumInfoServiceImpl.java

@@ -435,6 +435,10 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             AlbumApproveVo albumApproveVo = new AlbumApproveVo();
             BeanUtils.copyProperties(albumApproveList.get(i), albumApproveVo);
             albumApproveVo.setComment(albumApproveList.get(i).getRemark());
+            //如果实际审核人是空,采用待审核人
+            if (StringUtils.isEmpty(albumApproveVo.getActualApproverName())){
+                albumApproveVo.setActualApproverName(albumApproveList.get(i).getApproverName());
+            }
             if (albumApproveList.get(i).getResult() == null) {
                 if (flag) {
                     albumApproveVo.setApprovalStatus("提交审核");
@@ -509,6 +513,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
     public List<AlbumApproverNodeVo> approveFlowsAlbumApprovalNode() {
         String userId = userService.queryLoginUser();
         List<AlbumApprovalNode> albumApprovalNodeList = albumApprovalNodeService.findAllAlbumApprovalNode(userId);
+        albumApprovalNodeList = albumApprovalNodeList.stream().filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).collect(Collectors.toList());
         List<AlbumApproverNodeVo> collect = albumApprovalNodeList.parallelStream().map(e -> {
             AlbumApproverNodeVo albumApproverNodeVo = new AlbumApproverNodeVo();
             BeanUtils.copyProperties(e, albumApproverNodeVo);
@@ -534,6 +539,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
     public List<AlbumApproverNodeVo> approveFlowsAlbumYelpApprovalNode() {
         String userId = userService.queryLoginUser();
         List<AlbumYelpApprovalNode> albumYelpApprovalNodeList = albumYelpApprovalNodeService.findAllAlbumApprovalNode(userId);
+        albumYelpApprovalNodeList = albumYelpApprovalNodeList.stream().filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).collect(Collectors.toList());
         List<AlbumApproverNodeVo> collect = albumYelpApprovalNodeList.parallelStream().map(e -> {
             AlbumApproverNodeVo albumApproverNodeVo = new AlbumApproverNodeVo();
             BeanUtils.copyProperties(e, albumApproverNodeVo);

+ 8 - 2
src/main/java/com/redxun/knowledge/album/service/AlbumYelpApproveServiceImpl.java

@@ -202,11 +202,17 @@ public class AlbumYelpApproveServiceImpl extends SuperServiceImpl<AlbumYelpAppro
             queryWrapper.orderByAsc("SORT");
             AlbumYelpApprove albumYelpApproveBySort = albumYelpApproveMapper.selectOne(queryWrapper);
             if (albumYelpApproveBySort != null) {
-                String actualApproverName = albumYelpApproveBySort.getActualApproverName();
-                albumApproveListVo.setPreviousApproverName(actualApproverName);
+                //String actualApproverName = albumYelpApproveBySort.getActualApproverName();
+                //albumApproveListVo.setPreviousApproverName(actualApproverName);
                 Date approvalTime = albumYelpApproveBySort.getApprovalTime();
                 albumApproveListVo.setPreviousApproverTime(approvalTime);
             }
+            //如果实际审核人是空,采用待审核人
+            if (StringUtils.isEmpty(albumYelpApprove.getActualApproverName())){
+                albumApproveListVo.setPreviousApproverName(albumYelpApprove.getApproverName());
+            } else {
+                albumApproveListVo.setPreviousApproverName(albumYelpApprove.getActualApproverName());
+            }
         }
         return albumApproveListVo;
 

+ 2 - 2
src/main/java/com/redxun/knowledge/analysis/controller/AnalysisCommonController.java

@@ -363,8 +363,8 @@ public class AnalysisCommonController {
         //获取当前年
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
-        result.put("beginTime",DateUtils.format(DateUtils.getFirstOfYear(year)));
-        result.put("endTime",DateUtils.format(DateUtils.getLastOfYear(year)));
+        result.put("beginTime",DateUtils.format(DateUtils.getFirstOfYearByUser(year)));
+        result.put("endTime",DateUtils.format(new Date()));
         return jsonResult.setData(result);
     }
 }

+ 6 - 6
src/main/java/com/redxun/knowledge/analysis/service/AnalysisCommonServiceImpl.java

@@ -443,11 +443,11 @@ public class AnalysisCommonServiceImpl {
             yelpSum = analysisCommonMapper.yelpSum(userId,beginTime,endTime);
         } else {
             //知识上传量
-            knowledgeSum = analysisCommonMapper.knowledgeSum(userId,DateUtils.format(DateUtils.getFirstOfYear(year)),
-                    DateUtils.format(DateUtils.getLastOfYear(year)));
+            knowledgeSum = analysisCommonMapper.knowledgeSum(userId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
+                    DateUtils.format(new Date()));
             //专辑点评量
-            yelpSum = analysisCommonMapper.yelpSum(userId,DateUtils.format(DateUtils.getFirstOfYear(year)),
-                    DateUtils.format(DateUtils.getLastOfYear(year)));
+            yelpSum = analysisCommonMapper.yelpSum(userId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
+                    DateUtils.format(new Date()));
         }
         String deptPath = pvLogMapper.findAllDeptIdByDeptId(userService.queryUser(userId).getDeptId());
         if (StringUtils.isNotEmpty(deptPath)) {
@@ -497,8 +497,8 @@ public class AnalysisCommonServiceImpl {
         if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {
             result = analysisCommonMapper.knowledgeSumAndYelpSumList(beginTime,endTime,pageNo,pageSize);
         } else {
-            result = analysisCommonMapper.knowledgeSumAndYelpSumList(DateUtils.format(DateUtils.getFirstOfYear(year)),
-                    DateUtils.format(DateUtils.getLastOfYear(year)),pageNo,pageSize);
+            result = analysisCommonMapper.knowledgeSumAndYelpSumList(DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
+                    DateUtils.format(new Date()),pageNo,pageSize);
         }
         result.forEach(e -> {
             e.setDeptId(userService.queryUser(e.getUserId()).getDeptId());

+ 11 - 6
src/main/java/com/redxun/knowledge/service/KnowledgeApprovalNodeServiceImpl.java

@@ -108,13 +108,15 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
             //判断是否能进行修改(创建人或维护人满足一个即可修改)
             KnowledgeApprovalNodeFlower knowledgeApprovalNodeFlower = knowledgeApprovalNodeFlowerMapper.selectById(knowledgeApprovalNodeFlowerDto.getPkId());
             String userId = userService.queryLoginUser();
-            if (!userId.equals(knowledgeApprovalNodeFlower.getCreateBy())){
-                throw new RuntimeException("您没有权限进行此操作");
-            }
+            //创建人校验
+            boolean createbybol = userId.equals(knowledgeApprovalNodeFlower.getCreateBy());
+            //维护人校验
+            boolean maintainerbol = false;
             if (StringUtils.isNotEmpty(knowledgeApprovalNodeFlower.getMaintainer())){
-                if (!Arrays.asList(knowledgeApprovalNodeFlower.getMaintainer().split(",")).contains(userId)){
-                    throw new RuntimeException("您没有权限进行此操作");
-                }
+                maintainerbol = Arrays.asList(knowledgeApprovalNodeFlower.getMaintainer().split(",")).contains(userId);
+            }
+            if (!createbybol && !maintainerbol){
+                throw new RuntimeException("您没有权限进行此操作");
             }
             knowledgeApprovalNodeMapper.deleteByFlowerId(knowledgeApprovalNodeFlowerDto.getPkId());
             knowledgeApprovalNodeCategoryMapper.deleteByFlowerId(knowledgeApprovalNodeFlowerDto.getPkId());
@@ -185,6 +187,9 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
     public List<KnowledgeApprovalNodeFlowerVo> findAllNodes() {
         String userId = userService.queryLoginUser();
         List<KnowledgeApprovalNodeFlowerVo> result = knowledgeApprovalNodeFlowerMapper.findAllNodes(userId);
+        result = result.stream().
+                filter(h -> userId.equals(h.getCreateBy()) || (StringUtils.isNotEmpty(h.getMaintainer()) && Arrays.asList(h.getMaintainer().split(",")).contains(userId))).
+                collect(Collectors.toList());
         result.forEach(e -> {
             if (flowerName.equals(e.getFlowerName())) {
                 e.setCategory(new ArrayList<>());

+ 16 - 12
src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

@@ -226,13 +226,15 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         KnowledgeCategory knowledgeCategory = this.get(entity.getPkId());
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(knowledgeCategory.getCreateBy())){
-            throw new RuntimeException("您没有权限进行此操作");
-        }
+        //创建人校验
+        boolean createbybol = userId.equals(knowledgeCategory.getCreateBy());
+        //维护人校验
+        boolean maintainerbol = false;
         if (StringUtils.isNotEmpty(knowledgeCategory.getMaintainer())){
-            if (!Arrays.asList(knowledgeCategory.getMaintainer().split(",")).contains(userId)){
-                throw new RuntimeException("您没有权限进行此操作");
-            }
+            maintainerbol = Arrays.asList(knowledgeCategory.getMaintainer().split(",")).contains(userId);
+        }
+        if (!createbybol && !maintainerbol){
+            throw new RuntimeException("您没有权限进行此操作");
         }
         if (knowledgeCategory.getIsSys() == 1) {
             throw new RuntimeException("系统内置节点,无法修改");
@@ -291,13 +293,15 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         KnowledgeCategory knowledgeCategory = this.baseMapper.selectById(knowledgeCategoryId);
         //判断是否能进行修改(创建人或维护人满足一个即可修改)
         String userId = userService.queryLoginUser();
-        if (!userId.equals(knowledgeCategory.getCreateBy())){
-            throw new RuntimeException("您没有权限进行此操作");
-        }
+        //创建人校验
+        boolean createbybol = userId.equals(knowledgeCategory.getCreateBy());
+        //维护人校验
+        boolean maintainerbol = false;
         if (StringUtils.isNotEmpty(knowledgeCategory.getMaintainer())){
-            if (!Arrays.asList(knowledgeCategory.getMaintainer().split(",")).contains(userId)){
-                throw new RuntimeException("您没有权限进行此操作");
-            }
+            maintainerbol = Arrays.asList(knowledgeCategory.getMaintainer().split(",")).contains(userId);
+        }
+        if (!createbybol && !maintainerbol){
+            throw new RuntimeException("您没有权限进行此操作");
         }
         // 查询该分类下是否还有知识
         Boolean hasKnowledge = hasKnowledge(knowledgeCategoryId);

+ 3 - 0
src/main/java/com/redxun/knowledge/service/KnowledgeServiceImpl.java

@@ -595,6 +595,9 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
                 OrganizationDto organizationDto = JSON.parseObject(e.getOrganizationId(), OrganizationDto.class);
                 e.setOrganizationIds(organizationDto);
             }
+            //头像和作者
+            Map<String, Object> map = userService.querySexAndPhoto(e.getCreateBy());
+            e.setParams(map);
             //处理默认节点有两个领导的情况(默认节点默认在第一位,sort=1)
             String[] split = e.getApproverId().split(",");
             if (split.length > 1){

+ 13 - 0
src/main/java/com/redxun/knowledge/utils/DateUtils.java

@@ -94,4 +94,17 @@ public class DateUtils {
         String dateStr = date.format(df);
         return dateStr;
     }
+
+    /**
+     * 用于员工贡献统计
+     * @param year
+     * @return
+     */
+    public static Date getFirstOfYearByUser(int year) {
+        LocalDateTime nowYear = LocalDateTime.now();
+        nowYear = nowYear.minus(1, ChronoUnit.YEARS);
+        Date date = Date.from(nowYear.atZone(ZoneId.systemDefault()).toInstant());
+        return date;
+
+    }
 }

+ 1 - 1
src/main/resources/mapper/knowledge/KnowledgeApprovalNodeFlowerMapper.xml

@@ -62,7 +62,7 @@
                  left join KM_KNOWLEDGE_APPROVAL_NODE node
                            on flower.PK_ID = node.FLOWER_ID and node.IS_DEL = 0
                  left join KM_KNOWLEDGE_APPROVAL_NODE_CATEGORY category on flower.PK_ID = category.FLOWER_ID and category.IS_DEL = 0
-       where flower.IS_DEL = 0 and (flower.CREATE_BY_ = #{userId} or instr(MAINTAINER,#{userId}) > 0)
+       where flower.IS_DEL = 0
        order by flower.CREATE_TIME_,node.IS_FINAL,node.sort
     </select>
 

+ 1 - 1
src/main/resources/mapper/knowledge/KnowledgeMapper.xml

@@ -158,7 +158,7 @@
             <if test="@rx.Ognl@isNotEmpty(params.approvalStatus)">
                 and k.APPROVAL_STATUS = #{params.approvalStatus}
             </if>
-            and k.IS_DEL = 0 and (APPROVAL_STATUS = 1 OR APPROVAL_STATUS = 3) and k.IS_DRAFT = 1
+            and k.IS_DEL = 0 and (APPROVAL_STATUS = 1 OR APPROVAL_STATUS = 3) and k.IS_DRAFT = 1 and ka.IS_DEL = 0
         </where>
         ORDER BY ka.SORT ASC,ka.CREATE_TIME_ DESC
     </select>

+ 1 - 2
src/main/resources/mapper/knowledge/album/AlbumApprovalNodeMapper.xml

@@ -54,8 +54,7 @@
     </select>
 
     <select id="findAllAlbumApprovalNode" resultType="com.redxun.knowledge.album.entity.dao.AlbumApprovalNode">
-        select * from KM_ALBUM_APPROVAL_NODE where IS_DEL = 0 and
-            (CREATE_BY_ = #{userId} or instr(MAINTAINER,#{userId}) > 0)
+        select * from KM_ALBUM_APPROVAL_NODE where IS_DEL = 0
     </select>
 
 </mapper>

+ 1 - 2
src/main/resources/mapper/knowledge/album/AlbumYelpApprovalNodeMapper.xml

@@ -43,8 +43,7 @@
     </delete>
 
     <select id="findAllAlbumApprovalNode" resultType="com.redxun.knowledge.album.entity.dao.AlbumYelpApprovalNode">
-        select * from KM_ALBUM_YELP_APPROVAL_NODE where IS_DEL = 0 and
-            (CREATE_BY_ = #{userId} or instr(MAINTAINER,#{userId}) > 0)
+        select * from KM_ALBUM_YELP_APPROVAL_NODE where IS_DEL = 0
     </select>
 
 </mapper>

+ 1 - 1
src/main/resources/mapper/knowledge/analysis/AnalysisCommonMapper.xml

@@ -169,7 +169,7 @@
                   (select count(*) as yelpSum, CREATE_BY_ as createBy
                    from KM_ALBUM_YELP
                    <where>
-                       APPROVAL_STATE = 5 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{beginTime} and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{endTime}
+                       STATE = 5 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{beginTime} and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{endTime}
                    </where>
                    group by CREATE_BY_) yelp using (createBy))) info right join LEARNING_USER_DEV.OS_USER users on users.USER_ID_ = info.createBy
         where STATUS_ = 1