From 4e87f5f570a84621734035217f08882f52809c48 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期二, 06 五月 2025 18:32:35 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/UPExgMsgTakeEwayBillAckController.java | 38 +++++++++++++++++++++++++++++++++----- 1 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/UPExgMsgTakeEwayBillAckController.java b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/UPExgMsgTakeEwayBillAckController.java index 60a22e3..69c2a9d 100644 --- a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/UPExgMsgTakeEwayBillAckController.java +++ b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/controller/UPExgMsgTakeEwayBillAckController.java @@ -5,12 +5,28 @@ import com.ruoyi.dataInterchange.api.vo.UPExgMsgTakeEwayBillAckVo; import com.ruoyi.dataInterchange.dao.UPExgMsgTakeEwayBillAckDao; import com.ruoyi.dataInterchange.model.UPExgMsgTakeEwayBillAck; +import org.elasticsearch.index.query.MatchAllQueryBuilder; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.search.sort.FieldSortBuilder; +import org.elasticsearch.search.sort.SortBuilders; +import org.elasticsearch.search.sort.SortOrder; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.data.elasticsearch.client.elc.QueryBuilders; +import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; +import org.springframework.data.elasticsearch.core.SearchHit; +import org.springframework.data.elasticsearch.core.SearchHits; +import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; +import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.naming.directory.SearchResult; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -25,6 +41,9 @@ @Resource private UPExgMsgTakeEwayBillAckDao upExgMsgTakeEwayBillAckDao; + + @Resource + private ElasticsearchRestTemplate elasticsearchRestTemplate; /** @@ -36,8 +55,16 @@ @PostMapping("/findByCreateTimeAfter") public R<List<UPExgMsgTakeEwayBillAckVo>> findByCreateTimeAfter(@RequestParam("createTime") Long createTime) { List<UPExgMsgTakeEwayBillAckVo> list = new ArrayList<>(); - if (-1 == createTime) { - Iterator<UPExgMsgTakeEwayBillAck> iterator = upExgMsgTakeEwayBillAckDao.findAll().iterator(); + if (-1 == createTime) { + //设置排序(排序方式,正序还是倒序,排序的 id) + Sort sort = Sort.by(Sort.Direction.ASC, "createTime"); + //设置分页(页码,每页显示的条数) + //当前页码0开始 + int currentPage = 0; + //每页显示的条数 + int pageSize = 10000; + PageRequest pageRequest = PageRequest.of(currentPage, pageSize, sort); + Iterator<UPExgMsgTakeEwayBillAck> iterator = upExgMsgTakeEwayBillAckDao.findAll(pageRequest).iterator(); if (iterator.hasNext()) { UPExgMsgTakeEwayBillAck takeEwayBillAck = iterator.next(); UPExgMsgTakeEwayBillAckVo vo = new UPExgMsgTakeEwayBillAckVo(); @@ -45,10 +72,11 @@ list.add(vo); } } else { - List<UPExgMsgTakeEwayBillAck> takeEwayBillAcks = upExgMsgTakeEwayBillAckDao.findByCreateTimeAfter(createTime); - for (UPExgMsgTakeEwayBillAck takeEwayBillAck : takeEwayBillAcks) { + //查询,获取查询结果 + List<UPExgMsgTakeEwayBillAck> byCreateTimeIsAfter = upExgMsgTakeEwayBillAckDao.findByCreateTimeIsAfter(createTime); + for (UPExgMsgTakeEwayBillAck searchHit : byCreateTimeIsAfter) { UPExgMsgTakeEwayBillAckVo vo = new UPExgMsgTakeEwayBillAckVo(); - BeanUtils.copyProperties(takeEwayBillAck, vo); + BeanUtils.copyProperties(searchHit, vo); list.add(vo); } } -- Gitblit v1.7.1