未符合项跟踪--表头排序
This commit is contained in:
+111
@@ -3,11 +3,13 @@ package com.jero.modules.project.controller;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.common.aspect.annotation.AutoLog;
|
import com.jero.common.aspect.annotation.AutoLog;
|
||||||
|
import com.jero.modules.dummy.enums.OrderEnum;
|
||||||
import com.jero.modules.project.service.INcrTrackService;
|
import com.jero.modules.project.service.INcrTrackService;
|
||||||
import com.jero.modules.project.vo.NcrTrackVO;
|
import com.jero.modules.project.vo.NcrTrackVO;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -19,7 +21,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description
|
* @description
|
||||||
@@ -51,10 +56,116 @@ public class NcrTrackController {
|
|||||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||||
HttpServletRequest req) {
|
HttpServletRequest req) {
|
||||||
List<NcrTrackVO> pageInfo = iNcrTrackService.getPageInfo(ncrTrackVO);
|
List<NcrTrackVO> pageInfo = iNcrTrackService.getPageInfo(ncrTrackVO);
|
||||||
|
//表头排序
|
||||||
|
orderHeader(ncrTrackVO, pageInfo);
|
||||||
Page pages = iNcrTrackService.getPages(pageNo, pageSize, pageInfo);
|
Page pages = iNcrTrackService.getPages(pageNo, pageSize, pageInfo);
|
||||||
return Result.OK(ncrTrackVO.getCut(),pages);
|
return Result.OK(ncrTrackVO.getCut(),pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void orderHeader(NcrTrackVO ncrTrackVO, List<NcrTrackVO> pageInfo) {
|
||||||
|
String orderBy = ncrTrackVO.getOrderBy();
|
||||||
|
String orderByField = ncrTrackVO.getOrderByField();
|
||||||
|
if(ObjectUtils.isNotEmpty(orderByField)){
|
||||||
|
Collator comparator = Collator.getInstance(Locale.CHINESE);
|
||||||
|
//编号
|
||||||
|
if("serialNumber".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1, e2)->{
|
||||||
|
return comparator.compare(e1.getSerialNumber(),e2.getSerialNumber());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getSerialNumber(),e1.getSerialNumber());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//标题
|
||||||
|
if("title".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e1.getTitle(),e2.getTitle());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getTitle(),e1.getTitle());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//流程类型
|
||||||
|
if("flowType".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e1.getFlowType(),e2.getFlowType());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getFlowType(),e1.getFlowType());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//责任领域
|
||||||
|
if("dutyTerritory".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e1.getDutyTerritory(),e2.getDutyTerritory());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getDutyTerritory(),e1.getDutyTerritory());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//相关项目
|
||||||
|
if("projectName".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e1.getProjectName(),e2.getProjectName());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getProjectName(),e1.getProjectName());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//问题类型
|
||||||
|
if("problemType".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e1.getProblemType(),e2.getProblemType());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getProblemType(),e1.getProblemType());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//发起人
|
||||||
|
if("initiator".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e1.getInitiator(),e2.getInitiator());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getInitiator(),e1.getInitiator());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//责任人
|
||||||
|
if("duty".equals(orderByField)){
|
||||||
|
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e1.getDuty(),e2.getDuty());
|
||||||
|
});
|
||||||
|
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
|
||||||
|
Collections.sort(pageInfo,(e1,e2)->{
|
||||||
|
return comparator.compare(e2.getDuty(),e1.getDuty());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 项目详情中项目未符合项跟踪
|
* 项目详情中项目未符合项跟踪
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -141,6 +141,13 @@ public class NcrTrackVO implements Serializable {
|
|||||||
private String administrator;
|
private String administrator;
|
||||||
|
|
||||||
|
|
||||||
|
//排序(1->正序, 2->倒序)
|
||||||
|
private String orderBy;
|
||||||
|
|
||||||
|
//排序字段
|
||||||
|
private String orderByField;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user