Skip to content

Commit

Permalink
test2 sort
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonBottle committed Jun 8, 2023
1 parent cfb5ee1 commit 2ae0629
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@NoArgsConstructor
public class FeederManualFeedSumDTO {

private String minute;
private String minuteInterval;
private BigDecimal sumWater;
private BigDecimal sumFeed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ReactiveCrudService<FeederManualFeedEntity, String> getService() {
@QueryAction
public Flux<FeederManualFeedSumDTO> testGroupBy1(@RequestBody QueryParamEntity query) {
return queryHelper.select(
"SELECT to_char(m.minute_interval, 'YYYY-MM-DD HH24:MI:SS') AS minute_interval,\n" +
"SELECT to_char(m.minute_interval, 'YYYY-MM-DD HH24:MI:SS') AS minute,\n" +
" COALESCE(SUM(f.measure), 0) AS sum_water,\n" +
" COALESCE(SUM(f2.measure), 0) AS sum_feed\n" +
"FROM minutes m\n" +
Expand All @@ -54,7 +54,7 @@ public Flux<FeederManualFeedSumDTO> testGroupBy1(@RequestBody QueryParamEntity q
" ON to_timestamp(f2.date / 1000) AT TIME ZONE 'Asia/Shanghai' >= m.minute_interval\n" +
" AND to_timestamp(f2.date / 1000) AT TIME ZONE 'Asia/Shanghai' < m.minute_interval + '1 minute'::interval\n" +
" AND f2.type = 'feed'\n" +
"GROUP BY minute_interval",
"GROUP BY minute",
FeederManualFeedSumDTO::new)
.where(query)
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,32 @@ void test2() {
List<Date> timeRange = generateTimeRange(startTimeStr, endTimeStr, intervalMinutes);

// 初始化测试数据
timeRange.forEach(time -> {
MinutesEntity entity = new MinutesEntity();
entity.setMinuteInterval(time);
testClient
.post()
.uri("/api/minutes/test")
.contentType(MediaType.APPLICATION_JSON)
.bodyValue(entity)
.exchange()
.expectStatus()
.is2xxSuccessful()
.expectBody();

});
// timeRange.forEach(time -> {
// MinutesEntity entity = new MinutesEntity();
// entity.setMinuteInterval(time);
// testClient
// .post()
// .uri("/api/minutes/test")
// .contentType(MediaType.APPLICATION_JSON)
// .bodyValue(entity)
// .exchange()
// .expectStatus()
// .is2xxSuccessful()
// .expectBody();
//
// });


testClient
.post()
.uri("/api/test2/group-by/_query1")
.contentType(MediaType.APPLICATION_JSON)
.bodyValue("{}")
.bodyValue("{\"sorts\": [\n" +
" {\n" +
" \"name\": \"minute\",\n" +
" \"order\": \"asc\"\n" +
" }\n" +
" ]}")
.exchange()
.expectBody()
.consumeWith(res->{
Expand Down

0 comments on commit 2ae0629

Please sign in to comment.