1. 增加查询传感器执行执行任务分页查询功能
This commit is contained in:
parent
f53ce601f8
commit
ed4e79bf76
|
@ -29,6 +29,13 @@ mybatis.mapper-locations=classpath*:mappers/*.xml
|
|||
mybatis.type-aliases-package=com.zjyr.beidouservice.pojo.entry
|
||||
mybatis.configuration.default-enum-type-handler=com.zjyr.beidouservice.common.CommonEnumHandler
|
||||
#mybatis.configuration.log-impl=lombok.extern.slf4j.Slf4j
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=true
|
||||
pagehelper.support-methods-arguments=true
|
||||
pagehelper.pageSizeZero=true
|
||||
pagehelper.params.count=countSql
|
||||
#config log
|
||||
logging.config=file:config/logback.xml
|
||||
log4j.logger.org.mybatis=debug
|
4
pom.xml
4
pom.xml
|
@ -108,8 +108,8 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>5.3.3</version>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package com.zjyr.beidouservice.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zjyr.beidouservice.pojo.entry.SensorTask;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorTaskAck;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SensorTaskService {
|
||||
void addSensorTaskResponse(Long controlId, SensorTaskAck sensorTaskAck);
|
||||
|
||||
int getRespSensors(int taskId);
|
||||
|
||||
int getRespSuccessedSensors(int taskId);
|
||||
|
||||
PageInfo<SensorTask> querySensorTaskData(int page, int nItems);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.zjyr.beidouservice.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zjyr.beidouservice.mapper.SensorTaskMapper;
|
||||
import com.zjyr.beidouservice.pojo.entry.SensorTask;
|
||||
import com.zjyr.beidouservice.pojo.vo.binary.SensorTaskAck;
|
||||
|
@ -48,4 +50,13 @@ public class SensorTaskServiceImpl implements SensorTaskService {
|
|||
public int getRespSuccessedSensors(int taskId) {
|
||||
return sensorTaskMapper.countTaskResponseSuccessedSensor(taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<SensorTask> querySensorTaskData(int page, int nItems) {
|
||||
PageHelper.startPage(page, nItems);
|
||||
List<SensorTask> sensorTasks = sensorTaskMapper.selectAll();
|
||||
PageInfo<SensorTask> pgInfo = new PageInfo<>(sensorTasks);
|
||||
PageHelper.clearPage();
|
||||
return pgInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,7 @@
|
|||
</resultMap>
|
||||
|
||||
<select id="selectAll" resultMap="sensor_task">
|
||||
SELECT id,
|
||||
taskId,
|
||||
sensorId,
|
||||
deviceId,
|
||||
taskResult,
|
||||
reportTime
|
||||
SELECT *
|
||||
FROM sensor_task
|
||||
</select>
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.zjyr.beidouservice.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zjyr.beidouservice.pojo.entry.ControlDevice;
|
||||
import com.zjyr.beidouservice.pojo.entry.SensorTask;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@Slf4j
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
@Transactional
|
||||
@Rollback
|
||||
public class SensorTaskServiceTest {
|
||||
@Resource
|
||||
SensorTaskService sensorTaskService;
|
||||
|
||||
@Test
|
||||
public void a1_querySensorTaskData() {
|
||||
PageInfo<SensorTask> info = sensorTaskService.querySensorTaskData(3, 3);
|
||||
log.info("Total: {}", info.getList().size());
|
||||
|
||||
for(var c : info.getList()) {
|
||||
log.info("Item ID: {}", c.getId());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue