检测计划统计弹窗下拉框内容调整
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
package com.njcn.gather.plan.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PlanStatisticsOptionVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
@@ -90,4 +90,14 @@ public class PlanStatisticsVO {
|
|||||||
* 检测项分布。
|
* 检测项分布。
|
||||||
*/
|
*/
|
||||||
private List<PlanStatisticsItemVO> itemDistributions;
|
private List<PlanStatisticsItemVO> itemDistributions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备厂家筛选项。
|
||||||
|
*/
|
||||||
|
private List<PlanStatisticsOptionVO> manufacturerOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备类型筛选项。
|
||||||
|
*/
|
||||||
|
private List<PlanStatisticsOptionVO> devTypeOptions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -827,13 +827,16 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
throw new BusinessException(DetectionResponseEnum.PLAN_NOT_EXIST);
|
throw new BusinessException(DetectionResponseEnum.PLAN_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PqDevVO> planDevices = listPlanDevices(plan.getId(), param.getManufacturer(), param.getDevType());
|
List<PqDevVO> allPlanDevices = listPlanDevices(plan.getId(), null, null);
|
||||||
|
List<PqDevVO> planDevices = filterPlanDevices(allPlanDevices, param.getManufacturer(), param.getDevType());
|
||||||
List<PqDevVO> checkedDevices = planDevices.stream()
|
List<PqDevVO> checkedDevices = planDevices.stream()
|
||||||
.filter(this::isCheckedDevice)
|
.filter(this::isCheckedDevice)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
||||||
statistics.setPlanId(plan.getId());
|
statistics.setPlanId(plan.getId());
|
||||||
statistics.setPlanName(plan.getName());
|
statistics.setPlanName(plan.getName());
|
||||||
|
statistics.setManufacturerOptions(buildManufacturerOptions(allPlanDevices, param.getDevType()));
|
||||||
|
statistics.setDevTypeOptions(buildDevTypeOptions(allPlanDevices, param.getManufacturer()));
|
||||||
statistics.setUncheckedDeviceCount(planDevices.size() - checkedDevices.size());
|
statistics.setUncheckedDeviceCount(planDevices.size() - checkedDevices.size());
|
||||||
statistics.setCheckedDeviceCount(checkedDevices.size());
|
statistics.setCheckedDeviceCount(checkedDevices.size());
|
||||||
statistics.setTotalCheckCount(checkedDevices.stream().mapToInt(dev -> defaultZero(dev.getRecheckNum())).sum());
|
statistics.setTotalCheckCount(checkedDevices.stream().mapToInt(dev -> defaultZero(dev.getRecheckNum())).sum());
|
||||||
@@ -880,12 +883,57 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
if (CollUtil.isEmpty(pqDevVOList)) {
|
if (CollUtil.isEmpty(pqDevVOList)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return pqDevVOList.stream()
|
return filterPlanDevices(pqDevVOList, manufacturer, devType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<PqDevVO> filterPlanDevices(List<PqDevVO> devices, String manufacturer, String devType) {
|
||||||
|
if (CollUtil.isEmpty(devices)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return devices.stream()
|
||||||
.filter(dev -> StrUtil.isBlank(manufacturer) || Objects.equals(dev.getManufacturer(), manufacturer))
|
.filter(dev -> StrUtil.isBlank(manufacturer) || Objects.equals(dev.getManufacturer(), manufacturer))
|
||||||
.filter(dev -> StrUtil.isBlank(devType) || Objects.equals(dev.getDevType(), devType))
|
.filter(dev -> StrUtil.isBlank(devType) || Objects.equals(dev.getDevType(), devType))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<PlanStatisticsOptionVO> buildManufacturerOptions(List<PqDevVO> devices, String devType) {
|
||||||
|
if (CollUtil.isEmpty(devices)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<String> ids = devices.stream()
|
||||||
|
.filter(dev -> StrUtil.isBlank(devType) || Objects.equals(dev.getDevType(), devType))
|
||||||
|
.map(PqDevVO::getManufacturer)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Map<String, String> nameMap = ids.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: dictDataService.listByIds(ids).stream()
|
||||||
|
.collect(Collectors.toMap(DictData::getId, DictData::getName, (left, right) -> left));
|
||||||
|
return ids.stream()
|
||||||
|
.map(id -> new PlanStatisticsOptionVO(id, nameMap.getOrDefault(id, id)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<PlanStatisticsOptionVO> buildDevTypeOptions(List<PqDevVO> devices, String manufacturer) {
|
||||||
|
if (CollUtil.isEmpty(devices)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<String> ids = devices.stream()
|
||||||
|
.filter(dev -> StrUtil.isBlank(manufacturer) || Objects.equals(dev.getManufacturer(), manufacturer))
|
||||||
|
.map(PqDevVO::getDevType)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Map<String, String> nameMap = ids.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: devTypeService.listByIds(ids).stream()
|
||||||
|
.collect(Collectors.toMap(DevType::getId, DevType::getName, (left, right) -> left));
|
||||||
|
return ids.stream()
|
||||||
|
.map(id -> new PlanStatisticsOptionVO(id, nameMap.getOrDefault(id, id)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isCheckedDevice(PqDevVO dev) {
|
private boolean isCheckedDevice(PqDevVO dev) {
|
||||||
return (Objects.equals(dev.getCheckState(), CheckStateEnum.CHECKED.getValue())
|
return (Objects.equals(dev.getCheckState(), CheckStateEnum.CHECKED.getValue())
|
||||||
|| Objects.equals(dev.getCheckState(), CheckStateEnum.DOCUMENTED.getValue()))
|
|| Objects.equals(dev.getCheckState(), CheckStateEnum.DOCUMENTED.getValue()))
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.njcn.gather.plan.pojo.vo;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class PlanStatisticsVOTest {
|
public class PlanStatisticsVOTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -13,4 +15,19 @@ public class PlanStatisticsVOTest {
|
|||||||
|
|
||||||
Assert.assertEquals(Integer.valueOf(6), statistics.getQualifiedDeviceCount());
|
Assert.assertEquals(Integer.valueOf(6), statistics.getQualifiedDeviceCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldExposeLinkedFilterOptions() {
|
||||||
|
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
||||||
|
PlanStatisticsOptionVO manufacturer = new PlanStatisticsOptionVO("manufacturer-1", "厂家A");
|
||||||
|
PlanStatisticsOptionVO devType = new PlanStatisticsOptionVO("dev-type-1", "PQS-882A");
|
||||||
|
|
||||||
|
statistics.setManufacturerOptions(Collections.singletonList(manufacturer));
|
||||||
|
statistics.setDevTypeOptions(Collections.singletonList(devType));
|
||||||
|
|
||||||
|
Assert.assertEquals("manufacturer-1", statistics.getManufacturerOptions().get(0).getId());
|
||||||
|
Assert.assertEquals("厂家A", statistics.getManufacturerOptions().get(0).getName());
|
||||||
|
Assert.assertEquals("dev-type-1", statistics.getDevTypeOptions().get(0).getId());
|
||||||
|
Assert.assertEquals("PQS-882A", statistics.getDevTypeOptions().get(0).getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ socket:
|
|||||||
# port: 61000
|
# port: 61000
|
||||||
|
|
||||||
webSocket:
|
webSocket:
|
||||||
port: 7778
|
port: 7777
|
||||||
|
|
||||||
#源参数下发,暂态数据默认值
|
#源参数下发,暂态数据默认值
|
||||||
Dip:
|
Dip:
|
||||||
|
|||||||
Reference in New Issue
Block a user