策略配置-策略模板修改
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
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;
|
||||
@ -11,7 +12,7 @@ import com.xzzn.common.annotation.Excel;
|
||||
* 模板对象 ems_strategy_temp
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-12
|
||||
* @date 2025-07-13
|
||||
*/
|
||||
public class EmsStrategyTemp extends BaseEntity
|
||||
{
|
||||
@ -40,10 +41,32 @@ public class EmsStrategyTemp extends BaseEntity
|
||||
@Excel(name = "SDC上限 (%)")
|
||||
private BigDecimal sdcUp;
|
||||
|
||||
/** 开始时间 */
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@Excel(name = "开始时间", width = 30, dateFormat = "HH:mm")
|
||||
private Date startTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@Excel(name = "结束时间", width = 30, dateFormat = "HH:mm")
|
||||
private Date endTime;
|
||||
|
||||
/** 充放功率 (kW) */
|
||||
@Excel(name = "充放功率 (kW)")
|
||||
private BigDecimal chargeDischargePower;
|
||||
|
||||
/** 充电状态,如“1-充电”、“2-待机” */
|
||||
@Excel(name = "充电状态,如“1-充电”、“2-待机”")
|
||||
private String chargeStatus;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 模板id */
|
||||
@Excel(name = "模板id")
|
||||
private String templateId;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
@ -104,6 +127,46 @@ public class EmsStrategyTemp extends BaseEntity
|
||||
return sdcUp;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime)
|
||||
{
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Date getEndTime()
|
||||
{
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setChargeDischargePower(BigDecimal chargeDischargePower)
|
||||
{
|
||||
this.chargeDischargePower = chargeDischargePower;
|
||||
}
|
||||
|
||||
public BigDecimal getChargeDischargePower()
|
||||
{
|
||||
return chargeDischargePower;
|
||||
}
|
||||
|
||||
public void setChargeStatus(String chargeStatus)
|
||||
{
|
||||
this.chargeStatus = chargeStatus;
|
||||
}
|
||||
|
||||
public String getChargeStatus()
|
||||
{
|
||||
return chargeStatus;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
@ -114,6 +177,16 @@ public class EmsStrategyTemp extends BaseEntity
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getTemplateId()
|
||||
{
|
||||
return templateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
@ -123,12 +196,17 @@ public class EmsStrategyTemp extends BaseEntity
|
||||
.append("sdcLimit", getSdcLimit())
|
||||
.append("sdcDown", getSdcDown())
|
||||
.append("sdcUp", getSdcUp())
|
||||
.append("startTime", getStartTime())
|
||||
.append("endTime", getEndTime())
|
||||
.append("chargeDischargePower", getChargeDischargePower())
|
||||
.append("chargeStatus", getChargeStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("siteId", getSiteId())
|
||||
.append("templateId", getTemplateId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,13 +22,13 @@ public class EmsStrategyTempTimeConfig extends BaseEntity
|
||||
private Long id;
|
||||
|
||||
/** 开始时间 */
|
||||
@JsonFormat(pattern = "HH:mm:ss")
|
||||
@Excel(name = "开始时间", width = 30, dateFormat = "HH:mm:ss")
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@Excel(name = "开始时间", width = 30, dateFormat = "HH:mm")
|
||||
private Date startTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@JsonFormat(pattern = "HH:mm:ss")
|
||||
@Excel(name = "结束时间", width = 30, dateFormat = "HH:mm:ss")
|
||||
@JsonFormat(pattern = "HH:mm")
|
||||
@Excel(name = "结束时间", width = 30, dateFormat = "HH:mm")
|
||||
private Date endTime;
|
||||
|
||||
/** 充放功率 (kW) */
|
||||
|
||||
@ -15,7 +15,7 @@ public class StrategyTempConfigRequest
|
||||
{
|
||||
|
||||
/** 模板id */
|
||||
private Long id;
|
||||
private String templateId;
|
||||
/** 站点id */
|
||||
private String siteId;
|
||||
|
||||
@ -37,12 +37,12 @@ public class StrategyTempConfigRequest
|
||||
/** 模板时间 */
|
||||
private List<EmsStrategyTempTimeConfig> timeConfigList;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setTemplateId(String templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public void setStrategyId(Long strategyId)
|
||||
|
||||
@ -65,6 +65,9 @@ public interface EmsStrategyTempMapper
|
||||
// 获取模板名称和id
|
||||
public List<Map<String,String>> getTempNameList(@Param("strategyId")Long strategyId, @Param("siteId")String siteId);
|
||||
|
||||
// 删除模板
|
||||
public int deleteEmsStrategyTempByIds(Long id);
|
||||
// 根据模板id获取模板所有的时间配置
|
||||
public List<EmsStrategyTemp> selectStrategyTempByTempId(String templateId);
|
||||
|
||||
// 根据模板id全部删除
|
||||
public int deleteTempByTempId(String templateId);
|
||||
}
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsStrategyTempTimeConfig;
|
||||
|
||||
/**
|
||||
* 模板配置Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-12
|
||||
*/
|
||||
public interface EmsStrategyTempTimeConfigMapper
|
||||
{
|
||||
/**
|
||||
* 查询模板配置
|
||||
*
|
||||
* @param id 模板配置主键
|
||||
* @return 模板配置
|
||||
*/
|
||||
public EmsStrategyTempTimeConfig selectEmsStrategyTempTimeConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 查询模板配置列表
|
||||
*
|
||||
* @param emsStrategyTempTimeConfig 模板配置
|
||||
* @return 模板配置集合
|
||||
*/
|
||||
public List<EmsStrategyTempTimeConfig> selectEmsStrategyTempTimeConfigList(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig);
|
||||
|
||||
/**
|
||||
* 新增模板配置
|
||||
*
|
||||
* @param emsStrategyTempTimeConfig 模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsStrategyTempTimeConfig(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig);
|
||||
|
||||
/**
|
||||
* 修改模板配置
|
||||
*
|
||||
* @param emsStrategyTempTimeConfig 模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsStrategyTempTimeConfig(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig);
|
||||
|
||||
/**
|
||||
* 删除模板配置
|
||||
*
|
||||
* @param id 模板配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyTempTimeConfigById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除模板配置
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyTempTimeConfigByIds(Long[] ids);
|
||||
|
||||
// 获取模板的时间
|
||||
public List<EmsStrategyTempTimeConfig> getTimeListByTempId(Long templateId);
|
||||
|
||||
// 根据模板id删除时间配置
|
||||
public void deleteTimeConfigByTempId(Long templateId);
|
||||
}
|
||||
@ -5,7 +5,6 @@ import java.util.Map;
|
||||
|
||||
import com.xzzn.ems.domain.EmsStrategyTemp;
|
||||
import com.xzzn.ems.domain.vo.StrategyTempConfigRequest;
|
||||
import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo;
|
||||
|
||||
/**
|
||||
* 模板Service接口
|
||||
@ -15,13 +14,6 @@ import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo;
|
||||
*/
|
||||
public interface IEmsStrategyTempService
|
||||
{
|
||||
|
||||
// 获取该模板下的时间配置
|
||||
public List<StrategyTempTimeConfigVo> selectEmsStrategyTempList(Long id);
|
||||
|
||||
// 新增模板及时间配置
|
||||
public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo);
|
||||
|
||||
/**
|
||||
* 修改模板
|
||||
*
|
||||
@ -30,23 +22,14 @@ public interface IEmsStrategyTempService
|
||||
*/
|
||||
public boolean updateEmsStrategyTemp(StrategyTempConfigRequest requestVo);
|
||||
|
||||
/**
|
||||
* 批量删除模板
|
||||
*
|
||||
* @param ids 需要删除的模板主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyTempByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除模板信息
|
||||
*
|
||||
* @param id 模板主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyTempById(Long id);
|
||||
|
||||
public List<Map<String,String>> getTempNameList(Long strategyId, String siteId);
|
||||
|
||||
public void deleteStrategyTempById(Long id);
|
||||
// 获取该模板下的时间配置
|
||||
public List<EmsStrategyTemp> selectEmsStrategyTempList(String templateId);
|
||||
|
||||
// 新增模板及时间配置
|
||||
public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo);
|
||||
|
||||
//根据templateId删除模板
|
||||
public int deleteStrategyTempById(String templateId);
|
||||
}
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.common.utils.bean.BeanUtils;
|
||||
import com.xzzn.ems.domain.EmsStrategyTempTimeConfig;
|
||||
import com.xzzn.ems.domain.vo.StrategyTempConfigRequest;
|
||||
import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo;
|
||||
import com.xzzn.ems.mapper.EmsStrategyTempTimeConfigMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xzzn.ems.mapper.EmsStrategyTempMapper;
|
||||
@ -26,10 +24,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService
|
||||
{
|
||||
private static final String PREFIX= "Temp";
|
||||
@Autowired
|
||||
private EmsStrategyTempMapper emsStrategyTempMapper;
|
||||
@Autowired
|
||||
private EmsStrategyTempTimeConfigMapper emsStrategyTempTimeConfigMapper;
|
||||
|
||||
/**
|
||||
* 查询模板列表
|
||||
@ -38,26 +35,42 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService
|
||||
* @return 模板
|
||||
*/
|
||||
@Override
|
||||
public List<StrategyTempTimeConfigVo> selectEmsStrategyTempList(Long templateId)
|
||||
public List<EmsStrategyTemp> selectEmsStrategyTempList(String templateId)
|
||||
{
|
||||
List<StrategyTempTimeConfigVo> dataList = new ArrayList<>();
|
||||
EmsStrategyTemp temp = emsStrategyTempMapper.selectEmsStrategyTempById(templateId);
|
||||
if (temp != null) {
|
||||
List<EmsStrategyTempTimeConfig> timeList = emsStrategyTempTimeConfigMapper.getTimeListByTempId(templateId);
|
||||
if (timeList != null && !timeList.isEmpty()) {
|
||||
for (EmsStrategyTempTimeConfig timeConfig : timeList) {
|
||||
StrategyTempTimeConfigVo vo = new StrategyTempTimeConfigVo();
|
||||
BeanUtils.copyProperties(timeConfig, vo);
|
||||
BeanUtils.copyProperties(temp, vo);
|
||||
dataList.add(vo);
|
||||
}
|
||||
} else {
|
||||
StrategyTempTimeConfigVo vo = new StrategyTempTimeConfigVo();
|
||||
BeanUtils.copyProperties(temp, vo);
|
||||
dataList.add(vo);
|
||||
}
|
||||
return emsStrategyTempMapper.selectStrategyTempByTempId(templateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模板和时间配置
|
||||
* @param requestVo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo) {
|
||||
// 随机生产模板id格式:Temp+时间戳
|
||||
String templateId = requestVo.getTemplateId();
|
||||
if (StringUtils.isEmpty(templateId)) {
|
||||
templateId = PREFIX + DateUtils.dateTimeNow();
|
||||
}
|
||||
return dataList;
|
||||
|
||||
EmsStrategyTemp publicTemp = new EmsStrategyTemp();
|
||||
BeanUtils.copyProperties(requestVo, publicTemp);
|
||||
publicTemp.setTemplateId(templateId);
|
||||
publicTemp.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
List<EmsStrategyTempTimeConfig> timeList = requestVo.getTimeConfigList();
|
||||
if (timeList != null && !timeList.isEmpty()) {
|
||||
for (EmsStrategyTempTimeConfig timeConfig : timeList) {
|
||||
EmsStrategyTemp temp = new EmsStrategyTemp();
|
||||
BeanUtils.copyProperties(publicTemp, temp);
|
||||
BeanUtils.copyProperties(timeConfig, temp);
|
||||
emsStrategyTempMapper.insertEmsStrategyTemp(temp);
|
||||
}
|
||||
} else {// 无时间配置只配置模板基本信息
|
||||
emsStrategyTempMapper.insertEmsStrategyTemp(publicTemp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,88 +83,25 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateEmsStrategyTemp(StrategyTempConfigRequest requestVo)
|
||||
{
|
||||
Long id = requestVo.getId();
|
||||
// 根据模板id校验该模板是否存在
|
||||
EmsStrategyTemp temp = emsStrategyTempMapper.selectEmsStrategyTempById(id);
|
||||
if (temp == null) {
|
||||
return false;
|
||||
}
|
||||
// 更新模板数据
|
||||
BeanUtils.copyProperties(requestVo, temp);
|
||||
emsStrategyTempMapper.updateEmsStrategyTemp(temp);
|
||||
String templateId = requestVo.getTemplateId();
|
||||
// 无发匹配原数据
|
||||
// 全删
|
||||
emsStrategyTempMapper.deleteTempByTempId(templateId);
|
||||
|
||||
// 先删除再加
|
||||
emsStrategyTempTimeConfigMapper.deleteTimeConfigByTempId(id);
|
||||
|
||||
List<EmsStrategyTempTimeConfig> timeList = requestVo.getTimeConfigList();
|
||||
if (timeList != null) {
|
||||
for (EmsStrategyTempTimeConfig timeConfig : timeList) {
|
||||
timeConfig.setTemplateId(id);
|
||||
timeConfig.setCreateTime(DateUtils.getNowDate());
|
||||
timeConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
emsStrategyTempTimeConfigMapper.insertEmsStrategyTempTimeConfig(timeConfig);
|
||||
}
|
||||
}
|
||||
// 重新新增
|
||||
addNewTempAndTimeConfig(requestVo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除模板
|
||||
*
|
||||
* @param ids 需要删除的模板主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmsStrategyTempByIds(Long[] ids)
|
||||
{
|
||||
return emsStrategyTempMapper.deleteEmsStrategyTempByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模板信息
|
||||
*
|
||||
* @param id 模板主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmsStrategyTempById(Long id)
|
||||
{
|
||||
return emsStrategyTempMapper.deleteEmsStrategyTempById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String,String>> getTempNameList(Long strategyId, String siteId) {
|
||||
return emsStrategyTempMapper.getTempNameList(strategyId, siteId);
|
||||
}
|
||||
|
||||
// 新增模板和时间配置
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo) {
|
||||
EmsStrategyTemp emsStrategyTemp = new EmsStrategyTemp();
|
||||
BeanUtils.copyProperties(requestVo, emsStrategyTemp);
|
||||
emsStrategyTemp.setCreateTime(DateUtils.getNowDate());
|
||||
emsStrategyTempMapper.insertEmsStrategyTemp(emsStrategyTemp);
|
||||
|
||||
List<EmsStrategyTempTimeConfig> timeList = requestVo.getTimeConfigList();
|
||||
if (timeList != null) {
|
||||
for (EmsStrategyTempTimeConfig timeConfig : timeList) {
|
||||
timeConfig.setCreateTime(DateUtils.getNowDate());
|
||||
timeConfig.setTemplateId(emsStrategyTemp.getId());
|
||||
emsStrategyTempTimeConfigMapper.insertEmsStrategyTempTimeConfig(timeConfig);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteStrategyTempById(Long id) {
|
||||
// 先删除时间配置
|
||||
emsStrategyTempTimeConfigMapper.deleteTimeConfigByTempId(id);
|
||||
|
||||
// 再删除模板
|
||||
emsStrategyTempMapper.deleteEmsStrategyTempById(id);
|
||||
public int deleteStrategyTempById(String templateId) {
|
||||
return emsStrategyTempMapper.deleteTempByTempId(templateId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user