diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/WlRecordPageParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/WlRecordPageParam.java index 616154a..468d60f 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/WlRecordPageParam.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/WlRecordPageParam.java @@ -4,6 +4,8 @@ import com.njcn.web.pojo.param.BaseParam; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotNull; +import java.util.ArrayList; import java.util.List; @Data @@ -22,6 +24,18 @@ public class WlRecordPageParam extends BaseParam { @ApiModelProperty(value="是否匹配测试项ID") private Integer isTrueFlag; + /** + * 添加设备时左侧的设备或测点ID + */ + @ApiModelProperty(value="添加设备时左侧的设备或测点ID") + private List treeIds = new ArrayList<>(); + + /** + * 添加测试项的时候顺便添加基础数据列表要排除临时已经添加的基础设备数据 + */ + @ApiModelProperty(value="添加测试项的时候顺便添加基础数据列表要排除临时已经添加的基础设备数据") + private List isBandIds = new ArrayList<>(); + /** * 关键字多个匹配 */ diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/WlRecordParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/WlRecordParam.java index 0cdfc03..79d6cca 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/WlRecordParam.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/WlRecordParam.java @@ -40,6 +40,12 @@ public class WlRecordParam { @ApiModelProperty("CT变比") private Integer ct; + @ApiModelProperty("PT变比") + private Integer pt1; + + @ApiModelProperty("CT变比") + private Integer ct1; + @ApiModelProperty("电压等级") private String voltageLevel; @@ -74,6 +80,9 @@ public class WlRecordParam { public static class AddRecord extends WlRecordParam { @ApiModelProperty("records") private List records; + + @ApiModelProperty("方案id") + private String id; } } diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/WlRecord.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/WlRecord.java index 257d306..8d12582 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/WlRecord.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/WlRecord.java @@ -68,6 +68,16 @@ public class WlRecord extends BaseEntity { */ private Integer ct; + /** + * PT变比 + */ + private Integer pt1; + + /** + * CT变比 + */ + private Integer ct1; + /** * 电压等级 */ diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordAllDevTreeVo.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordAllDevTreeVo.java new file mode 100644 index 0000000..91dce0c --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordAllDevTreeVo.java @@ -0,0 +1,36 @@ +package com.njcn.csdevice.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.List; + +/** + * 类的介绍:方案树、测试项树、基础数据树 + * + * @author xuyang + * @version 1.0.0 + * @createTime 2024/4/2 10:23 + */ +@Data +public class RecordAllDevTreeVo { + + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("设备名称") + private String name; + + @ApiModelProperty("线路") + private List children; + + @Data + public static class RecordAllLineTreeVo { + + @ApiModelProperty("线路ID") + private String id; + + @ApiModelProperty("线路名称") + private String name; + + } +} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordPageVo.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordPageVo.java index 53212d6..8ed4a45 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordPageVo.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordPageVo.java @@ -18,6 +18,9 @@ public class RecordPageVo { @ApiModelProperty("基础数据id") private String id; + @ApiModelProperty("数据名称") + private String itemName; + @ApiModelProperty("设备名称") private String devName; diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordTreeVo.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordTreeVo.java index cc481f8..cf57d56 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordTreeVo.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordTreeVo.java @@ -2,7 +2,6 @@ package com.njcn.csdevice.pojo.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import lombok.EqualsAndHashCode; import java.util.List; /** @@ -15,18 +14,26 @@ import java.util.List; @Data public class RecordTreeVo { - @ApiModelProperty("方案id") + @ApiModelProperty("id") private String id; - @ApiModelProperty("方案名称") + @ApiModelProperty("名称") private String name; @ApiModelProperty("测试项数据") private List children; @Data - @EqualsAndHashCode(callSuper = true) - public static class Children extends RecordTreeVo { + public static class Children{ + + @ApiModelProperty("id") + private String id; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("父级ID") + private String pId; @ApiModelProperty("测试项开始时间") private String startTime; diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordVo.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordVo.java index 5804709..4c02356 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordVo.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/RecordVo.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; +import java.util.List; /** * 类的介绍: 测试项详情表 @@ -15,10 +16,10 @@ import java.time.LocalDateTime; @Data public class RecordVo { - @ApiModelProperty("测试项id") + @ApiModelProperty("id") private String id; - @ApiModelProperty("测试项名称") + @ApiModelProperty("名称") private String itemName; @ApiModelProperty("数据起始时间") @@ -41,6 +42,12 @@ public class RecordVo { @ApiModelProperty("CT变比") private Integer ct; + @ApiModelProperty("PT变比") + private Integer pt1; + + @ApiModelProperty("CT变比") + private Integer ct1; + @ApiModelProperty("电压等级") private String voltageLevel; @@ -59,4 +66,16 @@ public class RecordVo { @ApiModelProperty("电压接线方式") private String volConType; + @Data + public static class RecordItemVo{ + + @ApiModelProperty("方案名称") + private String itemName; + + @ApiModelProperty("描述") + private String describe; + + @ApiModelProperty("测试项") + private List records; + } } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java index 5d07027..a9ef439 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java @@ -22,6 +22,7 @@ import com.njcn.csdevice.service.IMqttUserService; import com.njcn.csdevice.utils.ExcelStyleUtil; import com.njcn.poi.excel.ExcelUtil; import com.njcn.poi.util.PoiUtil; +import com.njcn.system.api.DicDataFeignClient; import com.njcn.web.advice.DeviceLog; import com.njcn.web.controller.BaseController; import io.swagger.annotations.*; @@ -161,6 +162,12 @@ public class EquipmentDeliveryController extends BaseController { public HttpResult> list(@RequestBody CsEquipmentDeliveryQueryParm param){ String methodDescribe = getMethodDescribe("list"); Page page = csEquipmentDeliveryService.list(param); + //新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入) + for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){ + if("8b45cf6b7f5266e777d07c166ad5fa77".equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){ + csEquipmentDeliveryVO.setStatus(5); + } + } return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/scheme/WlRecordController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/scheme/WlRecordController.java index 4a4d4a2..04697c3 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/scheme/WlRecordController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/scheme/WlRecordController.java @@ -1,6 +1,5 @@ package com.njcn.csdevice.controller.scheme; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.enums.common.LogEnum; @@ -10,11 +9,11 @@ import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.LogUtil; import com.njcn.csdevice.param.WlRecordPageParam; import com.njcn.csdevice.pojo.param.WlRecordParam; -import com.njcn.csdevice.pojo.po.WlRecord; -import com.njcn.csdevice.pojo.vo.RecordPageVo; import com.njcn.csdevice.pojo.vo.RecordTreeVo; import com.njcn.csdevice.pojo.vo.RecordVo; import com.njcn.csdevice.service.IWlRecordService; +import com.njcn.csharmonic.param.CommonStatisticalQueryParam; +import com.njcn.csharmonic.pojo.vo.ThdDataVO; import com.njcn.web.controller.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -24,7 +23,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Map; /** *

@@ -45,7 +43,7 @@ public class WlRecordController extends BaseController { private final IWlRecordService wlRecordService; /** - * 两层树方案+测试项* + * 两层树方案+测试项 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY) @GetMapping("/schemeTree") @@ -58,25 +56,25 @@ public class WlRecordController extends BaseController { } /** - * 根据测试项ID查询测试项信息* + * 根据测试项ID查询测试项信息 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY) @GetMapping("/getTestRecordById") @ApiOperation("根据测试项ID查询测试项信息") @ApiImplicitParam(name = "testRecordId", value = "测试项ID", required = true) - public HttpResult getTestRecordById(@RequestParam @Validated String testRecordId) { + public HttpResult getTestRecordById(@RequestParam @Validated String testRecordId) { String methodDescribe = getMethodDescribe("getTestRecordById"); LogUtil.njcnDebug(log, "{},测试项id为:{}", methodDescribe, testRecordId); - RecordVo result = wlRecordService.getTestRecordById(testRecordId); + RecordVo.RecordItemVo result = wlRecordService.getTestRecordById(testRecordId); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } /** - * 新增方案或新增测试项* + * 新增测试项 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD) @PostMapping("/addRecord") - @ApiOperation("新增方案或新增测试项") + @ApiOperation("新增测试项") @ApiImplicitParam(name = "records", value = "测试项集合", required = true) public HttpResult addRecord(@RequestBody @Validated WlRecordParam.AddRecord records) { String methodDescribe = getMethodDescribe("addRecord"); @@ -86,7 +84,7 @@ public class WlRecordController extends BaseController { } /** - * 修改测试项* + * 修改测试项 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE) @PostMapping("/updateTestRecord") @@ -100,15 +98,29 @@ public class WlRecordController extends BaseController { } /** - * 查询测试项下绑定的设备列表* + * 新增或修改方案 + */ + @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE) + @PostMapping("/updateSchemeRecord") + @ApiOperation("新增或修改方案") + @ApiImplicitParam(name = "record", value = "方案对象", required = true) + public HttpResult updateSchemeRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record) { + String methodDescribe = getMethodDescribe("updateSchemeRecord"); + LogUtil.njcnDebug(log, "{},新增或修改方案对象为:{}", methodDescribe, record); + wlRecordService.updateSchemeRecord(record); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + /** + * 设备列表 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY) @PostMapping("/queryPage") - @ApiOperation("查询测试项下绑定的设备列表") - public HttpResult> queryPage(@Validated @RequestBody WlRecordPageParam wlRecordPageParam) { + @ApiOperation("设备列表") + public HttpResult queryPage(@Validated @RequestBody WlRecordPageParam wlRecordPageParam) { String methodDescribe = getMethodDescribe("queryPage"); LogUtil.njcnDebug(log, "{}", methodDescribe); - Page result = wlRecordService.queryPage(wlRecordPageParam); + Object result = wlRecordService.queryPage(wlRecordPageParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } @@ -127,24 +139,12 @@ public class WlRecordController extends BaseController { } /** - * 修改方案名称 - */ - @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE) - @PostMapping("/updateSchemeRecordName") - @ApiOperation("修改方案名称") - public HttpResult> updateSchemeRecordName(@RequestBody @Validated WlRecordParam.UpdateRecord record) { - String methodDescribe = getMethodDescribe("updateSchemeRecordName"); - wlRecordService.updateSchemeRecordName(record); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); - } - - /** - * 删除测试项中的设备基础数据* + * 删除测试项中的设备基础数据 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE) @DeleteMapping("/deleteDataRecord") @ApiOperation("删除测试项中的设备基础数据") - public HttpResult deleteDataRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record) { + public HttpResult deleteDataRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record) { String methodDescribe = getMethodDescribe("deleteDataRecord"); LogUtil.njcnDebug(log, "{},测试项及基础数据ID为:{}", methodDescribe, record); wlRecordService.deleteDataRecord(record); @@ -152,27 +152,28 @@ public class WlRecordController extends BaseController { } /** - * 添加测试项中的设备基础数据* + * 添加测试项中的设备基础数据 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD) @PostMapping("/saveDataRecord") @ApiOperation("添加测试项中的设备基础数据") - public HttpResult saveDataRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record) { + public HttpResult saveDataRecord(@RequestBody @Validated WlRecordParam.UpdateRecord record) { String methodDescribe = getMethodDescribe("saveDataRecord"); - LogUtil.njcnDebug(log, "{},测试项及基础数据ID为:{}", methodDescribe, record); + LogUtil.njcnDebug(log, "{},测试项及基础数据对象为:{}", methodDescribe, record); wlRecordService.saveDataRecord(record); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } /** - * 方案下拉框* + * 查询测试项时间段实时数据 */ @OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY) - @GetMapping("/schemeRecordDown") - @ApiOperation("方案下拉框") - public HttpResult> schemeRecordDown() { - String methodDescribe = getMethodDescribe("schemeRecordDown"); - List result = wlRecordService.schemeRecordDown(); + @PostMapping("/queryCommonStatisticalByTest") + @ApiOperation("查询测试项时间段实时数据") + public HttpResult> queryCommonStatisticalByTest(@RequestBody @Validated CommonStatisticalQueryParam commonStatisticalQueryParam) { + String methodDescribe = getMethodDescribe("queryCommonStatisticalByTest"); + LogUtil.njcnDebug(log, "{},查询对象为:{}", methodDescribe, commonStatisticalQueryParam); + List result = wlRecordService.queryCommonStatisticalByTest(commonStatisticalQueryParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/WlRecordMapper.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/WlRecordMapper.java index 7a3c91f..f1f6c15 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/WlRecordMapper.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/WlRecordMapper.java @@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.csdevice.param.WlRecordPageParam; import com.njcn.csdevice.pojo.po.WlRecord; +import com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo; import com.njcn.csdevice.pojo.vo.RecordPageVo; import org.apache.ibatis.annotations.Param; import java.util.List; -import java.util.Map; /** *

@@ -40,8 +40,13 @@ public interface WlRecordMapper extends BaseMapper { List getDataRecordBytestId(@Param("testRecordId") String testRecordId); /** - * 方案下拉框 + * 组装测试项表的tree */ - List schemeRecordDown(); + List getRecordAll(); + List getRecordAllLine(@Param("devId") String devId); + /** + * 根据测试项ID或方案ID获取其下关联的所有设备基础数据信息 + */ + List getDataRecordByTestId(@Param("testRecordId") String testRecordId,@Param("flag") Integer flag); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/WlRecordMapper.xml b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/WlRecordMapper.xml index 7115534..c9588fd 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/WlRecordMapper.xml +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/WlRecordMapper.xml @@ -5,6 +5,7 @@ @@ -47,7 +77,30 @@ select data_id from wl_record_test_data where test_item_id = #{testRecordId}; - + select a.dev_id as id,b.name as name from wl_record a + left join cs_equipment_delivery b on a.dev_id = b.id + where a.type=1 and a.state =1 + group by a.dev_id,b.name having a.dev_id is not null and b.name is not null + + + + + \ No newline at end of file diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IWlRecordService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IWlRecordService.java index ec9cf4e..c3337f9 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IWlRecordService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IWlRecordService.java @@ -1,15 +1,14 @@ package com.njcn.csdevice.service; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.csdevice.param.WlRecordPageParam; import com.njcn.csdevice.pojo.param.WlRecordParam; import com.njcn.csdevice.pojo.po.WlRecord; -import com.njcn.csdevice.pojo.vo.RecordPageVo; import com.njcn.csdevice.pojo.vo.RecordTreeVo; import com.njcn.csdevice.pojo.vo.RecordVo; +import com.njcn.csharmonic.param.CommonStatisticalQueryParam; +import com.njcn.csharmonic.pojo.vo.ThdDataVO; import java.util.List; -import java.util.Map; /** *

@@ -33,10 +32,10 @@ public interface IWlRecordService extends IService { * @param testRecordId * @return */ - RecordVo getTestRecordById(String testRecordId); + RecordVo.RecordItemVo getTestRecordById(String testRecordId); /** - * 新增方案或新增测试项 + * 新增测试项 * @param records * @return */ @@ -49,13 +48,19 @@ public interface IWlRecordService extends IService { */ void updateTestRecord(WlRecordParam.UpdateRecord record); + /** + * 新增或修改方案 + * @param record + * @return + */ + void updateSchemeRecord(WlRecordParam.UpdateRecord record); /** - * 查询测试项下绑定的设备列表 + * 设备列表 * @param * @return */ - Page queryPage(WlRecordPageParam wlRecordPageParam); + Object queryPage(WlRecordPageParam wlRecordPageParam); /** * 删除测试项或方案 @@ -64,13 +69,6 @@ public interface IWlRecordService extends IService { */ void deleteRecord(String id); - /** - * 修改方案名称 - * @param - * @return - */ - void updateSchemeRecordName(WlRecordParam.UpdateRecord record); - /** * 删除测试项中的设备基础数据 * @return @@ -84,10 +82,9 @@ public interface IWlRecordService extends IService { void saveDataRecord(WlRecordParam.UpdateRecord record); /** - * 方案下拉框 + * 查询测试项时间段实时数据 * @return */ - List schemeRecordDown(); - + List queryCommonStatisticalByTest(CommonStatisticalQueryParam commonStatisticalQueryParam); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java index 7c84c7d..67d8e5a 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/WlRecordServiceImpl.java @@ -8,23 +8,43 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.csdevice.api.CsLineFeignClient; +import com.njcn.csdevice.api.EquipmentFeignClient; +import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.mapper.WlRecordMapper; import com.njcn.csdevice.param.WlRecordPageParam; +import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.param.WlRecordParam; +import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.WlRecord; +import com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo; import com.njcn.csdevice.pojo.vo.RecordPageVo; import com.njcn.csdevice.pojo.vo.RecordTreeVo; import com.njcn.csdevice.pojo.vo.RecordVo; import com.njcn.csdevice.service.IWlRecordService; +import com.njcn.csharmonic.param.CommonStatisticalQueryParam; +import com.njcn.csharmonic.pojo.vo.ThdDataVO; +import com.njcn.influx.pojo.bo.CommonQueryParam; +import com.njcn.influx.pojo.dto.StatisticalDataDTO; +import com.njcn.influx.service.CommonService; +import com.njcn.system.api.CsStatisticalSetFeignClient; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.enums.DicDataEnum; +import com.njcn.system.pojo.po.DictData; +import com.njcn.system.pojo.po.EleEpdPqd; +import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.DecimalFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; -import java.util.Map; +import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.Stream; /** *

@@ -35,28 +55,32 @@ import java.util.stream.Collectors; * @since 2024-04-01 */ @Service +@RequiredArgsConstructor public class WlRecordServiceImpl extends ServiceImpl implements IWlRecordService { + private final EquipmentFeignClient equipmentFeignClient; + + private final CsStatisticalSetFeignClient csStatisticalSetFeignClient; + + private final DicDataFeignClient dicDataFeignClient; + + private final CsLineFeignClient csLineFeignClient; + + private final CommonService commonService; + + private final DecimalFormat df = new DecimalFormat("#0.0000"); + @Override @Transactional(rollbackFor = Exception.class) public void addRecord(WlRecordParam.AddRecord records) { //整理的方案下测试项集合(可能添加多个测试项) List insertList = new ArrayList<>(); - //整理单独的方案 - WlRecord wlRecord = new WlRecord(); + //校验方案ID是否存在 QueryWrapper qw = new QueryWrapper(); - qw.eq("item_name",records.getItemName()).eq("type",0).eq("state",1); + qw.eq("id",records.getId()).eq("type",0).eq("state",1); List wlRecordList = this.baseMapper.selectList(qw); - //如果当前新增的方案名称已存在的话则测试项直接绑定已存在的方案 - if(!wlRecordList.isEmpty()){ - wlRecord.setId(wlRecordList.get(0).getId()); - }else{ - //否则新增方案 - BeanUtils.copyProperties(records, wlRecord); - wlRecord.setId(IdUtil.simpleUUID()); - wlRecord.setType(0); - wlRecord.setState(1); - this.save(wlRecord); + if(wlRecordList.isEmpty() && wlRecordList.get(0).getPId()!=null){ + throw new BusinessException("方案ID不存在"); } //便利测试项 records.getRecords().forEach(item->{ @@ -65,7 +89,7 @@ public class WlRecordServiceImpl extends ServiceImpl i BeanUtils.copyProperties(item, record); record.setId(id); //当前测试项绑定当前方案 - record.setPId(wlRecord.getId()); + record.setPId(records.getId()); record.setType(0); record.setState(1); insertList.add(record); @@ -80,40 +104,99 @@ public class WlRecordServiceImpl extends ServiceImpl i @Override public void updateTestRecord(WlRecordParam.UpdateRecord record) { - List updateList = new ArrayList<>(); WlRecord wlRecord = new WlRecord(); BeanUtils.copyProperties(record, wlRecord); this.updateById(wlRecord); } @Override - public RecordVo getTestRecordById(String testRecordId) { - RecordVo recordVo = new RecordVo(); + public void updateSchemeRecord(WlRecordParam.UpdateRecord record) { + WlRecord wlRecord = new WlRecord(); + if(record.getId()!=null){ + BeanUtils.copyProperties(record, wlRecord); + this.updateById(wlRecord); + }else{ + QueryWrapper qw = new QueryWrapper(); + qw.eq("item_name",record.getItemName()).eq("type",0).eq("state",1); + List wlRecordList = this.baseMapper.selectList(qw); + //方案名称重复校验 + if(!wlRecordList.isEmpty()){ + throw new BusinessException("方案名称已存在"); + } + BeanUtils.copyProperties(record, wlRecord); + wlRecord.setId(IdUtil.simpleUUID()); + wlRecord.setType(0); + wlRecord.setState(1); + this.save(wlRecord); + } + } + + @Override + public RecordVo.RecordItemVo getTestRecordById(String testRecordId) { + RecordVo.RecordItemVo recordItemVo = new RecordVo.RecordItemVo(); + List recordVoList = new ArrayList<>(); QueryWrapper qw = new QueryWrapper(); qw.eq("id",testRecordId).eq("type",0).eq("state",1); List list = this.baseMapper.selectList(qw); if(list.isEmpty()){ - throw new BusinessException("测试项ID有误"); + throw new BusinessException("ID有误"); } WlRecord wlRecord = list.get(0); - wlRecord.setStartTime(getFirstTimeById(wlRecord.getId())); - wlRecord.setEndTime(getLastTimeById(wlRecord.getId())); - BeanUtils.copyProperties(wlRecord, recordVo); - return recordVo; + //当前ID就是测试项ID直接返回 + if(wlRecord.getPId()!=null){ + qw = new QueryWrapper(); + qw.eq("id",wlRecord.getPId()).eq("type",0).eq("state",1); + List wlRecordList = this.baseMapper.selectList(qw); + recordItemVo.setDescribe(wlRecordList.get(0).getDescribe()); + recordItemVo.setItemName(wlRecordList.get(0).getItemName()); + RecordVo recordVo = new RecordVo(); + wlRecord.setStartTime(getFirstTimeById(wlRecord.getId())); + wlRecord.setEndTime(getLastTimeById(wlRecord.getId())); + BeanUtils.copyProperties(wlRecord, recordVo); + recordVoList.add(recordVo); + }else{ + //反之则是方案ID 则返回该方案下所有的测试项信息 + recordItemVo.setDescribe(wlRecord.getDescribe()); + recordItemVo.setItemName(wlRecord.getItemName()); + qw = new QueryWrapper(); + qw.eq("p_id",testRecordId).eq("type",0).eq("state",1).orderByAsc("create_time");; + for (WlRecord wl : this.baseMapper.selectList(qw)){ + RecordVo recordVo = new RecordVo(); + wl.setStartTime(getFirstTimeById(wlRecord.getId())); + wl.setEndTime(getLastTimeById(wlRecord.getId())); + BeanUtils.copyProperties(wl, recordVo); + recordVoList.add(recordVo); + } + } + recordItemVo.setRecords(recordVoList); + return recordItemVo; } @Override - public Page queryPage(WlRecordPageParam wlRecordPageParam) { - Page returnpage = new Page<> (wlRecordPageParam.getPageNum(), wlRecordPageParam.getPageSize ( )); - returnpage = this.getBaseMapper().queryPage(returnpage,wlRecordPageParam); - return returnpage; + public Object queryPage(WlRecordPageParam wlRecordPageParam) { + if(wlRecordPageParam.getIsTrueFlag()!=1 && wlRecordPageParam.getTreeIds().isEmpty()){ + //组装tree + List recordAllDevTreeVos = this.baseMapper.getRecordAll(); + for (RecordAllDevTreeVo recordAllDevTreeVo : recordAllDevTreeVos){ + List recordAllLineTreeVos = this.baseMapper.getRecordAllLine(recordAllDevTreeVo.getId()); + recordAllDevTreeVo.setChildren(recordAllLineTreeVos); + } + return recordAllDevTreeVos; + }else{ + //查看已绑定的设备基础数据列表 + Page returnpage = new Page<> (wlRecordPageParam.getPageNum(), wlRecordPageParam.getPageSize ()); + if(wlRecordPageParam.getSearchBeginTime()!=null) wlRecordPageParam.setSearchBeginTime(wlRecordPageParam.getSearchBeginTime()+" 00:00:00"); + if(wlRecordPageParam.getSearchEndTime()!=null) wlRecordPageParam.setSearchEndTime(wlRecordPageParam.getSearchEndTime()+" 23:59:59"); + returnpage = this.getBaseMapper().queryPage(returnpage,wlRecordPageParam); + return returnpage; + } } @Override public List getSchemeTree() { List result = new ArrayList<>(); QueryWrapper qw = new QueryWrapper(); - qw.eq("state","1").eq("type","0"); + qw.eq("state","1").eq("type","0").orderByAsc("create_time"); List list = this.baseMapper.selectList(qw); // 过滤出方案数据和测试项数据(组装成tree) List schemes = list.stream().filter(item -> item.getPId() == null).collect(Collectors.toList()); @@ -129,6 +212,7 @@ public class WlRecordServiceImpl extends ServiceImpl i RecordTreeVo.Children children = new RecordTreeVo.Children(); children.setId(testItem.getId()); children.setName(testItem.getItemName()); + children.setPId(testItem.getPId()); children.setStartTime(LocalDateTimeUtil.format(getFirstTimeById(testItem.getId()), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); children.setEndTime(LocalDateTimeUtil.format(getLastTimeById(testItem.getId()), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); childrens.add(children); @@ -171,37 +255,118 @@ public class WlRecordServiceImpl extends ServiceImpl i } } } - - } - - @Override - public void updateSchemeRecordName(WlRecordParam.UpdateRecord record) { - LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); - lambdaUpdateWrapper.set(WlRecord::getItemName,record.getItemName()).set(WlRecord::getDescribe,record.getDescribe()) - .eq(WlRecord::getId, record.getId()) - .eq(WlRecord::getType, 0); - this.update(lambdaUpdateWrapper); } @Override @Transactional(rollbackFor = Exception.class) public void deleteDataRecord(WlRecordParam.UpdateRecord record) { - for(String dataRecordId : record.getList()){ + if(record.getList()!=null && !record.getList().isEmpty()){ + for(String dataRecordId : record.getList()){ this.baseMapper.deleteDataRecord(record.getId(),dataRecordId); + } } } @Override @Transactional(rollbackFor = Exception.class) public void saveDataRecord(WlRecordParam.UpdateRecord record) { - for(String dataRecordId : record.getList()){ - this.baseMapper.saveDataRecord(record.getId(),dataRecordId); + if(record.getList()!=null && !record.getList().isEmpty()){ + for(String dataRecordId : record.getList()){ + this.baseMapper.saveDataRecord(record.getId(),dataRecordId); + } } } @Override - public List schemeRecordDown() { - return this.baseMapper.schemeRecordDown(); + public List queryCommonStatisticalByTest(CommonStatisticalQueryParam commonStatisticalQueryParam) { + List result = new ArrayList(); + QueryWrapper qw = new QueryWrapper(); + //注意:此DevId为方案或测试项ID + qw.eq("id",commonStatisticalQueryParam.getDevId()).eq("state","1").eq("type","0"); + List wlRecordList = this.baseMapper.selectList(qw); + if(wlRecordList.isEmpty()){ + throw new BusinessException("DevId有误"); + } + WlRecord wlRecord = wlRecordList.get(0); + List data = new ArrayList<>(); + if(wlRecord.getPId() == null){ + //如果查询的是方案 则查询该方案下所有的测试项关联的设备基础数据 + data = this.baseMapper.getDataRecordByTestId(wlRecord.getId(),1); + }else{ + //如果查询的是测试项 则查询该测试项下所有的关联的设备基础数据 + data = this.baseMapper.getDataRecordByTestId(wlRecord.getId(),0); + } + //进行时间覆盖 + + //开始组装查询数据对象 + String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse(""); + for(WlRecord wl : data){ + //根据设备ID获取设备基础信息 + List ids = new ArrayList(); + ids.add(wl.getLineId()); + List finalCsLinePOList = csLineFeignClient.queryLineById(ids).getData(); + List data1 = equipmentFeignClient.queryDeviceById(Stream.of(wl.getDevId()).collect(Collectors.toList())).getData(); + //获取指标下的相别 + List eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(commonStatisticalQueryParam.getStatisticalId()).getData(); + List commonQueryParams = new ArrayList<>(); + for(EleEpdPqd epdPqd : eleEpdPqds){ + commonQueryParams.clear(); + CommonQueryParam commonQueryParam = new CommonQueryParam(); + commonQueryParam.setLineId(wl.getLineId()); + commonQueryParam.setTableName(getTableNameByClassId(epdPqd.getClassId())); + commonQueryParam.setColumnName(epdPqd.getName()+ frequency); + commonQueryParam.setPhasic(epdPqd.getPhase()); + commonQueryParam.setStartTime(LocalDateTimeUtil.format(wl.getStartTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + commonQueryParam.setEndTime(LocalDateTimeUtil.format(wl.getEndTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType()); + commonQueryParam.setProcess(data1.get(0).getProcess()+""); + commonQueryParam.setClDid(getClDidByLineId(wl.getLineId())); + commonQueryParams.add(commonQueryParam); + List deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams); + List collect1 = deviceRtData.stream().map(temp -> { + ThdDataVO vo = new ThdDataVO(); + vo.setLineId(temp.getLineId()); + vo.setPhase(temp.getPhaseType()); + String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(wl.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition(); + vo.setPosition(position); + vo.setTime(temp.getTime()); + vo.setStatMethod(temp.getValueType()); + vo.setStatisticalData(Double.valueOf(df.format(temp.getValue()))); + vo.setStatisticalIndex(epdPqd.getId()); + vo.setUnit(epdPqd.getUnit()); + vo.setStatisticalName(epdPqd.getName()); + vo.setAnotherName(epdPqd.getShowName()); + return vo; + }).collect(Collectors.toList()); + result.addAll(collect1); + } + } + return result; + } + + /*表名换成了id本方法做转换*/ + private String getTableNameByClassId(String classId){ + DictData data = dicDataFeignClient.getDicDataById(classId).getData(); + if(Objects.isNull(data)){ + throw new BusinessException("数据缺失"); + } + return data.getCode(); + } + private String getClDidByLineId(String lineId){ + String position = csLineFeignClient.getPositionById(lineId).getData(); + if (Objects.isNull(position)){ + throw new BusinessException(AlgorithmResponseEnum.POSITION_ERROR); + } + String clDid = null; + String areaCode = dicDataFeignClient.getDicDataById(position).getData().getCode(); + if (Objects.equals(areaCode, DicDataEnum.OUTPUT_SIDE.getCode())){ + clDid = "0"; + } else if (Objects.equals(areaCode, DicDataEnum.GRID_SIDE.getCode())){ + clDid = "1"; + } else if (Objects.equals(areaCode, DicDataEnum.LOAD_SIDE.getCode())){ + clDid = "2"; + } + return clDid; } /**