文档库-表头排序
This commit is contained in:
+81
-1
@@ -32,6 +32,7 @@ import com.jero.modules.collection.service.IOnlCgformCollectionService;
|
||||
import com.jero.modules.document.entity.BussDocumentLibraryEO;
|
||||
import com.jero.modules.document.entity.OSSFileForDocumentLibrary;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
import com.jero.modules.document.enums.LawsStateEnum;
|
||||
import com.jero.modules.document.enums.SearchEnum;
|
||||
import com.jero.modules.document.mapper.BussDocumentLibraryEOMapper;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
@@ -3962,6 +3963,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
IPage page = new Page(pageNo, pageSize);
|
||||
IPage infoPage = bussDocumentLibraryEOMapper.getInfoPage(page, " " + StringUtils.join(fieldListNew, ","), condition);
|
||||
|
||||
infoPage = stateSort(parameter, fieldListNew, condition, pageNo, pageSize, infoPage);
|
||||
|
||||
|
||||
//树形数据字典
|
||||
List<SysCategory> categoryList = sysCategoryService.list();
|
||||
//过滤出树形字段
|
||||
@@ -4021,6 +4025,71 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
return infoPage;
|
||||
}
|
||||
|
||||
private IPage stateSort(Map<String, Object> parameter, List<String> fieldListNew, String condition, int pageNo, int pageSize, IPage infoPage) {
|
||||
List<Map<String,Object>> list = new LinkedList<>();
|
||||
//状态排序,需要特殊处理 现行,即将实施,草稿,被替代,废止
|
||||
if(ObjectUtils.isNotEmpty(parameter.get("orderByField")) && "state".equals((String) parameter.get("orderByField"))){
|
||||
List<Map<String, Object>> infoList = bussDocumentLibraryEOMapper.getInfoList(" " + StringUtils.join(fieldListNew, ","), condition);
|
||||
List<Map<String, Object>> active = infoList.stream()
|
||||
.filter(e -> LawsStateEnum.ACTIVE.getValue().equals(e.get("state"))).collect(Collectors.toList());
|
||||
List<Map<String, Object>> theUpcoming = infoList.stream()
|
||||
.filter(e -> LawsStateEnum.THE_UPCOMING.getValue().equals(e.get("state"))).collect(Collectors.toList());
|
||||
List<Map<String, Object>> draft = infoList.stream()
|
||||
.filter(e -> LawsStateEnum.DRAFT.getValue().equals(e.get("state"))).collect(Collectors.toList());
|
||||
List<Map<String, Object>> beReplaced = infoList.stream()
|
||||
.filter(e -> LawsStateEnum.BE_REPLACED.getValue().equals(e.get("state"))).collect(Collectors.toList());
|
||||
List<Map<String, Object>> abolish = infoList.stream()
|
||||
.filter(e -> LawsStateEnum.ABOLISH.getValue().equals(e.get("state"))).collect(Collectors.toList());
|
||||
if ("1".equals((String) parameter.get("orderBy"))) {
|
||||
//正序
|
||||
list.addAll(active);
|
||||
list.addAll(theUpcoming);
|
||||
list.addAll(draft);
|
||||
list.addAll(beReplaced);
|
||||
list.addAll(abolish);
|
||||
|
||||
} else if ("2".equals((String) parameter.get("orderBy"))) {
|
||||
//倒序
|
||||
list.addAll(abolish);
|
||||
list.addAll(beReplaced);
|
||||
list.addAll(draft);
|
||||
list.addAll(theUpcoming);
|
||||
list.addAll(active);
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(list)){
|
||||
infoPage = getPages(pageNo, pageSize, list);
|
||||
}
|
||||
}
|
||||
return infoPage;
|
||||
}
|
||||
|
||||
public IPage getPages(Integer currentPage, Integer pageSize, List<Map<String,Object>> list){
|
||||
IPage page =new Page();
|
||||
if(list==null){
|
||||
return null;
|
||||
}
|
||||
int size = list.size();
|
||||
if(pageSize > size){
|
||||
pageSize = size;
|
||||
}
|
||||
if(pageSize!=0){
|
||||
//求出最⼤页数,防⽌currentPage越界
|
||||
int maxPage = size % pageSize ==0? size / pageSize : size / pageSize +1;
|
||||
if(currentPage > maxPage){
|
||||
currentPage = maxPage;
|
||||
}
|
||||
}
|
||||
//当前页第⼀条数据的下标
|
||||
int curIdx = currentPage >1?(currentPage -1)* pageSize :0;
|
||||
List pageList =new ArrayList();
|
||||
//将当前页的数据放进pageList
|
||||
for(int i =0; i < pageSize && curIdx + i < size; i++){
|
||||
pageList.add(list.get(curIdx + i));
|
||||
}
|
||||
page.setCurrent(currentPage).setSize(pageSize).setTotal(list.size()).setRecords(pageList);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public String getConditionStr(Map<String, Object> parameter) {
|
||||
@@ -4134,7 +4203,18 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}else{
|
||||
//处理列表表头排序
|
||||
if (StringUtils.isNotBlank((String) parameter.get("orderByField"))) {
|
||||
conditionSb.append(" order by " + (String) parameter.get("orderByField"));
|
||||
String orderByField = (String) parameter.get("orderByField");
|
||||
if("serial_number".equals(orderByField)
|
||||
|| "title".equals(orderByField)
|
||||
|| "title_en".equals(orderByField)
|
||||
|| "region".equals(orderByField)
|
||||
|| "technology_territory".equals(orderByField)){
|
||||
|
||||
conditionSb.append(" order by " + "CONVERT("+orderByField +"USING gbk) COLLATE gbk_chinese_ci");
|
||||
}else if("issue_time".equals(orderByField)){
|
||||
conditionSb.append(" order by " + (String) parameter.get("orderByField"));
|
||||
}
|
||||
|
||||
if ("1".equals((String) parameter.get("orderBy"))) {
|
||||
conditionSb.append(" asc");//正序
|
||||
} else if ("2".equals((String) parameter.get("orderBy"))) {
|
||||
|
||||
Reference in New Issue
Block a user