排序BUG修复

pull/225/head
dxfeng 2 years ago
parent dd13fee015
commit 35cf5dc8f6

@ -74,4 +74,8 @@ public class CompListDTO {
*
*/
private List<CompListDTO> children;
public Integer getShowOrder() {
return null == showOrder ? 0 : showOrder;
}
}

@ -90,4 +90,8 @@ public class DepartmentListDTO {
*
*/
private List<DepartmentListDTO> children;
public Double getShowOrder() {
return null == showOrder ? 0 : showOrder;
}
}

@ -98,4 +98,8 @@ public class JobListDTO {
*
*/
private List<JobListDTO> children;
public Integer getShowOrder() {
return null == showOrder ? 0 : showOrder;
}
}

@ -516,7 +516,7 @@
select t.id
from jcl_org_job t
inner join hrmresource h on t.ec_jobtitle = h.jobtitle and t.ec_company = h.subcompanyid1 and
t.ec_department = h.departmentid and t.id = #{jobId}
t.ec_department = h.departmentid and t.id = #{jobId} and h.status &lt; 4
</select>
<select id="getJobByResource" resultType="com.engine.organization.entity.job.po.JobPO">
select

@ -70,7 +70,8 @@ public class CompServiceImpl extends Service implements CompService {
CompPO companyPO = CompBO.convertParamToPO(params, user.getUID());
boolean filter = isFilter(companyPO);
PageInfo<CompListDTO> pageInfos;
String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams(), " showorder ");
StringBuilder orderType = new StringBuilder("asc");
String orderSql = PageInfoSortUtil.getSortSql(orderType, params.getSortParams(), " showorder ");
List<CompPO> allList = getCompMapper().listAll(orderSql);
new DetachUtil(user).filterCompanyList(allList);
@ -83,6 +84,12 @@ public class CompServiceImpl extends Service implements CompService {
// 添加父级元素
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(allList, filterCompPOs);
if ("asc".equalsIgnoreCase(orderType.toString())) {
compListDTOS = compListDTOS.stream().sorted(Comparator.comparing(CompListDTO::getShowOrder)).collect(Collectors.toList());
} else {
compListDTOS = compListDTOS.stream().sorted(Comparator.comparing(CompListDTO::getShowOrder).reversed()).collect(Collectors.toList());
}
List<CompListDTO> subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS);
pageInfos = new PageInfo<>(subList, CompListDTO.class);
pageInfos.setTotal(compListDTOS.size());

@ -131,7 +131,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, user.getUID());
boolean filter = isFilter(departmentPO);
PageInfo<DepartmentListDTO> pageInfos;
String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams(), " showorder ");
StringBuilder orderType = new StringBuilder("asc");
String orderSql = PageInfoSortUtil.getSortSql(orderType, param.getSortParams(), " showorder ");
List<DepartmentPO> allList = getDepartmentMapper().listAll(orderSql);
new DetachUtil(user).filterDepartmentList(allList);
// 通过子级遍历父级元素
@ -141,6 +143,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
new DetachUtil(user).filterDepartmentList(filterDeptPOs);
// 添加父级元素
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(allList, filterDeptPOs);
if ("asc".equalsIgnoreCase(orderType.toString())) {
compListDTOS = compListDTOS.stream().sorted(Comparator.comparing(DepartmentListDTO::getShowOrder)).collect(Collectors.toList());
} else {
compListDTOS = compListDTOS.stream().sorted(Comparator.comparing(DepartmentListDTO::getShowOrder).reversed()).collect(Collectors.toList());
}
List<DepartmentListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS);
pageInfos = new PageInfo<>(DepartmentBO.buildDeptDTOShowNames(subList), DepartmentListDTO.class);
pageInfos.setTotal(compListDTOS.size());

@ -149,7 +149,9 @@ public class JobServiceImpl extends Service implements JobService {
JobPO jobPO = JobBO.convertParamsToPO(param, user.getUID());
boolean filter = isFilter(jobPO);
PageInfo<JobListDTO> pageInfos;
String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams(), " show_order ");
StringBuilder orderType = new StringBuilder("asc");
String orderSql = PageInfoSortUtil.getSortSql(orderType, param.getSortParams(), " show_order ");
orderSql = orderSql.replace("showOrder", "show_order");
List<JobListDTO> allList = getJobMapper().listNoFilter(orderSql);
new DetachUtil(user).filterJobDTOList(allList);
// 通过子级遍历父级元素
@ -159,6 +161,12 @@ public class JobServiceImpl extends Service implements JobService {
new DetachUtil(user).filterJobDTOList(allList);
// 添加父级元素
List<JobListDTO> jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs);
if ("asc".equalsIgnoreCase(orderType.toString())) {
jobListDTOS = jobListDTOS.stream().sorted(Comparator.comparing(JobListDTO::getShowOrder)).collect(Collectors.toList());
} else {
jobListDTOS = jobListDTOS.stream().sorted(Comparator.comparing(JobListDTO::getShowOrder).reversed()).collect(Collectors.toList());
}
List<JobListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS);
pageInfos = new PageInfo<>(subList, JobListDTO.class);
pageInfos.setTotal(jobListDTOS.size());
@ -637,7 +645,7 @@ public class JobServiceImpl extends Service implements JobService {
* @param departmentPO
* @param builderDeparts
*/
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts,Map<Integer, DepartmentPO> departmentPOMap) {
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts, Map<Integer, DepartmentPO> departmentPOMap) {
builderDeparts.add(departmentPO);
if (SearchTreeUtil.isTop(departmentPO.getSupDepId())) {
return;
@ -710,7 +718,7 @@ public class JobServiceImpl extends Service implements JobService {
new DetachUtil(user).filterCompanyList(filterComps);
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts,departmentPOMap);
buildParentDepts(departmentPO, builderDeparts, departmentPOMap);
}
List<SearchTree> deptTrees = SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 添加部门的上级分部

@ -20,12 +20,13 @@ public class PageInfoSortUtil {
* @param sortParams
* @return
*/
public static String getSortSql(String sortParams, String defaultOrder) {
public static String getSortSql(StringBuilder orderType, String sortParams, String defaultOrder) {
JSONArray jsonArray = JSONObject.parseArray(sortParams);
if (CollectionUtils.isNotEmpty(jsonArray)) {
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
String orderKey = jsonObject.getString("orderkey");
String sortOrder = jsonObject.getString("sortOrder").replace("end", "");
orderType.replace(0, orderType.length(), sortOrder);
return "t." + orderKey + " " + sortOrder;
}
return defaultOrder;

Loading…
Cancel
Save