Compare commits
2 Commits
2bb78dc020
...
prod
| Author | SHA1 | Date | |
|---|---|---|---|
| 44baca6c45 | |||
| f59eeab0d0 |
@ -1,72 +0,0 @@
|
||||
package com.xzzn.web.controller.ems;
|
||||
|
||||
import com.xzzn.common.core.controller.BaseController;
|
||||
import com.xzzn.common.core.domain.AjaxResult;
|
||||
import com.xzzn.common.enums.DeviceCategory;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import com.xzzn.ems.service.IGeneralQueryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* 综合查询
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ems/generalQuery")
|
||||
public class EmsGeneralQueryController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
private IGeneralQueryService iGeneralQueryService;
|
||||
|
||||
/**
|
||||
* 获取设备枚举
|
||||
*/
|
||||
@GetMapping("/getAllDeviceCategory")
|
||||
public AjaxResult getDeviceCategory()
|
||||
{
|
||||
// 获取所有枚举的中文信息
|
||||
List<String> deviceCategoryName = new ArrayList<>();
|
||||
for (DeviceCategory category : DeviceCategory.values()) {
|
||||
deviceCategoryName.add(category.getInfo());
|
||||
}
|
||||
return success(deviceCategoryName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 点位模糊查询
|
||||
*/
|
||||
@PostMapping("/pointFuzzyQuery")
|
||||
public AjaxResult pointFuzzyQuery(@RequestBody PointNameRequest request)
|
||||
{
|
||||
return success(iGeneralQueryService.getPointNameList(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据点位查询点位数据变化
|
||||
*/
|
||||
@PostMapping("/getPointValueList")
|
||||
public AjaxResult getPointValueList(@RequestBody PointNameRequest request)
|
||||
{
|
||||
List<GeneralQueryResponse> result = new ArrayList<>();
|
||||
try {
|
||||
result = iGeneralQueryService.getPointValueList(request);
|
||||
} catch (Exception e) {
|
||||
return error("报错请重试!");
|
||||
}
|
||||
return success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备枚举
|
||||
*/
|
||||
@GetMapping("/getAllBatteryIdsBySites/{siteIds}")
|
||||
public AjaxResult getAllBatteryIdsBySites(@PathVariable String[] siteIds)
|
||||
{
|
||||
return success(iGeneralQueryService.getAllBatteryIdsBySites(siteIds));
|
||||
}
|
||||
}
|
||||
@ -7,10 +7,8 @@ import com.xzzn.common.core.page.TableDataInfo;
|
||||
import com.xzzn.common.utils.file.FileUploadUtils;
|
||||
import com.xzzn.common.utils.file.MimeTypeUtils;
|
||||
import com.xzzn.ems.domain.EmsDevicesSetting;
|
||||
import com.xzzn.ems.domain.EmsPointMatch;
|
||||
import com.xzzn.ems.domain.EmsSiteSetting;
|
||||
import com.xzzn.ems.domain.vo.SiteDeviceListVo;
|
||||
import com.xzzn.ems.mapper.EmsPointMatchMapper;
|
||||
import com.xzzn.ems.service.IEmsDeviceSettingService;
|
||||
import com.xzzn.ems.service.IEmsSiteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -33,8 +31,6 @@ public class EmsSiteConfigController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
private IEmsDeviceSettingService iEmsDeviceSettingService;
|
||||
@Autowired
|
||||
private EmsPointMatchMapper emsPointMatchMapper;
|
||||
|
||||
/**
|
||||
* 获取站点列表
|
||||
@ -140,15 +136,4 @@ public class EmsSiteConfigController extends BaseController{
|
||||
{
|
||||
return toAjax(iEmsDeviceSettingService.deleteEmsDevicesSettingById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个站点单个设备点位查询
|
||||
*/
|
||||
@GetMapping("/getDevicePointList")
|
||||
public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceCategory)
|
||||
{
|
||||
startPage();
|
||||
List<EmsPointMatch> pointList = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory);
|
||||
return getDataTable(pointList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package com.xzzn.web.controller.ems;
|
||||
|
||||
import com.xzzn.common.core.controller.BaseController;
|
||||
import com.xzzn.common.core.domain.AjaxResult;
|
||||
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||
import com.xzzn.ems.service.IEmsSiteService;
|
||||
import com.xzzn.ems.service.IHomePageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
*
|
||||
* 站点地图
|
||||
// * 站点地图
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@ -31,17 +31,4 @@ public class EmsSiteMapController extends BaseController{
|
||||
return success(homePageService.getSingleSiteBaseInfo(siteId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个站点7天充放电数据
|
||||
*/
|
||||
@GetMapping("/getSevenChargeData")
|
||||
public AjaxResult getSevenChargeData(DateSearchRequest request)
|
||||
{
|
||||
String siteId = request.getSiteId();
|
||||
if(siteId == null || siteId.isEmpty()) {
|
||||
return error("站点必传");
|
||||
}
|
||||
return success(homePageService.getSevenChargeData(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,17 +3,14 @@ package com.xzzn.web.controller.ems;
|
||||
import com.xzzn.common.core.controller.BaseController;
|
||||
import com.xzzn.common.core.domain.AjaxResult;
|
||||
import com.xzzn.common.core.page.TableDataInfo;
|
||||
import com.xzzn.ems.domain.vo.BMSBatteryDataList;
|
||||
import com.xzzn.ems.domain.vo.BatteryDataStatsListVo;
|
||||
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||
import com.xzzn.ems.domain.vo.SiteBatteryDataList;
|
||||
import com.xzzn.ems.service.IEmsSiteService;
|
||||
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||
import com.xzzn.ems.service.ISingleSiteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -144,27 +141,11 @@ public class EmsSiteMonitorController extends BaseController{
|
||||
* 获取电池簇下面的单体电池数据
|
||||
*/
|
||||
@GetMapping("/getClusterDataInfoList")
|
||||
public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId,
|
||||
@RequestParam String stackDeviceId,@RequestParam String batteryId)
|
||||
public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId)
|
||||
{
|
||||
startPage();
|
||||
SiteBatteryDataList siteBatteryDataList = new SiteBatteryDataList();
|
||||
// 簇最大最小单体id数据
|
||||
List<BMSBatteryDataList> clusterBatteryDataList = iSingleSiteService.getClusterBatteryList(siteId,stackDeviceId,clusterDeviceId);
|
||||
siteBatteryDataList.setClusterList(clusterBatteryDataList);
|
||||
// 单体电池数据
|
||||
List<BatteryDataStatsListVo> List = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId,stackDeviceId,batteryId);
|
||||
// 对batteryList进行分页处理
|
||||
List<BatteryDataStatsListVo> batteryList = paginateList(List);
|
||||
siteBatteryDataList.setBatteryList(batteryList);
|
||||
|
||||
// 封装分页信息
|
||||
TableDataInfo pageInfo = new TableDataInfo();
|
||||
pageInfo.setTotal(List.size());
|
||||
pageInfo.setRows(Arrays.asList(siteBatteryDataList));
|
||||
pageInfo.setCode(0);
|
||||
pageInfo.setMsg("查询成功");
|
||||
return pageInfo;
|
||||
List<BatteryDataStatsListVo> list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId);
|
||||
return getDataTable2(list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -58,7 +58,8 @@ public class EmsStatisticalReportController extends BaseController
|
||||
@GetMapping("/getPCSData")
|
||||
public AjaxResult getPCSData(DateSearchRequest requestVo)
|
||||
{
|
||||
if (!StringUtils.isEmpty(requestVo.getSiteId())&&
|
||||
if (!StringUtils.isEmpty(requestVo.getSiteId()) &&
|
||||
!StringUtils.isEmpty(requestVo.getDeviceId()) &&
|
||||
!StringUtils.isEmpty(requestVo.getDataType())) {
|
||||
return success(ieEmsStatsReportService.getPCSDataResult(requestVo));
|
||||
} else {
|
||||
@ -73,6 +74,7 @@ public class EmsStatisticalReportController extends BaseController
|
||||
public AjaxResult getStackData(DateSearchRequest requestVo)
|
||||
{
|
||||
if (!StringUtils.isEmpty(requestVo.getSiteId()) &&
|
||||
!StringUtils.isEmpty(requestVo.getDeviceId()) &&
|
||||
!StringUtils.isEmpty(requestVo.getDataType())) {
|
||||
return success(ieEmsStatsReportService.getStackDataResult(requestVo));
|
||||
} else {
|
||||
@ -98,7 +100,7 @@ public class EmsStatisticalReportController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 概率统计-获取站点下所有电表
|
||||
* 概率统计-获取总表
|
||||
*/
|
||||
@GetMapping("/getLoadNameList")
|
||||
public AjaxResult getLoadNameList(String siteId)
|
||||
@ -129,7 +131,9 @@ public class EmsStatisticalReportController extends BaseController
|
||||
@GetMapping("/getPowerData")
|
||||
public AjaxResult getPowerData(DateSearchRequest requestVo)
|
||||
{
|
||||
if (!StringUtils.isEmpty(requestVo.getSiteId())) {
|
||||
if (!StringUtils.isEmpty(requestVo.getSiteId())
|
||||
&& !StringUtils.isEmpty(requestVo.getDeviceId())
|
||||
&& !StringUtils.isEmpty(requestVo.getDataType())) {
|
||||
return success(ieEmsStatsReportService.getPowerDataList(requestVo));
|
||||
} else {
|
||||
return error("缺少必传项");
|
||||
|
||||
@ -6,7 +6,7 @@ spring:
|
||||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://122.51.194.184:13306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://122.51.194.184:13306/setri_ems?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: ems
|
||||
password: 12345678
|
||||
# 从库数据源
|
||||
|
||||
@ -170,9 +170,4 @@ public class Constants
|
||||
*/
|
||||
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework", "org.apache", "com.xzzn.common.utils.file", "com.xzzn.common.config", "com.xzzn.generator" };
|
||||
|
||||
/**
|
||||
* 昨日充放电最晚数据有效期
|
||||
*/
|
||||
public static final Integer DATE_VALID_TIME = 1;
|
||||
}
|
||||
|
||||
@ -232,31 +232,4 @@ public class BaseController
|
||||
rspData.setTotal(list.size());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用分页工具方法
|
||||
*/
|
||||
protected <T> List<T> paginateList(List<T> sourceList) {
|
||||
if (sourceList == null || sourceList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 分页梳理
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
int pageNum = pageDomain.getPageNum();
|
||||
int pageSize = pageDomain.getPageSize();
|
||||
int startIndex = 0;
|
||||
int endIndex = sourceList.size();
|
||||
if (pageNum > 0 && pageSize > 0) {
|
||||
// 计算起始索引(处理页码小于1的情况)
|
||||
startIndex = Math.max((pageNum - 1) * pageSize, 0);
|
||||
// 计算结束索引(处理超出列表长度的情况)
|
||||
endIndex = Math.min(startIndex + pageSize, sourceList.size());
|
||||
}
|
||||
// 防止越界
|
||||
if (startIndex >= sourceList.size()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 截取分页数据
|
||||
return sourceList.subList(startIndex, endIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,8 +7,10 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -274,78 +276,4 @@ public class RedisCache
|
||||
{
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量缓存
|
||||
* @param cacheMap
|
||||
*/
|
||||
public <T> void multiSet(final Map<String, String> cacheMap)
|
||||
{
|
||||
|
||||
redisTemplate.opsForValue().multiSet(cacheMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置键值对,并为每个键设置相同的过期时间
|
||||
* @param keyValueMap 键值对集合
|
||||
* @param timeout 过期时间
|
||||
* @param unit 时间单位
|
||||
*/
|
||||
public void multiSetWithExpire(Map<String, String> keyValueMap, long timeout, TimeUnit unit) {
|
||||
if (keyValueMap.isEmpty()) {
|
||||
return; // 空集合直接返回
|
||||
}
|
||||
|
||||
// 使用Redis管道批量执行命令
|
||||
redisTemplate.executePipelined(new SessionCallback<Object>() {
|
||||
@Override
|
||||
public Object execute(RedisOperations operations) throws DataAccessException {
|
||||
// 循环处理每个键值对
|
||||
for (Map.Entry<String, String> entry : keyValueMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
|
||||
// 1. 设置键值对
|
||||
operations.opsForValue().set(key, value);
|
||||
// 2. 设置过期时间
|
||||
operations.expire(key, timeout, unit);
|
||||
}
|
||||
return null; // 管道操作无需返回值
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定站点的所有历史测试数据缓存(最精准)
|
||||
* @param testSiteId 测试数据所属的站点ID(如"test-site-001")
|
||||
*/
|
||||
public void deleteTestCacheBySite(String testSiteId) {
|
||||
System.out.println("开删除缓存redis:" + testSiteId + "<UNK>");
|
||||
if (testSiteId == null || testSiteId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构造键前缀:测试站点ID开头的所有缓存键(无论粒度和时间)
|
||||
String pattern = testSiteId + "_*";
|
||||
deleteCacheByPattern(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据键前缀批量删除缓存(核心方法)
|
||||
* @param pattern 键匹配模式(支持Redis的通配符:*表示任意字符,?表示单个字符)
|
||||
*/
|
||||
public void deleteCacheByPattern(String pattern) {
|
||||
try {
|
||||
// 1. 查找所有匹配的键(注意:keys命令在大数据量时可能阻塞Redis,建议生产环境用scan)
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
if (keys == null || keys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 批量删除匹配的键
|
||||
long deleteCount = redisTemplate.delete(keys);
|
||||
System.out.println("删除缓存数据:" + deleteCount + "<UNK>");
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
package com.xzzn.common.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* device-设备类别
|
||||
*
|
||||
@ -16,10 +13,7 @@ public enum DeviceCategory
|
||||
CLUSTER("CLUSTER", "电池簇"),
|
||||
BATTERY("BATTERY", "单体电池"),
|
||||
AMMETER("AMMETER", "电表"),
|
||||
COOLING("COOLING", "冷却"),
|
||||
DH("DH", "动环"),
|
||||
XF("XF", "消防"),
|
||||
BATTERY_GROUP("BATTERY_GROUP", "电池组");
|
||||
COOLING("COOLING", "冷液体");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
@ -39,19 +33,4 @@ public enum DeviceCategory
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
// 缓存info与code的映射(优化查询效率)
|
||||
private static final Map<String, String> INFO_CODE_MAP = new HashMap<>();
|
||||
|
||||
// 静态块初始化缓存
|
||||
static {
|
||||
for (DeviceCategory category : DeviceCategory.values()) {
|
||||
INFO_CODE_MAP.put(category.info, category.code);
|
||||
}
|
||||
}
|
||||
|
||||
// 通过info获取code的方法
|
||||
public static String getCodeByInfo(String info) {
|
||||
return INFO_CODE_MAP.get(info); // 从缓存中直接获取,效率高
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
package com.xzzn.common.enums;
|
||||
|
||||
/**
|
||||
* device-设备类型
|
||||
*
|
||||
* @author xzzn
|
||||
*/
|
||||
|
||||
public enum SiteEnum
|
||||
{
|
||||
DDS("021_DDS_01", "电动所内部"), FX("021_FXX_01", "奉贤西部污水处理厂");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
SiteEnum(String code, String info)
|
||||
{
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@ -8,11 +8,8 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
/**
|
||||
@ -32,13 +29,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public static String YYYYMMDD = "yyyyMMdd";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_00 = "yyyy-MM-dd HH:mm:00";
|
||||
|
||||
private static final DateTimeFormatter DAY_INPUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
private static final DateTimeFormatter MIN_HOUR_INPUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
@ -210,142 +200,4 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
long date = calendar.get(Calendar.DAY_OF_MONTH); // 月份从0开始,所以要加1
|
||||
return date;
|
||||
}
|
||||
|
||||
// LocalDateTime 转 Date(带时区)
|
||||
public static Date convertToDate(LocalDateTime localDateTime) {
|
||||
ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zonedDateTime.toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取昨天的日期,格式为yyyy-MM-dd
|
||||
* @return 昨天的日期字符串
|
||||
*/
|
||||
public static String getYesterdayDate() {
|
||||
// 获取今天的日期
|
||||
LocalDate today = LocalDate.now();
|
||||
// 减去一天得到昨天
|
||||
LocalDate yesterday = today.minusDays(1);
|
||||
// 定义日期格式化器
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYYMMDD);
|
||||
// 格式化并返回
|
||||
return yesterday.format(formatter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验传入日期是否今天
|
||||
* @param dataDate
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkIsToday(String dataDate) {
|
||||
boolean flag = false;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int todayMonth = calendar.get(Calendar.MONTH) + 1;
|
||||
int todayDay = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
if (StringUtils.isNotEmpty(dataDate)){
|
||||
String[] pcsDateArray = dataDate.split("-");
|
||||
if (todayMonth == Integer.parseInt(pcsDateArray[1]) &&
|
||||
todayDay == Integer.parseInt(pcsDateArray[2])) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将时间转换为月份(YYYY-MM)
|
||||
*/
|
||||
public static String formatMonth(LocalDateTime time) {
|
||||
return time.format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加 LocalDateTime ==> String
|
||||
*/
|
||||
public static String convertToString(LocalDateTime time) {
|
||||
return time.format(DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM_SS));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将输入时间调整到下一分钟的整点(秒数强制为00)
|
||||
* 例如:2026-09-03 18:34:49 -> 2026-09-03 18:35:00
|
||||
* @param timeStr 输入时间字符串(支持yyyy-MM-dd HH:mm:ss格式)
|
||||
* @return 调整后的时间字符串(yyyy-MM-dd HH:mm:00)
|
||||
* @throws ParseException 时间格式错误时抛出
|
||||
*/
|
||||
public static String adjustToNextMinute(String timeStr) throws ParseException {
|
||||
// 1. 解析原始时间(使用包含秒数的格式)
|
||||
SimpleDateFormat fullFormat = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
|
||||
Date originalDate = fullFormat.parse(timeStr);
|
||||
|
||||
// 2. 使用Calendar调整时间
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(originalDate);
|
||||
|
||||
// 3. 如果当前秒数大于0,自动进1分钟(否则保持当前分钟)
|
||||
if (cal.get(Calendar.SECOND) > 0) {
|
||||
cal.add(Calendar.MINUTE, 1); // 分钟+1
|
||||
}
|
||||
|
||||
// 4. 强制设置秒数和毫秒为0
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
// 5. 格式化为目标字符串
|
||||
return new SimpleDateFormat(YYYY_MM_DD_HH_MM_00).format(cal.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将"yyyy-MM-dd"字符串转换为Date类型的"yyyy-MM-dd 23:59:59"
|
||||
*/
|
||||
public static Date adjustToEndOfDay(String dateStr) {
|
||||
// 1. 解析字符串为LocalDate(仅日期)
|
||||
LocalDate localDate = LocalDate.parse(dateStr, DAY_INPUT_FORMATTER);
|
||||
|
||||
// 2. 补充时间为23:59:59,转换为LocalDateTime
|
||||
LocalDateTime localDateTime = localDate.atTime(23, 59, 59);
|
||||
|
||||
// 3. 转换为Date类型(兼容旧API)
|
||||
return Date.from(
|
||||
localDateTime.atZone(TimeZone.getDefault().toZoneId()) // 适配系统时区
|
||||
.toInstant()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 "yyyy-MM-dd HH:mm:ss" 字符串转换为Date类型的"yyyy-MM-dd HH:00:00"
|
||||
*/
|
||||
public static Date adjustToStartOfHour(String inputTime) {
|
||||
// 1. 解析输入字符串为LocalDateTime(包含日期和小时、分钟)
|
||||
LocalDateTime inputLdt = LocalDateTime.parse(inputTime, MIN_HOUR_INPUT_FORMATTER);
|
||||
|
||||
// 2. 调整分钟为00,秒为00(保留日期和小时不变)
|
||||
LocalDateTime adjustedLdt = inputLdt
|
||||
.withMinute(00) // 强制设为00分
|
||||
.withSecond(00); // 强制设为00秒
|
||||
|
||||
// 3. 转换为Date类型(适配旧API)
|
||||
return Date.from(
|
||||
adjustedLdt.atZone(TimeZone.getDefault().toZoneId()) // 适配系统时区
|
||||
.toInstant()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 "yyyy-MM-dd HH:mm:ss" 字符串转换为Date类型的"yyyy-MM-dd HH:mm:00"
|
||||
*/
|
||||
public static Date adjustToStartOfMinutes(String inputTime) {
|
||||
// 1. 解析输入字符串为LocalDateTime(包含日期和小时、分钟)
|
||||
LocalDateTime inputLdt = LocalDateTime.parse(inputTime, MIN_HOUR_INPUT_FORMATTER);
|
||||
|
||||
// 2. 调整分钟为00,秒为00(保留日期和小时不变)
|
||||
LocalDateTime adjustedLdt = inputLdt
|
||||
.withSecond(00); // 强制设为00秒
|
||||
|
||||
// 3. 转换为Date类型(适配旧API)
|
||||
return Date.from(
|
||||
adjustedLdt.atZone(TimeZone.getDefault().toZoneId()) // 适配系统时区
|
||||
.toInstant()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -751,17 +751,4 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 补全三位数字(返回字符串)
|
||||
public static String fillThreeDigits(String value) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return "000";
|
||||
}
|
||||
try {
|
||||
int num = Integer.parseInt(value.trim());
|
||||
return String.format("%03d", num);
|
||||
} catch (NumberFormatException e) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,7 @@ public class MqttLifecycleManager implements ApplicationRunner, SmartLifecycle,
|
||||
|
||||
private final MqttConnectOptions connectOptions;
|
||||
private MqttClient mqttClient;
|
||||
private volatile boolean running = false;
|
||||
private volatile boolean running = true;
|
||||
|
||||
// 存储订阅关系: topic -> (listener, qos)
|
||||
private final ConcurrentHashMap<String, SubscriptionInfo> subscriptions = new ConcurrentHashMap<>();
|
||||
|
||||
@ -3,7 +3,6 @@ package com.xzzn.ems.domain;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
@ -147,7 +146,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最高单体电压对应点号 */
|
||||
@Excel(name = "最高单体电压对应点号")
|
||||
private String maxCellVoltageId;
|
||||
private Long maxCellVoltageId;
|
||||
|
||||
/** 最低单体电压 */
|
||||
@Excel(name = "最低单体电压")
|
||||
@ -155,7 +154,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最低单体电压对应点号 */
|
||||
@Excel(name = "最低单体电压对应点号")
|
||||
private String minCellVoltageId;
|
||||
private Long minCellVoltageId;
|
||||
|
||||
/** 最高单体温度 */
|
||||
@Excel(name = "最高单体温度")
|
||||
@ -163,7 +162,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最高单体温度对应点号 */
|
||||
@Excel(name = "最高单体温度对应点号")
|
||||
private String maxCellTempId;
|
||||
private Long maxCellTempId;
|
||||
|
||||
/** 最低单体温度 */
|
||||
@Excel(name = "最低单体温度")
|
||||
@ -171,7 +170,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最低单体温度对应点号 */
|
||||
@Excel(name = "最低单体温度对应点号")
|
||||
private String minCellTempId;
|
||||
private Long minCellTempId;
|
||||
|
||||
/** 最高单体SOC */
|
||||
@Excel(name = "最高单体SOC")
|
||||
@ -179,7 +178,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最高单体SOC对应点号 */
|
||||
@Excel(name = "最高单体SOC对应点号")
|
||||
private String maxCellSocId;
|
||||
private Long maxCellSocId;
|
||||
|
||||
/** 最低单体SOC */
|
||||
@Excel(name = "最低单体SOC")
|
||||
@ -187,7 +186,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最低单体SOC对应点号 */
|
||||
@Excel(name = "最低单体SOC对应点号")
|
||||
private String minCellSocId;
|
||||
private Long minCellSocId;
|
||||
|
||||
/** 最高单体SOH */
|
||||
@Excel(name = "最高单体SOH")
|
||||
@ -195,7 +194,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最高单体SOH对应点号 */
|
||||
@Excel(name = "最高单体SOH对应点号")
|
||||
private String maxCellSohId;
|
||||
private Long maxCellSohId;
|
||||
|
||||
/** 最低单体SOH */
|
||||
@Excel(name = "最低单体SOH")
|
||||
@ -203,7 +202,7 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
|
||||
/** 最低单体SOH对应点号 */
|
||||
@Excel(name = "最低单体SOH对应点号")
|
||||
private String minCellSohId;
|
||||
private Long minCellSohId;
|
||||
|
||||
/** 单次累计充电电量 */
|
||||
@Excel(name = "单次累计充电电量")
|
||||
@ -533,12 +532,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return maxCellVoltage;
|
||||
}
|
||||
|
||||
public void setMaxCellVoltageId(String maxCellVoltageId)
|
||||
public void setMaxCellVoltageId(Long maxCellVoltageId)
|
||||
{
|
||||
this.maxCellVoltageId = StringUtils.fillThreeDigits(maxCellVoltageId);
|
||||
this.maxCellVoltageId = maxCellVoltageId;
|
||||
}
|
||||
|
||||
public String getMaxCellVoltageId()
|
||||
public Long getMaxCellVoltageId()
|
||||
{
|
||||
return maxCellVoltageId;
|
||||
}
|
||||
@ -553,12 +552,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return minCellVoltage;
|
||||
}
|
||||
|
||||
public void setMinCellVoltageId(String minCellVoltageId)
|
||||
public void setMinCellVoltageId(Long minCellVoltageId)
|
||||
{
|
||||
this.minCellVoltageId = StringUtils.fillThreeDigits(minCellVoltageId);
|
||||
this.minCellVoltageId = minCellVoltageId;
|
||||
}
|
||||
|
||||
public String getMinCellVoltageId()
|
||||
public Long getMinCellVoltageId()
|
||||
{
|
||||
return minCellVoltageId;
|
||||
}
|
||||
@ -573,12 +572,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return maxCellTemp;
|
||||
}
|
||||
|
||||
public void setMaxCellTempId(String maxCellTempId)
|
||||
public void setMaxCellTempId(Long maxCellTempId)
|
||||
{
|
||||
this.maxCellTempId = StringUtils.fillThreeDigits(maxCellTempId);
|
||||
this.maxCellTempId = maxCellTempId;
|
||||
}
|
||||
|
||||
public String getMaxCellTempId()
|
||||
public Long getMaxCellTempId()
|
||||
{
|
||||
return maxCellTempId;
|
||||
}
|
||||
@ -593,12 +592,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return minCellTemp;
|
||||
}
|
||||
|
||||
public void setMinCellTempId(String minCellTempId)
|
||||
public void setMinCellTempId(Long minCellTempId)
|
||||
{
|
||||
this.minCellTempId = StringUtils.fillThreeDigits(minCellTempId);
|
||||
this.minCellTempId = minCellTempId;
|
||||
}
|
||||
|
||||
public String getMinCellTempId()
|
||||
public Long getMinCellTempId()
|
||||
{
|
||||
return minCellTempId;
|
||||
}
|
||||
@ -613,12 +612,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return maxCellSoc;
|
||||
}
|
||||
|
||||
public void setMaxCellSocId(String maxCellSocId)
|
||||
public void setMaxCellSocId(Long maxCellSocId)
|
||||
{
|
||||
this.maxCellSocId = StringUtils.fillThreeDigits(maxCellSocId);
|
||||
this.maxCellSocId = maxCellSocId;
|
||||
}
|
||||
|
||||
public String getMaxCellSocId()
|
||||
public Long getMaxCellSocId()
|
||||
{
|
||||
return maxCellSocId;
|
||||
}
|
||||
@ -633,12 +632,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return minCellSoc;
|
||||
}
|
||||
|
||||
public void setMinCellSocId(String minCellSocId)
|
||||
public void setMinCellSocId(Long minCellSocId)
|
||||
{
|
||||
this.minCellSocId = StringUtils.fillThreeDigits(minCellSocId);
|
||||
this.minCellSocId = minCellSocId;
|
||||
}
|
||||
|
||||
public String getMinCellSocId()
|
||||
public Long getMinCellSocId()
|
||||
{
|
||||
return minCellSocId;
|
||||
}
|
||||
@ -653,12 +652,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return maxCellSoh;
|
||||
}
|
||||
|
||||
public void setMaxCellSohId(String maxCellSohId)
|
||||
public void setMaxCellSohId(Long maxCellSohId)
|
||||
{
|
||||
this.maxCellSohId = StringUtils.fillThreeDigits(maxCellSohId);
|
||||
this.maxCellSohId = maxCellSohId;
|
||||
}
|
||||
|
||||
public String getMaxCellSohId()
|
||||
public Long getMaxCellSohId()
|
||||
{
|
||||
return maxCellSohId;
|
||||
}
|
||||
@ -673,12 +672,12 @@ public class EmsBatteryCluster extends BaseEntity
|
||||
return minCellSoh;
|
||||
}
|
||||
|
||||
public void setMinCellSohId(String minCellSohId)
|
||||
public void setMinCellSohId(Long minCellSohId)
|
||||
{
|
||||
this.minCellSohId = StringUtils.fillThreeDigits(minCellSohId);
|
||||
this.minCellSohId = minCellSohId;
|
||||
}
|
||||
|
||||
public String getMinCellSohId()
|
||||
public Long getMinCellSohId()
|
||||
{
|
||||
return minCellSohId;
|
||||
}
|
||||
|
||||
@ -1,242 +0,0 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 单体电池天级数据对象 ems_battery_data_day
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-20
|
||||
*/
|
||||
public class EmsBatteryDataDay extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 电池堆 */
|
||||
@Excel(name = "电池堆")
|
||||
private String batteryPack;
|
||||
|
||||
/** 电池簇 */
|
||||
@Excel(name = "电池簇")
|
||||
private String batteryCluster;
|
||||
|
||||
/** 单体编号 */
|
||||
@Excel(name = "单体编号")
|
||||
private String batteryCellId;
|
||||
|
||||
/** 电压 (V) */
|
||||
@Excel(name = "电压 (V)")
|
||||
private BigDecimal voltage;
|
||||
|
||||
/** 温度 (℃) */
|
||||
@Excel(name = "温度 (℃)")
|
||||
private BigDecimal temperature;
|
||||
|
||||
/** SOC (%) */
|
||||
@Excel(name = "SOC (%)")
|
||||
private BigDecimal soc;
|
||||
|
||||
/** SOH (%) */
|
||||
@Excel(name = "SOH (%)")
|
||||
private BigDecimal soh;
|
||||
|
||||
/** 数据采集时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dataTimestamp;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
/** 簇设备id */
|
||||
@Excel(name = "簇设备id")
|
||||
private String clusterDeviceId;
|
||||
|
||||
/** 单体电池内阻 */
|
||||
@Excel(name = "单体电池内阻")
|
||||
private BigDecimal interResistance;
|
||||
|
||||
/** 天级时间维度 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "天级时间维度", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dayTime;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setBatteryPack(String batteryPack)
|
||||
{
|
||||
this.batteryPack = batteryPack;
|
||||
}
|
||||
|
||||
public String getBatteryPack()
|
||||
{
|
||||
return batteryPack;
|
||||
}
|
||||
|
||||
public void setBatteryCluster(String batteryCluster)
|
||||
{
|
||||
this.batteryCluster = batteryCluster;
|
||||
}
|
||||
|
||||
public String getBatteryCluster()
|
||||
{
|
||||
return batteryCluster;
|
||||
}
|
||||
|
||||
public void setBatteryCellId(String batteryCellId)
|
||||
{
|
||||
this.batteryCellId = batteryCellId;
|
||||
}
|
||||
|
||||
public String getBatteryCellId()
|
||||
{
|
||||
return batteryCellId;
|
||||
}
|
||||
|
||||
public void setVoltage(BigDecimal voltage)
|
||||
{
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
public BigDecimal getVoltage()
|
||||
{
|
||||
return voltage;
|
||||
}
|
||||
|
||||
public void setTemperature(BigDecimal temperature)
|
||||
{
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public BigDecimal getTemperature()
|
||||
{
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setSoc(BigDecimal soc)
|
||||
{
|
||||
this.soc = soc;
|
||||
}
|
||||
|
||||
public BigDecimal getSoc()
|
||||
{
|
||||
return soc;
|
||||
}
|
||||
|
||||
public void setSoh(BigDecimal soh)
|
||||
{
|
||||
this.soh = soh;
|
||||
}
|
||||
|
||||
public BigDecimal getSoh()
|
||||
{
|
||||
return soh;
|
||||
}
|
||||
|
||||
public void setDataTimestamp(Date dataTimestamp)
|
||||
{
|
||||
this.dataTimestamp = dataTimestamp;
|
||||
}
|
||||
|
||||
public Date getDataTimestamp()
|
||||
{
|
||||
return dataTimestamp;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setClusterDeviceId(String clusterDeviceId)
|
||||
{
|
||||
this.clusterDeviceId = clusterDeviceId;
|
||||
}
|
||||
|
||||
public String getClusterDeviceId()
|
||||
{
|
||||
return clusterDeviceId;
|
||||
}
|
||||
|
||||
public void setInterResistance(BigDecimal interResistance)
|
||||
{
|
||||
this.interResistance = interResistance;
|
||||
}
|
||||
|
||||
public BigDecimal getInterResistance()
|
||||
{
|
||||
return interResistance;
|
||||
}
|
||||
|
||||
public void setDayTime(Date dayTime)
|
||||
{
|
||||
this.dayTime = dayTime;
|
||||
}
|
||||
|
||||
public Date getDayTime()
|
||||
{
|
||||
return dayTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("batteryPack", getBatteryPack())
|
||||
.append("batteryCluster", getBatteryCluster())
|
||||
.append("batteryCellId", getBatteryCellId())
|
||||
.append("voltage", getVoltage())
|
||||
.append("temperature", getTemperature())
|
||||
.append("soc", getSoc())
|
||||
.append("soh", getSoh())
|
||||
.append("dataTimestamp", getDataTimestamp())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("clusterDeviceId", getClusterDeviceId())
|
||||
.append("interResistance", getInterResistance())
|
||||
.append("dayTime", getDayTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -1,242 +0,0 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 单体电池小时级数据对象 ems_battery_data_hour
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public class EmsBatteryDataHour extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 电池堆 */
|
||||
@Excel(name = "电池堆")
|
||||
private String batteryPack;
|
||||
|
||||
/** 电池簇 */
|
||||
@Excel(name = "电池簇")
|
||||
private String batteryCluster;
|
||||
|
||||
/** 单体编号 */
|
||||
@Excel(name = "单体编号")
|
||||
private String batteryCellId;
|
||||
|
||||
/** 电压 (V) */
|
||||
@Excel(name = "电压 (V)")
|
||||
private BigDecimal voltage;
|
||||
|
||||
/** 温度 (℃) */
|
||||
@Excel(name = "温度 (℃)")
|
||||
private BigDecimal temperature;
|
||||
|
||||
/** SOC (%) */
|
||||
@Excel(name = "SOC (%)")
|
||||
private BigDecimal soc;
|
||||
|
||||
/** SOH (%) */
|
||||
@Excel(name = "SOH (%)")
|
||||
private BigDecimal soh;
|
||||
|
||||
/** 数据采集时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dataTimestamp;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
/** 簇设备id */
|
||||
@Excel(name = "簇设备id")
|
||||
private String clusterDeviceId;
|
||||
|
||||
/** 单体电池内阻 */
|
||||
@Excel(name = "单体电池内阻")
|
||||
private BigDecimal interResistance;
|
||||
|
||||
/** 小时级时间维度 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "小时级时间维度", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date hourTime;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setBatteryPack(String batteryPack)
|
||||
{
|
||||
this.batteryPack = batteryPack;
|
||||
}
|
||||
|
||||
public String getBatteryPack()
|
||||
{
|
||||
return batteryPack;
|
||||
}
|
||||
|
||||
public void setBatteryCluster(String batteryCluster)
|
||||
{
|
||||
this.batteryCluster = batteryCluster;
|
||||
}
|
||||
|
||||
public String getBatteryCluster()
|
||||
{
|
||||
return batteryCluster;
|
||||
}
|
||||
|
||||
public void setBatteryCellId(String batteryCellId)
|
||||
{
|
||||
this.batteryCellId = batteryCellId;
|
||||
}
|
||||
|
||||
public String getBatteryCellId()
|
||||
{
|
||||
return batteryCellId;
|
||||
}
|
||||
|
||||
public void setVoltage(BigDecimal voltage)
|
||||
{
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
public BigDecimal getVoltage()
|
||||
{
|
||||
return voltage;
|
||||
}
|
||||
|
||||
public void setTemperature(BigDecimal temperature)
|
||||
{
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public BigDecimal getTemperature()
|
||||
{
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setSoc(BigDecimal soc)
|
||||
{
|
||||
this.soc = soc;
|
||||
}
|
||||
|
||||
public BigDecimal getSoc()
|
||||
{
|
||||
return soc;
|
||||
}
|
||||
|
||||
public void setSoh(BigDecimal soh)
|
||||
{
|
||||
this.soh = soh;
|
||||
}
|
||||
|
||||
public BigDecimal getSoh()
|
||||
{
|
||||
return soh;
|
||||
}
|
||||
|
||||
public void setDataTimestamp(Date dataTimestamp)
|
||||
{
|
||||
this.dataTimestamp = dataTimestamp;
|
||||
}
|
||||
|
||||
public Date getDataTimestamp()
|
||||
{
|
||||
return dataTimestamp;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setClusterDeviceId(String clusterDeviceId)
|
||||
{
|
||||
this.clusterDeviceId = clusterDeviceId;
|
||||
}
|
||||
|
||||
public String getClusterDeviceId()
|
||||
{
|
||||
return clusterDeviceId;
|
||||
}
|
||||
|
||||
public void setInterResistance(BigDecimal interResistance)
|
||||
{
|
||||
this.interResistance = interResistance;
|
||||
}
|
||||
|
||||
public BigDecimal getInterResistance()
|
||||
{
|
||||
return interResistance;
|
||||
}
|
||||
|
||||
public void setHourTime(Date hourTime)
|
||||
{
|
||||
this.hourTime = hourTime;
|
||||
}
|
||||
|
||||
public Date getHourTime()
|
||||
{
|
||||
return hourTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("batteryPack", getBatteryPack())
|
||||
.append("batteryCluster", getBatteryCluster())
|
||||
.append("batteryCellId", getBatteryCellId())
|
||||
.append("voltage", getVoltage())
|
||||
.append("temperature", getTemperature())
|
||||
.append("soc", getSoc())
|
||||
.append("soh", getSoh())
|
||||
.append("dataTimestamp", getDataTimestamp())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("clusterDeviceId", getClusterDeviceId())
|
||||
.append("interResistance", getInterResistance())
|
||||
.append("hourTime", getHourTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -1,226 +0,0 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 单体电池分钟级数据对象 ems_battery_data_minutes
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-18
|
||||
*/
|
||||
public class EmsBatteryDataMinutes extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 电池堆 */
|
||||
@Excel(name = "电池堆")
|
||||
private String batteryPack;
|
||||
|
||||
/** 电池簇 */
|
||||
@Excel(name = "电池簇")
|
||||
private String batteryCluster;
|
||||
|
||||
/** 单体编号 */
|
||||
@Excel(name = "单体编号")
|
||||
private String batteryCellId;
|
||||
|
||||
/** 电压 (V) */
|
||||
@Excel(name = "电压 (V)")
|
||||
private BigDecimal voltage;
|
||||
|
||||
/** 温度 (℃) */
|
||||
@Excel(name = "温度 (℃)")
|
||||
private BigDecimal temperature;
|
||||
|
||||
/** SOC (%) */
|
||||
@Excel(name = "SOC (%)")
|
||||
private BigDecimal soc;
|
||||
|
||||
/** SOH (%) */
|
||||
@Excel(name = "SOH (%)")
|
||||
private BigDecimal soh;
|
||||
|
||||
/** 数据采集时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dataTimestamp;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
/** 簇设备id */
|
||||
@Excel(name = "簇设备id")
|
||||
private String clusterDeviceId;
|
||||
|
||||
/** 单体电池内阻 */
|
||||
@Excel(name = "单体电池内阻")
|
||||
private BigDecimal interResistance;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setBatteryPack(String batteryPack)
|
||||
{
|
||||
this.batteryPack = batteryPack;
|
||||
}
|
||||
|
||||
public String getBatteryPack()
|
||||
{
|
||||
return batteryPack;
|
||||
}
|
||||
|
||||
public void setBatteryCluster(String batteryCluster)
|
||||
{
|
||||
this.batteryCluster = batteryCluster;
|
||||
}
|
||||
|
||||
public String getBatteryCluster()
|
||||
{
|
||||
return batteryCluster;
|
||||
}
|
||||
|
||||
public void setBatteryCellId(String batteryCellId)
|
||||
{
|
||||
this.batteryCellId = batteryCellId;
|
||||
}
|
||||
|
||||
public String getBatteryCellId()
|
||||
{
|
||||
return batteryCellId;
|
||||
}
|
||||
|
||||
public void setVoltage(BigDecimal voltage)
|
||||
{
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
public BigDecimal getVoltage()
|
||||
{
|
||||
return voltage;
|
||||
}
|
||||
|
||||
public void setTemperature(BigDecimal temperature)
|
||||
{
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public BigDecimal getTemperature()
|
||||
{
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setSoc(BigDecimal soc)
|
||||
{
|
||||
this.soc = soc;
|
||||
}
|
||||
|
||||
public BigDecimal getSoc()
|
||||
{
|
||||
return soc;
|
||||
}
|
||||
|
||||
public void setSoh(BigDecimal soh)
|
||||
{
|
||||
this.soh = soh;
|
||||
}
|
||||
|
||||
public BigDecimal getSoh()
|
||||
{
|
||||
return soh;
|
||||
}
|
||||
|
||||
public void setDataTimestamp(Date dataTimestamp)
|
||||
{
|
||||
this.dataTimestamp = dataTimestamp;
|
||||
}
|
||||
|
||||
public Date getDataTimestamp()
|
||||
{
|
||||
return dataTimestamp;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setClusterDeviceId(String clusterDeviceId)
|
||||
{
|
||||
this.clusterDeviceId = clusterDeviceId;
|
||||
}
|
||||
|
||||
public String getClusterDeviceId()
|
||||
{
|
||||
return clusterDeviceId;
|
||||
}
|
||||
|
||||
public void setInterResistance(BigDecimal interResistance)
|
||||
{
|
||||
this.interResistance = interResistance;
|
||||
}
|
||||
|
||||
public BigDecimal getInterResistance()
|
||||
{
|
||||
return interResistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("batteryPack", getBatteryPack())
|
||||
.append("batteryCluster", getBatteryCluster())
|
||||
.append("batteryCellId", getBatteryCellId())
|
||||
.append("voltage", getVoltage())
|
||||
.append("temperature", getTemperature())
|
||||
.append("soc", getSoc())
|
||||
.append("soh", getSoh())
|
||||
.append("dataTimestamp", getDataTimestamp())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("clusterDeviceId", getClusterDeviceId())
|
||||
.append("interResistance", getInterResistance())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -1,242 +0,0 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 单体电池月级数据对象 ems_battery_data_month
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-22
|
||||
*/
|
||||
public class EmsBatteryDataMonth extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 电池堆 */
|
||||
@Excel(name = "电池堆")
|
||||
private String batteryPack;
|
||||
|
||||
/** 电池簇 */
|
||||
@Excel(name = "电池簇")
|
||||
private String batteryCluster;
|
||||
|
||||
/** 单体编号 */
|
||||
@Excel(name = "单体编号")
|
||||
private String batteryCellId;
|
||||
|
||||
/** 电压 (V) */
|
||||
@Excel(name = "电压 (V)")
|
||||
private BigDecimal voltage;
|
||||
|
||||
/** 温度 (℃) */
|
||||
@Excel(name = "温度 (℃)")
|
||||
private BigDecimal temperature;
|
||||
|
||||
/** SOC (%) */
|
||||
@Excel(name = "SOC (%)")
|
||||
private BigDecimal soc;
|
||||
|
||||
/** SOH (%) */
|
||||
@Excel(name = "SOH (%)")
|
||||
private BigDecimal soh;
|
||||
|
||||
/** 数据采集时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dataTimestamp;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
/** 簇设备id */
|
||||
@Excel(name = "簇设备id")
|
||||
private String clusterDeviceId;
|
||||
|
||||
/** 单体电池内阻 */
|
||||
@Excel(name = "单体电池内阻")
|
||||
private BigDecimal interResistance;
|
||||
|
||||
/** 月级时间维度 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "月级时间维度", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date monthTime;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setBatteryPack(String batteryPack)
|
||||
{
|
||||
this.batteryPack = batteryPack;
|
||||
}
|
||||
|
||||
public String getBatteryPack()
|
||||
{
|
||||
return batteryPack;
|
||||
}
|
||||
|
||||
public void setBatteryCluster(String batteryCluster)
|
||||
{
|
||||
this.batteryCluster = batteryCluster;
|
||||
}
|
||||
|
||||
public String getBatteryCluster()
|
||||
{
|
||||
return batteryCluster;
|
||||
}
|
||||
|
||||
public void setBatteryCellId(String batteryCellId)
|
||||
{
|
||||
this.batteryCellId = batteryCellId;
|
||||
}
|
||||
|
||||
public String getBatteryCellId()
|
||||
{
|
||||
return batteryCellId;
|
||||
}
|
||||
|
||||
public void setVoltage(BigDecimal voltage)
|
||||
{
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
public BigDecimal getVoltage()
|
||||
{
|
||||
return voltage;
|
||||
}
|
||||
|
||||
public void setTemperature(BigDecimal temperature)
|
||||
{
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public BigDecimal getTemperature()
|
||||
{
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setSoc(BigDecimal soc)
|
||||
{
|
||||
this.soc = soc;
|
||||
}
|
||||
|
||||
public BigDecimal getSoc()
|
||||
{
|
||||
return soc;
|
||||
}
|
||||
|
||||
public void setSoh(BigDecimal soh)
|
||||
{
|
||||
this.soh = soh;
|
||||
}
|
||||
|
||||
public BigDecimal getSoh()
|
||||
{
|
||||
return soh;
|
||||
}
|
||||
|
||||
public void setDataTimestamp(Date dataTimestamp)
|
||||
{
|
||||
this.dataTimestamp = dataTimestamp;
|
||||
}
|
||||
|
||||
public Date getDataTimestamp()
|
||||
{
|
||||
return dataTimestamp;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setClusterDeviceId(String clusterDeviceId)
|
||||
{
|
||||
this.clusterDeviceId = clusterDeviceId;
|
||||
}
|
||||
|
||||
public String getClusterDeviceId()
|
||||
{
|
||||
return clusterDeviceId;
|
||||
}
|
||||
|
||||
public void setInterResistance(BigDecimal interResistance)
|
||||
{
|
||||
this.interResistance = interResistance;
|
||||
}
|
||||
|
||||
public BigDecimal getInterResistance()
|
||||
{
|
||||
return interResistance;
|
||||
}
|
||||
|
||||
public void setMonthTime(Date monthTime)
|
||||
{
|
||||
this.monthTime = monthTime;
|
||||
}
|
||||
|
||||
public Date getMonthTime()
|
||||
{
|
||||
return monthTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("batteryPack", getBatteryPack())
|
||||
.append("batteryCluster", getBatteryCluster())
|
||||
.append("batteryCellId", getBatteryCellId())
|
||||
.append("voltage", getVoltage())
|
||||
.append("temperature", getTemperature())
|
||||
.append("soc", getSoc())
|
||||
.append("soh", getSoh())
|
||||
.append("dataTimestamp", getDataTimestamp())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("clusterDeviceId", getClusterDeviceId())
|
||||
.append("interResistance", getInterResistance())
|
||||
.append("monthTime", getMonthTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -1,151 +0,0 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 站点每日充放电数据对象 ems_daily_charge_data
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-27
|
||||
*/
|
||||
public class EmsDailyChargeData extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
/** 数据日期:yyyy-MM-dd */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "数据日期:yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dateTime;
|
||||
|
||||
/** 总充电量 */
|
||||
@Excel(name = "总充电量")
|
||||
private BigDecimal totalChargeData;
|
||||
|
||||
/** 总放电量 */
|
||||
@Excel(name = "总放电量")
|
||||
private BigDecimal totalDischargeData;
|
||||
|
||||
/** 当日充电量 */
|
||||
@Excel(name = "当日充电量")
|
||||
private BigDecimal chargeData;
|
||||
|
||||
/** 当日放电量 */
|
||||
@Excel(name = "当日放电量")
|
||||
private BigDecimal dischargeData;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDateTime(Date dateTime)
|
||||
{
|
||||
this.dateTime = dateTime;
|
||||
}
|
||||
|
||||
public Date getDateTime()
|
||||
{
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public void setTotalChargeData(BigDecimal totalChargeData)
|
||||
{
|
||||
this.totalChargeData = totalChargeData;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalChargeData()
|
||||
{
|
||||
return totalChargeData;
|
||||
}
|
||||
|
||||
public void setTotalDischargeData(BigDecimal totalDischargeData)
|
||||
{
|
||||
this.totalDischargeData = totalDischargeData;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalDischargeData()
|
||||
{
|
||||
return totalDischargeData;
|
||||
}
|
||||
|
||||
public void setChargeData(BigDecimal chargeData)
|
||||
{
|
||||
this.chargeData = chargeData;
|
||||
}
|
||||
|
||||
public BigDecimal getChargeData()
|
||||
{
|
||||
return chargeData;
|
||||
}
|
||||
|
||||
public void setDischargeData(BigDecimal dischargeData)
|
||||
{
|
||||
this.dischargeData = dischargeData;
|
||||
}
|
||||
|
||||
public BigDecimal getDischargeData()
|
||||
{
|
||||
return dischargeData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("dateTime", getDateTime())
|
||||
.append("totalChargeData", getTotalChargeData())
|
||||
.append("totalDischargeData", getTotalDischargeData())
|
||||
.append("chargeData", getChargeData())
|
||||
.append("dischargeData", getDischargeData())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -1,162 +0,0 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 点位匹配对象 ems_point_match
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-09-13
|
||||
*/
|
||||
public class EmsPointMatch extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 设备ID,主键自增长 */
|
||||
private Long id;
|
||||
|
||||
/** 点位名称 */
|
||||
@Excel(name = "点位名称")
|
||||
private String pointName;
|
||||
|
||||
/** 点位所在表 */
|
||||
@Excel(name = "点位所在表")
|
||||
private String matchTable;
|
||||
|
||||
/** 点位匹配字段 */
|
||||
@Excel(name = "点位匹配字段")
|
||||
private String matchField;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备类别,例如“STACK/CLUSTER/PCS等” */
|
||||
@Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”")
|
||||
private String deviceCategory;
|
||||
|
||||
/** 数据点位 */
|
||||
@Excel(name = "数据点位")
|
||||
private String dataPoint;
|
||||
|
||||
/** 数据点位名称 */
|
||||
@Excel(name = "数据点位名称")
|
||||
private String dataPointName;
|
||||
|
||||
/** 数据点位来源设备 */
|
||||
@Excel(name = "数据点位来源设备")
|
||||
private String dataDevice;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setPointName(String pointName)
|
||||
{
|
||||
this.pointName = pointName;
|
||||
}
|
||||
|
||||
public String getPointName()
|
||||
{
|
||||
return pointName;
|
||||
}
|
||||
|
||||
public void setMatchTable(String matchTable)
|
||||
{
|
||||
this.matchTable = matchTable;
|
||||
}
|
||||
|
||||
public String getMatchTable()
|
||||
{
|
||||
return matchTable;
|
||||
}
|
||||
|
||||
public void setMatchField(String matchField)
|
||||
{
|
||||
this.matchField = matchField;
|
||||
}
|
||||
|
||||
public String getMatchField()
|
||||
{
|
||||
return matchField;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceCategory(String deviceCategory)
|
||||
{
|
||||
this.deviceCategory = deviceCategory;
|
||||
}
|
||||
|
||||
public String getDeviceCategory()
|
||||
{
|
||||
return deviceCategory;
|
||||
}
|
||||
|
||||
public void setDataPoint(String dataPoint)
|
||||
{
|
||||
this.dataPoint = dataPoint;
|
||||
}
|
||||
|
||||
public String getDataPoint()
|
||||
{
|
||||
return dataPoint;
|
||||
}
|
||||
|
||||
public void setDataPointName(String dataPointName)
|
||||
{
|
||||
this.dataPointName = dataPointName;
|
||||
}
|
||||
|
||||
public String getDataPointName()
|
||||
{
|
||||
return dataPointName;
|
||||
}
|
||||
|
||||
public void setDataDevice(String dataDevice)
|
||||
{
|
||||
this.dataDevice = dataDevice;
|
||||
}
|
||||
|
||||
public String getDataDevice()
|
||||
{
|
||||
return dataDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("pointName", getPointName())
|
||||
.append("matchTable", getMatchTable())
|
||||
.append("matchField", getMatchField())
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceCategory", getDeviceCategory())
|
||||
.append("dataPoint", getDataPoint())
|
||||
.append("dataPointName", getDataPointName())
|
||||
.append("dataDevice", getDataDevice())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -23,12 +23,6 @@ public class AlarmRecordListRequestVo {
|
||||
/** 告警结束时间 */
|
||||
private String alarmEndTime;
|
||||
|
||||
/** 设备id */
|
||||
private String deviceId;
|
||||
|
||||
/** 告警状态 */
|
||||
private String status;
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
@ -68,20 +62,4 @@ public class AlarmRecordListRequestVo {
|
||||
public void setAlarmEndTime(String alarmEndTime) {
|
||||
this.alarmEndTime = alarmEndTime;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,9 +13,6 @@ public class AmmeterLoadDataVo {
|
||||
/** 电表名称 */
|
||||
private String deviceName;
|
||||
|
||||
/** 设备id */
|
||||
private String deviceId;
|
||||
|
||||
/** 通信状态 */
|
||||
private String emsCommunicationStatus;
|
||||
|
||||
@ -57,12 +54,4 @@ public class AmmeterLoadDataVo {
|
||||
public void setLoadDataDetailInfo(List<LoadDataDetailInfo> loadDataDetailInfo) {
|
||||
this.loadDataDetailInfo = loadDataDetailInfo;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,8 +12,7 @@ public class AmmeterMeteDataVo {
|
||||
|
||||
/** 电表名称 */
|
||||
private String deviceName;
|
||||
/** 设备id */
|
||||
private String deviceId;
|
||||
|
||||
/** 通信状态 */
|
||||
private String emsCommunicationStatus;
|
||||
|
||||
@ -55,12 +54,4 @@ public class AmmeterMeteDataVo {
|
||||
public void setMeteDataDetailInfo(List<MeteDataDetailInfo> meteDataDetailInfo) {
|
||||
this.meteDataDetailInfo = meteDataDetailInfo;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,9 +57,6 @@ public class BMSBatteryClusterVo {
|
||||
/** 设备唯一标识符 */
|
||||
private String deviceId;
|
||||
|
||||
/** 父类设备名称 */
|
||||
private String parentDeviceName;
|
||||
|
||||
private List<BMSBatteryClusterDataList> batteryDataList;
|
||||
|
||||
public String getDeviceName() {
|
||||
@ -197,12 +194,4 @@ public class BMSBatteryClusterVo {
|
||||
public void setBatteryDataList(List<BMSBatteryClusterDataList> batteryDataList) {
|
||||
this.batteryDataList = batteryDataList;
|
||||
}
|
||||
|
||||
public String getParentDeviceName() {
|
||||
return parentDeviceName;
|
||||
}
|
||||
|
||||
public void setParentDeviceName(String parentDeviceName) {
|
||||
this.parentDeviceName = parentDeviceName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,27 +23,15 @@ public class BMSBatteryDataList {
|
||||
/** 单体最高电压 (V) */
|
||||
private BigDecimal maxCellVoltage;
|
||||
|
||||
/** 最高单体电压对应点号 */
|
||||
private String maxCellVoltageId;
|
||||
|
||||
/** 单体最低电压 (V) */
|
||||
private BigDecimal minCellVoltage;
|
||||
|
||||
/** 最低单体电压对应点号 */
|
||||
private String minCellVoltageId;
|
||||
|
||||
/** 单体最高温度 (℃) */
|
||||
private BigDecimal maxCellTemp;
|
||||
|
||||
/** 最高单体温度对应点号 */
|
||||
private String maxCellTempId;
|
||||
|
||||
/** 单体最低温度 (℃) */
|
||||
private BigDecimal minCellTemp;
|
||||
|
||||
/** 最低单体温度对应点号 */
|
||||
private String minCellTempId;
|
||||
|
||||
/** 换电站id */
|
||||
private String siteId;
|
||||
|
||||
@ -129,36 +117,4 @@ public class BMSBatteryDataList {
|
||||
public void setClusterVoltage(BigDecimal clusterVoltage) {
|
||||
this.clusterVoltage = clusterVoltage;
|
||||
}
|
||||
|
||||
public String getMaxCellVoltageId() {
|
||||
return maxCellVoltageId;
|
||||
}
|
||||
|
||||
public void setMaxCellVoltageId(String maxCellVoltageId) {
|
||||
this.maxCellVoltageId = maxCellVoltageId;
|
||||
}
|
||||
|
||||
public String getMinCellTempId() {
|
||||
return minCellTempId;
|
||||
}
|
||||
|
||||
public void setMinCellTempId(String minCellTempId) {
|
||||
this.minCellTempId = minCellTempId;
|
||||
}
|
||||
|
||||
public String getMaxCellTempId() {
|
||||
return maxCellTempId;
|
||||
}
|
||||
|
||||
public void setMaxCellTempId(String maxCellTempId) {
|
||||
this.maxCellTempId = maxCellTempId;
|
||||
}
|
||||
|
||||
public String getMinCellVoltageId() {
|
||||
return minCellVoltageId;
|
||||
}
|
||||
|
||||
public void setMinCellVoltageId(String minCellVoltageId) {
|
||||
this.minCellVoltageId = minCellVoltageId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,49 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 综合查询返回-设备数据list
|
||||
*/
|
||||
public class DevicePointDataList
|
||||
{
|
||||
// 设备id
|
||||
private String deviceId;
|
||||
// 父类设备id
|
||||
private String parentDeviceId;
|
||||
// 该设备点位数据list
|
||||
private List<GeneralQueryDataVo> pointValueList;
|
||||
|
||||
public DevicePointDataList(String deviceId, List<GeneralQueryDataVo> pointValueList) {
|
||||
this.deviceId = deviceId;
|
||||
this.pointValueList = pointValueList;
|
||||
}
|
||||
|
||||
public DevicePointDataList() {
|
||||
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public List<GeneralQueryDataVo> getPointValueList() {
|
||||
return pointValueList;
|
||||
}
|
||||
|
||||
public void setPointValueList(List<GeneralQueryDataVo> pointValueList) {
|
||||
this.pointValueList = pointValueList;
|
||||
}
|
||||
|
||||
public String getParentDeviceId() {
|
||||
return parentDeviceId;
|
||||
}
|
||||
|
||||
public void setParentDeviceId(String parentDeviceId) {
|
||||
this.parentDeviceId = parentDeviceId;
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 综合查询-数据库返回结果
|
||||
*/
|
||||
public class GeneralQueryDataVo {
|
||||
|
||||
// 站点
|
||||
private String siteId;
|
||||
private String deviceId;
|
||||
private String valueDate;
|
||||
private Object pointValue;
|
||||
private String parentDeviceId;
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getValueDate() {
|
||||
return valueDate;
|
||||
}
|
||||
|
||||
public void setValueDate(String valueDate) {
|
||||
this.valueDate = valueDate;
|
||||
}
|
||||
|
||||
public Object getPointValue() {
|
||||
return pointValue;
|
||||
}
|
||||
|
||||
public void setPointValue(Object pointValue) {
|
||||
this.pointValue = pointValue;
|
||||
}
|
||||
|
||||
public String getParentDeviceId() {
|
||||
return parentDeviceId;
|
||||
}
|
||||
|
||||
public void setParentDeviceId(String parentDeviceId) {
|
||||
this.parentDeviceId = parentDeviceId;
|
||||
}
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 综合查询结果
|
||||
*
|
||||
*/
|
||||
public class GeneralQueryResponse {
|
||||
|
||||
// 站点
|
||||
private String siteId;
|
||||
|
||||
// 设备数据
|
||||
private List<DevicePointDataList> deviceList;
|
||||
|
||||
public GeneralQueryResponse(String siteId, List<DevicePointDataList> deviceList) {
|
||||
this.siteId = siteId;
|
||||
this.deviceList = deviceList;
|
||||
}
|
||||
|
||||
public GeneralQueryResponse() {
|
||||
|
||||
}
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public List<DevicePointDataList> getDeviceList() {
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
public void setDeviceList(List<DevicePointDataList> deviceList) {
|
||||
this.deviceList = deviceList;
|
||||
}
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 每月时间范围实体
|
||||
*/
|
||||
public class MonthlyTimeRange {
|
||||
// 站点ID
|
||||
private String siteId;
|
||||
// 月份(YYYY-MM)
|
||||
private String month;
|
||||
// 当月最早时间
|
||||
private LocalDateTime firstDataTime;
|
||||
// 当月最晚时间
|
||||
private LocalDateTime lastDataTime;
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(String month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public LocalDateTime getFirstDataTime() {
|
||||
return firstDataTime;
|
||||
}
|
||||
|
||||
public void setFirstDataTime(LocalDateTime firstDataTime) {
|
||||
this.firstDataTime = firstDataTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastDataTime() {
|
||||
return lastDataTime;
|
||||
}
|
||||
|
||||
public void setLastDataTime(LocalDateTime lastDataTime) {
|
||||
this.lastDataTime = lastDataTime;
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单数据统计-pcs曲线-返回对象
|
||||
*
|
||||
*/
|
||||
public class PCSCurveResponse {
|
||||
/** pcs设备id */
|
||||
private String deviceId;
|
||||
/** 数据对象 */
|
||||
private List<PcsStatisListVo> dataList;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public List<PcsStatisListVo> getDataList() {
|
||||
return dataList;
|
||||
}
|
||||
|
||||
public void setDataList(List<PcsStatisListVo> dataList) {
|
||||
this.dataList = dataList;
|
||||
}
|
||||
}
|
||||
@ -89,9 +89,6 @@ public class PcsDetailInfoVo {
|
||||
/** 设备名称 */
|
||||
private String deviceName;
|
||||
|
||||
/** 报警个数 */
|
||||
private int alarmNum;
|
||||
|
||||
private List<PcsBranchInfo> pcsBranchInfoList;
|
||||
|
||||
public String getDeviceId() {
|
||||
@ -293,12 +290,4 @@ public class PcsDetailInfoVo {
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public int getAlarmNum() {
|
||||
return alarmNum;
|
||||
}
|
||||
|
||||
public void setAlarmNum(int alarmNum) {
|
||||
this.alarmNum = alarmNum;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package com.xzzn.ems.domain.vo;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 数据统计-pcs曲线-数据list对象
|
||||
* 数据统计-pcs曲线-通用对象
|
||||
*/
|
||||
public class PcsStatisListVo {
|
||||
/**
|
||||
@ -36,9 +36,6 @@ public class PcsStatisListVo {
|
||||
*/
|
||||
private BigDecimal wCurrent;
|
||||
|
||||
/** pcs设备id */
|
||||
private String deviceId;
|
||||
|
||||
public String getStatisDate() {
|
||||
return statisDate;
|
||||
}
|
||||
@ -86,12 +83,4 @@ public class PcsStatisListVo {
|
||||
public void setwCurrent(BigDecimal wCurrent) {
|
||||
this.wCurrent = wCurrent;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,92 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 点位模糊查询入参
|
||||
*
|
||||
*/
|
||||
public class PointNameRequest {
|
||||
|
||||
private List<String> siteIds;
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private String pointName;
|
||||
|
||||
/** 数据分组 1-分钟 2-小时 3-天 */
|
||||
private int dataUnit;
|
||||
|
||||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private Map<String,List<String>> siteDeviceMap;
|
||||
|
||||
public List<String> getSiteIds() {
|
||||
return siteIds;
|
||||
}
|
||||
|
||||
public void setSiteIds(List<String> siteIds) {
|
||||
this.siteIds = siteIds;
|
||||
}
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
public void setCategoryName(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getPointName() {
|
||||
return pointName;
|
||||
}
|
||||
|
||||
public void setPointName(String pointName) {
|
||||
this.pointName = pointName;
|
||||
}
|
||||
|
||||
public int getDataUnit() {
|
||||
return dataUnit;
|
||||
}
|
||||
|
||||
public void setDataUnit(int dataUnit) {
|
||||
this.dataUnit = dataUnit;
|
||||
}
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getSiteDeviceMap() {
|
||||
return siteDeviceMap;
|
||||
}
|
||||
|
||||
public void setSiteDeviceMap(Map<String, List<String>> siteDeviceMap) {
|
||||
this.siteDeviceMap = siteDeviceMap;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
@ -12,22 +12,22 @@ public class PowerStatisListVo {
|
||||
private String statisDate;
|
||||
|
||||
/**
|
||||
* 电网功率-total_active_power(LOAD)
|
||||
* 电网功率-total_apparent_power总交流视在功率
|
||||
*/
|
||||
private BigDecimal gridPower;
|
||||
|
||||
/**
|
||||
* 负载功率
|
||||
* 负载功率-total_active_power总交流有功电率
|
||||
*/
|
||||
private BigDecimal loadPower;
|
||||
|
||||
/**
|
||||
* 储能功率-secondary_total_active_power(METE)
|
||||
* 储能功率-max_discharge_power_capacity最大可放功率
|
||||
*/
|
||||
private BigDecimal storagePower;
|
||||
|
||||
/**
|
||||
* 光伏功率-total_active_power(METEGT)
|
||||
* 光伏功率-ac_capacitive_reactive_power交流侧容性无功功率
|
||||
*/
|
||||
private BigDecimal pvPower;
|
||||
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单站监控-单体电池返回数据
|
||||
*
|
||||
*/
|
||||
public class SiteBatteryDataList {
|
||||
|
||||
// 簇相关单体最大最小值list
|
||||
@Excel(name = "簇单体最大最小值list")
|
||||
List<BMSBatteryDataList> clusterList;
|
||||
|
||||
// 单体电池list
|
||||
@Excel(name = "单体电池list")
|
||||
List<BatteryDataStatsListVo> batteryList;
|
||||
|
||||
public List<BMSBatteryDataList> getClusterList() {
|
||||
return clusterList;
|
||||
}
|
||||
|
||||
public void setClusterList(List<BMSBatteryDataList> clusterList) {
|
||||
this.clusterList = clusterList;
|
||||
}
|
||||
|
||||
public List<BatteryDataStatsListVo> getBatteryList() {
|
||||
return batteryList;
|
||||
}
|
||||
|
||||
public void setBatteryList(List<BatteryDataStatsListVo> batteryList) {
|
||||
this.batteryList = batteryList;
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
/**
|
||||
* 综合查询-站点下单体电池实际数据
|
||||
*
|
||||
*/
|
||||
public class SiteBatteryListVo {
|
||||
/** 站点id */
|
||||
private String siteId;
|
||||
private String deviceId;
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
@ -25,8 +25,6 @@ public class SiteDeviceListVo {
|
||||
private String id;
|
||||
/** 父类id */
|
||||
private String parentId;
|
||||
/** 单体电池个数-仅stack设备下有 */
|
||||
private int batteryNum;
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
@ -107,12 +105,4 @@ public class SiteDeviceListVo {
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public int getBatteryNum() {
|
||||
return batteryNum;
|
||||
}
|
||||
|
||||
public void setBatteryNum(int batteryNum) {
|
||||
this.batteryNum = batteryNum;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,10 +24,6 @@ public class SiteMonitorDataVo {
|
||||
|
||||
private BigDecimal dailyEfficiency;
|
||||
|
||||
private BigDecimal totalChargedCap;
|
||||
|
||||
private BigDecimal totalDisChargedCap;
|
||||
|
||||
public String getAmmeterDate() {
|
||||
return ammeterDate;
|
||||
}
|
||||
@ -59,20 +55,4 @@ public class SiteMonitorDataVo {
|
||||
public void setDailyEfficiency(BigDecimal dailyEfficiency) {
|
||||
this.dailyEfficiency = dailyEfficiency;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalChargedCap() {
|
||||
return totalChargedCap;
|
||||
}
|
||||
|
||||
public void setTotalChargedCap(BigDecimal totalChargedCap) {
|
||||
this.totalChargedCap = totalChargedCap;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalDisChargedCap() {
|
||||
return totalDisChargedCap;
|
||||
}
|
||||
|
||||
public void setTotalDisChargedCap(BigDecimal totalDisChargedCap) {
|
||||
this.totalDisChargedCap = totalDisChargedCap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,11 +60,6 @@ public class SiteMonitorHomeVo {
|
||||
*/
|
||||
private List<SiteMonitorDataVo> siteMonitorDataVo;
|
||||
|
||||
/**
|
||||
* 策略显示
|
||||
*/
|
||||
private StrategyTempInfo strategyTempInfo;
|
||||
|
||||
public BigDecimal getDayChargedCap() {
|
||||
return dayChargedCap;
|
||||
}
|
||||
@ -144,12 +139,4 @@ public class SiteMonitorHomeVo {
|
||||
public void setSiteMonitorDataVo(List<SiteMonitorDataVo> siteMonitorDataVo) {
|
||||
this.siteMonitorDataVo = siteMonitorDataVo;
|
||||
}
|
||||
|
||||
public StrategyTempInfo getStrategyTempInfo() {
|
||||
return strategyTempInfo;
|
||||
}
|
||||
|
||||
public void setStrategyTempInfo(StrategyTempInfo strategyTempInfo) {
|
||||
this.strategyTempInfo = strategyTempInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据统计-堆曲线-返回对象
|
||||
*
|
||||
*/
|
||||
public class StackCurveResponse {
|
||||
/** pcs设备id */
|
||||
private String deviceId;
|
||||
/** 数据对象 */
|
||||
private List<StackStatisListVo> dataList;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public List<StackStatisListVo> getDataList() {
|
||||
return dataList;
|
||||
}
|
||||
|
||||
public void setDataList(List<StackStatisListVo> dataList) {
|
||||
this.dataList = dataList;
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@ package com.xzzn.ems.domain.vo;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 数据统计-堆曲线-数据list对象
|
||||
* 数据统计-堆曲线-通用对象
|
||||
*/
|
||||
public class StackStatisListVo {
|
||||
/**
|
||||
@ -31,9 +31,6 @@ public class StackStatisListVo {
|
||||
*/
|
||||
private BigDecimal soc;
|
||||
|
||||
/** pcs设备id */
|
||||
private String deviceId;
|
||||
|
||||
public String getStatisDate() {
|
||||
return statisDate;
|
||||
}
|
||||
@ -73,12 +70,4 @@ public class StackStatisListVo {
|
||||
public void setSoc(BigDecimal soc) {
|
||||
this.soc = soc;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 策略模板的功率数据
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-13
|
||||
*/
|
||||
public class StrategyPowerDataVo
|
||||
{
|
||||
/** 开始时间 */
|
||||
private String startTime;
|
||||
|
||||
/** 结束时间 */
|
||||
private String endTime;
|
||||
|
||||
/** 充放功率 (kW) */
|
||||
@Excel(name = "充放功率 (kW)")
|
||||
private BigDecimal powerData;
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public BigDecimal getPowerData() {
|
||||
return powerData;
|
||||
}
|
||||
|
||||
public void setPowerData(BigDecimal powerData) {
|
||||
this.powerData = powerData;
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import com.xzzn.ems.domain.EmsStrategyTemp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 单站首页-策略显示
|
||||
*
|
||||
*/
|
||||
public class StrategyTempInfo {
|
||||
|
||||
/*
|
||||
* 主策略名称
|
||||
*/
|
||||
private String mainStrategyName;
|
||||
/**
|
||||
* 模板时间
|
||||
*/
|
||||
private List<EmsStrategyTemp> siteMonitorDataVo;
|
||||
|
||||
public String getMainStrategyName() {
|
||||
return mainStrategyName;
|
||||
}
|
||||
|
||||
public void setMainStrategyName(String mainStrategyName) {
|
||||
this.mainStrategyName = mainStrategyName;
|
||||
}
|
||||
|
||||
public List<EmsStrategyTemp> getSiteMonitorDataVo() {
|
||||
return siteMonitorDataVo;
|
||||
}
|
||||
|
||||
public void setSiteMonitorDataVo(List<EmsStrategyTemp> siteMonitorDataVo) {
|
||||
this.siteMonitorDataVo = siteMonitorDataVo;
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 时间点参数实体
|
||||
*/
|
||||
public class TimePointQuery {
|
||||
private String siteId;
|
||||
// 要查询的时间点
|
||||
private LocalDateTime dataTime;
|
||||
|
||||
public TimePointQuery(String siteId, LocalDateTime dataTime) {
|
||||
this.siteId = siteId;
|
||||
this.dataTime = dataTime;
|
||||
}
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataTime() {
|
||||
return dataTime;
|
||||
}
|
||||
|
||||
public void setDataTime(LocalDateTime dataTime) {
|
||||
this.dataTime = dataTime;
|
||||
}
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 时间点-总充放电数据
|
||||
*/
|
||||
public class TimePointValue {
|
||||
private String siteId;
|
||||
private LocalDateTime dataUpdateTime;
|
||||
// 总充电量
|
||||
private BigDecimal totalChargeData;
|
||||
// 总放电量
|
||||
private BigDecimal totalDischargeData;
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId) {
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public LocalDateTime getDataUpdateTime() {
|
||||
return dataUpdateTime;
|
||||
}
|
||||
|
||||
public void setDataUpdateTime(LocalDateTime dataUpdateTime) {
|
||||
this.dataUpdateTime = dataUpdateTime;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalChargeData() {
|
||||
return totalChargeData;
|
||||
}
|
||||
|
||||
public void setTotalChargeData(BigDecimal totalChargeData) {
|
||||
this.totalChargeData = totalChargeData;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalDischargeData() {
|
||||
return totalDischargeData;
|
||||
}
|
||||
|
||||
public void setTotalDischargeData(BigDecimal totalDischargeData) {
|
||||
this.totalDischargeData = totalDischargeData;
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,6 @@ package com.xzzn.ems.mapper;
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsAlarmRecords;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 告警记录Mapper接口
|
||||
@ -87,7 +86,4 @@ public interface EmsAlarmRecordsMapper
|
||||
|
||||
|
||||
public List<AlarmRecordListResponseVo> getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo);
|
||||
|
||||
// 获取站点设备告警数量
|
||||
public int getDeviceAlarmNum(@Param("siteId") String siteId, @Param("deviceId") String deviceId);
|
||||
}
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsAmmeterData;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.xzzn.ems.domain.vo.AmmeterStatisListVo;
|
||||
import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest;
|
||||
|
||||
/**
|
||||
* 总数据Mapper接口
|
||||
@ -68,24 +67,4 @@ public interface EmsAmmeterDataMapper
|
||||
* @return
|
||||
*/
|
||||
public List<AmmeterStatisListVo> getLoadDataByHour(StatisAmmeterDateRequest requestVo);
|
||||
|
||||
// 获取昨天最晚数据
|
||||
public EmsAmmeterData getYestLatestDate(@Param("siteId")String siteId, @Param("deviceId")String deviceId, @Param("yestData")String yestData);
|
||||
|
||||
// 获取可统计站点每个月的时间范围
|
||||
public List<MonthlyTimeRange> getMonthlyTimeRanges();
|
||||
|
||||
// 批量获取站点时间节点的充放电数据
|
||||
public List<TimePointValue> batchGetTimePointValues(List<TimePointQuery> timePointQueries);
|
||||
|
||||
// 概率统计-电量指标(按小时)
|
||||
public List<SiteMonitorDataVo> getChargeDataByHour(@Param("siteId")String siteId, @Param("deviceId")String deviceId,@Param("startDate")Date startDate);
|
||||
|
||||
// 概率统计-电量指标(按月)
|
||||
public List<SiteMonitorDataVo> getChargeDataByMonth(@Param("siteId")String siteId, @Param("deviceId")String deviceId,@Param("startDate")Date startDate,@Param("endDate")Date endDate);
|
||||
|
||||
// 报表统计-功率曲线
|
||||
public List<PowerStatisListVo> getPowerDataByHour(DateSearchRequest requestVo);
|
||||
public List<PowerStatisListVo> getPowerDataByDay(DateSearchRequest requestVo);
|
||||
public List<PowerStatisListVo> getPowerDataByMonth(DateSearchRequest requestVo);
|
||||
}
|
||||
|
||||
@ -1,76 +0,0 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataDay;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataHour;
|
||||
import com.xzzn.ems.domain.vo.BatteryDataStatsListVo;
|
||||
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 单体电池天级数据Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-20
|
||||
*/
|
||||
public interface EmsBatteryDataDayMapper
|
||||
{
|
||||
/**
|
||||
* 查询单体电池天级数据
|
||||
*
|
||||
* @param id 单体电池天级数据主键
|
||||
* @return 单体电池天级数据
|
||||
*/
|
||||
public EmsBatteryDataDay selectEmsBatteryDataDayById(Long id);
|
||||
|
||||
/**
|
||||
* 查询单体电池天级数据列表
|
||||
*
|
||||
* @param emsBatteryDataDay 单体电池天级数据
|
||||
* @return 单体电池天级数据集合
|
||||
*/
|
||||
public List<EmsBatteryDataDay> selectEmsBatteryDataDayList(EmsBatteryDataDay emsBatteryDataDay);
|
||||
|
||||
/**
|
||||
* 新增单体电池天级数据
|
||||
*
|
||||
* @param emsBatteryDataDay 单体电池天级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsBatteryDataDay(EmsBatteryDataDay emsBatteryDataDay);
|
||||
|
||||
/**
|
||||
* 修改单体电池天级数据
|
||||
*
|
||||
* @param emsBatteryDataDay 单体电池天级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsBatteryDataDay(EmsBatteryDataDay emsBatteryDataDay);
|
||||
|
||||
/**
|
||||
* 删除单体电池天级数据
|
||||
*
|
||||
* @param id 单体电池天级数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataDayById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除单体电池天级数据
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataDayByIds(Long[] ids);
|
||||
|
||||
EmsBatteryDataDay findDayMaxTemp(@Param("siteId") String siteId, @Param("stackId") String stackId,
|
||||
@Param("clusterId") String clusterId, @Param("batteryId") String batteryId, @Param("dayStart") LocalDateTime dayStart);
|
||||
|
||||
/**
|
||||
* 批量插入或更新天级数据(存在则更新,不存在则插入)
|
||||
*/
|
||||
void batchInsertOrUpdate(@Param("list") List<EmsBatteryDataDay> dayDataList);
|
||||
|
||||
public List<BatteryDataStatsListVo> getBatteryDayData(DateSearchRequest requestVo);
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataHour;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 单体电池小时级数据Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-19
|
||||
*/
|
||||
public interface EmsBatteryDataHourMapper
|
||||
{
|
||||
/**
|
||||
* 查询单体电池小时级数据
|
||||
*
|
||||
* @param id 单体电池小时级数据主键
|
||||
* @return 单体电池小时级数据
|
||||
*/
|
||||
public EmsBatteryDataHour selectEmsBatteryDataHourById(Long id);
|
||||
|
||||
/**
|
||||
* 查询单体电池小时级数据列表
|
||||
*
|
||||
* @param emsBatteryDataHour 单体电池小时级数据
|
||||
* @return 单体电池小时级数据集合
|
||||
*/
|
||||
public List<EmsBatteryDataHour> selectEmsBatteryDataHourList(EmsBatteryDataHour emsBatteryDataHour);
|
||||
|
||||
/**
|
||||
* 新增单体电池小时级数据
|
||||
*
|
||||
* @param emsBatteryDataHour 单体电池小时级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsBatteryDataHour(EmsBatteryDataHour emsBatteryDataHour);
|
||||
|
||||
/**
|
||||
* 修改单体电池小时级数据
|
||||
*
|
||||
* @param emsBatteryDataHour 单体电池小时级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsBatteryDataHour(EmsBatteryDataHour emsBatteryDataHour);
|
||||
|
||||
/**
|
||||
* 删除单体电池小时级数据
|
||||
*
|
||||
* @param id 单体电池小时级数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataHourById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除单体电池小时级数据
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataHourByIds(Long[] ids);
|
||||
|
||||
EmsBatteryDataHour findHourMaxTemp(@Param("siteId") String siteId, @Param("stackId") String stackId,
|
||||
@Param("clusterId") String clusterId, @Param("batteryId") String batteryId, @Param("hourStart") LocalDateTime hourStart);
|
||||
|
||||
/**
|
||||
* 批量插入或更新小时级数据(存在则更新,不存在则插入)
|
||||
*/
|
||||
void batchInsertOrUpdate(@Param("list") List<EmsBatteryDataHour> hourDataList);
|
||||
|
||||
}
|
||||
@ -1,68 +0,0 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.xzzn.ems.domain.EmsBatteryData;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataMinutes;
|
||||
|
||||
/**
|
||||
* 单体电池分钟级数据Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-17
|
||||
*/
|
||||
public interface EmsBatteryDataMinutesMapper
|
||||
{
|
||||
/**
|
||||
* 查询单体电池分钟级数据
|
||||
*
|
||||
* @param dateDay 单体电池分钟级数据主键
|
||||
* @return 单体电池分钟级数据
|
||||
*/
|
||||
public EmsBatteryDataMinutes selectEmsBatteryDataMinutesByDateDay(Date dateDay);
|
||||
|
||||
/**
|
||||
* 查询单体电池分钟级数据列表
|
||||
*
|
||||
* @param emsBatteryDataMinutes 单体电池分钟级数据
|
||||
* @return 单体电池分钟级数据集合
|
||||
*/
|
||||
public List<EmsBatteryDataMinutes> selectEmsBatteryDataMinutesList(EmsBatteryDataMinutes emsBatteryDataMinutes);
|
||||
|
||||
/**
|
||||
* 新增单体电池分钟级数据
|
||||
*
|
||||
* @param emsBatteryDataMinutes 单体电池分钟级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsBatteryDataMinutes(EmsBatteryDataMinutes emsBatteryDataMinutes);
|
||||
|
||||
/**
|
||||
* 修改单体电池分钟级数据
|
||||
*
|
||||
* @param emsBatteryDataMinutes 单体电池分钟级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsBatteryDataMinutes(EmsBatteryDataMinutes emsBatteryDataMinutes);
|
||||
|
||||
/**
|
||||
* 删除单体电池分钟级数据
|
||||
*
|
||||
* @param dateDay 单体电池分钟级数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataMinutesByDateDay(Date dateDay);
|
||||
|
||||
/**
|
||||
* 批量删除单体电池分钟级数据
|
||||
*
|
||||
* @param dateDays 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataMinutesByDateDays(Date[] dateDays);
|
||||
|
||||
int insertMinutesBatteryDataList(List<EmsBatteryDataMinutes> emsBatteryDataList);
|
||||
|
||||
public void deleteByTimeBeforeOneHour(String oneHourAgoStr);
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.xzzn.ems.domain.EmsBatteryDataMonth;
|
||||
import com.xzzn.ems.domain.vo.SiteBatteryListVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 单体电池月级数据Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-22
|
||||
*/
|
||||
public interface EmsBatteryDataMonthMapper
|
||||
{
|
||||
/**
|
||||
* 查询单体电池月级数据
|
||||
*
|
||||
* @param id 单体电池月级数据主键
|
||||
* @return 单体电池月级数据
|
||||
*/
|
||||
public EmsBatteryDataMonth selectEmsBatteryDataMonthById(Long id);
|
||||
|
||||
/**
|
||||
* 查询单体电池月级数据列表
|
||||
*
|
||||
* @param emsBatteryDataMonth 单体电池月级数据
|
||||
* @return 单体电池月级数据集合
|
||||
*/
|
||||
public List<EmsBatteryDataMonth> selectEmsBatteryDataMonthList(EmsBatteryDataMonth emsBatteryDataMonth);
|
||||
|
||||
/**
|
||||
* 新增单体电池月级数据
|
||||
*
|
||||
* @param emsBatteryDataMonth 单体电池月级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsBatteryDataMonth(EmsBatteryDataMonth emsBatteryDataMonth);
|
||||
|
||||
/**
|
||||
* 修改单体电池月级数据
|
||||
*
|
||||
* @param emsBatteryDataMonth 单体电池月级数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsBatteryDataMonth(EmsBatteryDataMonth emsBatteryDataMonth);
|
||||
|
||||
/**
|
||||
* 删除单体电池月级数据
|
||||
*
|
||||
* @param id 单体电池月级数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataMonthById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除单体电池月级数据
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataMonthByIds(Long[] ids);
|
||||
|
||||
EmsBatteryDataMonth findMonthMaxTemp(@Param("siteId") String siteId, @Param("stackId") String stackId,
|
||||
@Param("clusterId") String clusterId, @Param("batteryId") String batteryId, @Param("monthStart") LocalDateTime monthStart);
|
||||
|
||||
/**
|
||||
* 批量插入或更新月级数据(存在则更新,不存在则插入)
|
||||
*/
|
||||
void batchInsertOrUpdate(@Param("list") List<EmsBatteryDataMonth> monthDataList);
|
||||
|
||||
// 查找siteId下面所有的单体电池编码
|
||||
public List<SiteBatteryListVo> getAllBatteryIdsBySites(@Param("siteIds")String[] siteIds);
|
||||
}
|
||||
@ -1,85 +0,0 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xzzn.ems.domain.EmsDailyChargeData;
|
||||
import com.xzzn.ems.domain.vo.ElectricIndexList;
|
||||
import com.xzzn.ems.domain.vo.SiteMonitorDataVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 站点每日充放电数据Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-08-27
|
||||
*/
|
||||
public interface EmsDailyChargeDataMapper
|
||||
{
|
||||
/**
|
||||
* 查询站点每日充放电数据
|
||||
*
|
||||
* @param id 站点每日充放电数据主键
|
||||
* @return 站点每日充放电数据
|
||||
*/
|
||||
public EmsDailyChargeData selectEmsDailyChargeDataById(Long id);
|
||||
|
||||
/**
|
||||
* 查询站点每日充放电数据列表
|
||||
*
|
||||
* @param emsDailyChargeData 站点每日充放电数据
|
||||
* @return 站点每日充放电数据集合
|
||||
*/
|
||||
public List<EmsDailyChargeData> selectEmsDailyChargeDataList(EmsDailyChargeData emsDailyChargeData);
|
||||
|
||||
/**
|
||||
* 新增站点每日充放电数据
|
||||
*
|
||||
* @param emsDailyChargeData 站点每日充放电数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsDailyChargeData(EmsDailyChargeData emsDailyChargeData);
|
||||
|
||||
/**
|
||||
* 修改站点每日充放电数据
|
||||
*
|
||||
* @param emsDailyChargeData 站点每日充放电数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsDailyChargeData(EmsDailyChargeData emsDailyChargeData);
|
||||
|
||||
/**
|
||||
* 删除站点每日充放电数据
|
||||
*
|
||||
* @param id 站点每日充放电数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsDailyChargeDataById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除站点每日充放电数据
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsDailyChargeDataByIds(Long[] ids);
|
||||
|
||||
// 插入或更新站点每日充放电数据
|
||||
public void insertOrUpdateData(EmsDailyChargeData emsDailyChargeData);
|
||||
|
||||
// 获取所有站点总充总放
|
||||
public Map<String, BigDecimal> getAllSiteChargeData(@Param("nowData")String nowData, @Param("siteId")String siteId);
|
||||
|
||||
// 获取单站点时间范围内每日充放电数据
|
||||
public List<SiteMonitorDataVo> getSingleSiteChargeData(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
|
||||
|
||||
// 按天获取站点每日总充总放
|
||||
public List<SiteMonitorDataVo> getTotalChargeDataByDay(@Param("siteId")String siteId,@Param("startDate")Date startDate, @Param("endDate")Date endDate);
|
||||
|
||||
// 按月获取站点每日总充总放
|
||||
public List<SiteMonitorDataVo> getTotalChargeDataByMonth(@Param("siteId")String siteId,@Param("startDate")Date startDate, @Param("endDate")Date endDate);
|
||||
|
||||
public List<ElectricIndexList> getAllSiteChargeDataByMonth();
|
||||
}
|
||||
@ -77,16 +77,11 @@ public interface EmsDevicesSettingMapper
|
||||
public List<Map<String, Object>> getDeviceInfosBySiteIdAndCategory(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory);
|
||||
|
||||
/**
|
||||
* 获取该设备下所有的电表
|
||||
* 获取该设备下的总表
|
||||
* @param siteId
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getAmmeterNameList(String siteId);
|
||||
public List<Map<String, Object>> getLoadNameList(String siteId);
|
||||
|
||||
public EmsDevicesSetting getDeviceBySiteAndDeviceId(@Param("deviceId")String deviceId, @Param("siteId")String siteId);
|
||||
|
||||
public List<Map<String, Object>> getClusterIdsByFuzzyQuery(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory,
|
||||
@Param("parentId")String parentId);
|
||||
|
||||
public List<String> getDeviceIdsBySiteIdAndCategory(@Param("siteId")String siteId,@Param("deviceCategory")String deviceCategory);
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xzzn.ems.domain.EmsPcsData;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
@ -68,7 +70,7 @@ public interface EmsPcsDataMapper
|
||||
* @param siteId
|
||||
* @return
|
||||
*/
|
||||
public List<SiteMonitorDataVo> getPcsDataBySiteId(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
|
||||
public List<SiteMonitorDataVo> getPcsDataBySiteId(@Param("siteId")String siteId, @Param("limitTime")int limitTime);
|
||||
|
||||
/**
|
||||
* 根据站点获取设备监控的实时运行头信息
|
||||
@ -90,6 +92,12 @@ public interface EmsPcsDataMapper
|
||||
*/
|
||||
public List<PcsDetailInfoVo> getPcsDetailInfoBySiteId(String siteId);
|
||||
|
||||
/**
|
||||
* 获取总充+总放
|
||||
* @return
|
||||
*/
|
||||
public Map<String, BigDecimal> getPcsTotalChargeData(String siteId);
|
||||
|
||||
/**
|
||||
* 根据时间按天获取充放电量
|
||||
* @param siteId
|
||||
@ -98,7 +106,14 @@ public interface EmsPcsDataMapper
|
||||
* @return
|
||||
*/
|
||||
public List<SiteMonitorDataVo> getPcsDataByDay(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
|
||||
|
||||
/**
|
||||
* 根据时间按月获取充放电量
|
||||
* @param siteId
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
public List<SiteMonitorDataVo> getPcsDataByMonth(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
|
||||
/**
|
||||
* 根据时间按小时获取充放电量
|
||||
* @param siteId
|
||||
@ -127,4 +142,15 @@ public interface EmsPcsDataMapper
|
||||
public List<PcsStatisListVo> getPcsActivePowerByHour(DateSearchRequest requestVo);
|
||||
|
||||
public List<PcsStatisListVo> getPcsActivePowerByMonth(DateSearchRequest requestVo);
|
||||
|
||||
/**
|
||||
* 获取pcs功率曲线数据
|
||||
* @param requestVo
|
||||
* @return
|
||||
*/
|
||||
public List<PowerStatisListVo> getPowerDataByHour(DateSearchRequest requestVo);
|
||||
|
||||
public List<PowerStatisListVo> getPowerDataByDay(DateSearchRequest requestVo);
|
||||
|
||||
public List<PowerStatisListVo> getPowerDataByMonth(DateSearchRequest requestVo);
|
||||
}
|
||||
|
||||
@ -1,122 +0,0 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xzzn.ems.domain.EmsPointMatch;
|
||||
import com.xzzn.ems.domain.vo.GeneralQueryDataVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 点位匹配Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-09-02
|
||||
*/
|
||||
public interface EmsPointMatchMapper
|
||||
{
|
||||
/**
|
||||
* 查询点位匹配
|
||||
*
|
||||
* @param id 点位匹配主键
|
||||
* @return 点位匹配
|
||||
*/
|
||||
public EmsPointMatch selectEmsPointMatchById(Long id);
|
||||
|
||||
/**
|
||||
* 查询点位匹配列表
|
||||
*
|
||||
* @param emsPointMatch 点位匹配
|
||||
* @return 点位匹配集合
|
||||
*/
|
||||
public List<EmsPointMatch> selectEmsPointMatchList(EmsPointMatch emsPointMatch);
|
||||
|
||||
/**
|
||||
* 新增点位匹配
|
||||
*
|
||||
* @param emsPointMatch 点位匹配
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsPointMatch(EmsPointMatch emsPointMatch);
|
||||
|
||||
/**
|
||||
* 修改点位匹配
|
||||
*
|
||||
* @param emsPointMatch 点位匹配
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsPointMatch(EmsPointMatch emsPointMatch);
|
||||
|
||||
/**
|
||||
* 删除点位匹配
|
||||
*
|
||||
* @param id 点位匹配主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsPointMatchById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除点位匹配
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsPointMatchByIds(Long[] ids);
|
||||
|
||||
// 模糊查询所有点位
|
||||
public List<String> getPointNameList(@Param("siteIds") List<String> siteIds,
|
||||
@Param("deviceCategory")String deviceCategory,
|
||||
@Param("pointName") String pointName);
|
||||
|
||||
// 获取匹配信息
|
||||
public List<EmsPointMatch> getMatchInfo(@Param("siteIds") List<String> siteIds,
|
||||
@Param("deviceCategory")String deviceCategory,
|
||||
@Param("pointName") String pointName);
|
||||
// 根据条件查询数据-按分钟-单体电池特殊处理
|
||||
public List<GeneralQueryDataVo> getBatteryPointDataByMinutes(@Param("siteIds")List<String> siteIds,
|
||||
@Param("tableName")String tableName,
|
||||
@Param("tableField")String tableField,
|
||||
@Param("startDate")Date startDate,
|
||||
@Param("endDate")Date endDate,
|
||||
@Param("params") Map<String, List<String>> params);
|
||||
// 根据条件查询数据-按小时-单体电池特殊处理
|
||||
public List<GeneralQueryDataVo> getBatteryPointDataByHours(@Param("siteIds")List<String> siteIds,
|
||||
@Param("tableName")String tableName,
|
||||
@Param("tableField")String tableField,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate")Date endDate,
|
||||
@Param("params") Map<String, List<String>> params);
|
||||
// 根据条件查询数据-按天-单体电池特殊处理
|
||||
public List<GeneralQueryDataVo> getBatteryPointDataByDays(@Param("siteIds")List<String> siteIds,
|
||||
@Param("tableName")String tableName,
|
||||
@Param("tableField")String tableField,
|
||||
@Param("startDate")Date startDate,
|
||||
@Param("endDate")Date endDate,
|
||||
@Param("params") Map<String, List<String>> params);
|
||||
|
||||
// 根据条件查询数据-按分钟-其他设备
|
||||
public List<GeneralQueryDataVo> getCommonPointDataByMinutes(@Param("siteIds")List<String> siteIds,
|
||||
@Param("tableName")String tableName,
|
||||
@Param("tableField")String tableField,
|
||||
@Param("startDate")Date startDate,
|
||||
@Param("endDate")Date endDate,
|
||||
@Param("deviceId")String deviceId);
|
||||
// 根据条件查询数据-按小时-其他设备
|
||||
public List<GeneralQueryDataVo> getCommonPointDataByHours(@Param("siteIds")List<String> siteIds,
|
||||
@Param("tableName")String tableName,
|
||||
@Param("tableField")String tableField,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate")Date endDate,
|
||||
@Param("deviceId")String deviceId);
|
||||
// 根据条件查询数据-按天-其他设备
|
||||
public List<GeneralQueryDataVo> getCommonPointDataByDays(@Param("siteIds")List<String> siteIds,
|
||||
@Param("tableName")String tableName,
|
||||
@Param("tableField")String tableField,
|
||||
@Param("startDate")Date startDate,
|
||||
@Param("endDate")Date endDate,
|
||||
@Param("deviceId")String deviceId);
|
||||
|
||||
// 单个站点单个设备点位查询
|
||||
public List<EmsPointMatch> getSingleSiteDevicePoints(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory);
|
||||
}
|
||||
@ -70,7 +70,4 @@ public interface EmsStrategyTempMapper
|
||||
|
||||
// 根据模板id全部删除
|
||||
public int deleteTempByTempId(String templateId);
|
||||
|
||||
// 获取站点和策略下的模板信息
|
||||
public List<EmsStrategyTemp> getTempListBySiteIdAndStrategyId(@Param("siteId") String siteId, @Param("strategyId")Long strategyId);
|
||||
}
|
||||
|
||||
@ -16,9 +16,9 @@ public interface IEmsStatsReportService
|
||||
|
||||
public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo);
|
||||
|
||||
public List<PCSCurveResponse> getPCSDataResult(DateSearchRequest requestVo);
|
||||
public List<PcsStatisListVo> getPCSDataResult(DateSearchRequest requestVo);
|
||||
|
||||
public List<StackCurveResponse> getStackDataResult(DateSearchRequest requestVo);
|
||||
public List<StackStatisListVo> getStackDataResult(DateSearchRequest requestVo);
|
||||
|
||||
public List<ClusterStatisListVo> getClusterDataResult(StatisClusterDateRequest requestVo);
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
package com.xzzn.ems.service;
|
||||
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 综合查询 服务层
|
||||
*
|
||||
*/
|
||||
public interface IGeneralQueryService
|
||||
{
|
||||
|
||||
// 模糊查询获取点位名称List
|
||||
public List<String> getPointNameList(PointNameRequest request);
|
||||
|
||||
// 根据条件获取点位数据变化
|
||||
public List<GeneralQueryResponse> getPointValueList(PointNameRequest request);
|
||||
|
||||
// 根据siteId获取下面对应的单体电池编号
|
||||
public Map<String,List<String>> getAllBatteryIdsBySites(String[] siteIds);
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package com.xzzn.ems.service;
|
||||
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.vo.HomePageDataViewVo;
|
||||
import com.xzzn.ems.domain.vo.SingleSiteBaseInfo;
|
||||
import com.xzzn.ems.domain.vo.SiteTotalInfoVo;
|
||||
|
||||
/**
|
||||
* 站点信息 服务层
|
||||
@ -16,6 +16,4 @@ public interface IHomePageService
|
||||
public SingleSiteBaseInfo getSingleSiteBaseInfo(String siteId);
|
||||
|
||||
public HomePageDataViewVo getHomePageDataList();
|
||||
|
||||
public List<SiteMonitorDataVo> getSevenChargeData(DateSearchRequest request);
|
||||
}
|
||||
|
||||
@ -27,8 +27,7 @@ public interface ISingleSiteService
|
||||
|
||||
public List<EmsCoolingData> getCoolingDataList(String siteId);
|
||||
|
||||
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId,
|
||||
String stackDeviceId, String batteryId);
|
||||
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId);
|
||||
|
||||
public AmmeterDataResponse getAmmeterDataList(String siteId);
|
||||
|
||||
@ -37,6 +36,4 @@ public interface ISingleSiteService
|
||||
public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId);
|
||||
|
||||
public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId);
|
||||
|
||||
public List<BMSBatteryDataList> getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId);
|
||||
}
|
||||
|
||||
@ -3,10 +3,6 @@ package com.xzzn.ems.service.impl;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xzzn.common.constant.Constants;
|
||||
import com.xzzn.common.constant.RedisKeyConstants;
|
||||
import com.xzzn.common.core.redis.RedisCache;
|
||||
import com.xzzn.common.enums.*;
|
||||
@ -15,7 +11,6 @@ import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.*;
|
||||
import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.service.IDDSDataProcessService;
|
||||
import com.xzzn.ems.utils.AbstractBatteryDataProcessor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -24,16 +19,12 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IDDSDataProcessService {
|
||||
public class DDSDataProcessServiceImpl implements IDDSDataProcessService {
|
||||
private static final Log log = LogFactory.getLog(DDSDataProcessServiceImpl.class);
|
||||
private static final String SITE_ID = "021_DDS_01";
|
||||
// 正则表达式匹配BMS设备编号和属性
|
||||
@ -70,14 +61,6 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
private EmsDhDataMapper emsDhDataMapper;
|
||||
@Autowired
|
||||
private EmsBatteryGroupMapper emsBatteryGroupMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper;
|
||||
@Autowired
|
||||
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
||||
|
||||
public DDSDataProcessServiceImpl(ObjectMapper objectMapper) {
|
||||
super(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDdsData(String message) {
|
||||
@ -87,12 +70,9 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
String jsonData = obj.get("Data").toString();
|
||||
|
||||
log.info("deviceId:" + deviceId);
|
||||
boolean isEmpty = checkJsonDataEmpty(jsonData);
|
||||
if (isEmpty) {
|
||||
if (StringUtils.isEmpty(jsonData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理相关数据
|
||||
if (deviceId.contains("BMSD")) {
|
||||
batteryStackDataProcess(deviceId, jsonData);
|
||||
batteryGroupDataProcess(deviceId, jsonData);
|
||||
@ -112,11 +92,11 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
} else if (deviceId.contains("XF")) {
|
||||
meteXFProcess(deviceId, jsonData);
|
||||
} else if (deviceId.contains("DH")) {
|
||||
dhDataProcess(deviceId, jsonData);
|
||||
meteDHProcess(deviceId, jsonData);
|
||||
}
|
||||
}
|
||||
|
||||
private void dhDataProcess(String deviceId, String dataJson) {
|
||||
private void meteDHProcess(String deviceId, String dataJson) {
|
||||
//动环
|
||||
Map<String, Object> obj = JSON.parseObject(dataJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
@ -244,6 +224,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
}
|
||||
|
||||
// 批量插入数据库
|
||||
log.info("批量插入");
|
||||
if (!CollectionUtils.isEmpty(groupMap)) {
|
||||
List<EmsBatteryGroup> batteryGroupList = new ArrayList<>(groupMap.values());
|
||||
emsBatteryGroupMapper.batchInsertGroupData(batteryGroupList);
|
||||
@ -285,17 +266,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
//电池组
|
||||
Map<String, Object> obj = JSON.parseObject(dataJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
List<EmsBatteryData> dataList = new ArrayList<>();
|
||||
|
||||
// 前一个小时
|
||||
LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String oneHourAgoStr = oneHourAgo.format(formatter);
|
||||
|
||||
List<EmsBatteryDataDailyLatest> dailyList = new ArrayList<>();
|
||||
Map<String, EmsBatteryData> dataMap = new HashMap<>();
|
||||
Map<String, EmsBatteryDataDailyLatest> dailyMap = new HashMap<>();
|
||||
Map<String, EmsBatteryDataMinutes> minutesMap = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Object> entry : obj.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
|
||||
@ -323,45 +295,26 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
setDTDCPropertyValue(data, property, entry.getValue());
|
||||
dataMap.put(batteryCellId, data);
|
||||
|
||||
// 每日最新数据:按batteryCellId去重
|
||||
EmsBatteryDataDailyLatest daily = dailyMap.getOrDefault(batteryCellId, new EmsBatteryDataDailyLatest());
|
||||
// 每日最新数据
|
||||
EmsBatteryDataDailyLatest daily = new EmsBatteryDataDailyLatest();
|
||||
BeanUtils.copyProperties(data, daily);
|
||||
daily.setDateDay(DateUtils.getNowDate());
|
||||
dailyMap.put(batteryCellId, daily);
|
||||
|
||||
// 分钟级的表,上报的数据直接存入,数据上限是 1 个小时
|
||||
EmsBatteryDataMinutes minutes = minutesMap.getOrDefault(batteryCellId, new EmsBatteryDataMinutes());
|
||||
BeanUtils.copyProperties(data, minutes);
|
||||
minutesMap.put(batteryCellId, minutes);
|
||||
dailyList.add(daily);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataMap)) {
|
||||
dataList = new ArrayList<>(dataMap.values());
|
||||
List<EmsBatteryData> dataList = new ArrayList<>(dataMap.values());
|
||||
emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList));
|
||||
|
||||
redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01");
|
||||
redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01" , dataList);
|
||||
}
|
||||
// 批量处理每日最新数据
|
||||
List<EmsBatteryDataDailyLatest> dailyList = new ArrayList<>(dailyMap.values());
|
||||
if (!dailyList.isEmpty()) {
|
||||
dailyList = new ArrayList<>(dailyMap.values());
|
||||
if (dailyList != null && dailyList.size() > 0) {
|
||||
emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList);
|
||||
}
|
||||
|
||||
// 实时插入每分钟数据
|
||||
List<EmsBatteryDataMinutes> minutesList = new ArrayList<>(minutesMap.values());
|
||||
if (!minutesList.isEmpty()) {
|
||||
emsBatteryDataMinutesMapper.insertMinutesBatteryDataList(minutesList);
|
||||
}
|
||||
// 清理分钟级表里一小时前数据
|
||||
emsBatteryDataMinutesMapper.deleteByTimeBeforeOneHour(oneHourAgoStr);
|
||||
|
||||
// 分片处理时级,天级,月级数据
|
||||
if (dataList.size() > 0) {
|
||||
super.processBatch(dataList);
|
||||
}
|
||||
}
|
||||
|
||||
private void setDTDCPropertyValue(EmsBatteryData data, String property, Object value) {
|
||||
@ -445,13 +398,13 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
data.setBatteryPackSoh(StringUtils.getBigDecimal(stackObj.get("BMSD01SOH")));
|
||||
data.setAvgCellTemp(StringUtils.getBigDecimal(stackObj.get("DTPJWD")));
|
||||
data.setMaxCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZDDY")));
|
||||
data.setMaxCellVoltageId(StringUtils.getString(stackObj.get("DTZDDYXH")));
|
||||
data.setMaxCellVoltageId(StringUtils.getLong(stackObj.get("DTZDDYXH")));
|
||||
data.setMinCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZXDY")));
|
||||
data.setMinCellVoltageId(StringUtils.getString(stackObj.get("DTZXDYXH")));
|
||||
data.setMinCellVoltageId(StringUtils.getLong(stackObj.get("DTZXDYXH")));
|
||||
data.setMaxCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZGWD")));
|
||||
data.setMaxCellTempId(StringUtils.getString(stackObj.get("DTZGWDXH")));
|
||||
data.setMaxCellTempId(StringUtils.getLong(stackObj.get("DTZGWDXH")));
|
||||
data.setMinCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZDWD")));
|
||||
data.setMinCellTempId(StringUtils.getString(stackObj.get("DTZDWDXH")));
|
||||
data.setMinCellTempId(StringUtils.getLong(stackObj.get("DTZDWDXH")));
|
||||
|
||||
emsBatteryClusterMapper.insertEmsBatteryCluster(data);
|
||||
redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data);
|
||||
@ -819,13 +772,13 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
dataMete.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN")));
|
||||
dataMete.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN")));
|
||||
// 电能设置-正向有功
|
||||
dataMete.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXZYGDN")));
|
||||
dataMete.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN")));
|
||||
dataMete.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN")));
|
||||
dataMete.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN")));
|
||||
dataMete.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN")));
|
||||
dataMete.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN")));
|
||||
// 电能设置-反向有功
|
||||
dataMete.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXZYGDN")));
|
||||
dataMete.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN")));
|
||||
dataMete.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN")));
|
||||
dataMete.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN")));
|
||||
dataMete.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN")));
|
||||
@ -888,9 +841,6 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
dataMete.setVoltageUnbalanceDegree(StringUtils.getBigDecimal(obj.get("DYBPHD")));
|
||||
dataMete.setCurrentUnbalanceDegree(StringUtils.getBigDecimal(obj.get("DLBPHD")));
|
||||
|
||||
// 储能功率
|
||||
dataMete.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL")));
|
||||
|
||||
dataMete.setCreateBy("system");
|
||||
dataMete.setCreateTime(DateUtils.getNowDate());
|
||||
dataMete.setUpdateBy("system");
|
||||
@ -901,56 +851,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
emsAmmeterDataMapper.insertEmsAmmeterData(dataMete);
|
||||
|
||||
redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataMete);
|
||||
|
||||
// 处理每日充放电数据
|
||||
dealDDSDailyChargeDate(obj,deviceId);
|
||||
}
|
||||
|
||||
private void dealDDSDailyChargeDate(Map<String, Object> obj, String deviceId) {
|
||||
log.info("start dealDDSDailyChargeDate");
|
||||
// 初始化今日充放电
|
||||
BigDecimal dailyDisChargeDate = new BigDecimal(0);
|
||||
BigDecimal dailyChargeDate = new BigDecimal(0);
|
||||
|
||||
BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN"));
|
||||
BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN"));
|
||||
// 初始化当日数据
|
||||
EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData();
|
||||
emsDailyChargeData.setSiteId(SITE_ID);
|
||||
emsDailyChargeData.setDeviceId(deviceId);
|
||||
emsDailyChargeData.setDateTime(DateUtils.getNowDate());
|
||||
emsDailyChargeData.setTotalChargeData(nowTotalChargeDate);
|
||||
emsDailyChargeData.setTotalDischargeData(nowTotalDisChargeDate);
|
||||
emsDailyChargeData.setCreateBy("system");
|
||||
emsDailyChargeData.setCreateTime(DateUtils.getNowDate());
|
||||
emsDailyChargeData.setUpdateBy("system");
|
||||
emsDailyChargeData.setUpdateTime(DateUtils.getNowDate());
|
||||
// 获取redis存放昨日最晚数据
|
||||
String yestData = DateUtils.getYesterdayDate();
|
||||
String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestData;
|
||||
EmsAmmeterData yestDate = redisCache.getCacheObject(yestDateRedisKey);
|
||||
if (yestDate == null) {
|
||||
// redis没有这查电表总数据表
|
||||
yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData);
|
||||
// 数据存redis-有效期1天
|
||||
redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS);
|
||||
}
|
||||
if (yestDate != null) {
|
||||
// 今日总数据-昨日总数据=今日充放电
|
||||
BigDecimal yestTotalDisChargeDate = yestDate.getCurrentReverseActiveTotal();
|
||||
BigDecimal yestTotalChargeDate = yestDate.getCurrentForwardActiveTotal();
|
||||
|
||||
dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate);
|
||||
dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate);
|
||||
emsDailyChargeData.setChargeData(dailyChargeDate);
|
||||
emsDailyChargeData.setDischargeData(dailyDisChargeDate);
|
||||
}
|
||||
|
||||
// 插入或更新每日充放电数据表
|
||||
emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData);
|
||||
log.info("end dealDDSDailyChargeDate");
|
||||
}
|
||||
|
||||
// 数据分组处理
|
||||
private static Map<String, Map<String, Object>> processData(Map<String, Object> rawData) {
|
||||
Map<String, Map<String, Object>> records = new HashMap<>();
|
||||
@ -976,22 +877,31 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
return records;
|
||||
}
|
||||
|
||||
// 空数据不处理
|
||||
private boolean checkJsonDataEmpty(String jsonData) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
if (StringUtils.isEmpty(jsonData)) {
|
||||
flag = true;
|
||||
private static Map<String, Map<String, Object>> processDataPrefix(Map<String, Object> rawData) {
|
||||
Map<String, Map<String, Object>> records = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Object> entry : rawData.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
// 确保键长度足够
|
||||
if (key.length() < 3) {
|
||||
continue;
|
||||
}
|
||||
JsonNode jsonNode = objectMapper.readTree(jsonData);
|
||||
// 判断是否为空对象({})
|
||||
if (jsonNode.isObject() && jsonNode.isEmpty()) {
|
||||
flag = true ;
|
||||
|
||||
// 提取记录ID(前3位)
|
||||
String recordId = key.substring(0, 3);
|
||||
if (!recordId.startsWith("DY")) {
|
||||
continue;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
// 提取字段类型(剩余部分)
|
||||
String fieldType = key.substring(3);
|
||||
|
||||
// 初始化记录
|
||||
records.putIfAbsent(recordId, new HashMap<>());
|
||||
// 存入字段值
|
||||
records.get(recordId).put(fieldType, entry.getValue());
|
||||
}
|
||||
return flag;
|
||||
return records;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import com.xzzn.common.constant.RedisKeyConstants;
|
||||
import com.xzzn.common.core.redis.RedisCache;
|
||||
import com.xzzn.common.enums.DeviceCategory;
|
||||
import com.xzzn.ems.domain.EmsBatteryData;
|
||||
import com.xzzn.ems.domain.EmsSiteSetting;
|
||||
import com.xzzn.ems.domain.vo.SiteDeviceListVo;
|
||||
import com.xzzn.ems.domain.vo.SiteTotalInfoVo;
|
||||
@ -28,8 +25,6 @@ public class EmsSiteServiceImpl implements IEmsSiteService
|
||||
private EmsSiteSettingMapper emsSiteMapper;
|
||||
@Autowired
|
||||
private EmsDevicesSettingMapper emsDevicesMapper;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public List<EmsSiteSetting> getAllSites() {
|
||||
@ -81,20 +76,7 @@ public class EmsSiteServiceImpl implements IEmsSiteService
|
||||
*/
|
||||
@Override
|
||||
public List<SiteDeviceListVo> getAllDeviceList(String siteId) {
|
||||
List<SiteDeviceListVo> resultData = emsSiteMapper.getAllSiteDeviceList(siteId);
|
||||
if(resultData == null || resultData.size() == 0){
|
||||
return resultData;
|
||||
}
|
||||
for (SiteDeviceListVo siteDeviceListVo : resultData) {
|
||||
String clusterId = siteDeviceListVo.getDeviceId();
|
||||
String deviceCategory = siteDeviceListVo.getDeviceCategory();
|
||||
if(DeviceCategory.CLUSTER.getCode().equals(deviceCategory)){
|
||||
// 获取该stack下面有多少单体电池
|
||||
List<EmsBatteryData> batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId);
|
||||
siteDeviceListVo.setBatteryNum(batteryDataList == null ? 0 : batteryDataList.size());
|
||||
}
|
||||
}
|
||||
return resultData;
|
||||
return emsSiteMapper.getAllSiteDeviceList(siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import com.xzzn.common.enums.SiteEnum;
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.ems.domain.EmsAmmeterData;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||
@ -12,13 +10,11 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 统计报表数据Service业务层处理
|
||||
@ -43,13 +39,6 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
private EmsBatteryDataMapper emsBatteryDataMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDailyLatestMapper emsBatteryDailyLatestMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDataDayMapper emsBatteryDataDayMapper;
|
||||
@Autowired
|
||||
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
||||
|
||||
private static final BigDecimal DDS_STORAGE_FACTOR = new BigDecimal("0.1");
|
||||
private static final BigDecimal DDS_PV_FACTOR = new BigDecimal("-0.001");
|
||||
|
||||
// 电量指标
|
||||
@Override
|
||||
@ -62,8 +51,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
Date endDate = requestVo.getEndDate();
|
||||
|
||||
// 总充总放
|
||||
String nowData = DateUtils.getDate();
|
||||
Map<String, BigDecimal> totalMap = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,requestVo.getSiteId());
|
||||
Map<String, BigDecimal> totalMap = emsPcsDataMapper.getPcsTotalChargeData(requestVo.getSiteId());
|
||||
BigDecimal totalDischarge = totalMap.get("totalDischargedCap") != null ? totalMap.get("totalDischargedCap") : BigDecimal.ZERO;
|
||||
BigDecimal totalCharge = totalMap.get("totalChargedCap") != null ? totalMap.get("totalChargedCap") : BigDecimal.ZERO;
|
||||
BigDecimal efficiency = new BigDecimal(0);
|
||||
@ -75,40 +63,32 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
electricDataInfoVo.setTotalChargedCap(totalCharge);
|
||||
electricDataInfoVo.setEfficiency(efficiency);
|
||||
|
||||
String siteId = requestVo.getSiteId();
|
||||
String deviceId = requestVo.getDeviceId();
|
||||
// 日期筛选
|
||||
List<SiteMonitorDataVo> dataList = new ArrayList();
|
||||
// 开始日期和结束日期同一天,展示 0-24 小时数据
|
||||
if (DateUtils.isSameDay(startDate, endDate)){
|
||||
electricDataInfoVo.setUnit("时");
|
||||
if ("021_DDS_01".equals(siteId)) {
|
||||
deviceId = "METE";
|
||||
dataList = emsAmmeterDataMapper.getChargeDataByHour(siteId,deviceId,startDate);
|
||||
} else if ("021_FXX_01".equals(siteId)) {
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate);
|
||||
}
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate);
|
||||
} else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1
|
||||
&& DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){
|
||||
electricDataInfoVo.setUnit("日");
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
// 开始日期-结束日期大于 1 天,小于30 天,按天展示数据
|
||||
dataList = emsDailyChargeDataMapper.getTotalChargeDataByDay(siteId,startDate,endDate);
|
||||
dataList = emsPcsDataMapper.getPcsDataByDay(requestVo.getSiteId(), startDate, endDate);
|
||||
} else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){
|
||||
electricDataInfoVo.setUnit("月");
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
// 开始日期-结束日期大于 1 个月,按月展示数据
|
||||
dataList = emsDailyChargeDataMapper.getTotalChargeDataByMonth(siteId,startDate, endDate);
|
||||
dataList = emsPcsDataMapper.getPcsDataByMonth(requestVo.getSiteId(), startDate, endDate);
|
||||
}
|
||||
// 获取昨天昨晚一条数据,计算第一个小时的差值
|
||||
//setFirstDataDiff(dataList,siteId,deviceId);
|
||||
// 计算充放电效率
|
||||
// 根据时间获取每天的充放电量
|
||||
if (!CollectionUtils.isEmpty(dataList)){
|
||||
|
||||
for (SiteMonitorDataVo siteMonitorDataVo : dataList) {
|
||||
// 计算单天的效率
|
||||
BigDecimal dailyEfficiency = new BigDecimal(0);
|
||||
if ( siteMonitorDataVo.getChargedCap() != null &&
|
||||
siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){
|
||||
if ( siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){
|
||||
dailyEfficiency = siteMonitorDataVo.getDisChargedCap().divide(siteMonitorDataVo.getChargedCap(), 2, RoundingMode.HALF_UP);
|
||||
dailyEfficiency = dailyEfficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
@ -120,33 +100,9 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
return electricDataInfoVo;
|
||||
}
|
||||
|
||||
private void setFirstDataDiff(List<SiteMonitorDataVo> dataList, String siteId, String deviceId) {
|
||||
BigDecimal yestTotalDisChargeDate = new BigDecimal(0);
|
||||
BigDecimal yestTotalChargeDate = new BigDecimal(0);
|
||||
|
||||
String yestDate = DateUtils.getYesterdayDate();
|
||||
if (dataList != null && dataList.size()>0){
|
||||
SiteMonitorDataVo firstData = dataList.get(0);
|
||||
if ("021_DDS_01".equals(siteId)){
|
||||
EmsAmmeterData yestData = emsAmmeterDataMapper.getYestLatestDate(siteId,deviceId,yestDate);
|
||||
if (yestData != null) {
|
||||
yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal();
|
||||
yestTotalChargeDate = yestData.getCurrentForwardActiveTotal();
|
||||
}
|
||||
} else if ("021_FXX_01".equals(siteId)) {
|
||||
|
||||
}
|
||||
firstData.setChargedCap(firstData.getTotalChargedCap() == null ? BigDecimal.ZERO
|
||||
: firstData.getTotalChargedCap().subtract(yestTotalChargeDate));
|
||||
firstData.setDisChargedCap(firstData.getTotalDisChargedCap() == null ? BigDecimal.ZERO
|
||||
: firstData.getTotalDisChargedCap().subtract(yestTotalDisChargeDate));
|
||||
}
|
||||
}
|
||||
|
||||
// pcs曲线数据
|
||||
@Override
|
||||
public List<PCSCurveResponse> getPCSDataResult(DateSearchRequest requestVo) {
|
||||
List<PCSCurveResponse> responseList = new ArrayList<>();
|
||||
public List<PcsStatisListVo> getPCSDataResult(DateSearchRequest requestVo) {
|
||||
List<PcsStatisListVo> dataList = new ArrayList();
|
||||
|
||||
// 默认时间-7天
|
||||
@ -171,30 +127,12 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
// 开始日期-结束日期大于 1 个月,按月展示数据
|
||||
dataList = emsPcsDataMapper.getPcsActivePowerByMonth(requestVo);
|
||||
}
|
||||
|
||||
// 数据格式转换 按deviceId分组
|
||||
if (dataList != null && dataList.size()>0){
|
||||
responseList = dataList.stream()
|
||||
.collect(Collectors.groupingBy(PcsStatisListVo::getDeviceId))
|
||||
// 将Map转换为Set<Entry>后流转
|
||||
.entrySet().stream()
|
||||
// 映射为PCSCurveResponse对象
|
||||
.map(entry -> {
|
||||
PCSCurveResponse response = new PCSCurveResponse();
|
||||
response.setDeviceId(entry.getKey());
|
||||
response.setDataList(entry.getValue());
|
||||
return response;
|
||||
})
|
||||
// 收集为List
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return responseList;
|
||||
return dataList;
|
||||
}
|
||||
|
||||
// 电池堆曲线
|
||||
@Override
|
||||
public List<StackCurveResponse> getStackDataResult(DateSearchRequest requestVo) {
|
||||
List<StackCurveResponse> responseList = new ArrayList<>();
|
||||
public List<StackStatisListVo> getStackDataResult(DateSearchRequest requestVo) {
|
||||
List<StackStatisListVo> dataList = new ArrayList();
|
||||
// 默认时间-7天
|
||||
dealRequestTime(requestVo);
|
||||
@ -218,24 +156,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
// 开始日期-结束日期大于 1 个月,按月展示数据
|
||||
dataList = emsBatteryStackMapper.getStackDataByMonth(requestVo);
|
||||
}
|
||||
|
||||
// 数据格式转换 按deviceId分组
|
||||
if (dataList != null && dataList.size()>0){
|
||||
responseList = dataList.stream()
|
||||
.collect(Collectors.groupingBy(StackStatisListVo::getDeviceId))
|
||||
// 将Map转换为Set<Entry>后流转
|
||||
.entrySet().stream()
|
||||
// 映射为PCSCurveResponse对象
|
||||
.map(entry -> {
|
||||
StackCurveResponse response = new StackCurveResponse();
|
||||
response.setDeviceId(entry.getKey());
|
||||
response.setDataList(entry.getValue());
|
||||
return response;
|
||||
})
|
||||
// 收集为List
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return responseList;
|
||||
return dataList;
|
||||
}
|
||||
|
||||
// 电池温度
|
||||
@ -255,7 +176,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getLoadNameList(String siteId) {
|
||||
return emsDevicesSettingMapper.getAmmeterNameList(siteId);
|
||||
return emsDevicesSettingMapper.getLoadNameList(siteId);
|
||||
}
|
||||
|
||||
// 电表报表
|
||||
@ -333,52 +254,23 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
if (DateUtils.isSameDay(startDate, endDate)){
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
requestVo.setEndDate(endDate);
|
||||
dataList = emsAmmeterDataMapper.getPowerDataByHour(requestVo);
|
||||
dataList = emsPcsDataMapper.getPowerDataByHour(requestVo);
|
||||
} else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1
|
||||
&& DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
requestVo.setEndDate(endDate);
|
||||
// 开始日期-结束日期大于 1 天,小于30 天,按天展示数据
|
||||
dataList = emsAmmeterDataMapper.getPowerDataByDay(requestVo);
|
||||
dataList = emsPcsDataMapper.getPowerDataByDay(requestVo);
|
||||
} else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){
|
||||
endDate = DateUtils.addDays(endDate, 1);
|
||||
requestVo.setEndDate(endDate);
|
||||
// 开始日期-结束日期大于 1 个月,按月展示数据
|
||||
dataList = emsAmmeterDataMapper.getPowerDataByMonth(requestVo);
|
||||
dataList = emsPcsDataMapper.getPowerDataByMonth(requestVo);
|
||||
}
|
||||
|
||||
// 处理数据设置 负荷功率
|
||||
dealDataPower(requestVo.getSiteId(),dataList);
|
||||
return dataList;
|
||||
}
|
||||
|
||||
private void dealDataPower(String siteId, List<PowerStatisListVo> dataList) {
|
||||
DecimalFormat df = new DecimalFormat("0.####");
|
||||
|
||||
if (dataList == null || dataList.size() == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
for (PowerStatisListVo powerStatisListVo : dataList) {
|
||||
BigDecimal gridPower = powerStatisListVo.getGridPower() == null ? BigDecimal.ZERO : powerStatisListVo.getGridPower();
|
||||
BigDecimal storagePower = powerStatisListVo.getStoragePower() == null ? BigDecimal.ZERO : powerStatisListVo.getStoragePower();
|
||||
BigDecimal pvPower = powerStatisListVo.getPvPower() == null ? BigDecimal.ZERO : powerStatisListVo.getPvPower();
|
||||
BigDecimal loadPower = new BigDecimal(0);
|
||||
|
||||
// 电动所:储能功率=储能功率乘0.1;光伏功率=光伏功率*乘-0.001;负荷功率=电网功率+光伏功率-储能功率
|
||||
if (SiteEnum.DDS.getCode().equals(siteId)){
|
||||
powerStatisListVo.setStoragePower(storagePower.multiply(DDS_STORAGE_FACTOR).stripTrailingZeros());
|
||||
powerStatisListVo.setPvPower(pvPower.multiply(DDS_PV_FACTOR).stripTrailingZeros());
|
||||
loadPower = gridPower.add(powerStatisListVo.getPvPower()).subtract(powerStatisListVo.getStoragePower());
|
||||
powerStatisListVo.setLoadPower(loadPower);
|
||||
} else if (SiteEnum.FX.getCode().equals(siteId)){
|
||||
// 奉贤:负荷功率=电网功率-储能功率;
|
||||
loadPower = gridPower.subtract(storagePower);
|
||||
powerStatisListVo.setLoadPower(loadPower);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 统计入参时间处理
|
||||
public void dealRequestTime(DateSearchRequest requestVo){
|
||||
|
||||
@ -403,6 +295,6 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
public List<BatteryDataStatsListVo> getSingleBatteryData(DateSearchRequest requestVo) {
|
||||
// 默认时间-7天
|
||||
dealRequestTime(requestVo);
|
||||
return emsBatteryDataDayMapper.getBatteryDayData(requestVo);
|
||||
return emsBatteryDailyLatestMapper.getBatteryDailyLatest(requestVo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,10 +4,6 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xzzn.common.constant.Constants;
|
||||
import com.xzzn.common.constant.RedisKeyConstants;
|
||||
import com.xzzn.common.core.redis.RedisCache;
|
||||
import com.xzzn.common.enums.*;
|
||||
@ -16,25 +12,18 @@ import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.*;
|
||||
import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.service.IFXXDataProcessService;
|
||||
import com.xzzn.ems.utils.AbstractBatteryDataProcessor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXDataProcessService {
|
||||
public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
private static final Log log = LogFactory.getLog(FXXDataProcessServiceImpl.class);
|
||||
private static final String SITE_ID = "021_FXX_01";
|
||||
|
||||
@Autowired
|
||||
private EmsBatteryClusterMapper emsBatteryClusterMapper;
|
||||
|
||||
@ -60,17 +49,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
private EmsAmmeterDataMapper emsAmmeterDataMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDailyLatestServiceImpl emsBatteryDailyLatestServiceImpl;
|
||||
@Autowired
|
||||
private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper;
|
||||
@Autowired
|
||||
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
||||
@Autowired
|
||||
private EmsDhDataMapper emsDhDataMapper;
|
||||
|
||||
// 构造方法(调用父类构造)
|
||||
public FXXDataProcessServiceImpl(ObjectMapper objectMapper) {
|
||||
super(objectMapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleFxData(String message) {
|
||||
@ -83,11 +61,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
String jsonData = obj.get("Data").toString();
|
||||
|
||||
log.info("deviceId:" + deviceId);
|
||||
boolean isEmpty = checkJsonDataEmpty(jsonData);
|
||||
if (isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deviceId.contains("BMSD")) {
|
||||
batteryStackDataProcess(deviceId, jsonData);
|
||||
|
||||
@ -99,39 +72,14 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
} else if (deviceId.contains("PCS")) {
|
||||
pcsDataProcess(deviceId, jsonData);
|
||||
pcsBranchDataProcess(deviceId, jsonData);
|
||||
dealFXXDailyChargeDate(deviceId, jsonData);
|
||||
} else if (deviceId.contains("LOAD")) {
|
||||
loadDataProcess(deviceId, jsonData);
|
||||
} else if (deviceId.contains("METE")) {
|
||||
} else if (deviceId.contains("METE")) {
|
||||
meteDataProcess(deviceId, jsonData);
|
||||
} else if (deviceId.contains("donghuan")) {
|
||||
dhDataProcess(deviceId, jsonData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dhDataProcess(String deviceId, String dataJson) {
|
||||
//动环
|
||||
Map<String, Object> obj = JSON.parseObject(dataJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
//DH
|
||||
EmsDhData dhData = new EmsDhData();
|
||||
|
||||
dhData.setHumidity(StringUtils.getBigDecimal(obj.get("SD3")));
|
||||
dhData.setTemperature(StringUtils.getBigDecimal(obj.get("WD3")));
|
||||
|
||||
dhData.setCreateBy("system");
|
||||
dhData.setCreateTime(DateUtils.getNowDate());
|
||||
dhData.setUpdateBy("system");
|
||||
dhData.setUpdateTime(DateUtils.getNowDate());
|
||||
dhData.setSiteId(SITE_ID);
|
||||
dhData.setDeviceId(deviceId);
|
||||
emsDhDataMapper.insertEmsDhData(dhData);
|
||||
|
||||
redisCache.setCacheObject(RedisKeyConstants.DH + SITE_ID + "_" +deviceId, dhData);
|
||||
}
|
||||
|
||||
private void batteryStackDataProcess(String deviceId, String dataJson) {
|
||||
|
||||
//电池堆
|
||||
@ -275,14 +223,14 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
data.setUpdateTime(DateUtils.getNowDate());
|
||||
data.setSiteId(SITE_ID);
|
||||
data.setDeviceId(deviceId);
|
||||
data.setMaxCellVoltageId(StringUtils.getString(obj.get("ZGDTDYDYD")));
|
||||
data.setMinCellVoltageId(StringUtils.getString(obj.get("ZDDTDYDYD")));
|
||||
data.setMaxCellTempId(StringUtils.getString(obj.get("ZGDTWDDYD")));
|
||||
data.setMinCellTempId(StringUtils.getString(obj.get("ZDDTWDDYD")));
|
||||
data.setMaxCellSocId(StringUtils.getString(obj.get("ZGDTSOCDYD")));
|
||||
data.setMinCellSocId(StringUtils.getString(obj.get("ZDDTSOCDYD")));
|
||||
data.setMaxCellSohId(StringUtils.getString(obj.get("ZGDTSOHDYD")));
|
||||
data.setMinCellSohId(StringUtils.getString(obj.get("ZDDTSOHDYD")));
|
||||
data.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD")));
|
||||
data.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD")));
|
||||
data.setMaxCellTempId(StringUtils.getLong(obj.get("ZGDTWDDYD")));
|
||||
data.setMinCellTempId(StringUtils.getLong(obj.get("ZDDTWDDYD")));
|
||||
data.setMaxCellSocId(StringUtils.getLong(obj.get("ZGDTSOCDYD")));
|
||||
data.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD")));
|
||||
data.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD")));
|
||||
data.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD")));
|
||||
if (StringUtils.isNotBlank(stackDeviceId)) {
|
||||
data.setStackDeviceId(stackDeviceId);
|
||||
} else {
|
||||
@ -309,11 +257,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
Map<String, Map<String, Object>> records = processData(JSON.parseObject(dataJson, new TypeReference<Map<String, Object>>() {}));
|
||||
List<EmsBatteryData> list = new ArrayList<>();
|
||||
List<EmsBatteryDataDailyLatest> dailyList = new ArrayList<>();
|
||||
List<EmsBatteryDataMinutes> minutesList = new ArrayList<>();
|
||||
// 前一个小时
|
||||
LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String oneHourAgoStr = oneHourAgo.format(formatter);
|
||||
//单体电池
|
||||
for (Map.Entry<String, Map<String, Object>> record : records.entrySet()) {
|
||||
String recordId = record.getKey();
|
||||
@ -332,14 +275,11 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
|
||||
// 时间戳
|
||||
batteryData.setDataTimestamp(new Date());
|
||||
// 系统管理字段
|
||||
batteryData.setCreateBy("system");
|
||||
batteryData.setCreateTime(DateUtils.getNowDate());
|
||||
batteryData.setUpdateBy("system");
|
||||
batteryData.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
// ID字段
|
||||
batteryData.setSiteId(SITE_ID);
|
||||
batteryData.setClusterDeviceId(deviceId);
|
||||
|
||||
list.add(batteryData);
|
||||
|
||||
// 每日最新数据
|
||||
@ -347,34 +287,18 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
BeanUtils.copyProperties(batteryData, daily);
|
||||
daily.setDateDay(DateUtils.getNowDate());
|
||||
dailyList.add(daily);
|
||||
|
||||
// 分钟级的表,上报的数据直接存入,数据上限是 1 个小时
|
||||
EmsBatteryDataMinutes minutes = new EmsBatteryDataMinutes();
|
||||
BeanUtils.copyProperties(batteryData, minutes);
|
||||
minutesList.add(minutes);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
if (list.size() > 0 ) {
|
||||
emsBatteryDataMapper.insertEmsBatteryDataList(list);
|
||||
|
||||
redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId);
|
||||
redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId, list);
|
||||
redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId);
|
||||
redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, list);
|
||||
}
|
||||
|
||||
// 批量处理每日最新数据
|
||||
if (dailyList != null && dailyList.size() > 0) {
|
||||
emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList);
|
||||
}
|
||||
// 实时插入每分钟数据
|
||||
if (minutesList != null && minutesList.size() > 0) {
|
||||
emsBatteryDataMinutesMapper.insertMinutesBatteryDataList(minutesList);
|
||||
}
|
||||
// 清理分钟级表里一小时前数据
|
||||
emsBatteryDataMinutesMapper.deleteByTimeBeforeOneHour(oneHourAgoStr);
|
||||
|
||||
// 分片处理时级,天级,月级数据
|
||||
if (list.size() > 0) {
|
||||
super.processBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
private void pcsDataProcess(String deviceId, String dataJson) {
|
||||
@ -460,7 +384,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
|
||||
EmsPcsBranchData data = new EmsPcsBranchData();
|
||||
data.setDeviceId(deviceId);
|
||||
data.setSiteId(SITE_ID);
|
||||
data.setGridStatus(GridStatus.GRID.getCode());
|
||||
data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL")));
|
||||
data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY")));
|
||||
@ -485,10 +408,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL")));
|
||||
data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK")));
|
||||
data.setBranchId(recordId);
|
||||
data.setCreateBy("system");
|
||||
data.setCreateTime(DateUtils.getNowDate());
|
||||
data.setUpdateBy("system");
|
||||
data.setUpdateTime(DateUtils.getNowDate());
|
||||
list.add(data);
|
||||
}
|
||||
if (list.size() > 0 ) {
|
||||
@ -599,30 +518,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad);
|
||||
}
|
||||
|
||||
private void dealFXXDailyChargeDate(String deviceId, String dataJson) {
|
||||
log.info("start dealFXXDailyChargeDate");
|
||||
//日充放电数据
|
||||
Map<String, Object> obj = JSON.parseObject(dataJson, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// 初始化当日数据
|
||||
EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData();
|
||||
emsDailyChargeData.setSiteId(SITE_ID);
|
||||
emsDailyChargeData.setDeviceId(deviceId);
|
||||
emsDailyChargeData.setDateTime(DateUtils.getNowDate());
|
||||
emsDailyChargeData.setTotalChargeData(StringUtils.getBigDecimal(obj.get("ZCDL")));
|
||||
emsDailyChargeData.setTotalDischargeData(StringUtils.getBigDecimal(obj.get("ZFDL")));
|
||||
emsDailyChargeData.setChargeData(StringUtils.getBigDecimal(obj.get("RCDL")));
|
||||
emsDailyChargeData.setDischargeData(StringUtils.getBigDecimal(obj.get("RFDL")));
|
||||
emsDailyChargeData.setCreateBy("system");
|
||||
emsDailyChargeData.setCreateTime(DateUtils.getNowDate());
|
||||
emsDailyChargeData.setUpdateBy("system");
|
||||
emsDailyChargeData.setUpdateTime(DateUtils.getNowDate());
|
||||
// 插入或更新每日充放电数据表
|
||||
emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData);
|
||||
log.info("end dealFXXDailyChargeDate");
|
||||
}
|
||||
|
||||
private void meteDataProcess(String deviceId, String dataJson) {
|
||||
|
||||
//总表
|
||||
@ -762,21 +657,4 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl
|
||||
return records;
|
||||
}
|
||||
|
||||
// 空数据不处理
|
||||
private boolean checkJsonDataEmpty(String jsonData) {
|
||||
boolean flag = false;
|
||||
try {
|
||||
if (StringUtils.isEmpty(jsonData)) {
|
||||
flag = true;
|
||||
}
|
||||
JsonNode jsonNode = objectMapper.readTree(jsonData);
|
||||
// 判断是否为空对象({})
|
||||
if (jsonNode.isObject() && jsonNode.isEmpty()) {
|
||||
flag = true ;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,443 +0,0 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import com.xzzn.common.enums.DeviceCategory;
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.ems.domain.EmsPointMatch;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import com.xzzn.ems.mapper.EmsBatteryDataMonthMapper;
|
||||
import com.xzzn.ems.mapper.EmsDevicesSettingMapper;
|
||||
import com.xzzn.ems.mapper.EmsPointMatchMapper;
|
||||
import com.xzzn.ems.service.IGeneralQueryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 综合查询 服务层实现
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class GeneralQueryServiceImpl implements IGeneralQueryService
|
||||
{
|
||||
private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
|
||||
|
||||
@Autowired
|
||||
private EmsPointMatchMapper emsPointMatchMapper;
|
||||
@Autowired
|
||||
private EmsDevicesSettingMapper emsDevicesSettingMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDataMonthMapper emsBatteryDataMonthMapper;
|
||||
|
||||
@Override
|
||||
public List<String> getPointNameList(PointNameRequest request) {
|
||||
List<String> siteIds = request.getSiteIds();
|
||||
if (siteIds == null || siteIds.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String categoryName = request.getCategoryName();
|
||||
String deviceCategory = DeviceCategory.getCodeByInfo(categoryName);
|
||||
if (deviceCategory == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return emsPointMatchMapper.getPointNameList(siteIds,deviceCategory,request.getPointName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getAllBatteryIdsBySites(String[] siteIds) {
|
||||
Map<String, List<String>> resultMap = new HashMap<>();
|
||||
if (siteIds == null || siteIds.length == 0) {
|
||||
return resultMap;
|
||||
}
|
||||
List<SiteBatteryListVo> siteBatteryListVos = emsBatteryDataMonthMapper.getAllBatteryIdsBySites(siteIds);
|
||||
resultMap = convertToMap(siteBatteryListVos);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> convertToMap(List<SiteBatteryListVo> siteDeviceList) {
|
||||
Map<String, List<String>> resultMap = new HashMap<>();
|
||||
|
||||
for (SiteBatteryListVo item : siteDeviceList) {
|
||||
String siteId = item.getSiteId ();
|
||||
String deviceId = item.getDeviceId ();
|
||||
if (!resultMap.containsKey (siteId)) {
|
||||
resultMap.put (siteId, new ArrayList<>());
|
||||
}
|
||||
resultMap.get (siteId).add (deviceId);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GeneralQueryResponse> getPointValueList(PointNameRequest request){
|
||||
List<GeneralQueryResponse> result = new ArrayList<>();
|
||||
List<String> querySiteIds = new ArrayList<>();
|
||||
|
||||
List<String> siteIds = request.getSiteIds();
|
||||
String categoryName = request.getCategoryName();
|
||||
String deviceCategory = DeviceCategory.getCodeByInfo(categoryName);
|
||||
// 根据入参获取点位对应的表和字段
|
||||
List<EmsPointMatch> matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceCategory,request.getPointName());
|
||||
if (matchInfo == null || matchInfo.size() == 0) {
|
||||
return result;
|
||||
} else {
|
||||
for (EmsPointMatch emsPointMatch : matchInfo) {
|
||||
querySiteIds.add(emsPointMatch.getSiteId());
|
||||
}
|
||||
}
|
||||
|
||||
// 单体电池特殊校验
|
||||
Map<String,List<String>> siteDeviceMap = request.getSiteDeviceMap();
|
||||
if (DeviceCategory.BATTERY.getCode().equals(deviceCategory) && (siteDeviceMap == null || siteDeviceMap.size() == 0)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 处理时间范围,如果未传根据数据单位设默认值
|
||||
dealDataTime(request);
|
||||
|
||||
try {
|
||||
// 不同的site_id根据设备类型和字段,默认取第一个匹配到的表和表字段只会有一个,
|
||||
String tableName = matchInfo.get(0).getMatchTable();
|
||||
String tableField = matchInfo.get(0).getMatchField();
|
||||
|
||||
if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) {
|
||||
// 单体电池数据特殊处理
|
||||
result = generalQueryBatteryData(querySiteIds,tableName,tableField,request,deviceCategory);
|
||||
} else {
|
||||
// 其他设备数据
|
||||
result = generalQueryCommonData(querySiteIds,tableName,tableField,request,deviceCategory);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<GeneralQueryResponse> generalQueryCommonData(List<String> querySiteIds,String tableName,
|
||||
String tableField, PointNameRequest request,
|
||||
String deviceCategory) throws ParseException {
|
||||
List<GeneralQueryResponse> result = new ArrayList<>();
|
||||
List<GeneralQueryDataVo> dataVoList = new ArrayList<>();
|
||||
|
||||
int dataUnit = request.getDataUnit();
|
||||
String deviceId = request.getDeviceId();
|
||||
Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate());
|
||||
Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate());
|
||||
if (dataUnit == 1) { // 分钟:yyyy-MM-dd HH:mm:ss
|
||||
startDate = DateUtils.adjustToStartOfMinutes(request.getStartDate());
|
||||
dataVoList = emsPointMatchMapper.getCommonPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate,deviceId);
|
||||
if (dataVoList != null && dataVoList.size() > 0) {
|
||||
dataVoList = dealWithMinutesData(querySiteIds,dataVoList,deviceCategory,
|
||||
request.getStartDate(),request.getEndDate());
|
||||
}
|
||||
} else if (dataUnit == 2) { // 小时:yyyy-MM-dd HH:mm:ss
|
||||
dataVoList = emsPointMatchMapper.getCommonPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate,deviceId);
|
||||
} else if (dataUnit == 3) { // 天:yyyy-MM-dd 00:00:00
|
||||
endDate = DateUtils.adjustToEndOfDay(request.getEndDate());
|
||||
dataVoList = emsPointMatchMapper.getCommonPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,deviceId);
|
||||
}
|
||||
|
||||
// 数据转换
|
||||
result = convertCommonToResultList(dataVoList);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<GeneralQueryResponse> generalQueryBatteryData(List<String> querySiteIds,String tableName,
|
||||
String tableField, PointNameRequest request,
|
||||
String deviceCategory) throws ParseException {
|
||||
List<GeneralQueryResponse> result = new ArrayList<>();
|
||||
List<GeneralQueryDataVo> dataVoList = new ArrayList<>();
|
||||
|
||||
int dataUnit = request.getDataUnit();
|
||||
Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate());
|
||||
Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate());
|
||||
Map<String,List<String>> siteDeviceMap = request.getSiteDeviceMap();
|
||||
if (dataUnit == 1) { // 分钟
|
||||
startDate = DateUtils.adjustToStartOfMinutes(request.getStartDate());
|
||||
dataVoList = emsPointMatchMapper.getBatteryPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap);
|
||||
if (dataVoList != null && dataVoList.size() > 0) {
|
||||
dataVoList = dealWithBatteryMinutesData(querySiteIds,dataVoList,deviceCategory,
|
||||
request.getStartDate(),request.getEndDate(),siteDeviceMap);
|
||||
}
|
||||
} else if (dataUnit == 2) { // 小时
|
||||
startDate = DateUtils.adjustToStartOfHour(request.getStartDate());
|
||||
tableName = "ems_battery_data_hour";
|
||||
dataVoList = emsPointMatchMapper.getBatteryPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap);
|
||||
} else if (dataUnit == 3) { // 天
|
||||
endDate = DateUtils.adjustToEndOfDay(request.getEndDate());
|
||||
tableName = "ems_battery_data_day";
|
||||
dataVoList = emsPointMatchMapper.getBatteryPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap);
|
||||
}
|
||||
// 数据转换
|
||||
result = convertBatteryToResultList(dataVoList);
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<GeneralQueryResponse> convertBatteryToResultList(List<GeneralQueryDataVo> dataVoList) {
|
||||
// 先按siteId分组
|
||||
return dataVoList.stream()
|
||||
.collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId))
|
||||
.entrySet().stream()
|
||||
.map(siteEntry -> {
|
||||
String siteId = siteEntry.getKey();
|
||||
List<GeneralQueryDataVo> siteData = siteEntry.getValue();
|
||||
|
||||
// 2. 按(deviceId + parentDeviceId)组合分组,生成deviceList
|
||||
List<DevicePointDataList> deviceList = siteData.stream()
|
||||
// 分组键:deviceId + parentDeviceId(确保唯一设备)
|
||||
.collect(Collectors.groupingBy(data ->
|
||||
data.getDeviceId() + "_" + data.getParentDeviceId()
|
||||
))
|
||||
.entrySet().stream()
|
||||
.map(deviceEntry -> {
|
||||
// 解析分组键,获取deviceId和parentDeviceId
|
||||
String[] keyParts = deviceEntry.getKey().split("_");
|
||||
String deviceId = keyParts[0];
|
||||
String parentDeviceId = keyParts[1];
|
||||
|
||||
// 3. 转换为PointValue列表
|
||||
List<GeneralQueryDataVo> pointValueList = deviceEntry.getValue().stream()
|
||||
.map(data -> {
|
||||
GeneralQueryDataVo pv = new GeneralQueryDataVo();
|
||||
pv.setSiteId(siteId);
|
||||
pv.setDeviceId(deviceId);
|
||||
pv.setValueDate(data.getValueDate());
|
||||
pv.setPointValue(data.getPointValue());
|
||||
pv.setParentDeviceId(parentDeviceId);
|
||||
return pv;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 4. 构建DeviceItem
|
||||
DevicePointDataList deviceItem = new DevicePointDataList();
|
||||
deviceItem.setDeviceId(deviceId);
|
||||
deviceItem.setParentDeviceId(parentDeviceId);
|
||||
deviceItem.setPointValueList(pointValueList);
|
||||
return deviceItem;
|
||||
})// 关键排序步骤:先按deviceId升序,再按parentDeviceId升序
|
||||
.sorted(
|
||||
Comparator.comparing(DevicePointDataList::getDeviceId) // 第一排序键:deviceId
|
||||
.thenComparing(DevicePointDataList::getParentDeviceId) // 第二排序键:parentDeviceId
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 5. 构建SiteData
|
||||
GeneralQueryResponse site = new GeneralQueryResponse();
|
||||
site.setSiteId(siteId);
|
||||
site.setDeviceList(deviceList);
|
||||
return site;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<GeneralQueryResponse> convertCommonToResultList(List<GeneralQueryDataVo> dataVoList) {
|
||||
// 数据转换: 先按siteId分组,再按deviceId分组
|
||||
return dataVoList.stream()
|
||||
// 第一层分组:按siteId分组,得到 <siteId, 该站点所有数据>
|
||||
.collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId))
|
||||
.entrySet().stream()
|
||||
.map(siteEntry -> {
|
||||
String siteId = siteEntry.getKey();
|
||||
List<GeneralQueryDataVo> siteAllData = siteEntry.getValue();
|
||||
|
||||
// 第二层分组:在当前站点下,按deviceId分组,得到 <deviceId, 该设备所有数据>
|
||||
List<DevicePointDataList> deviceList = siteAllData.stream()
|
||||
.collect(Collectors.groupingBy(GeneralQueryDataVo::getDeviceId))
|
||||
.entrySet().stream()
|
||||
.map(deviceEntry -> new DevicePointDataList(
|
||||
deviceEntry.getKey(),
|
||||
deviceEntry.getValue()
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new GeneralQueryResponse(siteId, deviceList);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
private void dealDataTime(PointNameRequest request) {
|
||||
String startDate = request.getStartDate();
|
||||
String endDate = request.getEndDate();
|
||||
int dataUnit = request.getDataUnit();
|
||||
if (startDate == null || endDate == null) {
|
||||
// 前端未传递时,根据dataunit设置默认时间范围
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime start;
|
||||
LocalDateTime end;
|
||||
switch (dataUnit) {
|
||||
case 1: // 按分钟 - 前一小时
|
||||
end = now;
|
||||
start = now.minusHours(1);
|
||||
break;
|
||||
case 2: // 按小时 - 当天
|
||||
end = now.with(LocalTime.MAX);
|
||||
start = now.with(LocalTime.MIN);
|
||||
break;
|
||||
case 3: // 按天 - 当月
|
||||
end = now.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
|
||||
start = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("无效的dataunit值: " + dataUnit);
|
||||
}
|
||||
// 格式化为字符串(与前端传递的格式一致)
|
||||
startDate = DateUtils.convertToString(start);
|
||||
endDate = DateUtils.convertToString(end);
|
||||
}
|
||||
request.setStartDate(startDate);
|
||||
request.setEndDate(endDate);
|
||||
}
|
||||
|
||||
private List<GeneralQueryDataVo> dealWithMinutesData(List<String> querySiteIds, List<GeneralQueryDataVo> dataVoList,
|
||||
String deviceCategory, String startDate, String endDate) throws ParseException {
|
||||
List<GeneralQueryDataVo> fullData = new ArrayList<>();
|
||||
Map<String, GeneralQueryDataVo> dataMap = new HashMap<>();
|
||||
List<String> deviceIds = new ArrayList<>();
|
||||
for (GeneralQueryDataVo data : dataVoList) {
|
||||
String key = data.getSiteId() + "_" + data.getDeviceId() + "_" + data.getValueDate();
|
||||
dataMap.put(key, data);
|
||||
|
||||
if (!deviceIds.contains(data.getDeviceId())) {
|
||||
deviceIds.add(data.getDeviceId());
|
||||
}
|
||||
}
|
||||
// 生成分钟序列
|
||||
Set<String> minuteSeries = generateMinuteSeries(startDate, endDate);
|
||||
// 遍历每个站点,查看设备
|
||||
for (String siteId : querySiteIds) {
|
||||
// 处理该站点下的所有设备
|
||||
for (String deviceId : deviceIds) {
|
||||
Object lastValue = null;
|
||||
|
||||
for (String minute : minuteSeries) {
|
||||
String dataKey = siteId + "_" + deviceId + "_" + minute;
|
||||
GeneralQueryDataVo data = dataMap.get(dataKey);
|
||||
|
||||
// 空值填充逻辑
|
||||
if (data == null) {
|
||||
data = new GeneralQueryDataVo();
|
||||
data.setValueDate(minute);
|
||||
data.setSiteId(siteId);
|
||||
data.setDeviceId(deviceId);
|
||||
data.setPointValue(lastValue==null? 0 : lastValue); // 用上一分钟值填充
|
||||
} else {
|
||||
lastValue = data.getPointValue(); // 更新最新值
|
||||
}
|
||||
|
||||
fullData.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fullData.sort(Comparator.comparing(GeneralQueryDataVo::getValueDate)
|
||||
.thenComparing(GeneralQueryDataVo::getSiteId)
|
||||
.thenComparing(GeneralQueryDataVo::getDeviceId));
|
||||
|
||||
return fullData;
|
||||
}
|
||||
|
||||
private List<GeneralQueryDataVo> dealWithBatteryMinutesData(List<String> querySiteIds, List<GeneralQueryDataVo> dataVoList,
|
||||
String deviceCategory, String startDate, String endDate,
|
||||
Map<String, List<String>> siteDeviceMap) throws ParseException {
|
||||
List<GeneralQueryDataVo> fullData = new ArrayList<>();
|
||||
Map<String, GeneralQueryDataVo> dataMap = new HashMap<>();
|
||||
List<String> clusterIds = new ArrayList<>();
|
||||
for (GeneralQueryDataVo data : dataVoList) {
|
||||
String key = data.getParentDeviceId() + "_" + data.getDeviceId() + "_" + data.getValueDate();
|
||||
dataMap.put(key, data);
|
||||
|
||||
if (!clusterIds.contains(data.getParentDeviceId())) {
|
||||
clusterIds.add(data.getParentDeviceId());
|
||||
}
|
||||
}
|
||||
// 生成分钟序列
|
||||
Set<String> minuteSeries = generateMinuteSeries(startDate, endDate);
|
||||
|
||||
Map<String, Object> lastValueMap = new HashMap<>();
|
||||
String siteId = querySiteIds.get(0);
|
||||
// 单站-先处理站点下的簇id
|
||||
for (String clusterId : clusterIds) {
|
||||
List<String> deviceIds = siteDeviceMap.get(siteId);
|
||||
if (deviceIds.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (String deviceId : deviceIds) {
|
||||
String deviceKey = clusterId + "_" + deviceId;
|
||||
|
||||
for (String minute : minuteSeries) {
|
||||
Object lastValue = lastValueMap.get(deviceKey);
|
||||
String dataKey = clusterId + "_" + deviceId + "_" + minute;
|
||||
GeneralQueryDataVo data = dataMap.get(dataKey);
|
||||
|
||||
// 空值填充逻辑
|
||||
if (data == null) {
|
||||
data = new GeneralQueryDataVo();
|
||||
data.setValueDate(minute);
|
||||
data.setSiteId(siteId);
|
||||
data.setDeviceId(deviceId);
|
||||
data.setParentDeviceId(clusterId);
|
||||
data.setPointValue(lastValue == null ? 0 : lastValue); // 上一分钟数据不存在默认0
|
||||
} else {
|
||||
lastValueMap.put(deviceKey,data.getPointValue());// 更新最新值
|
||||
}
|
||||
|
||||
fullData.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fullData.sort(Comparator.comparing(GeneralQueryDataVo::getValueDate)
|
||||
.thenComparing(GeneralQueryDataVo::getSiteId)
|
||||
.thenComparing(GeneralQueryDataVo::getDeviceId));
|
||||
|
||||
return fullData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据前端传递的startDate和endDate生成所有分钟点的序列
|
||||
* @param startDate 起始时间(格式:yyyy-MM-dd HH:mm:00)
|
||||
* @param endDate 结束时间(格式:yyyy-MM-dd HH:mm:00)
|
||||
* @return 包含所有分钟点的有序集合
|
||||
* @throws ParseException 时间格式解析失败时抛出
|
||||
*/
|
||||
private Set<String> generateMinuteSeries(String startDate, String endDate) throws ParseException {
|
||||
Set<String> minutes = new TreeSet<>(); // TreeSet保证时间有序
|
||||
|
||||
// 解析起止时间
|
||||
//startDate = DateUtils.adjustToNextMinute(startDate);
|
||||
Date startTime = TIME_FORMAT.parse(startDate.substring(0, 16) + ":00");
|
||||
Date endTime = TIME_FORMAT.parse(endDate.substring(0, 16) + ":00");
|
||||
|
||||
// 验证时间有效性
|
||||
if (startTime.after(endTime)) {
|
||||
throw new IllegalArgumentException("起始时间不能晚于结束时间");
|
||||
}
|
||||
|
||||
// 初始化日历对象,从起始时间开始
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(startTime);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
// 循环生成从startDate到endDate的所有分钟点
|
||||
while (!cal.getTime().after(endTime)) {
|
||||
// 添加当前分钟(格式:yyyy-MM-dd HH:mm:00)
|
||||
minutes.add(TIME_FORMAT.format(cal.getTime()));
|
||||
// 递增1分钟
|
||||
cal.add(Calendar.MINUTE, 1);
|
||||
}
|
||||
|
||||
return minutes;
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,9 @@ import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.EmsSiteSetting;
|
||||
import com.xzzn.ems.domain.vo.*;
|
||||
import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.mapper.EmsAlarmRecordsMapper;
|
||||
import com.xzzn.ems.mapper.EmsPcsDataMapper;
|
||||
import com.xzzn.ems.mapper.EmsSiteSettingMapper;
|
||||
import com.xzzn.ems.service.IEmsSiteService;
|
||||
import com.xzzn.ems.service.IHomePageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -12,9 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 首页看板+站点地图 服务层实现
|
||||
@ -28,24 +28,21 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
@Autowired
|
||||
private IEmsSiteService emsSiteService;
|
||||
@Autowired
|
||||
private EmsPcsDataMapper emsPcsDataMapper;
|
||||
@Autowired
|
||||
private EmsSiteSettingMapper emsSiteMapper;
|
||||
@Autowired
|
||||
private EmsAlarmRecordsMapper alarmRecordsMapper;
|
||||
@Autowired
|
||||
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
||||
@Autowired
|
||||
private EmsAmmeterDataMapper emsAmmeterDataMapper;
|
||||
|
||||
@Override
|
||||
public SiteTotalInfoVo getSiteTotalInfo() {
|
||||
SiteTotalInfoVo siteTotalInfoVo = new SiteTotalInfoVo();
|
||||
siteTotalInfoVo = emsSiteService.getSiteTotalInfo();
|
||||
// 获取总充+总放
|
||||
String nowData = DateUtils.getDate();
|
||||
Map<String,BigDecimal> data = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,null);
|
||||
if(data != null){
|
||||
siteTotalInfoVo.setTotalChargedCap(data.get("totalChargedCap"));
|
||||
siteTotalInfoVo.setTotalDischargedCap(data.get("totalDischargedCap"));
|
||||
Map<String,BigDecimal> pcsMap = emsPcsDataMapper.getPcsTotalChargeData(null);
|
||||
if(pcsMap != null){
|
||||
siteTotalInfoVo.setTotalChargedCap(pcsMap.get("totalChargedCap"));
|
||||
siteTotalInfoVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap"));
|
||||
}
|
||||
return siteTotalInfoVo;
|
||||
}
|
||||
@ -71,32 +68,28 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
singleSiteBaseInfo.setRunningTime(emsSite.getRunningTime() == null ? null :
|
||||
DateUtils.parseDateToStr("yyyy-MM-dd",emsSite.getRunningTime()));//投运时间
|
||||
// 获取单站点的总充+总放
|
||||
String nowData = DateUtils.getDate();
|
||||
Map<String,BigDecimal> data = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,siteId);
|
||||
if (data != null) {
|
||||
singleSiteBaseInfo.setTotalChargedCap(data.get("totalChargedCap"));
|
||||
singleSiteBaseInfo.setTotalDisChargedCap(data.get("totalDischargedCap"));
|
||||
Map<String,BigDecimal> pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId);
|
||||
if (pcsMap != null) {
|
||||
singleSiteBaseInfo.setTotalChargedCap(pcsMap.get("totalChargedCap"));
|
||||
singleSiteBaseInfo.setTotalDisChargedCap(pcsMap.get("totalDischargedCap"));
|
||||
}
|
||||
// 七天放电数据统计 默认从今天往前7天
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(LIMIT_TIME);
|
||||
Date startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
Date endDate = new Date();
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate);
|
||||
// 七天放电数据统计
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,LIMIT_TIME);
|
||||
singleSiteBaseInfo.setSevenDayDisChargeStats(siteMonitorDataVoList);
|
||||
// 充放电基本数据处理
|
||||
dealSiteChargeDate(singleSiteBaseInfo,siteMonitorDataVoList);
|
||||
dealSitePCSDate(singleSiteBaseInfo,siteMonitorDataVoList);
|
||||
}
|
||||
}
|
||||
|
||||
return singleSiteBaseInfo;
|
||||
}
|
||||
|
||||
private void dealSiteChargeDate(SingleSiteBaseInfo singleSiteBaseInfo, List<SiteMonitorDataVo> siteMonitorDataVoList) {
|
||||
private void dealSitePCSDate(SingleSiteBaseInfo singleSiteBaseInfo, List<SiteMonitorDataVo> siteMonitorDataVoList) {
|
||||
if (siteMonitorDataVoList != null && !siteMonitorDataVoList.isEmpty()) {
|
||||
for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) {
|
||||
// 获取当天的充电量+放电量
|
||||
String dayDate = sitePcsData.getAmmeterDate();
|
||||
boolean isToday= DateUtils.checkIsToday(dayDate);
|
||||
String pcsDate = sitePcsData.getAmmeterDate();
|
||||
boolean isToday= checkIsToday(pcsDate);
|
||||
if(isToday){
|
||||
singleSiteBaseInfo.setDayChargedCap(sitePcsData.getChargedCap());
|
||||
singleSiteBaseInfo.setDayDisChargedCap(sitePcsData.getDisChargedCap());
|
||||
@ -105,6 +98,21 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIsToday(String pcsDate) {
|
||||
boolean flag = false;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int todayMonth = calendar.get(Calendar.MONTH) + 1;
|
||||
int todayDay = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
if (StringUtils.isNotEmpty(pcsDate)){
|
||||
String[] pcsDateArray = pcsDate.split("-");
|
||||
if (todayMonth == Integer.parseInt(pcsDateArray[0]) &&
|
||||
todayDay == Integer.parseInt(pcsDateArray[1])) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页看板-数据概览
|
||||
*/
|
||||
@ -112,8 +120,7 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
public HomePageDataViewVo getHomePageDataList() {
|
||||
HomePageDataViewVo homePageDataViewVo = new HomePageDataViewVo();
|
||||
// 电量指标
|
||||
//List<ElectricIndexList> electricDataList = emsPcsDataMapper.getElectDataList();
|
||||
List<ElectricIndexList> electricDataList = getElectricDataList2();
|
||||
List<ElectricIndexList> electricDataList = emsPcsDataMapper.getElectDataList();
|
||||
homePageDataViewVo.setElecDataList(electricDataList);
|
||||
// 系统效率
|
||||
List<SystemEfficiencyList> systemEfficiencyLists = new ArrayList<>();
|
||||
@ -159,130 +166,4 @@ public class HomePageServiceImpl implements IHomePageService
|
||||
return homePageDataViewVo;
|
||||
}
|
||||
|
||||
private List<ElectricIndexList> getElectricDataList2() {
|
||||
List<ElectricIndexList> electricDataList = new ArrayList<>();
|
||||
electricDataList = emsDailyChargeDataMapper.getAllSiteChargeDataByMonth();
|
||||
return electricDataList;
|
||||
}
|
||||
|
||||
private List<ElectricIndexList> getElectricDataList() {
|
||||
List<ElectricIndexList> electricDataList = new ArrayList<>();
|
||||
// 获取每个月最早和最晚的时间
|
||||
List<MonthlyTimeRange> timeRanges = emsAmmeterDataMapper.getMonthlyTimeRanges();
|
||||
if (timeRanges.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 遍历收集所有需要查询的时间点(最早+最晚)
|
||||
List<TimePointQuery> timePointQueries = new ArrayList<>();
|
||||
for (MonthlyTimeRange range : timeRanges) {
|
||||
timePointQueries.add(new TimePointQuery(range.getSiteId(),range.getFirstDataTime()));
|
||||
timePointQueries.add(new TimePointQuery(range.getSiteId(),range.getLastDataTime()));
|
||||
}
|
||||
// 批量获取所有时间点对应的数据值转化为map
|
||||
List<TimePointValue> timePointValues = emsAmmeterDataMapper.batchGetTimePointValues(timePointQueries);
|
||||
Map<String, TimePointValue> valueMap = timePointValues.stream()
|
||||
.collect(Collectors.toMap(
|
||||
v -> v.getSiteId() + "_" + v.getDataUpdateTime().toString(),
|
||||
v -> v
|
||||
));
|
||||
// 缓存每个站点的上月最晚电量 key=siteId, value=上月最晚时间对应数据
|
||||
Map<String, TimePointValue> lastMonthMap = new HashMap<>();
|
||||
|
||||
// 组装结果-key=统计月,value=统计月的数据
|
||||
Map<String, ElectricIndexList> elecDataMap = new HashMap<>();
|
||||
for (MonthlyTimeRange timeRange : timeRanges) {
|
||||
String dataMonth = timeRange.getMonth();
|
||||
String siteId = timeRange.getSiteId();
|
||||
|
||||
BigDecimal totalChargeData = new BigDecimal(0);
|
||||
BigDecimal totalDisChargeData = new BigDecimal(0);
|
||||
// 获取本月最晚数据
|
||||
TimePointValue monthLastValue = valueMap.get(siteId +"_"+timeRange.getLastDataTime());
|
||||
BigDecimal lastChargeValue = new BigDecimal(0);
|
||||
BigDecimal lastDisChargeValue = new BigDecimal(0);
|
||||
if (monthLastValue != null) {
|
||||
lastChargeValue = monthLastValue.getTotalChargeData() == null ? BigDecimal.ZERO : monthLastValue.getTotalChargeData();
|
||||
lastDisChargeValue = monthLastValue.getTotalDischargeData() == null ? BigDecimal.ZERO : monthLastValue.getTotalDischargeData();
|
||||
|
||||
}// 看是否有缓存上个月最晚电量,没有则是首月
|
||||
if (!lastMonthMap.containsKey(siteId)) {
|
||||
// 首月充放电 = 本月最晚数据 - 本月最早数据
|
||||
TimePointValue monthFirstValue = valueMap.get(siteId +"_"+timeRange.getFirstDataTime());
|
||||
BigDecimal firstChargeValue = new BigDecimal(0);
|
||||
BigDecimal firstDisChargeValue = new BigDecimal(0);
|
||||
if (monthLastValue != null) {
|
||||
firstChargeValue = monthFirstValue.getTotalChargeData() == null ? BigDecimal.ZERO : monthFirstValue.getTotalChargeData();
|
||||
firstDisChargeValue = monthFirstValue.getTotalDischargeData() == null ? BigDecimal.ZERO : monthFirstValue.getTotalDischargeData();
|
||||
}
|
||||
totalChargeData = lastChargeValue.subtract(firstChargeValue);
|
||||
totalDisChargeData = lastDisChargeValue.subtract(firstDisChargeValue);
|
||||
} else {// 非本月充放电 = 本月最晚数据 - 上月最晚数据
|
||||
TimePointValue lastValue = lastMonthMap.get(siteId);
|
||||
if (lastValue == null) {// 缓存找不到上月数据,则取本月最早数据
|
||||
lastValue = valueMap.get(siteId +"_"+timeRange.getFirstDataTime());
|
||||
}
|
||||
BigDecimal lastMonthChargeValue = new BigDecimal(0);
|
||||
BigDecimal lastMonthDisChargeValue = new BigDecimal(0);
|
||||
if (lastValue != null) {
|
||||
lastMonthChargeValue = lastValue.getTotalChargeData() == null ? BigDecimal.ZERO : lastValue.getTotalChargeData();
|
||||
lastMonthDisChargeValue = lastValue.getTotalDischargeData() == null ? BigDecimal.ZERO : lastValue.getTotalDischargeData();
|
||||
}totalChargeData = lastChargeValue.subtract(lastMonthChargeValue);
|
||||
totalDisChargeData = lastDisChargeValue.subtract(lastMonthDisChargeValue);
|
||||
}
|
||||
// 缓存最晚数据
|
||||
lastMonthMap.put(siteId,monthLastValue);
|
||||
|
||||
ElectricIndexList electricIndexList = new ElectricIndexList();
|
||||
// 判断map里面是否已经有排序月份
|
||||
if (elecDataMap.containsKey(dataMonth)) {
|
||||
electricIndexList = elecDataMap.get(dataMonth);
|
||||
totalChargeData = totalChargeData.add(electricIndexList.getChargeEnergy());
|
||||
totalDisChargeData = totalDisChargeData.add(electricIndexList.getDisChargeEnergy());
|
||||
}
|
||||
electricIndexList.setDateMonth(dataMonth);
|
||||
electricIndexList.setChargeEnergy(totalChargeData);
|
||||
electricIndexList.setDisChargeEnergy(totalDisChargeData);
|
||||
elecDataMap.put(dataMonth,electricIndexList);
|
||||
}
|
||||
// 按月份升序排序后返回
|
||||
electricDataList = elecDataMap.values().stream()
|
||||
.sorted(Comparator.comparing(ElectricIndexList::getDateMonth))
|
||||
.collect(Collectors.toList());
|
||||
return electricDataList;
|
||||
}
|
||||
// 从timeRangeList中获取指定站点+月份的时间范围
|
||||
private MonthlyTimeRange getSiteRangeByMonth(List<MonthlyTimeRange> rangeList, String siteId, String month) {
|
||||
return rangeList.stream()
|
||||
.filter(r -> siteId.equals(r.getSiteId()) && month.equals(r.getMonth()))
|
||||
.findFirst() .orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<SiteMonitorDataVo> getSevenChargeData(DateSearchRequest requestVo) {
|
||||
String siteId = requestVo.getSiteId();
|
||||
|
||||
// 默认时间-7天
|
||||
dealRequestTime(requestVo);
|
||||
Date startDate = requestVo.getStartDate();
|
||||
Date endDate = requestVo.getEndDate();
|
||||
// 七天放电数据统计
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate);
|
||||
return siteMonitorDataVoList;
|
||||
}
|
||||
|
||||
// 统计入参时间处理
|
||||
public void dealRequestTime(DateSearchRequest requestVo){
|
||||
|
||||
Date startDate = requestVo.getStartDate();
|
||||
Date endDate = requestVo.getEndDate();
|
||||
if (startDate == null && endDate == null) {
|
||||
// 如果没有传时间,默认从今天往前7天
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(6);
|
||||
startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
endDate = new Date();
|
||||
requestVo.setStartDate(startDate);
|
||||
requestVo.setEndDate(endDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,9 +16,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -59,12 +56,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
@Autowired
|
||||
private EmsStrategyRunningMapper emsStrategyRunningMapper;
|
||||
@Autowired
|
||||
private EmsStrategyTempMapper emsStrategyTempMapper;
|
||||
@Autowired
|
||||
private EmsDailyChargeDataMapper emsDailyChargeDataMapper;
|
||||
|
||||
@Override
|
||||
public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) {
|
||||
@ -72,36 +63,22 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
|
||||
if (!StringUtils.isEmpty(siteId)) {
|
||||
// 获取单站点的总充+总放+电网实时功率
|
||||
String nowData = DateUtils.getDate();
|
||||
Map<String,BigDecimal> dataMap = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,siteId);
|
||||
if (dataMap != null) {
|
||||
siteMonitorHomeVo.setTotalChargedCap(dataMap.get("totalChargedCap"));
|
||||
siteMonitorHomeVo.setTotalDischargedCap(dataMap.get("totalDischargedCap"));
|
||||
//siteMonitorHomeVo.setGridNrtPower(dataMap.get("gridNrtPower"));
|
||||
Map<String,BigDecimal> pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId);
|
||||
if (pcsMap != null) {
|
||||
siteMonitorHomeVo.setTotalChargedCap(pcsMap.get("totalChargedCap"));
|
||||
siteMonitorHomeVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap"));
|
||||
siteMonitorHomeVo.setGridNrtPower(pcsMap.get("gridNrtPower"));
|
||||
}
|
||||
// 实时告警数据 名称+状态+告警内容
|
||||
List<SiteMonitorHomeAlarmVo> siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId);
|
||||
siteMonitorHomeVo.setSiteMonitorHomeAlarmVo(siteMonitorHomeAlarmVo);
|
||||
// 策略运行-主策略模板数据
|
||||
List<StrategyRunningVo> runningVo = emsStrategyRunningMapper.getRunningList(siteId);
|
||||
if (runningVo != null && runningVo.size() > 0) {
|
||||
StrategyTempInfo siteTempInfo = new StrategyTempInfo();
|
||||
siteTempInfo.setMainStrategyName(runningVo.get(0).getMainStrategyName());
|
||||
Long mainStrategyId = runningVo.get(0).getMainStrategyId();
|
||||
List<EmsStrategyTemp> tempList = emsStrategyTempMapper.getTempListBySiteIdAndStrategyId(siteId, mainStrategyId);
|
||||
siteTempInfo.setSiteMonitorDataVo(tempList);
|
||||
siteMonitorHomeVo.setStrategyTempInfo(siteTempInfo);
|
||||
}
|
||||
// 能量数据
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(6);
|
||||
Date startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
Date endDate = new Date();
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate);
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,6);
|
||||
if (!CollectionUtils.isEmpty(siteMonitorDataVoList)) {
|
||||
for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) {
|
||||
// 获取当天的充电量+放电量
|
||||
String pcsDate = sitePcsData.getAmmeterDate();
|
||||
boolean isToday= DateUtils.checkIsToday(pcsDate);
|
||||
boolean isToday= checkIsToday(pcsDate);
|
||||
if(isToday){
|
||||
siteMonitorHomeVo.setDayChargedCap(sitePcsData.getChargedCap());
|
||||
siteMonitorHomeVo.setDayDisChargedCap(sitePcsData.getDisChargedCap());
|
||||
@ -117,26 +94,29 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
return siteMonitorHomeVo;
|
||||
}
|
||||
|
||||
private boolean checkIsToday(String pcsDate) {
|
||||
boolean flag = false;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int todayMonth = calendar.get(Calendar.MONTH) + 1;
|
||||
int todayDay = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
if (StringUtils.isNotEmpty(pcsDate)){
|
||||
String[] pcsDateArray = pcsDate.split("-");
|
||||
if (todayMonth == Integer.parseInt(pcsDateArray[0]) &&
|
||||
todayDay == Integer.parseInt(pcsDateArray[1])) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// 获取单站监控实时运行头部数据
|
||||
@Override
|
||||
public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId) {
|
||||
SiteMonitorRunningHeadInfoVo siteMonitorRunningHeadInfoVo = new SiteMonitorRunningHeadInfoVo();
|
||||
|
||||
if (!StringUtils.isEmpty(siteId)) {
|
||||
// 实时有功功率/实时无功功率
|
||||
SiteMonitorRunningHeadInfoVo tempVo = emsPcsDataMapper.getSiteRunningHeadInfo(siteId);
|
||||
siteMonitorRunningHeadInfoVo.setTotalActivePower(tempVo.getTotalActivePower());
|
||||
siteMonitorRunningHeadInfoVo.setTotalReactivePower(tempVo.getTotalReactivePower());
|
||||
// 今日充放电
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime startOfDay = now.with(LocalTime.MIN);
|
||||
Date startDate = DateUtils.toDate(startOfDay);
|
||||
Date endDate = new Date();
|
||||
List<SiteMonitorDataVo> siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate);
|
||||
if (siteMonitorDataVoList != null && siteMonitorDataVoList.size() > 0) {
|
||||
siteMonitorRunningHeadInfoVo.setDayChargedCap(siteMonitorDataVoList.get(0).getChargedCap());
|
||||
siteMonitorRunningHeadInfoVo.setDayDisChargedCap(siteMonitorDataVoList.get(0).getDisChargedCap());
|
||||
}
|
||||
// 实时有功功率/实时无功功率/今日充电量/今日放电量
|
||||
siteMonitorRunningHeadInfoVo = emsPcsDataMapper.getSiteRunningHeadInfo(siteId);
|
||||
// 电池堆SOC + 电池堆SOH
|
||||
EmsBatteryStack emsBatteryStack = emsBatteryStackMapper.getSiteSumStackInfo(siteId);
|
||||
if (emsBatteryStack != null) {
|
||||
@ -164,7 +144,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
return siteMonitorRuningInfoVo;
|
||||
}
|
||||
// 获取单站监控实时运行-stack平均温度
|
||||
// 20250811 按小时
|
||||
@Override
|
||||
public SiteMonitorRuningInfoVo getRunningGraphStackTemp(String siteId) {
|
||||
SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo();
|
||||
@ -231,9 +210,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
List<PcsBranchInfo> pcsBranchInfoList = new ArrayList<>();
|
||||
processBranchDataInfo(siteId,pcsId,pcsBranchInfoList);
|
||||
pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList);
|
||||
// 报警个数
|
||||
int alarmNum = emsAlarmRecordsMapper.getDeviceAlarmNum(siteId,pcsId);
|
||||
pcsDetailInfoVo.setAlarmNum(alarmNum);
|
||||
|
||||
pcsDetailInfoVoList.add(pcsDetailInfoVo);
|
||||
}
|
||||
@ -272,10 +248,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
BeanUtils.copyProperties(stackData, bmsOverViewVo);
|
||||
}
|
||||
// 下面簇列表数据
|
||||
List<BMSBatteryDataList> batteryDataLists = new ArrayList<>();
|
||||
if (!StringUtils.isEmpty(stackId)) {
|
||||
batteryDataLists = getBMSClusterListInfo(siteId,stackId,null);
|
||||
bmsOverViewVo.setBatteryDataList(batteryDataLists);
|
||||
getBMSClusterListInfo(siteId,stackId,bmsOverViewVo);
|
||||
}
|
||||
bmsOverViewVoList.add(bmsOverViewVo);
|
||||
}
|
||||
@ -283,18 +257,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
return bmsOverViewVoList;
|
||||
}
|
||||
|
||||
private List<BMSBatteryDataList> getBMSClusterListInfo(String siteId, String stackId, String clusterDeviceId) {
|
||||
private void getBMSClusterListInfo(String siteId, String stackId, BMSOverViewVo bmsOverViewVo) {
|
||||
List<BMSBatteryDataList> batteryDataList = new ArrayList();
|
||||
|
||||
List<Map<String, Object>> clusterIds = new ArrayList<>();
|
||||
if (StringUtils.isEmpty(clusterDeviceId)) {
|
||||
clusterIds = emsDevicesSettingMapper.getClusterIdsByFuzzyQuery(siteId, DeviceCategory.CLUSTER.getCode(),stackId);
|
||||
} else {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", clusterDeviceId);
|
||||
clusterIds.add(map);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> clusterIds = emsDevicesSettingMapper.getDeviceInfoByParentId(siteId, stackId);
|
||||
for (Map<String, Object> clusterDevice : clusterIds) {
|
||||
BMSBatteryDataList bmsBatteryDataList= new BMSBatteryDataList();
|
||||
// 从redis取单个簇的详细数据
|
||||
@ -307,7 +273,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
batteryDataList.add(bmsBatteryDataList);
|
||||
}
|
||||
|
||||
return batteryDataList;
|
||||
bmsOverViewVo.setBatteryDataList(batteryDataList);
|
||||
}
|
||||
|
||||
// 获取BMS电池簇数据
|
||||
@ -321,11 +287,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
for (Map<String, Object> clusterDevice : clusterIds) {
|
||||
BMSBatteryClusterVo bmsBatteryClusterVo = new BMSBatteryClusterVo();
|
||||
bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString());
|
||||
bmsBatteryClusterVo.setParentDeviceName(clusterDevice.get("parentDeviceName").toString());
|
||||
// 从redis取单个簇详细数据
|
||||
String clusterId = clusterDevice.get("id").toString();
|
||||
EmsBatteryCluster clusterData = redisCache.getCacheObject(RedisKeyConstants.CLUSTER +siteId+"_"+clusterId);
|
||||
String parentDeviceId = "";
|
||||
if (clusterData != null) {
|
||||
BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo);
|
||||
// 处理单体电池数据-平均/最大/最小
|
||||
@ -333,6 +297,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
dealWithBatteryClusterData(clusterData,clusterDataList);
|
||||
bmsBatteryClusterVo.setBatteryDataList(clusterDataList);
|
||||
}
|
||||
|
||||
bmsBatteryClusterVoList.add(bmsBatteryClusterVo);
|
||||
}
|
||||
}
|
||||
@ -386,12 +351,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId,
|
||||
String stackDeviceId, String batteryId) {
|
||||
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId) {
|
||||
List<BatteryDataStatsListVo> batteryDataStatsListVo = new ArrayList<>();
|
||||
List<Map<String, Object>> clusterIds = new ArrayList<>();
|
||||
if (StringUtils.isEmpty(clusterDeviceId)) {
|
||||
clusterIds = emsDevicesSettingMapper.getClusterIdsByFuzzyQuery(siteId, DeviceCategory.CLUSTER.getCode(),stackDeviceId);
|
||||
clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode());
|
||||
} else {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", clusterDeviceId);
|
||||
@ -403,22 +367,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
List<EmsBatteryData> batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId);
|
||||
if (batteryDataList != null) {
|
||||
for (EmsBatteryData batteryData : batteryDataList) {
|
||||
// 判断是否需要筛选:batteryId不为空时才进行匹配
|
||||
if (batteryId == null || batteryId.trim().isEmpty()) {
|
||||
// 空值情况:直接添加所有数据
|
||||
BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo();
|
||||
BeanUtils.copyProperties(batteryData, batteryDataStatsVo);
|
||||
batteryDataStatsListVo.add(batteryDataStatsVo);
|
||||
} else {
|
||||
// 有值情况:只添加匹配的数据
|
||||
if (batteryId.equals(batteryData.getDeviceId())) {
|
||||
BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo();
|
||||
BeanUtils.copyProperties(batteryData, batteryDataStatsVo);
|
||||
batteryDataStatsListVo.add(batteryDataStatsVo);
|
||||
// 找到匹配项后可提前退出当前簇的循环
|
||||
break;
|
||||
}
|
||||
}
|
||||
BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo();
|
||||
BeanUtils.copyProperties(batteryData, batteryDataStatsVo);
|
||||
batteryDataStatsListVo.add(batteryDataStatsVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -429,12 +380,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
return sortedList;
|
||||
}
|
||||
|
||||
// 获取单站的最大最小温度和电压单体数据id
|
||||
@Override
|
||||
public List<BMSBatteryDataList> getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId) {
|
||||
return getBMSClusterListInfo(siteId, stackDeviceId,clusterDeviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 电表数据信息
|
||||
* @param siteId
|
||||
@ -456,7 +401,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
if (AMMETER_DEVICE_LOAD.equals(ammeterId)) {
|
||||
AmmeterLoadDataVo ammeterLoadDataVo = new AmmeterLoadDataVo();
|
||||
ammeterLoadDataVo.setDeviceName(ammeterDevice.get("deviceName").toString());
|
||||
ammeterLoadDataVo.setDeviceId(ammeterDevice.get("id").toString());
|
||||
ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" :
|
||||
ammeterDevice.get("communicationStatus").toString());
|
||||
// 处理总表数据
|
||||
@ -465,7 +409,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
|
||||
} else if (AMMETER_DEVICE_METE.equals(ammeterId)) {
|
||||
AmmeterMeteDataVo ammeterMeteDataVo = new AmmeterMeteDataVo();
|
||||
ammeterMeteDataVo.setDeviceName(ammeterDevice.get("deviceName").toString());
|
||||
ammeterMeteDataVo.setDeviceId(ammeterDevice.get("id").toString());
|
||||
ammeterMeteDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" :
|
||||
ammeterDevice.get("communicationStatus").toString());
|
||||
// 处理储能表数据
|
||||
|
||||
@ -1,678 +0,0 @@
|
||||
package com.xzzn.ems.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xzzn.common.core.redis.RedisCache;
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.ems.domain.EmsBatteryData;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataDay;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataHour;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataMonth;
|
||||
import com.xzzn.ems.mapper.EmsBatteryDataDayMapper;
|
||||
import com.xzzn.ems.mapper.EmsBatteryDataHourMapper;
|
||||
import com.xzzn.ems.mapper.EmsBatteryDataMonthMapper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public abstract class AbstractBatteryDataProcessor {
|
||||
|
||||
private static final Log log = LogFactory.getLog(AbstractBatteryDataProcessor.class);
|
||||
|
||||
protected static final DateTimeFormatter HOUR_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH");
|
||||
protected static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
protected static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
// 公共缓存:<batteryId_granularity, 缓存值>
|
||||
protected final Map<String, CacheValue> tempCache = new ConcurrentHashMap<>();
|
||||
// 公共锁缓存:<batteryId_granularity, 锁>
|
||||
protected final Map<String, ReentrantLock> lockCache = new ConcurrentHashMap<>();
|
||||
protected final ObjectMapper objectMapper;
|
||||
|
||||
@Autowired
|
||||
private EmsBatteryDataHourMapper emsBatteryDataHourMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDataDayMapper emsBatteryDataDayMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDataMonthMapper emsBatteryDataMonthMapper;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
// 公共线程池(IO密集型,子类共享)
|
||||
protected ThreadPoolTaskExecutor ioExecutor;
|
||||
// 批量缓冲区(线程安全队列,按级别区分)
|
||||
protected ConcurrentLinkedQueue<EmsBatteryData> hourBatchQueue = new ConcurrentLinkedQueue<>();
|
||||
protected ConcurrentLinkedQueue<EmsBatteryData> dayBatchQueue = new ConcurrentLinkedQueue<>();
|
||||
protected ConcurrentLinkedQueue<EmsBatteryData> monthBatchQueue = new ConcurrentLinkedQueue<>();
|
||||
// 批量提交阈值(满100条触发数据库操作)
|
||||
protected static final int BATCH_THRESHOLD = 50;
|
||||
// 死锁重试等待时间基数(毫秒)
|
||||
private static final int RETRY_BASE_DELAY = 100;
|
||||
// 随机数生成器,用于重试退避
|
||||
private static final Random random = new Random();
|
||||
|
||||
// 初始化方法(构造时初始化线程池)
|
||||
public AbstractBatteryDataProcessor(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
ioExecutor = new ThreadPoolTaskExecutor();
|
||||
int coreThreads = Runtime.getRuntime().availableProcessors() * 2;
|
||||
ioExecutor.setCorePoolSize(coreThreads);
|
||||
ioExecutor.setMaxPoolSize(coreThreads * 2);
|
||||
ioExecutor.setQueueCapacity(10000);
|
||||
ioExecutor.setThreadNamePrefix("battery-io-");
|
||||
// 线程池饱和策略:使用调用者线程执行,避免任务丢失
|
||||
ioExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
ioExecutor.initialize();
|
||||
}
|
||||
|
||||
// 模板方法:定义数据处理主流程(子类无需重写)
|
||||
public void processBatch(List<EmsBatteryData> batchData) {
|
||||
// 1. 数据分片(实现通用分片逻辑)
|
||||
List<List<EmsBatteryData>> shards = splitIntoShards(batchData, 50);
|
||||
int totalShards = shards.size();
|
||||
|
||||
// 2. 并行处理每个分片(使用父类线程池)
|
||||
for (int i = 0; i < totalShards; i++) {
|
||||
List<EmsBatteryData> shard = shards.get(i);
|
||||
boolean isLastShard = (i == totalShards - 1); // 判断是否为最后一个分片
|
||||
|
||||
// 传递分片索引和是否最后一个分片的标记
|
||||
ioExecutor.execute(() -> processShard(shard, isLastShard));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将大批量数据拆分为多个小分片
|
||||
* @param dataList 原始数据列表
|
||||
* @param shardSize 每个分片的最大大小(如100条/片)
|
||||
* @return 分片后的列表(每个元素是一个子列表)
|
||||
*/
|
||||
protected List<List<EmsBatteryData>> splitIntoShards(List<EmsBatteryData> dataList, int shardSize) {
|
||||
// 1. 校验参数:避免空列表或无效分片大小
|
||||
if (dataList == null || dataList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if (shardSize <= 0) {
|
||||
throw new IllegalArgumentException("分片大小必须大于0");
|
||||
}
|
||||
|
||||
// 2. 计算总分片数:向上取整(如150条数据,分片大小100 → 2片)
|
||||
int totalSize = dataList.size();
|
||||
int shardCount = (totalSize + shardSize - 1) / shardSize;
|
||||
|
||||
// 3. 拆分数据为分片(使用IntStream生成分片索引)
|
||||
return IntStream.range(0, shardCount)
|
||||
.mapToObj(shardIndex -> {
|
||||
// 计算当前分片的起始索引和结束索引
|
||||
int startIndex = shardIndex * shardSize;
|
||||
int endIndex = Math.min(startIndex + shardSize, totalSize);
|
||||
// 截取子列表作为一个分片
|
||||
return dataList.subList(startIndex, endIndex);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 处理单个分片(父类定义流程,调用子类实现的具体判断和更新逻辑)
|
||||
private void processShard(List<EmsBatteryData> shard, boolean isLastShard) {
|
||||
int shardSize = shard.size();
|
||||
log.info("分片校验:" + shardSize + "<UNK>");
|
||||
for (int i = 0; i < shardSize; i++) {
|
||||
EmsBatteryData data = shard.get(i);
|
||||
if (!isValidData(data)) continue;
|
||||
|
||||
// 判断当前数据是否为最后一个分片的最后一条数据
|
||||
boolean isLastData = isLastShard && (i == shardSize - 1);
|
||||
// shouldUpdate判断是否需要更新
|
||||
if (shouldUpdate(data, "hour")) {
|
||||
addToHourBatch(data, isLastData); // 加入小时级批量队列
|
||||
}
|
||||
if (shouldUpdate(data, "day")) {
|
||||
addToDayBatch(data, isLastData); // 加入天级批量队列
|
||||
}
|
||||
if (shouldUpdate(data, "month")) {
|
||||
addToMonthBatch(data, isLastData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加入小时级批量队列,达到阈值时触发批量更新
|
||||
protected void addToHourBatch(EmsBatteryData data, boolean isLastData) {
|
||||
hourBatchQueue.add(data);
|
||||
if (hourBatchQueue.size() >= BATCH_THRESHOLD || isLastData) {
|
||||
List<EmsBatteryData> batch = drainQueue(hourBatchQueue);
|
||||
ioExecutor.execute(() -> batchUpdateHour(batch)); // 异步批量更新
|
||||
}
|
||||
}
|
||||
|
||||
// 加入天级批量队列,达到阈值时触发批量更新
|
||||
protected void addToDayBatch(EmsBatteryData data, boolean isLastData) {
|
||||
dayBatchQueue.add(data);
|
||||
if (dayBatchQueue.size() >= BATCH_THRESHOLD || isLastData) {
|
||||
List<EmsBatteryData> batch = drainQueue(dayBatchQueue);
|
||||
ioExecutor.execute(() -> batchUpdateDay(batch)); // 异步批量更新
|
||||
}
|
||||
}
|
||||
|
||||
// 加入月级批量队列,达到阈值时触发批量更新
|
||||
protected void addToMonthBatch(EmsBatteryData data, boolean isLastData) {
|
||||
monthBatchQueue.add(data);
|
||||
if (monthBatchQueue.size() >= BATCH_THRESHOLD || isLastData) {
|
||||
List<EmsBatteryData> batch = drainQueue(monthBatchQueue);
|
||||
ioExecutor.execute(() -> batchUpdateMonth(batch)); // 异步批量更新
|
||||
}
|
||||
}
|
||||
|
||||
// 实现父类的抽象方法:批量更新小时级数据
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void batchUpdateHour(List<EmsBatteryData> batch) {
|
||||
if (batch.isEmpty()) return;
|
||||
|
||||
int maxRetry = 3; // 最多重试3次
|
||||
int retryCount = 0;
|
||||
while (retryCount < maxRetry) {
|
||||
try {
|
||||
// 关键优化:按唯一键排序,保证所有线程处理相同记录时顺序一致
|
||||
List<EmsBatteryData> sortedBatch = batch.stream()
|
||||
.sorted(Comparator.comparing(data -> generateCacheKey(data, "hour"))) // 用唯一键排序
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 1. 转换原始数据为小时级统计对象(分组取最高温)
|
||||
List<EmsBatteryDataHour> hourDataList = sortedBatch.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
data -> generateCacheKey(data, "hour"), // 分组键
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.maxBy((d1, d2) -> d1.getTemperature().compareTo(d2.getTemperature())),
|
||||
maxData -> convertToHourData(maxData.get()) // 取每组最高温转换为HourData
|
||||
)
|
||||
))
|
||||
.values()
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(this::getHourDataUniqueKey))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 批量插入或更新数据库(依赖数据库唯一索引)
|
||||
emsBatteryDataHourMapper.batchInsertOrUpdate(hourDataList);
|
||||
|
||||
// 3. 同步更新Redis缓存(批量操作)
|
||||
batchUpdateHourCache(hourDataList);
|
||||
log.info("小时级批量更新成功,批次大小:" + batch.size() + ",重试次数:" + retryCount);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.error("小时级批量更新失败", e);
|
||||
// 使用改进的死锁判断方法,直接传入异常对象
|
||||
if (isDeadlockException(e) && retryCount < maxRetry - 1) {
|
||||
retryCount++;
|
||||
long sleepTime = calculateBackoffTime(retryCount);
|
||||
log.info("检测到死锁,第" + retryCount + "次重试(当前批次大小:" + batch.size() + ")", e);
|
||||
try {
|
||||
// 指数退避策略:100ms, 200ms, 300ms...
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt(); // 保留中断状态
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
log.error("小时级批量更新失败(已达最大重试次数)", e);
|
||||
//retryQueue.addAll(batch); // 加入重试队列
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 辅助方法:获取小时级数据的唯一键(用于排序)
|
||||
private String getHourDataUniqueKey(EmsBatteryDataHour data) {
|
||||
return data.getSiteId() + "_" + data.getBatteryPack() + "_" + data.getClusterDeviceId()
|
||||
+ "_" + data.getDeviceId() + "_" + data.getHourTime();
|
||||
}
|
||||
// 批量更新小时级数据缓存-小时级统计数据列表(已按唯一键分组并取最高温)
|
||||
public void batchUpdateHourCache(List<EmsBatteryDataHour> hourDataList) {
|
||||
if (hourDataList.isEmpty()) return;
|
||||
|
||||
Map<String, String> tempCacheMap = buildCacheMap(hourDataList, "hour");
|
||||
|
||||
try {
|
||||
// 批量设置缓存
|
||||
redisCache.multiSetWithExpire(tempCacheMap, 1, TimeUnit.HOURS);
|
||||
} catch (Exception e) {
|
||||
log.error("批量更新小时级缓存失败", e);
|
||||
// 缓存更新失败不影响主流程,但需记录日志便于排查
|
||||
}
|
||||
}
|
||||
// 转换为小时级数据对象
|
||||
private EmsBatteryDataHour convertToHourData(EmsBatteryData data) {
|
||||
LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai"))
|
||||
.toLocalDateTime();
|
||||
LocalDateTime hourStart = localDateTime.truncatedTo(ChronoUnit.HOURS);
|
||||
|
||||
EmsBatteryDataHour hourData = new EmsBatteryDataHour();
|
||||
BeanUtils.copyProperties(data, hourData);
|
||||
hourData.setUpdateTime(new Date());
|
||||
hourData.setHourTime(DateUtils.convertToDate(hourStart));
|
||||
return hourData;
|
||||
}
|
||||
|
||||
// 实现父类的抽象方法:批量更新天级数据
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void batchUpdateDay(List<EmsBatteryData> batch) {
|
||||
if (batch.isEmpty()) return;
|
||||
|
||||
int maxRetry = 3; // 最多重试3次
|
||||
int retryCount = 0;
|
||||
while (retryCount < maxRetry) {
|
||||
try {
|
||||
// 关键优化:按唯一键排序,保证所有线程处理相同记录时顺序一致
|
||||
List<EmsBatteryData> sortedBatch = batch.stream()
|
||||
.sorted(Comparator.comparing(data -> generateCacheKey(data, "day"))) // 用唯一键排序
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 1. 转换原始数据为天级统计对象(分组取最高温)
|
||||
List<EmsBatteryDataDay> dayDataList = sortedBatch.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
data -> generateCacheKey(data, "day"), // 分组键
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.maxBy((d1, d2) -> d1.getTemperature().compareTo(d2.getTemperature())),
|
||||
maxData -> convertToDayData(maxData.get()) // 取每组最高温转换为HourData
|
||||
)
|
||||
))
|
||||
.values()
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(this::getDayDataUniqueKey))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 批量插入或更新数据库(依赖数据库唯一索引)
|
||||
emsBatteryDataDayMapper.batchInsertOrUpdate(dayDataList);
|
||||
|
||||
// 3. 同步更新Redis缓存(批量操作)
|
||||
batchUpdateDayCache(dayDataList);
|
||||
log.info("天级批量更新成功,批次大小:" + batch.size() + ",重试次数:" + retryCount);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.error("天级批量更新失败", e);
|
||||
// 使用改进的死锁判断方法,直接传入异常对象
|
||||
if (isDeadlockException(e) && retryCount < maxRetry - 1) {
|
||||
retryCount++;
|
||||
long sleepTime = calculateBackoffTime(retryCount);
|
||||
log.info("检测到死锁,第" + retryCount + "次重试(当前批次大小:" + batch.size() + ")", e);
|
||||
try {
|
||||
// 指数退避策略:100ms, 200ms, 300ms...
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt(); // 保留中断状态
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
log.error("天级批量更新失败(已达最大重试次数)", e);
|
||||
//retryQueue.addAll(batch); // 加入重试队列
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 辅助方法:获取天级数据的唯一键(用于排序)
|
||||
private String getDayDataUniqueKey(EmsBatteryDataDay data) {
|
||||
return data.getSiteId() + "_" + data.getBatteryPack() + "_" + data.getClusterDeviceId()
|
||||
+ "_" + data.getDeviceId() + "_" + data.getDayTime();
|
||||
}
|
||||
// 批量更新天级数据缓存-天级统计数据列表(已按唯一键分组并取最高温)
|
||||
public void batchUpdateDayCache(List<EmsBatteryDataDay> dayDataList) {
|
||||
if (dayDataList.isEmpty()) return;
|
||||
|
||||
Map<String, String> tempCacheMap = buildCacheMap(dayDataList, "hour");
|
||||
|
||||
try {
|
||||
// 批量设置缓存
|
||||
redisCache.multiSetWithExpire(tempCacheMap, 24, TimeUnit.HOURS);
|
||||
} catch (Exception e) {
|
||||
log.error("批量更新小时级缓存失败", e);
|
||||
// 缓存更新失败不影响主流程,但需记录日志便于排查
|
||||
}
|
||||
}
|
||||
// 转换为天级数据对象
|
||||
private EmsBatteryDataDay convertToDayData(EmsBatteryData data) {
|
||||
LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai"))
|
||||
.toLocalDateTime();
|
||||
LocalDateTime dayStart = localDateTime.truncatedTo(ChronoUnit.DAYS);
|
||||
|
||||
EmsBatteryDataDay dayData = new EmsBatteryDataDay();
|
||||
BeanUtils.copyProperties(data, dayData);
|
||||
dayData.setUpdateTime(new Date());
|
||||
dayData.setDayTime(DateUtils.convertToDate(dayStart));
|
||||
return dayData;
|
||||
}
|
||||
|
||||
// 实现父类的抽象方法:批量更新月级数据
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void batchUpdateMonth(List<EmsBatteryData> batch) {
|
||||
if (batch.isEmpty()) return;
|
||||
|
||||
int maxRetry = 3; // 最多重试3次
|
||||
int retryCount = 0;
|
||||
while (retryCount < maxRetry) {
|
||||
try {
|
||||
// 关键优化:按唯一键排序,保证所有线程处理相同记录时顺序一致
|
||||
List<EmsBatteryData> sortedBatch = batch.stream()
|
||||
.sorted(Comparator.comparing(data -> generateCacheKey(data, "month"))) // 用唯一键排序
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 1. 转换原始数据为小时级统计对象(分组取最高温)
|
||||
List<EmsBatteryDataMonth> monthDataList = sortedBatch.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
data -> generateCacheKey(data, "month"), // 分组键
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.maxBy((d1, d2) -> d1.getTemperature().compareTo(d2.getTemperature())),
|
||||
maxData -> convertToMonthData(maxData.get()) // 取每组最高温转换为HourData
|
||||
)
|
||||
))
|
||||
.values()
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(this::getMonthDataUniqueKey))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 批量插入或更新数据库(依赖数据库唯一索引)
|
||||
emsBatteryDataMonthMapper.batchInsertOrUpdate(monthDataList);
|
||||
|
||||
// 3. 同步更新Redis缓存(批量操作)
|
||||
batchUpdateMonthCache(monthDataList);
|
||||
log.info("月级批量更新成功,批次大小:" + batch.size() + ",重试次数:" + retryCount);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.error("月级批量更新失败", e);
|
||||
// 使用改进的死锁判断方法,直接传入异常对象
|
||||
if (isDeadlockException(e) && retryCount < maxRetry - 1) {
|
||||
retryCount++;
|
||||
long sleepTime = calculateBackoffTime(retryCount);
|
||||
log.info("检测到死锁,第" + retryCount + "次重试(当前批次大小:" + batch.size() + ")", e);
|
||||
try {
|
||||
// 指数退避策略:100ms, 200ms, 300ms...
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt(); // 保留中断状态
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
log.error("月级批量更新失败(已达最大重试次数)", e);
|
||||
//retryQueue.addAll(batch); // 加入重试队列
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 辅助方法:获取月级数据的唯一键(用于排序)
|
||||
private String getMonthDataUniqueKey(EmsBatteryDataMonth data) {
|
||||
return data.getSiteId() + "_" + data.getBatteryPack() + "_" + data.getClusterDeviceId()
|
||||
+ "_" + data.getDeviceId() + "_" + data.getMonthTime();
|
||||
}
|
||||
// 转换为月级数据对象
|
||||
private EmsBatteryDataMonth convertToMonthData(EmsBatteryData data) {
|
||||
LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai"))
|
||||
.toLocalDateTime();
|
||||
LocalDateTime monthStart = localDateTime.withDayOfMonth(1).withHour(0).withMinute(0)
|
||||
.withSecond(0).withNano(0);
|
||||
|
||||
EmsBatteryDataMonth monthData = new EmsBatteryDataMonth();
|
||||
BeanUtils.copyProperties(data, monthData);
|
||||
monthData.setUpdateTime(new Date());
|
||||
monthData.setMonthTime(DateUtils.convertToDate(monthStart));
|
||||
return monthData;
|
||||
}
|
||||
// 批量更新月级数据缓存-月级统计数据列表(已按唯一键分组并取最高温)
|
||||
public void batchUpdateMonthCache(List<EmsBatteryDataMonth> monthDataList) {
|
||||
if (monthDataList.isEmpty()) return;
|
||||
|
||||
Map<String, String> tempCacheMap = buildCacheMap(monthDataList, "hour");
|
||||
|
||||
try {
|
||||
// 批量设置缓存
|
||||
redisCache.multiSetWithExpire(tempCacheMap, 24*30, TimeUnit.HOURS);
|
||||
} catch (Exception e) {
|
||||
log.error("批量更新月级缓存失败", e);
|
||||
// 缓存更新失败不影响主流程,但需记录日志便于排查
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验数据有效性(公共逻辑:检查核心字段)
|
||||
*/
|
||||
protected boolean isValidData(EmsBatteryData data) {
|
||||
return data.getDeviceId() != null
|
||||
&& data.getTemperature() != null
|
||||
&& data.getDataTimestamp() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要更新(公共缓存逻辑)
|
||||
*/
|
||||
protected boolean shouldUpdate(EmsBatteryData data, String granularity) {
|
||||
String cacheKey = generateCacheKey(data, granularity);
|
||||
if (cacheKey == null) return true;
|
||||
|
||||
BigDecimal newTemp = data.getTemperature();
|
||||
CacheValue localCache = tempCache.get(cacheKey);
|
||||
if (localCache != null) {
|
||||
return newTemp.compareTo(localCache.maxTemp) > 0;
|
||||
}
|
||||
|
||||
// 本地缓存未命中:查Redis
|
||||
try {
|
||||
String redisValue = redisCache.getCacheObject(cacheKey);
|
||||
if (redisValue != null) {
|
||||
// Redis有值:转换为BigDecimal比较
|
||||
BigDecimal redisMaxTemp = new BigDecimal(redisValue);
|
||||
// 同时更新本地缓存(减少下次查询Redis的开销)
|
||||
tempCache.put(cacheKey, new CacheValue(redisMaxTemp, LocalDateTime.now()));
|
||||
return newTemp.compareTo(redisMaxTemp) > 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("查询Redis缓存失败(key: " + cacheKey + ")", e);
|
||||
}
|
||||
|
||||
|
||||
// 数据库校验(缓存都未命中或新温度更高时)
|
||||
BigDecimal dbMaxTemp = queryDbMaxTemp(data, granularity);
|
||||
if (dbMaxTemp != null && newTemp.compareTo(dbMaxTemp) <= 0) {
|
||||
// 数据库已有更高温度,更新缓存后返回
|
||||
CacheValue dbCache = new CacheValue(dbMaxTemp, LocalDateTime.now());
|
||||
tempCache.put(cacheKey, dbCache);
|
||||
redisCache.setCacheObject(cacheKey, dbMaxTemp.toString()); // 同步到Redis
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据库中该设备在指定时间粒度下的最大温度
|
||||
*/
|
||||
private BigDecimal queryDbMaxTemp(EmsBatteryData data, String granularity) {
|
||||
try {
|
||||
LocalDateTime dataTime = data.getDataTimestamp().toInstant()
|
||||
.atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime();
|
||||
|
||||
String siteId = data.getSiteId();
|
||||
String batteryPack = data.getBatteryPack();
|
||||
String clusterId = data.getClusterDeviceId();
|
||||
String deviceId = data.getDeviceId();
|
||||
|
||||
// 根据粒度查询对应的数据表
|
||||
switch (granularity) {
|
||||
case "hour":
|
||||
LocalDateTime hourStart = dataTime.truncatedTo(ChronoUnit.HOURS);
|
||||
// 调用Mapper查询该小时的最大温度(需确保Mapper方法存在)
|
||||
EmsBatteryDataHour hourMax = emsBatteryDataHourMapper.findHourMaxTemp(
|
||||
siteId, batteryPack, clusterId, deviceId, hourStart
|
||||
);
|
||||
return hourMax != null ? hourMax.getTemperature() : null;
|
||||
|
||||
case "day":
|
||||
LocalDateTime dayStart = dataTime.truncatedTo(ChronoUnit.DAYS);
|
||||
EmsBatteryDataDay dayMax = emsBatteryDataDayMapper.findDayMaxTemp(
|
||||
siteId, batteryPack, clusterId, deviceId, dayStart
|
||||
);
|
||||
return dayMax != null ? dayMax.getTemperature() : null;
|
||||
|
||||
case "month":
|
||||
// 设为当月1号 与其他表统一格式
|
||||
LocalDateTime monthStart = dataTime.withDayOfMonth(1).withHour(0).withMinute(0)
|
||||
.withSecond(0).withNano(0);
|
||||
EmsBatteryDataMonth monthMax = emsBatteryDataMonthMapper.findMonthMaxTemp(
|
||||
siteId, batteryPack, clusterId, deviceId, monthStart
|
||||
);
|
||||
return monthMax != null ? monthMax.getTemperature() : null;
|
||||
|
||||
default:
|
||||
log.error("不支持的查询粒度:" + granularity);
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("查询数据库最大温度失败", e);
|
||||
return null; // 数据库查询失败时,暂不阻止更新(避免业务中断)
|
||||
}
|
||||
}
|
||||
|
||||
// 生成缓存键(不同级别格式不同)
|
||||
private String generateCacheKey(EmsBatteryData data, String granularity) {
|
||||
String siteId = data.getSiteId();
|
||||
String stackId = data.getBatteryPack();
|
||||
String clusterId = data.getClusterDeviceId();
|
||||
String batteryId = data.getDeviceId();
|
||||
try {
|
||||
LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai"))
|
||||
.toLocalDateTime();
|
||||
String timeStr;
|
||||
// 根据级别格式化时间(小时/天/月)
|
||||
switch (granularity) {
|
||||
case "hour":
|
||||
timeStr = localDateTime.format(HOUR_FORMATTER);
|
||||
break;
|
||||
case "day":
|
||||
timeStr = localDateTime.format(DAY_FORMATTER);
|
||||
break;
|
||||
case "month":
|
||||
timeStr = localDateTime.format(MONTH_FORMATTER);
|
||||
break;
|
||||
default:
|
||||
log.info("不支持的级别:" + granularity);
|
||||
return null;
|
||||
}
|
||||
// 缓存键格式
|
||||
return siteId + "_" + stackId + "_" + clusterId + "_" + batteryId + "_" +timeStr;
|
||||
} catch (Exception e) {
|
||||
log.error("生成缓存键失败", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 工具方法:从队列中取出所有元素
|
||||
protected <T> List<T> drainQueue(ConcurrentLinkedQueue<T> queue) {
|
||||
List<T> result = new ArrayList<>();
|
||||
T element;
|
||||
while ((element = queue.poll()) != null) {
|
||||
result.add(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电池+粒度的专属锁(公共锁逻辑)
|
||||
*/
|
||||
protected ReentrantLock getLock(String siteId, String stackId, String clusterId,
|
||||
String batteryId, String granularity) {
|
||||
String lockKey = siteId + "_" + stackId + "_" + clusterId + "_" + batteryId + "_" + granularity;
|
||||
return lockCache.computeIfAbsent(lockKey, k -> new ReentrantLock());
|
||||
}
|
||||
|
||||
// 计算退避时间:指数退避 + 随机抖动,避免重试风暴
|
||||
private long calculateBackoffTime(int retryCount) {
|
||||
// 100ms * 2^retry + 随机0-100ms
|
||||
return (long)(RETRY_BASE_DELAY * Math.pow(2, retryCount)) + random.nextInt(100);
|
||||
}
|
||||
|
||||
// 判断是否为死锁异常
|
||||
private boolean isDeadlockException(Throwable e) {
|
||||
// 遍历所有异常链(包括cause的cause...)
|
||||
while (e != null) {
|
||||
// 检查异常消息是否包含死锁关键字
|
||||
if (e.getMessage() != null && e.getMessage().contains("Deadlock found when trying to get lock")) {
|
||||
return true;
|
||||
}
|
||||
// 深入下一层异常
|
||||
e = e.getCause();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共缓存实体(所有站点通用)
|
||||
*/
|
||||
protected static class CacheValue {
|
||||
BigDecimal maxTemp;
|
||||
LocalDateTime lastUpdateTime;
|
||||
|
||||
public CacheValue(BigDecimal maxTemp, LocalDateTime lastUpdateTime) {
|
||||
this.maxTemp = maxTemp;
|
||||
this.lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
}
|
||||
|
||||
// 通用构建缓存键值对的方法(根据不同数据类型适配)
|
||||
private <T> Map<String, String> buildCacheMap(List<T> dataList, String granularity) {
|
||||
Map<String, String> cacheMap = new HashMap<>(dataList.size());
|
||||
for (T data : dataList) {
|
||||
EmsBatteryData cacheData = new EmsBatteryData();
|
||||
BeanUtils.copyProperties(data, cacheData);
|
||||
String cacheKey = generateCacheKey(cacheData, granularity);
|
||||
|
||||
// 根据数据类型获取温度值(实际项目中可通过接口或反射统一处理)
|
||||
String temperature;
|
||||
if (data instanceof EmsBatteryDataHour) {
|
||||
temperature = ((EmsBatteryDataHour) data).getTemperature().toString();
|
||||
} else if (data instanceof EmsBatteryDataDay) {
|
||||
temperature = ((EmsBatteryDataDay) data).getTemperature().toString();
|
||||
} else if (data instanceof EmsBatteryDataMonth) {
|
||||
temperature = ((EmsBatteryDataMonth) data).getTemperature().toString();
|
||||
} else {
|
||||
throw new IllegalArgumentException("不支持的数据类型");
|
||||
}
|
||||
cacheMap.put(cacheKey, temperature);
|
||||
}
|
||||
return cacheMap;
|
||||
}
|
||||
|
||||
// 新增定时任务,每1分钟强制刷新一次队列(防止数据长期积压)
|
||||
@Scheduled(fixedRate = 60000) // 1分钟 = 60000毫秒
|
||||
protected void scheduledFlushBatch() {
|
||||
if (!hourBatchQueue.isEmpty()) {
|
||||
List<EmsBatteryData> remaining = drainQueue(hourBatchQueue);
|
||||
ioExecutor.execute(() -> batchUpdateHour(remaining));
|
||||
log.info("定时任务触发,处理小时级剩余数据,数量: " + remaining.size());
|
||||
}
|
||||
if (!dayBatchQueue.isEmpty()) {
|
||||
List<EmsBatteryData> remaining = drainQueue(dayBatchQueue);
|
||||
ioExecutor.execute(() -> batchUpdateDay(remaining));
|
||||
log.info("定时任务触发,处理天级剩余数据,数量: " + remaining.size());
|
||||
}
|
||||
if (!monthBatchQueue.isEmpty()) {
|
||||
List<EmsBatteryData> remaining = drainQueue(monthBatchQueue);
|
||||
ioExecutor.execute(() -> batchUpdateMonth(remaining));
|
||||
log.info("定时任务触发,处理月级剩余数据,数量: " + remaining.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,24 +159,9 @@
|
||||
<if test="alarmLevel != null and alarmLevel != ''">
|
||||
AND t.alarm_level = #{alarmLevel}
|
||||
</if>
|
||||
<if test="deviceId != null and deviceId != ''">
|
||||
AND t.device_id = #{deviceId}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND t.status IN (
|
||||
<foreach collection="status.split(',')" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="alarmStartTime != null and alarmStartTime != null and alarmEndTime != null and alarmEndTime != ''">
|
||||
AND (date_format(t.alarm_start_time,'%Y%m%d') BETWEEN date_format(#{alarmStartTime},'%Y%m%d') and date_format(#{alarmEndTime},'%Y%m%d')
|
||||
or date_format(t.alarm_end_time,'%Y%m%d') BETWEEN date_format(#{alarmStartTime},'%Y%m%d') and date_format(#{alarmEndTime},'%Y%m%d') )
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getDeviceAlarmNum" resultType="java.lang.Integer">
|
||||
select COUNT(*) as alarmNum from ems_alarm_records
|
||||
where site_id = #{siteId} and device_id = #{deviceId}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -883,143 +883,4 @@
|
||||
and t.data_update_time = latest.max_update_time
|
||||
order by dataTime
|
||||
</select>
|
||||
|
||||
<select id="getYestLatestDate" resultMap="EmsAmmeterDataResult">
|
||||
<include refid="selectEmsAmmeterDataVo"/>
|
||||
where site_id = #{siteId}
|
||||
and device_id = #{deviceId}
|
||||
and DATE(data_update_time) = #{yestData}
|
||||
order by data_update_time desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getMonthlyTimeRanges" resultType="com.xzzn.ems.domain.vo.MonthlyTimeRange">
|
||||
SELECT site_id as siteId,
|
||||
DATE_FORMAT(data_update_time, '%Y-%m') AS month,
|
||||
MIN(data_update_time) AS firstDataTime,
|
||||
MAX(data_update_time) AS lastDataTime
|
||||
FROM ems_ammeter_data
|
||||
WHERE (site_id = '021_DDS_01' AND device_id = 'METE')
|
||||
OR (site_id = '021_FXX_01' AND device_id = 'LOAD')
|
||||
GROUP BY site_id, DATE_FORMAT(data_update_time, '%Y-%m')
|
||||
ORDER BY site_id, month
|
||||
</select>
|
||||
|
||||
<select id="batchGetTimePointValues" resultType="com.xzzn.ems.domain.vo.TimePointValue">
|
||||
SELECT site_id as siteId, data_update_time as dataUpdateTime,
|
||||
current_forward_active_total AS totalChargeData,
|
||||
current_reverse_active_total AS totalDischargeData
|
||||
FROM ems_ammeter_data
|
||||
WHERE (site_id, data_update_time) IN
|
||||
<foreach collection="list" item="item" separator="," open="(" close=")">
|
||||
(#{item.siteId}, #{item.dataTime})
|
||||
</foreach>
|
||||
AND ((site_id = '021_DDS_01' AND device_id = 'METE')
|
||||
OR (site_id = '021_FXX_01' AND device_id = 'LOAD'))
|
||||
</select>
|
||||
|
||||
<select id="getChargeDataByHour" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT ammeterDate,
|
||||
dataUpdateTime,
|
||||
totalChargedCap,
|
||||
totalDisChargedCap,
|
||||
totalChargedCap - LAG(totalChargedCap) OVER (ORDER BY ammeterDate) AS chargedCap,
|
||||
totalDisChargedCap - LAG(totalDisChargedCap) OVER (ORDER BY ammeterDate) AS disChargedCap
|
||||
FROM ( SELECT data_update_time AS dataUpdateTime,
|
||||
current_forward_active_total AS totalChargedCap,
|
||||
current_reverse_active_total AS totalDisChargedCap,
|
||||
DATE_FORMAT(data_update_time, '%H:00') AS ammeterDate,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY DATE_FORMAT(data_update_time, '%H:00')
|
||||
ORDER BY data_update_time DESC
|
||||
) AS rn
|
||||
FROM ems_ammeter_data
|
||||
WHERE site_id = #{siteId}
|
||||
AND device_id = #{deviceId}
|
||||
AND DATE(data_update_time) = #{startDate}
|
||||
) AS hourly_data
|
||||
WHERE rn = 1
|
||||
ORDER BY ammeterDate
|
||||
</select>
|
||||
|
||||
<select id="getChargeDataByMonth" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT month as ammeterDate,
|
||||
data_update_time AS dataUpdateTime,
|
||||
current_forward_active_total AS chargedCap,
|
||||
current_reverse_active_total AS disChargedCap
|
||||
FROM (
|
||||
SELECT DATE_FORMAT(data_update_time, '%Y-%m') AS month,
|
||||
data_update_time,
|
||||
current_forward_active_total,
|
||||
current_reverse_active_total,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY DATE_FORMAT(data_update_time, '%Y-%m')
|
||||
ORDER BY data_update_time DESC
|
||||
) AS rn
|
||||
FROM ems_ammeter_data
|
||||
WHERE site_id = #{siteId}
|
||||
AND device_id = #{deviceId}
|
||||
AND data_update_time BETWEEN #{startDate} AND #{endDate}
|
||||
) AS monthly_data
|
||||
WHERE rn = 1
|
||||
ORDER BY ammeterDate
|
||||
</select>
|
||||
|
||||
<sql id="powerFilter">
|
||||
MAX(CASE WHEN t.device_id = 'METE' THEN t.secondary_total_active_power END) AS gridPower,
|
||||
MAX(CASE WHEN t.device_id = 'LOAD' THEN t.total_active_power END) AS storagePower,
|
||||
MAX(CASE WHEN t.device_id = 'METEGF' THEN t.total_active_power END) AS pvPower
|
||||
</sql>
|
||||
|
||||
<sql id="commonFilter">
|
||||
WHERE p.device_id in ('METE','LOAD','METEGF')
|
||||
and p.site_id = #{siteId}
|
||||
<if test="startDate != null">
|
||||
AND p.data_update_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND p.data_update_time < #{endDate}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getPowerDataByHour" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PowerStatisListVo">
|
||||
select latest.dateHour as statisDate,
|
||||
<include refid="powerFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_ammeter_data p
|
||||
<include refid="commonFilter"/>
|
||||
GROUP BY p.site_id,p.device_id,dateHour
|
||||
) latest inner join ems_ammeter_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
GROUP BY statisDate
|
||||
order by statisDate desc
|
||||
</select>
|
||||
|
||||
<select id="getPowerDataByDay" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PowerStatisListVo">
|
||||
select latest.dateDay as statisDate,
|
||||
<include refid="powerFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id, DATE(p.data_update_time ) AS dateDay,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_ammeter_data p
|
||||
<include refid="commonFilter"/>
|
||||
GROUP BY p.site_id,p.device_id,dateDay
|
||||
) latest inner join ems_ammeter_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
GROUP BY statisDate
|
||||
order by statisDate desc
|
||||
</select>
|
||||
|
||||
<select id="getPowerDataByMonth" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PowerStatisListVo">
|
||||
select latest.dateMonth as statisDate,
|
||||
<include refid="powerFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%Y-%m') as dateMonth,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_ammeter_data p
|
||||
<include refid="commonFilter"/>
|
||||
GROUP BY p.site_id,p.device_id,dateMonth
|
||||
) latest inner join ems_ammeter_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
GROUP BY statisDate
|
||||
order by statisDate desc
|
||||
</select>
|
||||
</mapper>
|
||||
@ -343,7 +343,7 @@
|
||||
avg(t.avg_cell_temp) as batteryTemp,
|
||||
DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') AS createDate
|
||||
from ems_battery_cluster t
|
||||
where t.site_id = #{siteId}
|
||||
where t.site_id = '021_FXX_01'
|
||||
AND t.create_time >= Date(#{startDate})
|
||||
AND t.create_time <= #{endDate}
|
||||
GROUP BY t.site_id,DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00')
|
||||
|
||||
@ -1,216 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xzzn.ems.mapper.EmsBatteryDataDayMapper">
|
||||
|
||||
<resultMap type="EmsBatteryDataDay" id="EmsBatteryDataDayResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="batteryPack" column="battery_pack" />
|
||||
<result property="batteryCluster" column="battery_cluster" />
|
||||
<result property="batteryCellId" column="battery_cell_id" />
|
||||
<result property="voltage" column="voltage" />
|
||||
<result property="temperature" column="temperature" />
|
||||
<result property="soc" column="soc" />
|
||||
<result property="soh" column="soh" />
|
||||
<result property="dataTimestamp" column="data_timestamp" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="clusterDeviceId" column="cluster_device_id" />
|
||||
<result property="interResistance" column="inter_resistance" />
|
||||
<result property="dayTime" column="day_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsBatteryDataDayVo">
|
||||
select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance, day_time from ems_battery_data_day
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsBatteryDataDayList" parameterType="EmsBatteryDataDay" resultMap="EmsBatteryDataDayResult">
|
||||
<include refid="selectEmsBatteryDataDayVo"/>
|
||||
<where>
|
||||
<if test="batteryPack != null and batteryPack != ''"> and battery_pack = #{batteryPack}</if>
|
||||
<if test="batteryCluster != null and batteryCluster != ''"> and battery_cluster = #{batteryCluster}</if>
|
||||
<if test="batteryCellId != null and batteryCellId != ''"> and battery_cell_id = #{batteryCellId}</if>
|
||||
<if test="voltage != null "> and voltage = #{voltage}</if>
|
||||
<if test="temperature != null "> and temperature = #{temperature}</if>
|
||||
<if test="soc != null "> and soc = #{soc}</if>
|
||||
<if test="soh != null "> and soh = #{soh}</if>
|
||||
<if test="dataTimestamp != null "> and data_timestamp = #{dataTimestamp}</if>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="clusterDeviceId != null and clusterDeviceId != ''"> and cluster_device_id = #{clusterDeviceId}</if>
|
||||
<if test="interResistance != null "> and inter_resistance = #{interResistance}</if>
|
||||
<if test="dayTime != null "> and day_time = #{dayTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsBatteryDataDayById" parameterType="Long" resultMap="EmsBatteryDataDayResult">
|
||||
<include refid="selectEmsBatteryDataDayVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsBatteryDataDay" parameterType="EmsBatteryDataDay" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_battery_data_day
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack,</if>
|
||||
<if test="batteryCluster != null">battery_cluster,</if>
|
||||
<if test="batteryCellId != null">battery_cell_id,</if>
|
||||
<if test="voltage != null">voltage,</if>
|
||||
<if test="temperature != null">temperature,</if>
|
||||
<if test="soc != null">soc,</if>
|
||||
<if test="soh != null">soh,</if>
|
||||
<if test="dataTimestamp != null">data_timestamp,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id,</if>
|
||||
<if test="interResistance != null">inter_resistance,</if>
|
||||
<if test="dayTime != null">day_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">#{batteryPack},</if>
|
||||
<if test="batteryCluster != null">#{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">#{batteryCellId},</if>
|
||||
<if test="voltage != null">#{voltage},</if>
|
||||
<if test="temperature != null">#{temperature},</if>
|
||||
<if test="soc != null">#{soc},</if>
|
||||
<if test="soh != null">#{soh},</if>
|
||||
<if test="dataTimestamp != null">#{dataTimestamp},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">#{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">#{interResistance},</if>
|
||||
<if test="dayTime != null">#{dayTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsBatteryDataDay" parameterType="EmsBatteryDataDay">
|
||||
update ems_battery_data_day
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack = #{batteryPack},</if>
|
||||
<if test="batteryCluster != null">battery_cluster = #{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">battery_cell_id = #{batteryCellId},</if>
|
||||
<if test="voltage != null">voltage = #{voltage},</if>
|
||||
<if test="temperature != null">temperature = #{temperature},</if>
|
||||
<if test="soc != null">soc = #{soc},</if>
|
||||
<if test="soh != null">soh = #{soh},</if>
|
||||
<if test="dataTimestamp != null">data_timestamp = #{dataTimestamp},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id = #{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">inter_resistance = #{interResistance},</if>
|
||||
<if test="dayTime != null">day_time = #{dayTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsBatteryDataDayById" parameterType="Long">
|
||||
delete from ems_battery_data_day where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsBatteryDataDayByIds" parameterType="String">
|
||||
delete from ems_battery_data_day where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="findDayMaxTemp" resultMap="EmsBatteryDataDayResult">
|
||||
<include refid="selectEmsBatteryDataDayVo"/>
|
||||
WHERE site_id = #{siteId}
|
||||
AND battery_pack = #{stackId}
|
||||
AND cluster_device_id = #{clusterId}
|
||||
AND device_id = #{batteryId}
|
||||
AND day_time = #{dayStart}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 批量插入或更新-->
|
||||
<insert id="batchInsertOrUpdate">
|
||||
INSERT INTO ems_battery_data_day (
|
||||
battery_pack,
|
||||
battery_cluster,
|
||||
battery_cell_id,
|
||||
voltage,
|
||||
temperature,
|
||||
soc,
|
||||
soh,
|
||||
data_timestamp,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
site_id,
|
||||
device_id,
|
||||
cluster_device_id,
|
||||
inter_resistance,
|
||||
day_time
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.batteryPack},
|
||||
#{item.batteryCluster},
|
||||
#{item.batteryCellId},
|
||||
#{item.voltage},
|
||||
#{item.temperature},
|
||||
#{item.soc},
|
||||
#{item.soh},
|
||||
#{item.dataTimestamp},
|
||||
#{item.createBy},
|
||||
#{item.createTime}, #{item.updateBy},
|
||||
#{item.updateTime},
|
||||
#{item.remark},
|
||||
#{item.siteId},
|
||||
#{item.deviceId},
|
||||
#{item.clusterDeviceId},
|
||||
#{item.interResistance},
|
||||
#{item.dayTime}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
-- 仅当新温度高于现有温度时,才更新温度和相关字段
|
||||
update_time = IF(VALUES(temperature) > temperature, NOW(), update_time),
|
||||
data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp),
|
||||
voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage),
|
||||
soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc),
|
||||
soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh),
|
||||
inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance),
|
||||
update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by),
|
||||
temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature)
|
||||
</insert>
|
||||
|
||||
<select id="getBatteryDayData" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.BatteryDataStatsListVo">
|
||||
SELECT day_time as dataTimestamp,
|
||||
voltage, temperature, soc, soh,
|
||||
device_id as deviceId,
|
||||
cluster_device_id as clusterDeviceId
|
||||
FROM ems_battery_data_day
|
||||
WHERE site_id = #{siteId}
|
||||
and cluster_device_id = #{clusterDeviceId}
|
||||
and device_id = #{deviceId}
|
||||
and day_time >= #{startDate}
|
||||
and day_time <= #{endDate}
|
||||
order by day_time
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -1,202 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xzzn.ems.mapper.EmsBatteryDataHourMapper">
|
||||
|
||||
<resultMap type="EmsBatteryDataHour" id="EmsBatteryDataHourResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="batteryPack" column="battery_pack" />
|
||||
<result property="batteryCluster" column="battery_cluster" />
|
||||
<result property="batteryCellId" column="battery_cell_id" />
|
||||
<result property="voltage" column="voltage" />
|
||||
<result property="temperature" column="temperature" />
|
||||
<result property="soc" column="soc" />
|
||||
<result property="soh" column="soh" />
|
||||
<result property="dataTimestamp" column="data_timestamp" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="clusterDeviceId" column="cluster_device_id" />
|
||||
<result property="interResistance" column="inter_resistance" />
|
||||
<result property="hourTime" column="hour_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsBatteryDataHourVo">
|
||||
select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance, hour_time from ems_battery_data_hour
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsBatteryDataHourList" parameterType="EmsBatteryDataHour" resultMap="EmsBatteryDataHourResult">
|
||||
<include refid="selectEmsBatteryDataHourVo"/>
|
||||
<where>
|
||||
<if test="batteryPack != null and batteryPack != ''"> and battery_pack = #{batteryPack}</if>
|
||||
<if test="batteryCluster != null and batteryCluster != ''"> and battery_cluster = #{batteryCluster}</if>
|
||||
<if test="batteryCellId != null and batteryCellId != ''"> and battery_cell_id = #{batteryCellId}</if>
|
||||
<if test="voltage != null "> and voltage = #{voltage}</if>
|
||||
<if test="temperature != null "> and temperature = #{temperature}</if>
|
||||
<if test="soc != null "> and soc = #{soc}</if>
|
||||
<if test="soh != null "> and soh = #{soh}</if>
|
||||
<if test="dataTimestamp != null "> and data_timestamp = #{dataTimestamp}</if>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="clusterDeviceId != null and clusterDeviceId != ''"> and cluster_device_id = #{clusterDeviceId}</if>
|
||||
<if test="interResistance != null "> and inter_resistance = #{interResistance}</if>
|
||||
<if test="hourTime != null "> and hour_time = #{hourTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsBatteryDataHourById" parameterType="Long" resultMap="EmsBatteryDataHourResult">
|
||||
<include refid="selectEmsBatteryDataHourVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsBatteryDataHour" parameterType="EmsBatteryDataHour" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_battery_data_hour
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack,</if>
|
||||
<if test="batteryCluster != null">battery_cluster,</if>
|
||||
<if test="batteryCellId != null">battery_cell_id,</if>
|
||||
<if test="voltage != null">voltage,</if>
|
||||
<if test="temperature != null">temperature,</if>
|
||||
<if test="soc != null">soc,</if>
|
||||
<if test="soh != null">soh,</if>
|
||||
<if test="dataTimestamp != null">data_timestamp,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id,</if>
|
||||
<if test="interResistance != null">inter_resistance,</if>
|
||||
<if test="hourTime != null">hour_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">#{batteryPack},</if>
|
||||
<if test="batteryCluster != null">#{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">#{batteryCellId},</if>
|
||||
<if test="voltage != null">#{voltage},</if>
|
||||
<if test="temperature != null">#{temperature},</if>
|
||||
<if test="soc != null">#{soc},</if>
|
||||
<if test="soh != null">#{soh},</if>
|
||||
<if test="dataTimestamp != null">#{dataTimestamp},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">#{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">#{interResistance},</if>
|
||||
<if test="hourTime != null">#{hourTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsBatteryDataHour" parameterType="EmsBatteryDataHour">
|
||||
update ems_battery_data_hour
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack = #{batteryPack},</if>
|
||||
<if test="batteryCluster != null">battery_cluster = #{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">battery_cell_id = #{batteryCellId},</if>
|
||||
<if test="voltage != null">voltage = #{voltage},</if>
|
||||
<if test="temperature != null">temperature = #{temperature},</if>
|
||||
<if test="soc != null">soc = #{soc},</if>
|
||||
<if test="soh != null">soh = #{soh},</if>
|
||||
<if test="dataTimestamp != null">data_timestamp = #{dataTimestamp},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id = #{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">inter_resistance = #{interResistance},</if>
|
||||
<if test="hourTime != null">hour_time = #{hourTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsBatteryDataHourById" parameterType="Long">
|
||||
delete from ems_battery_data_hour where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsBatteryDataHourByIds" parameterType="String">
|
||||
delete from ems_battery_data_hour where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="findHourMaxTemp" resultMap="EmsBatteryDataHourResult">
|
||||
<include refid="selectEmsBatteryDataHourVo"/>
|
||||
WHERE site_id = #{siteId}
|
||||
AND battery_pack = #{stackId}
|
||||
AND cluster_device_id = #{clusterId}
|
||||
AND device_id = #{batteryId}
|
||||
AND hour_time = #{hourStart}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 批量插入或更新-->
|
||||
<insert id="batchInsertOrUpdate">
|
||||
INSERT INTO ems_battery_data_hour (
|
||||
battery_pack,
|
||||
battery_cluster,
|
||||
battery_cell_id,
|
||||
voltage,
|
||||
temperature,
|
||||
soc,
|
||||
soh,
|
||||
data_timestamp,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
site_id,
|
||||
device_id,
|
||||
cluster_device_id,
|
||||
inter_resistance,
|
||||
hour_time
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.batteryPack},
|
||||
#{item.batteryCluster},
|
||||
#{item.batteryCellId},
|
||||
#{item.voltage},
|
||||
#{item.temperature},
|
||||
#{item.soc},
|
||||
#{item.soh},
|
||||
#{item.dataTimestamp},
|
||||
#{item.createBy},
|
||||
#{item.createTime},
|
||||
#{item.updateBy},
|
||||
#{item.updateTime},
|
||||
#{item.remark},
|
||||
#{item.siteId},
|
||||
#{item.deviceId},
|
||||
#{item.clusterDeviceId},
|
||||
#{item.interResistance},
|
||||
#{item.hourTime}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
-- 仅当新温度高于现有温度时,才更新温度和相关字段
|
||||
update_time = IF(VALUES(temperature) > temperature, NOW(), update_time),
|
||||
data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp),
|
||||
voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage),
|
||||
soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc),
|
||||
soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh),
|
||||
inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance),
|
||||
update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by),
|
||||
temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature)
|
||||
</insert>
|
||||
</mapper>
|
||||
@ -1,152 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper">
|
||||
|
||||
<resultMap type="EmsBatteryDataMinutes" id="EmsBatteryDataMinutesResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="batteryPack" column="battery_pack" />
|
||||
<result property="batteryCluster" column="battery_cluster" />
|
||||
<result property="batteryCellId" column="battery_cell_id" />
|
||||
<result property="voltage" column="voltage" />
|
||||
<result property="temperature" column="temperature" />
|
||||
<result property="soc" column="soc" />
|
||||
<result property="soh" column="soh" />
|
||||
<result property="dataTimestamp" column="data_timestamp" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="clusterDeviceId" column="cluster_device_id" />
|
||||
<result property="interResistance" column="inter_resistance" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsBatteryDataMinutesVo">
|
||||
select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance from ems_battery_data_minutes
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsBatteryDataMinutesList" parameterType="EmsBatteryDataMinutes" resultMap="EmsBatteryDataMinutesResult">
|
||||
<include refid="selectEmsBatteryDataMinutesVo"/>
|
||||
<where>
|
||||
<if test="batteryPack != null and batteryPack != ''"> and battery_pack = #{batteryPack}</if>
|
||||
<if test="batteryCluster != null and batteryCluster != ''"> and battery_cluster = #{batteryCluster}</if>
|
||||
<if test="batteryCellId != null and batteryCellId != ''"> and battery_cell_id = #{batteryCellId}</if>
|
||||
<if test="voltage != null "> and voltage = #{voltage}</if>
|
||||
<if test="temperature != null "> and temperature = #{temperature}</if>
|
||||
<if test="soc != null "> and soc = #{soc}</if>
|
||||
<if test="soh != null "> and soh = #{soh}</if>
|
||||
<if test="dataTimestamp != null "> and data_timestamp = #{dataTimestamp}</if>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="clusterDeviceId != null and clusterDeviceId != ''"> and cluster_device_id = #{clusterDeviceId}</if>
|
||||
<if test="interResistance != null "> and inter_resistance = #{interResistance}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsBatteryDataMinutesById" parameterType="Long" resultMap="EmsBatteryDataMinutesResult">
|
||||
<include refid="selectEmsBatteryDataMinutesVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsBatteryDataMinutes" parameterType="EmsBatteryDataMinutes" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_battery_data_minutes
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack,</if>
|
||||
<if test="batteryCluster != null">battery_cluster,</if>
|
||||
<if test="batteryCellId != null">battery_cell_id,</if>
|
||||
<if test="voltage != null">voltage,</if>
|
||||
<if test="temperature != null">temperature,</if>
|
||||
<if test="soc != null">soc,</if>
|
||||
<if test="soh != null">soh,</if>
|
||||
<if test="dataTimestamp != null">data_timestamp,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id,</if>
|
||||
<if test="interResistance != null">inter_resistance,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">#{batteryPack},</if>
|
||||
<if test="batteryCluster != null">#{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">#{batteryCellId},</if>
|
||||
<if test="voltage != null">#{voltage},</if>
|
||||
<if test="temperature != null">#{temperature},</if>
|
||||
<if test="soc != null">#{soc},</if>
|
||||
<if test="soh != null">#{soh},</if>
|
||||
<if test="dataTimestamp != null">#{dataTimestamp},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">#{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">#{interResistance},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsBatteryDataMinutes" parameterType="EmsBatteryDataMinutes">
|
||||
update ems_battery_data_minutes
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack = #{batteryPack},</if>
|
||||
<if test="batteryCluster != null">battery_cluster = #{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">battery_cell_id = #{batteryCellId},</if>
|
||||
<if test="voltage != null">voltage = #{voltage},</if>
|
||||
<if test="temperature != null">temperature = #{temperature},</if>
|
||||
<if test="soc != null">soc = #{soc},</if>
|
||||
<if test="soh != null">soh = #{soh},</if>
|
||||
<if test="dataTimestamp != null">data_timestamp = #{dataTimestamp},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id = #{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">inter_resistance = #{interResistance},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsBatteryDataMinutesByDateDay" parameterType="Date">
|
||||
delete from ems_battery_data_minutes where date_day = #{dateDay}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsBatteryDataMinutesByDateDays" parameterType="String">
|
||||
delete from ems_battery_data_minutes where date_day in
|
||||
<foreach item="dateDay" collection="array" open="(" separator="," close=")">
|
||||
#{dateDay}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertMinutesBatteryDataList" parameterType="java.util.List">
|
||||
INSERT INTO ems_battery_data_minutes (
|
||||
battery_pack, battery_cluster, battery_cell_id,
|
||||
voltage, temperature, soc, soh, data_timestamp,
|
||||
create_by, create_time, update_by, update_time,
|
||||
remark, site_id, device_id, cluster_device_id, inter_resistance
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.batteryPack}, #{item.batteryCluster}, #{item.batteryCellId},
|
||||
#{item.voltage}, #{item.temperature}, #{item.soc}, #{item.soh}, #{item.dataTimestamp},
|
||||
#{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime},
|
||||
#{item.remark}, #{item.siteId}, #{item.deviceId}, #{item.clusterDeviceId},#{item.interResistance}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByTimeBeforeOneHour" parameterType="String">
|
||||
delete from ems_battery_data_minutes where data_timestamp < #{oneHourAgoStr}
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -1,211 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xzzn.ems.mapper.EmsBatteryDataMonthMapper">
|
||||
|
||||
<resultMap type="EmsBatteryDataMonth" id="EmsBatteryDataMonthResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="batteryPack" column="battery_pack" />
|
||||
<result property="batteryCluster" column="battery_cluster" />
|
||||
<result property="batteryCellId" column="battery_cell_id" />
|
||||
<result property="voltage" column="voltage" />
|
||||
<result property="temperature" column="temperature" />
|
||||
<result property="soc" column="soc" />
|
||||
<result property="soh" column="soh" />
|
||||
<result property="dataTimestamp" column="data_timestamp" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="clusterDeviceId" column="cluster_device_id" />
|
||||
<result property="interResistance" column="inter_resistance" />
|
||||
<result property="monthTime" column="month_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsBatteryDataMonthVo">
|
||||
select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance, month_time from ems_battery_data_month
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsBatteryDataMonthList" parameterType="EmsBatteryDataMonth" resultMap="EmsBatteryDataMonthResult">
|
||||
<include refid="selectEmsBatteryDataMonthVo"/>
|
||||
<where>
|
||||
<if test="batteryPack != null and batteryPack != ''"> and battery_pack = #{batteryPack}</if>
|
||||
<if test="batteryCluster != null and batteryCluster != ''"> and battery_cluster = #{batteryCluster}</if>
|
||||
<if test="batteryCellId != null and batteryCellId != ''"> and battery_cell_id = #{batteryCellId}</if>
|
||||
<if test="voltage != null "> and voltage = #{voltage}</if>
|
||||
<if test="temperature != null "> and temperature = #{temperature}</if>
|
||||
<if test="soc != null "> and soc = #{soc}</if>
|
||||
<if test="soh != null "> and soh = #{soh}</if>
|
||||
<if test="dataTimestamp != null "> and data_timestamp = #{dataTimestamp}</if>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="clusterDeviceId != null and clusterDeviceId != ''"> and cluster_device_id = #{clusterDeviceId}</if>
|
||||
<if test="interResistance != null "> and inter_resistance = #{interResistance}</if>
|
||||
<if test="monthTime != null "> and month_time = #{monthTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsBatteryDataMonthById" parameterType="Long" resultMap="EmsBatteryDataMonthResult">
|
||||
<include refid="selectEmsBatteryDataMonthVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsBatteryDataMonth" parameterType="EmsBatteryDataMonth" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_battery_data_month
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack,</if>
|
||||
<if test="batteryCluster != null">battery_cluster,</if>
|
||||
<if test="batteryCellId != null">battery_cell_id,</if>
|
||||
<if test="voltage != null">voltage,</if>
|
||||
<if test="temperature != null">temperature,</if>
|
||||
<if test="soc != null">soc,</if>
|
||||
<if test="soh != null">soh,</if>
|
||||
<if test="dataTimestamp != null">data_timestamp,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id,</if>
|
||||
<if test="interResistance != null">inter_resistance,</if>
|
||||
<if test="monthTime != null">month_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="batteryPack != null">#{batteryPack},</if>
|
||||
<if test="batteryCluster != null">#{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">#{batteryCellId},</if>
|
||||
<if test="voltage != null">#{voltage},</if>
|
||||
<if test="temperature != null">#{temperature},</if>
|
||||
<if test="soc != null">#{soc},</if>
|
||||
<if test="soh != null">#{soh},</if>
|
||||
<if test="dataTimestamp != null">#{dataTimestamp},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">#{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">#{interResistance},</if>
|
||||
<if test="monthTime != null">#{monthTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsBatteryDataMonth" parameterType="EmsBatteryDataMonth">
|
||||
update ems_battery_data_month
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="batteryPack != null">battery_pack = #{batteryPack},</if>
|
||||
<if test="batteryCluster != null">battery_cluster = #{batteryCluster},</if>
|
||||
<if test="batteryCellId != null">battery_cell_id = #{batteryCellId},</if>
|
||||
<if test="voltage != null">voltage = #{voltage},</if>
|
||||
<if test="temperature != null">temperature = #{temperature},</if>
|
||||
<if test="soc != null">soc = #{soc},</if>
|
||||
<if test="soh != null">soh = #{soh},</if>
|
||||
<if test="dataTimestamp != null">data_timestamp = #{dataTimestamp},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="clusterDeviceId != null">cluster_device_id = #{clusterDeviceId},</if>
|
||||
<if test="interResistance != null">inter_resistance = #{interResistance},</if>
|
||||
<if test="monthTime != null">month_time = #{monthTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsBatteryDataMonthById" parameterType="Long">
|
||||
delete from ems_battery_data_month where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsBatteryDataMonthByIds" parameterType="String">
|
||||
delete from ems_battery_data_month where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="findMonthMaxTemp" resultMap="EmsBatteryDataMonthResult">
|
||||
<include refid="selectEmsBatteryDataMonthVo"/>
|
||||
WHERE site_id = #{siteId}
|
||||
AND battery_pack = #{stackId}
|
||||
AND cluster_device_id = #{clusterId}
|
||||
AND device_id = #{batteryId}
|
||||
AND month_time = #{monthStart}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 批量插入或更新-->
|
||||
<insert id="batchInsertOrUpdate">
|
||||
INSERT INTO ems_battery_data_month (
|
||||
battery_pack,
|
||||
battery_cluster,
|
||||
battery_cell_id,
|
||||
voltage,
|
||||
temperature,
|
||||
soc,
|
||||
soh,
|
||||
data_timestamp,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark,
|
||||
site_id,
|
||||
device_id,
|
||||
cluster_device_id,
|
||||
inter_resistance,
|
||||
month_time
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.batteryPack},
|
||||
#{item.batteryCluster},
|
||||
#{item.batteryCellId},
|
||||
#{item.voltage},
|
||||
#{item.temperature},
|
||||
#{item.soc},
|
||||
#{item.soh},
|
||||
#{item.dataTimestamp},
|
||||
#{item.createBy},
|
||||
#{item.createTime},
|
||||
#{item.updateBy},
|
||||
#{item.updateTime},
|
||||
#{item.remark},
|
||||
#{item.siteId},
|
||||
#{item.deviceId},
|
||||
#{item.clusterDeviceId},
|
||||
#{item.interResistance},
|
||||
#{item.monthTime}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
-- 仅当新温度高于现有温度时,才更新温度和相关字段
|
||||
update_time = IF(VALUES(temperature) > temperature, NOW(), update_time),
|
||||
data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp),
|
||||
voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage),
|
||||
soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc),
|
||||
soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh),
|
||||
inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance),
|
||||
update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by),
|
||||
temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature)
|
||||
</insert>
|
||||
|
||||
<select id="getAllBatteryIdsBySites" resultType="com.xzzn.ems.domain.vo.SiteBatteryListVo">
|
||||
select DISTINCT t.site_id as siteId, t.device_id as deviceId
|
||||
from ems_battery_data_month t
|
||||
where t.site_id in
|
||||
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
||||
#{siteId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@ -348,7 +348,7 @@
|
||||
<select id="getStackAveTempList" resultType="com.xzzn.ems.domain.vo.StackAveTempVo">
|
||||
select t.site_id,
|
||||
avg(t.operating_temp) as temp,
|
||||
DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00:00') AS createDate
|
||||
DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') AS createDate
|
||||
from ems_battery_stack t
|
||||
where t.site_id = #{siteId}
|
||||
AND t.create_time >= Date(#{startDate})
|
||||
@ -359,6 +359,7 @@
|
||||
|
||||
<sql id="statisCommonFilter">
|
||||
WHERE p.site_id = #{siteId}
|
||||
and p.device_id = #{deviceId}
|
||||
<if test="startDate != null">
|
||||
AND p.update_time >= #{startDate}
|
||||
</if>
|
||||
@ -389,7 +390,6 @@
|
||||
|
||||
<select id="getStackDataByHour" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.StackStatisListVo">
|
||||
select latest.dateHour as statisDate,
|
||||
t.device_id as deviceId,
|
||||
<include refid="dataTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%H')+1 AS dateHour,MAX(p.update_time) as max_update_time
|
||||
FROM ems_battery_stack p
|
||||
@ -403,7 +403,6 @@
|
||||
|
||||
<select id="getStackDataByDay" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.StackStatisListVo">
|
||||
select latest.dateDay as statisDate,
|
||||
t.device_id as deviceId,
|
||||
<include refid="dataTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%Y-%m-%d') AS dateDay,MAX(p.update_time) as max_update_time
|
||||
FROM ems_battery_stack p
|
||||
@ -417,7 +416,6 @@
|
||||
|
||||
<select id="getStackDataByMonth" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.StackStatisListVo">
|
||||
select latest.dateMonth as statisDate,
|
||||
t.device_id as deviceId,
|
||||
<include refid="dataTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%Y-%m') AS dateMonth,MAX(p.update_time) as max_update_time
|
||||
FROM ems_battery_stack p
|
||||
@ -430,8 +428,8 @@
|
||||
</select>
|
||||
|
||||
<select id="getSiteSumStackInfo" parameterType="String" resultType="com.xzzn.ems.domain.EmsBatteryStack">
|
||||
select AVG(t.stack_soc) as stackSoc,
|
||||
AVG(t.stack_soh) as stackSoh
|
||||
select SUM(t.stack_soc) as stackSoc,
|
||||
sum(t.stack_soh) as stackSoh
|
||||
from ems_battery_stack t
|
||||
INNER JOIN (
|
||||
select p.site_id,p.device_id,MAX(p.create_time) as max_time
|
||||
|
||||
@ -1,210 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xzzn.ems.mapper.EmsDailyChargeDataMapper">
|
||||
|
||||
<resultMap type="EmsDailyChargeData" id="EmsDailyChargeDataResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="dateTime" column="date_time" />
|
||||
<result property="totalChargeData" column="total_charge_Data" />
|
||||
<result property="totalDischargeData" column="total_discharge_Data" />
|
||||
<result property="chargeData" column="charge_data" />
|
||||
<result property="dischargeData" column="discharge_data" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsDailyChargeDataVo">
|
||||
select id, site_id, device_id, date_time, total_charge_Data, total_discharge_Data, charge_data, discharge_data, create_by, create_time, update_by, update_time, remark from ems_daily_charge_data
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsDailyChargeDataList" parameterType="EmsDailyChargeData" resultMap="EmsDailyChargeDataResult">
|
||||
<include refid="selectEmsDailyChargeDataVo"/>
|
||||
<where>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
<if test="dateTime != null "> and date_time = #{dateTime}</if>
|
||||
<if test="totalChargeData != null "> and total_charge_Data = #{totalChargeData}</if>
|
||||
<if test="totalDischargeData != null "> and total_discharge_Data = #{totalDischargeData}</if>
|
||||
<if test="chargeData != null "> and charge_data = #{chargeData}</if>
|
||||
<if test="dischargeData != null "> and discharge_data = #{dischargeData}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsDailyChargeDataById" parameterType="Long" resultMap="EmsDailyChargeDataResult">
|
||||
<include refid="selectEmsDailyChargeDataVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsDailyChargeData" parameterType="EmsDailyChargeData" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_daily_charge_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null and deviceId != ''">device_id,</if>
|
||||
<if test="dateTime != null">date_time,</if>
|
||||
<if test="totalChargeData != null">total_charge_Data,</if>
|
||||
<if test="totalDischargeData != null">total_discharge_Data,</if>
|
||||
<if test="chargeData != null">charge_data,</if>
|
||||
<if test="dischargeData != null">discharge_data,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null and deviceId != ''">#{deviceId},</if>
|
||||
<if test="dateTime != null">#{dateTime},</if>
|
||||
<if test="totalChargeData != null">#{totalChargeData},</if>
|
||||
<if test="totalDischargeData != null">#{totalDischargeData},</if>
|
||||
<if test="chargeData != null">#{chargeData},</if>
|
||||
<if test="dischargeData != null">#{dischargeData},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsDailyChargeData" parameterType="EmsDailyChargeData">
|
||||
update ems_daily_charge_data
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
|
||||
<if test="dateTime != null">date_time = #{dateTime},</if>
|
||||
<if test="totalChargeData != null">total_charge_Data = #{totalChargeData},</if>
|
||||
<if test="totalDischargeData != null">total_discharge_Data = #{totalDischargeData},</if>
|
||||
<if test="chargeData != null">charge_data = #{chargeData},</if>
|
||||
<if test="dischargeData != null">discharge_data = #{dischargeData},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsDailyChargeDataById" parameterType="Long">
|
||||
delete from ems_daily_charge_data where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsDailyChargeDataByIds" parameterType="String">
|
||||
delete from ems_daily_charge_data where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertOrUpdateData" parameterType="EmsDailyChargeData">
|
||||
INSERT into ems_daily_charge_data (
|
||||
id,
|
||||
site_id,
|
||||
device_id,
|
||||
date_time,
|
||||
total_charge_Data,
|
||||
total_discharge_Data,
|
||||
charge_data,
|
||||
discharge_data,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark
|
||||
) values (
|
||||
#{id},
|
||||
#{siteId},
|
||||
#{deviceId},
|
||||
#{dateTime},
|
||||
#{totalChargeData},
|
||||
#{totalDischargeData},
|
||||
#{chargeData},
|
||||
#{dischargeData},
|
||||
#{createBy},
|
||||
#{createTime},
|
||||
#{updateBy},
|
||||
#{updateTime},
|
||||
#{remark}
|
||||
)
|
||||
on duplicate key update
|
||||
total_charge_Data = #{totalChargeData},
|
||||
total_discharge_Data = #{totalDischargeData},
|
||||
charge_data = #{chargeData},
|
||||
discharge_data = #{dischargeData},
|
||||
update_time = NOW()
|
||||
</insert>
|
||||
|
||||
<select id="getAllSiteChargeData" resultType="map">
|
||||
SELECT
|
||||
SUM(t.total_charge_data) AS totalChargedCap,
|
||||
SUM(t.total_discharge_data) AS totalDischargedCap
|
||||
FROM ems_daily_charge_data t
|
||||
LEFT JOIN ems_site_setting ss ON t.site_id = ss.site_id
|
||||
INNER JOIN (
|
||||
SELECT site_id,MAX(date_time) AS latest_date FROM ems_daily_charge_data
|
||||
WHERE date_time <= #{nowData}
|
||||
<if test="siteId != null">
|
||||
and site_id = #{siteId}
|
||||
</if>
|
||||
AND total_charge_data IS NOT NULL
|
||||
AND total_discharge_data IS NOT NULL
|
||||
GROUP BY site_id
|
||||
) AS latest ON t.date_time = latest.latest_date
|
||||
and t.site_id = latest.site_id
|
||||
<if test="siteId != null">
|
||||
where t.site_id = #{siteId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getSingleSiteChargeData" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT SUM(t.charge_data) AS chargedCap,
|
||||
SUM(t.discharge_data) AS disChargedCap,
|
||||
t.date_time AS ammeterDate
|
||||
FROM ems_daily_charge_data t
|
||||
WHERE t.site_id = #{siteId}
|
||||
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
||||
group by ammeterDate
|
||||
order by ammeterDate
|
||||
</select>
|
||||
|
||||
<select id="getTotalChargeDataByDay" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT t.date_time AS ammeterDate,
|
||||
SUM(t.charge_data) as chargedCap,
|
||||
SUM(t.discharge_data) as disChargedCap
|
||||
FROM ems_daily_charge_data t
|
||||
WHERE t.site_id = #{siteId}
|
||||
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
||||
group BY ammeterDate
|
||||
order by ammeterDate
|
||||
</select>
|
||||
|
||||
<select id="getTotalChargeDataByMonth" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
SELECT
|
||||
DATE_FORMAT(t.date_time, '%Y-%m') AS ammeterMonth,
|
||||
SUM(t.charge_data) AS chargedCap,
|
||||
SUM(t.discharge_data) AS disChargedCap
|
||||
FROM ems_daily_charge_data t
|
||||
WHERE t.site_id = #{siteId}
|
||||
AND t.date_time BETWEEN #{startDate} AND #{endDate}
|
||||
GROUP BY ammeterMonth
|
||||
ORDER BY ammeterMonth
|
||||
</select>
|
||||
|
||||
<select id="getAllSiteChargeDataByMonth" resultType="com.xzzn.ems.domain.vo.ElectricIndexList">
|
||||
SELECT
|
||||
DATE_FORMAT(t.date_time, '%Y-%m') AS dateMonth,
|
||||
SUM(t.charge_data) AS chargeEnergy,
|
||||
SUM(t.discharge_data) AS disChargeEnergy
|
||||
FROM ems_daily_charge_data t
|
||||
GROUP BY dateMonth
|
||||
ORDER BY dateMonth
|
||||
</select>
|
||||
</mapper>
|
||||
@ -182,15 +182,10 @@
|
||||
</select>
|
||||
|
||||
<select id="getDeviceInfosBySiteIdAndCategory" resultType="java.util.Map">
|
||||
select DISTINCT t1.device_id as id,
|
||||
t1.device_name as deviceName,
|
||||
t1.communication_status as communicationStatus,
|
||||
t1.parent_id as parentDeviceId,
|
||||
t2.device_name as parentDeviceName
|
||||
from ems_devices_setting t1
|
||||
LEFT JOIN ems_devices_setting t2
|
||||
ON t1.parent_id = t2.device_id and t1.site_id = t2.site_id
|
||||
where t1.site_id = #{siteId} and t1.device_category = #{deviceCategory}
|
||||
select DISTINCT device_id as id,
|
||||
device_name as deviceName,
|
||||
communication_status as communicationStatus
|
||||
from ems_devices_setting where site_id = #{siteId} and device_category = #{deviceCategory}
|
||||
</select>
|
||||
|
||||
<select id="getDeviceBySiteAndDeviceId" parameterType="String" resultMap="EmsDevicesSettingResult">
|
||||
@ -200,23 +195,7 @@
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getAmmeterNameList" parameterType="String" resultType="java.util.Map">
|
||||
select distinct device_id as id,device_name as deviceName from ems_devices_setting where site_id = #{siteId} and device_category = 'AMMETER'
|
||||
</select>
|
||||
|
||||
<select id="getClusterIdsByFuzzyQuery" resultType="java.util.Map">
|
||||
select DISTINCT device_id as id,
|
||||
device_name as deviceName,
|
||||
communication_status as communicationStatus
|
||||
from ems_devices_setting
|
||||
where site_id = #{siteId}
|
||||
<if test="parentId !=null and parentId !=''">
|
||||
and parent_id = #{parentId}
|
||||
</if>
|
||||
and device_category = #{deviceCategory}
|
||||
</select>
|
||||
|
||||
<select id="getDeviceIdsBySiteIdAndCategory" resultType="java.lang.String">
|
||||
select DISTINCT device_id from ems_devices_setting where site_id = #{siteId} and device_category = #{deviceCategory}
|
||||
<select id="getLoadNameList" parameterType="String" resultType="java.util.Map">
|
||||
select distinct device_id as id,device_name as deviceName from ems_devices_setting where site_id = #{siteId} and device_id like '%LOAD%'
|
||||
</select>
|
||||
</mapper>
|
||||
@ -306,15 +306,16 @@
|
||||
from ems_pcs_data t
|
||||
inner join( SELECT p.site_id, p.device_id, p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time
|
||||
FROM ems_pcs_data p
|
||||
<include refid="commonFilter"/>
|
||||
where p.site_id = #{siteId}
|
||||
and p.data_update_time >= CURDATE() - INTERVAL #{limitTime} DAY
|
||||
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
|
||||
) latest ON t.site_id = latest.site_id
|
||||
AND t.device_id = latest.device_id
|
||||
AND t.date_month = latest.date_month
|
||||
AND t.date_day = latest.date_day
|
||||
AND t.data_update_time = latest.max_update_time
|
||||
group by ammeterDate,t.date_month,t.date_day
|
||||
order by t.date_month desc, t.date_day desc
|
||||
group by ammeterDate
|
||||
order by ammeterDate
|
||||
</select>
|
||||
|
||||
<select id="getPcsTotalChargeData" resultType="map">
|
||||
@ -348,7 +349,7 @@
|
||||
SELECT p.device_id, MAX(p.data_update_time) AS max_update_time
|
||||
FROM ems_pcs_data p
|
||||
where p.site_id = #{siteId}
|
||||
and p.data_update_time <= CURDATE()
|
||||
and p.data_update_time >= CURDATE()
|
||||
GROUP BY p.device_id
|
||||
) latest inner join ems_pcs_data t ON latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
@ -454,8 +455,8 @@
|
||||
|
||||
<select id="getPcsDataByHour" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
|
||||
select latest.dateHour as ammeterDate,
|
||||
sum(t.daily_ac_charge_energy) as chargedCap,
|
||||
sum(t.daily_ac_discharge_energy) as disChargedCap
|
||||
sum(t.total_ac_charge_energy) as chargedCap,
|
||||
sum(t.total_ac_discharge_energy) as disChargedCap
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
<include refid="commonFilter"/>
|
||||
@ -469,6 +470,7 @@
|
||||
|
||||
<sql id="statisCommonFilter">
|
||||
WHERE p.site_id = #{siteId}
|
||||
and p.device_id = #{deviceId}
|
||||
<if test="startDate != null">
|
||||
AND p.data_update_time >= #{startDate}
|
||||
</if>
|
||||
@ -499,7 +501,6 @@
|
||||
|
||||
<select id="getPcsActivePowerByDay" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PcsStatisListVo">
|
||||
select latest.dateDay as statisDate,
|
||||
t.device_id as deviceId,
|
||||
<include refid="dataTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE(p.data_update_time ) AS dateDay,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
@ -513,7 +514,6 @@
|
||||
|
||||
<select id="getPcsActivePowerByMonth" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PcsStatisListVo">
|
||||
select DATE_FORMAT(latest.max_update_time, '%Y-%m') as statisDate,
|
||||
t.device_id as deviceId,
|
||||
<include refid="dataTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,p.date_month,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
@ -528,7 +528,6 @@
|
||||
|
||||
<select id="getPcsActivePowerByHour" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PcsStatisListVo">
|
||||
select latest.dateHour as statisDate,
|
||||
t.device_id as deviceId,
|
||||
<include refid="dataTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
@ -539,4 +538,64 @@
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
order by statisDate desc
|
||||
</select>
|
||||
|
||||
<sql id="powerTypeChooseFilter">
|
||||
<choose>
|
||||
<when test='dataType == "1"'>
|
||||
t.total_apparent_power as gridPower
|
||||
</when>
|
||||
<when test='dataType == "2"'>
|
||||
t.total_active_power as loadPower
|
||||
</when>
|
||||
<when test='dataType == "3"'>
|
||||
t.max_discharge_power_capacity as storagePower
|
||||
</when>
|
||||
<when test='dataType == "4"'>
|
||||
t.ac_capacitive_reactive_power as pvPower
|
||||
</when>
|
||||
<otherwise>
|
||||
0 as gridPower
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<select id="getPowerDataByHour" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PowerStatisListVo">
|
||||
select latest.dateHour as statisDate,
|
||||
<include refid="powerTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
<include refid="statisCommonFilter"/>
|
||||
GROUP BY p.site_id,p.device_id,dateHour
|
||||
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
order by statisDate desc
|
||||
</select>
|
||||
|
||||
<select id="getPowerDataByDay" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PowerStatisListVo">
|
||||
select latest.dateDay as statisDate,
|
||||
<include refid="powerTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id, DATE(p.data_update_time ) AS dateDay,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
<include refid="statisCommonFilter"/>
|
||||
GROUP BY p.site_id,p.device_id,dateDay
|
||||
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
order by statisDate desc
|
||||
</select>
|
||||
|
||||
<select id="getPowerDataByMonth" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.PowerStatisListVo">
|
||||
select DATE_FORMAT(latest.max_update_time, '%Y-%m') as statisDate,
|
||||
<include refid="powerTypeChooseFilter"/>
|
||||
from ( SELECT p.site_id, p.device_id,p.date_month,MAX(p.data_update_time) as max_update_time
|
||||
FROM ems_pcs_data p
|
||||
<include refid="statisCommonFilter"/>
|
||||
GROUP BY p.site_id,p.device_id,p.date_month
|
||||
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
|
||||
AND latest.device_id = t.device_id
|
||||
AND latest.max_update_time = t.data_update_time
|
||||
and latest.date_month = t.date_month
|
||||
order by statisDate desc
|
||||
</select>
|
||||
</mapper>
|
||||
@ -1,331 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xzzn.ems.mapper.EmsPointMatchMapper">
|
||||
|
||||
<resultMap type="EmsPointMatch" id="EmsPointMatchResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="pointName" column="point_name" />
|
||||
<result property="matchTable" column="match_table" />
|
||||
<result property="matchField" column="match_field" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceCategory" column="device_category" />
|
||||
<result property="dataPoint" column="data_point" />
|
||||
<result property="dataPointName" column="data_point_name" />
|
||||
<result property="dataDevice" column="data_device" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsPointMatchVo">
|
||||
select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, create_by, create_time, update_by, update_time, remark from ems_point_match
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsPointMatchList" parameterType="EmsPointMatch" resultMap="EmsPointMatchResult">
|
||||
<include refid="selectEmsPointMatchVo"/>
|
||||
<where>
|
||||
<if test="pointName != null and pointName != ''"> and point_name like concat('%', #{pointName}, '%')</if>
|
||||
<if test="matchTable != null and matchTable != ''"> and match_table = #{matchTable}</if>
|
||||
<if test="matchField != null and matchField != ''"> and match_field = #{matchField}</if>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceCategory != null and deviceCategory != ''"> and device_category = #{deviceCategory}</if>
|
||||
<if test="dataPoint != null and dataPoint != ''"> and data_point = #{dataPoint}</if>
|
||||
<if test="dataPointName != null and dataPointName != ''"> and data_point_name like concat('%', #{dataPointName}, '%')</if>
|
||||
<if test="dataDevice != null and dataDevice != ''"> and data_device = #{dataDevice}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsPointMatchById" parameterType="Long" resultMap="EmsPointMatchResult">
|
||||
<include refid="selectEmsPointMatchVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsPointMatch" parameterType="EmsPointMatch" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_point_match
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="pointName != null">point_name,</if>
|
||||
<if test="matchTable != null">match_table,</if>
|
||||
<if test="matchField != null">match_field,</if>
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceCategory != null">device_category,</if>
|
||||
<if test="dataPoint != null">data_point,</if>
|
||||
<if test="dataPointName != null">data_point_name,</if>
|
||||
<if test="dataDevice != null">data_device,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="pointName != null">#{pointName},</if>
|
||||
<if test="matchTable != null">#{matchTable},</if>
|
||||
<if test="matchField != null">#{matchField},</if>
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceCategory != null">#{deviceCategory},</if>
|
||||
<if test="dataPoint != null">#{dataPoint},</if>
|
||||
<if test="dataPointName != null">#{dataPointName},</if>
|
||||
<if test="dataDevice != null">#{dataDevice},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsPointMatch" parameterType="EmsPointMatch">
|
||||
update ems_point_match
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="pointName != null">point_name = #{pointName},</if>
|
||||
<if test="matchTable != null">match_table = #{matchTable},</if>
|
||||
<if test="matchField != null">match_field = #{matchField},</if>
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceCategory != null">device_category = #{deviceCategory},</if>
|
||||
<if test="dataPoint != null">data_point = #{dataPoint},</if>
|
||||
<if test="dataPointName != null">data_point_name = #{dataPointName},</if>
|
||||
<if test="dataDevice != null">data_device = #{dataDevice},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsPointMatchById" parameterType="Long">
|
||||
delete from ems_point_match where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsPointMatchByIds" parameterType="String">
|
||||
delete from ems_point_match where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getPointNameList" resultType="String">
|
||||
select distinct t.point_name
|
||||
from ems_point_match t
|
||||
where 1=1
|
||||
<if test="siteIds != null and siteIds.size() > 0">
|
||||
AND t.site_id IN
|
||||
<foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
|
||||
#{siteId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="deviceCategory != null and deviceCategory != ''">
|
||||
and t.device_category = #{deviceCategory}
|
||||
</if>
|
||||
<if test="pointName != null and pointName != ''">
|
||||
and t.point_name like CONCAT('%', #{pointName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getMatchInfo" resultType="com.xzzn.ems.domain.EmsPointMatch">
|
||||
select distinct t.site_id as siteId,
|
||||
t.match_table as matchTable,
|
||||
t.match_field as matchField,
|
||||
t.device_category as deviceCategory,
|
||||
t.point_name as pointName
|
||||
from ems_point_match t
|
||||
where 1=1
|
||||
<if test="siteIds != null and siteIds.size() > 0">
|
||||
AND t.site_id IN
|
||||
<foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
|
||||
#{siteId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="deviceCategory != null and deviceCategory != ''">
|
||||
and t.device_category = #{deviceCategory}
|
||||
</if>
|
||||
<if test="pointName != null and pointName != ''">
|
||||
and t.point_name = #{pointName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<sql id="commonFilter">
|
||||
<choose>
|
||||
<when test="params != null and !params.isEmpty()">
|
||||
AND ( <trim prefixOverrides="OR">
|
||||
<foreach collection="params.entrySet()" item="devices" index="siteId" separator="OR">
|
||||
( site_id = #{siteId}
|
||||
AND device_id IN
|
||||
<foreach collection="devices" item="deviceId" open="(" close=")" separator=",">
|
||||
#{deviceId}
|
||||
</foreach>
|
||||
)
|
||||
</foreach>
|
||||
</trim>
|
||||
)
|
||||
</when>
|
||||
<otherwise>
|
||||
AND site_id IN
|
||||
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
||||
#{siteId}
|
||||
</foreach>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<select id="getBatteryPointDataByMinutes" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
||||
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:00') AS valueDate,
|
||||
site_id as siteId,
|
||||
device_id as deviceId,
|
||||
cluster_device_id as parentDeviceId,
|
||||
${tableField} as pointValue
|
||||
FROM ${tableName}
|
||||
WHERE create_time >= #{startDate}
|
||||
AND create_time <= #{endDate}
|
||||
AND ${tableField} is not null
|
||||
<include refid="commonFilter"/>
|
||||
GROUP BY valueDate, site_id, device_id,cluster_device_id,pointValue
|
||||
ORDER BY site_id,device_id,cluster_device_id, valueDate ASC
|
||||
</select>
|
||||
|
||||
<select id="getBatteryPointDataByHours" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
||||
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') AS valueDate,
|
||||
t.site_id as siteId,
|
||||
t.device_id as deviceId,
|
||||
t.${tableField} as pointValue,
|
||||
t.cluster_device_id as parentDeviceId,
|
||||
t.create_time AS last_update_time
|
||||
FROM ${tableName} t
|
||||
INNER JOIN ( SELECT site_id, device_id, cluster_device_id,
|
||||
DATE_FORMAT(create_time, '%Y-%m-%d %H:00') AS hour_group,
|
||||
MAX(create_time) AS max_time
|
||||
FROM ${tableName}
|
||||
WHERE create_time >= #{startDate}
|
||||
AND create_time <= #{endDate}
|
||||
AND ${tableField} is not null
|
||||
<include refid="commonFilter"/>
|
||||
GROUP BY site_id, device_id,cluster_device_id, hour_group
|
||||
) tmp ON t.site_id = tmp.site_id
|
||||
AND t.device_id = tmp.device_id
|
||||
AND t.cluster_device_id = tmp.cluster_device_id
|
||||
AND DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') = tmp.hour_group
|
||||
AND t.create_time = tmp.max_time
|
||||
where ${tableField} is not null
|
||||
ORDER BY t.site_id, t.device_id, t.cluster_device_id, valueDate ASC
|
||||
</select>
|
||||
|
||||
<select id="getBatteryPointDataByDays" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
||||
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d') AS valueDate,
|
||||
t.site_id as siteId,
|
||||
t.device_id as deviceId,
|
||||
t.cluster_device_id as parentDeviceId,
|
||||
t.${tableField} as pointValue,
|
||||
t.create_time AS last_update_time
|
||||
FROM ${tableName} t
|
||||
INNER JOIN ( SELECT site_id, device_id, cluster_device_id,
|
||||
DATE_FORMAT(create_time, '%Y-%m-%d') AS day_group,
|
||||
MAX(create_time) AS max_time
|
||||
FROM ${tableName}
|
||||
WHERE create_time >= #{startDate}
|
||||
AND create_time <= #{endDate}
|
||||
AND ${tableField} is not null
|
||||
<include refid="commonFilter"/>
|
||||
GROUP BY site_id, device_id, cluster_device_id, day_group
|
||||
) tmp ON t.site_id = tmp.site_id
|
||||
AND t.device_id = tmp.device_id
|
||||
AND t.cluster_device_id = tmp.cluster_device_id
|
||||
AND DATE_FORMAT(t.create_time, '%Y-%m-%d') = tmp.day_group
|
||||
AND t.create_time = tmp.max_time
|
||||
WHERE t.${tableField} is not null
|
||||
ORDER BY t.site_id, t.device_id, t.cluster_device_id, valueDate ASC
|
||||
</select>
|
||||
|
||||
<select id="getCommonPointDataByMinutes" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
||||
SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:00') AS valueDate,
|
||||
site_id as siteId,
|
||||
device_id as deviceId,
|
||||
${tableField} as pointValue
|
||||
FROM ${tableName}
|
||||
WHERE create_time >= #{startDate}
|
||||
AND create_time <= #{endDate}
|
||||
AND ${tableField} is not null
|
||||
AND site_id IN
|
||||
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
||||
#{siteId}
|
||||
</foreach>
|
||||
<if test="deviceId != null and deviceId != ''">
|
||||
and device_id = #{deviceId}
|
||||
</if>
|
||||
GROUP BY valueDate, site_id, device_id,pointValue
|
||||
ORDER BY site_id,device_id, valueDate ASC
|
||||
</select>
|
||||
|
||||
<select id="getCommonPointDataByHours" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
||||
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') AS valueDate,
|
||||
t.site_id as siteId,
|
||||
t.device_id as deviceId,
|
||||
t.${tableField} as pointValue,
|
||||
t.create_time AS last_update_time
|
||||
FROM ${tableName} t
|
||||
INNER JOIN ( SELECT site_id, device_id, DATE_FORMAT(create_time, '%Y-%m-%d %H:00') AS hour_group,
|
||||
MAX(create_time) AS max_time
|
||||
FROM ${tableName}
|
||||
WHERE create_time >= #{startDate}
|
||||
AND create_time <= #{endDate}
|
||||
AND ${tableField} is not null
|
||||
AND site_id IN
|
||||
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
||||
#{siteId}
|
||||
</foreach>
|
||||
<if test="deviceId != null and deviceId != ''">
|
||||
and device_id = #{deviceId}
|
||||
</if>
|
||||
GROUP BY site_id, device_id, hour_group
|
||||
) tmp ON t.site_id = tmp.site_id
|
||||
AND t.device_id = tmp.device_id
|
||||
AND DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') = tmp.hour_group
|
||||
AND t.create_time = tmp.max_time
|
||||
where ${tableField} is not null
|
||||
ORDER BY t.site_id, t.device_id, valueDate ASC
|
||||
</select>
|
||||
|
||||
<select id="getCommonPointDataByDays" resultType="com.xzzn.ems.domain.vo.GeneralQueryDataVo">
|
||||
SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d') AS valueDate,
|
||||
t.site_id as siteId,
|
||||
t.device_id as deviceId,
|
||||
t.${tableField} as pointValue,
|
||||
t.create_time AS last_update_time
|
||||
FROM ${tableName} t
|
||||
INNER JOIN ( SELECT site_id, device_id, DATE_FORMAT(create_time, '%Y-%m-%d') AS day_group,
|
||||
MAX(create_time) AS max_time
|
||||
FROM ${tableName}
|
||||
WHERE create_time >= #{startDate}
|
||||
AND create_time <= #{endDate}
|
||||
AND ${tableField} is not null
|
||||
AND site_id IN
|
||||
<foreach collection="siteIds" item="siteId" open="(" close=")" separator=",">
|
||||
#{siteId}
|
||||
</foreach>
|
||||
<if test="deviceId != null and deviceId != ''">
|
||||
and device_id = #{deviceId}
|
||||
</if>
|
||||
GROUP BY site_id, device_id, day_group
|
||||
) tmp ON t.site_id = tmp.site_id
|
||||
AND t.device_id = tmp.device_id
|
||||
AND DATE_FORMAT(t.create_time, '%Y-%m-%d') = tmp.day_group
|
||||
AND t.create_time = tmp.max_time
|
||||
WHERE t.${tableField} is not null
|
||||
ORDER BY t.site_id, t.device_id, valueDate ASC
|
||||
</select>
|
||||
|
||||
<select id="getSingleSiteDevicePoints" resultMap="EmsPointMatchResult">
|
||||
<include refid="selectEmsPointMatchVo"/>
|
||||
where 1=1
|
||||
<if test="siteId != null and siteId != ''">
|
||||
and site_id = #{siteId}
|
||||
</if>
|
||||
<if test="deviceCategory != null and deviceCategory != ''">
|
||||
and device_category = #{deviceCategory}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@ -143,10 +143,4 @@
|
||||
<delete id="deleteTempByTempId" parameterType="String">
|
||||
delete from ems_strategy_temp where template_id = #{templateId}
|
||||
</delete>
|
||||
|
||||
<select id="getTempListBySiteIdAndStrategyId" resultMap="EmsStrategyTempResult">
|
||||
<include refid="selectEmsStrategyTempVo"/>
|
||||
where site_id = #{siteId} and strategy_id = #{strategyId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user