代码调整
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
package com.njcn.csdevice.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @date 2023/6/19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DataGroupTemplateVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
@ApiModelProperty("组名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@ApiModelProperty("指标数据")
|
||||||
|
private List<EnergyTemplateVO> children;
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.njcn.csdevice.pojo.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.njcn.common.utils.serializer.InstantDateSerializer;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @date 2023/6/19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EnergyTemplateVO {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
@ApiModelProperty("字典id")
|
||||||
|
private String dataId;
|
||||||
|
|
||||||
|
@ApiModelProperty("别名")
|
||||||
|
private String anotherName;
|
||||||
|
|
||||||
|
@ApiModelProperty("指标名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("数据类型")
|
||||||
|
private String statMethod;
|
||||||
|
|
||||||
|
@ApiModelProperty("相别")
|
||||||
|
private String phase;
|
||||||
|
|
||||||
|
@ApiModelProperty("数据查询表名")
|
||||||
|
private String classId;
|
||||||
|
|
||||||
|
@ApiModelProperty("数据时间")
|
||||||
|
@JsonSerialize(using = InstantDateSerializer.class)
|
||||||
|
private Instant time;
|
||||||
|
|
||||||
|
@ApiModelProperty("数据")
|
||||||
|
private Double dataValue;
|
||||||
|
}
|
||||||
@@ -58,6 +58,21 @@
|
|||||||
<artifactId>system-api</artifactId>
|
<artifactId>system-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>pqs-influx</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>logging-interceptor</artifactId>
|
||||||
|
<version>4.9.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
import org.springframework.context.annotation.DependsOn;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,6 +17,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||||||
@MapperScan("com.njcn.**.mapper")
|
@MapperScan("com.njcn.**.mapper")
|
||||||
@EnableFeignClients(basePackages = "com.njcn")
|
@EnableFeignClients(basePackages = "com.njcn")
|
||||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||||
|
@DependsOn("proxyMapperRegister")
|
||||||
public class CsDeviceBootApplication {
|
public class CsDeviceBootApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
package com.njcn.csdevice.controller.equipment;
|
package com.njcn.csdevice.controller.equipment;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||||
import com.njcn.csdevice.service.ICsGroupService;
|
import com.njcn.csdevice.service.ICsGroupService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -48,5 +51,20 @@ public class CsGroupController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/deviceRtData")
|
||||||
|
@ApiOperation("装置分组实时数据")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "id", value = "tab选项id", required = true),
|
||||||
|
@ApiImplicitParam(name = "pageNum", value = "页码", required = true),
|
||||||
|
@ApiImplicitParam(name = "pageSize", value = "页面尺寸", required = true),
|
||||||
|
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true)
|
||||||
|
})
|
||||||
|
public HttpResult<IPage<DataGroupTemplateVO>> getDeviceRtData(@RequestParam("id") String id, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "lineId")String lineId){
|
||||||
|
String methodDescribe = getMethodDescribe("getDeviceData");
|
||||||
|
IPage<DataGroupTemplateVO> list = csGroupService.getDeviceRtData(id, pageNum, pageSize,lineId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
|||||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||||
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
import com.njcn.csdevice.pojo.vo.*;
|
||||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
|
||||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
|
||||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
|
||||||
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -140,4 +137,5 @@ public class EquipmentDeliveryController extends BaseController {
|
|||||||
DeviceManagerVO vo = csEquipmentDeliveryService.getDeviceData(deviceId);
|
DeviceManagerVO vo = csEquipmentDeliveryService.getDeviceData(deviceId);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.csdevice.mapper;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||||
|
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
||||||
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
import com.njcn.csdevice.pojo.vo.LineTargetVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@@ -26,4 +27,5 @@ public interface CsDataArrayMapper extends BaseMapper<CsDataArray> {
|
|||||||
|
|
||||||
List<CsDataArray> getGroupData(@Param("id") String id);
|
List<CsDataArray> getGroupData(@Param("id") String id);
|
||||||
|
|
||||||
|
List<EnergyTemplateVO> getArrayByGroup(@Param("list") List<String> list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.njcn.csdevice.mapper;
|
package com.njcn.csdevice.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.csdevice.pojo.po.CsGroup;
|
import com.njcn.csdevice.pojo.po.CsGroup;
|
||||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,4 +27,6 @@ public interface CsGroupMapper extends BaseMapper<CsGroup> {
|
|||||||
List<CsGroupVO> getArrayData(@Param("list") List<String> list);
|
List<CsGroupVO> getArrayData(@Param("list") List<String> list);
|
||||||
|
|
||||||
void insertList(@Param("list") List<CsGroup> list);
|
void insertList(@Param("list") List<CsGroup> list);
|
||||||
|
|
||||||
|
Page<DataGroupTemplateVO> getGroupDataList(IPage<DataGroupTemplateVO> page, @Param("id") String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,4 +65,28 @@
|
|||||||
phase
|
phase
|
||||||
order by min(sort)
|
order by min(sort)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getArrayByGroup" resultType="EnergyTemplateVO">
|
||||||
|
select
|
||||||
|
t1.id,
|
||||||
|
t0.group_id pid,
|
||||||
|
t1.data_id dataId,
|
||||||
|
t1.name,
|
||||||
|
case when t1.phase in ('A', 'B', 'C') then concat(t1.phase, "相", t1.another_name)
|
||||||
|
when t1.phase in ('M', 'T') then t1.another_name
|
||||||
|
else concat(t1.phase, t1.another_name)
|
||||||
|
end anotherName,
|
||||||
|
t1.stat_method statMethod,
|
||||||
|
t1.phase
|
||||||
|
from
|
||||||
|
cs_gro_arr t0
|
||||||
|
left join cs_data_array t1 on
|
||||||
|
t0.array_id = t1.id
|
||||||
|
where
|
||||||
|
t0.group_id in
|
||||||
|
<foreach collection='list' item='item' index="index" open='(' separator=',' close=')'>
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
order by t1.sort
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -71,4 +71,19 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getGroupDataList" resultType="DataGroupTemplateVO">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
data_set_id pid,
|
||||||
|
group_name name,
|
||||||
|
sort
|
||||||
|
from
|
||||||
|
cs_group
|
||||||
|
where
|
||||||
|
data_set_id = #{id} and is_show = 1
|
||||||
|
order by
|
||||||
|
sort
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -8,10 +8,7 @@ import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
|||||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||||
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
import com.njcn.csdevice.pojo.vo.*;
|
||||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
|
||||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
|
||||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.njcn.csdevice.service;
|
package com.njcn.csdevice.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.csdevice.pojo.po.CsGroup;
|
import com.njcn.csdevice.pojo.po.CsGroup;
|
||||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -22,4 +24,10 @@ public interface ICsGroupService extends IService<CsGroup> {
|
|||||||
*/
|
*/
|
||||||
List<CsGroupVO> getGroupData(String dataSet);
|
List<CsGroupVO> getGroupData(String dataSet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取装置分组后的实时数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.csdevice.service.impl;
|
package com.njcn.csdevice.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@@ -12,19 +13,22 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||||
|
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
||||||
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
||||||
|
import com.njcn.csdevice.mapper.CsGroupMapper;
|
||||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
|
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm;
|
||||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
|
||||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||||
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
import com.njcn.csdevice.pojo.po.*;
|
||||||
import com.njcn.csdevice.pojo.po.CsEngineeringPO;
|
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
|
||||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
|
||||||
import com.njcn.csdevice.pojo.vo.*;
|
import com.njcn.csdevice.pojo.vo.*;
|
||||||
import com.njcn.csdevice.service.*;
|
import com.njcn.csdevice.service.*;
|
||||||
import com.njcn.db.constant.DbConstant;
|
import com.njcn.db.constant.DbConstant;
|
||||||
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||||
|
import com.njcn.influx.service.CommonService;
|
||||||
|
import com.njcn.system.api.EpdFeignClient;
|
||||||
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -189,10 +193,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
return deviceManagerVo;
|
return deviceManagerVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private List<EnergyTemplateVO> getChildren(String tabId, List<EnergyTemplateVO> all) {
|
||||||
* 获取子节点
|
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
|
||||||
*/
|
|
||||||
public List<CsLedgerVO> getChildren(CsLedgerVO item, List<CsLedgerVO> all) {
|
|
||||||
return all.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,26 @@ package com.njcn.csdevice.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
||||||
import com.njcn.csdevice.mapper.CsGroupMapper;
|
import com.njcn.csdevice.mapper.CsGroupMapper;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||||
import com.njcn.csdevice.pojo.po.CsGroArr;
|
import com.njcn.csdevice.pojo.po.CsGroArr;
|
||||||
import com.njcn.csdevice.pojo.po.CsGroup;
|
import com.njcn.csdevice.pojo.po.CsGroup;
|
||||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
||||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||||
import com.njcn.csdevice.service.ICsGroArrService;
|
import com.njcn.csdevice.service.ICsGroArrService;
|
||||||
import com.njcn.csdevice.service.ICsGroupService;
|
import com.njcn.csdevice.service.ICsGroupService;
|
||||||
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||||
|
import com.njcn.influx.service.CommonService;
|
||||||
|
import com.njcn.system.api.EpdFeignClient;
|
||||||
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -35,6 +45,14 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
|
|
||||||
private final ICsGroArrService csGroArrService;
|
private final ICsGroArrService csGroArrService;
|
||||||
|
|
||||||
|
private final CsGroupMapper csGroupMapper;
|
||||||
|
|
||||||
|
private final CsDataArrayMapper csDataArrayMapper;
|
||||||
|
|
||||||
|
private final CommonService commonService;
|
||||||
|
|
||||||
|
private final EpdFeignClient epdFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<CsGroupVO> getGroupData(String dataSet) {
|
public List<CsGroupVO> getGroupData(String dataSet) {
|
||||||
@@ -53,6 +71,52 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<DataGroupTemplateVO> getDeviceRtData(String id, Integer pageNum, Integer pageSize, String lineId) {
|
||||||
|
IPage<DataGroupTemplateVO> pageTurn = new Page<>();
|
||||||
|
List<EnergyTemplateVO> arrayList = new ArrayList<>();
|
||||||
|
IPage<DataGroupTemplateVO> pageRes = csGroupMapper.getGroupDataList(new Page<>(pageNum, pageSize), id);
|
||||||
|
if (pageRes.getTotal() != 0) {
|
||||||
|
List<DataGroupTemplateVO> groupList = pageRes.getRecords();
|
||||||
|
List<String> group = groupList.stream().map(DataGroupTemplateVO::getId).collect(Collectors.toList());
|
||||||
|
//获取当前组的所有指标项
|
||||||
|
List<EnergyTemplateVO> list = csDataArrayMapper.getArrayByGroup(group);
|
||||||
|
list.forEach(item->{
|
||||||
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
||||||
|
BeanUtils.copyProperties(item,vo);
|
||||||
|
EleEpdPqd eleEpdPqd = epdFeignClient.selectById(item.getDataId()).getData();
|
||||||
|
vo.setClassId(eleEpdPqd.getClassId());
|
||||||
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,eleEpdPqd.getClassId(),item.getName(),item.getPhase(),item.getStatMethod());
|
||||||
|
if (!Objects.isNull(statisticalDataDTO)){
|
||||||
|
vo.setTime(statisticalDataDTO.getTime());
|
||||||
|
vo.setDataValue(statisticalDataDTO.getValue());
|
||||||
|
} else {
|
||||||
|
vo.setDataValue(3.1415926);
|
||||||
|
}
|
||||||
|
arrayList.add(vo);
|
||||||
|
});
|
||||||
|
if (CollectionUtil.isNotEmpty(arrayList)){
|
||||||
|
List<DataGroupTemplateVO> grList = groupList.stream().peek((item) -> {item.setChildren(getChildren(item.getId(), arrayList));}).collect(Collectors.toList());
|
||||||
|
pageTurn.setRecords(grList);
|
||||||
|
pageTurn.setTotal(pageRes.getTotal());
|
||||||
|
pageTurn.setSize(pageRes.getSize());
|
||||||
|
pageTurn.setCurrent(pageRes.getCurrent());
|
||||||
|
pageTurn.setPages(pageRes.getPages());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pageTurn.setRecords(new ArrayList<>());
|
||||||
|
pageTurn.setTotal(pageRes.getTotal());
|
||||||
|
pageTurn.setSize(pageRes.getSize());
|
||||||
|
pageTurn.setCurrent(pageRes.getCurrent());
|
||||||
|
pageTurn.setPages(pageRes.getPages());
|
||||||
|
}
|
||||||
|
return pageTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<EnergyTemplateVO> getChildren(String tabId, List<EnergyTemplateVO> all) {
|
||||||
|
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
private List<CsGroupVO> getChildrenes(String tabId, List<CsGroupVO> all) {
|
private List<CsGroupVO> getChildrenes(String tabId, List<CsGroupVO> all) {
|
||||||
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
|
return all.stream().filter(item -> item.getPid().equals(tabId)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user