Compare commits
21 Commits
88aa61d2db
...
0ca36be409
| Author | SHA1 | Date |
|---|---|---|
|
|
0ca36be409 | 2 months ago |
|
|
f42ba68fdc | 2 months ago |
|
|
c07a739911 | 2 months ago |
|
|
a6627716e5 | 2 months ago |
|
|
fd0323865b | 2 months ago |
|
|
d596b1fcf0 | 2 months ago |
|
|
c3ecd4ea72 | 2 months ago |
|
|
3683ed3779 | 3 months ago |
|
|
82fc7fe2c8 | 3 months ago |
|
|
bbbfa9c54f | 4 months ago |
|
|
8511dea90f | 4 months ago |
|
|
9575c2f5bd | 4 months ago |
|
|
0d03103873 | 4 months ago |
|
|
5854784fca | 4 months ago |
|
|
66a82465e3 | 5 months ago |
|
|
70fae8bb37 | 5 months ago |
|
|
9b6eda256e | 5 months ago |
|
|
8d6a08e5b1 | 5 months ago |
|
|
12882dca12 | 5 months ago |
|
|
653b1d0cd3 | 5 months ago |
|
|
1fd7f15c87 | 5 months ago |
83 changed files with 3010 additions and 249 deletions
@ -0,0 +1,95 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.DayReportvo.*; |
|||
import cn.iocoder.yudao.module.alert.dao.domain.DayReport; |
|||
import cn.iocoder.yudao.module.alert.dao.service.DayReportService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.ZoneId; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Tag(name = "日报") |
|||
@RestController |
|||
@RequestMapping("/alarm") |
|||
public class DayReportController { |
|||
private final DayReportService service; |
|||
|
|||
public DayReportController(DayReportService service) { |
|||
this.service = service; |
|||
} |
|||
@Operation(summary = "获取日报表数据") |
|||
@GetMapping("/daily-report") |
|||
public CommonResult<PageResult<AlarmDailyVO>> getDailyReport( |
|||
@RequestParam(required = false) String unit, |
|||
@RequestParam(required = false) String driverType, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date, |
|||
@RequestParam(defaultValue = "1") Integer pageNo, |
|||
@RequestParam(defaultValue = "10") Integer pageSize) { |
|||
|
|||
PageResult<DayReport> pageResult = service.getDailyAlarmData(unit, driverType, date, pageNo, pageSize); |
|||
List<AlarmDailyVO> vos = pageResult.getList().stream() |
|||
.map(this::convertToVO) |
|||
.collect(Collectors.toList()); |
|||
return CommonResult.success(new PageResult<>(vos, pageResult.getTotal())); |
|||
} |
|||
|
|||
private AlarmDailyVO convertToVO(DayReport domain) { |
|||
AlarmDailyVO vo = new AlarmDailyVO(); |
|||
vo.setId(domain.getId()); |
|||
vo.setInstanceName(domain.getInstanceName()); |
|||
vo.setTotalAlarms(domain.getTotalAlarms()); |
|||
vo.setHourCounts(domain.getHourCounts()); |
|||
vo.setAlarmDuration(domain.getAlarmDuration()); |
|||
vo.setHasDetails(true); // 添加详情标识
|
|||
return vo; |
|||
} |
|||
|
|||
@Operation(summary = "获取报警详情") |
|||
@GetMapping("/details/{instanceId}") |
|||
public CommonResult<List<AlarmDetailVO>> getDetails( |
|||
@PathVariable String instanceId, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) { |
|||
|
|||
List<AlarmDetailVO> details = service.getAlarmDetails(instanceId, date).stream() |
|||
.map(domain -> { |
|||
AlarmDetailVO vo = new AlarmDetailVO(); |
|||
vo.setTagname(domain.getTagname()); |
|||
vo.setAlarmcount(domain.getAlarmcount()); |
|||
vo.setAlarmtime(domain.getAlarmtime()); |
|||
return vo; |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
return CommonResult.success(details); |
|||
} |
|||
|
|||
@Operation(summary = "获取光字牌报警详情") |
|||
@GetMapping("/gzp-details/{gzpName}") |
|||
public CommonResult<List<GzpAlarmDetailVO>> getGzpDetails( |
|||
@PathVariable String gzpName, |
|||
@RequestParam String instanceId, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) { |
|||
|
|||
List<GzpAlarmDetailVO> details = service.getGzpAlarmDetails(gzpName, instanceId, date).stream() |
|||
.map(domain -> { |
|||
GzpAlarmDetailVO vo = new GzpAlarmDetailVO(); |
|||
vo.setGzpName(domain.getGzpName()); |
|||
vo.setStartTime(domain.getStartTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime()); |
|||
vo.setEndTime(domain.getEndTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime()); |
|||
vo.setDuration(domain.getExceedDuration()); |
|||
return vo; |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
return CommonResult.success(details); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.DayReportvo; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
@Schema(description = "报警日报表视图对象") |
|||
public class AlarmDailyVO { |
|||
@Schema(description = "实例ID", example = "mp_123456") |
|||
private String id; |
|||
|
|||
@Schema(description = "实例名称", example = "锅炉1号压力传感器") |
|||
private String instanceName; |
|||
|
|||
@Schema( description= "总报警次数", example = "42") |
|||
private Integer totalAlarms; |
|||
|
|||
@Schema(description = "各小时报警数量", example = "{\"hour_0\":10,\"hour_1\":20}") |
|||
private Map<String, Integer> hourCounts; |
|||
|
|||
@Schema(description = "总报警时长(秒)", example = "8130") |
|||
private Long alarmDuration; |
|||
@Schema(description = "是否可查看详情", example = "true") |
|||
private Boolean hasDetails; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.DayReportvo; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "报警详情视图对象") |
|||
public class AlarmDetailVO { |
|||
@Schema(description = "光字牌名称", example = "锅炉超压报警") |
|||
private String tagname; |
|||
|
|||
@Schema(description = "报警次数", example = "5") |
|||
private Integer alarmcount; |
|||
|
|||
@Schema(description = "报警时长(秒)", example = "1510") |
|||
private Long alarmtime; |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.DayReportvo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.time.LocalDateTime; |
|||
|
|||
@Data |
|||
@Schema(description = "光字牌详情视图对象") |
|||
public class GzpAlarmDetailVO { |
|||
|
|||
@Schema(description = "光字牌名称", example = "锅炉压力高报警") |
|||
private String gzpName; |
|||
|
|||
@Schema(description = "开始时间", example = "2023-08-01 10:15:30") |
|||
private LocalDateTime startTime; |
|||
|
|||
@Schema(description = "结束时间", example = "2023-08-01 10:25:45") |
|||
private LocalDateTime endTime; |
|||
|
|||
@Schema(description = "超限时长(秒)", example = "615") |
|||
private Long duration; |
|||
} |
|||
@ -0,0 +1,61 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis; |
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.MonthReportvo.*; |
|||
import cn.iocoder.yudao.module.alert.dao.service.MonthReportService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.time.YearMonth; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Tag(name = "管理后台 - 月报分析") |
|||
@RestController |
|||
@RequestMapping("/alarm") |
|||
public class MonthReportController { |
|||
|
|||
private final MonthReportService monthlyReportService; |
|||
|
|||
public MonthReportController(MonthReportService monthlyReportService) { |
|||
this.monthlyReportService = monthlyReportService; |
|||
} |
|||
|
|||
@Operation(summary = "获取月报表数据") |
|||
@GetMapping("/monthly-report") |
|||
public CommonResult<PageResult<AlarmMonthlyVO>> getMonthlyReport( |
|||
@RequestParam(required = false) String unit, |
|||
@RequestParam(required = false) String driverType, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM") YearMonth month, |
|||
@RequestParam(defaultValue = "1") Integer pageNo, |
|||
@RequestParam(defaultValue = "10") Integer pageSize) { |
|||
|
|||
PageResult<AlarmMonthlyVO> result = monthlyReportService.getMonthlyAlarmData(unit, driverType, month, pageNo, pageSize); |
|||
return CommonResult.success(result); |
|||
} |
|||
|
|||
@Operation(summary = "获取报警详情") |
|||
@GetMapping("/monthly-details/{instanceId}") |
|||
public CommonResult<List<AlarmDetailVO>> getMonthlyDetails( |
|||
@PathVariable String instanceId, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM") YearMonth month) { |
|||
|
|||
List<AlarmDetailVO> details = monthlyReportService.getAlarmDetails(instanceId, month); |
|||
return CommonResult.success(details); |
|||
} |
|||
|
|||
@Operation(summary = "获取光字牌报警详情") |
|||
@GetMapping("/monthly-gzp-details/{gzpName}") |
|||
public CommonResult<List<GzpAlarmDetailVO>> getGzpMonthlyDetails( |
|||
@PathVariable String gzpName, |
|||
@RequestParam String instanceId, |
|||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM") YearMonth month) { |
|||
|
|||
List<GzpAlarmDetailVO> details = monthlyReportService.getGzpAlarmDetails(gzpName, instanceId, month); |
|||
return CommonResult.success(details); |
|||
} |
|||
} |
|||
|
|||
|
|||
@ -0,0 +1,18 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.MonthReportvo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "报警详情视图对象") |
|||
public class AlarmDetailVO { |
|||
|
|||
@Schema(description = "光字牌名称", example = "锅炉超压报警") |
|||
private String tagname; |
|||
|
|||
@Schema(description = "报警次数", example = "5") |
|||
private Integer alarmcount; |
|||
|
|||
@Schema(description = "报警时长(秒)", example = "1510") |
|||
private Long alarmtime; |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.MonthReportvo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
@Schema(description = "报警月报表视图对象") |
|||
public class AlarmMonthlyVO { |
|||
|
|||
@Schema(description = "实例ID", example = "mp_123456") |
|||
private String id; |
|||
|
|||
@Schema(description = "实例名称", example = "锅炉1号压力传感器") |
|||
private String instanceName; |
|||
|
|||
@Schema(description = "总报警次数", example = "42") |
|||
private Integer totalAlarms; |
|||
|
|||
@Schema(description = "各天报警数量", example = "{\"day_1\":10,\"day_2\":20}") |
|||
private Map<String, Integer> dayCounts; |
|||
|
|||
@Schema(description = "总报警时长(秒)", example = "8130") |
|||
private Long alarmDuration; |
|||
|
|||
@Schema(description = "是否可查看详情", example = "true") |
|||
private Boolean hasDetails; |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.MonthReportvo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import java.time.LocalDateTime; |
|||
|
|||
@Data |
|||
@Schema(description = "光字牌详情视图对象") |
|||
public class GzpAlarmDetailVO { |
|||
|
|||
@Schema(description = "光字牌名称", example = "锅炉压力高报警") |
|||
private String gzpName; |
|||
|
|||
@Schema(description = "开始时间", example = "2023-08-01 10:15:30") |
|||
private LocalDateTime startTime; |
|||
|
|||
@Schema(description = "结束时间", example = "2023-08-01 10:25:45") |
|||
private LocalDateTime endTime; |
|||
|
|||
@Schema(description = "超限时长(秒)", example = "615") |
|||
private Long duration; |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.YearReportvo.*; |
|||
import cn.iocoder.yudao.module.alert.dao.domain.YearReport; |
|||
import cn.iocoder.yudao.module.alert.dao.service.YearReportService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.time.ZoneId; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Tag(name = "年报") |
|||
@RestController |
|||
@RequestMapping("/alarm") |
|||
public class YearReportController { |
|||
private final YearReportService service; |
|||
|
|||
public YearReportController(YearReportService service) { |
|||
this.service = service; |
|||
} |
|||
|
|||
@Operation(summary = "获取年报表数据") |
|||
@GetMapping("/yearly-report") |
|||
public CommonResult<PageResult<AlarmYearlyVO>> getYearlyReport( |
|||
@RequestParam(required = false) String unit, |
|||
@RequestParam(required = false) String driverType, |
|||
@RequestParam(required = false) Integer year, |
|||
@RequestParam(defaultValue = "1") Integer pageNo, |
|||
@RequestParam(defaultValue = "10") Integer pageSize) { |
|||
|
|||
PageResult<YearReport> pageResult = service.getYearlyAlarmData(unit, driverType, year, pageNo, pageSize); |
|||
List<AlarmYearlyVO> vos = pageResult.getList().stream() |
|||
.map(this::convertToVO) |
|||
.collect(Collectors.toList()); |
|||
return CommonResult.success(new PageResult<>(vos, pageResult.getTotal())); |
|||
} |
|||
|
|||
private AlarmYearlyVO convertToVO(YearReport domain) { |
|||
AlarmYearlyVO vo = new AlarmYearlyVO(); |
|||
vo.setId(domain.getId()); |
|||
vo.setInstanceName(domain.getInstanceName()); |
|||
vo.setTotalAlarms(domain.getTotalAlarms()); |
|||
vo.setMonthCounts(domain.getMonthCounts()); |
|||
vo.setAlarmDuration(domain.getAlarmDuration()); |
|||
vo.setHasDetails(true); |
|||
return vo; |
|||
} |
|||
|
|||
@Operation(summary = "获取报警详情") |
|||
@GetMapping("/yearly-details/{instanceId}") |
|||
public CommonResult<List<AlarmDetailVO>> getYearlyDetails( |
|||
@PathVariable String instanceId, |
|||
@RequestParam(required = false) Integer year) { |
|||
|
|||
List<AlarmDetailVO> details = service.getAlarmDetails(instanceId, year).stream() |
|||
.map(domain -> { |
|||
AlarmDetailVO vo = new AlarmDetailVO(); |
|||
vo.setTagname(domain.getTagname()); |
|||
vo.setAlarmcount(domain.getAlarmcount()); |
|||
vo.setAlarmtime(domain.getAlarmtime()); |
|||
return vo; |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
return CommonResult.success(details); |
|||
} |
|||
|
|||
@Operation(summary = "获取光字牌报警详情") |
|||
@GetMapping("/yearly-gzp-details/{gzpName}") |
|||
public CommonResult<List<GzpAlarmDetailVO>> getGzpYearlyDetails( |
|||
@PathVariable String gzpName, |
|||
@RequestParam String instanceId, |
|||
@RequestParam(required = false) Integer year) { |
|||
|
|||
List<GzpAlarmDetailVO> details = service.getGzpAlarmDetails(gzpName, instanceId, year).stream() |
|||
.map(domain -> { |
|||
GzpAlarmDetailVO vo = new GzpAlarmDetailVO(); |
|||
vo.setGzpName(domain.getGzpName()); |
|||
vo.setStartTime(domain.getStartTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime()); |
|||
vo.setEndTime(domain.getEndTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime()); |
|||
vo.setDuration(domain.getExceedDuration()); |
|||
return vo; |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
return CommonResult.success(details); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.YearReportvo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(description = "报警详情视图对象") |
|||
public class AlarmDetailVO { |
|||
|
|||
@Schema(description = "光字牌名称", example = "锅炉超压报警") |
|||
private String tagname; |
|||
|
|||
@Schema(description = "报警次数", example = "5") |
|||
private Integer alarmcount; |
|||
|
|||
@Schema(description = "报警时长(秒)", example = "1510") |
|||
private Long alarmtime; |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.YearReportvo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
@Schema(description = "报警年报表视图对象") |
|||
public class AlarmYearlyVO { |
|||
@Schema(description = "实例ID", example = "mp_123456") |
|||
private String id; |
|||
|
|||
@Schema(description = "实例名称", example = "锅炉1号压力传感器") |
|||
private String instanceName; |
|||
|
|||
@Schema(description = "总报警次数", example = "42") |
|||
private Integer totalAlarms; |
|||
|
|||
@Schema(description = "各月报警数量", example = "{\"month_1\":10,\"month_2\":20}") |
|||
private Map<String, Integer> monthCounts; |
|||
|
|||
@Schema(description = "总报警时长(秒)", example = "8130") |
|||
private Long alarmDuration; |
|||
|
|||
@Schema(description = "是否可查看详情", example = "true") |
|||
private Boolean hasDetails; |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.YearReportvo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import java.time.LocalDateTime; |
|||
|
|||
@Data |
|||
@Schema(description = "光字牌详情视图对象") |
|||
public class GzpAlarmDetailVO { |
|||
|
|||
@Schema(description = "光字牌名称", example = "锅炉压力高报警") |
|||
private String gzpName; |
|||
|
|||
@Schema(description = "开始时间", example = "2023-08-01 10:15:30") |
|||
private LocalDateTime startTime; |
|||
|
|||
@Schema(description = "结束时间", example = "2023-08-01 10:25:45") |
|||
private LocalDateTime endTime; |
|||
|
|||
@Schema(description = "超限时长(秒)", example = "615") |
|||
private Long duration; |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.device; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.calcgroup.vo.CalcGroupPageReqVO; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.calcgroup.vo.CalcGroupRespVO; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.device.vo.DeviceRespVO; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.calcgroup.CalcGroupDO; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
|||
import cn.iocoder.yudao.module.alert.service.calcgroup.CalcGroupService; |
|||
import cn.iocoder.yudao.module.alert.service.device.DeviceService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.Comparator; |
|||
import java.util.List; |
|||
|
|||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
|||
|
|||
@Tag(name = "设备 - 设备首页") |
|||
@RestController |
|||
@RequestMapping("/device") |
|||
@Validated |
|||
public class DeviceController { |
|||
@Resource |
|||
private DeviceService deviceService; |
|||
|
|||
@GetMapping("/info") |
|||
@Operation(summary = "获取页面属性", description = "用于构造前端页面") |
|||
public CommonResult<DeviceRespVO> getdeviceInfo(Long id) { |
|||
DeviceDO list = deviceService.getDeviceInfo(id); |
|||
return success(BeanUtils.toBean(list, DeviceRespVO.class)); |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.device.vo; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Schema(description = "设备 - 设备首页") |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
public class DeviceRespVO { |
|||
@JsonProperty("ID") |
|||
|
|||
@Schema(description = "id", example = "id") |
|||
private Long id; |
|||
|
|||
@JsonProperty("Unit_ID") |
|||
@Schema(description = "机组id", example = "id") |
|||
|
|||
private Long unitId; |
|||
|
|||
@JsonProperty("System_ID") |
|||
|
|||
@Schema(description = "系统id", example = "id") |
|||
|
|||
private Long systemId; |
|||
|
|||
@JsonProperty("Name") |
|||
|
|||
@Schema(description = "页面名称", example = "yudao") |
|||
private String name; |
|||
|
|||
@JsonProperty("Page_Content") |
|||
|
|||
@Schema(description = "页面信息", example = "yudao") |
|||
private String pageContent; |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.instant; |
|||
|
|||
import cn.iocoder.yudao.module.alert.service.instant.InstantService; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@Tag(name = "运行中心 - 模型实例-回算") |
|||
@RestController |
|||
@RequestMapping("/alert/instant/calc") |
|||
@Validated |
|||
public class InstantCalcController { |
|||
@Resource |
|||
private InstantService instantService; |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.model; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.vo.ModelDataQuery; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.vo.ModelDataVO; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.vo.TimeRange; |
|||
import cn.iocoder.yudao.module.alert.service.model.ModelDataService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
/** |
|||
* @author chenjiale |
|||
* @version 1.0 |
|||
* @date 2023-09-05 22:08 |
|||
*/ |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@RequestMapping("/alert/model/data") |
|||
public class ModelDataController { |
|||
private final ModelDataService modelDataService; |
|||
|
|||
|
|||
@GetMapping("/{id}") |
|||
public CommonResult<ModelDataVO> getModelData(@PathVariable Integer id, ModelDataQuery query) { |
|||
return CommonResult.success(null); |
|||
} |
|||
|
|||
@PostMapping("/calculate/{id}") |
|||
public CommonResult<Boolean> calculate(@PathVariable Integer id, @RequestBody TimeRange timeRange) { |
|||
return CommonResult.success(null); |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.model.model; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class TrainTime { |
|||
/** |
|||
* 开始时间 |
|||
*/ |
|||
private String st; |
|||
|
|||
/** |
|||
* 结束时间 |
|||
*/ |
|||
private String et; |
|||
|
|||
/** |
|||
* 时长(秒) |
|||
*/ |
|||
private Integer duration; |
|||
|
|||
/** |
|||
* 采样数量 |
|||
*/ |
|||
private Integer number; |
|||
|
|||
/** |
|||
* 清洗样本数 |
|||
*/ |
|||
private Integer filter; |
|||
|
|||
/** |
|||
* 有效样本数 |
|||
*/ |
|||
private Integer mode; |
|||
|
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.model.vo; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
public class ModelInfoDetails { |
|||
|
|||
@JsonProperty("Train_X_min") |
|||
private List<Double> trainXMin; |
|||
|
|||
@JsonProperty("Train_X_max") |
|||
private List<Double> trainXMax; |
|||
|
|||
@JsonProperty("Train_X_std") |
|||
private List<Double> trainXStd; |
|||
|
|||
@JsonProperty("Train_X_mean") |
|||
private List<Double> trainXMean; |
|||
|
|||
@JsonProperty("Train_X_bais_max") |
|||
private List<List<Double>> trainXBaisMax; |
|||
|
|||
@JsonProperty("Train_X_bais_min") |
|||
private List<List<Double>> trainXBaisMin; |
|||
|
|||
@JsonProperty("Train_X_bais_mean") |
|||
private List<List<Double>> trainXBaisMean; |
|||
|
|||
@JsonProperty("QCUL_95") |
|||
private double qcul95; |
|||
|
|||
@JsonProperty("QCUL_99") |
|||
private double qcul99; |
|||
|
|||
@JsonProperty("QCUL_95_line") |
|||
private List<Double> qcul95Line; |
|||
|
|||
@JsonProperty("QCUL_99_line") |
|||
private List<Double> qcul99Line; |
|||
|
|||
@JsonProperty("T2CUL_95") |
|||
private double t2cul95; |
|||
|
|||
@JsonProperty("T2CUL_99") |
|||
private double t2cul99; |
|||
|
|||
@JsonProperty("T2CUL_95_line") |
|||
private List<Double> t2cul95Line; |
|||
|
|||
@JsonProperty("T2CUL_99_line") |
|||
private List<Double> t2cul99Line; |
|||
|
|||
@JsonProperty("Kesi_95") |
|||
private double kesi95; |
|||
|
|||
@JsonProperty("Kesi_99") |
|||
private double kesi99; |
|||
|
|||
@JsonProperty("Kesi_95_line") |
|||
private List<Double> kesi95Line; |
|||
|
|||
@JsonProperty("Kesi_99_line") |
|||
private List<Double> kesi99Line; |
|||
|
|||
@JsonProperty("COV") |
|||
private List<List<Double>> cov; |
|||
|
|||
@JsonProperty("K") |
|||
private int k; |
|||
|
|||
@JsonProperty("R") |
|||
private double r; |
|||
|
|||
@JsonProperty("featValue") |
|||
private List<Double> featValue; |
|||
|
|||
@JsonProperty("featVec") |
|||
private List<List<Double>> featVec; |
|||
|
|||
@JsonProperty("selectVec") |
|||
private List<List<Double>> selectVec; |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.model.vo; |
|||
|
|||
import cn.iocoder.yudao.module.alert.common.enums.Algorithm; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.model.Point; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.model.TrainTime; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.*; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@Builder |
|||
@ToString |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class ModelInitVO { |
|||
/** |
|||
* id |
|||
*/ |
|||
private Integer id; |
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String founder; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date createTime; |
|||
|
|||
/** |
|||
* 运行条件 |
|||
*/ |
|||
private String condition; |
|||
|
|||
/** |
|||
* 名称 |
|||
*/ |
|||
private String modelName; |
|||
|
|||
private String description; |
|||
|
|||
|
|||
private List<Point> pointInfo; |
|||
|
|||
private List<TrainTime> trainTime; |
|||
|
|||
private Algorithm algorithm; |
|||
|
|||
private Integer systemId; |
|||
|
|||
private Integer sampling; |
|||
|
|||
private BigDecimal rate; |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.model.vo; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class ModelTestData { |
|||
private List<List<Double>> sampleData; |
|||
private List<List<Double>> reconData; |
|||
private List<List<Double>> errorData; |
|||
private Integer R; |
|||
private List<Double> SPE; |
|||
private List<List<Integer>> paraState; |
|||
private String time; |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
package cn.iocoder.yudao.module.alert.controller.admin.model.vo; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class TrainInfo { |
|||
@JsonProperty("Model_info") |
|||
private ModelInfoDetails modelInfo; |
|||
|
|||
@JsonProperty("Model_type") |
|||
private String modelType; |
|||
|
|||
@JsonProperty("BeforeCleanSamNum") |
|||
private int beforeCleanSamNum; |
|||
|
|||
@JsonProperty("AfterCleanSamNum") |
|||
private int afterCleanSamNum; |
|||
|
|||
@JsonProperty("CleanOrNot") |
|||
private boolean cleanOrNot; |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
package cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import lombok.Data; |
|||
import java.util.Date; |
|||
@Data |
|||
public class dayDO { |
|||
private Long id; |
|||
private String warnId; |
|||
private Date startTime; |
|||
private Date endTime; |
|||
|
|||
@TableField("超限时长") |
|||
private Long exceedDuration; // 超限时长(秒)
|
|||
|
|||
private String year; |
|||
|
|||
private Integer month; |
|||
private Integer day; |
|||
|
|||
private Integer hour; |
|||
private String timeFlag; |
|||
|
|||
private String mpId; |
|||
private String unitId; |
|||
|
|||
private String systemTypeName; |
|||
private String systemName; |
|||
private String systemTypeId; |
|||
private String systemId; |
|||
private String algorithmId; |
|||
private String modelId; |
|||
private String mpName; // 实例名称
|
|||
private String alarmTypeId; |
|||
|
|||
@TableField("UNIT") |
|||
private String unit; // 机组
|
|||
|
|||
private String alarmLevelName; |
|||
private String alarmModelRuleName; |
|||
private String pointId; |
|||
private String pointName; |
|||
private String modelOrRuleName; |
|||
private String warnStatus1; |
|||
private String pointOrModel; |
|||
private String gzpName; // 光字牌名称
|
|||
private Integer alarmCount; |
|||
@TableField("Algorithm_ShortName") |
|||
private String algorithmShortName; |
|||
@TableField("Confirmed") |
|||
private Boolean confirmed; |
|||
@TableField("SUGGESTION") |
|||
private String suggestion; |
|||
|
|||
private Date confirmTime; |
|||
private String modelName; |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
package cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
@TableName("WARN_HISTORY_VIEW") |
|||
public class monthDO { |
|||
private Long id; |
|||
private String warnId; |
|||
private Date startTime; |
|||
private Date endTime; |
|||
|
|||
@TableField("超限时长") |
|||
private Long exceedDuration; |
|||
|
|||
private String year; |
|||
private Integer month; |
|||
private Integer day; |
|||
private Integer hour; |
|||
private String timeFlag; |
|||
|
|||
private String mpId; |
|||
private String unitId; |
|||
|
|||
private String systemTypeName; |
|||
private String systemName; |
|||
private String systemTypeId; |
|||
private String systemId; |
|||
private String algorithmId; |
|||
private String modelId; |
|||
|
|||
@TableField("mpName") |
|||
private String mpName; |
|||
|
|||
private String alarmTypeId; |
|||
|
|||
@TableField("UNIT") |
|||
private String unit; |
|||
|
|||
private String alarmLevelName; |
|||
private String alarmModelRuleName; |
|||
private String pointId; |
|||
private String pointName; |
|||
private String modelOrRuleName; |
|||
private String warnStatus1; |
|||
private String pointOrModel; |
|||
|
|||
@TableField("gzpName") |
|||
private String gzpName; |
|||
|
|||
private Integer alarmCount; |
|||
|
|||
@TableField("Algorithm_ShortName") |
|||
private String algorithmShortName; |
|||
|
|||
@TableField("Confirmed") |
|||
private Boolean confirmed; |
|||
|
|||
@TableField("SUGGESTION") |
|||
private String suggestion; |
|||
|
|||
private Date confirmTime; |
|||
private String modelName; |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import lombok.Data; |
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class yearDO { |
|||
private Long id; |
|||
private String warnId; |
|||
private Date startTime; |
|||
private Date endTime; |
|||
|
|||
@TableField("超限时长") |
|||
private Long exceedDuration; // 超限时长(秒)
|
|||
|
|||
private Integer year; |
|||
private Integer month; |
|||
private Integer day; |
|||
private Integer hour; |
|||
private String timeFlag; |
|||
|
|||
private String mpId; |
|||
private String unitId; |
|||
|
|||
private String systemTypeName; |
|||
private String systemName; |
|||
private String systemTypeId; |
|||
private String systemId; |
|||
private String algorithmId; |
|||
private String modelId; |
|||
private String mpName; // 实例名称
|
|||
private String alarmTypeId; |
|||
|
|||
@TableField("UNIT") |
|||
private String unit; // 机组
|
|||
|
|||
private String alarmLevelName; |
|||
private String alarmModelRuleName; |
|||
private String pointId; |
|||
private String pointName; |
|||
private String modelOrRuleName; |
|||
private String warnStatus1; |
|||
private String pointOrModel; |
|||
private String gzpName; // 光字牌名称
|
|||
private Integer alarmCount; |
|||
|
|||
@TableField("Algorithm_ShortName") |
|||
private String algorithmShortName; |
|||
|
|||
@TableField("Confirmed") |
|||
private Boolean confirmed; |
|||
|
|||
@TableField("SUGGESTION") |
|||
private String suggestion; |
|||
|
|||
private Date confirmTime; |
|||
private String modelName; |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
package cn.iocoder.yudao.module.alert.dal.dataobject.device; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.annotation.KeySequence; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonAlias; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@DS("slave") |
|||
@TableName(value = "Page_Display", autoResultMap = true) |
|||
@KeySequence("system_role_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
public class DeviceDO { |
|||
@TableId("ID") |
|||
|
|||
@Schema(description = "id", example = "id") |
|||
private Long id; |
|||
|
|||
@TableField("Unit_ID") |
|||
@Schema(description = "机组id", example = "id") |
|||
|
|||
private Long unitId; |
|||
|
|||
@TableField("System_ID") |
|||
|
|||
@Schema(description = "系统id", example = "id") |
|||
|
|||
private Long systemId; |
|||
|
|||
@TableField("Name") |
|||
|
|||
@Schema(description = "页面名称", example = "yudao") |
|||
private String name; |
|||
|
|||
@TableField("Page_Content") |
|||
|
|||
@Schema(description = "页面信息", example = "yudao") |
|||
private String pageContent; |
|||
|
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
package cn.iocoder.yudao.module.alert.dal.mysql.device; |
|||
|
|||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantTableDO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface DeviceMapper extends BaseMapperX<DeviceDO> { |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.domain; |
|||
import lombok.Data; |
|||
import java.util.Map; |
|||
@Data |
|||
public class DayReport { |
|||
private String id; |
|||
private String instanceName; |
|||
private Integer totalAlarms; |
|||
private Long alarmDuration; |
|||
private Map<String, Integer> hourCounts; |
|||
|
|||
// 详情用
|
|||
private String tagname; |
|||
private Integer alarmcount; |
|||
private Long alarmtime; |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.domain; |
|||
|
|||
import lombok.Data; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
public class MonthReport { |
|||
private String id; |
|||
private String instanceName; |
|||
private Integer totalAlarms; |
|||
private Long alarmDuration; |
|||
private Map<String, Integer> dayCounts; |
|||
|
|||
// 详情用字段
|
|||
private String tagname; |
|||
private Integer alarmcount; |
|||
private Long alarmtime; |
|||
|
|||
// 光字牌详情用字段
|
|||
private String gzpName; |
|||
private java.util.Date startTime; |
|||
private java.util.Date endTime; |
|||
private Long exceedDuration; |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.domain; |
|||
|
|||
import lombok.Data; |
|||
import java.util.Map; |
|||
|
|||
@Data |
|||
public class YearReport { |
|||
private String id; |
|||
private String instanceName; |
|||
private Integer totalAlarms; |
|||
private Long alarmDuration; |
|||
private Map<String, Integer> monthCounts; |
|||
|
|||
// 详情用
|
|||
private String tagname; |
|||
private Integer alarmcount; |
|||
private Long alarmtime; |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.mapper; |
|||
|
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.dayDO; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface DayReportMapper extends BaseMapper<dayDO> { |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"<where>" + |
|||
" <if test='unit != null'> AND unit_id = #{unit} </if>" + |
|||
" <if test='driverType != null'> AND model_or_rule_name = #{driverType} </if>" + |
|||
" <if test='date != null'> " + |
|||
" AND YY = YEAR(#{date}) AND MM = MONTH(#{date}) AND DD = DAY(#{date}) " + |
|||
" </if>" + |
|||
"</where>" + |
|||
"</script>") |
|||
List<dayDO> selectByCondition( |
|||
@Param("unit") String unit, |
|||
@Param("driverType") String driverType, |
|||
@Param("date") String date); |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"WHERE mp_id = #{instanceId} " + |
|||
"<if test='date != null'> " + |
|||
" AND YY = YEAR(#{date}) AND MM = MONTH(#{date}) AND DD = DAY(#{date}) " + |
|||
"</if>" + |
|||
"</script>") |
|||
List<dayDO> selectDetailsByInstanceId( |
|||
@Param("instanceId") String instanceId, |
|||
@Param("date") String date); |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"WHERE mp_id = #{instanceId} AND gzp_name = #{gzpName} " + |
|||
"<if test='date != null'> " + |
|||
" AND YY = YEAR(#{date}) AND MM = MONTH(#{date}) AND DD = DAY(#{date}) " + |
|||
"</if>" + |
|||
"</script>") |
|||
List<dayDO> selectGzpDetails( |
|||
@Param("gzpName") String gzpName, |
|||
@Param("instanceId") String instanceId, |
|||
@Param("date") String date); |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.mapper; |
|||
|
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.monthDO; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface MonthReportMapper extends BaseMapper<monthDO>{ |
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"<where>" + |
|||
" <if test='unit != null'> AND unit_id = #{unit} </if>" + |
|||
" <if test='driverType != null'> AND model_or_rule_name = #{driverType} </if>" + |
|||
" <if test='year != null and month != null'> " + |
|||
" AND YY = #{year} AND MM = #{month} " + |
|||
" </if>" + |
|||
"</where>" + |
|||
"</script>") |
|||
List<monthDO> selectByCondition( |
|||
@Param("unit") String unit, |
|||
@Param("driverType") String driverType, |
|||
@Param("year") Integer year, |
|||
@Param("month") Integer month); |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"WHERE mp_id = #{instanceId} " + |
|||
"<if test='year != null and month != null'> " + |
|||
" AND YY = #{year} AND MM = #{month} " + |
|||
"</if>" + |
|||
"</script>") |
|||
List<monthDO> selectDetailsByInstanceId( |
|||
@Param("instanceId") String instanceId, |
|||
@Param("year") Integer year, |
|||
@Param("month") Integer month); |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"WHERE mp_id = #{instanceId} AND gzp_name = #{gzpName} " + |
|||
"<if test='year != null and month != null'> " + |
|||
" AND YY = #{year} AND MM = #{month} " + |
|||
"</if>" + |
|||
"</script>") |
|||
List<monthDO> selectGzpDetails( |
|||
@Param("gzpName") String gzpName, |
|||
@Param("instanceId") String instanceId, |
|||
@Param("year") Integer year, |
|||
@Param("month") Integer month); |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.mapper; |
|||
|
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.yearDO; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface YearReportMapper extends BaseMapper<yearDO> { |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"<where>" + |
|||
" <if test='unit != null'> AND unit_id = #{unit} </if>" + |
|||
" <if test='driverType != null'> AND MODEL_OR_RULE_NAME = #{driverType} </if>" + |
|||
" <if test='year != null'> AND YY = #{year} </if>" + |
|||
"</where>" + |
|||
"</script>") |
|||
List<yearDO> selectByCondition( |
|||
@Param("unit") String unit, |
|||
@Param("driverType") String driverType, |
|||
@Param("year") Integer year); |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"WHERE mp_id = #{instanceId} " + |
|||
"<if test='year != null'> AND YY = #{year} </if>" + |
|||
"</script>") |
|||
List<yearDO> selectDetailsByInstanceId( |
|||
@Param("instanceId") String instanceId, |
|||
@Param("year") Integer year); |
|||
|
|||
@Select("<script>" + |
|||
"SELECT * FROM WARN_HISTORY_VIEW " + |
|||
"WHERE mp_id = #{instanceId} AND gzp_name = #{gzpName} " + |
|||
"<if test='year != null'> AND YY = #{year} </if>" + |
|||
"</script>") |
|||
List<yearDO> selectGzpDetails( |
|||
@Param("gzpName") String gzpName, |
|||
@Param("instanceId") String instanceId, |
|||
@Param("year") Integer year); |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.service; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.dayDO; |
|||
import cn.iocoder.yudao.module.alert.dao.domain.DayReport; |
|||
import java.time.LocalDate; |
|||
import java.util.List; |
|||
|
|||
public interface DayReportService { |
|||
/** |
|||
* 获取日报表数据(分页版本) |
|||
*/ |
|||
PageResult<DayReport> getDailyAlarmData(String unit, String driverType, LocalDate date, int pageNo, int pageSize); |
|||
|
|||
/** |
|||
* 获取报警详情 |
|||
*/ |
|||
List<DayReport> getAlarmDetails(String instanceId, LocalDate date); |
|||
/** |
|||
* @deprecated 使用分页版本 {@link #getDailyAlarmData(String, String, LocalDate, int, int)} 代替 |
|||
*/ |
|||
@Deprecated |
|||
default List<DayReport> getDailyAlarmData(String unit, String driverType, String date) { |
|||
return getDailyAlarmData(unit, driverType, date != null ? LocalDate.parse(date) : null, 1, Integer.MAX_VALUE).getList(); |
|||
} |
|||
|
|||
/** |
|||
* 获取光字牌报警详情 |
|||
*/ |
|||
List<dayDO> getGzpAlarmDetails(String gzpName, String instanceId, LocalDate date); |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.service; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.MonthReportvo.*; |
|||
import java.time.YearMonth; |
|||
import java.util.List; |
|||
public interface MonthReportService { |
|||
/** |
|||
* 获取月报表数据 |
|||
*/ |
|||
PageResult<AlarmMonthlyVO> getMonthlyAlarmData(String unit, String driverType, YearMonth month, int pageNo, int pageSize); |
|||
|
|||
/** |
|||
* 获取报警详情 |
|||
*/ |
|||
List<AlarmDetailVO> getAlarmDetails(String instanceId, YearMonth month); |
|||
|
|||
/** |
|||
* 获取光字牌报警详情 |
|||
*/ |
|||
List<GzpAlarmDetailVO> getGzpAlarmDetails(String gzpName, String instanceId, YearMonth month); |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.service; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.yearDO; |
|||
import cn.iocoder.yudao.module.alert.dao.domain.YearReport; |
|||
import java.util.List; |
|||
|
|||
public interface YearReportService { |
|||
/** |
|||
* 获取年报表数据(分页版本) |
|||
*/ |
|||
PageResult<YearReport> getYearlyAlarmData(String unit, String driverType, Integer year, int pageNo, int pageSize); |
|||
|
|||
/** |
|||
* 获取报警详情 |
|||
*/ |
|||
List<YearReport> getAlarmDetails(String instanceId, Integer year); |
|||
|
|||
/** |
|||
* 获取光字牌报警详情 |
|||
*/ |
|||
List<yearDO> getGzpAlarmDetails(String gzpName, String instanceId, Integer year); |
|||
} |
|||
@ -0,0 +1,156 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.service.impl; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.dayDO; |
|||
import cn.iocoder.yudao.module.alert.dao.domain.DayReport; |
|||
import cn.iocoder.yudao.module.alert.dao.mapper.DayReportMapper; |
|||
import cn.iocoder.yudao.module.alert.dao.service.DayReportService; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.time.*; |
|||
import java.time.format.DateTimeFormatter; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class DayReportServiceImpl implements DayReportService { |
|||
|
|||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.BASIC_ISO_DATE; |
|||
|
|||
private final DayReportMapper dayReportMapper; |
|||
|
|||
public DayReportServiceImpl(DayReportMapper dayReportMapper) { |
|||
this.dayReportMapper = dayReportMapper; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public PageResult<DayReport> getDailyAlarmData(String unit, String driverType, LocalDate date, int pageNo, int pageSize) { |
|||
Page<dayDO> page = new Page<>(pageNo, pageSize); |
|||
String formattedDate = (date != null) ? date.format(DATE_FORMATTER) : null; |
|||
|
|||
List<dayDO> rawData = dayReportMapper.selectByCondition( unit, driverType, formattedDate); |
|||
if (CollectionUtils.isEmpty(rawData)) { |
|||
return new PageResult<>(Collections.emptyList(), 0L); |
|||
} |
|||
|
|||
// 动态计算 exceedDuration、year、month、day、hour
|
|||
rawData.forEach(this::calculateDynamicFields); |
|||
|
|||
Map<String, List<dayDO>> groupByInstance = rawData.stream() |
|||
.collect(Collectors.groupingBy(dayDO::getMpName)); |
|||
|
|||
// 4. 获取所有 instanceName 并按分页截取
|
|||
List<String> instanceNames = new ArrayList<>(groupByInstance.keySet()); |
|||
Long totalInstances = (long) instanceNames.size(); |
|||
|
|||
// 5. 计算分页范围
|
|||
int fromIndex = (pageNo - 1) * pageSize; |
|||
if (fromIndex >= totalInstances) { |
|||
return new PageResult<>(Collections.emptyList(), (long) totalInstances); |
|||
} |
|||
int toIndex = (int) Math.min(fromIndex + pageSize, totalInstances); |
|||
List<String> pagedInstanceNames = instanceNames.subList(fromIndex, toIndex); |
|||
|
|||
// 6. 构建分页结果
|
|||
List<DayReport> result = pagedInstanceNames.stream() |
|||
.map(instanceName -> { |
|||
List<dayDO> instanceData = groupByInstance.get(instanceName); |
|||
return buildDayReport(instanceName, instanceData); |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
|
|||
return new PageResult<>(result, (Long) totalInstances); |
|||
} |
|||
|
|||
@Override |
|||
public List<DayReport> getAlarmDetails(String instanceId, LocalDate date) { |
|||
// 1. 查询原始数据(按 instanceId + 日期)
|
|||
List<dayDO> rawData = dayReportMapper.selectDetailsByInstanceId( |
|||
instanceId, |
|||
date != null ? date.format(DATE_FORMATTER) : null |
|||
); |
|||
|
|||
if (CollectionUtils.isEmpty(rawData)) { |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
// 2. 动态计算 exceedDuration
|
|||
rawData.forEach(this::calculateDynamicFields); |
|||
|
|||
// 3. 按 GZP_NAME 分组
|
|||
Map<String, List<dayDO>> groupByGzp = rawData.stream() |
|||
.collect(Collectors.groupingBy(dayDO::getGzpName)); |
|||
|
|||
// 4. 构建返回结果
|
|||
List<DayReport> result = new ArrayList<>(groupByGzp.size()); |
|||
groupByGzp.forEach((gzpName, gzpData) -> { |
|||
DayReport domain = new DayReport(); |
|||
domain.setTagname(gzpName); |
|||
domain.setAlarmcount(gzpData.size()); |
|||
domain.setAlarmtime(gzpData.stream() |
|||
.mapToLong(item -> item.getExceedDuration() != null ? item.getExceedDuration() : 0L) |
|||
.sum()); |
|||
result.add(domain); |
|||
}); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Override |
|||
public List<dayDO> getGzpAlarmDetails(String gzpName, String instanceId, LocalDate date) { |
|||
String formattedDate = (date != null) ? date.format(DATE_FORMATTER) : null; |
|||
List<dayDO> rawData = dayReportMapper.selectGzpDetails(gzpName, instanceId, formattedDate); |
|||
rawData.forEach(this::calculateDynamicFields); |
|||
return rawData; |
|||
} |
|||
/** |
|||
* 动态计算字段:exceedDuration、year、month、day、hour |
|||
*/ |
|||
private void calculateDynamicFields(dayDO item) { |
|||
if (item.getStartTime() != null && item.getEndTime() != null) { |
|||
// 计算超限时长(秒)
|
|||
long durationSeconds = Duration.between( |
|||
item.getStartTime().toInstant(), |
|||
item.getEndTime().toInstant() |
|||
).getSeconds(); |
|||
item.setExceedDuration(durationSeconds); |
|||
|
|||
// 计算年、月、日、小时
|
|||
LocalDateTime localStart = item.getStartTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime(); |
|||
item.setYear(String.valueOf(localStart.getYear())); |
|||
item.setMonth(localStart.getMonthValue()); |
|||
item.setDay(localStart.getDayOfMonth()); |
|||
item.setHour(localStart.getHour()); |
|||
|
|||
} |
|||
} |
|||
|
|||
private DayReport buildDayReport(String instanceName, List<dayDO> instanceData) { |
|||
DayReport domain = new DayReport(); |
|||
domain.setId(instanceData.get(0).getMpId()); |
|||
domain.setInstanceName(instanceName); |
|||
domain.setTotalAlarms(instanceData.size()); |
|||
domain.setAlarmDuration(instanceData.stream() |
|||
.mapToLong(item -> item.getExceedDuration() != null ? item.getExceedDuration() : 0) |
|||
.sum()); |
|||
domain.setHourCounts(calculateHourlyCounts(instanceData)); |
|||
return domain; |
|||
} |
|||
|
|||
private Map<String, Integer> calculateHourlyCounts(List<dayDO> data) { |
|||
Map<String, Integer> hourCounts = new HashMap<>(24); |
|||
for (int i = 0; i < 24; i++) { |
|||
final int hour = i; |
|||
hourCounts.put("hour_" + i, (int) data.stream() |
|||
.filter(item -> item.getHour() != null && item.getHour() == hour) |
|||
.count()); |
|||
|
|||
} |
|||
return hourCounts; |
|||
} |
|||
} |
|||
@ -0,0 +1,169 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.service.impl; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.alarm.analysis.MonthReportvo.*; |
|||
import cn.iocoder.yudao.module.alert.dao.service.MonthReportService; |
|||
import cn.iocoder.yudao.module.alert.dao.mapper.MonthReportMapper; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.monthDO; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.time.*; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class MonthReportServiceImpl implements MonthReportService { |
|||
private final MonthReportMapper monthlyReportMapper; |
|||
|
|||
public MonthReportServiceImpl(MonthReportMapper monthlyReportMapper) { |
|||
this.monthlyReportMapper = monthlyReportMapper; |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<AlarmMonthlyVO> getMonthlyAlarmData(String unit, String driverType, YearMonth month, int pageNo, int pageSize) { |
|||
|
|||
Integer year = month != null ? month.getYear() : null; |
|||
Integer monthValue = month != null ? month.getMonthValue() : null; |
|||
List<monthDO> rawData = monthlyReportMapper.selectByCondition(unit, driverType, year, monthValue); |
|||
if (CollectionUtils.isEmpty(rawData)) { |
|||
return new PageResult<>(Collections.emptyList(), 0L); |
|||
} |
|||
// 动态计算字段
|
|||
rawData.forEach(this::calculateDynamicFields); |
|||
|
|||
// 按实例名称分组
|
|||
Map<String, List<monthDO>> groupByInstance = rawData.stream() |
|||
.collect(Collectors.groupingBy(monthDO::getMpName)); |
|||
|
|||
List<String> instanceNames = new ArrayList<>(groupByInstance.keySet()); |
|||
Long totalInstances = (long) instanceNames.size(); |
|||
|
|||
// 分页处理
|
|||
int fromIndex = (pageNo - 1) * pageSize; |
|||
if (fromIndex >= totalInstances) { |
|||
return new PageResult<>(Collections.emptyList(), totalInstances); |
|||
} |
|||
int toIndex = (int) Math.min(fromIndex + pageSize, totalInstances); |
|||
List<String> pagedInstanceNames = instanceNames.subList(fromIndex, toIndex); |
|||
// 构建结果
|
|||
List<AlarmMonthlyVO> result = pagedInstanceNames.stream() |
|||
.map(instanceName -> { |
|||
List<monthDO> instanceData = groupByInstance.get(instanceName); |
|||
return buildMonthlyVO(instanceName, instanceData, month); |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
|
|||
return new PageResult<>(result, totalInstances); |
|||
} |
|||
|
|||
@Override |
|||
public List<AlarmDetailVO> getAlarmDetails(String instanceId, YearMonth month) { |
|||
Integer year = month != null ? month.getYear() : null; |
|||
Integer monthValue = month != null ? month.getMonthValue() : null; |
|||
|
|||
List<monthDO> rawData = monthlyReportMapper.selectDetailsByInstanceId(instanceId, year, monthValue); |
|||
if (CollectionUtils.isEmpty(rawData)) { |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
for (monthDO rawDatum : rawData) { |
|||
calculateDynamicFields(rawDatum); |
|||
} |
|||
|
|||
// 按光字牌名称分组
|
|||
Map<String, List<monthDO>> groupByGzp = rawData.stream() |
|||
.collect(Collectors.groupingBy(monthDO::getGzpName)); |
|||
|
|||
List<AlarmDetailVO> result = new ArrayList<>(); |
|||
groupByGzp.forEach((gzpName, gzpData) -> { |
|||
AlarmDetailVO vo = new AlarmDetailVO(); |
|||
vo.setTagname(gzpName); |
|||
vo.setAlarmcount(gzpData.size()); |
|||
vo.setAlarmtime(gzpData.stream() |
|||
.mapToLong(item -> item.getExceedDuration() != null ? item.getExceedDuration() : 0L) |
|||
.sum()); |
|||
result.add(vo); |
|||
}); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Override |
|||
public List<GzpAlarmDetailVO> getGzpAlarmDetails(String gzpName, String instanceId, YearMonth month) { |
|||
Integer year = month != null ? month.getYear() : null; |
|||
Integer monthValue = month != null ? month.getMonthValue() : null; |
|||
|
|||
List<monthDO> rawData = monthlyReportMapper.selectGzpDetails(gzpName, instanceId, year, monthValue); |
|||
if (CollectionUtils.isEmpty(rawData)) { |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
rawData.forEach(this::calculateDynamicFields); |
|||
|
|||
return rawData.stream() |
|||
.map(this::convertToGzpDetailVO) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
|
|||
private void calculateDynamicFields(monthDO item) { |
|||
if (item.getStartTime() != null && item.getEndTime() != null) { |
|||
// 计算超限时长(秒)
|
|||
long durationSeconds = Duration.between( |
|||
item.getStartTime().toInstant(), |
|||
item.getEndTime().toInstant() |
|||
).getSeconds(); |
|||
item.setExceedDuration(durationSeconds); |
|||
|
|||
// 计算年、月、日
|
|||
LocalDateTime localStart = item.getStartTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime(); |
|||
item.setYear(String.valueOf(localStart.getYear())); |
|||
item.setMonth(localStart.getMonthValue()); |
|||
item.setDay(localStart.getDayOfMonth()); |
|||
item.setHour(localStart.getHour()); |
|||
} |
|||
} |
|||
|
|||
private AlarmMonthlyVO buildMonthlyVO(String instanceName, List<monthDO> instanceData, YearMonth month) { |
|||
AlarmMonthlyVO vo = new AlarmMonthlyVO(); |
|||
vo.setId(instanceData.get(0).getMpId()); |
|||
vo.setInstanceName(instanceName); |
|||
vo.setTotalAlarms(instanceData.size()); |
|||
vo.setAlarmDuration(instanceData.stream() |
|||
.mapToLong(item -> item.getExceedDuration() != null ? item.getExceedDuration() : 0L) |
|||
.sum()); |
|||
vo.setDayCounts(calculateDailyCounts(instanceData, month)); |
|||
vo.setHasDetails(true); |
|||
return vo; |
|||
} |
|||
|
|||
private Map<String, Integer> calculateDailyCounts(List<monthDO> data, YearMonth month) { |
|||
int daysInMonth = month != null ? month.lengthOfMonth() : YearMonth.now().lengthOfMonth(); |
|||
Map<String, Integer> dayCounts = new HashMap<>(daysInMonth); |
|||
|
|||
for (int day = 1; day <= daysInMonth; day++) { |
|||
final int targetDay = day; |
|||
long count = data.stream() |
|||
.filter(item -> item.getDay() != null && item.getDay() == targetDay) |
|||
.count(); |
|||
dayCounts.put("day_" + day, (int) count); |
|||
} |
|||
return dayCounts; |
|||
} |
|||
private GzpAlarmDetailVO convertToGzpDetailVO(monthDO domain) { |
|||
GzpAlarmDetailVO vo = new GzpAlarmDetailVO(); |
|||
vo.setGzpName(domain.getGzpName()); |
|||
vo.setStartTime(domain.getStartTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime()); |
|||
vo.setEndTime(domain.getEndTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime()); |
|||
vo.setDuration(domain.getExceedDuration()); |
|||
return vo; |
|||
} |
|||
} |
|||
@ -0,0 +1,133 @@ |
|||
package cn.iocoder.yudao.module.alert.dao.service.impl; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.dao.domain.YearReport; |
|||
import cn.iocoder.yudao.module.alert.dao.mapper.YearReportMapper; |
|||
import cn.iocoder.yudao.module.alert.dao.service.YearReportService; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.alarm.analysis.yearDO; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.time.Duration; |
|||
import java.time.LocalDateTime; |
|||
import java.time.ZoneId; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class YearReportServiceImpl implements YearReportService { |
|||
|
|||
private final YearReportMapper yearReportMapper; |
|||
|
|||
public YearReportServiceImpl(YearReportMapper yearReportMapper) { |
|||
this.yearReportMapper = yearReportMapper; |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<YearReport> getYearlyAlarmData(String unit, String driverType, Integer year, int pageNo, int pageSize) { |
|||
System.out.printf("查询参数 - unit: %s, driverType: %s, year: %d, pageNo: {}, pageSize: {}", |
|||
unit, driverType, year, pageNo, pageSize); |
|||
|
|||
List<yearDO> rawData = yearReportMapper.selectByCondition(unit, driverType, year); |
|||
if (CollectionUtils.isEmpty(rawData)) { |
|||
return new PageResult<>(Collections.emptyList(), 0L); |
|||
} |
|||
|
|||
rawData.forEach(this::calculateDynamicFields); |
|||
|
|||
Map<String, List<yearDO>> groupByInstance = rawData.stream() |
|||
.collect(Collectors.groupingBy(yearDO::getMpName)); |
|||
|
|||
List<String> instanceNames = new ArrayList<>(groupByInstance.keySet()); |
|||
Long totalInstances = (long) instanceNames.size(); |
|||
|
|||
int fromIndex = (pageNo - 1) * pageSize; |
|||
if (fromIndex >= totalInstances) { |
|||
return new PageResult<>(Collections.emptyList(), totalInstances); |
|||
} |
|||
int toIndex = (int) Math.min(fromIndex + pageSize, totalInstances); |
|||
List<String> pagedInstanceNames = instanceNames.subList(fromIndex, toIndex); |
|||
|
|||
List<YearReport> result = pagedInstanceNames.stream() |
|||
.map(instanceName -> { |
|||
List<yearDO> instanceData = groupByInstance.get(instanceName); |
|||
return buildYearReport(instanceName, instanceData); |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
|
|||
return new PageResult<>(result, totalInstances); |
|||
} |
|||
|
|||
private void calculateDynamicFields(yearDO item) { |
|||
if (item.getStartTime() != null && item.getEndTime() != null) { |
|||
long durationSeconds = Duration.between( |
|||
item.getStartTime().toInstant(), |
|||
item.getEndTime().toInstant() |
|||
).getSeconds(); |
|||
item.setExceedDuration(durationSeconds); |
|||
|
|||
LocalDateTime localStart = item.getStartTime().toInstant() |
|||
.atZone(ZoneId.systemDefault()) |
|||
.toLocalDateTime(); |
|||
item.setYear(localStart.getYear()); |
|||
item.setMonth(localStart.getMonthValue()); |
|||
} |
|||
} |
|||
|
|||
private YearReport buildYearReport(String instanceName, List<yearDO> instanceData) { |
|||
YearReport domain = new YearReport(); |
|||
domain.setId(instanceData.get(0).getMpId()); |
|||
domain.setInstanceName(instanceName); |
|||
domain.setTotalAlarms(instanceData.size()); |
|||
domain.setAlarmDuration(instanceData.stream() |
|||
.mapToLong(item -> item.getExceedDuration() != null ? item.getExceedDuration() : 0) |
|||
.sum()); |
|||
domain.setMonthCounts(calculateMonthlyCounts(instanceData)); |
|||
return domain; |
|||
} |
|||
|
|||
private Map<String, Integer> calculateMonthlyCounts(List<yearDO> data) { |
|||
Map<String, Integer> monthCounts = new HashMap<>(12); |
|||
for (int i = 1; i <= 12; i++) { |
|||
final int month = i; |
|||
monthCounts.put("month_" + i, (int) data.stream() |
|||
.filter(item -> item.getMonth() != null && item.getMonth() == month) |
|||
.count()); |
|||
} |
|||
return monthCounts; |
|||
} |
|||
|
|||
@Override |
|||
public List<YearReport> getAlarmDetails(String instanceId, Integer year) { |
|||
List<yearDO> rawData = yearReportMapper.selectDetailsByInstanceId(instanceId, year); |
|||
|
|||
if (CollectionUtils.isEmpty(rawData)) { |
|||
return Collections.emptyList(); |
|||
} |
|||
|
|||
rawData.forEach(this::calculateDynamicFields); |
|||
|
|||
Map<String, List<yearDO>> groupByGzp = rawData.stream() |
|||
.collect(Collectors.groupingBy(yearDO::getGzpName)); |
|||
|
|||
List<YearReport> result = new ArrayList<>(groupByGzp.size()); |
|||
groupByGzp.forEach((gzpName, gzpData) -> { |
|||
YearReport domain = new YearReport(); |
|||
domain.setTagname(gzpName); |
|||
domain.setAlarmcount(gzpData.size()); |
|||
domain.setAlarmtime(gzpData.stream() |
|||
.mapToLong(item -> item.getExceedDuration() != null ? item.getExceedDuration() : 0L) |
|||
.sum()); |
|||
result.add(domain); |
|||
}); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Override |
|||
public List<yearDO> getGzpAlarmDetails(String gzpName, String instanceId, Integer year) { |
|||
List<yearDO> rawData = yearReportMapper.selectGzpDetails(gzpName, instanceId, year); |
|||
rawData.forEach(this::calculateDynamicFields); |
|||
return rawData; |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package cn.iocoder.yudao.module.alert.param; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class ModelTestParam { |
|||
@JsonProperty("Test_Data") |
|||
private TestData testData; |
|||
private Integer modelId; |
|||
private String version; |
|||
|
|||
@Data |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public static class TestData { |
|||
private String time; |
|||
private String points; |
|||
private Integer interval; |
|||
@JsonProperty("AddBias") |
|||
private List<Double> addBias; |
|||
@JsonProperty("AddBias_Time") |
|||
private String addBiasTime; |
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package cn.iocoder.yudao.module.alert.param; |
|||
|
|||
import com.alibaba.fastjson.annotation.JSONField; |
|||
import com.fasterxml.jackson.annotation.JsonAlias; |
|||
import com.fasterxml.jackson.annotation.JsonProperty; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class TrainParam { |
|||
@JsonAlias("Train_Data") |
|||
@JsonProperty("Train_Data") |
|||
private TrainData trainData; |
|||
|
|||
@JsonAlias("Hyper_para") |
|||
@JsonProperty("Hyper_para") |
|||
private HyperPara hyperPara; |
|||
private String type; |
|||
private String condition; |
|||
|
|||
@JsonAlias("smote_config") |
|||
@JsonProperty("smote_config") |
|||
private String smoteConfig; |
|||
|
|||
private Boolean smote; |
|||
|
|||
private String targetPoint; |
|||
|
|||
@Data |
|||
public static class Smote { |
|||
private String pointId; |
|||
private String max; |
|||
private String min; |
|||
private String number; |
|||
} |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public static class HyperPara { |
|||
private Double percent; |
|||
} |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public static class TrainData { |
|||
private String time; |
|||
private String points; |
|||
private String dead; |
|||
private String limit; |
|||
private String uplow; |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package cn.iocoder.yudao.module.alert.service.device; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.instant.vo.*; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantDO; |
|||
import jakarta.validation.Valid; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.List; |
|||
|
|||
public interface DeviceService { |
|||
DeviceDO getDeviceInfo(Long id); |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
package cn.iocoder.yudao.module.alert.service.device; |
|||
|
|||
import cn.hutool.core.util.ObjUtil; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
|||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.exa.vo.Point; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.instant.vo.*; |
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.vo.RunModelInfoVO; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.device.DeviceDO; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantDO; |
|||
import cn.iocoder.yudao.module.alert.dal.dataobject.instant.InstantTableDO; |
|||
import cn.iocoder.yudao.module.alert.dal.mysql.device.DeviceMapper; |
|||
import cn.iocoder.yudao.module.alert.dal.mysql.instant.InstantMapper; |
|||
import cn.iocoder.yudao.module.alert.dal.mysql.instant.InstantTableMapper; |
|||
import cn.iocoder.yudao.module.alert.utils.EXAUtils; |
|||
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; |
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.dynamic.datasource.annotation.Slave; |
|||
import com.google.common.annotations.VisibleForTesting; |
|||
import com.mzt.logapi.context.LogRecordContext; |
|||
import com.mzt.logapi.service.impl.DiffParseFunction; |
|||
import com.mzt.logapi.starter.annotation.LogRecord; |
|||
import jakarta.annotation.Resource; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.cache.annotation.CacheEvict; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
|
|||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
|||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.INSTANT_NOT_EXISTS; |
|||
import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*; |
|||
|
|||
@Slave |
|||
@Service |
|||
@Slf4j |
|||
public class DeviceServiceImpl implements DeviceService { |
|||
@Resource |
|||
private DeviceMapper deviceMapper; |
|||
@Override |
|||
public DeviceDO getDeviceInfo(Long id) { |
|||
return deviceMapper.selectById(id); |
|||
} |
|||
|
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
package cn.iocoder.yudao.module.alert.service.model; |
|||
|
|||
|
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.vo.ModelDataVO; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author chenjiale |
|||
* @version 1.0 |
|||
* @date 2023-09-05 22:10 |
|||
*/ |
|||
public interface ModelDataService { |
|||
/** |
|||
* 获取模型数据 |
|||
* |
|||
* @param modelId 模型id |
|||
* @param type 类型 |
|||
* @param indexList 边界参数索引 |
|||
* @param st 开始时间 |
|||
* @param et 结束时间 |
|||
* @return 模型数据 |
|||
*/ |
|||
ModelDataVO getModelData(Integer modelId, String type, List<Integer> indexList, Date st, Date et); |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
package cn.iocoder.yudao.module.alert.service.model.impl; |
|||
|
|||
import cn.iocoder.yudao.module.alert.controller.admin.model.vo.ModelDataVO; |
|||
import cn.iocoder.yudao.module.alert.service.model.ModelDataService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author chenjiale |
|||
* @version 1.0 |
|||
* @date 2023-09-05 22:11 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ModelDataServiceImpl implements ModelDataService { |
|||
|
|||
|
|||
@Override |
|||
public ModelDataVO getModelData(Integer modelId, String type, List<Integer> indexList, Date st, Date et) { |
|||
|
|||
|
|||
return null; |
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.Factory; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
|||
import cn.iocoder.yudao.module.system.convert.config.FactoryConvert; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
|||
import cn.iocoder.yudao.module.system.service.config.Factory.FactoryService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.validation.Valid; |
|||
import lombok.RequiredArgsConstructor; // 新增导入
|
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
|||
|
|||
@Tag(name = "管理后台 - 厂级管理") |
|||
@RestController |
|||
@RequestMapping("/system/Factory") |
|||
@Validated |
|||
@RequiredArgsConstructor // << 修改点1:新增注解
|
|||
public class FactoryController { |
|||
|
|||
private final FactoryService factoryService; // << 修改点2:移除@Resource, 添加final
|
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得厂级分页列表") |
|||
public CommonResult<PageResult<FactoryRespVO>> getFactoryPage(@Valid FactoryPageReqVO reqVO) { |
|||
PageResult<FactoryRespVO> pageResult = factoryService.getFactoryPage(reqVO); |
|||
return success(pageResult); |
|||
} |
|||
|
|||
// ... 其他方法保持不变 ...
|
|||
@GetMapping("/get") |
|||
@Operation(summary = "获得厂级详情") |
|||
public CommonResult<FactoryRespVO> getFactory(@RequestParam("id") Long id) { |
|||
FactoryDO factory = factoryService.getFactory(id); |
|||
return success(FactoryConvert.INSTANCE.convert(factory)); |
|||
} |
|||
|
|||
@PostMapping("/create") |
|||
@Operation(summary = "创建厂级") |
|||
public CommonResult<Long> createFactory(@Valid @RequestBody FactorySaveReqVO reqVO) { |
|||
return success(factoryService.createFactory(reqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "修改厂级") |
|||
public CommonResult<Boolean> updateFactory(@Valid @RequestBody FactorySaveReqVO reqVO) { |
|||
factoryService.updateFactory(reqVO); |
|||
return success(true); |
|||
} |
|||
|
|||
@DeleteMapping("/delete") |
|||
@Operation(summary = "删除厂级") |
|||
public CommonResult<Boolean> deleteFactory(@RequestParam("id") Long id) { |
|||
factoryService.deleteFactory(id); |
|||
return success(true); |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Schema(description = "管理后台 - 厂级基础VO") |
|||
@Data |
|||
public class FactoryBaseVO { |
|||
|
|||
@Schema(description = "序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
|||
|
|||
private Long id; |
|||
|
|||
@Schema(description = "厂级序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001") |
|||
|
|||
private Long num; |
|||
|
|||
@Schema(description = "厂级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试厂级") |
|||
|
|||
private String name; |
|||
|
|||
@Schema(description = "厂级简称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试") |
|||
private String shortName; |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
|||
|
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Company.vo.CompanyBaseVO; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@Schema(description = "管理后台 - 厂级创建请求VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class FactoryCreateReqVO extends CompanyBaseVO { |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@Schema(description = "管理后台 - 厂级分页请求VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class FactoryPageReqVO extends PageParam { |
|||
|
|||
@Schema(description = "厂级名称", example = "测试") |
|||
private String name; |
|||
private Long num; |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import java.time.LocalDateTime; |
|||
|
|||
@Schema(description = "管理后台 - 电厂响应 VO") |
|||
@Data |
|||
public class FactoryRespVO { |
|||
@Schema(description = "电厂编号 (对应 plant_id)", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
private Long id; |
|||
@Schema(description = "电厂名称 (对应 plant_name)", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
private String name; |
|||
@Schema(description = "电厂简称 (对应 plant_shortname)") |
|||
private String shortName; |
|||
@Schema(description = "所属集团编号 (对应 area_id)", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
private Long areaId; |
|||
@Schema(description = "所属集团名称 (后端关联查询得到)") |
|||
private String areaName; |
|||
@Schema(description = "创建时间") |
|||
private LocalDateTime createTime; |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import jakarta.validation.constraints.NotNull; |
|||
import jakarta.validation.constraints.Size; |
|||
import lombok.Data; // 新增导入
|
|||
|
|||
@Schema(description = "管理后台 - 电厂创建/修改 Request VO") |
|||
@Data // << 修改点:新增注解,并移除所有手写的getter/setter
|
|||
public class FactorySaveReqVO { |
|||
|
|||
@Schema(description = "电厂编号,更新时必填", example = "1") |
|||
private Long id; |
|||
|
|||
@Schema(description = "电厂名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "正宁电厂") |
|||
@NotBlank(message = "电厂名称不能为空") |
|||
@Size(max = 255) |
|||
private String name; |
|||
|
|||
@Schema(description = "电厂简称", example = "正宁") |
|||
@Size(max = 50) |
|||
private String shortName; |
|||
|
|||
@Schema(description = "所属集团编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9") |
|||
@NotNull(message = "所属集团不能为空") |
|||
private Long areaId; |
|||
|
|||
// --- 此处所有手写的 Getter 和 Setter 方法均已删除 ---
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo; |
|||
|
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Company.vo.CompanyBaseVO; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
|
|||
@Schema(description = "管理后台 - 厂级更新请求VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class FactoryUpdateReqVO extends CompanyBaseVO { |
|||
|
|||
@Schema(description = "序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
|||
private Long id; |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.*; |
|||
import cn.iocoder.yudao.module.system.convert.config.SystemConfigConvert; // 确保引入正确的Convert
|
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
|||
import cn.iocoder.yudao.module.system.service.config.SystemConfig.SystemConfigService; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.Parameter; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import jakarta.annotation.Resource; |
|||
import jakarta.validation.Valid; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
|||
|
|||
@Tag(name = "管理后台 - 系统配置") |
|||
@RestController |
|||
@RequestMapping("/system/system-config") |
|||
@Validated |
|||
public class SystemConfigController { |
|||
|
|||
@Resource |
|||
private SystemConfigService systemConfigService; |
|||
|
|||
@Resource |
|||
private SystemConfigConvert systemConfigConvert; // 【关键修正】注入Converter
|
|||
|
|||
@PostMapping("/create") |
|||
@Operation(summary = "创建系统配置") |
|||
@PreAuthorize("@ss.hasPermission('system:system-config:create')") |
|||
public CommonResult<Long> createSystemConfig(@Valid @RequestBody SystemConfigSaveReqVO createReqVO) { |
|||
return success(systemConfigService.createSystemConfig(createReqVO)); |
|||
} |
|||
|
|||
@PutMapping("/update") |
|||
@Operation(summary = "更新系统配置") |
|||
@PreAuthorize("@ss.hasPermission('system:system-config:update')") |
|||
public CommonResult<Boolean> updateSystemConfig(@Valid @RequestBody SystemConfigSaveReqVO updateReqVO) { |
|||
systemConfigService.updateSystemConfig(updateReqVO); |
|||
return success(true); |
|||
} |
|||
|
|||
@DeleteMapping("/delete") |
|||
@Operation(summary = "删除系统配置") |
|||
@Parameter(name = "id", description = "编号", required = true) |
|||
@PreAuthorize("@ss.hasPermission('system:system-config:delete')") |
|||
public CommonResult<Boolean> deleteSystemConfig(@RequestParam("id") Long id) { |
|||
systemConfigService.deleteSystemConfig(id); |
|||
return success(true); |
|||
} |
|||
|
|||
@GetMapping("/get") |
|||
@Operation(summary = "获得系统配置") |
|||
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|||
@PreAuthorize("@ss.hasPermission('system:system-config:query')") |
|||
public CommonResult<SystemConfigRespVO> getSystemConfig(@RequestParam("id") Long id) { |
|||
SystemConfigDO config = systemConfigService.getSystemConfig(id); |
|||
return success(systemConfigConvert.convert(config)); // 【关键修正】使用注入的bean进行转换
|
|||
} |
|||
|
|||
@GetMapping("/page") |
|||
@Operation(summary = "获得系统配置分页") |
|||
@PreAuthorize("@ss.hasPermission('system:system-config:query')") |
|||
public CommonResult<PageResult<SystemConfigRespVO>> getSystemConfigPage(@Valid SystemConfigPageReqVO pageVO) { |
|||
PageResult<SystemConfigDO> pageResult = systemConfigService.getSystemConfigPage(pageVO); |
|||
return success(systemConfigConvert.convertPage(pageResult)); // 【关键修正】使用注入的bean进行转换
|
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotBlank; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class SystemConfigBaseVO { |
|||
@Schema(description = "系统名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "锅炉系统") |
|||
@NotBlank(message = "系统名称不能为空") |
|||
private String name; |
|||
|
|||
@Schema(description = "系统简称", example = "锅炉") |
|||
private String abbreviation; |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageParam; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@Schema(description = "管理后台 - 系统配置分页请求 VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class SystemConfigPageReqVO extends PageParam { |
|||
@Schema(description = "系统名称", example = "锅炉") |
|||
private String name; |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@Schema(description = "管理后台 - 系统配置响应 VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class SystemConfigRespVO extends SystemConfigBaseVO { |
|||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED) |
|||
private Long id; |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
package cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
@Schema(description = "管理后台 - 系统配置创建/修改 Request VO") |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class SystemConfigSaveReqVO extends SystemConfigBaseVO { |
|||
@Schema(description = "编号,更新时必填", example = "1") |
|||
private Long id; |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package cn.iocoder.yudao.module.system.convert.config; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
|||
import org.mapstruct.Mapper; |
|||
import org.mapstruct.factory.Mappers; |
|||
import java.util.List; |
|||
|
|||
@Mapper(componentModel = "spring") // 【核心修正】添加 componentModel = "spring" 属性
|
|||
public interface FactoryConvert { |
|||
|
|||
FactoryConvert INSTANCE = Mappers.getMapper(FactoryConvert.class); |
|||
|
|||
// 将 SaveReqVO 转换为 DO
|
|||
FactoryDO convert(FactorySaveReqVO bean); |
|||
|
|||
// 将 DO 转换为 RespVO
|
|||
FactoryRespVO convert(FactoryDO bean); |
|||
|
|||
// 将 DO 列表转换为 RespVO 列表
|
|||
List<FactoryRespVO> convertList(List<FactoryDO> list); |
|||
|
|||
// 将 DO 分页 转换为 RespVO 分页
|
|||
PageResult<FactoryRespVO> convertPage(PageResult<FactoryDO> page); |
|||
|
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
package cn.iocoder.yudao.module.system.convert.config; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigRespVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigSaveReqVO; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
|||
import org.mapstruct.Mapper; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Mapper(componentModel = "spring") |
|||
public interface SystemConfigConvert { |
|||
|
|||
default SystemConfigRespVO convert(SystemConfigDO bean) { |
|||
if (bean == null) { |
|||
return null; |
|||
} |
|||
SystemConfigRespVO respVO = new SystemConfigRespVO(); |
|||
|
|||
respVO.setId(bean.getId()); |
|||
respVO.setName(bean.getName()); |
|||
respVO.setAbbreviation(bean.getAbbreviation()); |
|||
|
|||
return respVO; |
|||
} |
|||
|
|||
default List<SystemConfigRespVO> convertList(List<SystemConfigDO> list) { |
|||
if (list == null) { |
|||
return null; |
|||
} |
|||
List<SystemConfigRespVO> result = new ArrayList<>(list.size()); |
|||
for (SystemConfigDO systemConfigDO : list) { |
|||
result.add(convert(systemConfigDO)); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
default PageResult<SystemConfigRespVO> convertPage(PageResult<SystemConfigDO> page) { |
|||
if (page == null) { |
|||
return null; |
|||
} |
|||
return new PageResult<>(convertList(page.getList()), page.getTotal()); |
|||
} |
|||
|
|||
SystemConfigDO convert(SystemConfigSaveReqVO bean); |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package cn.iocoder.yudao.module.system.dal.dataobject.config; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.*; |
|||
|
|||
@TableName("plant_cfg") |
|||
@Data |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class FactoryDO { |
|||
|
|||
@TableId("plant_id") |
|||
private Long id; |
|||
|
|||
@TableField("plant_name") |
|||
private String name; |
|||
|
|||
@TableField("plant_shortname") |
|||
private String shortName; |
|||
|
|||
@TableField("area_id") |
|||
private Long areaId; |
|||
|
|||
@TableField(exist = false) |
|||
private String areaName; |
|||
|
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package cn.iocoder.yudao.module.system.dal.dataobject.config; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.*; |
|||
|
|||
/** |
|||
* 系统配置 DO |
|||
* |
|||
* @author 芋道源码 |
|||
*/ |
|||
@TableName("system_cfg") |
|||
@Data |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class SystemConfigDO { |
|||
|
|||
@TableId("system_id") |
|||
private Long id; |
|||
|
|||
@TableField("system_name") |
|||
private String name; |
|||
|
|||
@TableField("system_shortname") |
|||
private String abbreviation; |
|||
|
|||
@TableField("system_type_id") |
|||
private Integer systemTypeId; |
|||
|
|||
@TableField("unit_id") |
|||
private Integer unitId; |
|||
|
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
package cn.iocoder.yudao.module.system.dal.mysql.config; |
|||
|
|||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
@Mapper |
|||
public interface FactoryMapper extends BaseMapperX<FactoryDO> { |
|||
|
|||
IPage<FactoryDO> selectFactoryPage(Page<?> page, @Param("reqVO") FactoryPageReqVO reqVO); |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package cn.iocoder.yudao.module.system.dal.mysql.config; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
|||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigPageReqVO; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface SystemConfigMapper extends BaseMapperX<SystemConfigDO> { |
|||
|
|||
// 【关键修正】恢复使用框架默认的分页查询,无需XML
|
|||
default PageResult<SystemConfigDO> selectPage(SystemConfigPageReqVO reqVO) { |
|||
return selectPage(reqVO, new LambdaQueryWrapperX<SystemConfigDO>() |
|||
.likeIfPresent(SystemConfigDO::getName, reqVO.getName()) |
|||
.orderByDesc(SystemConfigDO::getId)); |
|||
} |
|||
|
|||
default SystemConfigDO selectByName(String name) { |
|||
return selectOne(SystemConfigDO::getName, name); |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
package cn.iocoder.yudao.module.system.service.config.Factory; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
|||
import jakarta.validation.Valid; |
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
public interface FactoryService { |
|||
|
|||
/** |
|||
* 创建电厂 |
|||
* |
|||
* @param createReqVO 创建信息 |
|||
* @return 编号 |
|||
*/ |
|||
Long createFactory(@Valid FactorySaveReqVO createReqVO); |
|||
|
|||
/** |
|||
* 更新电厂 |
|||
* |
|||
* @param updateReqVO 更新信息 |
|||
*/ |
|||
void updateFactory(@Valid FactorySaveReqVO updateReqVO); |
|||
|
|||
/** |
|||
* 删除电厂 |
|||
* |
|||
* @param id 编号 |
|||
*/ |
|||
void deleteFactory(Long id); |
|||
|
|||
/** |
|||
* 获得电厂 |
|||
* |
|||
* @param id 编号 |
|||
* @return 电厂 |
|||
*/ |
|||
FactoryDO getFactory(Long id); |
|||
|
|||
/** |
|||
* 获得电厂列表 |
|||
* |
|||
* @param ids 编号 |
|||
* @return 电厂列表 |
|||
*/ |
|||
List<FactoryDO> getFactoryList(Collection<Long> ids); |
|||
|
|||
/** |
|||
* 获得电厂分页 |
|||
* |
|||
* @param pageReqVO 分页查询 |
|||
* @return 电厂分页 |
|||
*/ |
|||
PageResult<FactoryRespVO> getFactoryPage(FactoryPageReqVO pageReqVO); |
|||
|
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
package cn.iocoder.yudao.module.system.service.config.Factory; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryPageReqVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactoryRespVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.Factory.vo.FactorySaveReqVO; |
|||
import cn.iocoder.yudao.module.system.convert.config.FactoryConvert; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO; |
|||
import cn.iocoder.yudao.module.system.dal.mysql.config.FactoryMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import lombok.RequiredArgsConstructor; // 新增导入
|
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.validation.annotation.Validated; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
@Validated |
|||
@RequiredArgsConstructor // << 修改点1:新增注解
|
|||
public class FactoryServiceImpl implements FactoryService { |
|||
|
|||
private final FactoryMapper factoryMapper; // << 修改点2:移除@Resource, 添加final
|
|||
private final FactoryConvert factoryConvert; // << 修改点3:移除@Resource, 添加final
|
|||
|
|||
@Override |
|||
public Long createFactory(FactorySaveReqVO createReqVO) { |
|||
FactoryDO factory = factoryConvert.convert(createReqVO); |
|||
factoryMapper.insert(factory); |
|||
return factory.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public void updateFactory(FactorySaveReqVO updateReqVO) { |
|||
FactoryDO updateObj = factoryConvert.convert(updateReqVO); |
|||
factoryMapper.updateById(updateObj); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteFactory(Long id) { |
|||
factoryMapper.deleteById(id); |
|||
} |
|||
|
|||
@Override |
|||
public FactoryDO getFactory(Long id) { |
|||
return factoryMapper.selectById(id); |
|||
} |
|||
|
|||
@Override |
|||
public List<FactoryDO> getFactoryList(Collection<Long> ids) { |
|||
if (ids == null || ids.isEmpty()) { |
|||
return Collections.emptyList(); |
|||
} |
|||
return factoryMapper.selectBatchIds(ids); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<FactoryRespVO> getFactoryPage(FactoryPageReqVO pageReqVO) { |
|||
Page<FactoryDO> page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); |
|||
IPage<FactoryDO> pageResult = factoryMapper.selectFactoryPage(page, pageReqVO); |
|||
return new PageResult<>(factoryConvert.convertList(pageResult.getRecords()), pageResult.getTotal()); |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package cn.iocoder.yudao.module.system.service.config.SystemConfig; |
|||
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigPageReqVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigSaveReqVO; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
|||
import jakarta.validation.Valid; |
|||
|
|||
public interface SystemConfigService { |
|||
|
|||
/** |
|||
* 创建系统配置 |
|||
* @param createReqVO 创建信息 |
|||
* @return 编号 |
|||
*/ |
|||
Long createSystemConfig(@Valid SystemConfigSaveReqVO createReqVO); |
|||
|
|||
/** |
|||
* 更新系统配置 |
|||
* @param updateReqVO 更新信息 |
|||
*/ |
|||
void updateSystemConfig(@Valid SystemConfigSaveReqVO updateReqVO); |
|||
|
|||
/** |
|||
* 删除系统配置 |
|||
* @param id 编号 |
|||
*/ |
|||
void deleteSystemConfig(Long id); |
|||
|
|||
/** |
|||
* 获得系统配置 |
|||
* @param id 编号 |
|||
* @return 系统配置 |
|||
*/ |
|||
SystemConfigDO getSystemConfig(Long id); |
|||
|
|||
/** |
|||
* 获得系统配置分页 |
|||
* @param pageReqVO 分页查询 |
|||
* @return 系统配置分页 |
|||
*/ |
|||
PageResult<SystemConfigDO> getSystemConfigPage(SystemConfigPageReqVO pageReqVO); |
|||
|
|||
} |
|||
@ -0,0 +1,75 @@ |
|||
package cn.iocoder.yudao.module.system.service.config.SystemConfig; |
|||
|
|||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigPageReqVO; |
|||
import cn.iocoder.yudao.module.system.controller.admin.config.SystemConfig.vo.SystemConfigSaveReqVO; |
|||
import cn.iocoder.yudao.module.system.convert.config.SystemConfigConvert; |
|||
import cn.iocoder.yudao.module.system.dal.dataobject.config.SystemConfigDO; |
|||
import cn.iocoder.yudao.module.system.dal.mysql.config.SystemConfigMapper; |
|||
import jakarta.annotation.Resource; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.validation.annotation.Validated; |
|||
|
|||
import java.util.Objects; |
|||
|
|||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
|||
|
|||
@Service |
|||
@Validated |
|||
public class SystemConfigServiceImpl implements SystemConfigService { |
|||
|
|||
@Resource |
|||
private SystemConfigMapper systemConfigMapper; |
|||
|
|||
@Resource |
|||
private SystemConfigConvert systemConfigConvert; |
|||
|
|||
@Override |
|||
public Long createSystemConfig(SystemConfigSaveReqVO createReqVO) { |
|||
validateNameDuplicate(createReqVO.getName(), null); |
|||
SystemConfigDO systemConfig = systemConfigConvert.convert(createReqVO); |
|||
systemConfigMapper.insert(systemConfig); |
|||
return systemConfig.getId(); |
|||
} |
|||
|
|||
@Override |
|||
public void updateSystemConfig(SystemConfigSaveReqVO updateReqVO) { |
|||
validateExists(updateReqVO.getId()); |
|||
validateNameDuplicate(updateReqVO.getName(), updateReqVO.getId()); |
|||
SystemConfigDO updateObj = systemConfigConvert.convert(updateReqVO); |
|||
systemConfigMapper.updateById(updateObj); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteSystemConfig(Long id) { |
|||
validateExists(id); |
|||
systemConfigMapper.deleteById(id); |
|||
} |
|||
|
|||
@Override |
|||
public SystemConfigDO getSystemConfig(Long id) { |
|||
return systemConfigMapper.selectById(id); |
|||
} |
|||
|
|||
@Override |
|||
public PageResult<SystemConfigDO> getSystemConfigPage(SystemConfigPageReqVO pageReqVO) { |
|||
return systemConfigMapper.selectPage(pageReqVO); |
|||
} |
|||
|
|||
private void validateExists(Long id) { |
|||
if (systemConfigMapper.selectById(id) == null) { |
|||
throw ServiceExceptionUtil.exception(SYSTEM_CONFIG_NOT_EXISTS); |
|||
} |
|||
} |
|||
|
|||
private void validateNameDuplicate(String name, Long id) { |
|||
SystemConfigDO config = systemConfigMapper.selectByName(name); |
|||
if (config == null) { |
|||
return; |
|||
} |
|||
if (id == null || !Objects.equals(config.getId(), id)) { |
|||
throw ServiceExceptionUtil.exception(SYSTEM_CONFIG_NAME_DUPLICATE); |
|||
} |
|||
} |
|||
} |
|||
@ -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="cn.iocoder.yudao.module.system.dal.mysql.config.FactoryMapper"> |
|||
|
|||
<select id="selectFactoryPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.config.FactoryDO"> |
|||
SELECT |
|||
p.plant_id AS id, |
|||
p.plant_name AS name, |
|||
p.plant_shortname AS short_name, |
|||
p.area_id, |
|||
a.area_name AS area_name |
|||
FROM |
|||
plant_cfg AS p |
|||
LEFT JOIN area_cfg AS a ON p.area_id = a.area_id |
|||
<where> |
|||
<if test="reqVO.name != null and reqVO.name != ''"> |
|||
AND p.plant_name LIKE CONCAT('%', #{reqVO.name}, '%') |
|||
</if> |
|||
</where> |
|||
</select> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,29 @@ |
|||
package cn.iocoder.yudao.server.config; |
|||
|
|||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* MyBatis Plus 的自定义配置类 |
|||
* |
|||
* @author 芋道源码 |
|||
*/ |
|||
@Configuration |
|||
public class MybatisPlusCustomConfig { |
|||
|
|||
/** |
|||
* 创建一个 MybatisPlusPropertiesCustomizer Bean |
|||
* 用于在 Spring Boot 自动配置 MyBatis-Plus 之前,自定义其属性 |
|||
*/ |
|||
@Bean |
|||
public MybatisPlusPropertiesCustomizer mybatisPlusPropertiesCustomizer() { |
|||
return properties -> { |
|||
// 【核心配置】在这里用代码的方式,为 mybatis-plus.mapper-locations 赋上我们期望的值
|
|||
// "classpath*:mapper/**/*.xml" 会递归扫描所有模块下 resources/mapper 目录中的所有xml文件
|
|||
String[] mapperLocations = {"classpath*:mapper/**/*.xml"}; |
|||
properties.setMapperLocations(mapperLocations); |
|||
}; |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue