REM:
1. 修正获取设备信息分页不正确问题
This commit is contained in:
HuangXin 2020-09-16 20:14:05 +08:00
parent ca831439bb
commit f8d3cf876c
8 changed files with 94 additions and 7 deletions

View File

@ -227,7 +227,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
PageHelper.startPage(startPage, pageSize); PageHelper.startPage(startPage, pageSize);
// 获取分页数据 // 获取分页数据
List<DisposeDevice> devList = disposeDeviceMapper.selectAll(); List<DisposeDevice> devList = disposeDeviceMapper.selectPageAll();
if (devList == null) { if (devList == null) {
devList = new ArrayList<>(); devList = new ArrayList<>();
@ -236,7 +236,11 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
// 获取分页信息 // 获取分页信息
PageInfo<DisposeDevice> pageInfo = new PageInfo<>(devList); PageInfo<DisposeDevice> pageInfo = new PageInfo<>(devList);
return new MulReturnType<>(pageInfo, devList); // 返回实际数据
List<Long> idArray = devList.stream().map(DisposeDevice::getId).collect(Collectors.toList());
List<DisposeDevice> rspList = disposeDeviceMapper.selectByIdSet(idArray);
return new MulReturnType<>(pageInfo, rspList);
} }
/** /**

View File

@ -16,6 +16,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* The type Dispose task manager. * The type Dispose task manager.
@ -120,7 +121,6 @@ public class DisposeTaskManagerImpl implements DisposeTaskManager {
Integer pageSize) { Integer pageSize) {
// 设置分页信息 // 设置分页信息
PageHelper.startPage(startPage, pageSize); PageHelper.startPage(startPage, pageSize);
List<DisposeTask> taskList = disposeTaskMapper.selectAll(); List<DisposeTask> taskList = disposeTaskMapper.selectAll();
if (taskList == null) { if (taskList == null) {
@ -129,6 +129,9 @@ public class DisposeTaskManagerImpl implements DisposeTaskManager {
PageInfo<DisposeTask> pageInfo = new PageInfo<>(taskList); PageInfo<DisposeTask> pageInfo = new PageInfo<>(taskList);
return new MulReturnType<>(pageInfo, taskList); List<Long> idArray = taskList.stream().map(DisposeTask::getId).collect(Collectors.toList());
List<DisposeTask> rspList = disposeTaskMapper.selectByIdSet(idArray);
return new MulReturnType<>(pageInfo, rspList);
} }
} }

View File

@ -19,6 +19,21 @@ public interface DisposeDeviceMapper {
*/ */
List<DisposeDevice> selectAll(); List<DisposeDevice> selectAll();
/**
* Select page all list.
*
* @return the list
*/
List<DisposeDevice> selectPageAll();
/**
* Select by id set list.
*
* @param idList the id list
* @return the list
*/
List<DisposeDevice> selectByIdSet(@Param("idList") List<Long> idList);
/** /**
* Add new dispose device int. * Add new dispose device int.
* *

View File

@ -20,6 +20,21 @@ public interface DisposeTaskMapper {
*/ */
List<DisposeTask> selectAll(); List<DisposeTask> selectAll();
/**
* Select page all list.
*
* @return the list
*/
List<DisposeTask> selectPageAll();
/**
* Select by id set list.
*
* @param idList the id list
* @return the list
*/
List<DisposeTask> selectByIdSet(@Param("idList") List<Long> idList);
/** /**
* Gets dispose task by id. * Gets dispose task by id.
* *

View File

@ -28,6 +28,28 @@
</collection> </collection>
</resultMap> </resultMap>
<select id="selectPageAll" resultType="com.dispose.pojo.entity.DisposeDevice">
SELECT *
FROM dispose_device d
</select>
<select id="selectByIdSet" resultMap="dispose_device">
SELECT d.*,
c.id c_id,
c.deviceId deviceId,
c.capacityType capacityType,
c.objectType objectType,
c.ipType ipType,
c.protectIp protectIp,
c.reserveNetflow reserveNetflow
FROM dispose_device d
LEFT JOIN dispose_capacity c ON d.id = c.deviceId
WHERE d.id IN
<foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<select id="selectAll" resultMap="dispose_device"> <select id="selectAll" resultMap="dispose_device">
SELECT d.*, SELECT d.*,
c.id c_id, c.id c_id,

View File

@ -31,6 +31,34 @@
</collection> </collection>
</resultMap> </resultMap>
<select id="selectPageAll" resultType="com.dispose.pojo.entity.DisposeTask">
SELECT *
FROM dispose_task d
</select>
<select id="selectByIdSet" resultMap="dispose_task">
SELECT dt.*,
ti.id t_id,
ti.taskId taskId,
ti.deviceId t_deviceId,
ti.beginTime beginTime,
ti.endTime t_endTime,
ti.taskAttackType taskAttackType,
ti.execAttackTypeIn execAttackTypeIn,
ti.attackTypeStatusIn attackTypeStatusIn,
ti.execAttackTypeOut execAttackTypeOut,
ti.attackTypeStatusOut attackTypeStatusOut,
ti.externId externId,
ti.errRetry errRetry,
ti.status status
FROM dispose_task dt
LEFT JOIN device_task ti on dt.id = ti.taskId
WHERE dt.id IN
<foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<select id="selectAll" resultMap="dispose_task"> <select id="selectAll" resultMap="dispose_task">
SELECT dt.*, SELECT dt.*,
ti.id t_id, ti.id t_id,

View File

@ -57,10 +57,10 @@ public class P2DeviceQuery {
Assert.assertEquals((long)v.getMsgContent().getStatus(), e.getCode()); Assert.assertEquals((long)v.getMsgContent().getStatus(), e.getCode());
Assert.assertEquals((long)v.getMsgContent().getCurPageNumber(), 1); Assert.assertEquals((long)v.getMsgContent().getCurPageNumber(), 1);
//Assert.assertEquals((long)v.getMsgContent().getPageSize(), 10); Assert.assertEquals((long)v.getMsgContent().getPageSize(), 10);
Assert.assertNotNull(v.getMsgContent().getItems()); Assert.assertNotNull(v.getMsgContent().getItems());
//Assert.assertEquals(v.getMsgContent().getItems().size(), 10); Assert.assertEquals(v.getMsgContent().getItems().size(), 10);
Assert.assertNotEquals(v.getMsgContent().getItems().size(), 0); Assert.assertNotEquals(v.getMsgContent().getItems().size(), 0);
v.getMsgContent().getItems().forEach(k -> { v.getMsgContent().getItems().forEach(k -> {

View File

@ -61,7 +61,7 @@ public class P2TaskList {
.build(), .build(),
QATestItem.builder() QATestItem.builder()
.id(BASE_P2_TASK_LIST_ID) .id(BASE_P2_TASK_LIST_ID + 1)
.name("msgContent为空") .name("msgContent为空")
.priority(TestPriority.P2_PRIORITY) .priority(TestPriority.P2_PRIORITY)
.urlPath("/task/taskList") .urlPath("/task/taskList")