单体电池每日最新数据处理
This commit is contained in:
@ -0,0 +1,213 @@
|
||||
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_daily_latest
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-17
|
||||
*/
|
||||
public class EmsBatteryDataDailyLatest extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 电池堆 */
|
||||
@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;
|
||||
|
||||
/** 日期:yyyy-MM-dd */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "日期:yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date dateDay;
|
||||
|
||||
/** 数据采集时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date dataTimestamp;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
/** 簇设备id */
|
||||
@Excel(name = "簇设备id")
|
||||
private String clusterDeviceId;
|
||||
|
||||
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 setDateDay(Date dateDay)
|
||||
{
|
||||
this.dateDay = dateDay;
|
||||
}
|
||||
|
||||
public Date getDateDay()
|
||||
{
|
||||
return dateDay;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("batteryPack", getBatteryPack())
|
||||
.append("batteryCluster", getBatteryCluster())
|
||||
.append("batteryCellId", getBatteryCellId())
|
||||
.append("voltage", getVoltage())
|
||||
.append("temperature", getTemperature())
|
||||
.append("soc", getSoc())
|
||||
.append("soh", getSoh())
|
||||
.append("dateDay", getDateDay())
|
||||
.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())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataDailyLatest;
|
||||
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-07-18
|
||||
*/
|
||||
public interface EmsBatteryDailyLatestMapper
|
||||
{
|
||||
/**
|
||||
* 查询单体电池每日最新数据
|
||||
*
|
||||
* @param batteryPack 单体电池每日最新数据主键
|
||||
* @return 单体电池每日最新数据
|
||||
*/
|
||||
public EmsBatteryDataDailyLatest selectEmsBatteryDataDailyLatestByBatteryPack(String batteryPack);
|
||||
|
||||
/**
|
||||
* 查询单体电池每日最新数据列表
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 单体电池每日最新数据集合
|
||||
*/
|
||||
public List<EmsBatteryDataDailyLatest> selectEmsBatteryDataDailyLatestList(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest);
|
||||
|
||||
/**
|
||||
* 新增单体电池每日最新数据
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest);
|
||||
|
||||
/**
|
||||
* 修改单体电池每日最新数据
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest);
|
||||
|
||||
/**
|
||||
* 删除单体电池每日最新数据
|
||||
*
|
||||
* @param batteryPack 单体电池每日最新数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataDailyLatestByBatteryPack(String batteryPack);
|
||||
|
||||
/**
|
||||
* 批量删除单体电池每日最新数据
|
||||
*
|
||||
* @param batteryPacks 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataDailyLatestByBatteryPacks(String[] batteryPacks);
|
||||
|
||||
public void batchUpsert(@Param("list") List<EmsBatteryDataDailyLatest> dataList);
|
||||
|
||||
public List<BatteryDataStatsListVo> getBatteryDailyLatest(DateSearchRequest requestVo);
|
||||
}
|
||||
@ -97,10 +97,4 @@ public interface EmsBatteryDataMapper
|
||||
|
||||
int insertEmsBatteryDataList(List<EmsBatteryData> emsBatteryDataList);
|
||||
|
||||
/**
|
||||
* 获取单个单体电池数据
|
||||
* @param requestVo
|
||||
* @return
|
||||
*/
|
||||
public List<BatteryDataStatsListVo> getSingleBatteryData(DateSearchRequest requestVo);
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.xzzn.ems.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataDailyLatest;
|
||||
|
||||
/**
|
||||
* 单体电池每日最新数据Service接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-18
|
||||
*/
|
||||
public interface IEmsBatteryDailyLatestService
|
||||
{
|
||||
/**
|
||||
* 查询单体电池每日最新数据
|
||||
*
|
||||
* @param batteryPack 单体电池每日最新数据主键
|
||||
* @return 单体电池每日最新数据
|
||||
*/
|
||||
public EmsBatteryDataDailyLatest selectEmsBatteryDataDailyLatestByBatteryPack(String batteryPack);
|
||||
|
||||
/**
|
||||
* 查询单体电池每日最新数据列表
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 单体电池每日最新数据集合
|
||||
*/
|
||||
public List<EmsBatteryDataDailyLatest> selectEmsBatteryDataDailyLatestList(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest);
|
||||
|
||||
/**
|
||||
* 新增单体电池每日最新数据
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest);
|
||||
|
||||
/**
|
||||
* 修改单体电池每日最新数据
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest);
|
||||
|
||||
/**
|
||||
* 批量删除单体电池每日最新数据
|
||||
*
|
||||
* @param batteryPacks 需要删除的单体电池每日最新数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataDailyLatestByBatteryPacks(String[] batteryPacks);
|
||||
|
||||
/**
|
||||
* 删除单体电池每日最新数据信息
|
||||
*
|
||||
* @param batteryPack 单体电池每日最新数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsBatteryDataDailyLatestByBatteryPack(String batteryPack);
|
||||
|
||||
/**
|
||||
* 批量处理每日数据
|
||||
* @param dailyList
|
||||
*/
|
||||
public void batchProcessBatteryData(List<EmsBatteryDataDailyLatest> dailyList);
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xzzn.ems.mapper.EmsBatteryDailyLatestMapper;
|
||||
import com.xzzn.ems.domain.EmsBatteryDataDailyLatest;
|
||||
import com.xzzn.ems.service.IEmsBatteryDailyLatestService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 单体电池每日最新数据Service业务层处理
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-18
|
||||
*/
|
||||
@Service
|
||||
public class EmsBatteryDailyLatestServiceImpl implements IEmsBatteryDailyLatestService
|
||||
{
|
||||
@Autowired
|
||||
private EmsBatteryDailyLatestMapper emsBatteryDataDailyLatestMapper;
|
||||
|
||||
/**
|
||||
* 查询单体电池每日最新数据
|
||||
*
|
||||
* @param batteryPack 单体电池每日最新数据主键
|
||||
* @return 单体电池每日最新数据
|
||||
*/
|
||||
@Override
|
||||
public EmsBatteryDataDailyLatest selectEmsBatteryDataDailyLatestByBatteryPack(String batteryPack)
|
||||
{
|
||||
return emsBatteryDataDailyLatestMapper.selectEmsBatteryDataDailyLatestByBatteryPack(batteryPack);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单体电池每日最新数据列表
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 单体电池每日最新数据
|
||||
*/
|
||||
@Override
|
||||
public List<EmsBatteryDataDailyLatest> selectEmsBatteryDataDailyLatestList(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest)
|
||||
{
|
||||
return emsBatteryDataDailyLatestMapper.selectEmsBatteryDataDailyLatestList(emsBatteryDataDailyLatest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增单体电池每日最新数据
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest)
|
||||
{
|
||||
emsBatteryDataDailyLatest.setCreateTime(DateUtils.getNowDate());
|
||||
return emsBatteryDataDailyLatestMapper.insertEmsBatteryDataDailyLatest(emsBatteryDataDailyLatest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改单体电池每日最新数据
|
||||
*
|
||||
* @param emsBatteryDataDailyLatest 单体电池每日最新数据
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest)
|
||||
{
|
||||
emsBatteryDataDailyLatest.setUpdateTime(DateUtils.getNowDate());
|
||||
return emsBatteryDataDailyLatestMapper.updateEmsBatteryDataDailyLatest(emsBatteryDataDailyLatest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除单体电池每日最新数据
|
||||
*
|
||||
* @param batteryPacks 需要删除的单体电池每日最新数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmsBatteryDataDailyLatestByBatteryPacks(String[] batteryPacks)
|
||||
{
|
||||
return emsBatteryDataDailyLatestMapper.deleteEmsBatteryDataDailyLatestByBatteryPacks(batteryPacks);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单体电池每日最新数据信息
|
||||
*
|
||||
* @param batteryPack 单体电池每日最新数据主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmsBatteryDataDailyLatestByBatteryPack(String batteryPack)
|
||||
{
|
||||
return emsBatteryDataDailyLatestMapper.deleteEmsBatteryDataDailyLatestByBatteryPack(batteryPack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchProcessBatteryData(List<EmsBatteryDataDailyLatest> dailyList) {
|
||||
// 批量更新每日最新数据表(使用 ON DUPLICATE KEY UPDATE)
|
||||
emsBatteryDataDailyLatestMapper.batchUpsert(dailyList);
|
||||
}
|
||||
}
|
||||
@ -37,6 +37,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
private EmsDevicesSettingMapper emsDevicesSettingMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDataMapper emsBatteryDataMapper;
|
||||
@Autowired
|
||||
private EmsBatteryDailyLatestMapper emsBatteryDailyLatestMapper;
|
||||
|
||||
// 电量指标
|
||||
@Override
|
||||
@ -194,8 +196,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
BigDecimal activePower = ammeterStatisListVo.getActiveTotalKwh();
|
||||
BigDecimal reactivePower = ammeterStatisListVo.getReActiveTotalKwh();
|
||||
if ( activePower != null && reactivePower !=null
|
||||
&& activePower.compareTo(BigDecimal.ZERO) >= 0
|
||||
&& reactivePower.compareTo(BigDecimal.ZERO) >= 0){
|
||||
&& activePower.compareTo(BigDecimal.ZERO) > 0
|
||||
&& reactivePower.compareTo(BigDecimal.ZERO) > 0){
|
||||
effect = reactivePower.divide(activePower, 2, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
@ -210,7 +212,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
BigDecimal totalActive = totalVo.getActiveTotalKwh();
|
||||
BigDecimal totalReactive = totalVo.getReActiveTotalKwh();
|
||||
if ( totalActive != null && totalReactive !=null
|
||||
&& totalActive.compareTo(BigDecimal.ZERO) >= 0
|
||||
&& totalActive.compareTo(BigDecimal.ZERO) > 0
|
||||
&& totalReactive.compareTo(BigDecimal.ZERO) >= 0){
|
||||
BigDecimal totalEffect = new BigDecimal(0);
|
||||
totalEffect = totalReactive.divide(totalActive, 2, RoundingMode.HALF_UP)
|
||||
@ -290,14 +292,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
*/
|
||||
@Override
|
||||
public List<BatteryDataStatsListVo> getSingleBatteryData(DateSearchRequest requestVo) {
|
||||
List<BatteryDataStatsListVo> dataList = new ArrayList<>();
|
||||
// 默认时间-7天
|
||||
dealRequestTime(requestVo);
|
||||
|
||||
// 按天比较endDate+1
|
||||
Date endDate = requestVo.getEndDate();
|
||||
requestVo.setEndDate(DateUtils.addDays(endDate, 1));
|
||||
dataList = emsBatteryDataMapper.getSingleBatteryData(requestVo);
|
||||
return dataList;
|
||||
return emsBatteryDailyLatestMapper.getBatteryDailyLatest(requestVo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import com.xzzn.ems.mapper.*;
|
||||
import com.xzzn.ems.service.IFXXDataProcessService;
|
||||
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;
|
||||
|
||||
@ -46,6 +47,8 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
|
||||
@Autowired
|
||||
private EmsAmmeterDataMapper emsAmmeterDataMapper;;
|
||||
@Autowired
|
||||
private EmsBatteryDailyLatestServiceImpl emsBatteryDailyLatestServiceImpl;
|
||||
|
||||
@Override
|
||||
public void handleFxData(String message) {
|
||||
@ -253,6 +256,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
//单体电池
|
||||
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<>();
|
||||
//单体电池
|
||||
for (Map.Entry<String, Map<String, Object>> record : records.entrySet()) {
|
||||
String recordId = record.getKey();
|
||||
@ -277,6 +281,12 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
batteryData.setClusterDeviceId(deviceId);
|
||||
|
||||
list.add(batteryData);
|
||||
|
||||
// 每日最新数据
|
||||
EmsBatteryDataDailyLatest daily = new EmsBatteryDataDailyLatest();
|
||||
BeanUtils.copyProperties(batteryData, daily);
|
||||
daily.setDateDay(DateUtils.getNowDate());
|
||||
dailyList.add(daily);
|
||||
}
|
||||
if (list.size() > 0 ) {
|
||||
emsBatteryDataMapper.insertEmsBatteryDataList(list);
|
||||
@ -284,6 +294,15 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService {
|
||||
redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId);
|
||||
redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, list);
|
||||
}
|
||||
|
||||
// 批量处理每日最新数据
|
||||
batchProcessDailyData(dailyList);
|
||||
}
|
||||
|
||||
private void batchProcessDailyData(List<EmsBatteryDataDailyLatest> dailyList) {
|
||||
if (dailyList != null && dailyList.size() > 0) {
|
||||
emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,179 @@
|
||||
<?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.EmsBatteryDailyLatestMapper">
|
||||
|
||||
<resultMap type="EmsBatteryDataDailyLatest" id="EmsBatteryDataDailyLatestResult">
|
||||
<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="dateDay" column="date_day" />
|
||||
<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" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsBatteryDataDailyLatestVo">
|
||||
select battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, date_day, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id from ems_battery_data_daily_latest
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsBatteryDataDailyLatestList" parameterType="EmsBatteryDataDailyLatest" resultMap="EmsBatteryDataDailyLatestResult">
|
||||
<include refid="selectEmsBatteryDataDailyLatestVo"/>
|
||||
<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="dateDay != null "> and date_day = #{dateDay}</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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsBatteryDataDailyLatestByBatteryPack" parameterType="String" resultMap="EmsBatteryDataDailyLatestResult">
|
||||
<include refid="selectEmsBatteryDataDailyLatestVo"/>
|
||||
where battery_pack = #{batteryPack}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsBatteryDataDailyLatest" parameterType="EmsBatteryDataDailyLatest">
|
||||
insert into ems_battery_data_daily_latest
|
||||
<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="dateDay != null">date_day,</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>
|
||||
</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="dateDay != null">#{dateDay},</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>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsBatteryDataDailyLatest" parameterType="EmsBatteryDataDailyLatest">
|
||||
update ems_battery_data_daily_latest
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<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="dateDay != null">date_day = #{dateDay},</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>
|
||||
</trim>
|
||||
where battery_pack = #{batteryPack}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsBatteryDataDailyLatestByBatteryPack" parameterType="String">
|
||||
delete from ems_battery_data_daily_latest where battery_pack = #{batteryPack}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsBatteryDataDailyLatestByBatteryPacks" parameterType="String">
|
||||
delete from ems_battery_data_daily_latest where battery_pack in
|
||||
<foreach item="batteryPack" collection="array" open="(" separator="," close=")">
|
||||
#{batteryPack}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="batchUpsert">
|
||||
INSERT INTO ems_battery_data_daily_latest (
|
||||
battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, date_day,
|
||||
data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.batteryPack},
|
||||
#{item.batteryCluster},
|
||||
#{item.batteryCellId},
|
||||
#{item.voltage},
|
||||
#{item.temperature},
|
||||
#{item.soc},
|
||||
#{item.soh},
|
||||
#{item.dateDay},
|
||||
#{item.dataTimestamp},
|
||||
#{item.createBy},
|
||||
#{item.createTime},
|
||||
#{item.updateBy},
|
||||
#{item.updateTime},
|
||||
#{item.remark},
|
||||
#{item.siteId},
|
||||
#{item.deviceId},
|
||||
#{item.clusterDeviceId}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
voltage = VALUES(voltage),
|
||||
temperature = VALUES(temperature),
|
||||
soc = VALUES(soc),
|
||||
soh = VALUES(soh),
|
||||
data_timestamp = VALUES(data_timestamp),
|
||||
update_time = NOW(),
|
||||
remark = VALUES(remark)
|
||||
</insert>
|
||||
|
||||
<select id="getBatteryDailyLatest" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.BatteryDataStatsListVo">
|
||||
SELECT date_day as dataTimestamp,
|
||||
voltage, temperature, soc, soh,
|
||||
device_id as deviceId,
|
||||
cluster_device_id as clusterDeviceId
|
||||
FROM ems_battery_data_daily_latest
|
||||
WHERE site_id = #{siteId}
|
||||
and cluster_device_id = #{clusterDeviceId}
|
||||
and device_id = #{deviceId}
|
||||
and date_day >= #{startDate}
|
||||
and date_day <= #{endDate}
|
||||
GROUP BY dataTimestamp
|
||||
</select>
|
||||
</mapper>
|
||||
@ -214,24 +214,4 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getSingleBatteryData" parameterType="com.xzzn.ems.domain.vo.DateSearchRequest" resultType="com.xzzn.ems.domain.vo.BatteryDataStatsListVo">
|
||||
SELECT latest.dateDay as dataTimestamp,
|
||||
t.voltage,
|
||||
t.temperature,
|
||||
t.soc,
|
||||
t.soh,
|
||||
t.device_id as deviceId,
|
||||
t.cluster_device_id as clusterDeviceId
|
||||
FROM ems_battery_data t
|
||||
INNER JOIN ( SELECT site_id,cluster_device_id,device_id,DATE(data_timestamp) as dateDay,MAX(data_timestamp) AS max_update_time
|
||||
FROM ems_battery_data
|
||||
WHERE site_id = #{siteId}
|
||||
and cluster_device_id = #{clusterDeviceId}
|
||||
and device_id = #{deviceId}
|
||||
and data_timestamp >= #{startDate}
|
||||
and data_timestamp < #{endDate}
|
||||
GROUP BY site_id,cluster_device_id,device_id,dateDay
|
||||
) latest ON t.site_id = latest.site_id and t.cluster_device_id = latest.cluster_device_id
|
||||
and t.device_id = latest.device_id AND t.data_timestamp = latest.max_update_time
|
||||
</select>
|
||||
</mapper>
|
||||
@ -358,7 +358,7 @@
|
||||
AND t.date_day = max_dates.date_day
|
||||
AND t.data_update_time = max_dates.max_update_time
|
||||
GROUP BY dateMonth
|
||||
ORDER BY dateMonth;
|
||||
ORDER BY dateMonth
|
||||
</select>
|
||||
|
||||
<select id="getPcsDetailInfoBySiteId" parameterType="String" resultType="com.xzzn.ems.domain.vo.PcsDetailInfoVo">
|
||||
|
||||
Reference in New Issue
Block a user