zbj//大屏区域暂降统计
This commit is contained in:
@@ -1,21 +1,13 @@
|
|||||||
package com.njcn.device.pq.pojo.param;
|
package com.njcn.device.pq.pojo.param;
|
||||||
|
|
||||||
import com.njcn.common.pojo.constant.PatternRegex;
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
import com.njcn.common.pojo.dto.SimpleDTO;
|
|
||||||
import com.njcn.device.biz.enums.LineFlagEnum;
|
|
||||||
import com.njcn.web.constant.ValidMessage;
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.hibernate.validator.constraints.Range;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.njcn.device.pq.pojo.vo;
|
||||||
|
|
||||||
|
import com.njcn.device.pq.pojo.param.MonitoringPointScaleParam;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/03/31
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AreaDownVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* 部门信息
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("部门信息")
|
||||||
|
private List<MonitoringPointScaleParam> param;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.njcn.event.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.AreaDownVO;
|
||||||
|
import com.njcn.device.pq.pojo.vo.MonitoringPointScaleVO;
|
||||||
|
|
||||||
|
import com.njcn.event.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/03/31
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "大屏")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/largeScreen")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LargeScreenController extends BaseController {
|
||||||
|
|
||||||
|
private final LargeScreenService largeScreenService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点规模
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getAreaDownStatistics")
|
||||||
|
@ApiOperation("区域暂降统计")
|
||||||
|
@ApiImplicitParam(name = "largeScreenParam", value = "区域暂降统计", required = true)
|
||||||
|
public HttpResult<AreaDownVO> getAreaDownStatistics(@RequestBody @Validated LargeScreenParam largeScreenParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("getAreaDownStatistics");
|
||||||
|
AreaDownVO result = largeScreenService.getAreaDownStatistics(largeScreenParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.event.mapper.majornetwork;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
|
||||||
|
Map<String, Object> selectDownCount(@Param("lineIds") List<String> lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?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.event.mapper.majornetwork.LargeScreenMapper">
|
||||||
|
|
||||||
|
<select id="selectDownCount" resultType="java.util.Map">
|
||||||
|
select
|
||||||
|
count(ed.event_id) "count"
|
||||||
|
from r_mp_event_detail ed
|
||||||
|
left join sys_dict_data dd on ed.event_type and dd.Type_Id ='c37861896dafab0883321e1d508caa51'
|
||||||
|
where
|
||||||
|
ed.measurement_point_id in
|
||||||
|
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
and date_format(pl.Create_Time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
and date_format(pl.Create_Time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package com.njcn.event.service.majornetwork.Impl;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||||
|
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.AreaDownVO;
|
||||||
|
import com.njcn.device.pq.pojo.vo.MonitoringPointScaleVO;
|
||||||
|
import com.njcn.event.mapper.majornetwork.LargeScreenMapper;
|
||||||
|
import com.njcn.event.service.majornetwork.LargeScreenService;
|
||||||
|
import com.njcn.system.pojo.enums.StatisticsEnum;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 AreaDownVO getAreaDownStatistics(LargeScreenParam largeScreenParam) {
|
||||||
|
//创建返回VO
|
||||||
|
AreaDownVO result = new AreaDownVO();
|
||||||
|
ArrayList<MonitoringPointScaleParam> list = 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());
|
||||||
|
//添加服务名
|
||||||
|
deviceInfoParam.setServerName("event-boot");
|
||||||
|
// 获取所有数据
|
||||||
|
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
|
||||||
|
|
||||||
|
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||||
|
if (generalDeviceDTO.getLineIndexes().size() == 0){
|
||||||
|
MonitoringPointScaleParam param = new MonitoringPointScaleParam();
|
||||||
|
param.setName(generalDeviceDTO.getName());
|
||||||
|
param.setIndex(generalDeviceDTO.getIndex());
|
||||||
|
param.setCount(0);
|
||||||
|
list.add(param);
|
||||||
|
}else{
|
||||||
|
Map<String, Object> map = largeScreenMapper.selectDownCount(generalDeviceDTO.getLineIndexes(),largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
|
||||||
|
MonitoringPointScaleParam param = new MonitoringPointScaleParam();
|
||||||
|
param.setName(generalDeviceDTO.getName());
|
||||||
|
param.setIndex(generalDeviceDTO.getIndex());
|
||||||
|
String s = map.get("count").toString();
|
||||||
|
int count = Integer.parseInt(s);
|
||||||
|
param.setCount(count);
|
||||||
|
list.add(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.setParam(list);
|
||||||
|
return result;
|
||||||
|
/* //获取所有监测点集合
|
||||||
|
List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
|
||||||
|
List<Map<String, Object>> maps = largeScreenMapper.selectDownCount(lineIds);
|
||||||
|
|
||||||
|
Map<String,Integer> countMap = new HashMap<>();
|
||||||
|
for (Map<String, Object> map : maps) {
|
||||||
|
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
|
||||||
|
for (String lineIndex : generalDeviceDTO.getLineIndexes()) {
|
||||||
|
if (map.get("id").equals(lineIndex)){
|
||||||
|
if(countMap.containsKey(generalDeviceDTO.getName())){
|
||||||
|
countMap.put(generalDeviceDTO.getName(),countMap.get(generalDeviceDTO.getName())+1);
|
||||||
|
break;
|
||||||
|
}else {
|
||||||
|
countMap.put(generalDeviceDTO.getName(),1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.event.service.majornetwork;
|
||||||
|
|
||||||
|
import com.njcn.device.pq.pojo.param.LargeScreenParam;
|
||||||
|
import com.njcn.device.pq.pojo.vo.AreaDownVO;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: zbj
|
||||||
|
* @date: 2023/03/31
|
||||||
|
*/
|
||||||
|
public interface LargeScreenService {
|
||||||
|
|
||||||
|
AreaDownVO getAreaDownStatistics(LargeScreenParam largeScreenParam);
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user