3 Achegas bbed0b99f5 ... 082e7d5213

Autor SHA1 Mensaxe Data
  zizg 082e7d5213 作者:张哲 hai 1 ano
  zizg eff3ca2a30 作者:张哲 hai 1 ano
  zizg f35250b396 作者:张哲 hai 1 ano
Modificáronse 19 ficheiros con 197 adicións e 76 borrados
  1. 3 0
      src/main/java/com/redxun/knowledge/album/entity/dao/AlbumApprovalNode.java
  2. 3 0
      src/main/java/com/redxun/knowledge/album/entity/dao/AlbumYelpApprovalNode.java
  3. 2 1
      src/main/java/com/redxun/knowledge/album/service/AlbumApprovalNodeServiceImpl.java
  4. 13 6
      src/main/java/com/redxun/knowledge/album/service/AlbumCategoryServiceImpl.java
  5. 11 12
      src/main/java/com/redxun/knowledge/album/service/AlbumInfoServiceImpl.java
  6. 1 1
      src/main/java/com/redxun/knowledge/album/service/AlbumYelpServiceImpl.java
  7. 3 2
      src/main/java/com/redxun/knowledge/analysis/controller/AnalysisCommonController.java
  8. 18 0
      src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisCommonMapper.java
  9. 37 17
      src/main/java/com/redxun/knowledge/analysis/service/AnalysisCommonServiceImpl.java
  10. 2 0
      src/main/java/com/redxun/knowledge/entity/dto/KnowledgeApprovalNodeFlowerDto.java
  11. 1 1
      src/main/java/com/redxun/knowledge/mapper/KnowledgeApproveMapper.java
  12. 7 3
      src/main/java/com/redxun/knowledge/service/KnowledgeApprovalNodeServiceImpl.java
  13. 3 1
      src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java
  14. 41 25
      src/main/java/com/redxun/knowledge/service/KnowledgeServiceImpl.java
  15. 17 3
      src/main/java/com/redxun/knowledge/utils/DateUtils.java
  16. 5 2
      src/main/resources/mapper/knowledge/KnowledgeApproveMapper.xml
  17. 1 0
      src/main/resources/mapper/knowledge/album/AlbumApprovalNodeMapper.xml
  18. 1 0
      src/main/resources/mapper/knowledge/album/AlbumYelpApprovalNodeMapper.xml
  19. 28 2
      src/main/resources/mapper/knowledge/analysis/AnalysisCommonMapper.xml

+ 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){

+ 13 - 6
src/main/java/com/redxun/knowledge/album/service/AlbumCategoryServiceImpl.java

@@ -293,12 +293,13 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
      */
     private void operatorSort(AlbumCategory entity) {
         List<Integer> sortList = albumCategoryMapper.selectSortList(entity.getParent());
+        if (entity.getSort() != null) {
+            albumCategoryMapper.insertOrUpdateBySort(entity.getParent(), entity.getSort());
+            return;
+        }
         if (!CollectionUtils.isEmpty(sortList) && sortList.contains(entity.getSort())) {
             //根据排序和父类Id变更排序
             albumCategoryMapper.insertOrUpdateBySort(entity.getParent(), entity.getSort());
-        } else if (!CollectionUtils.isEmpty(sortList)) {
-            Integer lastSort = sortList.get(sortList.size() - 1);
-            entity.setSort(lastSort + 1);
         } else {
             entity.setSort(1);
         }
@@ -397,10 +398,16 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
      * @return
      */
     private int permission(String createBy,String maintainer,String userId){
-        if (userId.equals(createBy) || (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId))){
-            return 0;
+        if (StringUtils.isNotEmpty(userId)) {
+            if (userId.equals(createBy) ||
+                    (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId)) ||
+                    userId.equals("1")){
+                return 0;
+            } else {
+                return 1;
+            }
         } else {
-            return 1;
+            return 2;
         }
 
     }

+ 11 - 12
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);
@@ -513,7 +508,9 @@ 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());
+        if (!"1".equals(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);
@@ -539,7 +536,9 @@ 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());
+        if (!"1".equals(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);
@@ -755,7 +754,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 -> {

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

@@ -339,9 +339,10 @@ public class AnalysisCommonController {
     @GetMapping("knowledgeSumAndYelpSumByUserId")
     public JsonResult knowledgeSumAndYelpSumByUserId(@RequestParam(value = "beginTime",required = false) String beginTime,
                                                     @RequestParam(value = "endTime",required = false) String endTime,
-                                                    @RequestParam(value = "userId",required = false) String userId){
+                                                    @RequestParam(value = "userId",required = false) String userId,
+                                                     @RequestParam(value = "deptId") String deptId){
         JsonResult jsonResult = JsonResult.getSuccessResult("");
-        Map<String,Object> result = analysisCommonService.knowledgeSumAndYelpSumByLogin(beginTime,endTime,userId);
+        Map<String,Object> result = analysisCommonService.knowledgeSumAndYelpSumByLogin(beginTime,endTime,userId,deptId);
         return jsonResult.setData(result);
     }
 

+ 18 - 0
src/main/java/com/redxun/knowledge/analysis/mapper/AnalysisCommonMapper.java

@@ -130,4 +130,22 @@ public interface AnalysisCommonMapper {
      */
     List<KnowledgeSumAndYelpSumListVo> knowledgeSumAndYelpSumList(@Param("beginTime") String beginTime, @Param("endTime") String endTime,
                                                                   @Param("pageNo") Integer pageNo, @Param("pageSize")Integer pageSize);
+
+    /**
+     * 查询部门的知识上传量
+     * @param deptId
+     * @param beginTime
+     * @param endTime
+     * @return
+     */
+    Integer knowledgeSumByDeptId(@Param("deptId") String deptId,@Param("beginTime") String beginTime,@Param("endTime") String endTime);
+
+    /**
+     * 查询部门的专辑评论量
+     * @param deptId
+     * @param beginTime
+     * @param endTime
+     * @return
+     */
+    Integer yelpSumByDeptId(@Param("deptId") String deptId,@Param("beginTime") String beginTime,@Param("endTime") String endTime);
 }

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

@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.redxun.common.base.entity.QueryData;
+import com.redxun.common.model.JPaasUser;
 import com.redxun.common.tool.StringUtils;
+import com.redxun.dto.user.OsUserDto;
 import com.redxun.knowledge.analysis.entity.dao.KnowledgeDao;
 import com.redxun.knowledge.analysis.entity.dto.PersonVisitDto;
 import com.redxun.knowledge.analysis.entity.vo.*;
@@ -427,29 +429,43 @@ public class AnalysisCommonServiceImpl {
      * 员工的知识上传数和专辑评论数
      * @return
      */
-    public Map<String, Object> knowledgeSumAndYelpSumByLogin(String beginTime,String endTime,String userId) {
+    public Map<String, Object> knowledgeSumAndYelpSumByLogin(String beginTime,String endTime,String userId,String deptId) {
         Map<String, Object> map = new LinkedHashMap<>();
         Integer knowledgeSum = 0;
         Integer yelpSum = 0;
-        if (StringUtils.isEmpty(userId)){
-            userId = userService.queryLoginUser();
-        }
         //获取当前年
         Calendar calendar = Calendar.getInstance();
         int year = calendar.get(Calendar.YEAR);
-        if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {
-            knowledgeSum = analysisCommonMapper.knowledgeSum(userId,beginTime,endTime);
-            //专辑点评量
-            yelpSum = analysisCommonMapper.yelpSum(userId,beginTime,endTime);
+        //用户id为空了,查询部门;否则查询员工
+        if (StringUtils.isEmpty(userId)){
+            if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {
+                knowledgeSum = analysisCommonMapper.knowledgeSumByDeptId(deptId,beginTime,endTime);
+                //专辑点评量
+                yelpSum = analysisCommonMapper.yelpSumByDeptId(deptId,beginTime,endTime);
+            } else {
+                //知识上传量
+                knowledgeSum = analysisCommonMapper.knowledgeSumByDeptId(deptId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
+                        DateUtils.format(new Date()));
+                //专辑点评量
+                yelpSum = analysisCommonMapper.yelpSumByDeptId(deptId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
+                        DateUtils.format(new Date()));
+            }
         } else {
-            //知识上传量
-            knowledgeSum = analysisCommonMapper.knowledgeSum(userId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
-                    DateUtils.format(new Date()));
-            //专辑点评量
-            yelpSum = analysisCommonMapper.yelpSum(userId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
-                    DateUtils.format(new Date()));
+            if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {
+                knowledgeSum = analysisCommonMapper.knowledgeSum(userId,beginTime,endTime);
+                //专辑点评量
+                yelpSum = analysisCommonMapper.yelpSum(userId,beginTime,endTime);
+            } else {
+                //知识上传量
+                knowledgeSum = analysisCommonMapper.knowledgeSum(userId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
+                        DateUtils.format(new Date()));
+                //专辑点评量
+                yelpSum = analysisCommonMapper.yelpSum(userId,DateUtils.format(DateUtils.getFirstOfYearByUser(year)),
+                        DateUtils.format(new Date()));
+            }
+
         }
-        String deptPath = pvLogMapper.findAllDeptIdByDeptId(userService.queryUser(userId).getDeptId());
+        String deptPath = pvLogMapper.findAllDeptIdByDeptId(deptId);
         if (StringUtils.isNotEmpty(deptPath)) {
             deptPath = deptPath.substring(deptPath.indexOf(".") + 1);
             String[] split = deptPath.split("\\.");
@@ -501,8 +517,12 @@ public class AnalysisCommonServiceImpl {
                     DateUtils.format(new Date()),pageNo,pageSize);
         }
         result.forEach(e -> {
-            e.setDeptId(userService.queryUser(e.getUserId()).getDeptId());
-            e.setDeptName(userService.queryUser(e.getUserId()).getDeptName());
+            OsUserDto osUserDto = userService.queryOsUserDto(e.getUserId());
+            if (osUserDto != null){
+                e.setDeptId(osUserDto.getDeptId());
+                e.setDeptName(osUserDto.getDeptName());
+                e.setUserId(osUserDto.getUserNo());
+            }
         });
         return result;
     }

+ 2 - 0
src/main/java/com/redxun/knowledge/entity/dto/KnowledgeApprovalNodeFlowerDto.java

@@ -37,6 +37,8 @@ public class KnowledgeApprovalNodeFlowerDto {
     private List<KnowledgeApprovalNodeDto> knowledgeApprovalNode;
     //维护人
     private String maintainer;
+
+    private String createBy;
 }
 
 

+ 1 - 1
src/main/java/com/redxun/knowledge/mapper/KnowledgeApproveMapper.java

@@ -35,5 +35,5 @@ public interface KnowledgeApproveMapper extends BaseDao<KnowledgeApprove> {
 
     List<KnowledgeApprove> selectByKnowledgerId(@Param("knowledgeId") String knowledgeId);
 
-    List<String> findAllDeptIdByParent(@Param("deptId") String deptId);
+    List<String> findAllDeptIdByParent(@Param("deptIdList") List<String> deptId);
 }

+ 7 - 3
src/main/java/com/redxun/knowledge/service/KnowledgeApprovalNodeServiceImpl.java

@@ -146,6 +146,7 @@ public class KnowledgeApprovalNodeServiceImpl extends SuperServiceImpl<Knowledge
         KnowledgeApprovalNodeFlower knowledgeApprovalNodeFlower = new KnowledgeApprovalNodeFlower();
         knowledgeApprovalNodeFlower.setFlowerName(knowledgeApprovalNodeFlowerDto.getFlowerName());
         knowledgeApprovalNodeFlower.setMaintainer(knowledgeApprovalNodeFlowerDto.getMaintainer());
+        knowledgeApprovalNodeFlower.setCreateBy(knowledgeApprovalNodeFlowerDto.getCreateBy());
         if (StringUtils.isEmpty(knowledgeApprovalNodeFlowerDto.getPkId())) {
             knowledgeApprovalNodeFlowerMapper.insert(knowledgeApprovalNodeFlower);
         } else {
@@ -187,9 +188,12 @@ 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());
+        //if not admin
+        if (!"1".equals(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<>());

+ 3 - 1
src/main/java/com/redxun/knowledge/service/KnowledgeCategoryServiceImpl.java

@@ -471,7 +471,9 @@ public class KnowledgeCategoryServiceImpl extends SuperServiceImpl<KnowledgeCate
      */
     private int permission(String createBy,String maintainer,String userId){
         if (StringUtils.isNotEmpty(userId)){
-            if (userId.equals(createBy) || (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId))){
+            if (userId.equals(createBy) ||
+                    (StringUtils.isNotEmpty(maintainer) && Arrays.asList(maintainer.split(",")).contains(userId)) ||
+                    userId.equals("1")){
                 return 0;
             } else {
                 return 1;

+ 41 - 25
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);
             }
 
         });
@@ -1029,18 +1055,10 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
         //二者都不为空
         if (StringUtils.isNotEmpty(downloadDeptId) && StringUtils.isNotEmpty(downloadUserId)){
             //可下载部门数组
-            List<String> deptAuthority = knowledgeApproveMapper.findAllDeptIdByParent(deptId);
-            String[] downloadDeptIdStr = downloadDeptId.split(",");
-            boolean flag = false;
-            for (int i = 0; i < downloadDeptIdStr.length; i++) {
-                if (deptAuthority.contains(downloadDeptIdStr[i])) {
-                    flag = true;
-                    break;
-                }
-            }
+            List<String> deptAuthority = knowledgeApproveMapper.findAllDeptIdByParent(Arrays.asList(downloadDeptId.split(",")));
             List<String> approverIdList = Arrays.asList(downloadUserId.split(","));
             // 如果有权限
-            if (!approverIdList.contains(userId) && !flag) {
+            if (!approverIdList.contains(userId) && !deptAuthority.contains(deptId)) {
                 // 不是该部门的人,不能查看
                 return 1;
             } else {
@@ -1050,15 +1068,13 @@ public class KnowledgeServiceImpl extends SuperServiceImpl<KnowledgeMapper, Know
             //可下载部门情况
             if (StringUtils.isNotEmpty(downloadDeptId)){
                 //可下载部门数组
-                String[] downloadDeptIdStr = downloadDeptId.split(",");
-                for (String downloadDeptIds : downloadDeptIdStr) {
-                    List<String> deptAuthority = knowledgeApproveMapper.findAllDeptIdByParent(downloadDeptIds);
-                    if (deptAuthority.contains(deptId)){
-                        return 0;
-                    }
+                List<String> deptAuthority = knowledgeApproveMapper.findAllDeptIdByParent(Arrays.asList(downloadDeptId.split(",")));
+                if (deptAuthority.contains(deptId)){
+                    return 0;
+                } else {
+                    return 1;
                 }
             }
-
             //可下载人员情况
             if (StringUtils.isNotEmpty(downloadUserId)){
                 List<String> approverIdList = Arrays.asList(downloadUserId.split(","));

+ 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;
 
     }

+ 5 - 2
src/main/resources/mapper/knowledge/KnowledgeApproveMapper.xml

@@ -150,8 +150,11 @@
     </select>
 
     <select id="findAllDeptIdByParent" resultType="string">
-        SELECT os.GROUP_ID_ FROM LEARNING_USER_DEV.OS_GROUP os
-            START WITH os.GROUP_ID_ = #{deptId}
+        SELECT distinct os.GROUP_ID_ FROM LEARNING_USER_DEV.OS_GROUP os
+            START WITH os.GROUP_ID_ in
+            <foreach collection="deptIdList" separator="," open="(" close=")" item="deptId">
+                #{deptId}
+            </foreach>
         CONNECT BY PRIOR os.GROUP_ID_ = os.PARENT_ID_
     </select>
 

+ 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>
 
 

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

@@ -145,7 +145,7 @@
         select count(*)
         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 = 1 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{beginTime} and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{endTime}
             <if test="userId != null">
                 and CREATE_BY_ = #{userId}
             </if>
@@ -169,7 +169,7 @@
                   (select count(*) as yelpSum, CREATE_BY_ as createBy
                    from KM_ALBUM_YELP
                    <where>
-                       STATE = 5 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{beginTime} and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{endTime}
+                       STATE = 1 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
@@ -177,6 +177,32 @@
         where rn &gt;= #{pageNo} and rn &lt;= #{pageSize}
     </select>
 
+    <select id="knowledgeSumByDeptId" resultType="int">
+        select count(*)
+        from KM_KNOWLEDGE
+        <where>
+            APPROVAL_STATUS = 5 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{beginTime} and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{endTime}
+            and CREATE_DEP_ID_ in (SELECT GROUP_ID_
+                                   FROM LEARNING_USER_DEV.OS_GROUP c
+                                   START WITH c.GROUP_ID_ = #{deptId}
+                                   CONNECT BY PRIOR c.GROUP_ID_ = c.PARENT_ID_
+                                   )
+        </where>
+    </select>
+
+    <select id="yelpSumByDeptId" resultType="int">
+        select count(*)
+        from KM_ALBUM_YELP
+        <where>
+            STATE = 1 and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &gt;= #{beginTime} and TO_CHAR(CREATE_TIME_,'yyyy-mm-dd') &lt;= #{endTime}
+            and CREATE_DEP_ID_ in (SELECT GROUP_ID_
+                                   FROM LEARNING_USER_DEV.OS_GROUP c
+                                   START WITH c.GROUP_ID_ = #{deptId}
+                                   CONNECT BY PRIOR c.GROUP_ID_ = c.PARENT_ID_
+                                   )
+        </where>
+    </select>
+
 
 </mapper>