新增PCS设备配置功能

This commit is contained in:
zq
2025-12-29 17:45:53 +08:00
parent 5456d4742e
commit bac66aaddb
8 changed files with 408 additions and 20 deletions

View File

@ -6,24 +6,31 @@ import com.xzzn.common.core.domain.AjaxResult;
import com.xzzn.common.core.page.TableDataInfo; import com.xzzn.common.core.page.TableDataInfo;
import com.xzzn.common.utils.file.FileUploadUtils; import com.xzzn.common.utils.file.FileUploadUtils;
import com.xzzn.common.utils.file.MimeTypeUtils; import com.xzzn.common.utils.file.MimeTypeUtils;
import com.xzzn.ems.domain.EmsDevicesSetting;
import com.xzzn.ems.domain.EmsSiteSetting; import com.xzzn.ems.domain.EmsSiteSetting;
import com.xzzn.ems.domain.vo.DeviceUpdateRequest; import com.xzzn.ems.domain.vo.DeviceUpdateRequest;
import com.xzzn.ems.domain.vo.DevicesSettingVo;
import com.xzzn.ems.domain.vo.PointDataRequest; import com.xzzn.ems.domain.vo.PointDataRequest;
import com.xzzn.ems.domain.vo.PointQueryResponse; import com.xzzn.ems.domain.vo.PointQueryResponse;
import com.xzzn.ems.domain.vo.SiteDeviceListVo; import com.xzzn.ems.domain.vo.SiteDeviceListVo;
import com.xzzn.ems.mapper.EmsPointMatchMapper;
import com.xzzn.ems.service.IEmsDeviceSettingService; import com.xzzn.ems.service.IEmsDeviceSettingService;
import com.xzzn.ems.service.IEmsSiteService; import com.xzzn.ems.service.IEmsSiteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
/** /**
* *
* 站点配置 * 站点配置
@ -93,7 +100,7 @@ public class EmsSiteConfigController extends BaseController{
* 新增设备 * 新增设备
*/ */
@PostMapping("/addDevice") @PostMapping("/addDevice")
public AjaxResult addDevice(@RequestBody EmsDevicesSetting devicesSetting) public AjaxResult addDevice(@RequestBody DevicesSettingVo devicesSetting)
{ {
int result = iEmsDeviceSettingService.addDevice(devicesSetting); int result = iEmsDeviceSettingService.addDevice(devicesSetting);
if (result > 0) { if (result > 0) {
@ -123,7 +130,7 @@ public class EmsSiteConfigController extends BaseController{
* 修改Modbus设备配置 * 修改Modbus设备配置
*/ */
@PostMapping("/updateDevice") @PostMapping("/updateDevice")
public AjaxResult updateDevice(@RequestBody EmsDevicesSetting emsDevicesSetting) public AjaxResult updateDevice(@RequestBody DevicesSettingVo emsDevicesSetting)
{ {
int result = iEmsDeviceSettingService.updateDevice(emsDevicesSetting); int result = iEmsDeviceSettingService.updateDevice(emsDevicesSetting);
if (result > 0) { if (result > 0) {

View File

@ -39,7 +39,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -60,7 +59,6 @@ public class StrategyPoller {
private static final BigDecimal ANTI_REVERSE_RANGE_PERCENT = new BigDecimal(20); private static final BigDecimal ANTI_REVERSE_RANGE_PERCENT = new BigDecimal(20);
// PCS功率降幅默认为10% // PCS功率降幅默认为10%
private static final BigDecimal ANTI_REVERSE_POWER_DOWN_PERCENT = new BigDecimal(10); private static final BigDecimal ANTI_REVERSE_POWER_DOWN_PERCENT = new BigDecimal(10);
private final Map<String, BigDecimal> sitePcsPowerDown = new ConcurrentHashMap<>();
@Autowired @Autowired
private EmsStrategyRunningMapper emsStrategyRunningMapper; private EmsStrategyRunningMapper emsStrategyRunningMapper;

View File

@ -0,0 +1,165 @@
package com.xzzn.ems.domain;
import com.xzzn.common.annotation.Excel;
import com.xzzn.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* PCS设备配置对象 ems_pcs_setting
*
* @author xzzn
* @date 2025-12-29
*/
public class EmsPcsSetting extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 设备ID主键自增长 */
private Long id;
/** 设备配置关联ID */
@Excel(name = "设备配置关联ID")
private Long deviceSettingId;
/** 开关机地址 */
@Excel(name = "开关机地址")
private String pointAddress;
/** 开机指令 */
@Excel(name = "开机指令")
private String startCommand;
/** 关机指令 */
@Excel(name = "关机指令")
private String stopCommand;
/** 开机目标功率 */
@Excel(name = "开机目标功率")
private BigDecimal startPower;
/** 关机目标功率 */
@Excel(name = "关机目标功率")
private BigDecimal stopPower;
/** 电池簇数 */
@Excel(name = "电池簇数")
private Integer clusterNum;
/** 电池簇地址 */
@Excel(name = "电池簇地址")
private String clusterPointAddress;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setDeviceSettingId(Long deviceSettingId)
{
this.deviceSettingId = deviceSettingId;
}
public Long getDeviceSettingId()
{
return deviceSettingId;
}
public void setPointAddress(String pointAddress)
{
this.pointAddress = pointAddress;
}
public String getPointAddress()
{
return pointAddress;
}
public void setStartCommand(String startCommand)
{
this.startCommand = startCommand;
}
public String getStartCommand()
{
return startCommand;
}
public void setStopCommand(String stopCommand)
{
this.stopCommand = stopCommand;
}
public String getStopCommand()
{
return stopCommand;
}
public void setStartPower(BigDecimal startPower)
{
this.startPower = startPower;
}
public BigDecimal getStartPower()
{
return startPower;
}
public void setStopPower(BigDecimal stopPower)
{
this.stopPower = stopPower;
}
public BigDecimal getStopPower()
{
return stopPower;
}
public void setClusterNum(Integer clusterNum)
{
this.clusterNum = clusterNum;
}
public Integer getClusterNum()
{
return clusterNum;
}
public void setClusterPointAddress(String clusterPointAddress)
{
this.clusterPointAddress = clusterPointAddress;
}
public String getClusterPointAddress()
{
return clusterPointAddress;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("deviceSettingId", getDeviceSettingId())
.append("pointAddress", getPointAddress())
.append("startCommand", getStartCommand())
.append("stopCommand", getStopCommand())
.append("startPower", getStartPower())
.append("stopPower", getStopPower())
.append("clusterNum", getClusterNum())
.append("clusterPointAddress", getClusterPointAddress())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,20 @@
package com.xzzn.ems.domain.vo;
import com.xzzn.ems.domain.EmsDevicesSetting;
import com.xzzn.ems.domain.EmsPcsSetting;
public class DevicesSettingVo extends EmsDevicesSetting
{
private static final long serialVersionUID = 1L;
/** PCS设备配置 */
private EmsPcsSetting pcsSetting;
public EmsPcsSetting getPcsSetting() {
return pcsSetting;
}
public void setPcsSetting(EmsPcsSetting pcsSetting) {
this.pcsSetting = pcsSetting;
}
}

View File

@ -0,0 +1,66 @@
package com.xzzn.ems.mapper;
import com.xzzn.ems.domain.EmsPcsSetting;
import java.util.List;
import org.apache.ibatis.annotations.Param;
/**
* PCS设备配置Mapper接口
*
* @author xzzn
* @date 2025-12-29
*/
public interface EmsPcsSettingMapper
{
/**
* 查询PCS设备配置
*
* @param id PCS设备配置主键
* @return PCS设备配置
*/
public EmsPcsSetting selectEmsPcsSettingById(Long id);
/**
* 查询PCS设备配置列表
*
* @param emsPcsSetting PCS设备配置
* @return PCS设备配置集合
*/
public List<EmsPcsSetting> selectEmsPcsSettingList(EmsPcsSetting emsPcsSetting);
/**
* 新增PCS设备配置
*
* @param emsPcsSetting PCS设备配置
* @return 结果
*/
public int insertEmsPcsSetting(EmsPcsSetting emsPcsSetting);
/**
* 修改PCS设备配置
*
* @param emsPcsSetting PCS设备配置
* @return 结果
*/
public int updateEmsPcsSetting(EmsPcsSetting emsPcsSetting);
/**
* 删除PCS设备配置
*
* @param id PCS设备配置主键
* @return 结果
*/
public int deleteEmsPcsSettingById(Long id);
/**
* 批量删除PCS设备配置
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteEmsPcsSettingByIds(Long[] ids);
EmsPcsSetting selectEmsPcsSettingByDeviceId(@Param("deviceSettingId") Long deviceSettingId);
}

View File

@ -2,8 +2,8 @@ package com.xzzn.ems.service;
import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.enums.DeviceCategory;
import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.EmsDevicesSetting;
import com.xzzn.ems.domain.EmsPointMatch;
import com.xzzn.ems.domain.vo.DeviceUpdateRequest; import com.xzzn.ems.domain.vo.DeviceUpdateRequest;
import com.xzzn.ems.domain.vo.DevicesSettingVo;
import com.xzzn.ems.domain.vo.PointDataRequest; import com.xzzn.ems.domain.vo.PointDataRequest;
import com.xzzn.ems.domain.vo.PointQueryResponse; import com.xzzn.ems.domain.vo.PointQueryResponse;
@ -17,11 +17,11 @@ import java.util.Map;
public interface IEmsDeviceSettingService public interface IEmsDeviceSettingService
{ {
public EmsDevicesSetting getDeviceDetailInfo(Long deviceId); public DevicesSettingVo getDeviceDetailInfo(Long deviceId);
public int addDevice(EmsDevicesSetting devicesSetting); public int addDevice(DevicesSettingVo devicesSetting);
public int updateDevice(EmsDevicesSetting emsDevicesSetting); public int updateDevice(DevicesSettingVo emsDevicesSetting);
public int deleteEmsDevicesSettingById(Long id); public int deleteEmsDevicesSettingById(Long id);

View File

@ -17,12 +17,15 @@ import com.xzzn.common.exception.ServiceException;
import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.DateUtils;
import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.StringUtils;
import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.EmsDevicesSetting;
import com.xzzn.ems.domain.EmsPcsSetting;
import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.domain.EmsPointMatch;
import com.xzzn.ems.domain.vo.DeviceUpdateRequest; import com.xzzn.ems.domain.vo.DeviceUpdateRequest;
import com.xzzn.ems.domain.vo.DevicesSettingVo;
import com.xzzn.ems.domain.vo.PointDataRequest; import com.xzzn.ems.domain.vo.PointDataRequest;
import com.xzzn.ems.domain.vo.PointQueryResponse; import com.xzzn.ems.domain.vo.PointQueryResponse;
import com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper; import com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper;
import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsDevicesSettingMapper;
import com.xzzn.ems.mapper.EmsPcsSettingMapper;
import com.xzzn.ems.mapper.EmsPointMatchMapper; import com.xzzn.ems.mapper.EmsPointMatchMapper;
import com.xzzn.ems.service.IEmsDeviceSettingService; import com.xzzn.ems.service.IEmsDeviceSettingService;
@ -39,6 +42,7 @@ import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -61,6 +65,8 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
@Autowired @Autowired
private EmsPointMatchMapper emsPointMatchMapper; private EmsPointMatchMapper emsPointMatchMapper;
@Autowired @Autowired
private EmsPcsSettingMapper emsPcsSettingMapper;
@Autowired
private RedisCache redisCache; private RedisCache redisCache;
@Autowired @Autowired
private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper;
@ -75,8 +81,13 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
* @return * @return
*/ */
@Override @Override
public EmsDevicesSetting getDeviceDetailInfo(Long id) { public DevicesSettingVo getDeviceDetailInfo(Long id) {
return emsDevicesMapper.selectEmsDevicesSettingById(id); EmsDevicesSetting emsDevicesSetting = emsDevicesMapper.selectEmsDevicesSettingById(id);
DevicesSettingVo devicesSettingVo = new DevicesSettingVo();
BeanUtils.copyProperties(emsDevicesSetting, devicesSettingVo);
EmsPcsSetting pcsSetting = emsPcsSettingMapper.selectEmsPcsSettingByDeviceId(id);
devicesSettingVo.setPcsSetting(pcsSetting);
return devicesSettingVo;
} }
/** /**
@ -85,13 +96,17 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
* @return * @return
*/ */
@Override @Override
public int addDevice(EmsDevicesSetting devicesSetting) { public int addDevice(DevicesSettingVo devicesSetting) {
boolean flag = checkDeviceExist(devicesSetting); boolean flag = checkDeviceExist(devicesSetting);
if (flag) { if (flag) {
return -1; return -1;
} }
devicesSetting.setCreateTime(DateUtils.getNowDate()); devicesSetting.setCreateTime(DateUtils.getNowDate());
return emsDevicesMapper.insertEmsDevicesSetting(devicesSetting); int id = emsDevicesMapper.insertEmsDevicesSetting(devicesSetting);
EmsPcsSetting pcsSetting = devicesSetting.getPcsSetting();
pcsSetting.setDeviceSettingId(devicesSetting.getId());
emsPcsSettingMapper.insertEmsPcsSetting(pcsSetting);
return id;
} }
/** /**
@ -100,7 +115,7 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
* @return * @return
*/ */
@Override @Override
public int updateDevice(EmsDevicesSetting devicesSetting) { public int updateDevice(DevicesSettingVo devicesSetting) {
boolean checkExist = false; boolean checkExist = false;
if (devicesSetting.getId() != null) { if (devicesSetting.getId() != null) {
// 根据id判断该数据是否存在 // 根据id判断该数据是否存在
@ -121,10 +136,11 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
return -2; return -2;
} }
devicesSetting.setUpdateTime(DateUtils.getNowDate()); devicesSetting.setUpdateTime(DateUtils.getNowDate());
emsPcsSettingMapper.updateEmsPcsSetting(devicesSetting.getPcsSetting());
return emsDevicesMapper.updateEmsDevicesSetting(devicesSetting); return emsDevicesMapper.updateEmsDevicesSetting(devicesSetting);
} }
private boolean checkDeviceExist(EmsDevicesSetting devicesSetting) { private boolean checkDeviceExist(DevicesSettingVo devicesSetting) {
String deviceId = devicesSetting.getDeviceId(); String deviceId = devicesSetting.getDeviceId();
String siteId = devicesSetting.getSiteId(); String siteId = devicesSetting.getSiteId();
if (!StringUtils.isEmpty(deviceId) && !StringUtils.isEmpty(siteId)) { if (!StringUtils.isEmpty(deviceId) && !StringUtils.isEmpty(siteId)) {

View File

@ -0,0 +1,116 @@
<?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.EmsPcsSettingMapper">
<resultMap type="EmsPcsSetting" id="EmsPcsSettingResult">
<result property="id" column="id" />
<result property="deviceSettingId" column="device_setting_id" />
<result property="pointAddress" column="point_address" />
<result property="startCommand" column="start_command" />
<result property="stopCommand" column="stop_command" />
<result property="startPower" column="start_power" />
<result property="stopPower" column="stop_power" />
<result property="clusterNum" column="cluster_num" />
<result property="clusterPointAddress" column="cluster_point_address" />
<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="selectEmsPcsSettingVo">
select id, device_setting_id, point_address, start_command, stop_command, start_power, stop_power, cluster_num, cluster_point_address, create_by, create_time, update_by, update_time, remark from ems_pcs_setting
</sql>
<select id="selectEmsPcsSettingList" parameterType="EmsPcsSetting" resultMap="EmsPcsSettingResult">
<include refid="selectEmsPcsSettingVo"/>
<where>
<if test="deviceSettingId != null "> and device_setting_id = #{deviceSettingId}</if>
<if test="pointAddress != null and pointAddress != ''"> and point_address = #{pointAddress}</if>
<if test="startCommand != null and startCommand != ''"> and start_command = #{startCommand}</if>
<if test="stopCommand != null and stopCommand != ''"> and stop_command = #{stopCommand}</if>
<if test="startPower != null "> and start_power = #{startPower}</if>
<if test="stopPower != null "> and stop_power = #{stopPower}</if>
<if test="clusterNum != null "> and cluster_num = #{clusterNum}</if>
<if test="clusterPointAddress != null and clusterPointAddress != ''"> and cluster_point_address = #{clusterPointAddress}</if>
</where>
</select>
<select id="selectEmsPcsSettingById" parameterType="Long" resultMap="EmsPcsSettingResult">
<include refid="selectEmsPcsSettingVo"/>
where id = #{id}
</select>
<select id="selectEmsPcsSettingByDeviceId" parameterType="Long" resultMap="EmsPcsSettingResult">
<include refid="selectEmsPcsSettingVo"/>
where device_setting_id = #{deviceSettingId}
</select>
<insert id="insertEmsPcsSetting" parameterType="EmsPcsSetting" useGeneratedKeys="true" keyProperty="id">
insert into ems_pcs_setting
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceSettingId != null">device_setting_id,</if>
<if test="pointAddress != null">point_address,</if>
<if test="startCommand != null">start_command,</if>
<if test="stopCommand != null">stop_command,</if>
<if test="startPower != null">start_power,</if>
<if test="stopPower != null">stop_power,</if>
<if test="clusterNum != null">cluster_num,</if>
<if test="clusterPointAddress != null">cluster_point_address,</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="deviceSettingId != null">#{deviceSettingId},</if>
<if test="pointAddress != null">#{pointAddress},</if>
<if test="startCommand != null">#{startCommand},</if>
<if test="stopCommand != null">#{stopCommand},</if>
<if test="startPower != null">#{startPower},</if>
<if test="stopPower != null">#{stopPower},</if>
<if test="clusterNum != null">#{clusterNum},</if>
<if test="clusterPointAddress != null">#{clusterPointAddress},</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="updateEmsPcsSetting" parameterType="EmsPcsSetting">
update ems_pcs_setting
<trim prefix="SET" suffixOverrides=",">
<if test="deviceSettingId != null">device_setting_id = #{deviceSettingId},</if>
<if test="pointAddress != null">point_address = #{pointAddress},</if>
<if test="startCommand != null">start_command = #{startCommand},</if>
<if test="stopCommand != null">stop_command = #{stopCommand},</if>
<if test="startPower != null">start_power = #{startPower},</if>
<if test="stopPower != null">stop_power = #{stopPower},</if>
<if test="clusterNum != null">cluster_num = #{clusterNum},</if>
<if test="clusterPointAddress != null">cluster_point_address = #{clusterPointAddress},</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="deleteEmsPcsSettingById" parameterType="Long">
delete from ems_pcs_setting where id = #{id}
</delete>
<delete id="deleteEmsPcsSettingByIds" parameterType="String">
delete from ems_pcs_setting where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>