策略配置-策略运行
This commit is contained in:
114
ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategy.java
Normal file
114
ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategy.java
Normal file
@ -0,0 +1,114 @@
|
||||
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_strategy
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
public class EmsStrategy extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** */
|
||||
private Long id;
|
||||
|
||||
/** 策略名称,如“削峰填谷” */
|
||||
@Excel(name = "策略名称,如“削峰填谷”")
|
||||
private String strategyName;
|
||||
|
||||
/** 策略类型:1 - 主策略;2 - 辅助策略 */
|
||||
@Excel(name = "策略类型:1 - 主策略;2 - 辅助策略")
|
||||
private Long strategyType;
|
||||
|
||||
/** 策略状态:0-未启用 1-已运行 2-已暂停 3-禁用 4-删除 */
|
||||
@Excel(name = "策略状态:0-未启用 1-已运行 2-已暂停 3-禁用 4-删除")
|
||||
private String status;
|
||||
|
||||
/** 描述 */
|
||||
@Excel(name = "描述")
|
||||
private String description;
|
||||
|
||||
/** 主策略id */
|
||||
@Excel(name = "主策略id")
|
||||
private Long mainStrategy;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setStrategyName(String strategyName)
|
||||
{
|
||||
this.strategyName = strategyName;
|
||||
}
|
||||
|
||||
public String getStrategyName()
|
||||
{
|
||||
return strategyName;
|
||||
}
|
||||
|
||||
public void setStrategyType(Long strategyType)
|
||||
{
|
||||
this.strategyType = strategyType;
|
||||
}
|
||||
|
||||
public Long getStrategyType()
|
||||
{
|
||||
return strategyType;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setMainStrategy(Long mainStrategy)
|
||||
{
|
||||
this.mainStrategy = mainStrategy;
|
||||
}
|
||||
|
||||
public Long getMainStrategy()
|
||||
{
|
||||
return mainStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("strategyName", getStrategyName())
|
||||
.append("strategyType", getStrategyType())
|
||||
.append("status", getStatus())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("description", getDescription())
|
||||
.append("mainStrategy", getMainStrategy())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,115 @@
|
||||
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_strategy_running
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
public class EmsStrategyRunning extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 主要策略 */
|
||||
@Excel(name = "主要策略")
|
||||
private Long mainStrategyId;
|
||||
|
||||
/** 辅助策略 */
|
||||
@Excel(name = "辅助策略")
|
||||
private Long auxiliaryStrategyId;
|
||||
|
||||
/** 策略状态:0-未启用 1-已运行 2-已暂停 3-禁用 4-删除 */
|
||||
@Excel(name = "策略状态:0-未启用 1-已运行 2-已暂停 3-禁用 4-删除")
|
||||
private String status;
|
||||
|
||||
/** 站点id */
|
||||
@Excel(name = "站点id")
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setMainStrategyId(Long mainStrategyId)
|
||||
{
|
||||
this.mainStrategyId = mainStrategyId;
|
||||
}
|
||||
|
||||
public Long getMainStrategyId()
|
||||
{
|
||||
return mainStrategyId;
|
||||
}
|
||||
|
||||
public void setAuxiliaryStrategyId(Long auxiliaryStrategyId)
|
||||
{
|
||||
this.auxiliaryStrategyId = auxiliaryStrategyId;
|
||||
}
|
||||
|
||||
public Long getAuxiliaryStrategyId()
|
||||
{
|
||||
return auxiliaryStrategyId;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("mainStrategyId", getMainStrategyId())
|
||||
.append("auxiliaryStrategyId", getAuxiliaryStrategyId())
|
||||
.append("status", getStatus())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("siteId", getSiteId())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,8 @@ public class SiteDeviceListVo {
|
||||
private String deviceType;
|
||||
/** 通信状态 */
|
||||
private String communicationStatus;
|
||||
/** 设备类型 */
|
||||
private String deviceCategory;
|
||||
|
||||
public String getSiteId() {
|
||||
return siteId;
|
||||
@ -65,4 +67,12 @@ public class SiteDeviceListVo {
|
||||
public void setCommunicationStatus(String communicationStatus) {
|
||||
this.communicationStatus = communicationStatus;
|
||||
}
|
||||
|
||||
public String getDeviceCategory() {
|
||||
return deviceCategory;
|
||||
}
|
||||
|
||||
public void setDeviceCategory(String deviceCategory) {
|
||||
this.deviceCategory = deviceCategory;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
package com.xzzn.ems.domain.vo;
|
||||
|
||||
/**
|
||||
* 策略运行对象
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
public class StrategyRunningVo
|
||||
{
|
||||
/** 策略状态:0-未启用 1-已运行 2-已暂停 3-禁用 4-删除 */
|
||||
private String status;
|
||||
|
||||
/** 主策略名称 */
|
||||
private String mainStrategyName;
|
||||
|
||||
/** 辅助策略名称 */
|
||||
private String auxStrategyName;
|
||||
|
||||
/** 站点id */
|
||||
private String siteId;
|
||||
|
||||
/** 设备唯一标识符 */
|
||||
private String deviceId;
|
||||
|
||||
/** 策略运行id */
|
||||
private Long id;
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getMainStrategyName() {
|
||||
return mainStrategyName;
|
||||
}
|
||||
|
||||
public void setMainStrategyName(String mainStrategyName) {
|
||||
this.mainStrategyName = mainStrategyName;
|
||||
}
|
||||
|
||||
public String getAuxStrategyName() {
|
||||
return auxStrategyName;
|
||||
}
|
||||
|
||||
public void setAuxStrategyName(String auxStrategyName) {
|
||||
this.auxStrategyName = auxStrategyName;
|
||||
}
|
||||
|
||||
public void setSiteId(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsStrategy;
|
||||
|
||||
/**
|
||||
* 策略Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
public interface EmsStrategyMapper
|
||||
{
|
||||
/**
|
||||
* 查询策略
|
||||
*
|
||||
* @param id 策略主键
|
||||
* @return 策略
|
||||
*/
|
||||
public EmsStrategy selectEmsStrategyById(Long id);
|
||||
|
||||
/**
|
||||
* 查询策略列表
|
||||
*
|
||||
* @param emsStrategy 策略
|
||||
* @return 策略集合
|
||||
*/
|
||||
public List<EmsStrategy> selectEmsStrategyList(EmsStrategy emsStrategy);
|
||||
|
||||
/**
|
||||
* 新增策略
|
||||
*
|
||||
* @param emsStrategy 策略
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsStrategy(EmsStrategy emsStrategy);
|
||||
|
||||
/**
|
||||
* 修改策略
|
||||
*
|
||||
* @param emsStrategy 策略
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsStrategy(EmsStrategy emsStrategy);
|
||||
|
||||
/**
|
||||
* 删除策略
|
||||
*
|
||||
* @param id 策略主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除策略
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyByIds(Long[] ids);
|
||||
|
||||
public List<EmsStrategy> getStrategyListByType(Long type);
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package com.xzzn.ems.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsStrategyRunning;
|
||||
import com.xzzn.ems.domain.vo.StrategyRunningVo;
|
||||
|
||||
/**
|
||||
* 策略运行Mapper接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
public interface EmsStrategyRunningMapper
|
||||
{
|
||||
/**
|
||||
* 查询策略运行
|
||||
*
|
||||
* @param id 策略运行主键
|
||||
* @return 策略运行
|
||||
*/
|
||||
public EmsStrategyRunning selectEmsStrategyRunningById(Long id);
|
||||
|
||||
/**
|
||||
* 查询策略运行列表
|
||||
*
|
||||
* @param emsStrategyRunning 策略运行
|
||||
* @return 策略运行集合
|
||||
*/
|
||||
public List<EmsStrategyRunning> selectEmsStrategyRunningList(EmsStrategyRunning emsStrategyRunning);
|
||||
|
||||
/**
|
||||
* 新增策略运行
|
||||
*
|
||||
* @param emsStrategyRunning 策略运行
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertEmsStrategyRunning(EmsStrategyRunning emsStrategyRunning);
|
||||
|
||||
/**
|
||||
* 修改策略运行
|
||||
*
|
||||
* @param emsStrategyRunning 策略运行
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateEmsStrategyRunning(EmsStrategyRunning emsStrategyRunning);
|
||||
|
||||
/**
|
||||
* 删除策略运行
|
||||
*
|
||||
* @param id 策略运行主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyRunningById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除策略运行
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteEmsStrategyRunningByIds(Long[] ids);
|
||||
|
||||
// 获取站点运行策略
|
||||
public List<StrategyRunningVo> getRunningList(String siteId);
|
||||
|
||||
// 停止策略
|
||||
public int stopEmsStrategyRunning(Long id);
|
||||
|
||||
// 根据主策略id、辅助策略id、siteId 获取运行策略
|
||||
public EmsStrategyRunning selectEmsStrategyRunning(EmsStrategyRunning emsStrategyRunning);
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.xzzn.ems.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.ems.domain.EmsStrategy;
|
||||
import com.xzzn.ems.domain.EmsStrategyRunning;
|
||||
import com.xzzn.ems.domain.vo.StrategyRunningVo;
|
||||
|
||||
|
||||
/**
|
||||
* 策略Service接口
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
public interface IEmsStrategyService
|
||||
{
|
||||
// 获取策略运行列表
|
||||
public List<StrategyRunningVo> selectEmsStrategyRunningList(String siteId);
|
||||
|
||||
// 停止策略
|
||||
public int stopRunningStrategy(Long id);
|
||||
|
||||
// 获取主策略
|
||||
public List<EmsStrategy> getMainStrategyList();
|
||||
|
||||
// 获取辅助策略
|
||||
public List<EmsStrategy> getAuxStrategyList();
|
||||
|
||||
public int configStrategy(EmsStrategyRunning emsStrategyRunning);
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.ems.domain.EmsStrategyRunning;
|
||||
import com.xzzn.ems.domain.vo.StrategyRunningVo;
|
||||
import com.xzzn.ems.mapper.EmsStrategyRunningMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xzzn.ems.mapper.EmsStrategyMapper;
|
||||
import com.xzzn.ems.domain.EmsStrategy;
|
||||
import com.xzzn.ems.service.IEmsStrategyService;
|
||||
|
||||
/**
|
||||
* 策略Service业务层处理
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
@Service
|
||||
public class EmsStrategyServiceImpl implements IEmsStrategyService
|
||||
{
|
||||
@Autowired
|
||||
private EmsStrategyMapper emsStrategyMapper;
|
||||
@Autowired
|
||||
private EmsStrategyRunningMapper emsStrategyRunningMapper;
|
||||
|
||||
@Override
|
||||
public List<StrategyRunningVo> selectEmsStrategyRunningList(String siteId) {
|
||||
List<StrategyRunningVo> dataList = emsStrategyRunningMapper.getRunningList(siteId);
|
||||
return dataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int stopRunningStrategy(Long id) {
|
||||
return emsStrategyRunningMapper.stopEmsStrategyRunning(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmsStrategy> getMainStrategyList() {
|
||||
return emsStrategyMapper.getStrategyListByType(1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmsStrategy> getAuxStrategyList() {
|
||||
return emsStrategyMapper.getStrategyListByType(2L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int configStrategy(EmsStrategyRunning emsStrategyRunning) {
|
||||
// 校验改策略是否已存在
|
||||
EmsStrategyRunning existStrategy = emsStrategyRunningMapper.selectEmsStrategyRunning(emsStrategyRunning);
|
||||
if (existStrategy != null) {
|
||||
return -1;
|
||||
}
|
||||
// 不存在则插入
|
||||
emsStrategyRunning.setStatus("1");
|
||||
emsStrategyRunning.setCreateTime(DateUtils.getNowDate());
|
||||
emsStrategyRunning.setUpdateTime(DateUtils.getNowDate());
|
||||
return emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user