From bac66aaddb1cdb67693f5cdd6c8587ef8d6218a5 Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 29 Dec 2025 17:45:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EPCS=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 23 ++- .../com/xzzn/quartz/task/StrategyPoller.java | 2 - .../com/xzzn/ems/domain/EmsPcsSetting.java | 165 ++++++++++++++++++ .../xzzn/ems/domain/vo/DevicesSettingVo.java | 20 +++ .../xzzn/ems/mapper/EmsPcsSettingMapper.java | 66 +++++++ .../ems/service/IEmsDeviceSettingService.java | 8 +- .../impl/EmsDeviceSettingServiceImpl.java | 28 ++- .../mapper/ems/EmsPcsSettingMapper.xml | 116 ++++++++++++ 8 files changed, 408 insertions(+), 20 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsSetting.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicesSettingVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsSettingMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteConfigController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteConfigController.java index 6561ae3..342ad9e 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteConfigController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteConfigController.java @@ -6,24 +6,31 @@ import com.xzzn.common.core.domain.AjaxResult; import com.xzzn.common.core.page.TableDataInfo; import com.xzzn.common.utils.file.FileUploadUtils; import com.xzzn.common.utils.file.MimeTypeUtils; -import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.EmsSiteSetting; 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.domain.vo.SiteDeviceListVo; -import com.xzzn.ems.mapper.EmsPointMatchMapper; import com.xzzn.ems.service.IEmsDeviceSettingService; 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 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") - public AjaxResult addDevice(@RequestBody EmsDevicesSetting devicesSetting) + public AjaxResult addDevice(@RequestBody DevicesSettingVo devicesSetting) { int result = iEmsDeviceSettingService.addDevice(devicesSetting); if (result > 0) { @@ -123,7 +130,7 @@ public class EmsSiteConfigController extends BaseController{ * 修改Modbus设备配置 */ @PostMapping("/updateDevice") - public AjaxResult updateDevice(@RequestBody EmsDevicesSetting emsDevicesSetting) + public AjaxResult updateDevice(@RequestBody DevicesSettingVo emsDevicesSetting) { int result = iEmsDeviceSettingService.updateDevice(emsDevicesSetting); if (result > 0) { diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/StrategyPoller.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/StrategyPoller.java index 976c408..a8cd2b2 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/StrategyPoller.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/StrategyPoller.java @@ -39,7 +39,6 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; @@ -60,7 +59,6 @@ public class StrategyPoller { private static final BigDecimal ANTI_REVERSE_RANGE_PERCENT = new BigDecimal(20); // PCS功率降幅,默认为10% private static final BigDecimal ANTI_REVERSE_POWER_DOWN_PERCENT = new BigDecimal(10); - private final Map sitePcsPowerDown = new ConcurrentHashMap<>(); @Autowired private EmsStrategyRunningMapper emsStrategyRunningMapper; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsSetting.java new file mode 100644 index 0000000..0ab722e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsSetting.java @@ -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(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicesSettingVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicesSettingVo.java new file mode 100644 index 0000000..26510aa --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicesSettingVo.java @@ -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; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsSettingMapper.java new file mode 100644 index 0000000..c9e6cdc --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsSettingMapper.java @@ -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 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); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceSettingService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceSettingService.java index d38d27b..554bdee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceSettingService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceSettingService.java @@ -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); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java index ce2bafb..a9d4153 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java @@ -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)) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml new file mode 100644 index 0000000..2c26e91 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + + insert into ems_pcs_setting + + 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, + + + #{deviceSettingId}, + #{pointAddress}, + #{startCommand}, + #{stopCommand}, + #{startPower}, + #{stopPower}, + #{clusterNum}, + #{clusterPointAddress}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_pcs_setting + + device_setting_id = #{deviceSettingId}, + point_address = #{pointAddress}, + start_command = #{startCommand}, + stop_command = #{stopCommand}, + start_power = #{startPower}, + stop_power = #{stopPower}, + cluster_num = #{clusterNum}, + cluster_point_address = #{clusterPointAddress}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_pcs_setting where id = #{id} + + + + delete from ems_pcs_setting where id in + + #{id} + + + \ No newline at end of file