Commit 84a8172a authored by 刘林's avatar 刘林

fix(ymt):安全技术档案管理, D1_A3 8大类设备技术档案列表信息添加排序

parent 5756be0e
...@@ -175,6 +175,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -175,6 +175,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private static final String LEVEL = "company"; private static final String LEVEL = "company";
private static final String EQUSTATE = "EQU_STATE"; private static final String EQUSTATE = "EQU_STATE";
private static final String USEPLACE = "USE_PLACE"; private static final String USEPLACE = "USE_PLACE";
private static final String REC_DATE = "REC_DATE";
@Autowired @Autowired
ESEquipmentCategory esEquipmentCategory; ESEquipmentCategory esEquipmentCategory;
@Autowired @Autowired
...@@ -2159,13 +2160,20 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2159,13 +2160,20 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
boolMust.must(meBuilder); boolMust.must(meBuilder);
} }
builder.query(boolMust); builder.query(boolMust);
builder.sort("REC_DATE", SortOrder.DESC);
builder.sort("REC_DATE", Optional.ofNullable(map.getString("sort"))
.map(s -> s.split(","))
.filter(sortParams -> "ascend".equals(sortParams[1]))
.map(s -> SortOrder.ASC)
.orElse(SortOrder.DESC));
builder.from((map.getInteger("number") - 1) * map.getInteger("size")); builder.from((map.getInteger("number") - 1) * map.getInteger("size"));
builder.size(map.getInteger("size")); builder.size(map.getInteger("size"));
request.source(builder); request.source(builder);
List<JSONObject> list = new LinkedList<>(); List<JSONObject> list = new LinkedList<>();
long totle = 0; long totle = 0;
try { try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT); SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) { for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit); System.out.println(hit);
...@@ -2176,6 +2184,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2176,6 +2184,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
String status = EquimentEnum.getName.get(integer); String status = EquimentEnum.getName.get(integer);
dto2.put(EQUSTATE, status); dto2.put(EQUSTATE, status);
} }
dto2.put(REC_DATE, dateFormat.format(dto2.get(REC_DATE)));
list.add(dto2); list.add(dto2);
} }
totle = response.getInternalResponse().hits().getTotalHits().value; totle = response.getInternalResponse().hits().getTotalHits().value;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment