Selaa lähdekoodia

作者:张哲
时间:2023/09/06
类型:优化
描述:专辑审核节点加入sort排序。防止节点拉取顺序不一致

zizg 1 vuosi sitten
vanhempi
commit
eff3ca2a30

+ 3 - 0
src/main/java/com/redxun/knowledge/album/entity/dao/AlbumApprovalNode.java

@@ -55,6 +55,9 @@ public class AlbumApprovalNode extends BaseExtEntity<String> {
     @TableField(value = "MAINTAINER")
     private String maintainer;
 
+    @TableField(value = "SORT")
+    private Integer sort;
+
 
     @Override
     public String getPkId() {

+ 3 - 0
src/main/java/com/redxun/knowledge/album/entity/dao/AlbumYelpApprovalNode.java

@@ -55,6 +55,9 @@ public class AlbumYelpApprovalNode extends BaseExtEntity<String> {
     @TableField(value = "MAINTAINER")
     private String maintainer;
 
+    @TableField(value = "SORT")
+    private Integer sort;
+
 
     @Override
     public String getPkId() {

+ 2 - 1
src/main/java/com/redxun/knowledge/album/service/AlbumApprovalNodeServiceImpl.java

@@ -1,5 +1,6 @@
 package com.redxun.knowledge.album.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.redxun.common.base.db.BaseDao;
 import com.redxun.common.base.db.BaseService;
 import com.redxun.common.service.impl.SuperServiceImpl;
@@ -54,7 +55,7 @@ public class AlbumApprovalNodeServiceImpl extends SuperServiceImpl<AlbumApproval
     public List<Map<String, Object>> approvalTemplate() {
         String userId = userService.queryLoginUser();
         List<AlbumApprovalNode> albumApprovalNodeList =
-                albumApprovalNodeMapper.selectList(null);
+                albumApprovalNodeMapper.selectList(new QueryWrapper<AlbumApprovalNode>().orderByAsc("SORT"));
         List<Map<String, Object>> result = albumApprovalNodeList.parallelStream().map(e -> {
             //如果是默认节点了,查询对应的审核人
             if (e.getIsFinal() == -1){

+ 5 - 10
src/main/java/com/redxun/knowledge/album/service/AlbumInfoServiceImpl.java

@@ -1,6 +1,5 @@
 package com.redxun.knowledge.album.service;
 
-import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -10,7 +9,6 @@ import com.redxun.common.base.db.BaseDao;
 import com.redxun.common.base.db.BaseService;
 import com.redxun.common.base.db.PageHelper;
 import com.redxun.common.base.search.QueryFilter;
-import com.redxun.common.model.JPaasUser;
 import com.redxun.common.service.impl.SuperServiceImpl;
 import com.redxun.common.tool.IdGenerator;
 import com.redxun.common.tool.StringUtils;
@@ -22,16 +20,10 @@ import com.redxun.knowledge.album.entity.enums.AlbumInfoEnum;
 import com.redxun.knowledge.album.entity.enums.AlbumVersionEnum;
 import com.redxun.knowledge.album.entity.vo.*;
 import com.redxun.knowledge.album.mapper.*;
-import com.redxun.knowledge.analysis.entity.vo.KnowledgeCompanyVo;
 import com.redxun.knowledge.common.UserService;
 import com.redxun.knowledge.entity.dao.ActionLog;
-import com.redxun.knowledge.entity.dao.Knowledge;
-import com.redxun.knowledge.entity.vo.KnowledgeCategoryAdminVo;
 import com.redxun.knowledge.mapper.ActionLogMapper;
-import com.redxun.knowledge.service.KnowledgeCategoryServiceImpl;
-import com.redxun.knowledge.service.KnowledgeServiceImpl;
 import com.redxun.knowledge.utils.PageListUtils;
-import com.sun.xml.bind.v2.TODO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +31,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.io.Serializable;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -476,11 +467,13 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             //清除原有数据
             albumApprovalNodeService.deleteAll();
             //批量插入数据
+            AtomicInteger i = new AtomicInteger(1);
             List<AlbumApprovalNode> albumApprovalNodeList = albumApprovalNodeDto1.stream().map(e -> {
                 AlbumApprovalNode albumApprovalNode = new AlbumApprovalNode();
                 albumApprovalNode.setPkId(IdGenerator.getIdStr());
                 BeanUtils.copyProperties(e, albumApprovalNode);
                 albumApprovalNode.setCreateBy(e.getCreateBy());
+                albumApprovalNode.setSort(i.getAndIncrement());
                 return albumApprovalNode;
 
             }).collect(Collectors.toList());
@@ -494,11 +487,13 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
             //清除原有数据
             albumYelpApprovalNodeService.deleteAll();
             //批量插入数据
+            AtomicInteger i = new AtomicInteger(1);
             List<AlbumYelpApprovalNode> albumYelpApprovalNodeList = albumApprovalNodeDto2.stream().map(e -> {
                 AlbumYelpApprovalNode albumYelpApprovalNode = new AlbumYelpApprovalNode();
                 albumYelpApprovalNode.setPkId(IdGenerator.getIdStr());
                 BeanUtils.copyProperties(e, albumYelpApprovalNode);
                 albumYelpApprovalNode.setCreateBy(e.getCreateBy());
+                albumYelpApprovalNode.setSort(i.getAndIncrement());
                 return albumYelpApprovalNode;
             }).collect(Collectors.toList());
             albumYelpApprovalNodeService.saveBatch(albumYelpApprovalNodeList);
@@ -755,7 +750,7 @@ public class AlbumInfoServiceImpl extends SuperServiceImpl<AlbumInfoMapper, Albu
         albumApproveService.deleteByVersionId(versionId);
         //拉取专辑审核节点表
         List<AlbumApprovalNode> albumApprovalNodeList = albumApprovalNodeService.
-                findAll(new QueryWrapper<AlbumApprovalNode>().orderByAsc("IS_FINAL", "CREATE_TIME_"));
+                findAll(new QueryWrapper<AlbumApprovalNode>().orderByAsc("IS_FINAL","SORT", "CREATE_TIME_"));
         //将版本推送至专辑审核表中(各个节点都推送)
         AtomicInteger sort = new AtomicInteger(1);
         List<AlbumApprove> albumApproveList = albumApprovalNodeList.stream().map(albumApprovalNode -> {

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

@@ -201,7 +201,7 @@ public class AlbumYelpServiceImpl extends SuperServiceImpl<AlbumYelpMapper, Albu
         String userId = userService.queryLoginUser();
         //拉取点评审核节点表
         List<AlbumYelpApprovalNode> albumYelpApprovalNodeList = albumYelpApprovalNodeService.
-                findAll(new QueryWrapper<AlbumYelpApprovalNode>().orderByAsc("IS_FINAL", "CREATE_TIME_"));
+                findAll(new QueryWrapper<AlbumYelpApprovalNode>().orderByAsc("IS_FINAL","SORT","CREATE_TIME_"));
         //将点评信息推送至点评审核表中(各个节点都推送)
         AtomicInteger sort = new AtomicInteger(1);
         List<AlbumYelpApprove> albumYelpApproveList = albumYelpApprovalNodeList.stream().map(albumYelpApprovalNode -> {

+ 34 - 8
src/main/java/com/redxun/knowledge/service/KnowledgeServiceImpl.java

@@ -264,12 +264,24 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
                 knowledgeVo.setIsAllowDownload(isAllowDownload(knowledge.getDownloadUserId(),knowledge.getDownloadDeptId()));
                 //附件可下载人员或部门字符串复制
                 if (StringUtils.isNotEmpty(knowledge.getDownloadUserId())){
-                    List<String> fullNameList = knowledgeMapper.selectFullNameByUserIds(knowledge.getDownloadUserId().split(","));
-                    knowledgeVo.setDownloadUserName(fullNameList.stream().collect(Collectors.joining(",")));
+                    List<String> list = new ArrayList<>();
+                    String[] split = knowledge.getDownloadUserId().split(",");
+                    for (int i = 0; i < split.length; i++) {
+                        OsUserDto osUserDto = userService.queryOsUserDto(split[i]);
+                        list.add(osUserDto.getFullName());
+                    }
+                    //List<String> fullNameList = knowledgeMapper.selectFullNameByUserIds(knowledge.getDownloadUserId().split(","));
+                    knowledgeVo.setDownloadUserName(list.stream().collect(Collectors.joining(",")));
                 }
                 if (StringUtils.isNotEmpty(knowledge.getDownloadDeptId())){
-                    List<String> fullNameList = knowledgeMapper.selectFullNameByDeptIds(knowledge.getDownloadDeptId().split(","));
-                    knowledgeVo.setDownloadDeptName(fullNameList.stream().collect(Collectors.joining(",")));
+                    List<String> list = new ArrayList<>();
+                    String[] split = knowledge.getDownloadDeptId().split(",");
+                    for (int i = 0; i < split.length; i++) {
+                        OsGroupDto os = userService.findDeptByDeptId(split[i]);
+                        list.add(os.getName());
+                    }
+                    //List<String> fullNameList = knowledgeMapper.selectFullNameByDeptIds(knowledge.getDownloadDeptId().split(","));
+                    knowledgeVo.setDownloadDeptName(list.stream().collect(Collectors.joining(",")));
                 }
             } else {
                 knowledgeVo.setIsAllowDownload(0);
@@ -401,13 +413,27 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
                 e.setIsAllowDownload(isAllowDownload(e.getDownloadUserId(),e.getDownloadDeptId()));
                 //附件可下载人员或部门字符串复制
                 if (StringUtils.isNotEmpty(e.getDownloadUserId())){
-                    List<String> fullNameList = knowledgeMapper.selectFullNameByUserIds(e.getDownloadUserId().split(","));
-                    e.setDownloadUserName(fullNameList.stream().collect(Collectors.joining(",")));
+                    List<String> list = new ArrayList<>();
+                    String[] split = e.getDownloadUserId().split(",");
+                    for (int i = 0; i < split.length; i++) {
+                        OsUserDto osUserDto = userService.queryOsUserDto(split[i]);
+                        list.add(osUserDto.getFullName());
+                    }
+                    //List<String> fullNameList = knowledgeMapper.selectFullNameByUserIds(e.getDownloadUserId().split(","));
+                    e.setDownloadUserName(list.stream().collect(Collectors.joining(",")));
                 }
                 if (StringUtils.isNotEmpty(e.getDownloadDeptId())){
-                    List<String> fullNameList = knowledgeMapper.selectFullNameByDeptIds(e.getDownloadDeptId().split(","));
-                    e.setDownloadDeptName(fullNameList.stream().collect(Collectors.joining(",")));
+                    List<String> list = new ArrayList<>();
+                    String[] split = e.getDownloadDeptId().split(",");
+                    for (int i = 0; i < split.length; i++) {
+                        OsGroupDto os = userService.findDeptByDeptId(split[i]);
+                        list.add(os.getName());
+                    }
+                    //List<String> fullNameList = knowledgeMapper.selectFullNameByDeptIds(e.getDownloadDeptId().split(","));
+                    e.setDownloadDeptName(list.stream().collect(Collectors.joining(",")));
                 }
+            } else {
+                e.setIsAllowDownload(0);
             }
 
         });

+ 17 - 3
src/main/java/com/redxun/knowledge/utils/DateUtils.java

@@ -2,6 +2,8 @@ package com.redxun.knowledge.utils;
 
 import org.apache.commons.lang.time.DateFormatUtils;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
@@ -46,9 +48,21 @@ public class DateUtils {
      * @return Date
      */
     public static Date getFirstOfYear(int year) {
-        LocalDateTime nowYear = LocalDateTime.now();
-        nowYear = nowYear.minus(1, ChronoUnit.YEARS).plus(1, ChronoUnit.MONTHS);
-        Date date = Date.from(nowYear.atZone(ZoneId.systemDefault()).toInstant());
+        //LocalDateTime nowYear = LocalDateTime.now();
+        //nowYear = nowYear.minus(1, ChronoUnit.YEARS).plus(1, ChronoUnit.MONTHS);
+        //Date date = Date.from(nowYear.atZone(ZoneId.systemDefault()).toInstant());
+        //return date;
+        LocalDate today = LocalDate.now();
+        LocalDate localDate = today.minusMonths(11);
+        String dateStr = localDate.toString().substring(0, 8);
+        dateStr += "01";
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = null;
+        try {
+            date = sdf.parse(dateStr);
+        } catch (ParseException e) {
+            date = new Date();
+        }
         return date;
 
     }

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

@@ -16,6 +16,7 @@
         <result property="createTime" column="CREATE_TIME_" jdbcType="DATE"/>
         <result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
         <result property="updateTime" column="UPDATE_TIME_" jdbcType="DATE"/>
+        <result property="sort" column="sort" jdbcType="INTEGER"/>
     </resultMap>
 
 

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

@@ -16,6 +16,7 @@
         <result property="createTime" column="CREATE_TIME_" jdbcType="DATE"/>
         <result property="updateBy" column="UPDATE_BY_" jdbcType="VARCHAR"/>
         <result property="updateTime" column="UPDATE_TIME_" jdbcType="DATE"/>
+        <result property="sort" column="sort" jdbcType="INTEGER"/>
     </resultMap>