相关人员名单默认排序以及表头排序

This commit is contained in:
zhn
2023-10-19 16:37:31 +08:00
parent 474e0dcff5
commit 42988d66f8
6 changed files with 188 additions and 14 deletions
@@ -61,7 +61,9 @@ public class ProjectRelatedPersonnelController extends JeroController<ProjectRel
(String) map.get("engineeringInterfacePerson"),
(String) map.get("engineerLawSet"),
(String) map.get("engineerAttSet"),
(String) map.get("firstLevelDutyTerritory"));
(String) map.get("firstLevelDutyTerritory"),
(String) map.get("orderBy"),
(String) map.get("orderByField"));
return Result.OK((String)map.get("cut"),pageList);
}
/**
@@ -43,6 +43,8 @@ public class ProjectRelatedPersonnel implements Serializable {
@Excel(name = "责任领域,Responsible Field", width = 15,orderNum = "1",dicCode = "duty_territory")
@Dict(dicCode = "duty_territory")
private java.lang.String dutyTerritory;
@TableField(exist = false)
private java.lang.String dutyTerritoryName;
/**法规工程师*/
private java.lang.String lawEngineer;
@@ -76,7 +76,7 @@
</if>
AND sd.dict_code = #{dictCode}
</where>
ORDER BY sdi.item_text ASC
ORDER BY sdi.sort_order ASC
</select>
<select id="queryById" resultType="com.jero.modules.project.entity.ProjectRelatedPersonnel">
@@ -3,7 +3,6 @@ package com.jero.modules.project.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.common.api.vo.Result;
import com.jero.common.system.vo.DictModel;
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.system.entity.SysDictItem;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -71,7 +70,15 @@ public interface IProjectRelatedPersonnelService extends IService<ProjectRelated
List<ProjectRelatedPersonnel> queryList();
// List<ProjectRelatedPersonnel> queryPageList(String projectId,String dutyTerritory,String lawEngineer,String engineeringInterfacePerson,String certificationEngineer);
List<ProjectRelatedPersonnel> queryPageList(String projectId,String dutyTerritory,String lawEngineer,String engineeringInterfacePerson,String engineerLawSet,String engineerAttSet,String firstLevelDutyTerritory);
List<ProjectRelatedPersonnel> queryPageList(String projectId,
String dutyTerritory,
String lawEngineer,
String engineeringInterfacePerson,
String engineerLawSet,
String engineerAttSet,
String firstLevelDutyTerritory,
String orderBy,
String orderByField);
Map<String,Object> queryPersonByProjectId(String projectId, String dutyTerritory);
@@ -1746,7 +1746,7 @@ public class ProjectCertificationInventoryEOServiceImpl extends ServiceImpl<Proj
// 法规
//相关人员名单中取法规工程师
List<ProjectRelatedPersonnel> projectRelatedPersonnels = this.projectRelatedPersonnelService.queryPageList(projectLibraryId,null,null,null,null,null,null);
List<ProjectRelatedPersonnel> projectRelatedPersonnels = this.projectRelatedPersonnelService.queryPageList(projectLibraryId,null,null,null,null,null,null,null,null);
List<String> lawEngineerNameList = new ArrayList<>();
if(projectRelatedPersonnels.size() != 0){
for (ProjectRelatedPersonnel projectRelatedPersonnel : projectRelatedPersonnels) {
@@ -10,15 +10,23 @@ import com.jero.common.constant.CommonConstant;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.vo.DictModel;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.RedisUtil;
import com.jero.common.util.TokenUtils;
import com.jero.modules.dummy.enums.OrderEnum;
import com.jero.modules.dummy.service.impl.DummyInventoryInfoEOServiceImpl;
import com.jero.modules.enums.DictCodeEnum;
import com.jero.modules.ocr.entity.User;
import com.jero.modules.project.entity.*;
import com.jero.modules.project.enums.*;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.entity.ProjectRelatedPersonnel;
import com.jero.modules.project.entity.ProjectTaskInventoryEO;
import com.jero.modules.project.entity.ProjectUserPermission;
import com.jero.modules.project.enums.DesignComplianceStatusEnum;
import com.jero.modules.project.enums.PermissionDescriptionEnum;
import com.jero.modules.project.enums.ProjectInventoryFieldEnum;
import com.jero.modules.project.enums.ProjectRoleEnum;
import com.jero.modules.project.enums.ProjectUserLocationEnum;
import com.jero.modules.project.enums.TaskAffirmStatusEnum;
import com.jero.modules.project.mapper.ProjectLibraryBaseMapper;
import com.jero.modules.project.mapper.ProjectRelatedPersonnelMapper;
import com.jero.modules.project.mapper.ProjectTaskInventoryEOMapper;
@@ -33,7 +41,7 @@ import com.jero.modules.system.mapper.SysUserMapper;
import com.jero.modules.system.service.ISysDictItemService;
import com.jero.modules.system.service.ISysDictService;
import com.jero.modules.system.service.ISysUserService;
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
import com.jero.modules.system.util.DictItemUtil;
import com.jero.modules.system.util.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
@@ -43,7 +51,14 @@ import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -57,7 +72,18 @@ import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeSet;
import java.util.stream.Collectors;
/**
@@ -295,7 +321,9 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
String lawEngineer,
String engineeringInterfacePerson,
String engineerLawSet,String engineerAttSet,
String firstLevelDutyTerritory) {
String firstLevelDutyTerritory,
String orderBy,
String orderByField) {
//查询数据
List<ProjectRelatedPersonnel> result = projectRelatedPersonnelMapper.queryPageList(projectId,
DictCodeEnum.DUTY_TERRITORY.getValue(),
@@ -337,9 +365,130 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
}
}
disposeData(result,firstLevelDutyTerritory);
//表头排序
if(StringUtils.isNotBlank(orderByField)) {
hearSort(orderBy, orderByField, result);
}
return result;
}
private void hearSort(String orderBy, String orderByField, List<ProjectRelatedPersonnel> result) {
Collator comparator = Collator.getInstance(Locale.CHINESE);
// 责任部门 dutyTerritory
if("dutyTerritory".equals(orderByField)){
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
Collections.sort(result,(e1, e2)->{
String e1DutyTerritoryName = StringUtils.isNotBlank(e1.getDutyTerritoryName()) ? e1.getDutyTerritoryName() : "";
String e2DutyTerritoryName = StringUtils.isNotBlank(e2.getDutyTerritoryName()) ? e2.getDutyTerritoryName() : "";
return comparator.compare(e1DutyTerritoryName,e2DutyTerritoryName);
});
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
Collections.sort(result,(e1,e2)->{
String e1DutyTerritoryName = StringUtils.isNotBlank(e1.getDutyTerritoryName()) ? e1.getDutyTerritoryName() : "";
String e2DutyTerritoryName = StringUtils.isNotBlank(e2.getDutyTerritoryName()) ? e2.getDutyTerritoryName() : "";
return comparator.compare(e2DutyTerritoryName,e1DutyTerritoryName);
});
}
}
//责任领域 firstLevelDutyTerritory
if("firstLevelDutyTerritory".equals(orderByField)){
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
Collections.sort(result,(e1, e2)->{
String e1FirstLevelDutyTerritory = StringUtils.isNotBlank(e1.getFirstLevelDutyTerritory()) ? e1.getFirstLevelDutyTerritory() : "";
String e2FirstLevelDutyTerritory = StringUtils.isNotBlank(e2.getFirstLevelDutyTerritory()) ? e2.getFirstLevelDutyTerritory() : "";
return comparator.compare(e1FirstLevelDutyTerritory,e2FirstLevelDutyTerritory);
});
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
Collections.sort(result,(e1,e2)->{
String e1FirstLevelDutyTerritory = StringUtils.isNotBlank(e1.getFirstLevelDutyTerritory()) ? e1.getFirstLevelDutyTerritory() : "";
String e2FirstLevelDutyTerritory = StringUtils.isNotBlank(e2.getFirstLevelDutyTerritory()) ? e2.getFirstLevelDutyTerritory() : "";
return comparator.compare(e2FirstLevelDutyTerritory,e1FirstLevelDutyTerritory);
});
}
}
//法规工程师 lawEngineer
if("lawEngineer".equals(orderByField)){
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
Collections.sort(result,(e1, e2)->{
String e1LawEngineerName = StringUtils.isNotBlank(e1.getLawEngineerName()) ? e1.getLawEngineerName() : "";
String e2LawEngineerName = StringUtils.isNotBlank(e2.getLawEngineerName()) ? e2.getLawEngineerName() : "";
return comparator.compare(e1LawEngineerName,e2LawEngineerName);
});
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
Collections.sort(result,(e1,e2)->{
String e1LawEngineerName = StringUtils.isNotBlank(e1.getLawEngineerName()) ? e1.getLawEngineerName() : "";
String e2LawEngineerName = StringUtils.isNotBlank(e2.getLawEngineerName()) ? e2.getLawEngineerName() : "";
return comparator.compare(e2LawEngineerName,e1LawEngineerName);
});
}
}
//工程接口人 engineeringInterfacePerson
if("engineeringInterfacePerson".equals(orderByField)){
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
Collections.sort(result,(e1, e2)->{
String e1EngineeringInterfacePersonName = StringUtils.isNotBlank(e1.getEngineeringInterfacePersonName()) ? e1.getEngineeringInterfacePersonName() : "";
String e2EngineeringInterfacePersonName = StringUtils.isNotBlank(e2.getEngineeringInterfacePersonName()) ? e2.getEngineeringInterfacePersonName() : "";
return comparator.compare(e1EngineeringInterfacePersonName,e2EngineeringInterfacePersonName);
});
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
Collections.sort(result,(e1,e2)->{
String e1EngineeringInterfacePersonName = StringUtils.isNotBlank(e1.getEngineeringInterfacePersonName()) ? e1.getEngineeringInterfacePersonName() : "";
String e2EngineeringInterfacePersonName = StringUtils.isNotBlank(e2.getEngineeringInterfacePersonName()) ? e2.getEngineeringInterfacePersonName() : "";
return comparator.compare(e2EngineeringInterfacePersonName,e1EngineeringInterfacePersonName);
});
}
}
//工程接口人-法规工程师设置 engineerLawSet
if("engineerLawSet".equals(orderByField)){
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
Collections.sort(result,(e1, e2)->{
String e1EngineerLawSetName = StringUtils.isNotBlank(e1.getEngineerLawSetName()) ? e1.getEngineerLawSetName() : "";
String e2EngineerLawSetName = StringUtils.isNotBlank(e2.getEngineerLawSetName()) ? e2.getEngineerLawSetName() : "";
return comparator.compare(e1EngineerLawSetName,e2EngineerLawSetName);
});
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
Collections.sort(result,(e1,e2)->{
String e1EngineerLawSetName = StringUtils.isNotBlank(e1.getEngineerLawSetName()) ? e1.getEngineerLawSetName() : "";
String e2EngineerLawSetName = StringUtils.isNotBlank(e2.getEngineerLawSetName()) ? e2.getEngineerLawSetName() : "";
return comparator.compare(e2EngineerLawSetName,e1EngineerLawSetName);
});
}
}
//工程接口人-认证工程师设置 engineerAttSet
if("engineerAttSet".equals(orderByField)){
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
Collections.sort(result,(e1, e2)->{
String e1EngineerAttSetName = StringUtils.isNotBlank(e1.getEngineerAttSetName()) ? e1.getEngineerAttSetName() : "";
String e2EngineerAttSetName = StringUtils.isNotBlank(e2.getEngineerAttSetName()) ? e2.getEngineerAttSetName() : "";
return comparator.compare(e1EngineerAttSetName,e2EngineerAttSetName);
});
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
Collections.sort(result,(e1,e2)->{
String e1EngineerAttSetName = StringUtils.isNotBlank(e1.getEngineerAttSetName()) ? e1.getEngineerAttSetName() : "";
String e2EngineerAttSetName = StringUtils.isNotBlank(e2.getEngineerAttSetName()) ? e2.getEngineerAttSetName() : "";
return comparator.compare(e2EngineerAttSetName,e1EngineerAttSetName);
});
}
}
//备注 remark
if("remark".equals(orderByField)){
if(OrderEnum.POSITIVE.getValue().equals(orderBy)){
Collections.sort(result,(e1, e2)->{
String e1Remark = StringUtils.isNotBlank(e1.getRemark()) ? e1.getRemark() : "";
String e2Remark = StringUtils.isNotBlank(e2.getRemark()) ? e2.getRemark() : "";
return comparator.compare(e1Remark,e2Remark);
});
}else if(OrderEnum.REVERSE.getValue().equals(orderBy)){
Collections.sort(result,(e1,e2)->{
String e1Remark = StringUtils.isNotBlank(e1.getRemark()) ? e1.getRemark() : "";
String e2Remark = StringUtils.isNotBlank(e2.getRemark()) ? e2.getRemark() : "";
return comparator.compare(e2Remark,e1Remark);
});
}
}
}
public void disposeData(List<ProjectRelatedPersonnel> records, String firstLevelDutyTerritory) {
List<SysDictItem> sysDictItems = this.sysDictItemService.selectItemsAll();
@@ -363,6 +512,20 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
}
}
}
//责任部门
if(StringUtils.isNotBlank(dutyTerritory)){
StringBuilder sb = new StringBuilder();
for (String s : dutyTerritory.split(",")) {
List<SysDictItem> collect = sysDictItems.stream().filter(e -> s.equals(e.getItemValue())).collect(Collectors.toList());
if(ObjectUtils.isNotEmpty(collect)){
sb.append(collect.get(0).getItemText()+",");
}
}
if(StringUtils.isNotBlank(sb)){
String substring = sb.substring(0, sb.length() - 1);
projectRelatedPersonnel.setDutyTerritoryName(substring);
}
}
//法规工程师
List<SysUser> lawEngineerUsers = new ArrayList<>();
if (StringUtils.isNotEmpty(projectRelatedPersonnel.getLawEngineer())){
@@ -731,7 +894,7 @@ public class ProjectRelatedPersonnelServiceImpl extends ServiceImpl<ProjectRelat
records = queryById(id);
}
}else{
records=queryPageList(projectId,null,null,null,null,null,null);
records=queryPageList(projectId,null,null,null,null,null,null,null,null);
}
//id无值,传全部
disposeDutyTerritory(records,cut);