Browse Source

光伏逆变器详情

2025年1月9日10:30:17
qingyuan_dev_new
lishuai 1 year ago
parent
commit
44b29b4738
  1. 103
      modules/qingyuan/src/main/java/com/thing/qingyuan/alert/controller/AlertController.java
  2. 70
      modules/qingyuan/src/main/java/com/thing/qingyuan/alert/dto/AlertDTO.java
  3. 113
      modules/qingyuan/src/main/java/com/thing/qingyuan/alert/entity/AlertEntity.java
  4. 64
      modules/qingyuan/src/main/java/com/thing/qingyuan/alert/excel/AlertExcel.java
  5. 18
      modules/qingyuan/src/main/java/com/thing/qingyuan/alert/mapper/AlertMapper.java
  6. 19
      modules/qingyuan/src/main/java/com/thing/qingyuan/alert/service/AlertService.java
  7. 97
      modules/qingyuan/src/main/java/com/thing/qingyuan/alert/service/impl/AlertServiceImpl.java
  8. 7
      modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/ManageBoardController.java
  9. 3
      modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/ManageBoardService.java
  10. 12
      modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/impl/ManageBoardServiceImpl.java

103
modules/qingyuan/src/main/java/com/thing/qingyuan/alert/controller/AlertController.java

@ -1,103 +0,0 @@
package com.thing.qingyuan.alert.controller;
import com.thing.qingyuan.alert.dto.AlertDTO;
import com.thing.qingyuan.alert.service.AlertService;
import com.thing.common.core.annotation.LogOperation;
import com.thing.common.core.constants.Constant;
import com.thing.common.core.validator.AssertUtils;
import com.thing.common.core.validator.ValidatorUtils;
import com.thing.common.core.validator.group.AddGroup;
import com.thing.common.core.validator.group.DefaultGroup;
import com.thing.common.core.validator.group.UpdateGroup;
import com.thing.common.core.web.response.PageData;
import com.thing.common.core.web.response.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 告警记录
*
* @author xc
* @since 3.0 2024-01-31
*/
@RestController
@RequestMapping("alert")
@Tag(name="告警记录")
@RequiredArgsConstructor
public class AlertController {
private final AlertService alertService;
@GetMapping("page")
@Operation(summary="分页")
@Parameters({
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始") ,
@Parameter(name = Constant.LIMIT, description = "每页显示记录数") ,
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段") ,
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)"),
@Parameter(name = "name", description = "告警名称"),
@Parameter(name = "level", description = "告警等级"),
@Parameter(name = "status", description = "处理状态"),
@Parameter(name = "startTime", description = "告警开始时间窗口"),
@Parameter(name = "endTime", description = "告警结束时间窗口"),
@Parameter(name = "plantIds", description = "光伏场站id列表"),
})
public Result<PageData<AlertDTO>> page(@RequestParam Map<String, Object> params){
PageData<AlertDTO> page = alertService.handlePage(params);
return new Result<PageData<AlertDTO>>().ok(page);
}
@GetMapping("{id}")
@Operation(summary="信息")
public Result<AlertDTO> get(@PathVariable("id") Long id){
AlertDTO data = alertService.getByIdAs(id, AlertDTO.class);
return new Result<AlertDTO>().ok(data);
}
@PostMapping
@Operation(summary="保存")
@LogOperation("保存")
public Result<Void> save(@RequestBody AlertDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
alertService.saveDto(dto);
return new Result<>();
}
@PutMapping
@Operation(summary="修改")
@LogOperation("修改")
public Result<Void> update(@RequestBody AlertDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
alertService.updateDto(dto);
return new Result<>();
}
@DeleteMapping
@Operation(summary="删除")
@LogOperation("删除")
public Result<Void> delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
alertService.batchDelete(ids);
return new Result<>();
}
@GetMapping("export")
@Operation(summary="导出")
@LogOperation("导出")
public void export( @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<AlertDTO> list = alertService.listAs(params, AlertDTO.class);
//ExcelUtils.exportExcelToTarget(response, null, "告警记录", list, AlertExcel.class);
}
}

70
modules/qingyuan/src/main/java/com/thing/qingyuan/alert/dto/AlertDTO.java

@ -1,70 +0,0 @@
package com.thing.qingyuan.alert.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 告警记录
*
* @author xc
* @since 3.0 2024-01-31
*/
@Data
@Schema( name= "告警记录")
public class AlertDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "主键")
private Long plantAlertId;
@Schema(description = "电站id")
private Long plantId;
@Schema(description = "电站名称")
private String plantName;
@Schema(description = "设备id")
private Long deviceId;
@Schema(description = "设备名称")
private String deviceName;
@Schema(description = "状态id:1.未处理;2.已处理;3.已恢复")
private Integer status;
@Schema(description = "状态文本:1.未处理;2.已处理;3.已恢复")
private String statusLabel;
@Schema(description = "采集器sn")
private String collectorSn;
@Schema(description = "逆变器sn")
private String deviceSn;
@Schema(description = "报警等级id: 01.故障 02.警告 03.提示")
private Integer alertLevel;
@Schema(description = "报警等级文本: 01.故障 02.警告 03.提示")
private String alertLevelLabel;
@Schema(description = "报警名称")
private String alertName;
@Schema(description = "报警代码")
private String alertCode;
@Schema(description = "报警影响面")
private Integer alertEffect;
@Schema(description = "报警影响面文本")
private String alertEffectLabel;
@Schema(description = "报警发生时间")
private String startTimeOrigin;
@Schema(description = "报警发生时间")
private String startTime;
@Schema(description = "报警恢复时间")
private String endTimeOrigin;
@Schema(description = "报警恢复时间")
private String endTime;
@Schema(description = "报警发生时间")
private String startTimeForCharts;
@Schema(description = "报警恢复时间")
private String endTimeForCharts;
@Schema(description = "持续时间")
private String duration;
@Schema(description = "拟解决方案")
private String solution;
@Schema(description = "时区")
private Integer timeZoneOffset;
}

113
modules/qingyuan/src/main/java/com/thing/qingyuan/alert/entity/AlertEntity.java

@ -1,113 +0,0 @@
package com.thing.qingyuan.alert.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
/**
* 告警记录
*
* @author xc
* @since 3.0 2024-01-31
*/
@Data
@EqualsAndHashCode(callSuper=false)
@Table("alert")
public class AlertEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@Id
private Long plantAlertId;
/**
* 电站id
*/
private Long plantId;
/**
* 设备id
*/
private Long deviceId;
/**
* 状态id1.未处理2.已处理3.已恢复
*/
private Integer status;
/**
* 状态文本1.未处理2.已处理3.已恢复
*/
private String statusLabel;
/**
* 采集器sn
*/
private String collectorSn;
/**
* 逆变器sn
*/
private String deviceSn;
/**
* 报警等级id: 01.故障 02.警告 03.提示
*/
private Integer alertLevel;
/**
* 报警等级文本: 01.故障 02.警告 03.提示
*/
private String alertLevelLabel;
/**
* 报警名称
*/
private String alertName;
/**
* 报警代码
*/
private String alertCode;
/**
* 报警影响面
*/
private Integer alertEffect;
/**
* 报警影响面文本
*/
private String alertEffectLabel;
/**
* 报警发生时间
*/
private String startTimeOrigin;
/**
* 报警发生时间
*/
private String startTime;
/**
* 报警恢复时间
*/
private String endTimeOrigin;
/**
* 报警恢复时间
*/
private String endTime;
/**
* 报警发生时间
*/
private String startTimeForCharts;
/**
* 报警恢复时间
*/
private String endTimeForCharts;
/**
* 持续时间
*/
private String duration;
/**
* 拟解决方案
*/
private String solution;
/**
* 时区
*/
private Integer timeZoneOffset;
}

64
modules/qingyuan/src/main/java/com/thing/qingyuan/alert/excel/AlertExcel.java

@ -1,64 +0,0 @@
package com.thing.qingyuan.alert.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
/**
* 告警记录
*
* @author xc
* @since 3.0 2024-01-31
*/
@Data
@ContentRowHeight(20)
@HeadRowHeight(20)
@ColumnWidth(25)
public class AlertExcel {
@ExcelProperty(value = "主键", index = 0)
private Long plantAlertId;
@ExcelProperty(value = "电站id", index = 1)
private Long plantId;
@ExcelProperty(value = "设备id", index = 2)
private Long deviceId;
@ExcelProperty(value = "状态id:1.未处理;2.已处理;3.已恢复", index = 3)
private Integer status;
@ExcelProperty(value = "状态文本:1.未处理;2.已处理;3.已恢复", index = 4)
private String statusLabel;
@ExcelProperty(value = "采集器sn", index = 5)
private String collectorSn;
@ExcelProperty(value = "逆变器sn", index = 6)
private String deviceSn;
@ExcelProperty(value = "报警等级id: 01.故障 02.警告 03.提示", index = 7)
private Integer alertLevel;
@ExcelProperty(value = "报警等级文本: 01.故障 02.警告 03.提示", index = 8)
private String alertLevelLabel;
@ExcelProperty(value = "报警名称", index = 9)
private String alertName;
@ExcelProperty(value = "报警代码", index = 10)
private String alertCode;
@ExcelProperty(value = "报警影响面", index = 11)
private Integer alertEffect;
@ExcelProperty(value = "报警影响面文本", index = 12)
private String alertEffectLabel;
@ExcelProperty(value = "报警发生时间", index = 13)
private String startTimeOrigin;
@ExcelProperty(value = "报警发生时间", index = 14)
private String startTime;
@ExcelProperty(value = "报警恢复时间", index = 15)
private String endTimeOrigin;
@ExcelProperty(value = "报警恢复时间", index = 16)
private String endTime;
@ExcelProperty(value = "报警发生时间", index = 17)
private String startTimeForCharts;
@ExcelProperty(value = "报警恢复时间", index = 18)
private String endTimeForCharts;
@ExcelProperty(value = "持续时间", index = 19)
private String duration;
@ExcelProperty(value = "拟解决方案", index = 20)
private String solution;
@ExcelProperty(value = "时区", index = 21)
private Integer timeZoneOffset;
}

