zbj//1.稳态指标超标占比(区域)
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
package com.njcn.device.pq.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/04/06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class HomeostasisAreaVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 稳态超标占比
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("稳态超标占比")
|
||||||
|
private String avg;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.njcn.harmonic.controller.majornetwork;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.device.pq.pojo.param.LargeScreenParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.*;
|
||||||
|
|
||||||
|
import com.njcn.harmonic.service.majornetwork.LargeScreenService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/04/06
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "大屏")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/largeScreen")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LargeScreenController extends BaseController {
|
||||||
|
|
||||||
|
private final LargeScreenService largeScreenService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 稳态指标超标占比(区域)
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getHomeostasisArea")
|
||||||
|
@ApiOperation("稳态指标超标占比(区域)")
|
||||||
|
@ApiImplicitParam(name = "largeScreenParam", value = "稳态指标超标占比(区域)", required = true)
|
||||||
|
public HttpResult<List<HomeostasisAreaVO>> getHomeostasisArea(@RequestBody @Validated LargeScreenParam largeScreenParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("getHomeostasisArea");
|
||||||
|
List<HomeostasisAreaVO> result = largeScreenService.getHomeostasisArea(largeScreenParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.harmonic.mapper.majornetwork;
|
||||||
|
|
||||||
|
import com.njcn.device.pq.pojo.vo.AllDataVO;
|
||||||
|
import com.njcn.device.pq.pojo.vo.EventVO;
|
||||||
|
import com.njcn.device.pq.pojo.vo.MiddleLimitRateVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/03/31
|
||||||
|
*/
|
||||||
|
public interface LargeScreenMapper {
|
||||||
|
|
||||||
|
List<Map<String,Object>> getHomeostasisArea (@Param("indexIds") List<String> indexIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.harmonic.mapper.majornetwork.LargeScreenMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getHomeostasisArea" resultType="java.util.Map">
|
||||||
|
select
|
||||||
|
rshom.org_no "id",
|
||||||
|
round(avg(rshom.over_limit_measurement_ratio_accrued),2) avg
|
||||||
|
from r_stat_harmonic_org_m rshom
|
||||||
|
left join sys_dict_data sdd on rshom.data_type = sdd.Id and sdd.`Code` = 'Mainnet_Point'
|
||||||
|
WHERE
|
||||||
|
rshom.org_no IN
|
||||||
|
<foreach collection="indexIds" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
and date_format(rshom.data_date,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
and date_format(rshom.data_date,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
group by rshom.org_no
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.njcn.harmonic.service.majornetwork;
|
||||||
|
|
||||||
|
import com.njcn.device.pq.pojo.param.LargeScreenParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/03/31
|
||||||
|
*/
|
||||||
|
public interface LargeScreenService {
|
||||||
|
|
||||||
|
List<HomeostasisAreaVO> getHomeostasisArea(LargeScreenParam largeScreenParam);
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.njcn.harmonic.service.majornetwork.impl;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||||
|
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||||
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||||
|
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||||
|
import com.njcn.device.pq.pojo.param.LargeScreenParam;
|
||||||
|
import com.njcn.device.pq.pojo.param.MonitoringPointScaleParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.*;
|
||||||
|
import com.njcn.harmonic.mapper.majornetwork.LargeScreenMapper;
|
||||||
|
import com.njcn.harmonic.service.majornetwork.LargeScreenService;
|
||||||
|
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.map.HashedMap;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/03/31
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LargeScreenServiceImpl implements LargeScreenService {
|
||||||
|
|
||||||
|
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||||
|
|
||||||
|
private final LargeScreenMapper largeScreenMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 稳态指标超标占比(区域)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<HomeostasisAreaVO> getHomeostasisArea(LargeScreenParam largeScreenParam) {
|
||||||
|
//创建返回VO
|
||||||
|
List<HomeostasisAreaVO> result = new ArrayList<>();
|
||||||
|
|
||||||
|
DeviceInfoParam.BusinessParam deviceInfoParam = new DeviceInfoParam.BusinessParam();
|
||||||
|
//部门索引
|
||||||
|
deviceInfoParam.setDeptIndex(largeScreenParam.getDeptIndex());
|
||||||
|
//统计类型
|
||||||
|
SimpleDTO simpleDTO = new SimpleDTO();
|
||||||
|
simpleDTO.setCode(String.valueOf(StatisticsEnum.POWER_NETWORK));
|
||||||
|
deviceInfoParam.setStatisticalType(simpleDTO);
|
||||||
|
//添加时间
|
||||||
|
deviceInfoParam.setSearchBeginTime(largeScreenParam.getSearchBeginTime());
|
||||||
|
deviceInfoParam.setSearchEndTime(largeScreenParam.getSearchEndTime());
|
||||||
|
|
||||||
|
// 获取所有数据
|
||||||
|
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
|
||||||
|
//部门id集合
|
||||||
|
List<String> indexIds = generalDeviceDTOList.stream().map(GeneralDeviceDTO::getIndex).collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<Map<String, Object>> homeostasisArea = largeScreenMapper.getHomeostasisArea(indexIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
|
||||||
|
|
||||||
|
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||||
|
for (Map<String, Object> map : homeostasisArea) {
|
||||||
|
if (Objects.equals(generalDeviceDTO.getIndex(), map.get("id"))) {
|
||||||
|
HomeostasisAreaVO homeostasisAreaVO = new HomeostasisAreaVO();
|
||||||
|
homeostasisAreaVO.setName(generalDeviceDTO.getName());
|
||||||
|
homeostasisAreaVO.setAvg(map.get("avg").toString());
|
||||||
|
result.add(homeostasisAreaVO);
|
||||||
|
} else {
|
||||||
|
HomeostasisAreaVO homeostasisAreaVO = new HomeostasisAreaVO();
|
||||||
|
homeostasisAreaVO.setName(generalDeviceDTO.getName());
|
||||||
|
homeostasisAreaVO.setAvg("0");
|
||||||
|
result.add(homeostasisAreaVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user