|
@@ -465,13 +465,32 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
List<CurrentNode> nodeType46 = getNodeType46(tec);
|
|
|
List<Long> ids = nodeType46.stream().map(CurrentNode::getPkId).collect(Collectors.toList());
|
|
|
|
|
|
- Map<Long, Integer> sortMap = nodeType46.stream().collect(Collectors.toMap(CurrentNode::getPkId, CurrentNode::getSort));
|
|
|
- itemBlockList.sort((obj1, obj2) -> {
|
|
|
- int sort1 = sortMap.getOrDefault(obj1.getPkeyId(), Integer.MAX_VALUE);
|
|
|
- int sort2 = sortMap.getOrDefault(obj2.getPkeyId(), Integer.MAX_VALUE);
|
|
|
- // 比较排序值
|
|
|
- return Integer.compare(sort1, sort2);
|
|
|
- });
|
|
|
+ Map<Long, CurrentNode> sortInfoMap = nodeType46.stream().collect(Collectors.toMap(CurrentNode::getPkId, info -> info,
|
|
|
+ (oldInfo, newInfo) -> newInfo));
|
|
|
+ //排序规则
|
|
|
+ Comparator<ItemBlock> itemBlockComparator = Comparator
|
|
|
+ // 第一级:按sort排序(升序),缺失的排最后
|
|
|
+ .comparingInt((ItemBlock obj) ->
|
|
|
+ sortInfoMap.containsKey(obj.getPkeyId()) ?
|
|
|
+ sortInfoMap.get(obj.getPkeyId()).getSort() :
|
|
|
+ Integer.MAX_VALUE)
|
|
|
+
|
|
|
+ // 第二级:按title排序(自然顺序),缺失的排最后
|
|
|
+ .thenComparing(obj ->
|
|
|
+ sortInfoMap.containsKey(obj.getPkeyId()) ?
|
|
|
+ sortInfoMap.get(obj.getPkeyId()).getTitle() :
|
|
|
+ null,
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder()))
|
|
|
+
|
|
|
+ // 第三级:按create_time排序(时间升序),缺失的排最后
|
|
|
+ .thenComparing(obj ->
|
|
|
+ sortInfoMap.containsKey(obj.getPkeyId()) ?
|
|
|
+ sortInfoMap.get(obj.getPkeyId()).getCreateTime() :
|
|
|
+ null,
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder()));
|
|
|
+
|
|
|
+ // 2. 对对象集合进行多级排序
|
|
|
+ itemBlockList.sort(itemBlockComparator);
|
|
|
|
|
|
|
|
|
/*清除那些已经不存在的工序*/
|
|
@@ -642,7 +661,15 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
|
|
|
public void descendantType46(Object id, List<Map<String, Object>> listMaps) {
|
|
|
- String sql = "select p_Key_id pkId,id,node_type nodeType,table_type tableType,sort from m_wbs_tree_contract where parent_id =? and is_deleted=0";
|
|
|
+ String sql = "select " +
|
|
|
+ "p_Key_id pkId," +
|
|
|
+ "id," +
|
|
|
+ "node_type nodeType," +
|
|
|
+ "table_type tableType," +
|
|
|
+ "sort," +
|
|
|
+ "IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title," +
|
|
|
+ "create_time createTime " +
|
|
|
+ "from m_wbs_tree_contract where parent_id =? and is_deleted=0";
|
|
|
List<Map<String, Object>> tmp = this.jdbcTemplate.queryForList(sql, id);
|
|
|
if (tmp.size() > 0) {
|
|
|
for (Map<String, Object> map : tmp) {
|