|
@@ -30,6 +30,7 @@ import org.springblade.manager.feign.ProjectClient;
|
|
|
import org.springblade.manager.feign.SignPfxClient;
|
|
|
import org.springblade.manager.vo.ContractInfoVO;
|
|
|
import org.springblade.manager.vo.ProjectInfoVO;
|
|
|
+import org.springblade.manager.vo.WbsTreeContractLazyVO;
|
|
|
import org.springblade.system.entity.Role;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
@@ -273,35 +274,30 @@ public class UserViewProjectContractController {
|
|
|
//剔除没有合同段的项目
|
|
|
projectInfoVOS.removeIf(next -> next.getContractInfoList().size() == 0);
|
|
|
//排序项目
|
|
|
- List<Long> collectIds = new ArrayList<>();
|
|
|
+ List<UserProjectInfoCollect> collectIds = new ArrayList<>();
|
|
|
if (!projectInfoVOS.isEmpty()) {
|
|
|
String pIds = projectInfoVOS.stream().map(projectInfoVO -> projectInfoVO.getId() + "").collect(Collectors.joining(","));
|
|
|
- collectIds = jdbcTemplate.query("select project_id from m_user_project_collect where is_deleted = 0 and user_id = " + AuthUtil.getUserId() + " and project_id in ( " + pIds + ")",
|
|
|
- new SingleColumnRowMapper<>(Long.class));
|
|
|
+ collectIds = jdbcTemplate.query("select project_id,sort from m_user_project_collect where is_deleted = 0 and user_id = " + AuthUtil.getUserId() + " and project_id in ( " + pIds + ")",
|
|
|
+ new BeanPropertyRowMapper<>(UserProjectInfoCollect.class));
|
|
|
}
|
|
|
- Map<Long, Long> collect = collectIds.stream().collect(Collectors.toMap(v -> v, v -> v, (k1, k2) -> k1));
|
|
|
- // 按是否收藏进行排序,然后按照sort 进行排序
|
|
|
- projectInfoVOS.sort((o1, o2) -> {
|
|
|
- if (collect.containsKey(o1.getId())) {
|
|
|
- if (!collect.containsKey(o2.getId())) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (collect.containsKey(o2.getId())) {
|
|
|
- return 1;
|
|
|
- }
|
|
|
- }
|
|
|
- if (o1.getSort() != null && o2.getSort() != null) {
|
|
|
- return o1.getSort().compareTo(o2.getSort());
|
|
|
- }
|
|
|
- return 0;
|
|
|
- });
|
|
|
+ Map<Long, Integer> collect = collectIds.stream().collect(Collectors.toMap(UserProjectInfoCollect::getProjectId, UserProjectInfoCollect::getSort, (k1, k2) -> k1));
|
|
|
+ for (ProjectInfoVO vo : projectInfoVOS) {
|
|
|
+ vo.setIsCollect(collect.getOrDefault(vo.getId(), 999));
|
|
|
+ }
|
|
|
+ // 按是否收藏进行排序,然后按照sort 进行排序, 按照创建时间倒序排序
|
|
|
+ projectInfoVOS.sort(Comparator.comparing(ProjectInfoVO::getIsCollect, Comparator.nullsLast(Comparator.naturalOrder()))
|
|
|
+ .thenComparing(ProjectInfoVO::getSort, Comparator.nullsLast(Comparator.naturalOrder())).thenComparing(ProjectInfoVO::getCreateTime, Comparator.nullsLast(Comparator.reverseOrder())));
|
|
|
+
|
|
|
//将合同段中业主合同段排在最前面
|
|
|
if(ObjectUtil.isNotEmpty(projectInfoVOS)){
|
|
|
for (ProjectInfoVO projectInfoVO : projectInfoVOS) {
|
|
|
if(ObjectUtil.isNotEmpty(projectInfoVO.getContractInfoList())){
|
|
|
List<ContractInfoVO> contractInfoList = projectInfoVO.getContractInfoList();
|
|
|
- contractInfoList.sort(Comparator.comparingInt(ContractInfoVO::getSort));
|
|
|
+ contractInfoList.sort(Comparator
|
|
|
+ .comparing(ContractInfoVO::getSort, Comparator.nullsLast(Comparator.naturalOrder()))
|
|
|
+ .thenComparing(
|
|
|
+ ContractInfoVO::getCreateTime,
|
|
|
+ Comparator.nullsLast(Comparator.reverseOrder())));
|
|
|
}
|
|
|
}
|
|
|
}
|