Commit 3d54697d authored by 朱晨阳's avatar 朱晨阳

添加告警统计接口

parent e92867f6
......@@ -78,4 +78,6 @@ public interface JpStationMapper extends BaseMapper<JpStation> {
List<PowerStationStatistics> getDealerPage(String regionalCompaniesCode, String dealerName);
@UserEmpower(field ={"hygf_jp_station.regional_companies_code"},dealerField ={"hygf_jp_station.amos_company_code","hygf_jp_station.regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<JpStationDto> queryAllPowerStation(String regionalCompaniesCode, String amosCompanyCode, String powerStationId);
}
......@@ -31,11 +31,16 @@ public interface TdHygfJpInverterWarnMapper extends BaseMapper<TdHygfJpInverterW
TdHygfJpInverterWarnDto getByTime(@Param("createdTime") long createdTime);
@UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<TdHygfJpInverterWarnDto> selectWarnList(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, Integer current, Integer size,String handlerStatus,String stationName);
@UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
int selectWarnListTotal(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content,String handlerStatus,String stationName);
@UserEmpower(field = {"regional_companies_code"}, dealerField = {"amos_company_code", "regional_companies_code"}, fieldConditions = {"eq", "in"}, relationship = "and")
List<TdHygfJpInverterWarnDto> selectWarnList(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, Integer current, Integer size, String handlerStatus, String stationName);
@UserEmpower(field = {"regional_companies_code"}, dealerField = {"amos_company_code", "regional_companies_code"}, fieldConditions = {"eq", "in"}, relationship = "and")
int selectWarnListTotal(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, String handlerStatus, String stationName);
@Select("SELECT * from td_hygf_jp_inverter_warn WHERE (third_station_id = #{thirdStationId} AND sn_code = #{sncode} AND created_time = #{createdTime})")
TdHygfJpInverterWarn getInverTerWarnByparams(@Param("createdTime") long createdTime, @Param("sncode") String snCode, @Param("thirdStationId") String thirdStationId);
// @UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<TdHygfJpInverterWarnDto> queryAlarmNumber(@Param("thirdStationIds") List<String> thirdStationIds);
}
......@@ -658,5 +658,28 @@
</select>
<!-- 查询所有场站-->
<select id="queryAllPowerStation" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto">
select
name,
third_station_id
from hygf_jp_station
<where>
<if test="powerStationId!=null">
and hygf_jp_station.sequence_nbr =#{powerStationId}
</if>
<if test="regionalCompaniesCode!=null">
and hygf_jp_station.regional_companies_code =#{regionalCompaniesCode}
</if>
<if test="amosCompanyCode!=null">
and hygf_jp_station.amos_company_code =#{amosCompanyCode}
</if>
</where>
</select>
</mapper>
......@@ -158,4 +158,20 @@
</where>
</select>
<select id="queryAlarmNumber" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpInverterWarnDto">
SELECT
`state`
FROM house_pv_data.td_hygf_jp_inverter_warn
<where>
<if test="thirdStationIds != null and thirdStationIds.size > 0 ">
third_station_id in
<foreach collection="thirdStationIds" item="item" open='(' close=')' separator=",">
#{item}
</foreach>
</if>
</where>
</select>
</mapper>
......@@ -286,8 +286,7 @@ public class TdHygfJpInverterWarnController extends BaseController {
}
List<TdHygfJpInverterWarnDto> maps = tdHygfJpInverterWarnServiceImpl.selectWarnList(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, current, size, handlerStatus,stationName);
List<TdHygfJpInverterWarnDto> maps = tdHygfJpInverterWarnServiceImpl.selectWarnList(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, current, size, handlerStatus, stationName);
for (TdHygfJpInverterWarnDto map : maps) {
// if (nameMaps.containsKey(map.getThirdStationId())) {
// map.setStationName(nameMaps.get(map.getThirdStationId()));
......@@ -296,7 +295,7 @@ public class TdHygfJpInverterWarnController extends BaseController {
map.setTimeLongFormat(te);
}
result.setTotal(tdHygfJpInverterWarnServiceImpl.selectWarnListTotal(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, handlerStatus,stationName));
result.setTotal(tdHygfJpInverterWarnServiceImpl.selectWarnListTotal(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, handlerStatus, stationName));
List<Long> waringIds = maps.stream().map(tdHygfJpInverterWarnDto -> tdHygfJpInverterWarnDto.getCreatedTime()).collect(Collectors.toList());
if (waringIds.size() == 0) {
waringIds = Arrays.asList(0L);
......@@ -317,4 +316,18 @@ public class TdHygfJpInverterWarnController extends BaseController {
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "户用光伏逆变器报警表统计数据查询", notes = "户用光伏逆变器报警表统计数据查询")
@GetMapping(value = "/queryAlarmNumber")
@UserLimits
public ResponseModel<Map<String, Object>> queryAlarmNumber(@RequestParam(required = false) String regionalCompaniesCode,
@RequestParam(required = false) String amosCompanyCode,
@RequestParam(required = false) String powerStationId
) {
Map<String, Object> result = tdHygfJpInverterWarnServiceImpl.queryAlarmNumber(regionalCompaniesCode, amosCompanyCode, powerStationId);
return ResponseHelper.buildResponse(result);
}
}
......@@ -964,4 +964,9 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
}
public List<JpStationDto> queryAllPowerStation(String regionalCompaniesCode, String amosCompanyCode, String powerStationId) {
List<JpStationDto> powerStationList = jpStationMapper.queryAllPowerStation(regionalCompaniesCode, amosCompanyCode, powerStationId);
return powerStationList;
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.hygf.api.dto.HYGFMaintenanceTicketsDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto;
import com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpInverterWarnDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.HYGFMaintenanceTickets;
import com.yeejoin.amos.boot.module.hygf.api.entity.JpStation;
......@@ -19,6 +20,7 @@ import com.yeejoin.amos.boot.module.hygf.api.util.TimeUtil;
import jdk.nashorn.internal.ir.annotations.Ignore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.*;
......@@ -42,6 +44,7 @@ public class TdHygfJpInverterWarnServiceImpl
HYGFMaintenanceTicketsMapper hygfMaintenanceTicketsMapper;
@Autowired
TdHygfJpInverterWarnMapper tdHygfJpInverterWarnMapper;
/**
* 分页查询
*/
......@@ -96,18 +99,18 @@ public class TdHygfJpInverterWarnServiceImpl
}
List<HYGFMaintenanceTickets> hygfMaintenanceTicketsList = hygfMaintenanceTicketsMapper.selectList(new QueryWrapper<HYGFMaintenanceTickets>().in("warning_id", waringIds));
if (hygfMaintenanceTicketsList.size() > 0) {
list.forEach(i -> {
List<HYGFMaintenanceTickets> ticketsList = hygfMaintenanceTicketsList.stream().filter(hygfmaintenanceTickets -> i.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(ticketsList)) {
Set<String> status = ticketsList.stream().map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if (status.contains("未处理")) {
i.setTicketStatus("处理中");
}
if (status.contains("已处理") && status.size() == 1) {
i.setTicketStatus("已处理");
}
}
});
list.forEach(i -> {
List<HYGFMaintenanceTickets> ticketsList = hygfMaintenanceTicketsList.stream().filter(hygfmaintenanceTickets -> i.getCreatedTime().equals(hygfmaintenanceTickets.getWarningId())).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(ticketsList)) {
Set<String> status = ticketsList.stream().map(HYGFMaintenanceTickets::getHandlerStatus).collect(Collectors.toSet());
if (status.contains("未处理")) {
i.setTicketStatus("处理中");
}
if (status.contains("已处理") && status.size() == 1) {
i.setTicketStatus("已处理");
}
}
});
}
PageInfo<TdHygfJpInverterWarnDto> page = new PageInfo(list);
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto> pagenew = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<TdHygfJpInverterWarnDto>();
......@@ -166,7 +169,7 @@ public class TdHygfJpInverterWarnServiceImpl
return tdHygfJpInverterWarnDto;
}
public List<TdHygfJpInverterWarnDto> selectWarnList(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, Integer current, Integer size, String handlerStatus,String stationName) {
public List<TdHygfJpInverterWarnDto> selectWarnList(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, Integer current, Integer size, String handlerStatus, String stationName) {
List<TdHygfJpInverterWarnDto> list = tdHygfJpInverterWarnMapper.selectWarnList(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, (current - 1) * size, size, handlerStatus, stationName);
list.forEach(i -> {
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
......@@ -180,7 +183,46 @@ public class TdHygfJpInverterWarnServiceImpl
return list;
}
public int selectWarnListTotal(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, String handlerStatus,String stationName) {
public int selectWarnListTotal(String state, String level, String minvalue, String maxValue, String snCode, List<String> stationId, String startTime, String endTime, String content, String handlerStatus, String stationName) {
return tdHygfJpInverterWarnMapper.selectWarnListTotal(state, level, minvalue, maxValue, snCode, stationId, startTime, endTime, content, handlerStatus, stationName);
}
public Map<String, Object> queryAlarmNumber(String regionalCompaniesCode, String amosCompanyCode, String powerStationId) {
// 查询所有场站
List<JpStationDto> jpStationDtos = jpStationServiceImpl.queryAllPowerStation(regionalCompaniesCode, amosCompanyCode, powerStationId);
Map<String, Object> result = new HashMap<>();
if (!CollectionUtils.isEmpty(jpStationDtos)) {
// 获取thirdStationId集合
List<String> thirdStationIds = jpStationDtos.stream().map(JpStation -> JpStation.getThirdStationId()).collect(Collectors.toList());
List<TdHygfJpInverterWarnDto> tdHygfJpInverterWarnDtos = tdHygfJpInverterWarnMapper.queryAlarmNumber(thirdStationIds);
ArrayList<String> yclArray = new ArrayList<>();
ArrayList<String> wclArray = new ArrayList<>();
tdHygfJpInverterWarnDtos.stream().forEach(tdHygfJpInverterWarnDto -> {
if (tdHygfJpInverterWarnDto.getState().equals("已恢复") || tdHygfJpInverterWarnDto.getState().equals("已处理")) {
yclArray.add(tdHygfJpInverterWarnDto.getState());
} else {
wclArray.add(tdHygfJpInverterWarnDto.getState());
}
});
result.put("ycl", yclArray.size());
result.put("wcl", wclArray.size());
}else {
result.put("ycl", 0);
result.put("wcl", 0);
}
return result;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment