新增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

@ -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.ems.domain.EmsDevicesSetting;
import com.xzzn.ems.domain.EmsPointMatch;
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.PointQueryResponse;
@ -17,11 +17,11 @@ import java.util.Map;
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);

View File

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