被检设备根据设备类型调整

This commit is contained in:
caozehui
2025-02-10 13:34:25 +08:00
parent 776141bea7
commit 2def1546a9
13 changed files with 90 additions and 127 deletions

View File

@@ -3,6 +3,7 @@ package com.njcn.gather.device.controller;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
@@ -14,6 +15,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.device.pojo.enums.PatternEnum;
import com.njcn.gather.device.pojo.param.PqDevParam;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.CNDevExcel;
@@ -21,10 +24,10 @@ import com.njcn.gather.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.pojo.vo.PreDetection;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.device.pojo.enums.PatternEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.type.entity.DevType;
import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.ExcelUtil;
import com.njcn.web.utils.FileUtil;
@@ -60,6 +63,7 @@ public class PqDevController extends BaseController {
private final IPqDevService pqDevService;
private final IDictDataService dictDataService;
private final IDevTypeService devTypeService;
@OperateInfo
@@ -80,10 +84,10 @@ public class PqDevController extends BaseController {
@PostMapping("/list")
@ApiOperation("分页查询被检设备")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<Page<PqDev>> list(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
public HttpResult<Page<PqDevVO>> list(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("list");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
Page<PqDev> result = pqDevService.listPqDevs(queryParam);
Page<PqDevVO> result = pqDevService.listPqDevs(queryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@@ -283,12 +287,22 @@ public class PqDevController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/listByPlanId")
@ApiOperation("根据查询参数查询出所有已绑定的设备")
@ApiOperation("查询出所有已绑定的设备")
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
public HttpResult<List<PqDev>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
public HttpResult<List<PqDevVO>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
String methodDescribe = getMethodDescribe("listByPlanId");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
List<PqDev> result = pqDevService.listByPlanId(param);
List<PqDev> pqDevList = pqDevService.listByPlanId(param);
List<PqDevVO> result = BeanUtil.copyToList(pqDevList, PqDevVO.class);
result.forEach(pqDevVO -> {
DevType devType = devTypeService.getById(pqDevVO.getDevType());
if (ObjectUtil.isNotNull(devType)) {
pqDevVO.setDevChns(devType.getDevChns());
pqDevVO.setDevVolt(devType.getDevVolt());
pqDevVO.setDevCurr(devType.getDevCurr());
}
});
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}

View File

@@ -36,19 +36,6 @@ public class PqDevParam {
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_TYPE_FORMAT_ERROR)
private String devType;
@ApiModelProperty(value = "设备通道数", required = true)
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
@Min(value = 1, message = DevValidMessage.DEV_CHNS_RANGE_ERROR)
private Integer devChns;
@ApiModelProperty(value = "额定电压V", required = true)
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt;
@ApiModelProperty(value = "额定电流A", required = true)
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr;
@ApiModelProperty(value = "设备厂家,字典表", required = true)
//@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
//@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR)

View File

@@ -47,21 +47,6 @@ public class PqDev extends BaseEntity implements Serializable {
*/
private String devType;
/**
* 设备通道数
*/
private Integer devChns;
/**
* 额定电压V
*/
private Double devVolt;
/**
* 额定电流A
*/
private Double devCurr;
/**
* 设备厂家,字典表
*/
@@ -207,8 +192,6 @@ public class PqDev extends BaseEntity implements Serializable {
*/
private Integer factorCheckResult;
private String icdId;
@TableField("Check_Time")
private LocalDateTime checkTime;

View File

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.monitor.pojo.po.PqMonitor;
import lombok.Data;
@@ -17,75 +18,13 @@ import java.util.List;
* @data 2024-12-13
*/
@Data
public class PqDevVO {
private String id;
private String name;
private String pattern;
private String devType;
public class PqDevVO extends PqDev {
private Integer devChns;
private Float devVolt;
private Double devVolt;
private Float devCurr;
private String manufacturer;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate createDate;
private String createId;
private String hardwareVersion;
private String softwareVersion;
private String protocol;
private String ip;
private Integer port;
private Integer encryptionFlag;
private String series;
private String devKey;
private String sampleId;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate arrivedDate;
private String cityName;
private String gdName;
private String subName;
private Integer checkState;
private Integer checkResult;
private Integer reportState;
// private Integer documentState;
private String reportPath;
private String qrCode;
private Integer reCheckNum;
private Double devCurr;
private List<PqMonitor> monitorList;
private LocalDateTime checkTime;
}

View File

@@ -26,7 +26,7 @@ public interface IPqDevService extends IService<PqDev> {
* @param queryParam 查询参数
* @return 分页数据,包含被检设备列表
*/
Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam);
Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam);
/**
* 新增被检设备信息
@@ -168,21 +168,22 @@ public interface IPqDevService extends IService<PqDev> {
/**
* 设备归档操作
*
* @param id 设备id
* @return 归档成功返回true否则返回false
*/
boolean documented(List<String> id);
/**
* 正式监测完成,修改中断状态
*
* @param ids
* @param valueType
* @param code
* @return
*/
boolean updateResult(List<String> ids,List<String> valueType ,String code);
boolean updateResult(List<String> ids, List<String> valueType, String code);
void updatePqDevReportState(String devId, int i);

View File

@@ -68,9 +68,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
Page<PqDev> page = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam));
page.getRecords().forEach(p -> {
public Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam) {
Page<PqDev> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam));
page1.getRecords().forEach(p -> {
if (ObjectUtil.isNotNull(p.getSeries())) {
p.setSeries(DeviceUtil.decoderString(1, p.getSeries()));
}
@@ -78,7 +78,20 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
p.setDevKey(DeviceUtil.decoderString(1, p.getDevKey()));
}
});
return page;
Page<PqDevVO> page2 = new Page<>();
BeanUtil.copyProperties(page1, page2);
List<PqDevVO> voList = BeanUtil.copyToList(page1.getRecords(), PqDevVO.class);
page2.setRecords(voList);
page2.getRecords().forEach(p -> {
DevType devType = devTypeService.getById(p.getDevType());
if (ObjectUtil.isNotNull(devType)) {
p.setDevChns(devType.getDevChns());
p.setDevVolt(devType.getDevVolt());
p.setDevCurr(devType.getDevCurr());
}
});
return page2;
}
@Override
@@ -305,12 +318,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
.orderByAsc(PqDev::getCreateTime)
.list();
// List<Map<String, Object>> result = pqDevList.stream().map(pqDev -> {
// Map<String, Object> map = new HashMap<>();
// map.put("id", pqDev.getId());
// map.put("name", pqDev.getName());
// return map;
// }).collect(Collectors.toList());
return pqDevList;
}
@@ -373,6 +381,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
PqDev pqDev = this.getById(id);
PqDevVO pqDevVO = new PqDevVO();
BeanUtil.copyProperties(pqDev, pqDevVO);
DevType devType = devTypeService.getById(pqDev.getDevType());
if (ObjectUtil.isNotNull(devType)) {
pqDevVO.setDevChns(devType.getDevChns());
pqDevVO.setDevVolt(devType.getDevVolt());
pqDevVO.setDevCurr(devType.getDevCurr());
}
List<PqMonitor> monitorList = pqMonitorService.listPqMonitorByDevId(id);
if (ObjectUtil.isNotEmpty(monitorList)) {
pqDevVO.setMonitorList(monitorList);
@@ -895,10 +911,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
DevType devType = devTypeService.getByName(pqDev.getDevType());
pqDev.setDevType(devType.getId());
pqDev.setIcdId(devType.getIcd());
pqDev.setDevVolt(devType.getDevVolt());
pqDev.setDevCurr(devType.getDevCurr());
pqDev.setDevChns(devType.getDevChns());
// pqDev.setIcdId(devType.getIcd());
// pqDev.setDevVolt(devType.getDevVolt());
// pqDev.setDevCurr(devType.getDevCurr());
// pqDev.setDevChns(devType.getDevChns());
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
});
}

View File

@@ -15,6 +15,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.device.pojo.enums.*;
import com.njcn.gather.device.pojo.param.PqDevParam;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.err.service.IPqErrSysService;
import com.njcn.gather.plan.mapper.AdPlanMapper;

View File

@@ -22,6 +22,8 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.script.service.IPqScriptDtlsService;
import com.njcn.gather.script.util.ScriptDtlsDesc;
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.type.entity.DevType;
import com.njcn.gather.type.service.IDevTypeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@@ -69,6 +71,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
private final IPqDevService pqDevService;
private final PqScriptMapper pqScriptMapper;
private final IPqScriptCheckDataService pqScriptCheckDataService;
private final IDevTypeService devTypeService;
@Override
@Transactional(rollbackFor = {Exception.class})
@@ -117,10 +120,14 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
.in(PqDev::getId, param.getDevIds())
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
);
Set<String> devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet());
List<DevType> devTypes = devTypeService.listByIds(devTypeSet);
//额定电压信息
Set<Double> voltSet = list.stream().map(PqDev::getDevVolt).collect(Collectors.toSet());
Set<Double> voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet());
//额定电流信息
Set<Double> currSet = list.stream().map(PqDev::getDevCurr).collect(Collectors.toSet());
Set<Double> currSet = devTypes.stream().map(DevType::getDevCurr).collect(Collectors.toSet());
if (voltSet.size() == 1 && currSet.size() == 1) {
Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
Double curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();

View File

@@ -129,7 +129,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
.sorted(Comparator.comparingInt(SourceInitialize.Initialize::getSort))
.collect(Collectors.toList());
if(CollUtil.isNotEmpty(sourceParams)){
SourceInitialize initialize=new SourceInitialize();
SourceInitialize initialize = new SourceInitialize();
SourceInitialize.Initialize source = sourceParams.get(0);
initialize.setSourceId(source.getValue());
initialize.setSourceType(source.getType());

View File

@@ -18,4 +18,8 @@ public interface IDevTypeService extends IService<DevType> {
List<DevType> listAll();
DevType getByName(String name);
DevType getById(String id);
List<DevType> listByIds(List<String> ids);
}

View File

@@ -33,4 +33,14 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
public DevType getByName(String name) {
return this.lambdaQuery().eq(DevType::getName, name).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).one();
}
@Override
public DevType getById(String id) {
return this.lambdaQuery().eq(DevType::getId, id).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).one();
}
@Override
public List<DevType> listByIds(List<String> ids) {
return this.lambdaQuery().in(DevType::getId, ids).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).list();
}
}

View File

@@ -6,7 +6,7 @@ spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
username: root
password: njcnpqs
#初始化建立物理连接的个数、最小、最大连接数
@@ -33,9 +33,9 @@ mybatis-plus:
#驼峰命名
map-underscore-to-camel-case: true
#配置sql日志输出
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#关闭日志输出
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config:
db-config:
#指定主键生成策略

View File

@@ -43,7 +43,8 @@ public class MenuController {
MenuVO menuVO12 = getMenuVO("/machine/device","device","/machine/device/index","Cpu","被检设备");
MenuVO menuVO13 = getMenuVO("/machine/errorSystem","errorSystem","/machine/errorSystem/index","Tickets","误差体系");
MenuVO menuVO14 = getMenuVO("/machine/testSource","testSource","/machine/testSource/index","Help","检测源");
menuVO1.setChildren(CollectionUtil.toList(menuVO11,menuVO12,menuVO13,menuVO14));
MenuVO menuVO15 = getMenuVO("/machine/devType","devType","/machine/devType/index","Cpu","设备类型");
menuVO1.setChildren(CollectionUtil.toList(menuVO11,menuVO12,menuVO13,menuVO14,menuVO15));
menuVOList.add(menuVO1);