18
modules/qingyuan/src/main/java/com/thing/qingyuan/alert/mapper/AlertMapper.java

@ -1,18 +0,0 @@
package com.thing.qingyuan.alert.mapper;
import com.mybatisflex.annotation.UseDataSource;
import com.thing.qingyuan.alert.entity.AlertEntity;
import com.thing.common.orm.mapper.PowerBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 告警记录
*
* @author xc
* @since 3.0 2024-01-31
*/
@Mapper
@UseDataSource("systemCollect")
public interface AlertMapper extends PowerBaseMapper<AlertEntity> {
}

19
modules/qingyuan/src/main/java/com/thing/qingyuan/alert/service/AlertService.java

@ -1,19 +0,0 @@
package com.thing.qingyuan.alert.service;
import com.thing.qingyuan.alert.dto.AlertDTO;
import com.thing.qingyuan.alert.entity.AlertEntity;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.IBaseService;
import java.util.Map;
/**
* 告警记录
*
* @author xc
* @since 3.0 2024-01-31
*/
public interface AlertService extends IBaseService<AlertEntity> {
PageData<AlertDTO> handlePage(Map<String, Object> params);
}

97
modules/qingyuan/src/main/java/com/thing/qingyuan/alert/service/impl/AlertServiceImpl.java

@ -1,97 +0,0 @@
package com.thing.qingyuan.alert.service.impl;
import cn.hutool.core.map.MapUtil;
import com.mybatisflex.core.query.QueryWrapper;
import com.thing.qingyuan.alert.dto.AlertDTO;
import com.thing.qingyuan.alert.entity.AlertEntity;
import com.thing.qingyuan.alert.mapper.AlertMapper;
import com.thing.qingyuan.alert.service.AlertService;
import com.thing.qingyuan.basedevice.entity.DeviceEntity;
import com.thing.qingyuan.basedevice.service.IotDeviceService;
import com.thing.qingyuan.manageboard.entity.PlantEntity;
import com.thing.qingyuan.manageboard.service.PlantService;
import com.thing.common.core.web.response.PageData;
import com.thing.common.orm.service.impl.BaseServiceImpl;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import static com.thing.qingyuan.alert.entity.table.AlertEntityTableDef.ALERT_ENTITY;
/**
* 告警记录
*
* @author xc
* @since 3.0 2024-01-31
*/
@Service
@RequiredArgsConstructor
public class AlertServiceImpl extends BaseServiceImpl<AlertMapper, AlertEntity>
implements AlertService {
private final PlantService plantService;
private final IotDeviceService deviceService;
@Override
public QueryWrapper getWrapper(Map<String, Object> params) {
QueryWrapper wrapper = new QueryWrapper();
String alertName = MapUtil.getStr(params, "name");
Integer alertLevel = MapUtil.getInt(params, "level");
String statusLabel = MapUtil.getStr(params, "status");
String startTime = MapUtil.getStr(params, "startTime");
String endTime = MapUtil.getStr(params, "endTime");
String plantIds = MapUtil.getStr(params, "plantIds");
wrapper.eq(AlertEntity::getAlertName, alertName, StringUtils.isNotBlank(alertName))
.eq(AlertEntity::getAlertLevel, alertLevel, Objects.nonNull(alertLevel))
.eq(AlertEntity::getStatusLabel, statusLabel, StringUtils.isNotBlank(statusLabel));
if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
startTime += " UTC+08:00";
endTime += " UTC+08:00";
wrapper.and(ALERT_ENTITY.START_TIME.between(startTime, endTime)
.or(ALERT_ENTITY.END_TIME.between(startTime, endTime)));
}
if (StringUtils.isNotBlank(plantIds)) {
List<Long> plantIdList =
Arrays.stream(plantIds.split(","))
.map(Long::valueOf)
.toList();
wrapper.in(AlertEntity::getPlantId, plantIdList);
}
wrapper.isNotNull(AlertEntity::getStartTimeOrigin);
return wrapper;
}
@Override
public PageData<AlertDTO> handlePage(Map<String, Object> params) {
PageData<AlertDTO> pageData = getPageData(params, AlertDTO.class);
List<AlertDTO> list = pageData.getList();
if (list.isEmpty()) {
return pageData;
}
Set<Long> plantIds = list.stream().map(AlertDTO::getPlantId).collect(Collectors.toSet());
Set<Long> deviceIds = list.stream().map(AlertDTO::getDeviceId).collect(Collectors.toSet());
Map<Long, String> plantMap =
plantService.getMapper().selectListByIds(plantIds).stream()
.collect(
Collectors.toMap(
PlantEntity::getPlantId, PlantEntity::getPlantName));
Map<Long, String> deviceMap =
deviceService.getMapper().selectListByIds(deviceIds).stream()
.filter(e -> Objects.nonNull(e.getAlias()))
.collect(
Collectors.toMap(
DeviceEntity::getDeviceId, DeviceEntity::getAlias));
list.forEach(
item -> {
item.setPlantName(plantMap.get(item.getPlantId()));
item.setDeviceName(deviceMap.get(item.getDeviceId()));
});
return pageData;
}
}

