diff --git a/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java b/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java index 7cd5b9bb..afcb4201 100644 --- a/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java +++ b/detection/src/main/java/com/njcn/gather/device/controller/PqDevController.java @@ -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> list(@RequestBody @Validated PqDevParam.QueryParam queryParam) { + public HttpResult> list(@RequestBody @Validated PqDevParam.QueryParam queryParam) { String methodDescribe = getMethodDescribe("list"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam); - Page result = pqDevService.listPqDevs(queryParam); + Page 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> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) { + public HttpResult> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) { String methodDescribe = getMethodDescribe("listByPlanId"); LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param); - List result = pqDevService.listByPlanId(param); + List pqDevList = pqDevService.listByPlanId(param); + + List 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); } diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java b/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java index 0142680d..f59f7ab9 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/param/PqDevParam.java @@ -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) diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java index ac35aedc..98a9a007 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java @@ -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; diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/vo/PqDevVO.java b/detection/src/main/java/com/njcn/gather/device/pojo/vo/PqDevVO.java index 08d20a8d..01de6b07 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/vo/PqDevVO.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/vo/PqDevVO.java @@ -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 monitorList; - - private LocalDateTime checkTime; } diff --git a/detection/src/main/java/com/njcn/gather/device/service/IPqDevService.java b/detection/src/main/java/com/njcn/gather/device/service/IPqDevService.java index 8d8ae4b5..5651502e 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/IPqDevService.java +++ b/detection/src/main/java/com/njcn/gather/device/service/IPqDevService.java @@ -26,7 +26,7 @@ public interface IPqDevService extends IService { * @param queryParam 查询参数 * @return 分页数据,包含被检设备列表 */ - Page listPqDevs(PqDevParam.QueryParam queryParam); + Page listPqDevs(PqDevParam.QueryParam queryParam); /** * 新增被检设备信息 @@ -168,21 +168,22 @@ public interface IPqDevService extends IService { /** * 设备归档操作 + * * @param id 设备id * @return 归档成功返回true,否则返回false */ boolean documented(List id); - /** * 正式监测完成,修改中断状态 + * * @param ids * @param valueType * @param code * @return */ - boolean updateResult(List ids,List valueType ,String code); + boolean updateResult(List ids, List valueType, String code); void updatePqDevReportState(String devId, int i); @@ -204,7 +205,7 @@ public interface IPqDevService extends IService { * 导入灿能二楼设备数据 * * @param cnDevExcelList 灿能二楼设备数据列表 - * @param patternId 模式Id + * @param patternId 模式Id */ void importCNDev(List cnDevExcelList, String patternId); } diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java index b59e811f..e68dd5e4 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java @@ -68,9 +68,9 @@ public class PqDevServiceImpl extends ServiceImpl implements @Override - public Page listPqDevs(PqDevParam.QueryParam queryParam) { - Page page = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam)); - page.getRecords().forEach(p -> { + public Page listPqDevs(PqDevParam.QueryParam queryParam) { + Page 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 implements p.setDevKey(DeviceUtil.decoderString(1, p.getDevKey())); } }); - return page; + + Page page2 = new Page<>(); + BeanUtil.copyProperties(page1, page2); + List 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 implements .eq(PqDev::getState, DataStateEnum.ENABLE.getCode()) .orderByAsc(PqDev::getCreateTime) .list(); -// List> result = pqDevList.stream().map(pqDev -> { -// Map 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 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 monitorList = pqMonitorService.listPqMonitorByDevId(id); if (ObjectUtil.isNotEmpty(monitorList)) { pqDevVO.setMonitorList(monitorList); @@ -895,10 +911,10 @@ public class PqDevServiceImpl extends ServiceImpl 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()); }); } diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 10ed5e0b..4feed15d 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -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; diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index 8df1b0ee..a0d2ff72 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -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 devTypeSet = list.stream().map(PqDev::getDevType).collect(Collectors.toSet()); + List devTypes = devTypeService.listByIds(devTypeSet); + //额定电压信息 - Set voltSet = list.stream().map(PqDev::getDevVolt).collect(Collectors.toSet()); + Set voltSet = devTypes.stream().map(DevType::getDevVolt).collect(Collectors.toSet()); //额定电流信息 - Set currSet = list.stream().map(PqDev::getDevCurr).collect(Collectors.toSet()); + Set 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(); diff --git a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java index efad0488..f240dd14 100644 --- a/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/source/service/impl/PqSourceServiceImpl.java @@ -129,7 +129,7 @@ public class PqSourceServiceImpl extends ServiceImpl 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()); diff --git a/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java b/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java index 021279b3..e483cc92 100644 --- a/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java +++ b/detection/src/main/java/com/njcn/gather/type/service/IDevTypeService.java @@ -18,4 +18,8 @@ public interface IDevTypeService extends IService { List listAll(); DevType getByName(String name); + + DevType getById(String id); + + List listByIds(List ids); } diff --git a/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java b/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java index d8bda016..38a3bccd 100644 --- a/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/type/service/impl/DevTypeServiceImpl.java @@ -33,4 +33,14 @@ public class DevTypeServiceImpl extends ServiceImpl 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 listByIds(List ids) { + return this.lambdaQuery().in(DevType::getId, ids).eq(DevType::getState, DataStateEnum.ENABLE.getCode()).list(); + } } diff --git a/entrance/src/main/resources/application.yml b/entrance/src/main/resources/application.yml index 767c8e52..8899d7b8 100644 --- a/entrance/src/main/resources/application.yml +++ b/entrance/src/main/resources/application.yml @@ -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: #指定主键生成策略 diff --git a/system/src/main/java/com/njcn/gather/system/menu/controller/MenuController.java b/system/src/main/java/com/njcn/gather/system/menu/controller/MenuController.java index 80818bd6..cd6c9d3b 100644 --- a/system/src/main/java/com/njcn/gather/system/menu/controller/MenuController.java +++ b/system/src/main/java/com/njcn/gather/system/menu/controller/MenuController.java @@ -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);