dev #2
@ -3,7 +3,6 @@ package com.xzzn.web.controller.ems;
|
||||
import com.xzzn.common.core.controller.BaseController;
|
||||
import com.xzzn.common.core.domain.AjaxResult;
|
||||
import com.xzzn.common.core.page.TableDataInfo;
|
||||
import com.xzzn.ems.domain.EmsDevicesSetting;
|
||||
import com.xzzn.ems.domain.EmsSiteSetting;
|
||||
import com.xzzn.ems.domain.vo.SiteDeviceListVo;
|
||||
import com.xzzn.ems.service.IEmsDeviceSettingService;
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
package com.xzzn.web.controller.ems;
|
||||
|
||||
import com.xzzn.ems.domain.EmsStrategyRunning;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.xzzn.common.core.controller.BaseController;
|
||||
import com.xzzn.common.core.domain.AjaxResult;
|
||||
import com.xzzn.ems.service.IEmsStrategyService;
|
||||
|
||||
/**
|
||||
* 策略Controller
|
||||
*
|
||||
* @author xzzn
|
||||
* @date 2025-07-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/strategyRunning")
|
||||
public class EmsStrategyController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IEmsStrategyService emsStrategyService;
|
||||
|
||||
/**
|
||||
* 获取站点策略配置
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(String siteId) {
|
||||
return success(emsStrategyService.selectEmsStrategyRunningList(siteId));
|
||||
}
|
||||
/**
|
||||
* 停止策略
|
||||
*/
|
||||
@GetMapping(value = "/stop")
|
||||
public AjaxResult stop(Long id)
|
||||
{
|
||||
return toAjax(emsStrategyService.stopRunningStrategy(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主策略列表
|
||||
*/
|
||||
@GetMapping(value = "/getMainStrategyList")
|
||||
public AjaxResult getMainStrategyList()
|
||||
{
|
||||
return success(emsStrategyService.getMainStrategyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取辅助策略列表
|
||||
*/
|
||||
@GetMapping(value = "/getAuxStrategyList")
|
||||
public AjaxResult getAuxStrategyList()
|
||||
{
|
||||
return success(emsStrategyService.getAuxStrategyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置策略
|
||||
*/
|
||||
@PostMapping(value = "/configStrategy")
|
||||
public AjaxResult configStrategy(@RequestBody EmsStrategyRunning emsStrategyRunning)
|
||||
{
|
||||
emsStrategyRunning.setCreateBy(getUsername());
|
||||
emsStrategyRunning.setUpdateBy(getUsername());
|
||||
return toAjax(emsStrategyService.configStrategy(emsStrategyRunning));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -136,7 +136,8 @@
|
||||
<select id="getAllSiteDeviceList" parameterType="String" resultType="com.xzzn.ems.domain.vo.SiteDeviceListVo">
|
||||
select es.site_id as siteId,es.site_name as siteName,
|
||||
ed.device_id as deviceId,ed.device_name as deviceName,
|
||||
ed.device_type as deviceType,ed.communication_status as communicationStatus
|
||||
ed.device_type as deviceType,ed.communication_status as communicationStatus,
|
||||
ed.device_category as deviceCategory
|
||||
from ems_site_setting es INNER JOIN ems_devices_setting ed on es.site_id = ed.site_id
|
||||
where 1=1
|
||||
<if test="siteId != null and siteId != ''">
|
||||
|
||||
@ -0,0 +1,92 @@
|
||||
<?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.EmsStrategyMapper">
|
||||
|
||||
<resultMap type="EmsStrategy" id="EmsStrategyResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="strategyName" column="strategy_name" />
|
||||
<result property="strategyType" column="strategy_type" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="description" column="description" />
|
||||
<result property="mainStrategy" column="main_strategy" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsStrategyVo">
|
||||
select id, strategy_name, strategy_type, status, create_time, update_time, description, main_strategy from ems_strategy
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsStrategyList" parameterType="EmsStrategy" resultMap="EmsStrategyResult">
|
||||
<include refid="selectEmsStrategyVo"/>
|
||||
<where>
|
||||
<if test="strategyName != null and strategyName != ''"> and strategy_name like concat('%', #{strategyName}, '%')</if>
|
||||
<if test="strategyType != null "> and strategy_type = #{strategyType}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="description != null and description != ''"> and description = #{description}</if>
|
||||
<if test="mainStrategy != null "> and main_strategy = #{mainStrategy}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsStrategyById" parameterType="Long" resultMap="EmsStrategyResult">
|
||||
<include refid="selectEmsStrategyVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsStrategy" parameterType="EmsStrategy" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_strategy
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="strategyName != null">strategy_name,</if>
|
||||
<if test="strategyType != null">strategy_type,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="description != null">description,</if>
|
||||
<if test="mainStrategy != null">main_strategy,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="strategyName != null">#{strategyName},</if>
|
||||
<if test="strategyType != null">#{strategyType},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="mainStrategy != null">#{mainStrategy},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsStrategy" parameterType="EmsStrategy">
|
||||
update ems_strategy
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="strategyName != null">strategy_name = #{strategyName},</if>
|
||||
<if test="strategyType != null">strategy_type = #{strategyType},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="mainStrategy != null">main_strategy = #{mainStrategy},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsStrategyById" parameterType="Long">
|
||||
delete from ems_strategy where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsStrategyByIds" parameterType="String">
|
||||
delete from ems_strategy where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getStrategyListByType" resultMap="EmsStrategyResult">
|
||||
<include refid="selectEmsStrategyVo"/>
|
||||
where 1=1
|
||||
<if test="strategyType != null">
|
||||
and strategy_type = #{type}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,113 @@
|
||||
<?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.EmsStrategyRunningMapper">
|
||||
|
||||
<resultMap type="EmsStrategyRunning" id="EmsStrategyRunningResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="mainStrategyId" column="main_strategy_id" />
|
||||
<result property="auxiliaryStrategyId" column="auxiliary_strategy_id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="siteId" column="site_id" />
|
||||
<result property="deviceId" column="device_id" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmsStrategyRunningVo">
|
||||
select id, main_strategy_id, auxiliary_strategy_id, status, create_time, update_time, site_id, device_id, remark from ems_strategy_running
|
||||
</sql>
|
||||
|
||||
<select id="selectEmsStrategyRunningList" parameterType="EmsStrategyRunning" resultMap="EmsStrategyRunningResult">
|
||||
<include refid="selectEmsStrategyRunningVo"/>
|
||||
<where>
|
||||
<if test="mainStrategyId != null "> and main_strategy_id = #{mainStrategyId}</if>
|
||||
<if test="auxiliaryStrategyId != null "> and auxiliary_strategy_id = #{auxiliaryStrategyId}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="siteId != null and siteId != ''"> and site_id = #{siteId}</if>
|
||||
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEmsStrategyRunningById" parameterType="Long" resultMap="EmsStrategyRunningResult">
|
||||
<include refid="selectEmsStrategyRunningVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertEmsStrategyRunning" parameterType="EmsStrategyRunning" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into ems_strategy_running
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="mainStrategyId != null">main_strategy_id,</if>
|
||||
<if test="auxiliaryStrategyId != null">auxiliary_strategy_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="siteId != null">site_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="mainStrategyId != null">#{mainStrategyId},</if>
|
||||
<if test="auxiliaryStrategyId != null">#{auxiliaryStrategyId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="siteId != null">#{siteId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateEmsStrategyRunning" parameterType="EmsStrategyRunning">
|
||||
update ems_strategy_running
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="mainStrategyId != null">main_strategy_id = #{mainStrategyId},</if>
|
||||
<if test="auxiliaryStrategyId != null">auxiliary_strategy_id = #{auxiliaryStrategyId},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="siteId != null">site_id = #{siteId},</if>
|
||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteEmsStrategyRunningById" parameterType="Long">
|
||||
delete from ems_strategy_running where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteEmsStrategyRunningByIds" parameterType="String">
|
||||
delete from ems_strategy_running where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getRunningList" parameterType="String" resultType="com.xzzn.ems.domain.vo.StrategyRunningVo">
|
||||
select t.id,
|
||||
t.`status`,
|
||||
t.site_id as siteId,
|
||||
main.strategy_name as mainStrategyName,
|
||||
aux.strategy_name as auxStrategyName
|
||||
from ems_strategy_running t
|
||||
LEFT JOIN ems_strategy main on t.main_strategy_id = main.id
|
||||
LEFT JOIN ems_strategy aux on t.auxiliary_strategy_id = aux.id
|
||||
where t.site_id = #{siteId}
|
||||
and t.`status` != 4
|
||||
</select>
|
||||
|
||||
<update id="stopEmsStrategyRunning" parameterType="Long">
|
||||
update ems_strategy_running set `status`= 4 where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectEmsStrategyRunning" resultMap="EmsStrategyRunningResult">
|
||||
<include refid="selectEmsStrategyRunningVo"/>
|
||||
where site_id = #{siteId}
|
||||
and main_strategy_id = #{mainStrategyId}
|
||||
and auxiliary_strategy_id = #{auxiliaryStrategyId}
|
||||
and `status` != 4
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user