电价配置
This commit is contained in:
@ -0,0 +1,89 @@
|
|||||||
|
package com.xzzn.web.controller.ems;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xzzn.ems.domain.vo.EnergyPriceVo;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.xzzn.common.annotation.Log;
|
||||||
|
import com.xzzn.common.core.controller.BaseController;
|
||||||
|
import com.xzzn.common.core.domain.AjaxResult;
|
||||||
|
import com.xzzn.common.enums.BusinessType;
|
||||||
|
import com.xzzn.ems.service.IEmsEnergyPriceConfigService;
|
||||||
|
import com.xzzn.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电价配置Controller
|
||||||
|
*
|
||||||
|
* @author xzzn
|
||||||
|
* @date 2025-09-28
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ems/energyPriceConfig")
|
||||||
|
public class EmsEnergyPriceConfigController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IEmsEnergyPriceConfigService emsEnergyPriceConfigService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询电价配置列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list()
|
||||||
|
{
|
||||||
|
List<EnergyPriceVo> list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList();
|
||||||
|
return getDataTable2(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取电价配置详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||||
|
{
|
||||||
|
return success(emsEnergyPriceConfigService.selectEmsEnergyPriceConfigById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增电价配置
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:add')")
|
||||||
|
@Log(title = "电价配置", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody EnergyPriceVo priceVo)
|
||||||
|
{
|
||||||
|
return toAjax(emsEnergyPriceConfigService.insertEmsEnergyPriceConfig(priceVo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改电价配置
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:edit')")
|
||||||
|
@Log(title = "电价配置", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody EnergyPriceVo priceVo)
|
||||||
|
{
|
||||||
|
return toAjax(emsEnergyPriceConfigService.updateEmsEnergyPriceConfig(priceVo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除电价配置
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||||
|
@Log(title = "电价配置", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids)
|
||||||
|
{
|
||||||
|
return toAjax(emsEnergyPriceConfigService.deleteEmsEnergyPriceConfigByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,151 @@
|
|||||||
|
<?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.EmsEnergyPriceConfigMapper">
|
||||||
|
|
||||||
|
<resultMap type="EmsEnergyPriceConfig" id="EmsEnergyPriceConfigResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="year" column="year" />
|
||||||
|
<result property="month" column="month" />
|
||||||
|
<result property="peak" column="peak" />
|
||||||
|
<result property="high" column="high" />
|
||||||
|
<result property="flat" column="flat" />
|
||||||
|
<result property="valley" column="valley" />
|
||||||
|
<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="selectEmsEnergyPriceConfigVo">
|
||||||
|
select id, year, month, peak, high, flat, valley, create_by, create_time, update_by, update_time, remark from ems_energy_price_config
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectEmsEnergyPriceConfigList" parameterType="EmsEnergyPriceConfig" resultMap="EmsEnergyPriceConfigResult">
|
||||||
|
<include refid="selectEmsEnergyPriceConfigVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="year != null and year != ''"> and year = #{year}</if>
|
||||||
|
<if test="month != null and month != ''"> and month = #{month}</if>
|
||||||
|
<if test="peak != null "> and peak = #{peak}</if>
|
||||||
|
<if test="high != null "> and high = #{high}</if>
|
||||||
|
<if test="flat != null "> and flat = #{flat}</if>
|
||||||
|
<if test="valley != null "> and valley = #{valley}</if>
|
||||||
|
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectEmsEnergyPriceConfigById" parameterType="Long" resultMap="EmsEnergyPriceConfigResult">
|
||||||
|
<include refid="selectEmsEnergyPriceConfigVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into ems_energy_price_config
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="year != null and year != ''">year,</if>
|
||||||
|
<if test="month != null and month != ''">month,</if>
|
||||||
|
<if test="peak != null">peak,</if>
|
||||||
|
<if test="high != null">high,</if>
|
||||||
|
<if test="flat != null">flat,</if>
|
||||||
|
<if test="valley != null">valley,</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="year != null and year != ''">#{year},</if>
|
||||||
|
<if test="month != null and month != ''">#{month},</if>
|
||||||
|
<if test="peak != null">#{peak},</if>
|
||||||
|
<if test="high != null">#{high},</if>
|
||||||
|
<if test="flat != null">#{flat},</if>
|
||||||
|
<if test="valley != null">#{valley},</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="updateEmsEnergyPriceConfig" parameterType="EmsEnergyPriceConfig">
|
||||||
|
update ems_energy_price_config
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="year != null and year != ''">year = #{year},</if>
|
||||||
|
<if test="month != null and month != ''">month = #{month},</if>
|
||||||
|
<if test="peak != null">peak = #{peak},</if>
|
||||||
|
<if test="high != null">high = #{high},</if>
|
||||||
|
<if test="flat != null">flat = #{flat},</if>
|
||||||
|
<if test="valley != null">valley = #{valley},</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="deleteEmsEnergyPriceConfigById" parameterType="Long">
|
||||||
|
delete from ems_energy_price_config where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteEmsEnergyPriceConfigByIds" parameterType="String">
|
||||||
|
delete from ems_energy_price_config where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="getCurrentYearConfigList" resultMap="EmsEnergyPriceConfigResult">
|
||||||
|
<include refid="selectEmsEnergyPriceConfigVo"/>
|
||||||
|
<where>
|
||||||
|
year = #{currentYear}
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertOrUpdateEmsEnergyPriceConfig" parameterType="com.xzzn.ems.domain.EmsEnergyPriceConfig"
|
||||||
|
useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT INTO ems_energy_price_config (
|
||||||
|
id,
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
peak,
|
||||||
|
high,
|
||||||
|
flat,
|
||||||
|
valley,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
remark
|
||||||
|
) VALUES (
|
||||||
|
#{id},
|
||||||
|
#{year},
|
||||||
|
#{month},
|
||||||
|
#{peak},
|
||||||
|
#{high},
|
||||||
|
#{flat},
|
||||||
|
#{valley},
|
||||||
|
'system',
|
||||||
|
NOW(),
|
||||||
|
'system',
|
||||||
|
NOW(),
|
||||||
|
#{remark}
|
||||||
|
) ON DUPLICATE KEY UPDATE
|
||||||
|
peak = #{peak},
|
||||||
|
high = #{high},
|
||||||
|
flat = #{flat},
|
||||||
|
valley = #{valley},
|
||||||
|
update_time = NOW();
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="getConfigListByYearAndMonth" resultMap="EmsEnergyPriceConfigResult">
|
||||||
|
<include refid="selectEmsEnergyPriceConfigVo"/>
|
||||||
|
where year = #{currentYear}
|
||||||
|
and month = #{month}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,127 @@
|
|||||||
|
<?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.EmsPriceTimeConfigMapper">
|
||||||
|
|
||||||
|
<resultMap type="EmsPriceTimeConfig" id="EmsPriceTimeConfigResult">
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="startTime" column="start_time" />
|
||||||
|
<result property="endTime" column="end_time" />
|
||||||
|
<result property="costType" column="cost_type" />
|
||||||
|
<result property="priceId" column="price_id" />
|
||||||
|
<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="selectEmsPriceTimeConfigVo">
|
||||||
|
select id, start_time, end_time, cost_type, price_id, create_by, create_time, update_by, update_time, remark from ems_price_time_config
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectEmsPriceTimeConfigList" parameterType="EmsPriceTimeConfig" resultMap="EmsPriceTimeConfigResult">
|
||||||
|
<include refid="selectEmsPriceTimeConfigVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="startTime != null and startTime != ''"> and start_time = #{startTime}</if>
|
||||||
|
<if test="endTime != null and endTime != ''"> and end_time = #{endTime}</if>
|
||||||
|
<if test="costType != null and costType != ''"> and cost_type = #{costType}</if>
|
||||||
|
<if test="priceId != null "> and price_id = #{priceId}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectEmsPriceTimeConfigById" parameterType="Long" resultMap="EmsPriceTimeConfigResult">
|
||||||
|
<include refid="selectEmsPriceTimeConfigVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertEmsPriceTimeConfig" parameterType="EmsPriceTimeConfig" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into ems_price_time_config
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="startTime != null and startTime != ''">start_time,</if>
|
||||||
|
<if test="endTime != null and endTime != ''">end_time,</if>
|
||||||
|
<if test="costType != null and costType != ''">cost_type,</if>
|
||||||
|
<if test="priceId != null">price_id,</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="startTime != null and startTime != ''">#{startTime},</if>
|
||||||
|
<if test="endTime != null and endTime != ''">#{endTime},</if>
|
||||||
|
<if test="costType != null and costType != ''">#{costType},</if>
|
||||||
|
<if test="priceId != null">#{priceId},</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="updateEmsPriceTimeConfig" parameterType="EmsPriceTimeConfig">
|
||||||
|
update ems_price_time_config
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="startTime != null and startTime != ''">start_time = #{startTime},</if>
|
||||||
|
<if test="endTime != null and endTime != ''">end_time = #{endTime},</if>
|
||||||
|
<if test="costType != null and costType != ''">cost_type = #{costType},</if>
|
||||||
|
<if test="priceId != null">price_id = #{priceId},</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="deleteEmsPriceTimeConfigById" parameterType="Long">
|
||||||
|
delete from ems_price_time_config where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteEmsPriceTimeConfigByIds" parameterType="String">
|
||||||
|
delete from ems_price_time_config where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="getTimeRangeByPriceId" resultType="com.xzzn.ems.domain.vo.EnergyPriceTimeRange">
|
||||||
|
Select start_time as startTime,
|
||||||
|
end_time as endTime,
|
||||||
|
cost_type as costType
|
||||||
|
from ems_price_time_config
|
||||||
|
where price_id = #{priceId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="batchInsert" parameterType="java.util.List">
|
||||||
|
INSERT INTO ems_price_time_config (
|
||||||
|
start_time, end_time, cost_type, price_id, create_by, create_time, update_by, update_time, remark
|
||||||
|
) VALUES
|
||||||
|
<!-- 遍历集合生成多条记录,注意separator和括号闭合 -->
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(
|
||||||
|
#{item.startTime},
|
||||||
|
#{item.endTime},
|
||||||
|
#{item.costType},
|
||||||
|
#{item.priceId},
|
||||||
|
#{item.createBy},
|
||||||
|
#{item.createTime},
|
||||||
|
#{item.updateBy},
|
||||||
|
#{item.updateTime},
|
||||||
|
#{item.remark}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteTimeRangeByPriceId" parameterType="Long">
|
||||||
|
delete from ems_price_time_config where price_id in
|
||||||
|
<foreach item="priceId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{priceId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user