7
modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/controller/ManageBoardController.java

@ -1,7 +1,6 @@
package com.thing.qingyuan.manageboard.controller;
import com.mybatisflex.core.query.QueryWrapper;
import com.thing.qingyuan.alert.dto.AlertDTO;
import com.thing.qingyuan.basedevice.dto.DeviceDTO;
import com.thing.qingyuan.basedevice.entity.DeviceEntity;
import com.thing.qingyuan.basedevice.mapper.DeviceMapper;
@ -56,12 +55,6 @@ public class ManageBoardController {
return boardService.totalInfo();
}
@GetMapping ("alertList")
@Operation(summary="管理端主平台,光伏子平台-光伏项目告警记录列表")
private Result<List<AlertDTO>> alertList(){
return boardService.alertList();
}
@PostMapping ("findListByAttrCodeAndType")
@Operation(summary="管理端主平台,月/年得电量用量查询")
private Result<DataReq> findListByAttrCodeAndType(@RequestBody DataParam dataParam){

3
modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/ManageBoardService.java

@ -1,6 +1,5 @@
package com.thing.qingyuan.manageboard.service;
import com.thing.qingyuan.alert.dto.AlertDTO;
import com.thing.qingyuan.manageboard.dto.*;
import com.thing.qingyuan.screen.ScreenData;
import com.thing.common.core.web.response.Result;
@ -17,8 +16,6 @@ public interface ManageBoardService {
Result<TotalInfo> totalInfo();
Result<List<AlertDTO>> alertList();
Result<DataReq> findListByAttrCodeAndType(DataParam dataParam);
Result<List<YOYDataReq>> findYOYList(DataParam dataParam);

12
modules/qingyuan/src/main/java/com/thing/qingyuan/manageboard/service/impl/ManageBoardServiceImpl.java

@ -8,8 +8,6 @@ import com.thing.common.core.utils.DateTimeUtils;
import com.thing.common.core.web.response.Result;
import com.thing.common.data.tskv.TsKvDTO;
import com.thing.common.tskv.service.TsKvService;
import com.thing.qingyuan.alert.dto.AlertDTO;
import com.thing.qingyuan.alert.service.AlertService;
import com.thing.qingyuan.manageboard.dto.*;
import com.thing.qingyuan.manageboard.entity.PlantEntity;
import com.thing.qingyuan.manageboard.service.ManageBoardService;
@ -39,8 +37,6 @@ public class ManageBoardServiceImpl implements ManageBoardService {
private final TsKvService tskvService;
private final AlertService alertService;
private final IotThingDictService iotThingDictService;
@Override
public Result<List<ScreenData>> mapInfoByNameAndType(MapParam mapParam) {
@ -132,14 +128,6 @@ public class ManageBoardServiceImpl implements ManageBoardService {
}
@Override
public Result<List<AlertDTO>> alertList() {
List<AlertDTO> alertDTOS = alertService.listAs(new HashMap<>(),AlertDTO.class);
alertDTOS.sort((p1, p2) -> p2.getStartTime().compareTo(p1.getStartTime()));
return new Result<List<AlertDTO>>().ok(alertDTOS);
}
@Override
public Result<DataReq> findListByAttrCodeAndType(DataParam dataParam) {
DataReq req = new DataReq();

Loading…
Cancel
Save