Explorar el Código

作者:张哲
时间:2023/07/14
类型:需求变更
描述:专辑收录变更

zizg hace 1 año
padre
commit
89611e3e54

+ 53 - 0
src/main/java/com/redxun/knowledge/album/service/AlbumApprovalNodeServiceImpl.java

@@ -3,11 +3,17 @@ package com.redxun.knowledge.album.service;
 import com.redxun.common.base.db.BaseDao;
 import com.redxun.common.base.db.BaseService;
 import com.redxun.common.service.impl.SuperServiceImpl;
+import com.redxun.dto.user.OsUserDto;
 import com.redxun.knowledge.album.entity.dao.AlbumApprovalNode;
 import com.redxun.knowledge.album.mapper.AlbumApprovalNodeMapper;
+import com.redxun.knowledge.common.UserService;
+import com.redxun.knowledge.mapper.KnowledgeApprovalNodeFlowerMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -22,6 +28,12 @@ public class AlbumApprovalNodeServiceImpl extends SuperServiceImpl<AlbumApproval
     @Resource
     private AlbumApprovalNodeMapper albumApprovalNodeMapper;
 
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private KnowledgeApprovalNodeFlowerMapper knowledgeApprovalNodeFlowerMapper;
+
     @Override
     public BaseDao<AlbumApprovalNode> getRepository() {
         return albumApprovalNodeMapper;
@@ -40,9 +52,14 @@ public class AlbumApprovalNodeServiceImpl extends SuperServiceImpl<AlbumApproval
      * @return
      */
     public List<Map<String, Object>> approvalTemplate() {
+        String userId = userService.queryLoginUser();
         List<AlbumApprovalNode> albumApprovalNodeList =
                 albumApprovalNodeMapper.selectList(null);
         List<Map<String, Object>> result = albumApprovalNodeList.parallelStream().map(e -> {
+            //如果是默认节点了,查询对应的审核人
+            if (e.getIsFinal() == -1){
+                e.setApproverName(approverLdName(userId).get("approverName"));
+            }
             Map<String, Object> map = new HashMap<>();
             map.put("name", e.getName());
             map.put("approverName", e.getApproverName());
@@ -53,4 +70,40 @@ public class AlbumApprovalNodeServiceImpl extends SuperServiceImpl<AlbumApproval
         }).collect(Collectors.toList());
         return result;
     }
+
+    /**
+     * 获取直属领导信息
+     * @param userId
+     * @return
+     */
+    public Map<String, String> approverLdName(String userId){
+        OsUserDto osUserDto = userService.queryOsUserDto(userId);
+        String approverId = null;
+        String parentUserIds = knowledgeApprovalNodeFlowerMapper.findParentUserIdList(osUserDto.getDeptId());
+        if (!StringUtils.isEmpty(parentUserIds)){
+            //审核人userId(员工工号)
+            List<String> parentUserIdList = Arrays.asList(parentUserIds.split(","));
+            approverId = String.join(",", parentUserIdList);
+            //如果查出来的直属部门领导包含了当前登陆人,去查询该登陆人的直属上司
+            if (approverId.contains(osUserDto.getUserId())) {
+                approverId = knowledgeApprovalNodeFlowerMapper.findParentUserId(osUserDto.getUserNo());
+                if (StringUtils.isEmpty(approverId)){
+                    approverId = osUserDto.getUserId();
+                }
+            }
+        } else {
+            approverId = knowledgeApprovalNodeFlowerMapper.findParentUserId(osUserDto.getUserNo());
+            if (StringUtils.isEmpty(approverId)){
+                approverId = osUserDto.getUserId();
+            }
+
+        }
+        //审核人姓名
+        String approverName = Arrays.asList(approverId.split(",")).parallelStream().map(e -> userService.queryUser(e).getFullName()).
+                collect(Collectors.joining(","));
+        Map<String, String> map = new HashMap<>();
+        map.put("approverId",approverId);
+        map.put("approverName",approverName);
+        return map;
+    }
 }

+ 8 - 5
src/main/java/com/redxun/knowledge/album/service/AlbumApproveServiceImpl.java

@@ -175,7 +175,7 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
             List<AlbumApprove> value = entry.getValue();
             for (int i = 0; i < value.size(); i++) {
                 // 如果是最终审核通过,直接放入记录
-                if (value.get(i).getAlbumVersion().getApprovalState() == 5 && value.get(i).getIsFinal() == 1) {
+                if (value.get(i).getAlbumVersion().getApprovalState() == 5) {
                     albumApproveVos.add(value.get(i));
                     break;
                 }
@@ -205,7 +205,8 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
             //过滤数据
             albumApproveVos.forEach(albumApproveListVo -> {
                 Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumApproveListVo.getApproverId());
-                if ((userId.equals(albumApproveListVo.getApproverId()) || count > 0) &&
+                List<String> collect = Arrays.stream(albumApproveListVo.getApproverId().split(",")).collect(Collectors.toList());
+                if ((collect.contains(userId) || count > 0) &&
                         (albumApproveListVo.getAlbumVersion().getApprovalState() == 1 || albumApproveListVo.getAlbumVersion().getApprovalState() == 2)) {
                     albumApproveListVo1.add(albumApproveListVo);
                 }
@@ -254,7 +255,8 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
         String deptId = userService.queryLoginUserDeptId();
         Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumApproveListVo.getApproverId());
         List<String> actionFlag = new ArrayList<>();
-        if ((userId.equals(albumApproveListVo.getApproverId()) || count > 0) &&
+        List<String> collect = Arrays.stream(albumApproveListVo.getApproverId().split(",")).collect(Collectors.toList());
+        if ((collect.contains(userId) || count > 0) &&
                 (albumApprove.getAlbumVersion().getApprovalState() == 1 || albumApprove.getAlbumVersion().getApprovalState() == 2)) {
             actionFlag.add("approve");
         } else {
@@ -326,7 +328,8 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
             String userId = userService.queryLoginUser();
             String deptId = userService.queryLoginUserDeptId();
             Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumApprove.getApproverId());
-            if (!userId.equals(albumApprove.getApproverId())) {
+            List<String> collect = Arrays.stream(albumApprove.getApproverId().split(",")).collect(Collectors.toList());
+            if (!collect.contains(userId)) {
                 //没有权限
                 if (count <= 0) {
                     return 2;
@@ -372,7 +375,7 @@ public class AlbumApproveServiceImpl extends SuperServiceImpl<AlbumApproveMapper
                 albumVersionMapper.updateById(albumVersion);
             }
             //如果审核节点是终审节点且专辑审核通过,修改专辑版本状态为最终通过(即审核完成)
-            if (albumApproveById.getIsFinal() == 1 && albumApprovalRemarkDto.getResult() == 1) {
+            if ((albumApproveById.getIsFinal() == 1 || albumApproveByIdNext == null) && albumApprovalRemarkDto.getResult() == 1) {
                 AlbumVersion albumVersion = new AlbumVersion();
                 //更改其他专辑为未生效
                 albumVersion.setState(3);

+ 11 - 4
src/main/java/com/redxun/knowledge/album/service/AlbumInfoServiceImpl.java

@@ -467,7 +467,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             //清除原有数据
             albumApprovalNodeService.deleteAll();
             //批量插入数据
-            List<AlbumApprovalNode> albumApprovalNodeList = albumApprovalNodeDto1.parallelStream().map(e -> {
+            List<AlbumApprovalNode> albumApprovalNodeList = albumApprovalNodeDto1.stream().map(e -> {
                 AlbumApprovalNode albumApprovalNode = new AlbumApprovalNode();
                 albumApprovalNode.setPkId(IdGenerator.getIdStr());
                 BeanUtils.copyProperties(e, albumApprovalNode);
@@ -484,7 +484,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             //清除原有数据
             albumYelpApprovalNodeService.deleteAll();
             //批量插入数据
-            List<AlbumYelpApprovalNode> albumYelpApprovalNodeList = albumApprovalNodeDto2.parallelStream().map(e -> {
+            List<AlbumYelpApprovalNode> albumYelpApprovalNodeList = albumApprovalNodeDto2.stream().map(e -> {
                 AlbumYelpApprovalNode albumYelpApprovalNode = new AlbumYelpApprovalNode();
                 albumYelpApprovalNode.setPkId(IdGenerator.getIdStr());
                 BeanUtils.copyProperties(e, albumYelpApprovalNode);
@@ -710,6 +710,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
      * 生成最新版审核流程数据
      */
     private void createAlbumApprove(String albumId, String versionId) {
+        String userId = userService.queryLoginUser();
         //根据专辑Id查询审核表中批次(每次生成批次+1)(删除的审批记录批次也要)
         List<AlbumApprove> albumApproveListBatch = albumApproveMapper.selectAlbumApproveListBatch(albumId);
         //删除老版本审核流程(驳回情况)
@@ -724,8 +725,14 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             albumApprove.setPkId(IdGenerator.getIdStr());
             albumApprove.setAlbumId(albumId);
             albumApprove.setVersionId(versionId);
-            albumApprove.setApproverId(albumApprovalNode.getApproverId());
-            albumApprove.setApproverName(albumApprovalNode.getApproverName());
+            if (albumApprovalNode.getIsFinal() == -1){
+                Map<String, String> map = albumApprovalNodeService.approverLdName(userId);
+                albumApprove.setApproverId(map.get("approverId"));
+                albumApprove.setApproverName(map.get("approverName"));
+            } else {
+                albumApprove.setApproverId(albumApprovalNode.getApproverId());
+                albumApprove.setApproverName(albumApprovalNode.getApproverName());
+            }
             albumApprove.setSort(sort.getAndIncrement());
             albumApprove.setIsFinal(albumApprovalNode.getIsFinal());
             albumApprove.setUpdateBy(userService.queryLoginUser());

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

@@ -98,7 +98,7 @@ public class AlbumYelpApproveServiceImpl extends SuperServiceImpl<AlbumYelpAppro
             List<AlbumYelpApprove> value = entry.getValue();
             for (int i = 0; i < value.size(); i++) {
                 // 如果是最终审核通过,直接放入记录
-                if (value.get(i).getAlbumYelp().getApprovalState() == 5 && value.get(i).getIsFinal() == 1) {
+                if (value.get(i).getAlbumYelp().getApprovalState() == 5) {
                     albumYelpApproves.add(value.get(i));
                     break;
                 }
@@ -128,7 +128,8 @@ public class AlbumYelpApproveServiceImpl extends SuperServiceImpl<AlbumYelpAppro
             //过滤数据
             albumYelpApproves.forEach(albumYelpApprove -> {
                 Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumYelpApprove.getApproverId());
-                if ((userId.equals(albumYelpApprove.getApproverId()) || count > 0) &&
+                List<String> collect = Arrays.stream(albumYelpApprove.getApproverId().split(",")).collect(Collectors.toList());
+                if (((collect.contains(userId)) || count > 0) &&
                         (albumYelpApprove.getAlbumYelp().getApprovalState() == 1 || albumYelpApprove.getAlbumYelp().getApprovalState() == 2)) {
                     albumApproveListVoUser.add(albumYelpApprove);
                 }
@@ -169,7 +170,8 @@ public class AlbumYelpApproveServiceImpl extends SuperServiceImpl<AlbumYelpAppro
         String deptId = userService.queryLoginUserDeptId();
         Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumApproveListVo.getApproverId());
         List<String> actionFlag = new ArrayList<>();
-        if ((userId.equals(albumApproveListVo.getApproverId()) || count > 0)
+        List<String> collect = Arrays.stream(albumYelpApprove.getApproverId().split(",")).collect(Collectors.toList());
+        if ((collect.contains(userId) || count > 0)
                 && (albumYelpApprove.getAlbumYelp().getApprovalState() == 1 || albumYelpApprove.getAlbumYelp().getApprovalState() == 2)) {
             actionFlag.add("approve");
         } else {
@@ -228,7 +230,8 @@ public class AlbumYelpApproveServiceImpl extends SuperServiceImpl<AlbumYelpAppro
             String userId = userService.queryLoginUser();
             String deptId = userService.queryLoginUserDeptId();
             Integer count = albumApprovalNodeMapper.selectAllByDeptId(deptId, albumYelpApproveList.get(0).getApproverId());
-            if (!userId.equals(albumYelpApproveList.get(0).getApproverId())) {
+            List<String> collect = Arrays.stream(albumYelpApproveList.get(0).getApproverId().split(",")).collect(Collectors.toList());
+            if (!collect.contains(userId)) {
                 if (count <= 0) {
                     //没有权限
                     return 2;
@@ -277,7 +280,7 @@ public class AlbumYelpApproveServiceImpl extends SuperServiceImpl<AlbumYelpAppro
                 sendMessage(albumYelpById.getCreateBy(), albumInfo.getName(), albumYelpById.getContent(), albumApprovalRemarkDto.getRemark());
             }
             //如果审核节点是终审节点且专辑审核通过,修改点评状态为最终通过(即审核完成)
-            if (albumYelpApproveList.get(0).getIsFinal() == 1 && albumApprovalRemarkDto.getResult() == 1) {
+            if ((albumYelpApproveList.get(0).getIsFinal() == 1 || albumYelpApproveList.size() == 1) && albumApprovalRemarkDto.getResult() == 1) {
                 AlbumYelp albumYelp = new AlbumYelp();
                 albumYelp.setPkId(yelpId);
                 albumYelp.setState(1);

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

@@ -65,6 +65,9 @@ public class AlbumYelpServiceImpl extends SuperServiceImpl<AlbumYelpMapper, Albu
     @Autowired
     private AlbumYelpApproveServiceImpl albumYelpApproveService;
 
+    @Autowired
+    private AlbumApprovalNodeServiceImpl albumApprovalNodeService;
+
     @Autowired
     private UserService userService;
 
@@ -195,6 +198,7 @@ public class AlbumYelpServiceImpl extends SuperServiceImpl<AlbumYelpMapper, Albu
      * @param albumYelp
      */
     private void createAlbumYelpApprove(AlbumYelp albumYelp) {
+        String userId = userService.queryLoginUser();
         //拉取点评审核节点表
         List<AlbumYelpApprovalNode> albumYelpApprovalNodeList = albumYelpApprovalNodeService.
                 findAll(new QueryWrapper<AlbumYelpApprovalNode>().orderByAsc("IS_FINAL", "CREATE_TIME_"));
@@ -204,8 +208,14 @@ public class AlbumYelpServiceImpl extends SuperServiceImpl<AlbumYelpMapper, Albu
             AlbumYelpApprove albumYelpApprove = new AlbumYelpApprove();
             albumYelpApprove.setPkId(IdGenerator.getIdStr());
             albumYelpApprove.setAlbumId(albumYelp.getAlbumId());
-            albumYelpApprove.setApproverId(albumYelpApprovalNode.getApproverId());
-            albumYelpApprove.setApproverName(albumYelpApprovalNode.getApproverName());
+            if (albumYelpApprovalNode.getIsFinal() == -1){
+                Map<String, String> map = albumApprovalNodeService.approverLdName(userId);
+                albumYelpApprove.setApproverId(map.get("approverId"));
+                albumYelpApprove.setApproverName(map.get("approverName"));
+            } else {
+                albumYelpApprove.setApproverId(albumYelpApprovalNode.getApproverId());
+                albumYelpApprove.setApproverName(albumYelpApprovalNode.getApproverName());
+            }
             albumYelpApprove.setSort(sort.getAndIncrement());
             albumYelpApprove.setIsFinal(albumYelpApprovalNode.getIsFinal());
             albumYelpApprove.setUpdateBy(userService.queryLoginUser());

+ 2 - 0
src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

@@ -176,6 +176,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         if (entity.getSort() == null) {
             entity.setSort(0);
         }
+        entity.setIsSys(0);
         knowledgeCategoryMapper.insertOrUpdateBySort(entity.getParent(), entity.getSort());
         entity.setUpdateBy(userService.queryLoginUser());
         return this.getRepository().insert(entity);
@@ -219,6 +220,7 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
         }
         //变更sort
         knowledgeCategoryMapper.insertOrUpdateBySort(entity.getParent(), entity.getSort());
+        entity.setIsSys(0);
         return this.getRepository().updateById(entity);
     }