dev #2
@ -31,9 +31,9 @@ public class EmsEnergyPriceConfigController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(String startTime,String endTime)
|
public TableDataInfo list(String siteId, String startTime,String endTime)
|
||||||
{
|
{
|
||||||
List<EnergyPriceVo> list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList(startTime,endTime);
|
List<EnergyPriceVo> list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList(siteId,startTime,endTime);
|
||||||
return getDataTable2(list);
|
return getDataTable2(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,10 @@ public class EmsEnergyPriceConfig extends BaseEntity
|
|||||||
/** */
|
/** */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/** 站点id */
|
||||||
|
@Excel(name = "站点id")
|
||||||
|
private String siteId;
|
||||||
|
|
||||||
/** 年份,如2025 */
|
/** 年份,如2025 */
|
||||||
@Excel(name = "年份,如2025")
|
@Excel(name = "年份,如2025")
|
||||||
private String year;
|
private String year;
|
||||||
@ -54,6 +58,16 @@ public class EmsEnergyPriceConfig extends BaseEntity
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSiteId(String siteId)
|
||||||
|
{
|
||||||
|
this.siteId = siteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSiteId()
|
||||||
|
{
|
||||||
|
return siteId;
|
||||||
|
}
|
||||||
|
|
||||||
public void setYear(String year)
|
public void setYear(String year)
|
||||||
{
|
{
|
||||||
this.year = year;
|
this.year = year;
|
||||||
@ -118,6 +132,7 @@ public class EmsEnergyPriceConfig extends BaseEntity
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
.append("id", getId())
|
.append("id", getId())
|
||||||
|
.append("siteId", getSiteId())
|
||||||
.append("year", getYear())
|
.append("year", getYear())
|
||||||
.append("month", getMonth())
|
.append("month", getMonth())
|
||||||
.append("peak", getPeak())
|
.append("peak", getPeak())
|
||||||
|
|||||||
@ -12,6 +12,9 @@ import java.util.List;
|
|||||||
public class EnergyPriceVo {
|
public class EnergyPriceVo {
|
||||||
/** */
|
/** */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/** 站点id */
|
||||||
|
@Excel(name = "站点id")
|
||||||
|
private String siteId;
|
||||||
/** 年份 */
|
/** 年份 */
|
||||||
@Excel(name = "年份")
|
@Excel(name = "年份")
|
||||||
private String year;
|
private String year;
|
||||||
@ -41,6 +44,14 @@ public class EnergyPriceVo {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSiteId() {
|
||||||
|
return siteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSiteId(String siteId) {
|
||||||
|
this.siteId = siteId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getYear() {
|
public String getYear() {
|
||||||
return year;
|
return year;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,11 +62,15 @@ public interface EmsEnergyPriceConfigMapper
|
|||||||
public int deleteEmsEnergyPriceConfigByIds(Long[] ids);
|
public int deleteEmsEnergyPriceConfigByIds(Long[] ids);
|
||||||
|
|
||||||
// 查询当年电价配置列表
|
// 查询当年电价配置列表
|
||||||
public List<EmsEnergyPriceConfig> getCurrentYearConfigList(int currentYear);
|
public List<EmsEnergyPriceConfig> getCurrentYearConfigList(@Param("siteId")String siteId,@Param("currentYear")int currentYear);
|
||||||
// 根据指定年月获取电价配置
|
// 站点指定年月获取电价配置
|
||||||
public EmsEnergyPriceConfig getConfigListByYearAndMonth(@Param("currentYear") String currentYear, @Param("month")String month);
|
public EmsEnergyPriceConfig getConfigListByYearAndMonth(@Param("siteId")String siteId,
|
||||||
|
@Param("currentYear") String currentYear,
|
||||||
|
@Param("month")String month);
|
||||||
// 插入或更新
|
// 插入或更新
|
||||||
public void insertOrUpdateEmsEnergyPriceConfig(EmsEnergyPriceConfig priceConfig);
|
public void insertOrUpdateEmsEnergyPriceConfig(EmsEnergyPriceConfig priceConfig);
|
||||||
// 获取指定年月的电价时间配置
|
// 获取指定年月的电价时间配置
|
||||||
public List<EnergyPriceTimeRange> getTimeRangeByDate(@Param("currentYear")int currentYear, @Param("currentMonth")int currentMonth);
|
public List<EnergyPriceTimeRange> getTimeRangeByDate(@Param("siteId")String siteId,
|
||||||
|
@Param("currentYear")int currentYear,
|
||||||
|
@Param("currentMonth")int currentMonth);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,4 +90,6 @@ public interface EmsSiteSettingMapper
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<SiteDeviceListVo> getAllSiteDeviceList(String siteId);
|
public List<SiteDeviceListVo> getAllSiteDeviceList(String siteId);
|
||||||
|
|
||||||
|
public List<String> getAllSiteId();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public interface IEmsEnergyPriceConfigService
|
|||||||
*
|
*
|
||||||
* @return 电价配置集合
|
* @return 电价配置集合
|
||||||
*/
|
*/
|
||||||
public List<EnergyPriceVo> selectEmsEnergyPriceConfigList(String startTime,String endTime);
|
public List<EnergyPriceVo> selectEmsEnergyPriceConfigList(String siteId, String startTime,String endTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增电价配置-按月
|
* 新增电价配置-按月
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
package com.xzzn.ems.service.impl;
|
package com.xzzn.ems.service.impl;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -15,6 +13,7 @@ import com.xzzn.ems.domain.EmsPriceTimeConfig;
|
|||||||
import com.xzzn.ems.domain.vo.EnergyPriceTimeRange;
|
import com.xzzn.ems.domain.vo.EnergyPriceTimeRange;
|
||||||
import com.xzzn.ems.domain.vo.EnergyPriceVo;
|
import com.xzzn.ems.domain.vo.EnergyPriceVo;
|
||||||
import com.xzzn.ems.mapper.EmsPriceTimeConfigMapper;
|
import com.xzzn.ems.mapper.EmsPriceTimeConfigMapper;
|
||||||
|
import com.xzzn.ems.mapper.EmsSiteSettingMapper;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -37,6 +36,8 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
|||||||
private EmsPriceTimeConfigMapper emsPriceTimeConfigMapper;
|
private EmsPriceTimeConfigMapper emsPriceTimeConfigMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
@Autowired
|
||||||
|
private EmsSiteSettingMapper emsSiteSettingMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询电价配置
|
* 查询电价配置
|
||||||
@ -68,14 +69,14 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
|||||||
* @return 电价配置
|
* @return 电价配置
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<EnergyPriceVo> selectEmsEnergyPriceConfigList(String startTime,String endTime)
|
public List<EnergyPriceVo> selectEmsEnergyPriceConfigList(String siteId,String startTime,String endTime)
|
||||||
{
|
{
|
||||||
List<EnergyPriceVo> responses = new ArrayList<>();
|
List<EnergyPriceVo> responses = new ArrayList<>();
|
||||||
// 根据时间截取年份
|
// 根据时间截取年份
|
||||||
String[] startTimeArr = startTime.split("-");
|
String[] startTimeArr = startTime.split("-");
|
||||||
int currentYear = Integer.valueOf(startTimeArr[0]);
|
int currentYear = Integer.valueOf(startTimeArr[0]);
|
||||||
|
|
||||||
List<EmsEnergyPriceConfig> priceConfigs = emsEnergyPriceConfigMapper.getCurrentYearConfigList(currentYear);
|
List<EmsEnergyPriceConfig> priceConfigs = emsEnergyPriceConfigMapper.getCurrentYearConfigList(siteId,currentYear);
|
||||||
|
|
||||||
if (priceConfigs != null && priceConfigs.size() > 0) {
|
if (priceConfigs != null && priceConfigs.size() > 0) {
|
||||||
for (EmsEnergyPriceConfig priceConfig : priceConfigs) {
|
for (EmsEnergyPriceConfig priceConfig : priceConfigs) {
|
||||||
@ -106,14 +107,14 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
|||||||
{
|
{
|
||||||
String year = priceVo.getYear();
|
String year = priceVo.getYear();
|
||||||
String month = priceVo.getMonth();
|
String month = priceVo.getMonth();
|
||||||
|
String siteId = priceVo.getSiteId();
|
||||||
// 判断入参
|
// 判断入参
|
||||||
if(StringUtils.isEmpty(year) || StringUtils.isEmpty(month)){
|
if(StringUtils.isEmpty(siteId) || StringUtils.isEmpty(year) || StringUtils.isEmpty(month)){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验当前月电价设置是否已存在,不存在则新增,存在则更新
|
// 校验当前月电价设置是否已存在,不存在则新增,存在则更新
|
||||||
EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(year,month);
|
EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId,year,month);
|
||||||
if (priceConfig != null){
|
if (priceConfig != null){
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -214,9 +215,15 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer
|
|||||||
int currentMonth = LocalDate.now().getMonthValue();
|
int currentMonth = LocalDate.now().getMonthValue();
|
||||||
int currentYear = LocalDate.now().getYear();
|
int currentYear = LocalDate.now().getYear();
|
||||||
|
|
||||||
List<EnergyPriceTimeRange> timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(currentYear,currentMonth);
|
List<String> siteIds = emsSiteSettingMapper.getAllSiteId();
|
||||||
|
if (siteIds == null || siteIds.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String siteId : siteIds) {
|
||||||
|
List<EnergyPriceTimeRange> timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(siteId,currentYear,currentMonth);
|
||||||
|
String key = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + currentYear + currentMonth;
|
||||||
|
redisCache.setCacheObject(key,timeRanges, 31, TimeUnit.DAYS);
|
||||||
|
}
|
||||||
|
|
||||||
String key = RedisKeyConstants.ENERGY_PRICE_TIME + currentYear + currentMonth;
|
|
||||||
redisCache.setCacheObject(key,timeRanges, 31, TimeUnit.DAYS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<resultMap type="EmsEnergyPriceConfig" id="EmsEnergyPriceConfigResult">
|
<resultMap type="EmsEnergyPriceConfig" id="EmsEnergyPriceConfigResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
|
<result property="siteId" column="site_id" />
|
||||||
<result property="year" column="year" />
|
<result property="year" column="year" />
|
||||||
<result property="month" column="month" />
|
<result property="month" column="month" />
|
||||||
<result property="peak" column="peak" />
|
<result property="peak" column="peak" />
|
||||||
@ -20,19 +21,19 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectEmsEnergyPriceConfigVo">
|
<sql id="selectEmsEnergyPriceConfigVo">
|
||||||
select id, year, month, peak, high, flat, valley, create_by, create_time, update_by, update_time, remark from ems_energy_price_config
|
select id, site_id, year, month, peak, high, flat, valley, create_by, create_time, update_by, update_time, remark from ems_energy_price_config
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectEmsEnergyPriceConfigList" parameterType="EmsEnergyPriceConfig" resultMap="EmsEnergyPriceConfigResult">
|
<select id="selectEmsEnergyPriceConfigList" parameterType="EmsEnergyPriceConfig" resultMap="EmsEnergyPriceConfigResult">
|
||||||
<include refid="selectEmsEnergyPriceConfigVo"/>
|
<include refid="selectEmsEnergyPriceConfigVo"/>
|
||||||
<where>
|
<where>
|
||||||
|
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||||
<if test="year != null and year != ''"> and year = #{year}</if>
|
<if test="year != null and year != ''"> and year = #{year}</if>
|
||||||
<if test="month != null and month != ''"> and month = #{month}</if>
|
<if test="month != null and month != ''"> and month = #{month}</if>
|
||||||
<if test="peak != null "> and peak = #{peak}</if>
|
<if test="peak != null "> and peak = #{peak}</if>
|
||||||
<if test="high != null "> and high = #{high}</if>
|
<if test="high != null "> and high = #{high}</if>
|
||||||
<if test="flat != null "> and flat = #{flat}</if>
|
<if test="flat != null "> and flat = #{flat}</if>
|
||||||
<if test="valley != null "> and valley = #{valley}</if>
|
<if test="valley != null "> and valley = #{valley}</if>
|
||||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -44,6 +45,7 @@
|
|||||||
<insert id="insertEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into ems_energy_price_config
|
insert into ems_energy_price_config
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="siteId != null">site_id,</if>
|
||||||
<if test="year != null and year != ''">year,</if>
|
<if test="year != null and year != ''">year,</if>
|
||||||
<if test="month != null and month != ''">month,</if>
|
<if test="month != null and month != ''">month,</if>
|
||||||
<if test="peak != null">peak,</if>
|
<if test="peak != null">peak,</if>
|
||||||
@ -57,6 +59,7 @@
|
|||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="siteId != null">#{siteId},</if>
|
||||||
<if test="year != null and year != ''">#{year},</if>
|
<if test="year != null and year != ''">#{year},</if>
|
||||||
<if test="month != null and month != ''">#{month},</if>
|
<if test="month != null and month != ''">#{month},</if>
|
||||||
<if test="peak != null">#{peak},</if>
|
<if test="peak != null">#{peak},</if>
|
||||||
@ -74,6 +77,7 @@
|
|||||||
<update id="updateEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig">
|
<update id="updateEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig">
|
||||||
update ems_energy_price_config
|
update ems_energy_price_config
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="siteId != null">site_id = #{siteId},</if>
|
||||||
<if test="year != null and year != ''">year = #{year},</if>
|
<if test="year != null and year != ''">year = #{year},</if>
|
||||||
<if test="month != null and month != ''">month = #{month},</if>
|
<if test="month != null and month != ''">month = #{month},</if>
|
||||||
<if test="peak != null">peak = #{peak},</if>
|
<if test="peak != null">peak = #{peak},</if>
|
||||||
@ -104,6 +108,9 @@
|
|||||||
<include refid="selectEmsEnergyPriceConfigVo"/>
|
<include refid="selectEmsEnergyPriceConfigVo"/>
|
||||||
<where>
|
<where>
|
||||||
year = #{currentYear}
|
year = #{currentYear}
|
||||||
|
<if test="siteId != null and siteId != ''">
|
||||||
|
and site_id = #{siteId}
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -111,6 +118,7 @@
|
|||||||
useGeneratedKeys="true" keyProperty="id">
|
useGeneratedKeys="true" keyProperty="id">
|
||||||
INSERT INTO ems_energy_price_config (
|
INSERT INTO ems_energy_price_config (
|
||||||
id,
|
id,
|
||||||
|
site_id,
|
||||||
year,
|
year,
|
||||||
month,
|
month,
|
||||||
peak,
|
peak,
|
||||||
@ -124,6 +132,7 @@
|
|||||||
remark
|
remark
|
||||||
) VALUES (
|
) VALUES (
|
||||||
#{id},
|
#{id},
|
||||||
|
#{siteId},
|
||||||
#{year},
|
#{year},
|
||||||
#{month},
|
#{month},
|
||||||
#{peak},
|
#{peak},
|
||||||
@ -145,7 +154,8 @@
|
|||||||
|
|
||||||
<select id="getConfigListByYearAndMonth" resultMap="EmsEnergyPriceConfigResult">
|
<select id="getConfigListByYearAndMonth" resultMap="EmsEnergyPriceConfigResult">
|
||||||
<include refid="selectEmsEnergyPriceConfigVo"/>
|
<include refid="selectEmsEnergyPriceConfigVo"/>
|
||||||
where year = #{currentYear}
|
where site_id = #{siteId}
|
||||||
|
and year = #{currentYear}
|
||||||
and month = #{month}
|
and month = #{month}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -155,7 +165,8 @@
|
|||||||
t2.end_time as endTime
|
t2.end_time as endTime
|
||||||
from ems_energy_price_config t
|
from ems_energy_price_config t
|
||||||
left join ems_price_time_config t2 on t.id = t2.price_id
|
left join ems_price_time_config t2 on t.id = t2.price_id
|
||||||
where t.`year` = #{currentYear}
|
where t.site_id = #{siteId}
|
||||||
|
and t.`year` = #{currentYear}
|
||||||
and t.`month` = #{currentMonth}
|
and t.`month` = #{currentMonth}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -147,4 +147,8 @@
|
|||||||
and es.site_id = #{siteId}
|
and es.site_id = #{siteId}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getAllSiteId" resultType="String">
|
||||||
|
select distinct site_id from ems_site_setting
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user