电价配置
This commit is contained in:
@ -0,0 +1,134 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
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_energy_price_config
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-10-09
|
||||
*/
|
||||
public class EmsEnergyPriceConfig extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** */
|
||||
private Long id;
|
||||
|
||||
/** 年份,如2025 */
|
||||
@Excel(name = "年份,如2025")
|
||||
private String year;
|
||||
|
||||
/** 月份,如"9"表示9月 */
|
||||
@Excel(name = "月份,如\"9\"表示9月")
|
||||
private String month;
|
||||
|
||||
/** 尖-peak电价(元/kWh) */
|
||||
@Excel(name = "尖-peak电价(元/kWh)")
|
||||
private BigDecimal peak;
|
||||
|
||||
/** 峰-high电价(元/kWh) */
|
||||
@Excel(name = "峰-high电价(元/kWh)")
|
||||
private BigDecimal high;
|
||||
|
||||
/** 平-flat电价(元/kWh) */
|
||||
@Excel(name = "平-flat电价(元/kWh)")
|
||||
private BigDecimal flat;
|
||||
|
||||
/** 谷-valley电价(元/kWh) */
|
||||
@Excel(name = "谷-valley电价(元/kWh)")
|
||||
private BigDecimal valley;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setYear(String year)
|
||||
{
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public String getYear()
|
||||
{
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setMonth(String month)
|
||||
{
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public String getMonth()
|
||||
{
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setPeak(BigDecimal peak)
|
||||
{
|
||||
this.peak = peak;
|
||||
}
|
||||
|
||||
public BigDecimal getPeak()
|
||||
{
|
||||
return peak;
|
||||
}
|
||||
|
||||
public void setHigh(BigDecimal high)
|
||||
{
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
public BigDecimal getHigh()
|
||||
{
|
||||
return high;
|
||||
}
|
||||
|
||||
public void setFlat(BigDecimal flat)
|
||||
{
|
||||
this.flat = flat;
|
||||
}
|
||||
|
||||
public BigDecimal getFlat()
|
||||
{
|
||||
return flat;
|
||||
}
|
||||
|
||||
public void setValley(BigDecimal valley)
|
||||
{
|
||||
this.valley = valley;
|
||||
}
|
||||
|
||||
public BigDecimal getValley()
|
||||
{
|
||||
return valley;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("year", getYear())
|
||||
.append("month", getMonth())
|
||||
.append("peak", getPeak())
|
||||
.append("high", getHigh())
|
||||
.append("flat", getFlat())
|
||||
.append("valley", getValley())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
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_price_time_config
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-10-09
|
||||
*/
|
||||
public class EmsPriceTimeConfig extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** */
|
||||
private Long id;
|
||||
|
||||
/** 时段开始时间 */
|
||||
@Excel(name = "时段开始时间")
|
||||
private String startTime;
|
||||
|
||||
/** 时段结束时间 */
|
||||
@Excel(name = "时段结束时间")
|
||||
private String endTime;
|
||||
|
||||
/** 电价类型: 尖-peak,峰-high,平-flat,谷-valley */
|
||||
@Excel(name = "电价类型: 尖-peak,峰-high,平-flat,谷-valley")
|
||||
private String costType;
|
||||
|
||||
/** 电价配置id */
|
||||
@Excel(name = "电价配置id")
|
||||
private Long priceId;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime)
|
||||
{
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getEndTime()
|
||||
{
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setCostType(String costType)
|
||||
{
|
||||
this.costType = costType;
|
||||
}
|
||||
|
||||
public String getCostType()
|
||||
{
|
||||
return costType;
|
||||
}
|
||||
|
||||
public void setPriceId(Long priceId)
|
||||
{
|
||||
this.priceId = priceId;
|
||||
}
|
||||
|
||||
public Long getPriceId()
|
||||
{
|
||||
return priceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("startTime", getStartTime())
|
||||
.append("endTime", getEndTime())
|
||||
.append("costType", getCostType())
|
||||
.append("priceId", getPriceId())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 电价配置-电价列表-电价范围
|
||||
*
|
||||
*/
|
||||
public class EnergyPriceTimeRange {
|
||||
/** 时段开始时间 */
|
||||
@Excel(name = "时段开始时间")
|
||||
private String startTime;
|
||||
|
||||
/** 时段结束时间 */
|
||||
@Excel(name = "时段结束时间")
|
||||
private String endTime;
|
||||
|
||||
/** 电价类型: 尖-peak,峰-high,平-flat,谷=valley */
|
||||
@Excel(name = "电价类型: 尖-peak,峰-high,平-flat,谷=valley")
|
||||
private String costType;
|
||||
|
||||
public String getCostType() {
|
||||
return costType;
|
||||
}
|
||||
|
||||
public void setCostType(String costType) {
|
||||
this.costType = costType;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 电价配置-电价列表-对象
|
||||
*
|
||||
*/
|
||||
public class EnergyPriceVo {
|
||||
/** */
|
||||
private Long id;
|
||||
/** 年份 */
|
||||
@Excel(name = "年份")
|
||||
private String year;
|
||||
/** 月份,如"9"表示9月 */
|
||||
@Excel(name = "月份,如\"9\"表示9月")
|
||||
private String month;
|
||||
/** 尖电价(元/kWh) */
|
||||
@Excel(name = "尖电价(元/kWh)")
|
||||
private BigDecimal peak;
|
||||
/** 峰电价(元/kWh) */
|
||||
@Excel(name = "峰电价(元/kWh)")
|
||||
private BigDecimal high;
|
||||
/** 平电价(元/kWh) */
|
||||
@Excel(name = "平电价(元/kWh)")
|
||||
private BigDecimal flat;
|
||||
/** 谷电价(元/kWh) */
|
||||
@Excel(name = "谷电价(元/kWh)")
|
||||
private BigDecimal valley;
|
||||
/** 电价时间范围对象 */
|
||||
private List<EnergyPriceTimeRange> range;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(String year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public String getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(String month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public BigDecimal getPeak() {
|
||||
return peak;
|
||||
}
|
||||
|
||||
public void setPeak(BigDecimal peak) {
|
||||
this.peak = peak;
|
||||
}
|
||||
|
||||
public BigDecimal getHigh() {
|
||||
return high;
|
||||
}
|
||||
|
||||
public void setHigh(BigDecimal high) {
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
public BigDecimal getFlat() {
|
||||
return flat;
|
||||
}
|
||||
|
||||
public void setFlat(BigDecimal flat) {
|
||||
this.flat = flat;
|
||||
}
|
||||
|
||||
public BigDecimal getValley() {
|
||||
return valley;
|
||||
}
|
||||
|
||||
public void setValley(BigDecimal valley) {
|
||||
this.valley = valley;
|
||||
}
|
||||
|
||||
public List<EnergyPriceTimeRange> getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public void setRange(List<EnergyPriceTimeRange> range) {
|
||||
this.range = range;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xzzn.ems.domain.EmsEnergyPriceConfig;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 电价配置Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-09-28
|
||||
*/
|
||||
public interface EmsEnergyPriceConfigMapper
|
||||
{
|
||||
/**
|
||||
* 查询电价配置
|
||||
*
|
||||
* @param id 电价配置主键
|
||||
* @return 电价配置
|
||||
*/
|
||||
public EmsEnergyPriceConfig selectEmsEnergyPriceConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询当年电价配置列表
|
||||
*
|
||||
* @return 电价配置集合
|
||||
*/
|
||||
public List<EmsEnergyPriceConfig> selectEmsEnergyPriceConfigList(int currentYear);
|
||||
|
||||
/**
|
||||
* 新增电价配置
|
||||
*
|
||||
* @param emsEnergyPriceConfig 电价配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsEnergyPriceConfig(EmsEnergyPriceConfig emsEnergyPriceConfig);
|
||||
|
||||
/**
|
||||
* 修改电价配置
|
||||
*
|
||||
* @param emsEnergyPriceConfig 电价配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsEnergyPriceConfig(EmsEnergyPriceConfig emsEnergyPriceConfig);
|
||||
|
||||
/**
|
||||
* 删除电价配置
|
||||
*
|
||||
* @param id 电价配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsEnergyPriceConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除电价配置
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsEnergyPriceConfigByIds(Long[] ids);
|
||||
|
||||
// 查询当年电价配置列表
|
||||
public List<EmsEnergyPriceConfig> getCurrentYearConfigList(int currentYear);
|
||||
// 根据指定年月获取电价配置
|
||||
public EmsEnergyPriceConfig getConfigListByYearAndMonth(@Param("currentYear") String currentYear, @Param("month")String month);
|
||||
// 插入或更新
|
||||
public void insertOrUpdateEmsEnergyPriceConfig(EmsEnergyPriceConfig priceConfig);
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsPriceTimeConfig;
|
||||
import com.xzzn.ems.domain.vo.EnergyPriceTimeRange;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 电价时间配置Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-10-09
|
||||
*/
|
||||
public interface EmsPriceTimeConfigMapper
|
||||
{
|
||||
/**
|
||||
* 查询电价时间配置
|
||||
*
|
||||
* @param id 电价时间配置主键
|
||||
* @return 电价时间配置
|
||||
*/
|
||||
public EmsPriceTimeConfig selectEmsPriceTimeConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询电价时间配置列表
|
||||
*
|
||||
* @param emsPriceTimeConfig 电价时间配置
|
||||
* @return 电价时间配置集合
|
||||
*/
|
||||
public List<EmsPriceTimeConfig> selectEmsPriceTimeConfigList(EmsPriceTimeConfig emsPriceTimeConfig);
|
||||
|
||||
/**
|
||||
* 新增电价时间配置
|
||||
*
|
||||
* @param emsPriceTimeConfig 电价时间配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsPriceTimeConfig(EmsPriceTimeConfig emsPriceTimeConfig);
|
||||
|
||||
/**
|
||||
* 修改电价时间配置
|
||||
*
|
||||
* @param emsPriceTimeConfig 电价时间配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsPriceTimeConfig(EmsPriceTimeConfig emsPriceTimeConfig);
|
||||
|
||||
/**
|
||||
* 删除电价时间配置
|
||||
*
|
||||
* @param id 电价时间配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsPriceTimeConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除电价时间配置
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsPriceTimeConfigByIds(Long[] ids);
|
||||
|
||||
// 获取年月的电价时间范围
|
||||
public List<EnergyPriceTimeRange> getTimeRangeByPriceId(Long priceId);
|
||||
// 批量插入
|
||||
public int batchInsert(List<EmsPriceTimeConfig> timeConfigs);
|
||||
// 删除priceId对应的时间范围配置
|
||||
public void deleteTimeRangeByPriceId(Long[] priceIds);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.xzzn.ems.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsEnergyPriceConfig;
|
||||
import com.xzzn.ems.domain.vo.EnergyPriceVo;
|
||||
|
||||
/**
|
||||
* 电价配置Service接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-09-28
|
||||
*/
|
||||
public interface IEmsEnergyPriceConfigService
|
||||
{
|
||||
/**
|
||||
* 查询电价配置
|
||||
*
|
||||
* @param id 电价配置主键
|
||||
* @return 电价配置
|
||||
*/
|
||||
public EnergyPriceVo selectEmsEnergyPriceConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询电价配置列表
|
||||
*
|
||||
* @return 电价配置集合
|
||||
*/
|
||||
public List<EnergyPriceVo> selectEmsEnergyPriceConfigList();
|
||||
|
||||
/**
|
||||
* 新增电价配置-按月
|
||||
*
|
||||
* @param priceVo 电价配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsEnergyPriceConfig(EnergyPriceVo priceVo);
|
||||
|
||||
/**
|
||||
* 修改电价配置
|
||||
*
|
||||
* @param priceVo 电价配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsEnergyPriceConfig(EnergyPriceVo priceVo);
|
||||
|
||||
/**
|
||||
* 批量删除电价配置
|
||||
*
|
||||
* @param ids 需要删除的电价配置主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsEnergyPriceConfigByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除电价配置信息
|
||||
*
|
||||
* @param id 电价配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsEnergyPriceConfigById(Long id);
|
||||
}
|
||||
@ -0,0 +1,198 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.EmsPriceTimeConfig;
|
||||
import com.xzzn.ems.domain.vo.EnergyPriceTimeRange;
|
||||
import com.xzzn.ems.domain.vo.EnergyPriceVo;
|
||||
import com.xzzn.ems.mapper.EmsPriceTimeConfigMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper;
|
||||
import com.xzzn.ems.domain.EmsEnergyPriceConfig;
|
||||
import com.xzzn.ems.service.IEmsEnergyPriceConfigService;
|
||||
|
||||
/**
|
||||
* 电价配置Service业务层处理
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-09-28
|
||||
*/
|
||||
@Service
|
||||
public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigService
|
||||
{
|
||||
@Autowired
|
||||
private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper;
|
||||
@Autowired
|
||||
private EmsPriceTimeConfigMapper emsPriceTimeConfigMapper;
|
||||
|
||||
/**
|
||||
* 查询电价配置
|
||||
*
|
||||
* @param id 电价配置主键
|
||||
* @return 电价配置
|
||||
*/
|
||||
@Override
|
||||
public EnergyPriceVo selectEmsEnergyPriceConfigById(Long id)
|
||||
{
|
||||
EnergyPriceVo vo = new EnergyPriceVo();
|
||||
EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.selectEmsEnergyPriceConfigById(id);
|
||||
if(priceConfig != null) {
|
||||
BeanUtils.copyProperties(priceConfig,vo);
|
||||
// 时间范围
|
||||
if (priceConfig.getId() != null) {
|
||||
List<EnergyPriceTimeRange> priceVos = emsPriceTimeConfigMapper.getTimeRangeByPriceId(priceConfig.getId());
|
||||
vo.setRange(priceVos);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询电价配置列表
|
||||
*
|
||||
* @return 电价配置
|
||||
*/
|
||||
@Override
|
||||
public List<EnergyPriceVo> selectEmsEnergyPriceConfigList()
|
||||
{
|
||||
List<EnergyPriceVo> responses = new ArrayList<>();
|
||||
// 仅查询当年配置
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int currentYear = currentDate.getYear();
|
||||
|
||||
List<EmsEnergyPriceConfig> priceConfigs = emsEnergyPriceConfigMapper.getCurrentYearConfigList(currentYear);
|
||||
|
||||
if (priceConfigs != null && priceConfigs.size() > 0) {
|
||||
for (EmsEnergyPriceConfig priceConfig : priceConfigs) {
|
||||
EnergyPriceVo vo = new EnergyPriceVo();
|
||||
BeanUtils.copyProperties(priceConfig, vo);
|
||||
// 时间范围
|
||||
if (priceConfig.getId() != null) {
|
||||
List<EnergyPriceTimeRange> priceVos = emsPriceTimeConfigMapper.getTimeRangeByPriceId(priceConfig.getId());
|
||||
vo.setRange(priceVos);
|
||||
}
|
||||
responses.add(vo);
|
||||
}
|
||||
}
|
||||
|
||||
return responses;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增电价配置
|
||||
*
|
||||
* @param priceVo 电价配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertEmsEnergyPriceConfig(EnergyPriceVo priceVo)
|
||||
{
|
||||
String year = priceVo.getYear();
|
||||
String month = priceVo.getMonth();
|
||||
|
||||
// 判断入参
|
||||
if(StringUtils.isEmpty(year) || StringUtils.isEmpty(month)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 校验当前月电价设置是否已存在,不存在则新增,存在则更新
|
||||
EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(year,month);
|
||||
if (priceConfig != null){
|
||||
return 0;
|
||||
} else {
|
||||
priceConfig = new EmsEnergyPriceConfig();
|
||||
}
|
||||
BeanUtils.copyProperties(priceVo,priceConfig);
|
||||
priceConfig.setCreateTime(DateUtils.getNowDate());
|
||||
priceConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
priceConfig.setCreateBy("system");
|
||||
priceConfig.setUpdateBy("system");
|
||||
emsEnergyPriceConfigMapper.insertOrUpdateEmsEnergyPriceConfig(priceConfig);
|
||||
|
||||
return batchInsetPriceTimeRange(priceVo,priceConfig.getId());
|
||||
}
|
||||
|
||||
private int batchInsetPriceTimeRange(EnergyPriceVo priceVo, Long priceId) {
|
||||
List<EmsPriceTimeConfig> timeConfigs = new ArrayList<>();
|
||||
List<EnergyPriceTimeRange> rangeVos = priceVo.getRange();
|
||||
if (rangeVos != null && rangeVos.size() > 0) {
|
||||
for (EnergyPriceTimeRange rangeVo : rangeVos) {
|
||||
EmsPriceTimeConfig timeConfig = new EmsPriceTimeConfig();
|
||||
BeanUtils.copyProperties(rangeVo,timeConfig);
|
||||
timeConfig.setCreateTime(DateUtils.getNowDate());
|
||||
timeConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
timeConfig.setCreateBy("system");
|
||||
timeConfig.setUpdateBy("system");
|
||||
timeConfig.setPriceId(priceId);
|
||||
timeConfigs.add(timeConfig);
|
||||
}
|
||||
}
|
||||
// 批量插入
|
||||
return emsPriceTimeConfigMapper.batchInsert(timeConfigs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改电价配置
|
||||
*
|
||||
* @param priceVo 电价配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateEmsEnergyPriceConfig(EnergyPriceVo priceVo)
|
||||
{
|
||||
if (priceVo == null || priceVo.getId() == null) {
|
||||
return 0;
|
||||
}
|
||||
// 不存在
|
||||
EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.selectEmsEnergyPriceConfigById(priceVo.getId());
|
||||
if (priceConfig == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 存在更新
|
||||
BeanUtils.copyProperties(priceVo, priceConfig);
|
||||
priceConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
priceConfig.setUpdateBy("system");
|
||||
emsEnergyPriceConfigMapper.updateEmsEnergyPriceConfig(priceConfig);
|
||||
|
||||
// 时间配置,全删,全插入
|
||||
Long[] priceIds = {priceVo.getId()};
|
||||
emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(priceIds);
|
||||
return batchInsetPriceTimeRange(priceVo,priceConfig.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除电价配置
|
||||
*
|
||||
* @param ids 需要删除的电价配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmsEnergyPriceConfigByIds(Long[] ids)
|
||||
{
|
||||
// 先删时间配置
|
||||
emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(ids);
|
||||
// 再删月电价
|
||||
return emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除电价配置信息
|
||||
*
|
||||
* @param id 电价配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmsEnergyPriceConfigById(Long id)
|
||||
{
|
||||
return emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigById(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user