Forráskód Böngészése

fixed 回避设计中后续事项

zero 1 éve
szülő
commit
e4f5cddab3

+ 4 - 0
src/main/java/cn/cslg/pas/common/dto/FollowUpQueryDTO.java

@@ -1,8 +1,10 @@
 package cn.cslg.pas.common.dto;
 
+import cn.cslg.pas.common.model.request.OrderDTO;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -29,4 +31,6 @@ public class FollowUpQueryDTO {
      */
     private Integer size;
 
+    private List<OrderDTO> orderDTOList;
+
 }

+ 35 - 9
src/main/java/cn/cslg/pas/service/business/FollowUpService.java

@@ -9,15 +9,13 @@ import cn.cslg.pas.common.model.cronModel.PersonnelVO;
 import cn.cslg.pas.common.model.cronModel.Records;
 import cn.cslg.pas.common.model.cronModel.SystemFile;
 import cn.cslg.pas.common.model.request.GroupRequest;
+import cn.cslg.pas.common.model.request.OrderDTO;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.LoginUtils;
 import cn.cslg.pas.common.vo.business.FollowUpVO;
 import cn.cslg.pas.common.vo.business.ReportProjectVO;
-import cn.cslg.pas.domain.business.AssoEventFile;
-import cn.cslg.pas.domain.business.AssoFollowUpFile;
-import cn.cslg.pas.domain.business.FollowUp;
-import cn.cslg.pas.domain.business.RdProject;
+import cn.cslg.pas.domain.business.*;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.mapper.FollowUpMapper;
@@ -27,6 +25,7 @@ import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
@@ -38,9 +37,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.IOException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -133,11 +130,25 @@ public class FollowUpService extends ServiceImpl<FollowUpMapper, FollowUp> {
         Integer size = followUpQueryDTO.getSize();
         Integer current = followUpQueryDTO.getCurrent();
         Integer projectId = followUpQueryDTO.getProjectId();
+        List<OrderDTO> orderDTOList = followUpQueryDTO.getOrderDTOList();
         if (projectId == null) {
             throw new XiaoShiException("未选择报告");
         }
-        LambdaQueryWrapper<FollowUp> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(FollowUp::getProjectId, projectId);
+        QueryWrapper<FollowUp> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(FollowUp::getProjectId, projectId);
+        //添加排序逻辑
+        if (orderDTOList.size() == 1) {
+            OrderDTO orderDTO = orderDTOList.get(0);
+            String orderByField = orderDTO.getOrderBy();
+            String column = this.getColumns(orderByField);
+            boolean isTrue = orderDTO.getOrderType() == 0;
+            if (orderByField != null && !orderByField.equals("")) {
+                queryWrapper.orderBy(true, isTrue, column);
+            }
+        } else {
+            queryWrapper.orderBy(true, true, "create_time");
+        }
+
         if (size != null && current != null) {
             Page<FollowUp> followUpPage = this.page(new Page<>(current, size), queryWrapper);
             Records records = new Records();
@@ -263,4 +274,19 @@ public class FollowUpService extends ServiceImpl<FollowUpMapper, FollowUp> {
         }
         return  followUpId;
     }
+
+    public String getColumns(String column){
+        Map<String, String> map = new HashMap<>();
+        map.put("name","name");
+        map.put("description","description");
+        map.put("deadline","deadline");
+        map.put("handler","handler");
+        map.put("synery","synery");
+        map.put("createName","create_id");
+        map.put("createTime","create_time");
+        map.put("finishTime","finish_time");
+        map.put("statusStr","status");
+        String reStr = map.get(column);
+        return reStr;
+    }
 }