节能减排
This commit is contained in:
parent
590682dd08
commit
50d5d68a75
|
|
@ -2,6 +2,7 @@ package com.securitycontrol.screen.controller;
|
||||||
|
|
||||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||||
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
||||||
|
import com.securitycontrol.screen.domain.EnergySavingMeasure;
|
||||||
import com.securitycontrol.screen.service.DeviceEnergyAnalysisService;
|
import com.securitycontrol.screen.service.DeviceEnergyAnalysisService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
@ -63,4 +64,31 @@ public class DeviceEnergyAnalysisController {
|
||||||
public AjaxResult selectAnomalyByDateRange(@RequestBody DeviceEnergyAnalysis entity) {
|
public AjaxResult selectAnomalyByDateRange(@RequestBody DeviceEnergyAnalysis entity) {
|
||||||
return service.selectAnomalyByDateRange(entity);
|
return service.selectAnomalyByDateRange(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最新统计日期下的所有节能减排措施数据。
|
||||||
|
* <p>
|
||||||
|
* 功能说明:
|
||||||
|
* 本接口接收客户端传入的查询条件(封装在 EnergySavingMeasure 实体中),
|
||||||
|
* 并调用 service 层方法,从数据库中获取“最新统计日期”对应的节能减排措施记录列表。
|
||||||
|
* 通常用于前端页面展示最近一期的节能数据概览。
|
||||||
|
* <p>
|
||||||
|
* 请求方式:
|
||||||
|
* POST /selectLatestAll
|
||||||
|
* <p>
|
||||||
|
* 请求参数:
|
||||||
|
*
|
||||||
|
* @return AjaxResult 封装的查询结果:
|
||||||
|
* @RequestBody EnergySavingMeasure entity
|
||||||
|
* - 可选字段示例:
|
||||||
|
* - measureName: 节能措施名称(用于精确筛选)
|
||||||
|
* - siteId / projectId: 工地或项目编号(如表中定义)
|
||||||
|
* <p>
|
||||||
|
* 响应结果:
|
||||||
|
*/
|
||||||
|
@PostMapping("selectLatestAll")
|
||||||
|
public AjaxResult selectLatestAll(@RequestBody EnergySavingMeasure entity) {
|
||||||
|
return service.selectLatestAll(entity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.securitycontrol.screen.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EnergySavingMeasure 类表示某个统计周期下的节能减排措施信息。
|
||||||
|
* 用于记录措施名称、覆盖率、统计日期等信息,并追踪创建与更新时间。
|
||||||
|
* 可用于节能数据展示、趋势分析、覆盖率评估等场景。
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EnergySavingMeasure {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID,自增唯一标识符。
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节能减排措施名称,例如 "照明节能"、"空调温控"、"智能设备管控" 等。
|
||||||
|
* 用于识别该措施的类型。
|
||||||
|
*/
|
||||||
|
private String measureName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 覆盖率(coverage rate),表示该措施在工地范围内的实施比例。
|
||||||
|
* 取值范围为 0~1,通常以百分比展示(例如 0.85 表示 85%)。
|
||||||
|
*/
|
||||||
|
private BigDecimal coverageRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计日期,表示该数据记录对应的时间周期(如某天、某周、某月)。
|
||||||
|
* 一般按日为单位进行统计。
|
||||||
|
*/
|
||||||
|
private LocalDate statDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间,表示该数据记录的创建时间戳。
|
||||||
|
* 由系统自动生成,用于数据追踪。
|
||||||
|
*/
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间,表示该数据记录的最近一次更新时间戳。
|
||||||
|
* 由系统自动维护,用于记录数据变动历史。
|
||||||
|
*/
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询条件:开始时间(非数据库字段)
|
||||||
|
* 用于按时间段筛选数据
|
||||||
|
*/
|
||||||
|
private String startDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询条件:结束时间(非数据库字段)
|
||||||
|
* 用于按时间段筛选数据
|
||||||
|
*/
|
||||||
|
private String endDate;
|
||||||
|
/**
|
||||||
|
* 工程ID(项目标识)
|
||||||
|
* 用于区分所属工程,可作为查询过滤条件
|
||||||
|
*/
|
||||||
|
private String proId;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.securitycontrol.screen.mapper;
|
package com.securitycontrol.screen.mapper;
|
||||||
|
|
||||||
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
||||||
|
import com.securitycontrol.screen.domain.EnergySavingMeasure;
|
||||||
import org.apache.ibatis.annotations.MapKey;
|
import org.apache.ibatis.annotations.MapKey;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
@ -74,4 +75,31 @@ public interface DeviceEnergyAnalysisMapper {
|
||||||
* @return List<DeviceEnergyAnalysis> 查询到的异常能耗记录列表
|
* @return List<DeviceEnergyAnalysis> 查询到的异常能耗记录列表
|
||||||
*/
|
*/
|
||||||
List<DeviceEnergyAnalysis> selectAnomalyByDateRange(DeviceEnergyAnalysis entity);
|
List<DeviceEnergyAnalysis> selectAnomalyByDateRange(DeviceEnergyAnalysis entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最新统计日期下的所有节能减排措施记录。
|
||||||
|
* <p>
|
||||||
|
* 功能说明:
|
||||||
|
* 该方法根据传入的查询条件(如项目编号、设备类型等),从 energy_saving_measures 表中查询
|
||||||
|
* 最新统计日期(stat_date 最大值)对应的全部数据记录,用于展示当前工地节能措施覆盖情况。
|
||||||
|
* <p>
|
||||||
|
* 查询逻辑:
|
||||||
|
* 1. 确定当前表中最大的 stat_date(即最新的数据日期);
|
||||||
|
* 2. 在该日期下筛选所有匹配查询条件的记录;
|
||||||
|
* 3. 返回按条件过滤的所有记录列表。
|
||||||
|
* <p>
|
||||||
|
* 示例用途:
|
||||||
|
* - 首页或概览页展示最近的节能覆盖数据;
|
||||||
|
* - 周期性报表数据展示;
|
||||||
|
* <p>
|
||||||
|
* 参数:
|
||||||
|
*
|
||||||
|
* @param entity 查询条件封装实体,可包含以下字段(可选):
|
||||||
|
* - measureName: 按措施名称过滤;
|
||||||
|
* - projectId / siteId(如果扩展了这些字段):按项目或施工地过滤;
|
||||||
|
* <p>
|
||||||
|
* 返回值:
|
||||||
|
* @return List<EnergySavingMeasure> 最新日期下的所有匹配节能措施记录列表。
|
||||||
|
*/
|
||||||
|
List<EnergySavingMeasure> selectLatestAll(EnergySavingMeasure entity);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.securitycontrol.screen.service;
|
||||||
|
|
||||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||||
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
||||||
|
import com.securitycontrol.screen.domain.EnergySavingMeasure;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -44,4 +45,31 @@ public interface DeviceEnergyAnalysisService {
|
||||||
* @return AjaxResult 封装的查询结果:
|
* @return AjaxResult 封装的查询结果:
|
||||||
*/
|
*/
|
||||||
AjaxResult selectAnomalyByDateRange(DeviceEnergyAnalysis entity);
|
AjaxResult selectAnomalyByDateRange(DeviceEnergyAnalysis entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最新统计日期下的所有节能减排措施记录。
|
||||||
|
* <p>
|
||||||
|
* 功能说明:
|
||||||
|
* 该方法根据传入的查询条件(如项目编号、设备类型等),从 energy_saving_measures 表中查询
|
||||||
|
* 最新统计日期(stat_date 最大值)对应的全部数据记录,用于展示当前工地节能措施覆盖情况。
|
||||||
|
* <p>
|
||||||
|
* 查询逻辑:
|
||||||
|
* 1. 确定当前表中最大的 stat_date(即最新的数据日期);
|
||||||
|
* 2. 在该日期下筛选所有匹配查询条件的记录;
|
||||||
|
* 3. 返回按条件过滤的所有记录列表。
|
||||||
|
* <p>
|
||||||
|
* 示例用途:
|
||||||
|
* - 首页或概览页展示最近的节能覆盖数据;
|
||||||
|
* - 周期性报表数据展示;
|
||||||
|
* <p>
|
||||||
|
* 参数:
|
||||||
|
*
|
||||||
|
* @param entity 查询条件封装实体,可包含以下字段(可选):
|
||||||
|
* - measureName: 按措施名称过滤;
|
||||||
|
* - projectId / siteId(如果扩展了这些字段):按项目或施工地过滤;
|
||||||
|
* <p>
|
||||||
|
* 返回值:
|
||||||
|
* @return AjaxResult 封装的查询结果:
|
||||||
|
*/
|
||||||
|
AjaxResult selectLatestAll(EnergySavingMeasure entity);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.securitycontrol.screen.service.impl;
|
||||||
|
|
||||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||||
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
import com.securitycontrol.screen.domain.DeviceEnergyAnalysis;
|
||||||
|
import com.securitycontrol.screen.domain.EnergySavingMeasure;
|
||||||
import com.securitycontrol.screen.mapper.DeviceEnergyAnalysisMapper;
|
import com.securitycontrol.screen.mapper.DeviceEnergyAnalysisMapper;
|
||||||
import com.securitycontrol.screen.service.DeviceEnergyAnalysisService;
|
import com.securitycontrol.screen.service.DeviceEnergyAnalysisService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -80,4 +81,40 @@ public class DeviceEnergyAnalysisServiceImpl implements DeviceEnergyAnalysisServ
|
||||||
return AjaxResult.error("查询能耗异常分析失败");
|
return AjaxResult.error("查询能耗异常分析失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询最新统计日期下的所有节能减排措施记录。
|
||||||
|
* <p>
|
||||||
|
* 功能说明:
|
||||||
|
* 该方法根据传入的查询条件(如项目编号、设备类型等),从 energy_saving_measures 表中查询
|
||||||
|
* 最新统计日期(stat_date 最大值)对应的全部数据记录,用于展示当前工地节能措施覆盖情况。
|
||||||
|
* <p>
|
||||||
|
* 查询逻辑:
|
||||||
|
* 1. 确定当前表中最大的 stat_date(即最新的数据日期);
|
||||||
|
* 2. 在该日期下筛选所有匹配查询条件的记录;
|
||||||
|
* 3. 返回按条件过滤的所有记录列表。
|
||||||
|
* <p>
|
||||||
|
* 示例用途:
|
||||||
|
* - 首页或概览页展示最近的节能覆盖数据;
|
||||||
|
* - 周期性报表数据展示;
|
||||||
|
* <p>
|
||||||
|
* 参数:
|
||||||
|
*
|
||||||
|
* @param entity 查询条件封装实体,可包含以下字段(可选):
|
||||||
|
* - measureName: 按措施名称过滤;
|
||||||
|
* - projectId / siteId(如果扩展了这些字段):按项目或施工地过滤;
|
||||||
|
* <p>
|
||||||
|
* 返回值:
|
||||||
|
* @return AjaxResult 封装的查询结果:
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult selectLatestAll(EnergySavingMeasure entity) {
|
||||||
|
try {
|
||||||
|
List<EnergySavingMeasure> maps = mapper.selectLatestAll(entity);
|
||||||
|
return AjaxResult.success(maps);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("查询失败: {}", e.getMessage(), e);
|
||||||
|
return AjaxResult.error("查询失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,26 @@
|
||||||
stat_date ASC;
|
stat_date ASC;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectLatestAll" resultType="com.securitycontrol.screen.domain.EnergySavingMeasure">
|
||||||
|
SELECT esm.id AS id,
|
||||||
|
esm.measure_name AS measureName,
|
||||||
|
esm.coverage_rate AS coverageRate,
|
||||||
|
esm.stat_date AS statDate
|
||||||
|
FROM energy_saving_measures esm
|
||||||
|
INNER JOIN (SELECT measure_name,
|
||||||
|
MAX(stat_date) AS max_date,
|
||||||
|
pro_id
|
||||||
|
FROM energy_saving_measures
|
||||||
|
WHERE pro_id = #{proId}
|
||||||
|
AND stat_date BETWEEN #{startDate} AND #{endDate}
|
||||||
|
GROUP BY measure_name, pro_id) t ON esm.measure_name = t.measure_name
|
||||||
|
AND esm.stat_date = t.max_date
|
||||||
|
AND esm.pro_id = t.pro_id
|
||||||
|
WHERE esm.pro_id = #{proId}
|
||||||
|
AND esm.stat_date BETWEEN #{startDate} AND #{endDate};
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue