From 3609b03deb6f57e1bef7e906c42166fae3f4ce47 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 27 Jun 2025 10:14:15 +0800 Subject: [PATCH 001/336] =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0-?= =?UTF-8?q?=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 18 +++++- .../ems/domain/vo/BatteryDataStatsListVo.java | 61 +++++++++++++++++++ .../domain/vo/BatteryDataStatsTemplate.java | 48 +++++++++++++++ .../ems/mapper/EmsDevicesSettingMapper.java | 16 +++++ .../com/xzzn/ems/service/IEmsSiteService.java | 8 +++ .../ems/service/impl/EmsSiteServiceImpl.java | 29 +++++++++ .../mapper/ems/EmsBatteryClusterMapper.xml | 12 ++++ .../mapper/ems/EmsBatteryDataMapper.xml | 54 +++++++++++++++- .../mapper/ems/EmsDevicesSettingMapper.xml | 12 ++++ 9 files changed, 254 insertions(+), 4 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 67a683a..d664700 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -2,6 +2,7 @@ package com.xzzn.web.controller.ems; import com.xzzn.common.core.controller.BaseController; import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.ems.service.IEmsSiteService; import com.xzzn.ems.service.ISingleSiteService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -17,6 +18,8 @@ public class EmsSiteMonitorController extends BaseController{ @Autowired private ISingleSiteService iSingleSiteService; + @Autowired + private IEmsSiteService iEmsSiteService; /** * 获取单站首页数据 @@ -78,16 +81,16 @@ public class EmsSiteMonitorController extends BaseController{ @GetMapping("/getStackNameList") public AjaxResult getStackNameList(@RequestParam Long siteId) { - return success(iSingleSiteService.getBMSBatteryCluster(siteId)); + return success(iEmsSiteService.getAllStackInfo(siteId)); } /** * 获取所有电池簇 */ @GetMapping("/getClusterNameList") - public AjaxResult getClusterNameList(@RequestParam Long siteId) + public AjaxResult getClusterNameList(@RequestParam Long stackDeviceId) { - return success(iSingleSiteService.getBMSBatteryCluster(siteId)); + return success(iEmsSiteService.getAllClusterInfo(stackDeviceId)); } /** @@ -98,4 +101,13 @@ public class EmsSiteMonitorController extends BaseController{ { return success(iSingleSiteService.getCoolingDataList(siteId)); } + + /** + * 获取电池簇下面的单体电池数据 + */ + @GetMapping("/getClusterDataInfoList") + public AjaxResult getClusterDataInfoList(@RequestParam Long clusterDeviceId) + { + return success(iEmsSiteService.getClusterDataInfoList(clusterDeviceId)); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java new file mode 100644 index 0000000..7990385 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; + +/** + * 单站监控-单体电池数据 + * + */ +public class BatteryDataStatsListVo { + /** + * 电压List + */ + private List voltageDataList; + + /** + * 温度List + */ + private List tempDataList; + + /** + * SOCList + */ + private List socDataList; + + /** + * SOHList + */ + private List sohDataList; + + public List getVoltageDataList() { + return voltageDataList; + } + + public void setVoltageDataList(List voltageDataList) { + this.voltageDataList = voltageDataList; + } + + public List getTempDataList() { + return tempDataList; + } + + public void setTempDataList(List tempDataList) { + this.tempDataList = tempDataList; + } + + public List getSocDataList() { + return socDataList; + } + + public void setSocDataList(List socDataList) { + this.socDataList = socDataList; + } + + public List getSohDataList() { + return sohDataList; + } + + public void setSohDataList(List sohDataList) { + this.sohDataList = sohDataList; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java new file mode 100644 index 0000000..2c4a21d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java @@ -0,0 +1,48 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 单体电池-数据统计模板 + * + */ +public class BatteryDataStatsTemplate { + /** + * 月份 + */ + private String dataMonth; + + /** + * 数据一 + */ + private BigDecimal dataOne; + + /** + * 数据二 + */ + private BigDecimal dataTwo; + + public String getDataMonth() { + return dataMonth; + } + + public void setDataMonth(String dataMonth) { + this.dataMonth = dataMonth; + } + + public BigDecimal getDataOne() { + return dataOne; + } + + public void setDataOne(BigDecimal dataOne) { + this.dataOne = dataOne; + } + + public BigDecimal getDataTwo() { + return dataTwo; + } + + public void setDataTwo(BigDecimal dataTwo) { + this.dataTwo = dataTwo; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index a21507b..5a7f172 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -1,6 +1,8 @@ package com.xzzn.ems.mapper; import java.util.List; +import java.util.Map; + import com.xzzn.ems.domain.EmsDevicesSetting; /** @@ -58,4 +60,18 @@ public interface EmsDevicesSettingMapper * @return 结果 */ public int deleteEmsDevicesSettingByIds(Long[] ids); + + /** + * 根据site_id获取所有电池堆 + * @param siteId + * @return + */ + public List> getAllStackInfoBySiteId(Long siteId); + + /** + * 根据电池堆id获取所有电池簇 + * @param stackDeviceId + * @return + */ + public List> getAllClusterInfoByStackId(Long stackDeviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index 4ac665c..eff7a91 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -1,9 +1,11 @@ package com.xzzn.ems.service; import com.xzzn.ems.domain.EmsSiteSetting; +import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import java.util.List; +import java.util.Map; /** * 站点信息 服务层 @@ -16,4 +18,10 @@ public interface IEmsSiteService public SiteTotalInfoVo getSiteTotalInfo(); + + public List> getAllStackInfo(Long siteId); + + public List> getAllClusterInfo(Long stackDeviceId); + + public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index 4a9e166..ba12178 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -1,13 +1,16 @@ package com.xzzn.ems.service.impl; import com.xzzn.ems.domain.EmsSiteSetting; +import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsSiteSettingMapper; import com.xzzn.ems.service.IEmsSiteService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; /** * 站点信息 服务层实现 @@ -19,6 +22,8 @@ public class EmsSiteServiceImpl implements IEmsSiteService @Autowired private EmsSiteSettingMapper emsSiteMapper; + @Autowired + private EmsDevicesSettingMapper emsDevicesMapper; @Override public List getAllSites() { @@ -30,4 +35,28 @@ public class EmsSiteServiceImpl implements IEmsSiteService return emsSiteMapper.getSiteTotalInfo(); } + /** + * 根据site_id获取所有电池堆 + * @param siteId + * @return + */ + @Override + public List> getAllStackInfo(Long siteId) { + return emsDevicesMapper.getAllStackInfoBySiteId(siteId); + } + + @Override + public List> getAllClusterInfo(Long stackDeviceId) { + return emsDevicesMapper.getAllClusterInfoByStackId(stackDeviceId); + } + + /** + * 根据电池堆获取单体柱状数据 + * @param clusterDeviceId + * @return + */ + @Override + public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId) { + return null; + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 8b061cf..bd4f43c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -157,4 +157,16 @@ and t.device_id = tmp.device_id) order by tmp.device_id + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index 456f7a1..ad7ab18 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -21,10 +21,11 @@ + - select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_battery_data + select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id from ems_battery_data @@ -66,6 +68,7 @@ remark, site_id, device_id, + cluster_device_id, #{batteryPack}, @@ -83,6 +86,7 @@ #{remark}, #{siteId}, #{deviceId}, + #{clusterDeviceId}, @@ -104,6 +108,7 @@ remark = #{remark}, site_id = #{siteId}, device_id = #{deviceId}, + cluster_device_id = #{clusterDeviceId}, where id = #{id} @@ -124,4 +129,51 @@ where site_id = #{siteId} and DATE(data_timestamp) = DATE(NOW()) + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index c90b2c3..a9f4f03 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -133,4 +133,16 @@ #{id} + + + + \ No newline at end of file -- 2.49.0 From f439228432ba094bc90458949d62f2e0c884525b Mon Sep 17 00:00:00 2001 From: dashixiong Date: Fri, 27 Jun 2025 12:49:14 +0800 Subject: [PATCH 002/336] =?UTF-8?q?mqtt=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 79 +++++++++ ems-admin/src/main/resources/application.yml | 9 + ems-framework/pom.xml | 10 +- .../com/xzzn/framework/config/MqttConfig.java | 31 ++++ .../config/properties/MqttProperties.java | 31 ++++ .../manager/MqttLifecycleManager.java | 155 ++++++++++++++++++ .../framework/web/service/MqttPublisher.java | 8 + .../framework/web/service/MqttSubscriber.java | 7 + pom.xml | 10 ++ 9 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java create mode 100644 ems-framework/src/main/java/com/xzzn/framework/config/MqttConfig.java create mode 100644 ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java create mode 100644 ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java create mode 100644 ems-framework/src/main/java/com/xzzn/framework/web/service/MqttPublisher.java create mode 100644 ems-framework/src/main/java/com/xzzn/framework/web/service/MqttSubscriber.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java new file mode 100644 index 0000000..aec61ae --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -0,0 +1,79 @@ +package com.xzzn.web.controller.ems; + +import com.xzzn.framework.manager.MqttLifecycleManager; +import com.xzzn.framework.web.service.MqttPublisher; +import com.xzzn.framework.web.service.MqttSubscriber; +import org.eclipse.paho.client.mqttv3.IMqttMessageListener; +import org.eclipse.paho.client.mqttv3.MqttException; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; + +@Service +public class MqttMessageController implements MqttPublisher, MqttSubscriber { + + private final MqttLifecycleManager mqttLifecycleManager; + + @Autowired + public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { + this.mqttLifecycleManager = mqttLifecycleManager; + } + + @PostConstruct + public void init() { + // 订阅系统状态主题 + subscribe("system/status", 1, this::handleSystemStatus); + + // 订阅设备数据主题 + subscribe("devices/data", 0, this::handleDeviceData); + } + + // 处理系统状态消息 + private void handleSystemStatus(String topic, MqttMessage message) { + String payload = new String(message.getPayload()); + System.out.println("[SYSTEM] Status update: " + payload); + // 业务处理逻辑 + + + } + + // 处理设备数据 + private void handleDeviceData(String topic, MqttMessage message) { + String payload = new String(message.getPayload()); + System.out.println("[DEVICE] data: " + payload); + // 业务处理逻辑 + + + + + } + + @Override + public void publish(String topic, String message) throws MqttException { + mqttLifecycleManager.publish(topic, message, 0); + } + + @Override + public void publish(String topic, String message, int qos) throws MqttException { + mqttLifecycleManager.publish(topic, message, qos); + } + + @Override + public void subscribe(String topic, int qos, IMqttMessageListener listener) { + mqttLifecycleManager.subscribe(topic, qos, listener); + + + } + + // 发送设备控制命令 + public void sendDeviceCommand(String deviceId, String command) { + try { + String topic = "devices/" + deviceId + "/commands"; + publish(topic, command, 1); + } catch (MqttException e) { + System.err.println("Failed to send command to device " + deviceId); + } + } +} \ No newline at end of file diff --git a/ems-admin/src/main/resources/application.yml b/ems-admin/src/main/resources/application.yml index 58d7acb..9a02bd4 100644 --- a/ems-admin/src/main/resources/application.yml +++ b/ems-admin/src/main/resources/application.yml @@ -127,3 +127,12 @@ xss: excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* + +mqtt: + broker.url: tcp://122.51.194.184:1883 + client.id: ems-cloud + username: admin + password: pass123 + connection-timeout: 15 + keep-alive-interval: 30 + automatic-reconnect: true \ No newline at end of file diff --git a/ems-framework/pom.xml b/ems-framework/pom.xml index bc71b9a..06a1274 100644 --- a/ems-framework/pom.xml +++ b/ems-framework/pom.xml @@ -46,7 +46,10 @@ - + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + com.github.oshi @@ -58,6 +61,11 @@ com.xzzn ems-system + + org.projectlombok + lombok + provided + diff --git a/ems-framework/src/main/java/com/xzzn/framework/config/MqttConfig.java b/ems-framework/src/main/java/com/xzzn/framework/config/MqttConfig.java new file mode 100644 index 0000000..53cd2d5 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/config/MqttConfig.java @@ -0,0 +1,31 @@ +package com.xzzn.framework.config; + +import com.xzzn.framework.config.properties.MqttProperties; +import org.eclipse.paho.client.mqttv3.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.Resource; + +@Configuration +public class MqttConfig { + private static final Logger logger = LoggerFactory.getLogger(MqttConfig.class); + + @Resource + private MqttProperties mqttProperties; + @Bean + public MqttConnectOptions mqttConnectOptions() { + MqttConnectOptions options = new MqttConnectOptions(); + options.setServerURIs(new String[]{mqttProperties.getBrokerUrl()}); + if (!mqttProperties.getUsername().isEmpty()) options.setUserName(mqttProperties.getUsername()); + if (!mqttProperties.getPassword().isEmpty()) options.setPassword(mqttProperties.getPassword().toCharArray()); + options.setConnectionTimeout(mqttProperties.getConnectionTimeout()); + options.setKeepAliveInterval(mqttProperties.getKeepAliveInterval()); + options.setAutomaticReconnect(mqttProperties.isAutomaticReconnect()); + options.setCleanSession(true); + return options; + } + +} diff --git a/ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java b/ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java new file mode 100644 index 0000000..f751596 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java @@ -0,0 +1,31 @@ +package com.xzzn.framework.config.properties; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Data +@Configuration +public class MqttProperties { + @Value("${mqtt.broker.url}") + private String brokerUrl; + + @Value("${mqtt.client.id:}") + private String clientId; + + @Value("${mqtt.username:}") + private String username; + + @Value("${mqtt.password:}") + private String password; + + @Value("${mqtt.connection-timeout:10}") + private int connectionTimeout; + + @Value("${mqtt.keep-alive-interval:60}") + private int keepAliveInterval; + + @Value("${mqtt.automatic-reconnect:true}") + private boolean automaticReconnect; + +} diff --git a/ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java b/ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java new file mode 100644 index 0000000..234382a --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java @@ -0,0 +1,155 @@ +package com.xzzn.framework.manager; + +import org.eclipse.paho.client.mqttv3.*; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.context.SmartLifecycle; +import org.springframework.stereotype.Component; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +@Component +public class MqttLifecycleManager implements ApplicationRunner, SmartLifecycle, MqttCallback { + + private final MqttConnectOptions connectOptions; + private MqttClient mqttClient; + private volatile boolean running = false; + + // 存储订阅关系: topic -> (listener, qos) + private final ConcurrentHashMap subscriptions = new ConcurrentHashMap<>(); + + @Autowired + public MqttLifecycleManager(MqttConnectOptions connectOptions) { + this.connectOptions = connectOptions; + } + + // Spring Boot 启动完成后执行 + @Override + public void run(ApplicationArguments args) throws Exception { + start(); + } + + @Override + public void start() { + if (running) return; + + try { + String clientId = connectOptions.getUserName() + "-" + System.currentTimeMillis(); + mqttClient = new MqttClient( + connectOptions.getServerURIs()[0], + clientId, + new MemoryPersistence() + ); + + mqttClient.setCallback(this); + mqttClient.connect(connectOptions); + + // 重连后自动重新订阅 + resubscribeAll(); + + running = true; + System.out.println("MQTT client connected to: " + connectOptions.getServerURIs()[0]); + } catch (MqttException e) { + System.err.println("MQTT connection failed: " + e.getMessage()); + // 添加重试逻辑 + } + } + + @Override + public void stop() { + if (mqttClient != null && mqttClient.isConnected()) { + try { + mqttClient.disconnect(); + mqttClient.close(); + } catch (MqttException e) { + System.err.println("Error disconnecting MQTT client: " + e.getMessage()); + } + } + running = false; + } + + @Override + public boolean isRunning() { + return running; + } + + // MQTT 回调方法 + @Override + public void connectionLost(Throwable cause) { + System.err.println("MQTT connection lost: " + cause.getMessage()); + running = false; + // 自动重连由 MqttConnectOptions 处理 + } + + @Override + public void messageArrived(String topic, MqttMessage message) throws Exception { + SubscriptionInfo info = subscriptions.get(topic); + if (info != null && info.getListener() != null) { + info.getListener().messageArrived(topic, message); + } + } + + @Override + public void deliveryComplete(IMqttDeliveryToken token) { + // 消息发布完成处理 + } + + // 订阅方法 + public void subscribe(String topic, int qos, IMqttMessageListener listener) { + try { + if (mqttClient != null && mqttClient.isConnected()) { + mqttClient.subscribe(topic, qos); + } + subscriptions.put(topic, new SubscriptionInfo(listener, qos)); + } catch (MqttException e) { + System.err.println("Subscribe failed: " + e.getMessage()); + } + } + + // 发布方法 + public void publish(String topic, String payload, int qos) throws MqttException { + if (mqttClient != null && mqttClient.isConnected()) { + MqttMessage message = new MqttMessage(payload.getBytes()); + message.setQos(qos); + mqttClient.publish(topic, message); + } else { + throw new MqttException(MqttException.REASON_CODE_CLIENT_NOT_CONNECTED); + } + } + + // 重新订阅所有主题 + private void resubscribeAll() { + if (mqttClient == null || !mqttClient.isConnected()) return; + + subscriptions.forEach((topic, info) -> { + try { + mqttClient.subscribe(topic, info.getQos()); + } catch (MqttException e) { + System.err.println("Resubscribe failed for topic: " + topic); + } + }); + } + + // 订阅信息内部类 + private static class SubscriptionInfo { + private final IMqttMessageListener listener; + private final int qos; + + public SubscriptionInfo(IMqttMessageListener listener, int qos) { + this.listener = listener; + this.qos = qos; + } + + public IMqttMessageListener getListener() { + return listener; + } + + public int getQos() { + return qos; + } + } +} \ No newline at end of file diff --git a/ems-framework/src/main/java/com/xzzn/framework/web/service/MqttPublisher.java b/ems-framework/src/main/java/com/xzzn/framework/web/service/MqttPublisher.java new file mode 100644 index 0000000..927d44e --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/web/service/MqttPublisher.java @@ -0,0 +1,8 @@ +package com.xzzn.framework.web.service; + +import org.eclipse.paho.client.mqttv3.MqttException; + +public interface MqttPublisher { + void publish(String topic, String message) throws MqttException; + void publish(String topic, String message, int qos) throws MqttException; +} diff --git a/ems-framework/src/main/java/com/xzzn/framework/web/service/MqttSubscriber.java b/ems-framework/src/main/java/com/xzzn/framework/web/service/MqttSubscriber.java new file mode 100644 index 0000000..bf2c3be --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/web/service/MqttSubscriber.java @@ -0,0 +1,7 @@ +package com.xzzn.framework.web.service; + +import org.eclipse.paho.client.mqttv3.IMqttMessageListener; + +public interface MqttSubscriber { + void subscribe(String topic, int qos, IMqttMessageListener listener); +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index dfc25b0..ee188eb 100644 --- a/pom.xml +++ b/pom.xml @@ -154,6 +154,16 @@ poi-ooxml ${poi.version} + + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + 1.2.5 + + + org.springframework.integration + spring-integration-mqtt + -- 2.49.0 From 31dc8e72c69814542939154d03cda8b6d71658e5 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Fri, 27 Jun 2025 14:07:45 +0800 Subject: [PATCH 003/336] =?UTF-8?q?mqtt=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 52 ++++++++-- .../com/xzzn/ems/domain/EmsMqttMessage.java | 71 ++++++++++++++ .../xzzn/ems/mapper/EmsMqttMessageMapper.java | 62 ++++++++++++ .../ems/service/IEmsMqttMessageService.java | 62 ++++++++++++ .../impl/EmsMqttMessageServiceImpl.java | 96 +++++++++++++++++++ .../mapper/ems/EmsMqttMessageMapper.xml | 79 +++++++++++++++ 6 files changed, 413 insertions(+), 9 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttMessage.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttMessageMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsMqttMessageMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index aec61ae..e0d989a 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -1,8 +1,13 @@ package com.xzzn.web.controller.ems; +import com.xzzn.ems.domain.EmsMqttMessage; +import com.xzzn.ems.service.IEmsMqttMessageService; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.framework.web.service.MqttSubscriber; +import org.apache.coyote.http11.Http11NioProtocol; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; @@ -14,8 +19,16 @@ import javax.annotation.PostConstruct; @Service public class MqttMessageController implements MqttPublisher, MqttSubscriber { + + private static final Log log = LogFactory.getLog(MqttMessageController.class); + + private final MqttLifecycleManager mqttLifecycleManager; + @Autowired + private IEmsMqttMessageService emsMqttMessageService; + + @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { this.mqttLifecycleManager = mqttLifecycleManager; @@ -24,29 +37,50 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @PostConstruct public void init() { // 订阅系统状态主题 - subscribe("system/status", 1, this::handleSystemStatus); + subscribe("021_FXX_01_UP", 1, this::handleDeviceData); + subscribe("021_FXX_01_RECALL", 1, this::handleDeviceData); + subscribe("021_FXX_01_DOWN", 1, this::handleDeviceData); + subscribe("021_FXX_01", 1, this::handleSystemStatus); - // 订阅设备数据主题 - subscribe("devices/data", 0, this::handleDeviceData); } // 处理系统状态消息 private void handleSystemStatus(String topic, MqttMessage message) { String payload = new String(message.getPayload()); System.out.println("[SYSTEM] Status update: " + payload); - // 业务处理逻辑 - + try { + // 业务处理逻辑 + EmsMqttMessage mqttMessage = new EmsMqttMessage(); + mqttMessage.setMqttTopic(topic); + mqttMessage.setMqttMessage(payload); + mqttMessage.setCreateTime(new java.util.Date()); + mqttMessage.setUpdateTime(new java.util.Date()); + mqttMessage.setCreateBy("system"); + mqttMessage.setUpdateBy("system"); + emsMqttMessageService.insertEmsMqttMessage(mqttMessage); + } catch (Exception e) { + log.error("Failed to process system status message: " + e.getMessage(), e); + } } // 处理设备数据 private void handleDeviceData(String topic, MqttMessage message) { String payload = new String(message.getPayload()); System.out.println("[DEVICE] data: " + payload); - // 业务处理逻辑 - - - + try { + // 业务处理逻辑 + EmsMqttMessage mqttMessage = new EmsMqttMessage(); + mqttMessage.setMqttTopic(topic); + mqttMessage.setMqttMessage(payload); + mqttMessage.setCreateTime(new java.util.Date()); + mqttMessage.setUpdateTime(new java.util.Date()); + mqttMessage.setCreateBy("system"); + mqttMessage.setUpdateBy("system"); + emsMqttMessageService.insertEmsMqttMessage(mqttMessage); + } catch (Exception e) { + log.error("Failed to process system status message: " + e.getMessage(), e); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttMessage.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttMessage.java new file mode 100644 index 0000000..b9828ca --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttMessage.java @@ -0,0 +1,71 @@ +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_mqtt_message + * + * @author xzzn + * @date 2025-06-27 + */ +public class EmsMqttMessage extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String mqttTopic; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String mqttMessage; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setMqttTopic(String mqttTopic) + { + this.mqttTopic = mqttTopic; + } + + public String getMqttTopic() + { + return mqttTopic; + } + + public void setMqttMessage(String mqttMessage) + { + this.mqttMessage = mqttMessage; + } + + public String getMqttMessage() + { + return mqttMessage; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("mqttTopic", getMqttTopic()) + .append("mqttMessage", getMqttMessage()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttMessageMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttMessageMapper.java new file mode 100644 index 0000000..adf7841 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttMessageMapper.java @@ -0,0 +1,62 @@ +package com.xzzn.ems.mapper; + +import com.xzzn.ems.domain.EmsMqttMessage; + +import java.util.List; + +/** + * 【请填写功能名称】Mapper接口 + * + * @author xzzn + * @date 2025-06-27 + */ +public interface EmsMqttMessageMapper +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public EmsMqttMessage selectEmsMqttMessageById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectEmsMqttMessageList(EmsMqttMessage emsMqttMessage); + + /** + * 新增【请填写功能名称】 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 结果 + */ + public int insertEmsMqttMessage(EmsMqttMessage emsMqttMessage); + + /** + * 修改【请填写功能名称】 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 结果 + */ + public int updateEmsMqttMessage(EmsMqttMessage emsMqttMessage); + + /** + * 删除【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteEmsMqttMessageById(Long id); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsMqttMessageByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java new file mode 100644 index 0000000..c7355cb --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java @@ -0,0 +1,62 @@ +package com.xzzn.ems.service; + +import com.xzzn.ems.domain.EmsMqttMessage; + +import java.util.List; + +/** + * 【请填写功能名称】Service接口 + * + * @author xzzn + * @date 2025-06-27 + */ +public interface IEmsMqttMessageService +{ + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + public EmsMqttMessage selectEmsMqttMessageById(Long id); + + /** + * 查询【请填写功能名称】列表 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 【请填写功能名称】集合 + */ + public List selectEmsMqttMessageList(EmsMqttMessage emsMqttMessage); + + /** + * 新增【请填写功能名称】 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 结果 + */ + public int insertEmsMqttMessage(EmsMqttMessage emsMqttMessage); + + /** + * 修改【请填写功能名称】 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 结果 + */ + public int updateEmsMqttMessage(EmsMqttMessage emsMqttMessage); + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键集合 + * @return 结果 + */ + public int deleteEmsMqttMessageByIds(Long[] ids); + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + public int deleteEmsMqttMessageById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java new file mode 100644 index 0000000..8c6e158 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.EmsMqttMessage; +import com.xzzn.ems.mapper.EmsMqttMessageMapper; +import com.xzzn.ems.service.IEmsMqttMessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 【请填写功能名称】Service业务层处理 + * + * @author xzzn + * @date 2025-06-27 + */ +@Service +public class EmsMqttMessageServiceImpl implements IEmsMqttMessageService +{ + @Autowired + private EmsMqttMessageMapper emsMqttMessageMapper; + + /** + * 查询【请填写功能名称】 + * + * @param id 【请填写功能名称】主键 + * @return 【请填写功能名称】 + */ + @Override + public EmsMqttMessage selectEmsMqttMessageById(Long id) + { + return emsMqttMessageMapper.selectEmsMqttMessageById(id); + } + + /** + * 查询【请填写功能名称】列表 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 【请填写功能名称】 + */ + @Override + public List selectEmsMqttMessageList(EmsMqttMessage emsMqttMessage) + { + return emsMqttMessageMapper.selectEmsMqttMessageList(emsMqttMessage); + } + + /** + * 新增【请填写功能名称】 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 结果 + */ + @Override + public int insertEmsMqttMessage(EmsMqttMessage emsMqttMessage) + { + emsMqttMessage.setCreateTime(DateUtils.getNowDate()); + return emsMqttMessageMapper.insertEmsMqttMessage(emsMqttMessage); + } + + /** + * 修改【请填写功能名称】 + * + * @param emsMqttMessage 【请填写功能名称】 + * @return 结果 + */ + @Override + public int updateEmsMqttMessage(EmsMqttMessage emsMqttMessage) + { + emsMqttMessage.setUpdateTime(DateUtils.getNowDate()); + return emsMqttMessageMapper.updateEmsMqttMessage(emsMqttMessage); + } + + /** + * 批量删除【请填写功能名称】 + * + * @param ids 需要删除的【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteEmsMqttMessageByIds(Long[] ids) + { + return emsMqttMessageMapper.deleteEmsMqttMessageByIds(ids); + } + + /** + * 删除【请填写功能名称】信息 + * + * @param id 【请填写功能名称】主键 + * @return 结果 + */ + @Override + public int deleteEmsMqttMessageById(Long id) + { + return emsMqttMessageMapper.deleteEmsMqttMessageById(id); + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsMqttMessageMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsMqttMessageMapper.xml new file mode 100644 index 0000000..c101d13 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsMqttMessageMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + select id, mqtt_topic, mqtt_message, create_by, create_time, update_by, update_time from ems_mqtt_message + + + + + + + + insert into ems_mqtt_message + + id, + mqtt_topic, + mqtt_message, + create_by, + create_time, + update_by, + update_time, + + + #{id}, + #{mqttTopic}, + #{mqttMessage}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update ems_mqtt_message + + mqtt_topic = #{mqttTopic}, + mqtt_message = #{mqttMessage}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from ems_mqtt_message where id = #{id} + + + + delete from ems_mqtt_message where id in + + #{id} + + + \ No newline at end of file -- 2.49.0 From 365dd819b5e3d539865a6ce1f0bb5a89ad651219 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Fri, 27 Jun 2025 17:08:26 +0800 Subject: [PATCH 004/336] =?UTF-8?q?=E5=A5=89=E8=B4=A4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 91 ++++++++++++++++++ .../ems/service/IEmsBatteryDataService.java | 62 ++++++++++++ .../xzzn/ems/service/IEmsPcsDataService.java | 62 ++++++++++++ .../impl/EmsBatteryDataServiceImpl.java | 96 +++++++++++++++++++ .../service/impl/EmsPcsDataServiceImpl.java | 96 +++++++++++++++++++ 5 files changed, 407 insertions(+) create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsDataService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsDataServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index e0d989a..30d5de0 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -1,7 +1,17 @@ package com.xzzn.web.controller.ems; +import com.alibaba.druid.support.json.JSONParser; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.alibaba.fastjson2.TypeReference; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsMqttMessage; +import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.service.IEmsBatteryDataService; import com.xzzn.ems.service.IEmsMqttMessageService; +import com.xzzn.ems.service.IEmsPcsDataService; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.framework.web.service.MqttSubscriber; @@ -15,6 +25,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @Service public class MqttMessageController implements MqttPublisher, MqttSubscriber { @@ -28,6 +43,11 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IEmsMqttMessageService emsMqttMessageService; + @Autowired + private IEmsBatteryDataService emsBatteryDataService; + + @Autowired + private IEmsPcsDataService emsPcsDataService; @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { @@ -70,6 +90,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[DEVICE] data: " + payload); try { // 业务处理逻辑 +// handleFxData(JSONArray.parseArray(payload).get(0).toString()); + EmsMqttMessage mqttMessage = new EmsMqttMessage(); mqttMessage.setMqttTopic(topic); mqttMessage.setMqttMessage(payload); @@ -110,4 +132,73 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.err.println("Failed to send command to device " + deviceId); } } + + + private void handleFxData(String message) { + + + List upAll = JSON.parseObject(message, new TypeReference>() {}); + + for (int i = 0; i < upAll.size(); i++) { + JSONObject obj = JSONObject.parseObject(upAll.get(i)); + + String deviceId = obj.get("Device").toString(); + String jsonData = obj.get("Data").toString(); + + + if (deviceId.contains("BMS")) { + Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); + + //单体电池 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsBatteryData data = new EmsBatteryData(); + data.setDeviceId(Long.parseLong(recordId)); + data.setBatteryCellId(recordId); + data.setSoc(new BigDecimal(fields.get("DTSOC").toString())); + data.setSoh(new BigDecimal(fields.get("DTSOH").toString())); + data.setTemperature(new BigDecimal(fields.get("DTWD").toString())); + data.setVoltage(new BigDecimal(fields.get("DTDY").toString())); + + data.setBatteryCluster(deviceId); + data.setBatteryPack(deviceId); + emsBatteryDataService.insertEmsBatteryData(data); + } + } else if (deviceId.contains("PCS")) { + //pcs + EmsPcsData data = new EmsPcsData(); + + + + + + emsPcsDataService.insertEmsPcsData(data); + + } + + } + + + } + + // 数据分组处理 + private static Map> processData(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 提取记录ID(最后3位) + String recordId = key.substring(key.length() - 3); + // 提取字段类型(前缀) + String fieldType = key.substring(0, key.length() - 3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + return records; + } } \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java new file mode 100644 index 0000000..d694c11 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java @@ -0,0 +1,62 @@ +package com.xzzn.ems.service; + +import com.xzzn.ems.domain.EmsBatteryData; + +import java.util.List; + +/** + * 单体电池实时数据Service接口 + * + * @author xzzn + * @date 2025-06-27 + */ +public interface IEmsBatteryDataService +{ + /** + * 查询单体电池实时数据 + * + * @param id 单体电池实时数据主键 + * @return 单体电池实时数据 + */ + public EmsBatteryData selectEmsBatteryDataById(Long id); + + /** + * 查询单体电池实时数据列表 + * + * @param emsBatteryData 单体电池实时数据 + * @return 单体电池实时数据集合 + */ + public List selectEmsBatteryDataList(EmsBatteryData emsBatteryData); + + /** + * 新增单体电池实时数据 + * + * @param emsBatteryData 单体电池实时数据 + * @return 结果 + */ + public int insertEmsBatteryData(EmsBatteryData emsBatteryData); + + /** + * 修改单体电池实时数据 + * + * @param emsBatteryData 单体电池实时数据 + * @return 结果 + */ + public int updateEmsBatteryData(EmsBatteryData emsBatteryData); + + /** + * 批量删除单体电池实时数据 + * + * @param ids 需要删除的单体电池实时数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryDataByIds(Long[] ids); + + /** + * 删除单体电池实时数据信息 + * + * @param id 单体电池实时数据主键 + * @return 结果 + */ + public int deleteEmsBatteryDataById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsDataService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsDataService.java new file mode 100644 index 0000000..bff774d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsDataService.java @@ -0,0 +1,62 @@ +package com.xzzn.ems.service; + +import com.xzzn.ems.domain.EmsPcsData; + +import java.util.List; + +/** + * PCS数据Service接口 + * + * @author xzzn + * @date 2025-06-27 + */ +public interface IEmsPcsDataService +{ + /** + * 查询PCS数据 + * + * @param id PCS数据主键 + * @return PCS数据 + */ + public EmsPcsData selectEmsPcsDataById(Long id); + + /** + * 查询PCS数据列表 + * + * @param emsPcsData PCS数据 + * @return PCS数据集合 + */ + public List selectEmsPcsDataList(EmsPcsData emsPcsData); + + /** + * 新增PCS数据 + * + * @param emsPcsData PCS数据 + * @return 结果 + */ + public int insertEmsPcsData(EmsPcsData emsPcsData); + + /** + * 修改PCS数据 + * + * @param emsPcsData PCS数据 + * @return 结果 + */ + public int updateEmsPcsData(EmsPcsData emsPcsData); + + /** + * 批量删除PCS数据 + * + * @param ids 需要删除的PCS数据主键集合 + * @return 结果 + */ + public int deleteEmsPcsDataByIds(Long[] ids); + + /** + * 删除PCS数据信息 + * + * @param id PCS数据主键 + * @return 结果 + */ + public int deleteEmsPcsDataById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java new file mode 100644 index 0000000..562eb7c --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.EmsBatteryData; +import com.xzzn.ems.mapper.EmsBatteryDataMapper; +import com.xzzn.ems.service.IEmsBatteryDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 单体电池实时数据Service业务层处理 + * + * @author xzzn + * @date 2025-06-27 + */ +@Service +public class EmsBatteryDataServiceImpl implements IEmsBatteryDataService +{ + @Autowired + private EmsBatteryDataMapper emsBatteryDataMapper; + + /** + * 查询单体电池实时数据 + * + * @param id 单体电池实时数据主键 + * @return 单体电池实时数据 + */ + @Override + public EmsBatteryData selectEmsBatteryDataById(Long id) + { + return emsBatteryDataMapper.selectEmsBatteryDataById(id); + } + + /** + * 查询单体电池实时数据列表 + * + * @param emsBatteryData 单体电池实时数据 + * @return 单体电池实时数据 + */ + @Override + public List selectEmsBatteryDataList(EmsBatteryData emsBatteryData) + { + return emsBatteryDataMapper.selectEmsBatteryDataList(emsBatteryData); + } + + /** + * 新增单体电池实时数据 + * + * @param emsBatteryData 单体电池实时数据 + * @return 结果 + */ + @Override + public int insertEmsBatteryData(EmsBatteryData emsBatteryData) + { + emsBatteryData.setCreateTime(DateUtils.getNowDate()); + return emsBatteryDataMapper.insertEmsBatteryData(emsBatteryData); + } + + /** + * 修改单体电池实时数据 + * + * @param emsBatteryData 单体电池实时数据 + * @return 结果 + */ + @Override + public int updateEmsBatteryData(EmsBatteryData emsBatteryData) + { + emsBatteryData.setUpdateTime(DateUtils.getNowDate()); + return emsBatteryDataMapper.updateEmsBatteryData(emsBatteryData); + } + + /** + * 批量删除单体电池实时数据 + * + * @param ids 需要删除的单体电池实时数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryDataByIds(Long[] ids) + { + return emsBatteryDataMapper.deleteEmsBatteryDataByIds(ids); + } + + /** + * 删除单体电池实时数据信息 + * + * @param id 单体电池实时数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryDataById(Long id) + { + return emsBatteryDataMapper.deleteEmsBatteryDataById(id); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsDataServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsDataServiceImpl.java new file mode 100644 index 0000000..d3c1ba0 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsDataServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.mapper.EmsPcsDataMapper; +import com.xzzn.ems.service.IEmsPcsDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * PCS数据Service业务层处理 + * + * @author xzzn + * @date 2025-06-27 + */ +@Service +public class EmsPcsDataServiceImpl implements IEmsPcsDataService +{ + @Autowired + private EmsPcsDataMapper emsPcsDataMapper; + + /** + * 查询PCS数据 + * + * @param id PCS数据主键 + * @return PCS数据 + */ + @Override + public EmsPcsData selectEmsPcsDataById(Long id) + { + return emsPcsDataMapper.selectEmsPcsDataById(id); + } + + /** + * 查询PCS数据列表 + * + * @param emsPcsData PCS数据 + * @return PCS数据 + */ + @Override + public List selectEmsPcsDataList(EmsPcsData emsPcsData) + { + return emsPcsDataMapper.selectEmsPcsDataList(emsPcsData); + } + + /** + * 新增PCS数据 + * + * @param emsPcsData PCS数据 + * @return 结果 + */ + @Override + public int insertEmsPcsData(EmsPcsData emsPcsData) + { + emsPcsData.setCreateTime(DateUtils.getNowDate()); + return emsPcsDataMapper.insertEmsPcsData(emsPcsData); + } + + /** + * 修改PCS数据 + * + * @param emsPcsData PCS数据 + * @return 结果 + */ + @Override + public int updateEmsPcsData(EmsPcsData emsPcsData) + { + emsPcsData.setUpdateTime(DateUtils.getNowDate()); + return emsPcsDataMapper.updateEmsPcsData(emsPcsData); + } + + /** + * 批量删除PCS数据 + * + * @param ids 需要删除的PCS数据主键 + * @return 结果 + */ + @Override + public int deleteEmsPcsDataByIds(Long[] ids) + { + return emsPcsDataMapper.deleteEmsPcsDataByIds(ids); + } + + /** + * 删除PCS数据信息 + * + * @param id PCS数据主键 + * @return 结果 + */ + @Override + public int deleteEmsPcsDataById(Long id) + { + return emsPcsDataMapper.deleteEmsPcsDataById(id); + } +} -- 2.49.0 From 73f62c8fa5086b1e51ab55c8ed12154d0a68260e Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 28 Jun 2025 14:56:22 +0800 Subject: [PATCH 005/336] =?UTF-8?q?=E5=8D=95=E7=AB=99=E7=9B=91=E6=8E=A7-?= =?UTF-8?q?=E7=94=B5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 11 +- .../com/xzzn/ems/domain/EmsAmmeterData.java | 166 ++++++++++++++++++ .../ems/domain/vo/AmmeterDataDetailInfo.java | 98 +++++++++++ .../com/xzzn/ems/domain/vo/AmmeterDataVo.java | 45 +++++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 69 ++++++++ .../ems/mapper/EmsDevicesSettingMapper.java | 7 + .../com/xzzn/ems/service/IEmsSiteService.java | 3 +- .../xzzn/ems/service/ISingleSiteService.java | 4 + .../ems/service/impl/EmsSiteServiceImpl.java | 15 +- .../service/impl/SingleSiteServiceImpl.java | 41 ++++- .../mapper/ems/EmsAmmeterDataMapper.xml | 125 +++++++++++++ .../mapper/ems/EmsDevicesSettingMapper.xml | 6 + 12 files changed, 576 insertions(+), 14 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index d664700..91fbdd1 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -108,6 +108,15 @@ public class EmsSiteMonitorController extends BaseController{ @GetMapping("/getClusterDataInfoList") public AjaxResult getClusterDataInfoList(@RequestParam Long clusterDeviceId) { - return success(iEmsSiteService.getClusterDataInfoList(clusterDeviceId)); + return success(iSingleSiteService.getClusterDataInfoList(clusterDeviceId)); + } + + /** + * 电表数据 + */ + @GetMapping("/getAmmeterDataList") + public AjaxResult getAmmeterDataList(@RequestParam Long siteId) + { + return success(iSingleSiteService.getAmmeterDataList(siteId)); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java new file mode 100644 index 0000000..a110ce9 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java @@ -0,0 +1,166 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_ammeter_data + * + * @author xzzn + * @date 2025-06-27 + */ +public class EmsAmmeterData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataUpdateTime; + + /** 类别 */ + @Excel(name = "类别") + private String category; + + /** 总 (kWh) */ + @Excel(name = "总 (kWh)") + private BigDecimal totalKwh; + + /** 峰 (kWh) */ + @Excel(name = "峰 (kWh)") + private BigDecimal peakKwh; + + /** 平 (kWh) */ + @Excel(name = "平 (kWh)") + private BigDecimal flatKwh; + + /** 谷 (kWh) */ + @Excel(name = "谷 (kWh)") + private BigDecimal valleyKwh; + + /** 站点id */ + @Excel(name = "站点id") + private Long siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private Long deviceId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setDataUpdateTime(Date dataUpdateTime) + { + this.dataUpdateTime = dataUpdateTime; + } + + public Date getDataUpdateTime() + { + return dataUpdateTime; + } + + public void setCategory(String category) + { + this.category = category; + } + + public String getCategory() + { + return category; + } + + public void setTotalKwh(BigDecimal totalKwh) + { + this.totalKwh = totalKwh; + } + + public BigDecimal getTotalKwh() + { + return totalKwh; + } + + public void setPeakKwh(BigDecimal peakKwh) + { + this.peakKwh = peakKwh; + } + + public BigDecimal getPeakKwh() + { + return peakKwh; + } + + public void setFlatKwh(BigDecimal flatKwh) + { + this.flatKwh = flatKwh; + } + + public BigDecimal getFlatKwh() + { + return flatKwh; + } + + public void setValleyKwh(BigDecimal valleyKwh) + { + this.valleyKwh = valleyKwh; + } + + public BigDecimal getValleyKwh() + { + return valleyKwh; + } + + public void setSiteId(Long siteId) + { + this.siteId = siteId; + } + + public Long getSiteId() + { + return siteId; + } + + public void setDeviceId(Long deviceId) + { + this.deviceId = deviceId; + } + + public Long getDeviceId() + { + return deviceId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dataUpdateTime", getDataUpdateTime()) + .append("category", getCategory()) + .append("totalKwh", getTotalKwh()) + .append("peakKwh", getPeakKwh()) + .append("flatKwh", getFlatKwh()) + .append("valleyKwh", getValleyKwh()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java new file mode 100644 index 0000000..6f15ca1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java @@ -0,0 +1,98 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 总表详细数据 + */ +public class AmmeterDataDetailInfo +{ + /** 类别 */ + private String category; + + /** 总 (kWh) */ + private BigDecimal totalKwh; + + /** 尖 (kWh) */ + private BigDecimal sharpKwh; + + /** 峰 (kWh) */ + private BigDecimal peakKwh; + + /** 平 (kWh) */ + private BigDecimal flatKwh; + + /** 谷 (kWh) */ + private BigDecimal valleyKwh; + + /** 总表设备Id */ + private Long deviceId; + + /** 数据更新时间 */ + private Date updateTime; + + public BigDecimal getValleyKwh() { + return valleyKwh; + } + + public void setValleyKwh(BigDecimal valleyKwh) { + this.valleyKwh = valleyKwh; + } + + public BigDecimal getFlatKwh() { + return flatKwh; + } + + public void setFlatKwh(BigDecimal flatKwh) { + this.flatKwh = flatKwh; + } + + public BigDecimal getPeakKwh() { + return peakKwh; + } + + public void setPeakKwh(BigDecimal peakKwh) { + this.peakKwh = peakKwh; + } + + public BigDecimal getSharpKwh() { + return sharpKwh; + } + + public void setSharpKwh(BigDecimal sharpKwh) { + this.sharpKwh = sharpKwh; + } + + public BigDecimal getTotalKwh() { + return totalKwh; + } + + public void setTotalKwh(BigDecimal totalKwh) { + this.totalKwh = totalKwh; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Long getDeviceId() { + return deviceId; + } + + public void setDeviceId(Long deviceId) { + this.deviceId = deviceId; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java new file mode 100644 index 0000000..5993239 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java @@ -0,0 +1,45 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; +import java.util.List; + +/** + * 电表数据 + */ +public class AmmeterDataVo { + + /** 通信状态 */ + private String emsCommunicationStatus; + + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date dataUpdateTime; + + private List ammeterDataDetailInfos; + + public String getEmsCommunicationStatus() { + return emsCommunicationStatus; + } + + public void setEmsCommunicationStatus(String emsCommunicationStatus) { + this.emsCommunicationStatus = emsCommunicationStatus; + } + + public Date getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(Date dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + + public List getAmmeterDataDetailInfos() { + return ammeterDataDetailInfos; + } + + public void setAmmeterDataDetailInfos(List ammeterDataDetailInfos) { + this.ammeterDataDetailInfos = ammeterDataDetailInfos; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java new file mode 100644 index 0000000..2cf34aa --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -0,0 +1,69 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsAmmeterData; +import com.xzzn.ems.domain.vo.AmmeterDataDetailInfo; + +/** + * 总数据Mapper接口 + * + * @author xzzn + * @date 2025-06-27 + */ +public interface EmsAmmeterDataMapper +{ + /** + * 查询总数据 + * + * @param id 总数据主键 + * @return 总数据 + */ + public EmsAmmeterData selectEmsAmmeterDataById(Long id); + + /** + * 查询总数据列表 + * + * @param emsAmmeterData 总数据 + * @return 总数据集合 + */ + public List selectEmsAmmeterDataList(EmsAmmeterData emsAmmeterData); + + /** + * 新增总数据 + * + * @param emsAmmeterData 总数据 + * @return 结果 + */ + public int insertEmsAmmeterData(EmsAmmeterData emsAmmeterData); + + /** + * 修改总数据 + * + * @param emsAmmeterData 总数据 + * @return 结果 + */ + public int updateEmsAmmeterData(EmsAmmeterData emsAmmeterData); + + /** + * 删除总数据 + * + * @param id 总数据主键 + * @return 结果 + */ + public int deleteEmsAmmeterDataById(Long id); + + /** + * 批量删除总数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsAmmeterDataByIds(Long[] ids); + + /** + * 获取总表详细数据 + * @param siteId + * @return + */ + public List getAmmeterDetailInfo(Long siteId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 5a7f172..8002a45 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -74,4 +74,11 @@ public interface EmsDevicesSettingMapper * @return */ public List> getAllClusterInfoByStackId(Long stackDeviceId); + + /** + * 获取设备通信状态 + * @param deviceId + * @return + */ + public Map getDeviceStatus(Long deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index eff7a91..8bdd27b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -1,7 +1,6 @@ package com.xzzn.ems.service; import com.xzzn.ems.domain.EmsSiteSetting; -import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import java.util.List; @@ -23,5 +22,5 @@ public interface IEmsSiteService public List> getAllClusterInfo(Long stackDeviceId); - public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId); + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index b0a3221..a871b3e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -26,4 +26,8 @@ public interface ISingleSiteService public List getBMSBatteryCluster(Long siteId); public List getCoolingDataList(Long siteId); + + public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId); + + public List getAmmeterDataList(Long siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index ba12178..98a2282 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -1,7 +1,6 @@ package com.xzzn.ems.service.impl; import com.xzzn.ems.domain.EmsSiteSetting; -import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsSiteSettingMapper; @@ -45,18 +44,14 @@ public class EmsSiteServiceImpl implements IEmsSiteService return emsDevicesMapper.getAllStackInfoBySiteId(siteId); } + /** + * 根据电池堆Id获取电池簇 + * @param stackDeviceId + * @return + */ @Override public List> getAllClusterInfo(Long stackDeviceId) { return emsDevicesMapper.getAllClusterInfoByStackId(stackDeviceId); } - /** - * 根据电池堆获取单体柱状数据 - * @param clusterDeviceId - * @return - */ - @Override - public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId) { - return null; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 922c81e..9c9fd63 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -11,7 +11,6 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; -import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; @@ -41,6 +40,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private EmsPcsBranchDataMapper emsPcsBranchDataMapper; @Autowired private EmsCoolingDataMapper emsCoolingDataMapper; + @Autowired + private EmsAmmeterDataMapper emsAmmeterDataMapper; + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; @Override public SiteMonitorHomeVo getSiteMonitorDataVo(Long siteId) { @@ -258,4 +261,40 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return emsCoolingDataList; } + + /** + * 根据电池堆获取单体柱状数据 + * @param clusterDeviceId + * @return + */ + @Override + public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId) { + return null; + } + + /** + * 电表数据信息 + * @param siteId + * @return + */ + @Override + public List getAmmeterDataList(Long siteId) { + List ammeterDataVos = new ArrayList<>(); + AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); + if (siteId != null) { + List ammeterDataDetailInfos = emsAmmeterDataMapper.getAmmeterDetailInfo(siteId); + ammeterDataVo.setAmmeterDataDetailInfos(ammeterDataDetailInfos); + if (!CollectionUtils.isEmpty(ammeterDataDetailInfos)) { + // 获取通信状态 + Long deviceId = ammeterDataDetailInfos.get(0).getDeviceId(); + Map map = emsDevicesSettingMapper.getDeviceStatus(deviceId); + ammeterDataVo.setEmsCommunicationStatus(map.get("communication_status").toString()); + // 数据更新时间 + ammeterDataVo.setDataUpdateTime(ammeterDataDetailInfos.get(0).getUpdateTime()); + } + } + ammeterDataVos.add(ammeterDataVo); + return ammeterDataVos; + } + } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml new file mode 100644 index 0000000..1e91afe --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, data_update_time, category, total_kwh, peak_kwh, flat_kwh, valley_kwh, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_ammeter_data + + + + + + + + insert into ems_ammeter_data + + data_update_time, + category, + total_kwh, + peak_kwh, + flat_kwh, + valley_kwh, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + + + #{dataUpdateTime}, + #{category}, + #{totalKwh}, + #{peakKwh}, + #{flatKwh}, + #{valleyKwh}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + + + + + update ems_ammeter_data + + data_update_time = #{dataUpdateTime}, + category = #{category}, + total_kwh = #{totalKwh}, + peak_kwh = #{peakKwh}, + flat_kwh = #{flatKwh}, + valley_kwh = #{valleyKwh}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + + where id = #{id} + + + + delete from ems_ammeter_data where id = #{id} + + + + delete from ems_ammeter_data where id in + + #{id} + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index a9f4f03..39598d2 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -145,4 +145,10 @@ from ems_devices_setting where id in (select distinct eb.device_id from ems_battery_cluster eb where eb.stack_device_id = #{stackDeviceId}) + + \ No newline at end of file -- 2.49.0 From 38e93c9681b4d4105f6f76df03b1c60c440ef4d7 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sat, 28 Jun 2025 21:11:23 +0800 Subject: [PATCH 006/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20device=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/web/controller/ems/MqttMessageController.java | 2 +- .../main/java/com/xzzn/ems/domain/EmsBatteryData.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 30d5de0..ce774f7 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -155,7 +155,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { Map fields = record.getValue(); EmsBatteryData data = new EmsBatteryData(); - data.setDeviceId(Long.parseLong(recordId)); + data.setDeviceId(recordId); data.setBatteryCellId(recordId); data.setSoc(new BigDecimal(fields.get("DTSOC").toString())); data.setSoh(new BigDecimal(fields.get("DTSOH").toString())); diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java index 8faf4fc..1847431 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java @@ -12,13 +12,13 @@ import com.xzzn.common.annotation.Excel; * 单体电池实时数据对象 ems_battery_data * * @author xzzn - * @date 2025-06-25 + * @date 2025-06-28 */ public class EmsBatteryData extends BaseEntity { private static final long serialVersionUID = 1L; - /** */ + /** $column.columnComment */ private Long id; /** 电池堆 */ @@ -60,7 +60,7 @@ public class EmsBatteryData extends BaseEntity /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; /** 簇设备id */ @Excel(name = "簇设备id") @@ -166,12 +166,12 @@ public class EmsBatteryData extends BaseEntity return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } -- 2.49.0 From 1a56bd652644a9ffb893025f5efea228399c3634 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sat, 28 Jun 2025 21:16:48 +0800 Subject: [PATCH 007/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20device=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/xzzn/ems/domain/EmsPcsData.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index 98c2c72..d815905 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -128,7 +128,7 @@ public class EmsPcsData extends BaseEntity /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; /** 月 */ @Excel(name = "月") @@ -408,12 +408,12 @@ public class EmsPcsData extends BaseEntity return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } -- 2.49.0 From 177e235c0ee515b5a0844551cc8e10054735e3c8 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sat, 28 Jun 2025 23:07:49 +0800 Subject: [PATCH 008/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20device=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 102 ++++++-- .../com/xzzn/common/utils/StringUtils.java | 12 + .../java/com/xzzn/ems/domain/EmsPcsData.java | 224 +++++++++++++++++- .../resources/mapper/ems/EmsPcsDataMapper.xml | 157 ++++++------ 4 files changed, 380 insertions(+), 115 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index ce774f7..4baff1c 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -6,6 +6,8 @@ import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; import com.fasterxml.jackson.databind.json.JsonMapper; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsMqttMessage; import com.xzzn.ems.domain.EmsPcsData; @@ -26,10 +28,7 @@ import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class MqttMessageController implements MqttPublisher, MqttSubscriber { @@ -90,7 +89,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[DEVICE] data: " + payload); try { // 业务处理逻辑 -// handleFxData(JSONArray.parseArray(payload).get(0).toString()); + handleFxData(payload); EmsMqttMessage mqttMessage = new EmsMqttMessage(); mqttMessage.setMqttTopic(topic); @@ -135,18 +134,19 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { private void handleFxData(String message) { + JSONArray arraylist = JSONArray.parseArray(message); - - List upAll = JSON.parseObject(message, new TypeReference>() {}); - - for (int i = 0; i < upAll.size(); i++) { - JSONObject obj = JSONObject.parseObject(upAll.get(i)); + for (int i = 0; i < arraylist.size(); i++) { + JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); String deviceId = obj.get("Device").toString(); String jsonData = obj.get("Data").toString(); - + log.info("deviceId:" + deviceId); if (deviceId.contains("BMS")) { + log.info("===================="); + log.info("BMS data:"+ jsonData); + Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); //单体电池 @@ -157,19 +157,85 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { EmsBatteryData data = new EmsBatteryData(); data.setDeviceId(recordId); data.setBatteryCellId(recordId); - data.setSoc(new BigDecimal(fields.get("DTSOC").toString())); - data.setSoh(new BigDecimal(fields.get("DTSOH").toString())); - data.setTemperature(new BigDecimal(fields.get("DTWD").toString())); - data.setVoltage(new BigDecimal(fields.get("DTDY").toString())); + data.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); + data.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); + data.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); + data.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); data.setBatteryCluster(deviceId); data.setBatteryPack(deviceId); + + // 时间戳 + data.setDataTimestamp(new Date()); + + // ID字段 + data.setSiteId(Long.parseLong("021")); + data.setClusterDeviceId(Long.parseLong("021")); + + emsBatteryDataService.insertEmsBatteryData(data); } } else if (deviceId.contains("PCS")) { + log.info("===================="); + + log.info("PCS data:"+ jsonData); //pcs EmsPcsData data = new EmsPcsData(); + // 时间与状态类字段 + data.setDataUpdateTime(new Date()); + data.setWorkStatus("A"); + data.setGridStatus("B"); + data.setDeviceStatus("C"); + data.setControlMode("D"); + // 功率与能量类字段 + data.setTotalActivePower(BigDecimal.ZERO); + data.setDailyAcChargeEnergy(BigDecimal.ZERO); + data.setTotalReactivePower(BigDecimal.ZERO); + data.setDailyAcDischargeEnergy(BigDecimal.ZERO); + data.setTotalApparentPower(BigDecimal.ZERO); + data.setTotalPowerFactor(BigDecimal.ZERO); + data.setDcPower(BigDecimal.ZERO); + data.setTotalAcChargeEnergy(BigDecimal.ZERO); + data.setTotalAcDischargeEnergy(BigDecimal.ZERO); + data.setAcChargeActivePower(BigDecimal.ZERO); + data.setAcCapacitiveReactivePower(BigDecimal.ZERO); + data.setAcDischargeActivePower(BigDecimal.ZERO); + data.setAcInductiveReactivePower(BigDecimal.ZERO); + data.setMaxCapacitivePowerCapacity(BigDecimal.ZERO); + data.setMaxInductivePowerCapacity(BigDecimal.ZERO); + data.setMaxChargePowerCapacity(BigDecimal.ZERO); + data.setMaxDischargePowerCapacity(BigDecimal.ZERO); + + + // 温度与环境参数 + data.setPcsModuleTemperature(BigDecimal.ZERO); + data.setPcsEnvironmentTemperature(BigDecimal.ZERO); + data.setAcFrequency(BigDecimal.ZERO); + + // 状态指示类 + data.setBranchStatus("A"); + data.setDischargeStatus("A"); + data.setAcSwitchStatus("A"); + data.setDcSwitchStatus("A"); + data.setRemoteControlStatus("A"); + + // 直流参数 + data.setDcVoltage(BigDecimal.ZERO); + data.setDcCurrent(BigDecimal.ZERO); + + // 系统管理字段 +// data.setCreateBy(BigDecimal.ZERO); +// data.setCreateTime(BigDecimal.ZERO); +// data.setUpdateBy(BigDecimal.ZERO); +// data.setUpdateTime(BigDecimal.ZERO); +// data.setRemark(BigDecimal.ZERO); + data.setSiteId(Long.parseLong("021")); + data.setDeviceId(deviceId); + data.setDateMonth(Long.parseLong("6")); + data.setDateDay(Long.parseLong("28")); + + data.setDeviceId(deviceId); @@ -191,6 +257,12 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { String key = entry.getKey(); // 提取记录ID(最后3位) String recordId = key.substring(key.length() - 3); + try { + Long.parseLong(recordId); + } catch (Exception e) { + continue; + } + // 提取字段类型(前缀) String fieldType = key.substring(0, key.length() - 3); diff --git a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java index bf29afe..0eb43f4 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java @@ -1,5 +1,6 @@ package com.xzzn.common.utils; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -719,4 +720,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } return sb.toString(); } + + + public static BigDecimal getBigDecimal(Object s){ + + try { + return new BigDecimal(s.toString()); + } catch (NumberFormatException e) { + return BigDecimal.ZERO; + } + + } } \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index d815905..1864b04 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * PCS数据对象 ems_pcs_data * * @author xzzn - * @date 2025-06-17 + * @date 2025-06-28 */ public class EmsPcsData extends BaseEntity { @@ -22,7 +22,7 @@ public class EmsPcsData extends BaseEntity private Long id; /** 数据更新时间 */ - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd") private Date dataUpdateTime; @@ -132,11 +132,63 @@ public class EmsPcsData extends BaseEntity /** 月 */ @Excel(name = "月") - private int dateMonth; + private Long dateMonth; /** 日 */ @Excel(name = "日") - private int dateDay; + private Long dateDay; + + /** 总交流充电量 (kWh) */ + @Excel(name = "总交流充电量 (kWh)") + private BigDecimal totalAcChargeEnergy; + + /** 总交流放电量 (kWh) */ + @Excel(name = "总交流放电量 (kWh)") + private BigDecimal totalAcDischargeEnergy; + + /** 交流侧充电有功功率 */ + @Excel(name = "交流侧充电有功功率") + private BigDecimal acChargeActivePower; + + /** 交流侧容性无功功率 */ + @Excel(name = "交流侧容性无功功率") + private BigDecimal acCapacitiveReactivePower; + + /** 交流侧放电有功功率 */ + @Excel(name = "交流侧放电有功功率") + private BigDecimal acDischargeActivePower; + + /** 交流侧感性无功功率 */ + @Excel(name = "交流侧感性无功功率") + private BigDecimal acInductiveReactivePower; + + /** 最大容性无功能力 */ + @Excel(name = "最大容性无功能力") + private BigDecimal maxCapacitivePowerCapacity; + + /** 最大感性无功能力 */ + @Excel(name = "最大感性无功能力") + private BigDecimal maxInductivePowerCapacity; + + /** 最大可冲功率 */ + @Excel(name = "最大可冲功率") + private BigDecimal maxChargePowerCapacity; + + /** 最大可放功率 */ + @Excel(name = "最大可放功率") + private BigDecimal maxDischargePowerCapacity; + + /** 交流开关状态 */ + @Excel(name = "交流开关状态") + private String acSwitchStatus; + + /** 直流开关状态 */ + @Excel(name = "直流开关状态") + private String dcSwitchStatus; + + /** 远程投退状态 */ + @Excel(name = "远程投退状态") + private String remoteControlStatus; public void setId(Long id) { @@ -418,20 +470,154 @@ public class EmsPcsData extends BaseEntity return deviceId; } - public int getDateMonth() { - return dateMonth; - } - - public void setDateMonth(int dateMonth) { + public void setDateMonth(Long dateMonth) + { this.dateMonth = dateMonth; } - public int getDateDay() { + public Long getDateMonth() + { + return dateMonth; + } + + public void setDateDay(Long dateDay) + { + this.dateDay = dateDay; + } + + public Long getDateDay() + { return dateDay; } - public void setDateDay(int dateDay) { - this.dateDay = dateDay; + public void setTotalAcChargeEnergy(BigDecimal totalAcChargeEnergy) + { + this.totalAcChargeEnergy = totalAcChargeEnergy; + } + + public BigDecimal getTotalAcChargeEnergy() + { + return totalAcChargeEnergy; + } + + public void setTotalAcDischargeEnergy(BigDecimal totalAcDischargeEnergy) + { + this.totalAcDischargeEnergy = totalAcDischargeEnergy; + } + + public BigDecimal getTotalAcDischargeEnergy() + { + return totalAcDischargeEnergy; + } + + public void setAcChargeActivePower(BigDecimal acChargeActivePower) + { + this.acChargeActivePower = acChargeActivePower; + } + + public BigDecimal getAcChargeActivePower() + { + return acChargeActivePower; + } + + public void setAcCapacitiveReactivePower(BigDecimal acCapacitiveReactivePower) + { + this.acCapacitiveReactivePower = acCapacitiveReactivePower; + } + + public BigDecimal getAcCapacitiveReactivePower() + { + return acCapacitiveReactivePower; + } + + public void setAcDischargeActivePower(BigDecimal acDischargeActivePower) + { + this.acDischargeActivePower = acDischargeActivePower; + } + + public BigDecimal getAcDischargeActivePower() + { + return acDischargeActivePower; + } + + public void setAcInductiveReactivePower(BigDecimal acInductiveReactivePower) + { + this.acInductiveReactivePower = acInductiveReactivePower; + } + + public BigDecimal getAcInductiveReactivePower() + { + return acInductiveReactivePower; + } + + public void setMaxCapacitivePowerCapacity(BigDecimal maxCapacitivePowerCapacity) + { + this.maxCapacitivePowerCapacity = maxCapacitivePowerCapacity; + } + + public BigDecimal getMaxCapacitivePowerCapacity() + { + return maxCapacitivePowerCapacity; + } + + public void setMaxInductivePowerCapacity(BigDecimal maxInductivePowerCapacity) + { + this.maxInductivePowerCapacity = maxInductivePowerCapacity; + } + + public BigDecimal getMaxInductivePowerCapacity() + { + return maxInductivePowerCapacity; + } + + public void setMaxChargePowerCapacity(BigDecimal maxChargePowerCapacity) + { + this.maxChargePowerCapacity = maxChargePowerCapacity; + } + + public BigDecimal getMaxChargePowerCapacity() + { + return maxChargePowerCapacity; + } + + public void setMaxDischargePowerCapacity(BigDecimal maxDischargePowerCapacity) + { + this.maxDischargePowerCapacity = maxDischargePowerCapacity; + } + + public BigDecimal getMaxDischargePowerCapacity() + { + return maxDischargePowerCapacity; + } + + public void setAcSwitchStatus(String acSwitchStatus) + { + this.acSwitchStatus = acSwitchStatus; + } + + public String getAcSwitchStatus() + { + return acSwitchStatus; + } + + public void setDcSwitchStatus(String dcSwitchStatus) + { + this.dcSwitchStatus = dcSwitchStatus; + } + + public String getDcSwitchStatus() + { + return dcSwitchStatus; + } + + public void setRemoteControlStatus(String remoteControlStatus) + { + this.remoteControlStatus = remoteControlStatus; + } + + public String getRemoteControlStatus() + { + return remoteControlStatus; } @Override @@ -472,7 +658,19 @@ public class EmsPcsData extends BaseEntity .append("deviceId", getDeviceId()) .append("dateMonth", getDateMonth()) .append("dateDay", getDateDay()) + .append("totalAcChargeEnergy", getTotalAcChargeEnergy()) + .append("totalAcDischargeEnergy", getTotalAcDischargeEnergy()) + .append("acChargeActivePower", getAcChargeActivePower()) + .append("acCapacitiveReactivePower", getAcCapacitiveReactivePower()) + .append("acDischargeActivePower", getAcDischargeActivePower()) + .append("acInductiveReactivePower", getAcInductiveReactivePower()) + .append("maxCapacitivePowerCapacity", getMaxCapacitivePowerCapacity()) + .append("maxInductivePowerCapacity", getMaxInductivePowerCapacity()) + .append("maxChargePowerCapacity", getMaxChargePowerCapacity()) + .append("maxDischargePowerCapacity", getMaxDischargePowerCapacity()) + .append("acSwitchStatus", getAcSwitchStatus()) + .append("dcSwitchStatus", getDcSwitchStatus()) + .append("remoteControlStatus", getRemoteControlStatus()) .toString(); } } - diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 1746e64..c0f90a7 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -40,11 +40,23 @@ - + + + + + + + + + + + + + - select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, date_month, date_day, communication_status from ems_pcs_data + select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, date_month, date_day, total_ac_charge_energy, total_ac_discharge_energy, ac_charge_active_power, ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, remote_control_status from ems_pcs_data @@ -122,10 +146,22 @@ update_time, remark, site_id, - device_id, + device_id, date_month, date_day, - communication_status, + total_ac_charge_energy, + total_ac_discharge_energy, + ac_charge_active_power, + ac_capacitive_reactive_power, + ac_discharge_active_power, + ac_inductive_reactive_power, + max_capacitive_power_capacity, + max_inductive_power_capacity, + max_charge_power_capacity, + max_discharge_power_capacity, + ac_switch_status, + dc_switch_status, + remote_control_status, #{dataUpdateTime}, @@ -159,10 +195,22 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, + #{deviceId}, #{dateMonth}, #{dateDay}, - #{communicationStatus}, + #{totalAcChargeEnergy}, + #{totalAcDischargeEnergy}, + #{acChargeActivePower}, + #{acCapacitiveReactivePower}, + #{acDischargeActivePower}, + #{acInductiveReactivePower}, + #{maxCapacitivePowerCapacity}, + #{maxInductivePowerCapacity}, + #{maxChargePowerCapacity}, + #{maxDischargePowerCapacity}, + #{acSwitchStatus}, + #{dcSwitchStatus}, + #{remoteControlStatus}, @@ -200,10 +248,22 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, + device_id = #{deviceId}, date_month = #{dateMonth}, date_day = #{dateDay}, - communication_status = #{communicationStatus}, + total_ac_charge_energy = #{totalAcChargeEnergy}, + total_ac_discharge_energy = #{totalAcDischargeEnergy}, + ac_charge_active_power = #{acChargeActivePower}, + ac_capacitive_reactive_power = #{acCapacitiveReactivePower}, + ac_discharge_active_power = #{acDischargeActivePower}, + ac_inductive_reactive_power = #{acInductiveReactivePower}, + max_capacitive_power_capacity = #{maxCapacitivePowerCapacity}, + max_inductive_power_capacity = #{maxInductivePowerCapacity}, + max_charge_power_capacity = #{maxChargePowerCapacity}, + max_discharge_power_capacity = #{maxDischargePowerCapacity}, + ac_switch_status = #{acSwitchStatus}, + dc_switch_status = #{dcSwitchStatus}, + remote_control_status = #{remoteControlStatus}, where id = #{id} @@ -218,81 +278,4 @@ #{id} - - - - - - - - - - - - \ No newline at end of file -- 2.49.0 From d1aa8dbd2c3d6a4d150602222462af8cf50e355b Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 29 Jun 2025 10:55:05 +0800 Subject: [PATCH 009/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9site=5Fid=20&=20devic?= =?UTF-8?q?e=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/EmsSiteMapController.java | 2 +- .../ems/EmsSiteMonitorController.java | 22 +- .../controller/ems/MqttMessageController.java | 6 +- .../com/xzzn/ems/domain/EmsAlarmRecords.java | 14 +- .../com/xzzn/ems/domain/EmsAmmeterData.java | 31 +- .../xzzn/ems/domain/EmsBatteryCluster.java | 509 +++++++++++++++++- .../com/xzzn/ems/domain/EmsBatteryData.java | 16 +- .../com/xzzn/ems/domain/EmsBatteryStack.java | 494 ++++++++++++++++- .../com/xzzn/ems/domain/EmsCoolingData.java | 16 +- .../xzzn/ems/domain/EmsDevicesSetting.java | 23 +- .../com/xzzn/ems/domain/EmsPcsBranchData.java | 316 ++++++++++- .../java/com/xzzn/ems/domain/EmsPcsData.java | 8 +- .../com/xzzn/ems/domain/EmsSiteSetting.java | 19 +- .../ems/domain/vo/AmmeterDataDetailInfo.java | 6 +- .../domain/vo/BMSBatteryClusterDataList.java | 12 +- .../ems/domain/vo/BMSBatteryClusterVo.java | 12 +- .../ems/domain/vo/BMSBatteryDataList.java | 4 +- .../com/xzzn/ems/domain/vo/BMSOverViewVo.java | 12 +- .../domain/vo/BatteryClusterDataDetailVo.java | 12 +- .../ems/domain/vo/BatteryDataStatsListVo.java | 70 +-- .../domain/vo/BatteryDataStatsTemplate.java | 48 -- .../com/xzzn/ems/domain/vo/PcsBranchInfo.java | 12 +- .../xzzn/ems/domain/vo/PcsDetailInfoVo.java | 12 +- ...java => SiteMonitorRunningHeadInfoVo.java} | 2 +- .../ems/mapper/EmsAlarmRecordsMapper.java | 2 +- .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 2 +- .../ems/mapper/EmsBatteryClusterMapper.java | 4 +- .../xzzn/ems/mapper/EmsBatteryDataMapper.java | 4 +- .../ems/mapper/EmsBatteryStackMapper.java | 2 +- .../xzzn/ems/mapper/EmsCoolingDataMapper.java | 2 +- .../ems/mapper/EmsDevicesSettingMapper.java | 6 +- .../ems/mapper/EmsPcsBranchDataMapper.java | 6 +- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 10 +- .../xzzn/ems/mapper/EmsSiteSettingMapper.java | 7 + .../com/xzzn/ems/service/IEmsSiteService.java | 4 +- .../xzzn/ems/service/IHomePageService.java | 2 +- .../xzzn/ems/service/ISingleSiteService.java | 18 +- .../ems/service/impl/EmsSiteServiceImpl.java | 4 +- .../ems/service/impl/HomePageServiceImpl.java | 18 +- .../service/impl/SingleSiteServiceImpl.java | 57 +- .../mapper/ems/EmsAlarmRecordsMapper.xml | 12 +- .../mapper/ems/EmsAmmeterDataMapper.xml | 21 +- .../mapper/ems/EmsBatteryClusterMapper.xml | 179 +++++- .../mapper/ems/EmsBatteryDataMapper.xml | 20 +- .../mapper/ems/EmsBatteryStackMapper.xml | 174 +++++- .../mapper/ems/EmsCoolingDataMapper.xml | 14 +- .../mapper/ems/EmsDevicesSettingMapper.xml | 27 +- .../mapper/ems/EmsPcsBranchDataMapper.xml | 112 +++- .../resources/mapper/ems/EmsPcsDataMapper.xml | 79 ++- .../mapper/ems/EmsSiteSettingMapper.xml | 14 +- 50 files changed, 2142 insertions(+), 336 deletions(-) delete mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java rename ems-system/src/main/java/com/xzzn/ems/domain/vo/{SiteMonitorRuningHeadInfoVo.java => SiteMonitorRunningHeadInfoVo.java} (97%) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMapController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMapController.java index 4c39286..072d081 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMapController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMapController.java @@ -26,7 +26,7 @@ public class EmsSiteMapController extends BaseController{ * 获取某个站点基本信息 */ @GetMapping("/getSingleSiteBaseInfo") - public AjaxResult getSingleSiteBaseInfo(@RequestParam Long siteId) + public AjaxResult getSingleSiteBaseInfo(@RequestParam String siteId) { return success(homePageService.getSingleSiteBaseInfo(siteId)); } diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 91fbdd1..f462657 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -25,7 +25,7 @@ public class EmsSiteMonitorController extends BaseController{ * 获取单站首页数据 */ @GetMapping("/homeView") - public AjaxResult getSingleSiteViewInfo(@RequestParam Long siteId) + public AjaxResult getSingleSiteViewInfo(@RequestParam String siteId) { return success(iSingleSiteService.getSiteMonitorDataVo(siteId)); } @@ -34,7 +34,7 @@ public class EmsSiteMonitorController extends BaseController{ * 单站监控-设备监控-实时运行头部数据 */ @GetMapping("/runningHeadInfo") - public AjaxResult getRunningHeadInfo(@RequestParam Long siteId) + public AjaxResult getRunningHeadInfo(@RequestParam String siteId) { return success(iSingleSiteService.getSiteRunningHeadInfo(siteId)); } @@ -43,7 +43,7 @@ public class EmsSiteMonitorController extends BaseController{ * 单站监控-设备监控-实时运行曲线图数据 */ @GetMapping("/runningGraph") - public AjaxResult getRunningGraph(@RequestParam Long siteId) + public AjaxResult getRunningGraph(@RequestParam String siteId) { return success(iSingleSiteService.getRunningGraph(siteId)); } @@ -52,7 +52,7 @@ public class EmsSiteMonitorController extends BaseController{ * 单站监控-设备监控-PCS */ @GetMapping("/getPcsDetailInfo") - public AjaxResult getPcsDetailInfo(@RequestParam Long siteId) + public AjaxResult getPcsDetailInfo(@RequestParam String siteId) { return success(iSingleSiteService.getPcsDetailInfo(siteId)); } @@ -61,7 +61,7 @@ public class EmsSiteMonitorController extends BaseController{ * 单站监控-设备监控-BMS总览 */ @GetMapping("/getBMSOverView") - public AjaxResult getBMSOverView(@RequestParam Long siteId) + public AjaxResult getBMSOverView(@RequestParam String siteId) { return success(iSingleSiteService.getBMSOverView(siteId)); } @@ -70,7 +70,7 @@ public class EmsSiteMonitorController extends BaseController{ * 单站监控-设备监控-BMS电池簇 */ @GetMapping("/getBMSBatteryCluster") - public AjaxResult getBMSBatteryCluster(@RequestParam Long siteId) + public AjaxResult getBMSBatteryCluster(@RequestParam String siteId) { return success(iSingleSiteService.getBMSBatteryCluster(siteId)); } @@ -79,7 +79,7 @@ public class EmsSiteMonitorController extends BaseController{ * 获取所有电池堆 */ @GetMapping("/getStackNameList") - public AjaxResult getStackNameList(@RequestParam Long siteId) + public AjaxResult getStackNameList(@RequestParam String siteId) { return success(iEmsSiteService.getAllStackInfo(siteId)); } @@ -88,7 +88,7 @@ public class EmsSiteMonitorController extends BaseController{ * 获取所有电池簇 */ @GetMapping("/getClusterNameList") - public AjaxResult getClusterNameList(@RequestParam Long stackDeviceId) + public AjaxResult getClusterNameList(@RequestParam String stackDeviceId) { return success(iEmsSiteService.getAllClusterInfo(stackDeviceId)); } @@ -97,7 +97,7 @@ public class EmsSiteMonitorController extends BaseController{ * 液冷设备参数 */ @GetMapping("/getCoolingDataList") - public AjaxResult getCoolingDataList(@RequestParam Long siteId) + public AjaxResult getCoolingDataList(@RequestParam String siteId) { return success(iSingleSiteService.getCoolingDataList(siteId)); } @@ -106,7 +106,7 @@ public class EmsSiteMonitorController extends BaseController{ * 获取电池簇下面的单体电池数据 */ @GetMapping("/getClusterDataInfoList") - public AjaxResult getClusterDataInfoList(@RequestParam Long clusterDeviceId) + public AjaxResult getClusterDataInfoList(@RequestParam String clusterDeviceId) { return success(iSingleSiteService.getClusterDataInfoList(clusterDeviceId)); } @@ -115,7 +115,7 @@ public class EmsSiteMonitorController extends BaseController{ * 电表数据 */ @GetMapping("/getAmmeterDataList") - public AjaxResult getAmmeterDataList(@RequestParam Long siteId) + public AjaxResult getAmmeterDataList(@RequestParam String siteId) { return success(iSingleSiteService.getAmmeterDataList(siteId)); } diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 4baff1c..292aac9 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -169,8 +169,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { data.setDataTimestamp(new Date()); // ID字段 - data.setSiteId(Long.parseLong("021")); - data.setClusterDeviceId(Long.parseLong("021")); + data.setSiteId(("021")); + data.setClusterDeviceId(("021")); emsBatteryDataService.insertEmsBatteryData(data); @@ -230,7 +230,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { // data.setUpdateBy(BigDecimal.ZERO); // data.setUpdateTime(BigDecimal.ZERO); // data.setRemark(BigDecimal.ZERO); - data.setSiteId(Long.parseLong("021")); + data.setSiteId(("021")); data.setDeviceId(deviceId); data.setDateMonth(Long.parseLong("6")); data.setDateDay(Long.parseLong("28")); diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java index f9a673b..fe5cb52 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * 告警记录对象 ems_alarm_records * * @author xzzn - * @date 2025-06-17 + * @date 2025-06-29 */ public class EmsAlarmRecords extends BaseEntity { @@ -48,11 +48,11 @@ public class EmsAlarmRecords extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; /** 设备名称,用于标识设备 */ @Excel(name = "设备名称,用于标识设备") @@ -128,22 +128,22 @@ public class EmsAlarmRecords extends BaseEntity return status; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java index a110ce9..7509603 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java @@ -12,13 +12,13 @@ import com.xzzn.common.annotation.Excel; * 总数据对象 ems_ammeter_data * * @author xzzn - * @date 2025-06-27 + * @date 2025-06-29 */ public class EmsAmmeterData extends BaseEntity { private static final long serialVersionUID = 1L; - /** $column.columnComment */ + /** */ private Long id; /** 数据更新时间 */ @@ -34,6 +34,10 @@ public class EmsAmmeterData extends BaseEntity @Excel(name = "总 (kWh)") private BigDecimal totalKwh; + /** 尖 (kWh) */ + @Excel(name = "尖 (kWh)") + private BigDecimal sharpKwh; + /** 峰 (kWh) */ @Excel(name = "峰 (kWh)") private BigDecimal peakKwh; @@ -48,11 +52,11 @@ public class EmsAmmeterData extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; public void setId(Long id) { @@ -94,6 +98,16 @@ public class EmsAmmeterData extends BaseEntity return totalKwh; } + public void setSharpKwh(BigDecimal sharpKwh) + { + this.sharpKwh = sharpKwh; + } + + public BigDecimal getSharpKwh() + { + return sharpKwh; + } + public void setPeakKwh(BigDecimal peakKwh) { this.peakKwh = peakKwh; @@ -124,22 +138,22 @@ public class EmsAmmeterData extends BaseEntity return valleyKwh; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } @@ -151,6 +165,7 @@ public class EmsAmmeterData extends BaseEntity .append("dataUpdateTime", getDataUpdateTime()) .append("category", getCategory()) .append("totalKwh", getTotalKwh()) + .append("sharpKwh", getSharpKwh()) .append("peakKwh", getPeakKwh()) .append("flatKwh", getFlatKwh()) .append("valleyKwh", getValleyKwh()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java index e19045d..05718b5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * 电池簇数据对象 ems_battery_cluster * * @author xzzn - * @date 2025-06-22 + * @date 2025-06-29 */ public class EmsBatteryCluster extends BaseEntity { @@ -74,11 +74,143 @@ public class EmsBatteryCluster extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; + + /** 堆设备id */ + @Excel(name = "堆设备id") + private String stackDeviceId; + + /** 允许充电最大功率 */ + @Excel(name = "允许充电最大功率") + private BigDecimal maxAllowedChargePower; + + /** 允许放电最大功率 */ + @Excel(name = "允许放电最大功率") + private BigDecimal maxAllowedDischargePower; + + /** 允许充电最大电压 */ + @Excel(name = "允许充电最大电压") + private BigDecimal maxAllowedChargeVoltage; + + /** 允许放电最大电压 */ + @Excel(name = "允许放电最大电压") + private BigDecimal maxAllowedDischargeVoltage; + + /** 允许充电最大电流 */ + @Excel(name = "允许充电最大电流") + private BigDecimal maxAllowedChargeCurrent; + + /** 允许放电最大电流 */ + @Excel(name = "允许放电最大电流") + private BigDecimal maxAllowedDischargeCurrent; + + /** 组电压 */ + @Excel(name = "组电压") + private BigDecimal batteryPackVoltage; + + /** 组电流 */ + @Excel(name = "组电流") + private BigDecimal batteryPackCurrent; + + /** 模块温度 */ + @Excel(name = "模块温度") + private BigDecimal batteryPackTemp; + + /** 组SOC */ + @Excel(name = "组SOC") + private BigDecimal batteryPackSoc; + + /** 组SOH */ + @Excel(name = "组SOH") + private BigDecimal batteryPackSoh; + + /** 组绝缘电阻 */ + @Excel(name = "组绝缘电阻") + private BigDecimal batteryPackInsulationResistance; + + /** 平均单体电压 */ + @Excel(name = "平均单体电压") + private BigDecimal avgCellVoltage; + + /** 平均单体温度 */ + @Excel(name = "平均单体温度") + private BigDecimal avgCellTemp; + + /** 最高单体电压 */ + @Excel(name = "最高单体电压") + private BigDecimal maxCellVoltage; + + /** 最高单体电压对应点号 */ + @Excel(name = "最高单体电压对应点号") + private Long maxCellVoltageId; + + /** 最低单体电压 */ + @Excel(name = "最低单体电压") + private BigDecimal minCellVoltage; + + /** 最低单体电压对应点号 */ + @Excel(name = "最低单体电压对应点号") + private Long minCellVoltageId; + + /** 最高单体温度 */ + @Excel(name = "最高单体温度") + private BigDecimal maxCellTemp; + + /** 最高单体温度对应点号 */ + @Excel(name = "最高单体温度对应点号") + private Long maxCellTempId; + + /** 最低单体温度 */ + @Excel(name = "最低单体温度") + private BigDecimal minCellTemp; + + /** 最低单体温度对应点号 */ + @Excel(name = "最低单体温度对应点号") + private Long minCellTempId; + + /** 最高单体SOC */ + @Excel(name = "最高单体SOC") + private BigDecimal maxCellSoc; + + /** 最高单体SOC对应点号 */ + @Excel(name = "最高单体SOC对应点号") + private Long maxCellSocId; + + /** 最低单体SOC */ + @Excel(name = "最低单体SOC") + private BigDecimal minCellSoc; + + /** 最低单体SOC对应点号 */ + @Excel(name = "最低单体SOC对应点号") + private Long minCellSocId; + + /** 最高单体SOH */ + @Excel(name = "最高单体SOH") + private BigDecimal maxCellSoh; + + /** 最高单体SOH对应点号 */ + @Excel(name = "最高单体SOH对应点号") + private Long maxCellSohId; + + /** 最低单体SOH */ + @Excel(name = "最低单体SOH") + private BigDecimal minCellSoh; + + /** 最低单体SOH对应点号 */ + @Excel(name = "最低单体SOH对应点号") + private Long minCellSohId; + + /** 单次累计充电电量 */ + @Excel(name = "单次累计充电电量") + private BigDecimal totalChargeEnergy; + + /** 单次累计放电电量 */ + @Excel(name = "单次累计放电电量") + private BigDecimal totalDischargeEnergy; public void setId(Long id) { @@ -220,26 +352,356 @@ public class EmsBatteryCluster extends BaseEntity return currentSoc; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } + public void setStackDeviceId(String stackDeviceId) + { + this.stackDeviceId = stackDeviceId; + } + + public String getStackDeviceId() + { + return stackDeviceId; + } + + public void setMaxAllowedChargePower(BigDecimal maxAllowedChargePower) + { + this.maxAllowedChargePower = maxAllowedChargePower; + } + + public BigDecimal getMaxAllowedChargePower() + { + return maxAllowedChargePower; + } + + public void setMaxAllowedDischargePower(BigDecimal maxAllowedDischargePower) + { + this.maxAllowedDischargePower = maxAllowedDischargePower; + } + + public BigDecimal getMaxAllowedDischargePower() + { + return maxAllowedDischargePower; + } + + public void setMaxAllowedChargeVoltage(BigDecimal maxAllowedChargeVoltage) + { + this.maxAllowedChargeVoltage = maxAllowedChargeVoltage; + } + + public BigDecimal getMaxAllowedChargeVoltage() + { + return maxAllowedChargeVoltage; + } + + public void setMaxAllowedDischargeVoltage(BigDecimal maxAllowedDischargeVoltage) + { + this.maxAllowedDischargeVoltage = maxAllowedDischargeVoltage; + } + + public BigDecimal getMaxAllowedDischargeVoltage() + { + return maxAllowedDischargeVoltage; + } + + public void setMaxAllowedChargeCurrent(BigDecimal maxAllowedChargeCurrent) + { + this.maxAllowedChargeCurrent = maxAllowedChargeCurrent; + } + + public BigDecimal getMaxAllowedChargeCurrent() + { + return maxAllowedChargeCurrent; + } + + public void setMaxAllowedDischargeCurrent(BigDecimal maxAllowedDischargeCurrent) + { + this.maxAllowedDischargeCurrent = maxAllowedDischargeCurrent; + } + + public BigDecimal getMaxAllowedDischargeCurrent() + { + return maxAllowedDischargeCurrent; + } + + public void setBatteryPackVoltage(BigDecimal batteryPackVoltage) + { + this.batteryPackVoltage = batteryPackVoltage; + } + + public BigDecimal getBatteryPackVoltage() + { + return batteryPackVoltage; + } + + public void setBatteryPackCurrent(BigDecimal batteryPackCurrent) + { + this.batteryPackCurrent = batteryPackCurrent; + } + + public BigDecimal getBatteryPackCurrent() + { + return batteryPackCurrent; + } + + public void setBatteryPackTemp(BigDecimal batteryPackTemp) + { + this.batteryPackTemp = batteryPackTemp; + } + + public BigDecimal getBatteryPackTemp() + { + return batteryPackTemp; + } + + public void setBatteryPackSoc(BigDecimal batteryPackSoc) + { + this.batteryPackSoc = batteryPackSoc; + } + + public BigDecimal getBatteryPackSoc() + { + return batteryPackSoc; + } + + public void setBatteryPackSoh(BigDecimal batteryPackSoh) + { + this.batteryPackSoh = batteryPackSoh; + } + + public BigDecimal getBatteryPackSoh() + { + return batteryPackSoh; + } + + public void setBatteryPackInsulationResistance(BigDecimal batteryPackInsulationResistance) + { + this.batteryPackInsulationResistance = batteryPackInsulationResistance; + } + + public BigDecimal getBatteryPackInsulationResistance() + { + return batteryPackInsulationResistance; + } + + public void setAvgCellVoltage(BigDecimal avgCellVoltage) + { + this.avgCellVoltage = avgCellVoltage; + } + + public BigDecimal getAvgCellVoltage() + { + return avgCellVoltage; + } + + public void setAvgCellTemp(BigDecimal avgCellTemp) + { + this.avgCellTemp = avgCellTemp; + } + + public BigDecimal getAvgCellTemp() + { + return avgCellTemp; + } + + public void setMaxCellVoltage(BigDecimal maxCellVoltage) + { + this.maxCellVoltage = maxCellVoltage; + } + + public BigDecimal getMaxCellVoltage() + { + return maxCellVoltage; + } + + public void setMaxCellVoltageId(Long maxCellVoltageId) + { + this.maxCellVoltageId = maxCellVoltageId; + } + + public Long getMaxCellVoltageId() + { + return maxCellVoltageId; + } + + public void setMinCellVoltage(BigDecimal minCellVoltage) + { + this.minCellVoltage = minCellVoltage; + } + + public BigDecimal getMinCellVoltage() + { + return minCellVoltage; + } + + public void setMinCellVoltageId(Long minCellVoltageId) + { + this.minCellVoltageId = minCellVoltageId; + } + + public Long getMinCellVoltageId() + { + return minCellVoltageId; + } + + public void setMaxCellTemp(BigDecimal maxCellTemp) + { + this.maxCellTemp = maxCellTemp; + } + + public BigDecimal getMaxCellTemp() + { + return maxCellTemp; + } + + public void setMaxCellTempId(Long maxCellTempId) + { + this.maxCellTempId = maxCellTempId; + } + + public Long getMaxCellTempId() + { + return maxCellTempId; + } + + public void setMinCellTemp(BigDecimal minCellTemp) + { + this.minCellTemp = minCellTemp; + } + + public BigDecimal getMinCellTemp() + { + return minCellTemp; + } + + public void setMinCellTempId(Long minCellTempId) + { + this.minCellTempId = minCellTempId; + } + + public Long getMinCellTempId() + { + return minCellTempId; + } + + public void setMaxCellSoc(BigDecimal maxCellSoc) + { + this.maxCellSoc = maxCellSoc; + } + + public BigDecimal getMaxCellSoc() + { + return maxCellSoc; + } + + public void setMaxCellSocId(Long maxCellSocId) + { + this.maxCellSocId = maxCellSocId; + } + + public Long getMaxCellSocId() + { + return maxCellSocId; + } + + public void setMinCellSoc(BigDecimal minCellSoc) + { + this.minCellSoc = minCellSoc; + } + + public BigDecimal getMinCellSoc() + { + return minCellSoc; + } + + public void setMinCellSocId(Long minCellSocId) + { + this.minCellSocId = minCellSocId; + } + + public Long getMinCellSocId() + { + return minCellSocId; + } + + public void setMaxCellSoh(BigDecimal maxCellSoh) + { + this.maxCellSoh = maxCellSoh; + } + + public BigDecimal getMaxCellSoh() + { + return maxCellSoh; + } + + public void setMaxCellSohId(Long maxCellSohId) + { + this.maxCellSohId = maxCellSohId; + } + + public Long getMaxCellSohId() + { + return maxCellSohId; + } + + public void setMinCellSoh(BigDecimal minCellSoh) + { + this.minCellSoh = minCellSoh; + } + + public BigDecimal getMinCellSoh() + { + return minCellSoh; + } + + public void setMinCellSohId(Long minCellSohId) + { + this.minCellSohId = minCellSohId; + } + + public Long getMinCellSohId() + { + return minCellSohId; + } + + public void setTotalChargeEnergy(BigDecimal totalChargeEnergy) + { + this.totalChargeEnergy = totalChargeEnergy; + } + + public BigDecimal getTotalChargeEnergy() + { + return totalChargeEnergy; + } + + public void setTotalDischargeEnergy(BigDecimal totalDischargeEnergy) + { + this.totalDischargeEnergy = totalDischargeEnergy; + } + + public BigDecimal getTotalDischargeEnergy() + { + return totalDischargeEnergy; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -264,6 +726,39 @@ public class EmsBatteryCluster extends BaseEntity .append("remark", getRemark()) .append("siteId", getSiteId()) .append("deviceId", getDeviceId()) + .append("stackDeviceId", getStackDeviceId()) + .append("maxAllowedChargePower", getMaxAllowedChargePower()) + .append("maxAllowedDischargePower", getMaxAllowedDischargePower()) + .append("maxAllowedChargeVoltage", getMaxAllowedChargeVoltage()) + .append("maxAllowedDischargeVoltage", getMaxAllowedDischargeVoltage()) + .append("maxAllowedChargeCurrent", getMaxAllowedChargeCurrent()) + .append("maxAllowedDischargeCurrent", getMaxAllowedDischargeCurrent()) + .append("batteryPackVoltage", getBatteryPackVoltage()) + .append("batteryPackCurrent", getBatteryPackCurrent()) + .append("batteryPackTemp", getBatteryPackTemp()) + .append("batteryPackSoc", getBatteryPackSoc()) + .append("batteryPackSoh", getBatteryPackSoh()) + .append("batteryPackInsulationResistance", getBatteryPackInsulationResistance()) + .append("avgCellVoltage", getAvgCellVoltage()) + .append("avgCellTemp", getAvgCellTemp()) + .append("maxCellVoltage", getMaxCellVoltage()) + .append("maxCellVoltageId", getMaxCellVoltageId()) + .append("minCellVoltage", getMinCellVoltage()) + .append("minCellVoltageId", getMinCellVoltageId()) + .append("maxCellTemp", getMaxCellTemp()) + .append("maxCellTempId", getMaxCellTempId()) + .append("minCellTemp", getMinCellTemp()) + .append("minCellTempId", getMinCellTempId()) + .append("maxCellSoc", getMaxCellSoc()) + .append("maxCellSocId", getMaxCellSocId()) + .append("minCellSoc", getMinCellSoc()) + .append("minCellSocId", getMinCellSocId()) + .append("maxCellSoh", getMaxCellSoh()) + .append("maxCellSohId", getMaxCellSohId()) + .append("minCellSoh", getMinCellSoh()) + .append("minCellSohId", getMinCellSohId()) + .append("totalChargeEnergy", getTotalChargeEnergy()) + .append("totalDischargeEnergy", getTotalDischargeEnergy()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java index 1847431..799b413 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java @@ -12,13 +12,13 @@ import com.xzzn.common.annotation.Excel; * 单体电池实时数据对象 ems_battery_data * * @author xzzn - * @date 2025-06-28 + * @date 2025-06-29 */ public class EmsBatteryData extends BaseEntity { private static final long serialVersionUID = 1L; - /** $column.columnComment */ + /** */ private Long id; /** 电池堆 */ @@ -56,7 +56,7 @@ public class EmsBatteryData extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") @@ -64,7 +64,7 @@ public class EmsBatteryData extends BaseEntity /** 簇设备id */ @Excel(name = "簇设备id") - private Long clusterDeviceId; + private String clusterDeviceId; public void setId(Long id) { @@ -156,12 +156,12 @@ public class EmsBatteryData extends BaseEntity return dataTimestamp; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } @@ -176,12 +176,12 @@ public class EmsBatteryData extends BaseEntity return deviceId; } - public void setClusterDeviceId(Long clusterDeviceId) + public void setClusterDeviceId(String clusterDeviceId) { this.clusterDeviceId = clusterDeviceId; } - public Long getClusterDeviceId() + public String getClusterDeviceId() { return clusterDeviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java index 30bc120..82409b9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * 电池堆数据对象 ems_battery_stack * * @author xzzn - * @date 2025-06-22 + * @date 2025-06-29 */ public class EmsBatteryStack extends BaseEntity { @@ -74,11 +74,139 @@ public class EmsBatteryStack extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; + + /** 允许充电最大功率 */ + @Excel(name = "允许充电最大功率") + private BigDecimal maxAllowedChargePower; + + /** 允许放电最大功率 */ + @Excel(name = "允许放电最大功率") + private BigDecimal maxAllowedDischargePower; + + /** 允许充电最大电压 */ + @Excel(name = "允许充电最大电压") + private BigDecimal maxAllowedChargeVoltage; + + /** 允许放电最大电压 */ + @Excel(name = "允许放电最大电压") + private BigDecimal maxAllowedDischargeVoltage; + + /** 允许充电最大电流 */ + @Excel(name = "允许充电最大电流") + private BigDecimal maxAllowedChargeCurrent; + + /** 允许放电最大电流 */ + @Excel(name = "允许放电最大电流") + private BigDecimal maxAllowedDischargeCurrent; + + /** 组电压 */ + @Excel(name = "组电压") + private BigDecimal batteryPackVoltage; + + /** 组电流 */ + @Excel(name = "组电流") + private BigDecimal batteryPackCurrent; + + /** 模块温度 */ + @Excel(name = "模块温度") + private BigDecimal batteryPackTemp; + + /** 组SOC */ + @Excel(name = "组SOC") + private BigDecimal batteryPackSoc; + + /** 组SOH */ + @Excel(name = "组SOH") + private BigDecimal batteryPackSoh; + + /** 组绝缘电阻 */ + @Excel(name = "组绝缘电阻") + private BigDecimal batteryPackInsulationResistance; + + /** 平均单体电压 */ + @Excel(name = "平均单体电压") + private BigDecimal avgCellVoltage; + + /** 平均单体温度 */ + @Excel(name = "平均单体温度") + private BigDecimal avgCellTemp; + + /** 最高单体电压 */ + @Excel(name = "最高单体电压") + private BigDecimal maxCellVoltage; + + /** 最高单体电压对应点号 */ + @Excel(name = "最高单体电压对应点号") + private Long maxCellVoltageId; + + /** 最低单体电压 */ + @Excel(name = "最低单体电压") + private BigDecimal minCellVoltage; + + /** 最低单体电压对应点号 */ + @Excel(name = "最低单体电压对应点号") + private Long minCellVoltageId; + + /** 最高单体温度 */ + @Excel(name = "最高单体温度") + private BigDecimal maxCellTemp; + + /** 最高单体温度对应点号 */ + @Excel(name = "最高单体温度对应点号") + private Long maxCellTempId; + + /** 最低单体温度 */ + @Excel(name = "最低单体温度") + private BigDecimal minCellTemp; + + /** 最低单体温度对应点号 */ + @Excel(name = "最低单体温度对应点号") + private Long minCellTempId; + + /** 最高单体SOC */ + @Excel(name = "最高单体SOC") + private BigDecimal maxCellSoc; + + /** 最高单体SOC对应点号 */ + @Excel(name = "最高单体SOC对应点号") + private Long maxCellSocId; + + /** 最低单体SOC */ + @Excel(name = "最低单体SOC") + private BigDecimal minCellSoc; + + /** 最低单体SOC对应点号 */ + @Excel(name = "最低单体SOC对应点号") + private Long minCellSocId; + + /** 最高单体SOH */ + @Excel(name = "最高单体SOH") + private BigDecimal maxCellSoh; + + /** 最高单体SOH对应点号 */ + @Excel(name = "最高单体SOH对应点号") + private Long maxCellSohId; + + /** 最低单体SOH */ + @Excel(name = "最低单体SOH") + private BigDecimal minCellSoh; + + /** 最低单体SOH对应点号 */ + @Excel(name = "最低单体SOH对应点号") + private Long minCellSohId; + + /** 单次累计充电电量 */ + @Excel(name = "单次累计充电电量") + private BigDecimal totalChargeEnergy; + + /** 单次累计放电电量 */ + @Excel(name = "单次累计放电电量") + private BigDecimal totalDischargeEnergy; public void setId(Long id) { @@ -220,26 +348,346 @@ public class EmsBatteryStack extends BaseEntity return currentSoc; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } + public void setMaxAllowedChargePower(BigDecimal maxAllowedChargePower) + { + this.maxAllowedChargePower = maxAllowedChargePower; + } + + public BigDecimal getMaxAllowedChargePower() + { + return maxAllowedChargePower; + } + + public void setMaxAllowedDischargePower(BigDecimal maxAllowedDischargePower) + { + this.maxAllowedDischargePower = maxAllowedDischargePower; + } + + public BigDecimal getMaxAllowedDischargePower() + { + return maxAllowedDischargePower; + } + + public void setMaxAllowedChargeVoltage(BigDecimal maxAllowedChargeVoltage) + { + this.maxAllowedChargeVoltage = maxAllowedChargeVoltage; + } + + public BigDecimal getMaxAllowedChargeVoltage() + { + return maxAllowedChargeVoltage; + } + + public void setMaxAllowedDischargeVoltage(BigDecimal maxAllowedDischargeVoltage) + { + this.maxAllowedDischargeVoltage = maxAllowedDischargeVoltage; + } + + public BigDecimal getMaxAllowedDischargeVoltage() + { + return maxAllowedDischargeVoltage; + } + + public void setMaxAllowedChargeCurrent(BigDecimal maxAllowedChargeCurrent) + { + this.maxAllowedChargeCurrent = maxAllowedChargeCurrent; + } + + public BigDecimal getMaxAllowedChargeCurrent() + { + return maxAllowedChargeCurrent; + } + + public void setMaxAllowedDischargeCurrent(BigDecimal maxAllowedDischargeCurrent) + { + this.maxAllowedDischargeCurrent = maxAllowedDischargeCurrent; + } + + public BigDecimal getMaxAllowedDischargeCurrent() + { + return maxAllowedDischargeCurrent; + } + + public void setBatteryPackVoltage(BigDecimal batteryPackVoltage) + { + this.batteryPackVoltage = batteryPackVoltage; + } + + public BigDecimal getBatteryPackVoltage() + { + return batteryPackVoltage; + } + + public void setBatteryPackCurrent(BigDecimal batteryPackCurrent) + { + this.batteryPackCurrent = batteryPackCurrent; + } + + public BigDecimal getBatteryPackCurrent() + { + return batteryPackCurrent; + } + + public void setBatteryPackTemp(BigDecimal batteryPackTemp) + { + this.batteryPackTemp = batteryPackTemp; + } + + public BigDecimal getBatteryPackTemp() + { + return batteryPackTemp; + } + + public void setBatteryPackSoc(BigDecimal batteryPackSoc) + { + this.batteryPackSoc = batteryPackSoc; + } + + public BigDecimal getBatteryPackSoc() + { + return batteryPackSoc; + } + + public void setBatteryPackSoh(BigDecimal batteryPackSoh) + { + this.batteryPackSoh = batteryPackSoh; + } + + public BigDecimal getBatteryPackSoh() + { + return batteryPackSoh; + } + + public void setBatteryPackInsulationResistance(BigDecimal batteryPackInsulationResistance) + { + this.batteryPackInsulationResistance = batteryPackInsulationResistance; + } + + public BigDecimal getBatteryPackInsulationResistance() + { + return batteryPackInsulationResistance; + } + + public void setAvgCellVoltage(BigDecimal avgCellVoltage) + { + this.avgCellVoltage = avgCellVoltage; + } + + public BigDecimal getAvgCellVoltage() + { + return avgCellVoltage; + } + + public void setAvgCellTemp(BigDecimal avgCellTemp) + { + this.avgCellTemp = avgCellTemp; + } + + public BigDecimal getAvgCellTemp() + { + return avgCellTemp; + } + + public void setMaxCellVoltage(BigDecimal maxCellVoltage) + { + this.maxCellVoltage = maxCellVoltage; + } + + public BigDecimal getMaxCellVoltage() + { + return maxCellVoltage; + } + + public void setMaxCellVoltageId(Long maxCellVoltageId) + { + this.maxCellVoltageId = maxCellVoltageId; + } + + public Long getMaxCellVoltageId() + { + return maxCellVoltageId; + } + + public void setMinCellVoltage(BigDecimal minCellVoltage) + { + this.minCellVoltage = minCellVoltage; + } + + public BigDecimal getMinCellVoltage() + { + return minCellVoltage; + } + + public void setMinCellVoltageId(Long minCellVoltageId) + { + this.minCellVoltageId = minCellVoltageId; + } + + public Long getMinCellVoltageId() + { + return minCellVoltageId; + } + + public void setMaxCellTemp(BigDecimal maxCellTemp) + { + this.maxCellTemp = maxCellTemp; + } + + public BigDecimal getMaxCellTemp() + { + return maxCellTemp; + } + + public void setMaxCellTempId(Long maxCellTempId) + { + this.maxCellTempId = maxCellTempId; + } + + public Long getMaxCellTempId() + { + return maxCellTempId; + } + + public void setMinCellTemp(BigDecimal minCellTemp) + { + this.minCellTemp = minCellTemp; + } + + public BigDecimal getMinCellTemp() + { + return minCellTemp; + } + + public void setMinCellTempId(Long minCellTempId) + { + this.minCellTempId = minCellTempId; + } + + public Long getMinCellTempId() + { + return minCellTempId; + } + + public void setMaxCellSoc(BigDecimal maxCellSoc) + { + this.maxCellSoc = maxCellSoc; + } + + public BigDecimal getMaxCellSoc() + { + return maxCellSoc; + } + + public void setMaxCellSocId(Long maxCellSocId) + { + this.maxCellSocId = maxCellSocId; + } + + public Long getMaxCellSocId() + { + return maxCellSocId; + } + + public void setMinCellSoc(BigDecimal minCellSoc) + { + this.minCellSoc = minCellSoc; + } + + public BigDecimal getMinCellSoc() + { + return minCellSoc; + } + + public void setMinCellSocId(Long minCellSocId) + { + this.minCellSocId = minCellSocId; + } + + public Long getMinCellSocId() + { + return minCellSocId; + } + + public void setMaxCellSoh(BigDecimal maxCellSoh) + { + this.maxCellSoh = maxCellSoh; + } + + public BigDecimal getMaxCellSoh() + { + return maxCellSoh; + } + + public void setMaxCellSohId(Long maxCellSohId) + { + this.maxCellSohId = maxCellSohId; + } + + public Long getMaxCellSohId() + { + return maxCellSohId; + } + + public void setMinCellSoh(BigDecimal minCellSoh) + { + this.minCellSoh = minCellSoh; + } + + public BigDecimal getMinCellSoh() + { + return minCellSoh; + } + + public void setMinCellSohId(Long minCellSohId) + { + this.minCellSohId = minCellSohId; + } + + public Long getMinCellSohId() + { + return minCellSohId; + } + + public void setTotalChargeEnergy(BigDecimal totalChargeEnergy) + { + this.totalChargeEnergy = totalChargeEnergy; + } + + public BigDecimal getTotalChargeEnergy() + { + return totalChargeEnergy; + } + + public void setTotalDischargeEnergy(BigDecimal totalDischargeEnergy) + { + this.totalDischargeEnergy = totalDischargeEnergy; + } + + public BigDecimal getTotalDischargeEnergy() + { + return totalDischargeEnergy; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -264,6 +712,38 @@ public class EmsBatteryStack extends BaseEntity .append("remark", getRemark()) .append("siteId", getSiteId()) .append("deviceId", getDeviceId()) + .append("maxAllowedChargePower", getMaxAllowedChargePower()) + .append("maxAllowedDischargePower", getMaxAllowedDischargePower()) + .append("maxAllowedChargeVoltage", getMaxAllowedChargeVoltage()) + .append("maxAllowedDischargeVoltage", getMaxAllowedDischargeVoltage()) + .append("maxAllowedChargeCurrent", getMaxAllowedChargeCurrent()) + .append("maxAllowedDischargeCurrent", getMaxAllowedDischargeCurrent()) + .append("batteryPackVoltage", getBatteryPackVoltage()) + .append("batteryPackCurrent", getBatteryPackCurrent()) + .append("batteryPackTemp", getBatteryPackTemp()) + .append("batteryPackSoc", getBatteryPackSoc()) + .append("batteryPackSoh", getBatteryPackSoh()) + .append("batteryPackInsulationResistance", getBatteryPackInsulationResistance()) + .append("avgCellVoltage", getAvgCellVoltage()) + .append("avgCellTemp", getAvgCellTemp()) + .append("maxCellVoltage", getMaxCellVoltage()) + .append("maxCellVoltageId", getMaxCellVoltageId()) + .append("minCellVoltage", getMinCellVoltage()) + .append("minCellVoltageId", getMinCellVoltageId()) + .append("maxCellTemp", getMaxCellTemp()) + .append("maxCellTempId", getMaxCellTempId()) + .append("minCellTemp", getMinCellTemp()) + .append("minCellTempId", getMinCellTempId()) + .append("maxCellSoc", getMaxCellSoc()) + .append("maxCellSocId", getMaxCellSocId()) + .append("minCellSoc", getMinCellSoc()) + .append("minCellSocId", getMinCellSocId()) + .append("maxCellSoh", getMaxCellSoh()) + .append("maxCellSohId", getMaxCellSohId()) + .append("minCellSoh", getMinCellSoh()) + .append("minCellSohId", getMinCellSohId()) + .append("totalChargeEnergy", getTotalChargeEnergy()) + .append("totalDischargeEnergy", getTotalDischargeEnergy()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java index 1a782f0..a469528 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java @@ -11,13 +11,13 @@ import com.xzzn.common.annotation.Excel; * 冷却系统参数对象 ems_cooling_data * * @author xzzn - * @date 2025-06-25 + * @date 2025-06-29 */ public class EmsCoolingData extends BaseEntity { private static final long serialVersionUID = 1L; - /** $column.columnComment */ + /** */ private Long id; /** 系统名称,如1#液冷 */ @@ -58,11 +58,11 @@ public class EmsCoolingData extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; public void setId(Long id) { @@ -164,22 +164,22 @@ public class EmsCoolingData extends BaseEntity return lowTempAlarmPoint; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java index de71eee..ea9c3c2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * Modbus设备配置对象 ems_devices_setting * * @author xzzn - * @date 2025-06-24 + * @date 2025-06-29 */ public class EmsDevicesSetting extends BaseEntity { @@ -84,12 +84,16 @@ public class EmsDevicesSetting extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 通信状态 */ @Excel(name = "通信状态") private String communicationStatus; + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + public void setId(Long id) { this.id = id; @@ -250,12 +254,12 @@ public class EmsDevicesSetting extends BaseEntity return updatedAt; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } @@ -270,6 +274,16 @@ public class EmsDevicesSetting extends BaseEntity return communicationStatus; } + 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) @@ -291,6 +305,7 @@ public class EmsDevicesSetting extends BaseEntity .append("updatedAt", getUpdatedAt()) .append("siteId", getSiteId()) .append("communicationStatus", getCommunicationStatus()) + .append("deviceId", getDeviceId()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java index 7fefdcc..f981197 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java @@ -11,13 +11,13 @@ import com.xzzn.common.annotation.Excel; * pcs支路数据对象 ems_pcs_branch_data * * @author xzzn - * @date 2025-06-24 + * @date 2025-06-29 */ public class EmsPcsBranchData extends BaseEntity { private static final long serialVersionUID = 1L; - /** $column.columnComment */ + /** */ private Long id; /** 放电状态 */ @@ -38,16 +38,96 @@ public class EmsPcsBranchData extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") - private Long deviceId; + private String deviceId; /** 支路id */ @Excel(name = "支路id") private Long branchId; + /** 电网U相电压 */ + @Excel(name = "电网U相电压") + private BigDecimal gridUVoltage; + + /** 电网V相电压 */ + @Excel(name = "电网V相电压") + private BigDecimal gridVVoltage; + + /** 电网W相电压 */ + @Excel(name = "电网W相电压") + private BigDecimal gridWVoltage; + + /** 输出U相电流 */ + @Excel(name = "输出U相电流") + private BigDecimal outputUCurrent; + + /** 输出V相电流 */ + @Excel(name = "输出V相电流") + private BigDecimal outputVCurrent; + + /** 输出W相电流 */ + @Excel(name = "输出W相电流") + private BigDecimal outputWCurrent; + + /** 视在功率 */ + @Excel(name = "视在功率") + private BigDecimal apparentPower; + + /** 有功功率 */ + @Excel(name = "有功功率") + private BigDecimal activePower; + + /** 无功功率 */ + @Excel(name = "无功功率") + private BigDecimal reactivePower; + + /** 功率因数 */ + @Excel(name = "功率因数") + private BigDecimal powerFactor; + + /** 频率 */ + @Excel(name = "频率") + private BigDecimal frequency; + + /** 内部温度 */ + @Excel(name = "内部温度") + private BigDecimal internalTemp; + + /** U相IGBT温度 */ + @Excel(name = "U相IGBT温度") + private BigDecimal uIgbtTemp; + + /** V相IGBT温度 */ + @Excel(name = "V相IGBT温度") + private BigDecimal vIgbtTemp; + + /** W相IGBT温度 */ + @Excel(name = "W相IGBT温度") + private BigDecimal wIgbtTemp; + + /** 并离网状态 */ + @Excel(name = "并离网状态") + private String gridStatus; + + /** 可用功率 */ + @Excel(name = "可用功率") + private BigDecimal availablePower; + + /** 总负载比 */ + @Excel(name = "总负载比") + private BigDecimal totalLoadRatio; + + /** 交流漏电流 */ + @Excel(name = "交流漏电流") + private BigDecimal acLeakageCurrent; + + /** 绝缘阻抗 */ + @Excel(name = "绝缘阻抗") + private BigDecimal insulationResistance; + public void setId(Long id) { this.id = id; @@ -98,22 +178,22 @@ public class EmsPcsBranchData extends BaseEntity return dcCurrent; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } - public void setDeviceId(Long deviceId) + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getDeviceId() + public String getDeviceId() { return deviceId; } @@ -128,6 +208,206 @@ public class EmsPcsBranchData extends BaseEntity return branchId; } + public void setGridUVoltage(BigDecimal gridUVoltage) + { + this.gridUVoltage = gridUVoltage; + } + + public BigDecimal getGridUVoltage() + { + return gridUVoltage; + } + + public void setGridVVoltage(BigDecimal gridVVoltage) + { + this.gridVVoltage = gridVVoltage; + } + + public BigDecimal getGridVVoltage() + { + return gridVVoltage; + } + + public void setGridWVoltage(BigDecimal gridWVoltage) + { + this.gridWVoltage = gridWVoltage; + } + + public BigDecimal getGridWVoltage() + { + return gridWVoltage; + } + + public void setOutputUCurrent(BigDecimal outputUCurrent) + { + this.outputUCurrent = outputUCurrent; + } + + public BigDecimal getOutputUCurrent() + { + return outputUCurrent; + } + + public void setOutputVCurrent(BigDecimal outputVCurrent) + { + this.outputVCurrent = outputVCurrent; + } + + public BigDecimal getOutputVCurrent() + { + return outputVCurrent; + } + + public void setOutputWCurrent(BigDecimal outputWCurrent) + { + this.outputWCurrent = outputWCurrent; + } + + public BigDecimal getOutputWCurrent() + { + return outputWCurrent; + } + + public void setApparentPower(BigDecimal apparentPower) + { + this.apparentPower = apparentPower; + } + + public BigDecimal getApparentPower() + { + return apparentPower; + } + + public void setActivePower(BigDecimal activePower) + { + this.activePower = activePower; + } + + public BigDecimal getActivePower() + { + return activePower; + } + + public void setReactivePower(BigDecimal reactivePower) + { + this.reactivePower = reactivePower; + } + + public BigDecimal getReactivePower() + { + return reactivePower; + } + + public void setPowerFactor(BigDecimal powerFactor) + { + this.powerFactor = powerFactor; + } + + public BigDecimal getPowerFactor() + { + return powerFactor; + } + + public void setFrequency(BigDecimal frequency) + { + this.frequency = frequency; + } + + public BigDecimal getFrequency() + { + return frequency; + } + + public void setInternalTemp(BigDecimal internalTemp) + { + this.internalTemp = internalTemp; + } + + public BigDecimal getInternalTemp() + { + return internalTemp; + } + + public void setuIgbtTemp(BigDecimal uIgbtTemp) + { + this.uIgbtTemp = uIgbtTemp; + } + + public BigDecimal getuIgbtTemp() + { + return uIgbtTemp; + } + + public void setvIgbtTemp(BigDecimal vIgbtTemp) + { + this.vIgbtTemp = vIgbtTemp; + } + + public BigDecimal getvIgbtTemp() + { + return vIgbtTemp; + } + + public void setwIgbtTemp(BigDecimal wIgbtTemp) + { + this.wIgbtTemp = wIgbtTemp; + } + + public BigDecimal getwIgbtTemp() + { + return wIgbtTemp; + } + + public void setGridStatus(String gridStatus) + { + this.gridStatus = gridStatus; + } + + public String getGridStatus() + { + return gridStatus; + } + + public void setAvailablePower(BigDecimal availablePower) + { + this.availablePower = availablePower; + } + + public BigDecimal getAvailablePower() + { + return availablePower; + } + + public void setTotalLoadRatio(BigDecimal totalLoadRatio) + { + this.totalLoadRatio = totalLoadRatio; + } + + public BigDecimal getTotalLoadRatio() + { + return totalLoadRatio; + } + + public void setAcLeakageCurrent(BigDecimal acLeakageCurrent) + { + this.acLeakageCurrent = acLeakageCurrent; + } + + public BigDecimal getAcLeakageCurrent() + { + return acLeakageCurrent; + } + + public void setInsulationResistance(BigDecimal insulationResistance) + { + this.insulationResistance = insulationResistance; + } + + public BigDecimal getInsulationResistance() + { + return insulationResistance; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -144,6 +424,26 @@ public class EmsPcsBranchData extends BaseEntity .append("siteId", getSiteId()) .append("deviceId", getDeviceId()) .append("branchId", getBranchId()) + .append("gridUVoltage", getGridUVoltage()) + .append("gridVVoltage", getGridVVoltage()) + .append("gridWVoltage", getGridWVoltage()) + .append("outputUCurrent", getOutputUCurrent()) + .append("outputVCurrent", getOutputVCurrent()) + .append("outputWCurrent", getOutputWCurrent()) + .append("apparentPower", getApparentPower()) + .append("activePower", getActivePower()) + .append("reactivePower", getReactivePower()) + .append("powerFactor", getPowerFactor()) + .append("frequency", getFrequency()) + .append("internalTemp", getInternalTemp()) + .append("uIgbtTemp", getuIgbtTemp()) + .append("vIgbtTemp", getvIgbtTemp()) + .append("wIgbtTemp", getwIgbtTemp()) + .append("gridStatus", getGridStatus()) + .append("availablePower", getAvailablePower()) + .append("totalLoadRatio", getTotalLoadRatio()) + .append("acLeakageCurrent", getAcLeakageCurrent()) + .append("insulationResistance", getInsulationResistance()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index 1864b04..079294f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * PCS数据对象 ems_pcs_data * * @author xzzn - * @date 2025-06-28 + * @date 2025-06-29 */ public class EmsPcsData extends BaseEntity { @@ -124,7 +124,7 @@ public class EmsPcsData extends BaseEntity /** 站点id */ @Excel(name = "站点id") - private Long siteId; + private String siteId; /** 设备唯一标识符 */ @Excel(name = "设备唯一标识符") @@ -450,12 +450,12 @@ public class EmsPcsData extends BaseEntity return dcCurrent; } - public void setSiteId(Long siteId) + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getSiteId() + public String getSiteId() { return siteId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java index 6143a21..d70f537 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * 站点对象 ems_site_setting * * @author xzzn - * @date 2025-06-20 + * @date 2025-06-29 */ public class EmsSiteSetting extends BaseEntity { @@ -50,6 +50,10 @@ public class EmsSiteSetting extends BaseEntity @Excel(name = "装机功率") private BigDecimal installPower; + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + public void setId(Long id) { this.id = id; @@ -130,6 +134,16 @@ public class EmsSiteSetting extends BaseEntity return installPower; } + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -146,6 +160,7 @@ public class EmsSiteSetting extends BaseEntity .append("updateBy", getUpdateBy()) .append("createTime", getCreateTime()) .append("updateTime", getUpdateTime()) + .append("siteId", getSiteId()) .toString(); } -} \ No newline at end of file +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java index 6f15ca1..6dfdff3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java @@ -27,7 +27,7 @@ public class AmmeterDataDetailInfo private BigDecimal valleyKwh; /** 总表设备Id */ - private Long deviceId; + private String deviceId; /** 数据更新时间 */ private Date updateTime; @@ -80,11 +80,11 @@ public class AmmeterDataDetailInfo this.category = category; } - public Long getDeviceId() { + public String getDeviceId() { return deviceId; } - public void setDeviceId(Long deviceId) { + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterDataList.java index edeb022..a03e286 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterDataList.java @@ -18,13 +18,13 @@ public class BMSBatteryClusterDataList { private BigDecimal minData; /** 单体最小值ID */ - private Long minDataID; + private String minDataID; /** 单体最大值 */ private BigDecimal maxData; /** 单体最大值ID */ - private Long maxDataID; + private String maxDataID; public String getDataName() { return dataName; @@ -50,11 +50,11 @@ public class BMSBatteryClusterDataList { this.minData = minData; } - public Long getMinDataID() { + public String getMinDataID() { return minDataID; } - public void setMinDataID(Long minDataID) { + public void setMinDataID(String minDataID) { this.minDataID = minDataID; } @@ -66,11 +66,11 @@ public class BMSBatteryClusterDataList { this.maxData = maxData; } - public Long getMaxDataID() { + public String getMaxDataID() { return maxDataID; } - public void setMaxDataID(Long maxDataID) { + public void setMaxDataID(String maxDataID) { this.maxDataID = maxDataID; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java index f576b6b..8de0dda 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java @@ -52,10 +52,10 @@ public class BMSBatteryClusterVo { private BigDecimal currentSoc; /** 站点id */ - private Long siteId; + private String siteId; /** 设备唯一标识符 */ - private Long deviceId; + private String deviceId; private List batteryDataList; @@ -171,19 +171,19 @@ public class BMSBatteryClusterVo { this.currentSoc = currentSoc; } - public Long getSiteId() { + public String getSiteId() { return siteId; } - public void setSiteId(Long siteId) { + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getDeviceId() { + public String getDeviceId() { return deviceId; } - public void setDeviceId(Long deviceId) { + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java index 1ef444c..394c921 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java @@ -33,10 +33,10 @@ public class BMSBatteryDataList { private BigDecimal minTemperature; /** 换电站id */ - private Long siteId; + private String siteId; /** 堆id */ - private Long stackDeviceId; + private String stackDeviceId; public Long getClusterId() { return clusterId; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java index e5b2a43..d209cd7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java @@ -52,10 +52,10 @@ public class BMSOverViewVo { private BigDecimal currentSoc; /** 站点id */ - private Long siteId; + private String siteId; /** 设备唯一标识符 */ - private Long deviceId; + private String deviceId; private List batteryDataList; @@ -171,19 +171,19 @@ public class BMSOverViewVo { this.currentSoc = currentSoc; } - public Long getDeviceId() { + public String getDeviceId() { return deviceId; } - public void setDeviceId(Long deviceId) { + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getSiteId() { + public String getSiteId() { return siteId; } - public void setSiteId(Long siteId) { + public void setSiteId(String siteId) { this.siteId = siteId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryClusterDataDetailVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryClusterDataDetailVo.java index 45e40e1..3cf27ed 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryClusterDataDetailVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryClusterDataDetailVo.java @@ -8,10 +8,10 @@ import java.math.BigDecimal; public class BatteryClusterDataDetailVo { /** 设备id */ - private Long siteId; + private String siteId; /** 电池簇id */ - private Long clusterId; + private String clusterId; /** 电压平均值 */ private BigDecimal avgVoltage; @@ -40,19 +40,19 @@ public class BatteryClusterDataDetailVo { /** soc最小值 */ private BigDecimal minSoc; - public Long getSiteId() { + public String getSiteId() { return siteId; } - public void setSiteId(Long siteId) { + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getClusterId() { + public String getClusterId() { return clusterId; } - public void setClusterId(Long clusterId) { + public void setClusterId(String clusterId) { this.clusterId = clusterId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java index 7990385..f71e713 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java @@ -1,61 +1,65 @@ package com.xzzn.ems.domain.vo; -import java.util.List; + +import java.math.BigDecimal; /** * 单站监控-单体电池数据 * */ public class BatteryDataStatsListVo { - /** - * 电压List - */ - private List voltageDataList; + /** 月份 */ + private String dataMonth; - /** - * 温度List - */ - private List tempDataList; + /** 电压 (V) */ + private BigDecimal voltage; - /** - * SOCList - */ - private List socDataList; + /** 温度 (℃) */ + private BigDecimal temperature; - /** - * SOHList - */ - private List sohDataList; + /** SOC (%) */ + private BigDecimal soc; - public List getVoltageDataList() { - return voltageDataList; + /** SOH (%) */ + private BigDecimal soh; + + public String getDataMonth() { + return dataMonth; } - public void setVoltageDataList(List voltageDataList) { - this.voltageDataList = voltageDataList; + public void setDataMonth(String dataMonth) { + this.dataMonth = dataMonth; } - public List getTempDataList() { - return tempDataList; + public BigDecimal getVoltage() { + return voltage; } - public void setTempDataList(List tempDataList) { - this.tempDataList = tempDataList; + public void setVoltage(BigDecimal voltage) { + this.voltage = voltage; } - public List getSocDataList() { - return socDataList; + public BigDecimal getTemperature() { + return temperature; } - public void setSocDataList(List socDataList) { - this.socDataList = socDataList; + public void setTemperature(BigDecimal temperature) { + this.temperature = temperature; } - public List getSohDataList() { - return sohDataList; + public BigDecimal getSoc() { + return soc; } - public void setSohDataList(List sohDataList) { - this.sohDataList = sohDataList; + public void setSoc(BigDecimal soc) { + this.soc = soc; + } + + public BigDecimal getSoh() { + return soh; + } + + public void setSoh(BigDecimal soh) { + this.soh = soh; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java deleted file mode 100644 index 2c4a21d..0000000 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsTemplate.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.xzzn.ems.domain.vo; - -import java.math.BigDecimal; - -/** - * 单体电池-数据统计模板 - * - */ -public class BatteryDataStatsTemplate { - /** - * 月份 - */ - private String dataMonth; - - /** - * 数据一 - */ - private BigDecimal dataOne; - - /** - * 数据二 - */ - private BigDecimal dataTwo; - - public String getDataMonth() { - return dataMonth; - } - - public void setDataMonth(String dataMonth) { - this.dataMonth = dataMonth; - } - - public BigDecimal getDataOne() { - return dataOne; - } - - public void setDataOne(BigDecimal dataOne) { - this.dataOne = dataOne; - } - - public BigDecimal getDataTwo() { - return dataTwo; - } - - public void setDataTwo(BigDecimal dataTwo) { - this.dataTwo = dataTwo; - } -} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java index 6b61911..4b0d923 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java @@ -25,10 +25,10 @@ public class PcsBranchInfo private BigDecimal dcCurrent; /** 站点id */ - private Long siteId; + private String siteId; /** 设备唯一标识符 */ - private Long deviceId; + private String deviceId; /** 支路id */ private Long branchId; @@ -65,19 +65,19 @@ public class PcsBranchInfo this.dcCurrent = dcCurrent; } - public Long getSiteId() { + public String getSiteId() { return siteId; } - public void setSiteId(Long siteId) { + public void setSiteId(String siteId) { this.siteId = siteId; } - public Long getDeviceId() { + public String getDeviceId() { return deviceId; } - public void setDeviceId(Long deviceId) { + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsDetailInfoVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsDetailInfoVo.java index 1fa77c1..5187f7b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsDetailInfoVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsDetailInfoVo.java @@ -81,29 +81,29 @@ public class PcsDetailInfoVo { private BigDecimal acFrequency; /** 站点id */ - private Long siteId; + private String siteId; /** 设备唯一标识符 */ - private Long deviceId; + private String deviceId; /** 设备名称 */ private String deviceName; private List pcsBranchInfoList; - public Long getDeviceId() { + public String getDeviceId() { return deviceId; } - public void setDeviceId(Long deviceId) { + public void setDeviceId(String deviceId) { this.deviceId = deviceId; } - public Long getSiteId() { + public String getSiteId() { return siteId; } - public void setSiteId(Long siteId) { + public void setSiteId(String siteId) { this.siteId = siteId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningHeadInfoVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRunningHeadInfoVo.java similarity index 97% rename from ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningHeadInfoVo.java rename to ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRunningHeadInfoVo.java index 1e87d0f..50583fe 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningHeadInfoVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRunningHeadInfoVo.java @@ -6,7 +6,7 @@ import java.math.BigDecimal; * 单站监控-设备监控-实时运行头部行数据 * */ -public class SiteMonitorRuningHeadInfoVo { +public class SiteMonitorRunningHeadInfoVo { /** * 实时有功功率 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java index d7592c4..0127cc6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java @@ -66,7 +66,7 @@ public interface EmsAlarmRecordsMapper * 根据站点id获取告警记录 * */ - public List getAlarmRecordsBySiteId(Long siteId); + public List getAlarmRecordsBySiteId(String siteId); /** * 获取告警趋势数据 diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index 2cf34aa..7c1d4e6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -65,5 +65,5 @@ public interface EmsAmmeterDataMapper * @param siteId * @return */ - public List getAmmeterDetailInfo(Long siteId); + public List getAmmeterDetailInfo(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java index f98b7ce..8502f5e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java @@ -67,7 +67,7 @@ public interface EmsBatteryClusterMapper * @param siteId * @return */ - public List getBMSBatteryCluster(Long siteId); + public List getBMSBatteryCluster(String siteId); /** * 根据site_di和堆id获取簇数据和单体数据 @@ -75,5 +75,5 @@ public interface EmsBatteryClusterMapper * @param stackDeviceId * @return */ - public List getBmsBatteryData(@Param("siteId")Long siteId, @Param("stackDeviceId")Long stackDeviceId); + public List getBmsBatteryData(@Param("siteId")String siteId, @Param("stackDeviceId")String stackDeviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java index 7862183..cdaa2b4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java @@ -70,7 +70,7 @@ public interface EmsBatteryDataMapper * @param siteId * @return */ - public EmsBatteryData getBatteryDataBySiteId(Long siteId); + public EmsBatteryData getBatteryDataBySiteId(String siteId); /** * 根据siteId和簇id获取单体数据 @@ -78,7 +78,7 @@ public interface EmsBatteryDataMapper * @param clusterDeviceId * @return */ - public BatteryClusterDataDetailVo getBatteryDataByClusterId(@Param("siteId")Long siteId, @Param("clusterDeviceId")Long clusterDeviceId); + public BatteryClusterDataDetailVo getBatteryDataByClusterId(@Param("siteId")String siteId, @Param("clusterDeviceId")String clusterDeviceId); /** * 获取最大最小的单体id diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java index e1b8155..7347fc6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java @@ -65,5 +65,5 @@ public interface EmsBatteryStackMapper * @param siteId * @return */ - public List selectEmsBatteryStackBySiteId(Long siteId); + public List selectEmsBatteryStackBySiteId(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingDataMapper.java index e1bc42f..4b4d984 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingDataMapper.java @@ -64,5 +64,5 @@ public interface EmsCoolingDataMapper * @param siteId * @return */ - public List getCoolingDataList(Long siteId); + public List getCoolingDataList(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 8002a45..a565438 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -66,19 +66,19 @@ public interface EmsDevicesSettingMapper * @param siteId * @return */ - public List> getAllStackInfoBySiteId(Long siteId); + public List> getAllStackInfoBySiteId(String siteId); /** * 根据电池堆id获取所有电池簇 * @param stackDeviceId * @return */ - public List> getAllClusterInfoByStackId(Long stackDeviceId); + public List> getAllClusterInfoByStackId(String stackDeviceId); /** * 获取设备通信状态 * @param deviceId * @return */ - public Map getDeviceStatus(Long deviceId); + public Map getDeviceStatus(String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java index 80baed6..96cc5ff 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java @@ -3,13 +3,13 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsPcsBranchData; import com.xzzn.ems.domain.vo.PcsBranchInfo; -import org.apache.ibatis.annotations.Param; +import io.lettuce.core.dynamic.annotation.Param; /** * pcs支路数据Mapper接口 * * @author xzzn - * @date 2025-06-24 + * @date 2025-06-29 */ public interface EmsPcsBranchDataMapper { @@ -67,5 +67,5 @@ public interface EmsPcsBranchDataMapper * @param deviceId * @return */ - public List getPcsBranchInfoList(@Param("siteId")Long siteId, @Param("deviceId")Long deviceId); + public List getPcsBranchInfoList(@Param("siteId")String siteId, @Param("deviceId")String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index 55dd7b5..a0f7a00 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -8,7 +8,7 @@ import com.xzzn.ems.domain.EmsPcsData; import com.xzzn.ems.domain.vo.ElectricIndexList; import com.xzzn.ems.domain.vo.PcsDetailInfoVo; import com.xzzn.ems.domain.vo.SiteMonitorDataVo; -import com.xzzn.ems.domain.vo.SiteMonitorRuningHeadInfoVo; +import com.xzzn.ems.domain.vo.SiteMonitorRunningHeadInfoVo; /** * PCS数据Mapper接口 @@ -71,21 +71,21 @@ public interface EmsPcsDataMapper * @param siteId * @return */ - public List getPcsDataBySiteId(Long siteId); + public List getPcsDataBySiteId(String siteId); /** * 根据站点获取电网实时功率=sum(总交流有功电率) * @param siteId * @return */ - public BigDecimal getGridNrtPower(Long siteId); + public BigDecimal getGridNrtPower(String siteId); /** * 根据站点获取设备监控的实时运行头信息 * @param siteId * @return */ - public SiteMonitorRuningHeadInfoVo getSiteRunningHeadInfo(Long siteId); + public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId); /** * 获取每月的充电量和放电量 @@ -98,7 +98,7 @@ public interface EmsPcsDataMapper * @param siteId * @return */ - public List getPcsDetailInfoBySiteId(Long siteId); + public List getPcsDetailInfoBySiteId(String siteId); /** * 获取总充+总放 diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java index 807a767..152726c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java @@ -65,4 +65,11 @@ public interface EmsSiteSettingMapper * @return */ public SiteTotalInfoVo getSiteTotalInfo(); + + /** + * 根据站点id获取站点信息 + * @param siteId + * @return + */ + public EmsSiteSetting selectEmsSiteSettingBySiteId(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index 8bdd27b..ef3ee31 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -18,9 +18,9 @@ public interface IEmsSiteService public SiteTotalInfoVo getSiteTotalInfo(); - public List> getAllStackInfo(Long siteId); + public List> getAllStackInfo(String siteId); - public List> getAllClusterInfo(Long stackDeviceId); + public List> getAllClusterInfo(String stackDeviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IHomePageService.java b/ems-system/src/main/java/com/xzzn/ems/service/IHomePageService.java index 81ba148..25823ce 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IHomePageService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IHomePageService.java @@ -13,7 +13,7 @@ public interface IHomePageService public SiteTotalInfoVo getSiteTotalInfo(); - public SingleSiteBaseInfo getSingleSiteBaseInfo(Long siteId); + public SingleSiteBaseInfo getSingleSiteBaseInfo(String siteId); public HomePageDataViewVo getHomePageDataList(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index a871b3e..7154a5e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -12,22 +12,22 @@ import java.util.List; public interface ISingleSiteService { - public SiteMonitorHomeVo getSiteMonitorDataVo(Long siteId); + public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId); - public SiteMonitorRuningHeadInfoVo getSiteRunningHeadInfo(Long siteId); + public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId); - public SiteMonitorRuningInfoVo getRunningGraph(Long siteId); + public SiteMonitorRuningInfoVo getRunningGraph(String siteId); - public List getPcsDetailInfo(Long siteId); + public List getPcsDetailInfo(String siteId); - public List getBMSOverView(Long siteId); + public List getBMSOverView(String siteId); - public List getBMSBatteryCluster(Long siteId); + public List getBMSBatteryCluster(String siteId); - public List getCoolingDataList(Long siteId); + public List getCoolingDataList(String siteId); - public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId); + public BatteryDataStatsListVo getClusterDataInfoList(String clusterDeviceId); - public List getAmmeterDataList(Long siteId); + public List getAmmeterDataList(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index 98a2282..1519a79 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -40,7 +40,7 @@ public class EmsSiteServiceImpl implements IEmsSiteService * @return */ @Override - public List> getAllStackInfo(Long siteId) { + public List> getAllStackInfo(String siteId) { return emsDevicesMapper.getAllStackInfoBySiteId(siteId); } @@ -50,7 +50,7 @@ public class EmsSiteServiceImpl implements IEmsSiteService * @return */ @Override - public List> getAllClusterInfo(Long stackDeviceId) { + public List> getAllClusterInfo(String stackDeviceId) { return emsDevicesMapper.getAllClusterInfoByStackId(stackDeviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index b563b98..be5a4dc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -46,12 +46,12 @@ public class HomePageServiceImpl implements IHomePageService // 单站点基本信息 @Override - public SingleSiteBaseInfo getSingleSiteBaseInfo(Long siteId) { + public SingleSiteBaseInfo getSingleSiteBaseInfo(String siteId) { SingleSiteBaseInfo singleSiteBaseInfo = new SingleSiteBaseInfo(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { // 站点基本信息 - EmsSiteSetting emsSite = emsSiteMapper.selectEmsSiteSettingById(siteId); + EmsSiteSetting emsSite = emsSiteMapper.selectEmsSiteSettingBySiteId(siteId); if (emsSite != null) { // 装机功率+装机容量 singleSiteBaseInfo.setSiteName(emsSite.getSiteName()); @@ -62,7 +62,8 @@ public class HomePageServiceImpl implements IHomePageService siteLocation[1] = emsSite.getLatitude() == null ? "" : emsSite.getLatitude().toString(); singleSiteBaseInfo.setSiteLocation(siteLocation);//站点位置 singleSiteBaseInfo.setSiteAddress(emsSite.getSiteAddress()); - singleSiteBaseInfo.setRunningTime(DateUtils.parseDateToStr("yyyy-MM-dd",emsSite.getRunningTime()));//投运时间 + singleSiteBaseInfo.setRunningTime(emsSite.getRunningTime() == null ? null : + DateUtils.parseDateToStr("yyyy-MM-dd",emsSite.getRunningTime()));//投运时间 // 七天放电数据统计 List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId); singleSiteBaseInfo.setSevenDayDisChargeStats(siteMonitorDataVoList); @@ -122,17 +123,14 @@ public class HomePageServiceImpl implements IHomePageService public HomePageDataViewVo getHomePageDataList() { HomePageDataViewVo homePageDataViewVo = new HomePageDataViewVo(); // 电量指标 - List electricDataList = new ArrayList(); - electricDataList = emsPcsDataMapper.getElectDataList(); + List electricDataList = emsPcsDataMapper.getElectDataList(); homePageDataViewVo.setElecDataList(electricDataList); // 系统效率 // 告警趋势 - List alarmTrendList = new ArrayList(); - alarmTrendList = alarmRecordsMapper.getAlarmTrendList(); + List alarmTrendList = alarmRecordsMapper.getAlarmTrendList(); homePageDataViewVo.setAlarmDataList(alarmTrendList); // 设备告警占比 - List deviceAlarmPropList = new ArrayList(); - deviceAlarmPropList = alarmRecordsMapper.getDeviceAlarmPropList(); + List deviceAlarmPropList = alarmRecordsMapper.getDeviceAlarmPropList(); homePageDataViewVo.setDeviceAlarmList(deviceAlarmPropList); // 告警等级分布 return homePageDataViewVo; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 9c9fd63..2c2c4f6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -46,10 +46,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private EmsDevicesSettingMapper emsDevicesSettingMapper; @Override - public SiteMonitorHomeVo getSiteMonitorDataVo(Long siteId) { + public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { SiteMonitorHomeVo siteMonitorHomeVo = new SiteMonitorHomeVo(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { // 实时告警数据 名称+状态+告警内容 List siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId); siteMonitorHomeVo.setSiteMonitorHomeAlarmVo(siteMonitorHomeAlarmVo); @@ -106,10 +106,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取单站监控实时运行头部数据 @Override - public SiteMonitorRuningHeadInfoVo getSiteRunningHeadInfo(Long siteId) { - SiteMonitorRuningHeadInfoVo siteMonitorRunningHeadInfoVo = new SiteMonitorRuningHeadInfoVo(); + public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId) { + SiteMonitorRunningHeadInfoVo siteMonitorRunningHeadInfoVo = new SiteMonitorRunningHeadInfoVo(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { // 实时有功功率/实时无功功率/今日充电量/今日放电量 siteMonitorRunningHeadInfoVo = emsPcsDataMapper.getSiteRunningHeadInfo(siteId); // 电池簇SOC @@ -126,9 +126,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取单站监控实时运行曲线图数据 @Override - public SiteMonitorRuningInfoVo getRunningGraph(Long siteId) { + public SiteMonitorRuningInfoVo getRunningGraph(String siteId) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { //储能功率list //pcs平均温度list //电池平均soclist @@ -139,17 +139,17 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 根据site_id获取pcs详细数据+支路数据 @Override - public List getPcsDetailInfo(Long siteId) { + public List getPcsDetailInfo(String siteId) { List pcsDetailInfoVoList = new ArrayList<>(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { // 获取pcs最新数据 pcsDetailInfoVoList = emsPcsDataMapper.getPcsDetailInfoBySiteId(siteId); if (!CollectionUtils.isEmpty(pcsDetailInfoVoList)) { for (PcsDetailInfoVo pcsDetailInfoVo : pcsDetailInfoVoList) { - Long deviceId = pcsDetailInfoVo.getDeviceId(); + String deviceId = pcsDetailInfoVo.getDeviceId(); // 获取支路最新数据 - if (deviceId != null) { + if (!StringUtils.isEmpty(deviceId)) { List pcsBranchInfoList = emsPcsBranchDataMapper.getPcsBranchInfoList(siteId, deviceId); pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList); } @@ -161,17 +161,17 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取BMS总览数据 @Override - public List getBMSOverView(Long siteId) { + public List getBMSOverView(String siteId) { List bmsOverViewVoList = new ArrayList<>(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { // 获取电池堆list bmsOverViewVoList = emsBatteryStackMapper.selectEmsBatteryStackBySiteId(siteId); if (!CollectionUtils.isEmpty(bmsOverViewVoList)) { for (BMSOverViewVo bmsOverViewVo : bmsOverViewVoList) { // 获取单体电池数据-待确认 - Long stackDeviceId = bmsOverViewVo.getDeviceId(); - if (stackDeviceId != null) { + String stackDeviceId = bmsOverViewVo.getDeviceId(); + if (!StringUtils.isEmpty(stackDeviceId)) { List batteryDataList = new ArrayList<>(); batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId); bmsOverViewVo.setBatteryDataList(batteryDataList); @@ -184,17 +184,17 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取BMS电池簇数据 @Override - public List getBMSBatteryCluster(Long siteId) { + public List getBMSBatteryCluster(String siteId) { List bmsBatteryClusterVoList = new ArrayList<>(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { bmsBatteryClusterVoList = emsBatteryClusterMapper.getBMSBatteryCluster(siteId); if (!CollectionUtils.isEmpty(bmsBatteryClusterVoList)) { for (BMSBatteryClusterVo bmsBatteryClusterVo : bmsBatteryClusterVoList) { - Long clusterDeviceId = bmsBatteryClusterVo.getDeviceId(); + String clusterDeviceId = bmsBatteryClusterVo.getDeviceId(); List clusterDataList = new ArrayList<>(); - if (clusterDeviceId != null) { + if (!StringUtils.isEmpty(clusterDeviceId)) { // 获取单体电池数据-平均/最大/最小 BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId); // 处理数据 @@ -218,14 +218,14 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 设置对应单体id List> dataIdMapList = emsBatteryDataMapper.getDataIdsMap(batteryClusterDataDetailVo); - Map resultIdMap = new HashMap<>(); + Map resultIdMap = new HashMap<>(); if (!CollectionUtils.isEmpty(dataIdMapList)) { resultIdMap = dataIdMapList.stream() .filter(map -> map.containsKey("type") && map.containsKey("device_id")) // 过滤无效数据 .filter(map -> map.get("type") instanceof String && map.get("device_id") instanceof Number) // 确保类型正确 .collect(Collectors.toMap( map -> (String) map.get("type"), // 键:type 字段 - map -> ((Number) map.get("device_id")).longValue(), // 值:device_id 转为 int + map -> (String) map.get("device_id"), // 值:device_id 转为 int (existing, replacement) -> existing // 处理键冲突的策略 )); @@ -253,9 +253,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取液冷设备参数 @Override - public List getCoolingDataList(Long siteId) { + public List getCoolingDataList(String siteId) { List emsCoolingDataList = new ArrayList<>(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { emsCoolingDataList = emsCoolingDataMapper.getCoolingDataList(siteId); } return emsCoolingDataList; @@ -268,8 +268,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public BatteryDataStatsListVo getClusterDataInfoList(Long clusterDeviceId) { - return null; + public BatteryDataStatsListVo getClusterDataInfoList(String clusterDeviceId) { + BatteryDataStatsListVo batteryDataStatsListVo = new BatteryDataStatsListVo(); + return batteryDataStatsListVo; } /** @@ -278,15 +279,15 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public List getAmmeterDataList(Long siteId) { + public List getAmmeterDataList(String siteId) { List ammeterDataVos = new ArrayList<>(); AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); - if (siteId != null) { + if (!StringUtils.isEmpty(siteId)) { List ammeterDataDetailInfos = emsAmmeterDataMapper.getAmmeterDetailInfo(siteId); ammeterDataVo.setAmmeterDataDetailInfos(ammeterDataDetailInfos); if (!CollectionUtils.isEmpty(ammeterDataDetailInfos)) { // 获取通信状态 - Long deviceId = ammeterDataDetailInfos.get(0).getDeviceId(); + String deviceId = ammeterDataDetailInfos.get(0).getDeviceId(); Map map = emsDevicesSettingMapper.getDeviceStatus(deviceId); ammeterDataVo.setEmsCommunicationStatus(map.get("communication_status").toString()); // 数据更新时间 diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index 2c92e25..5d7f60d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -35,8 +35,8 @@ and alarm_start_time = #{alarmStartTime} and alarm_end_time = #{alarmEndTime} and status = #{status} - and site_id = #{siteId} - and device_id = #{deviceId} + and site_id = #{siteId} + and device_id = #{deviceId} and device_name like concat('%', #{deviceName}, '%') @@ -61,7 +61,7 @@ update_time, remark, site_id, - device_id, + device_id, device_name, @@ -77,7 +77,7 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, + #{deviceId}, #{deviceName}, @@ -97,7 +97,7 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, + device_id = #{deviceId}, device_name = #{deviceName}, where id = #{id} @@ -114,7 +114,7 @@ - select device_name as deviceName, status,alarm_content as alarmContent from ems_alarm_records diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 1e91afe..63edc13 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -9,6 +9,7 @@ + @@ -22,7 +23,7 @@ - select id, data_update_time, category, total_kwh, peak_kwh, flat_kwh, valley_kwh, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_ammeter_data + select id, data_update_time, category, total_kwh, sharp_kwh, peak_kwh, flat_kwh, valley_kwh, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_ammeter_data @@ -50,6 +52,7 @@ data_update_time, category, total_kwh, + sharp_kwh, peak_kwh, flat_kwh, valley_kwh, @@ -59,12 +62,13 @@ update_time, remark, site_id, - device_id, + device_id, #{dataUpdateTime}, #{category}, #{totalKwh}, + #{sharpKwh}, #{peakKwh}, #{flatKwh}, #{valleyKwh}, @@ -74,7 +78,7 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, + #{deviceId}, @@ -84,6 +88,7 @@ data_update_time = #{dataUpdateTime}, category = #{category}, total_kwh = #{totalKwh}, + sharp_kwh = #{sharpKwh}, peak_kwh = #{peakKwh}, flat_kwh = #{flatKwh}, valley_kwh = #{valleyKwh}, @@ -93,7 +98,7 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, + device_id = #{deviceId}, where id = #{id} @@ -108,9 +113,11 @@ #{id} - select t.category as category, t.total_kwh as totalKwh, + t.sharp_kwh as sharpKwh, t.flat_kwh as flatKwh, t.peak_kwh as peakKwh, t.valley_kwh as valleyKwh, diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index bd4f43c..31349cb 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -26,10 +26,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - select id, work_status, pcs_communication_status, ems_communication_status, cluster_voltage, chargeable_capacity, total_charged_capacity, cluster_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_battery_cluster + select id, work_status, pcs_communication_status, ems_communication_status, cluster_voltage, chargeable_capacity, total_charged_capacity, cluster_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id, stack_device_id, max_allowed_charge_power, max_allowed_discharge_power, max_allowed_charge_voltage, max_allowed_discharge_voltage, max_allowed_charge_current, max_allowed_discharge_current, battery_pack_voltage, battery_pack_current, battery_pack_temp, battery_pack_soc, battery_pack_soh, battery_pack_insulation_resistance, avg_cell_voltage, avg_cell_temp, max_cell_voltage, max_cell_voltage_id, min_cell_voltage, min_cell_voltage_id, max_cell_temp, max_cell_temp_id, min_cell_temp, min_cell_temp_id, max_cell_soc, max_cell_soc_id, min_cell_soc, min_cell_soc_id, max_cell_soh, max_cell_soh_id, min_cell_soh, min_cell_soh_id, total_charge_energy, total_discharge_energy from ems_battery_cluster @@ -80,7 +146,40 @@ update_time, remark, site_id, - device_id, + device_id, + stack_device_id, + max_allowed_charge_power, + max_allowed_discharge_power, + max_allowed_charge_voltage, + max_allowed_discharge_voltage, + max_allowed_charge_current, + max_allowed_discharge_current, + battery_pack_voltage, + battery_pack_current, + battery_pack_temp, + battery_pack_soc, + battery_pack_soh, + battery_pack_insulation_resistance, + avg_cell_voltage, + avg_cell_temp, + max_cell_voltage, + max_cell_voltage_id, + min_cell_voltage, + min_cell_voltage_id, + max_cell_temp, + max_cell_temp_id, + min_cell_temp, + min_cell_temp_id, + max_cell_soc, + max_cell_soc_id, + min_cell_soc, + min_cell_soc_id, + max_cell_soh, + max_cell_soh_id, + min_cell_soh, + min_cell_soh_id, + total_charge_energy, + total_discharge_energy, #{workStatus}, @@ -102,7 +201,40 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, + #{deviceId}, + #{stackDeviceId}, + #{maxAllowedChargePower}, + #{maxAllowedDischargePower}, + #{maxAllowedChargeVoltage}, + #{maxAllowedDischargeVoltage}, + #{maxAllowedChargeCurrent}, + #{maxAllowedDischargeCurrent}, + #{batteryPackVoltage}, + #{batteryPackCurrent}, + #{batteryPackTemp}, + #{batteryPackSoc}, + #{batteryPackSoh}, + #{batteryPackInsulationResistance}, + #{avgCellVoltage}, + #{avgCellTemp}, + #{maxCellVoltage}, + #{maxCellVoltageId}, + #{minCellVoltage}, + #{minCellVoltageId}, + #{maxCellTemp}, + #{maxCellTempId}, + #{minCellTemp}, + #{minCellTempId}, + #{maxCellSoc}, + #{maxCellSocId}, + #{minCellSoc}, + #{minCellSocId}, + #{maxCellSoh}, + #{maxCellSohId}, + #{minCellSoh}, + #{minCellSohId}, + #{totalChargeEnergy}, + #{totalDischargeEnergy}, @@ -128,7 +260,40 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, + device_id = #{deviceId}, + stack_device_id = #{stackDeviceId}, + max_allowed_charge_power = #{maxAllowedChargePower}, + max_allowed_discharge_power = #{maxAllowedDischargePower}, + max_allowed_charge_voltage = #{maxAllowedChargeVoltage}, + max_allowed_discharge_voltage = #{maxAllowedDischargeVoltage}, + max_allowed_charge_current = #{maxAllowedChargeCurrent}, + max_allowed_discharge_current = #{maxAllowedDischargeCurrent}, + battery_pack_voltage = #{batteryPackVoltage}, + battery_pack_current = #{batteryPackCurrent}, + battery_pack_temp = #{batteryPackTemp}, + battery_pack_soc = #{batteryPackSoc}, + battery_pack_soh = #{batteryPackSoh}, + battery_pack_insulation_resistance = #{batteryPackInsulationResistance}, + avg_cell_voltage = #{avgCellVoltage}, + avg_cell_temp = #{avgCellTemp}, + max_cell_voltage = #{maxCellVoltage}, + max_cell_voltage_id = #{maxCellVoltageId}, + min_cell_voltage = #{minCellVoltage}, + min_cell_voltage_id = #{minCellVoltageId}, + max_cell_temp = #{maxCellTemp}, + max_cell_temp_id = #{maxCellTempId}, + min_cell_temp = #{minCellTemp}, + min_cell_temp_id = #{minCellTempId}, + max_cell_soc = #{maxCellSoc}, + max_cell_soc_id = #{maxCellSocId}, + min_cell_soc = #{minCellSoc}, + min_cell_soc_id = #{minCellSocId}, + max_cell_soh = #{maxCellSoh}, + max_cell_soh_id = #{maxCellSohId}, + min_cell_soh = #{minCellSoh}, + min_cell_soh_id = #{minCellSohId}, + total_charge_energy = #{totalChargeEnergy}, + total_discharge_energy = #{totalDischargeEnergy}, where id = #{id} @@ -144,7 +309,7 @@ - select td.device_name as deviceName, tmp.work_status as workStatus, tmp.pcs_communication_status as pcsCommunicationStatus, tmp.ems_communication_status as emsCommunicationStatus, tmp.cluster_voltage as clusterVoltage,tmp.chargeable_capacity as chargeableCapacity, tmp.total_charged_capacity as totalChargedCapacity, diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index ad7ab18..d47499c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -39,9 +39,9 @@ and soc = #{soc} and soh = #{soh} and data_timestamp = #{dataTimestamp} - and site_id = #{siteId} - and device_id = #{deviceId} - and cluster_device_id = #{clusterDeviceId} + and site_id = #{siteId} + and device_id = #{deviceId} + and cluster_device_id = #{clusterDeviceId} @@ -67,8 +67,8 @@ update_time, remark, site_id, - device_id, - cluster_device_id, + device_id, + cluster_device_id, #{batteryPack}, @@ -85,8 +85,8 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, - #{clusterDeviceId}, + #{deviceId}, + #{clusterDeviceId}, @@ -107,8 +107,8 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, - cluster_device_id = #{clusterDeviceId}, + device_id = #{deviceId}, + cluster_device_id = #{clusterDeviceId}, where id = #{id} @@ -124,7 +124,7 @@ - where site_id = #{siteId} and DATE(data_timestamp) = DATE(NOW()) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 724d750..db08ffb 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -26,10 +26,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - select id, work_status, pcs_communication_status, ems_communication_status, total_voltage, chargeable_capacity, total_charged_capacity, total_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_battery_stack + select id, work_status, pcs_communication_status, ems_communication_status, total_voltage, chargeable_capacity, total_charged_capacity, total_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id, max_allowed_charge_power, max_allowed_discharge_power, max_allowed_charge_voltage, max_allowed_discharge_voltage, max_allowed_charge_current, max_allowed_discharge_current, battery_pack_voltage, battery_pack_current, battery_pack_temp, battery_pack_soc, battery_pack_soh, battery_pack_insulation_resistance, avg_cell_voltage, avg_cell_temp, max_cell_voltage, max_cell_voltage_id, min_cell_voltage, min_cell_voltage_id, max_cell_temp, max_cell_temp_id, min_cell_temp, min_cell_temp_id, max_cell_soc, max_cell_soc_id, min_cell_soc, min_cell_soc_id, max_cell_soh, max_cell_soh_id, min_cell_soh, min_cell_soh_id, total_charge_energy, total_discharge_energy from ems_battery_stack @@ -80,7 +144,39 @@ update_time, remark, site_id, - device_id, + device_id, + max_allowed_charge_power, + max_allowed_discharge_power, + max_allowed_charge_voltage, + max_allowed_discharge_voltage, + max_allowed_charge_current, + max_allowed_discharge_current, + battery_pack_voltage, + battery_pack_current, + battery_pack_temp, + battery_pack_soc, + battery_pack_soh, + battery_pack_insulation_resistance, + avg_cell_voltage, + avg_cell_temp, + max_cell_voltage, + max_cell_voltage_id, + min_cell_voltage, + min_cell_voltage_id, + max_cell_temp, + max_cell_temp_id, + min_cell_temp, + min_cell_temp_id, + max_cell_soc, + max_cell_soc_id, + min_cell_soc, + min_cell_soc_id, + max_cell_soh, + max_cell_soh_id, + min_cell_soh, + min_cell_soh_id, + total_charge_energy, + total_discharge_energy, #{workStatus}, @@ -102,7 +198,39 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, + #{deviceId}, + #{maxAllowedChargePower}, + #{maxAllowedDischargePower}, + #{maxAllowedChargeVoltage}, + #{maxAllowedDischargeVoltage}, + #{maxAllowedChargeCurrent}, + #{maxAllowedDischargeCurrent}, + #{batteryPackVoltage}, + #{batteryPackCurrent}, + #{batteryPackTemp}, + #{batteryPackSoc}, + #{batteryPackSoh}, + #{batteryPackInsulationResistance}, + #{avgCellVoltage}, + #{avgCellTemp}, + #{maxCellVoltage}, + #{maxCellVoltageId}, + #{minCellVoltage}, + #{minCellVoltageId}, + #{maxCellTemp}, + #{maxCellTempId}, + #{minCellTemp}, + #{minCellTempId}, + #{maxCellSoc}, + #{maxCellSocId}, + #{minCellSoc}, + #{minCellSocId}, + #{maxCellSoh}, + #{maxCellSohId}, + #{minCellSoh}, + #{minCellSohId}, + #{totalChargeEnergy}, + #{totalDischargeEnergy}, @@ -128,7 +256,39 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, + device_id = #{deviceId}, + max_allowed_charge_power = #{maxAllowedChargePower}, + max_allowed_discharge_power = #{maxAllowedDischargePower}, + max_allowed_charge_voltage = #{maxAllowedChargeVoltage}, + max_allowed_discharge_voltage = #{maxAllowedDischargeVoltage}, + max_allowed_charge_current = #{maxAllowedChargeCurrent}, + max_allowed_discharge_current = #{maxAllowedDischargeCurrent}, + battery_pack_voltage = #{batteryPackVoltage}, + battery_pack_current = #{batteryPackCurrent}, + battery_pack_temp = #{batteryPackTemp}, + battery_pack_soc = #{batteryPackSoc}, + battery_pack_soh = #{batteryPackSoh}, + battery_pack_insulation_resistance = #{batteryPackInsulationResistance}, + avg_cell_voltage = #{avgCellVoltage}, + avg_cell_temp = #{avgCellTemp}, + max_cell_voltage = #{maxCellVoltage}, + max_cell_voltage_id = #{maxCellVoltageId}, + min_cell_voltage = #{minCellVoltage}, + min_cell_voltage_id = #{minCellVoltageId}, + max_cell_temp = #{maxCellTemp}, + max_cell_temp_id = #{maxCellTempId}, + min_cell_temp = #{minCellTemp}, + min_cell_temp_id = #{minCellTempId}, + max_cell_soc = #{maxCellSoc}, + max_cell_soc_id = #{maxCellSocId}, + min_cell_soc = #{minCellSoc}, + min_cell_soc_id = #{minCellSocId}, + max_cell_soh = #{maxCellSoh}, + max_cell_soh_id = #{maxCellSohId}, + min_cell_soh = #{minCellSoh}, + min_cell_soh_id = #{minCellSohId}, + total_charge_energy = #{totalChargeEnergy}, + total_discharge_energy = #{totalDischargeEnergy}, where id = #{id} @@ -144,7 +304,7 @@ - select td.device_name as deviceName,tmp.work_status as workStatus, tmp.pcs_communication_status as pcsCommunicationStatus,tmp.ems_communication_status as emsCommunicationStatus, tmp.total_voltage as totalVoltage,tmp.chargeable_capacity as chargeableCapacity,tmp.total_charged_capacity as totalChargedCapacity, diff --git a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml index 89808f1..71ba86c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml @@ -40,8 +40,8 @@ and heating_stop_point = #{heatingStopPoint} and cooling_stop_point = #{coolingStopPoint} and low_temp_alarm_point = #{lowTempAlarmPoint} - and site_id = #{siteId} - and device_id = #{deviceId} + and site_id = #{siteId} + and device_id = #{deviceId} @@ -68,7 +68,7 @@ update_time, remark, site_id, - device_id, + device_id, #{systemName}, @@ -86,7 +86,7 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, + #{deviceId}, @@ -108,7 +108,7 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, + device_id = #{deviceId}, where id = #{id} @@ -124,10 +124,10 @@ - select t.* from ems_cooling_data t - where t.site_id = 1 + where t.site_id = #{siteId} and t.update_time = ( select MAX(tcd.update_time) from ems_cooling_data tcd where tcd.site_id = t.site_id and tcd.device_id = t.device_id) order by t.system_name diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 39598d2..0df74f0 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -23,10 +23,11 @@ + - select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status from ems_devices_setting + select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id from ems_devices_setting @@ -77,6 +79,7 @@ updated_at, site_id, communication_status, + device_id, #{deviceName}, @@ -96,6 +99,7 @@ #{updatedAt}, #{siteId}, #{communicationStatus}, + #{deviceId}, @@ -119,6 +123,7 @@ updated_at = #{updatedAt}, site_id = #{siteId}, communication_status = #{communicationStatus}, + device_id = #{deviceId}, where id = #{id} @@ -134,21 +139,21 @@ - + select device_id as id,device_name as deviceName from ems_devices_setting + where device_id in ( select distinct eb.device_id from ems_battery_stack eb where eb.site_id = #{siteId}) - + select device_id as id,device_name as deviceName from ems_devices_setting - where id in (select distinct eb.device_id from ems_battery_cluster eb where eb.stack_device_id = #{stackDeviceId}) + where device_id in (select distinct eb.device_id from ems_battery_cluster eb where eb.stack_device_id = #{stackDeviceId}) - + select device_id as id,communication_status from ems_devices_setting - where id = #{deviceId} + where device_id = #{deviceId} \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml index 65561e9..9bab5b1 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml @@ -18,10 +18,30 @@ + + + + + + + + + + + + + + + + + + + + - select id, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, branch_id from ems_pcs_branch_data + select id, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, branch_id, grid_u_voltage, grid_v_voltage, grid_w_voltage, output_u_current, output_v_current, output_w_current, apparent_power, active_power, reactive_power, power_factor, frequency, internal_temp, u_igbt_temp, v_igbt_temp, w_igbt_temp, grid_status, available_power, total_load_ratio, ac_leakage_current, insulation_resistance from ems_pcs_branch_data @@ -55,8 +95,28 @@ update_time, remark, site_id, - device_id, + device_id, branch_id, + grid_u_voltage, + grid_v_voltage, + grid_w_voltage, + output_u_current, + output_v_current, + output_w_current, + apparent_power, + active_power, + reactive_power, + power_factor, + frequency, + internal_temp, + u_igbt_temp, + v_igbt_temp, + w_igbt_temp, + grid_status, + available_power, + total_load_ratio, + ac_leakage_current, + insulation_resistance, #{dischargeStatus}, @@ -69,8 +129,28 @@ #{updateTime}, #{remark}, #{siteId}, - #{deviceId}, + #{deviceId}, #{branchId}, + #{gridUVoltage}, + #{gridVVoltage}, + #{gridWVoltage}, + #{outputUCurrent}, + #{outputVCurrent}, + #{outputWCurrent}, + #{apparentPower}, + #{activePower}, + #{reactivePower}, + #{powerFactor}, + #{frequency}, + #{internalTemp}, + #{uIgbtTemp}, + #{vIgbtTemp}, + #{wIgbtTemp}, + #{gridStatus}, + #{availablePower}, + #{totalLoadRatio}, + #{acLeakageCurrent}, + #{insulationResistance}, @@ -87,8 +167,28 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, - device_id = #{deviceId}, + device_id = #{deviceId}, branch_id = #{branchId}, + grid_u_voltage = #{gridUVoltage}, + grid_v_voltage = #{gridVVoltage}, + grid_w_voltage = #{gridWVoltage}, + output_u_current = #{outputUCurrent}, + output_v_current = #{outputVCurrent}, + output_w_current = #{outputWCurrent}, + apparent_power = #{apparentPower}, + active_power = #{activePower}, + reactive_power = #{reactivePower}, + power_factor = #{powerFactor}, + frequency = #{frequency}, + internal_temp = #{internalTemp}, + u_igbt_temp = #{uIgbtTemp}, + v_igbt_temp = #{vIgbtTemp}, + w_igbt_temp = #{wIgbtTemp}, + grid_status = #{gridStatus}, + available_power = #{availablePower}, + total_load_ratio = #{totalLoadRatio}, + ac_leakage_current = #{acLeakageCurrent}, + insulation_resistance = #{insulationResistance}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index c0f90a7..cd1d7ae 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -87,7 +87,7 @@ and dc_power = #{dcPower} and dc_voltage = #{dcVoltage} and dc_current = #{dcCurrent} - and site_id = #{siteId} + and site_id = #{siteId} and device_id = #{deviceId} and date_month = #{dateMonth} and date_day = #{dateDay} @@ -278,4 +278,81 @@ #{id} + + + + + + + + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index b10678a..186c39d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -18,10 +18,11 @@ + - select id, site_name, site_address, running_time, latitude, longitude, install_capacity, install_power, remark, create_by, update_by, create_time, update_time from ems_site_setting + select id, site_name, site_address, running_time, latitude, longitude, install_capacity, install_power, remark, create_by, update_by, create_time, update_time, site_id from ems_site_setting @@ -57,6 +59,7 @@ update_by, create_time, update_time, + site_id, #{siteName}, @@ -71,6 +74,7 @@ #{updateBy}, #{createTime}, #{updateTime}, + #{siteId}, @@ -89,6 +93,7 @@ update_by = #{updateBy}, create_time = #{createTime}, update_time = #{updateTime}, + site_id = #{siteId}, where id = #{id} @@ -105,9 +110,14 @@ + + \ No newline at end of file -- 2.49.0 From bb0f972f55b556f7025e1cd936d20a06c8ed02cb Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sun, 29 Jun 2025 13:13:23 +0800 Subject: [PATCH 010/336] =?UTF-8?q?=E5=A5=89=E8=B4=A4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E4=BD=BF=E7=94=A8=20job=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/web/controller/ems/MqttMessageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 292aac9..6128e36 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -89,7 +89,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[DEVICE] data: " + payload); try { // 业务处理逻辑 - handleFxData(payload); +// handleFxData(payload); EmsMqttMessage mqttMessage = new EmsMqttMessage(); mqttMessage.setMqttTopic(topic); -- 2.49.0 From d2824b6087766034e03e94f62f3ef2ca33d62df4 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 29 Jun 2025 13:40:37 +0800 Subject: [PATCH 011/336] =?UTF-8?q?=E5=8D=95=E7=AB=99=E7=9B=91=E6=8E=A7-?= =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0=E5=88=97=E8=A1=A8=E5=88=86?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 10 ++++++-- .../ems/domain/vo/BatteryDataStatsListVo.java | 23 ++++++++++++++----- .../xzzn/ems/mapper/EmsBatteryDataMapper.java | 10 ++++++-- .../xzzn/ems/service/ISingleSiteService.java | 2 +- .../service/impl/SingleSiteServiceImpl.java | 5 ++-- .../mapper/ems/EmsBatteryDataMapper.xml | 18 +++++++++++++++ 6 files changed, 55 insertions(+), 13 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index f462657..3375e20 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -2,11 +2,15 @@ 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.vo.BatteryDataStatsListVo; import com.xzzn.ems.service.IEmsSiteService; import com.xzzn.ems.service.ISingleSiteService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * * 单站监控 @@ -106,9 +110,11 @@ public class EmsSiteMonitorController extends BaseController{ * 获取电池簇下面的单体电池数据 */ @GetMapping("/getClusterDataInfoList") - public AjaxResult getClusterDataInfoList(@RequestParam String clusterDeviceId) + public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId) { - return success(iSingleSiteService.getClusterDataInfoList(clusterDeviceId)); + startPage(); + List list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId); + return getDataTable(list); } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java index f71e713..044e150 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java @@ -2,14 +2,15 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; +import java.util.Date; /** * 单站监控-单体电池数据 * */ public class BatteryDataStatsListVo { - /** 月份 */ - private String dataMonth; + /** 单体电池设备id */ + private String deviceId; /** 电压 (V) */ private BigDecimal voltage; @@ -23,12 +24,14 @@ public class BatteryDataStatsListVo { /** SOH (%) */ private BigDecimal soh; - public String getDataMonth() { - return dataMonth; + private Date updateTime; + + public String getDeviceId() { + return deviceId; } - public void setDataMonth(String dataMonth) { - this.dataMonth = dataMonth; + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; } public BigDecimal getVoltage() { @@ -62,4 +65,12 @@ public class BatteryDataStatsListVo { public void setSoh(BigDecimal soh) { this.soh = soh; } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java index cdaa2b4..a7c0278 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java @@ -4,9 +4,8 @@ import java.util.List; import java.util.Map; import com.xzzn.ems.domain.EmsBatteryData; -import com.xzzn.ems.domain.vo.BMSBatteryClusterDataList; import com.xzzn.ems.domain.vo.BatteryClusterDataDetailVo; -import org.apache.ibatis.annotations.Mapper; +import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import org.apache.ibatis.annotations.Param; /** @@ -86,4 +85,11 @@ public interface EmsBatteryDataMapper * @return */ public List> getDataIdsMap(BatteryClusterDataDetailVo dataVo); + + /** + * 根据电池簇设备id获取下面所有单体电池 + * @param clusterDeviceId + * @return + */ + public List getAllBatteryDataByClusterId(String clusterDeviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 7154a5e..afa0287 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -27,7 +27,7 @@ public interface ISingleSiteService public List getCoolingDataList(String siteId); - public BatteryDataStatsListVo getClusterDataInfoList(String clusterDeviceId); + public List getClusterDataInfoList(String clusterDeviceId); public List getAmmeterDataList(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 2c2c4f6..55b770a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -268,8 +268,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public BatteryDataStatsListVo getClusterDataInfoList(String clusterDeviceId) { - BatteryDataStatsListVo batteryDataStatsListVo = new BatteryDataStatsListVo(); + public List getClusterDataInfoList(String clusterDeviceId) { + List batteryDataStatsListVo = new ArrayList<>(); + batteryDataStatsListVo = emsBatteryDataMapper.getAllBatteryDataByClusterId(clusterDeviceId); return batteryDataStatsListVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index d47499c..92ce55d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -176,4 +176,22 @@ SELECT NULL AS type, NULL AS device_id FROM DUAL WHERE 1=0 + + + \ No newline at end of file -- 2.49.0 From 747ce8a08de02c75d698fad104d0e97d4370cd2f Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sun, 29 Jun 2025 14:03:24 +0800 Subject: [PATCH 012/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=86=E6=AC=A1?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=94=B9=E6=88=90=E4=B8=80=E6=AC=A1=E6=80=A7?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 10 ++++++---- .../xzzn/ems/mapper/EmsBatteryDataMapper.java | 3 +++ .../ems/service/IEmsBatteryDataService.java | 9 +++++++++ .../service/impl/EmsBatteryDataServiceImpl.java | 8 ++++++++ .../mapper/ems/EmsBatteryDataMapper.xml | 17 +++++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 6128e36..9f78a6a 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -89,7 +89,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[DEVICE] data: " + payload); try { // 业务处理逻辑 -// handleFxData(payload); + handleFxData(payload); EmsMqttMessage mqttMessage = new EmsMqttMessage(); mqttMessage.setMqttTopic(topic); @@ -148,7 +148,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { log.info("BMS data:"+ jsonData); Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); - + List list = new ArrayList<>(); //单体电池 for (Map.Entry> record : records.entrySet()) { String recordId = record.getKey(); @@ -172,8 +172,10 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { data.setSiteId(("021")); data.setClusterDeviceId(("021")); - - emsBatteryDataService.insertEmsBatteryData(data); + list.add(data); + } + if (list.size() > 0 ) { + emsBatteryDataService.insertEmsBatteryDataList(list); } } else if (deviceId.contains("PCS")) { log.info("===================="); diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java index cdaa2b4..2605a72 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java @@ -86,4 +86,7 @@ public interface EmsBatteryDataMapper * @return */ public List> getDataIdsMap(BatteryClusterDataDetailVo dataVo); + + + int insertEmsBatteryDataList(List emsBatteryDataList); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java index d694c11..2c958a0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDataService.java @@ -59,4 +59,13 @@ public interface IEmsBatteryDataService * @return 结果 */ public int deleteEmsBatteryDataById(Long id); + + /** + * 新增单体电池实时数据 + * + * @param emsBatteryDataList 单体电池实时数据 + * @return 结果 + */ + public int insertEmsBatteryDataList(List emsBatteryDataList); + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java index 562eb7c..70e0b16 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDataServiceImpl.java @@ -93,4 +93,12 @@ public class EmsBatteryDataServiceImpl implements IEmsBatteryDataService { return emsBatteryDataMapper.deleteEmsBatteryDataById(id); } + + @Override + public int insertEmsBatteryDataList(List emsBatteryDataList) { + for (EmsBatteryData data : emsBatteryDataList) { + data.setCreateTime(DateUtils.getNowDate()); + } + return emsBatteryDataMapper.insertEmsBatteryDataList(emsBatteryDataList); + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index d47499c..aac3701 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -176,4 +176,21 @@ SELECT NULL AS type, NULL AS device_id FROM DUAL WHERE 1=0 + + + INSERT INTO ems_battery_data ( + battery_pack, battery_cluster, battery_cell_id, + voltage, temperature, soc, soh, data_timestamp, + create_by, create_time, update_by, update_time, + remark, site_id, device_id, cluster_device_id + ) VALUES + + ( + #{item.batteryPack}, #{item.batteryCluster}, #{item.batteryCellId}, + #{item.voltage}, #{item.temperature}, #{item.soc}, #{item.soh}, #{item.dataTimestamp}, + #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, + #{item.remark}, #{item.siteId}, #{item.deviceId}, #{item.clusterDeviceId} + ) + + \ No newline at end of file -- 2.49.0 From 324beeaa6903a306bdd80189aa8ae1351720461f Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 29 Jun 2025 14:45:20 +0800 Subject: [PATCH 013/336] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/mapper/EmsBatteryDataMapper.java | 3 +-- .../ems/service/impl/HomePageServiceImpl.java | 2 +- .../ems/service/impl/SingleSiteServiceImpl.java | 2 +- .../mapper/ems/EmsBatteryStackMapper.xml | 2 +- .../resources/mapper/ems/EmsCoolingDataMapper.xml | 14 +++++++------- .../mapper/ems/EmsPcsBranchDataMapper.xml | 15 ++++++++------- .../resources/mapper/ems/EmsPcsDataMapper.xml | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java index 4ccc714..f20530d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java @@ -4,9 +4,8 @@ import java.util.List; import java.util.Map; import com.xzzn.ems.domain.EmsBatteryData; -import com.xzzn.ems.domain.vo.BMSBatteryClusterDataList; import com.xzzn.ems.domain.vo.BatteryClusterDataDetailVo; -import org.apache.ibatis.annotations.Mapper; +import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import org.apache.ibatis.annotations.Param; /** diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index be5a4dc..2c79290 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -52,7 +52,7 @@ public class HomePageServiceImpl implements IHomePageService if (!StringUtils.isEmpty(siteId)) { // 站点基本信息 EmsSiteSetting emsSite = emsSiteMapper.selectEmsSiteSettingBySiteId(siteId); - if (emsSite != null) { + if (StringUtils.isNotEmpty(siteId)) { // 装机功率+装机容量 singleSiteBaseInfo.setSiteName(emsSite.getSiteName()); singleSiteBaseInfo.setInstalledCap(emsSite.getInstallCapacity()); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 55b770a..6bdc653 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -169,7 +169,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { bmsOverViewVoList = emsBatteryStackMapper.selectEmsBatteryStackBySiteId(siteId); if (!CollectionUtils.isEmpty(bmsOverViewVoList)) { for (BMSOverViewVo bmsOverViewVo : bmsOverViewVoList) { - // 获取单体电池数据-待确认 + // 获取单体电池数据 String stackDeviceId = bmsOverViewVo.getDeviceId(); if (!StringUtils.isEmpty(stackDeviceId)) { List batteryDataList = new ArrayList<>(); diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index db08ffb..351aa51 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -311,7 +311,7 @@ tmp.total_current as totalCurrent,tmp.dischargeable_capacity as dischargeableCapacity,tmp.total_discharged_capacity as totalDischargedCapacity, tmp.soh as soh,tmp.average_temperature as averageTemperature,tmp.insulation_resistance as insulationResistance, tmp.current_soc as currentSoc,tmp.site_id as siteId,tmp.device_id as deviceId - from ems_battery_stack tmp left join ems_devices_setting td on tmp.device_id = td.id and tmp.site_id = td.site_id + from ems_battery_stack tmp left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id where tmp.site_id = #{siteId} and tmp.update_time = (select MAX(t.update_time) FROM ems_battery_stack t where t.site_id = tmp.site_id and t.device_id = tmp.device_id) diff --git a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml index 71ba86c..99e6067 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml @@ -125,12 +125,12 @@ \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml index 9bab5b1..79890d1 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml @@ -205,14 +205,15 @@ \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index cd1d7ae..c3055cc 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -349,7 +349,7 @@ tmp.c_phase_current as cPhaseVoltage,tmp.c_phase_current as cPhaseCurrent, tmp.total_power_factor as totalPowerFactor, tmp.pcs_environment_temperature as pcsEnvironmentTemperature,tmp.ac_frequency as acFrequency - from ems_pcs_data tmp left join ems_devices_setting td on tmp.device_id = td.id and tmp.site_id = td.site_id + from ems_pcs_data tmp left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id where tmp.site_id = #{siteId} and tmp.data_update_time = (select MAX(data_update_time) FROM ems_pcs_data where site_id = tmp.site_id and device_id = tmp.device_id) -- 2.49.0 From 1225559c36d065e3deb601d63117f716f7109d90 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sun, 29 Jun 2025 15:19:01 +0800 Subject: [PATCH 014/336] =?UTF-8?q?pcs=20=E6=94=AF=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 161 +++++++++++++----- .../java/com/xzzn/common/utils/DateUtils.java | 12 ++ .../ems/mapper/EmsPcsBranchDataMapper.java | 2 + .../ems/service/IEmsPcsBranchDataService.java | 63 +++++++ .../impl/EmsPcsBranchDataServiceImpl.java | 105 ++++++++++++ .../mapper/ems/EmsPcsBranchDataMapper.xml | 73 ++++++++ 6 files changed, 374 insertions(+), 42 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsBranchDataService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsBranchDataServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 9f78a6a..15d9d9a 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -1,23 +1,22 @@ package com.xzzn.web.controller.ems; -import com.alibaba.druid.support.json.JSONParser; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; -import com.fasterxml.jackson.databind.json.JsonMapper; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsMqttMessage; +import com.xzzn.ems.domain.EmsPcsBranchData; import com.xzzn.ems.domain.EmsPcsData; import com.xzzn.ems.service.IEmsBatteryDataService; import com.xzzn.ems.service.IEmsMqttMessageService; +import com.xzzn.ems.service.IEmsPcsBranchDataService; import com.xzzn.ems.service.IEmsPcsDataService; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.framework.web.service.MqttSubscriber; -import org.apache.coyote.http11.Http11NioProtocol; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; @@ -48,6 +47,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IEmsPcsDataService emsPcsDataService; + @Autowired + private IEmsPcsBranchDataService emsPcsBranchDataService; + @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { this.mqttLifecycleManager = mqttLifecycleManager; @@ -91,6 +93,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { // 业务处理逻辑 handleFxData(payload); + EmsMqttMessage mqttMessage = new EmsMqttMessage(); mqttMessage.setMqttTopic(topic); mqttMessage.setMqttMessage(payload); @@ -146,7 +149,14 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { if (deviceId.contains("BMS")) { log.info("===================="); log.info("BMS data:"+ jsonData); + //BMS 电池簇 + + + + + + //单体电池 Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); List list = new ArrayList<>(); //单体电池 @@ -182,49 +192,49 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { log.info("PCS data:"+ jsonData); //pcs - EmsPcsData data = new EmsPcsData(); + EmsPcsData pcsData = new EmsPcsData(); // 时间与状态类字段 - data.setDataUpdateTime(new Date()); - data.setWorkStatus("A"); - data.setGridStatus("B"); - data.setDeviceStatus("C"); - data.setControlMode("D"); + pcsData.setDataUpdateTime(new Date()); + pcsData.setWorkStatus("A"); + pcsData.setGridStatus("B"); + pcsData.setDeviceStatus("C"); + pcsData.setControlMode("D"); // 功率与能量类字段 - data.setTotalActivePower(BigDecimal.ZERO); - data.setDailyAcChargeEnergy(BigDecimal.ZERO); - data.setTotalReactivePower(BigDecimal.ZERO); - data.setDailyAcDischargeEnergy(BigDecimal.ZERO); - data.setTotalApparentPower(BigDecimal.ZERO); - data.setTotalPowerFactor(BigDecimal.ZERO); - data.setDcPower(BigDecimal.ZERO); - data.setTotalAcChargeEnergy(BigDecimal.ZERO); - data.setTotalAcDischargeEnergy(BigDecimal.ZERO); - data.setAcChargeActivePower(BigDecimal.ZERO); - data.setAcCapacitiveReactivePower(BigDecimal.ZERO); - data.setAcDischargeActivePower(BigDecimal.ZERO); - data.setAcInductiveReactivePower(BigDecimal.ZERO); - data.setMaxCapacitivePowerCapacity(BigDecimal.ZERO); - data.setMaxInductivePowerCapacity(BigDecimal.ZERO); - data.setMaxChargePowerCapacity(BigDecimal.ZERO); - data.setMaxDischargePowerCapacity(BigDecimal.ZERO); + pcsData.setTotalActivePower(BigDecimal.ZERO); + pcsData.setDailyAcChargeEnergy(BigDecimal.ZERO); + pcsData.setTotalReactivePower(BigDecimal.ZERO); + pcsData.setDailyAcDischargeEnergy(BigDecimal.ZERO); + pcsData.setTotalApparentPower(BigDecimal.ZERO); + pcsData.setTotalPowerFactor(BigDecimal.ZERO); + pcsData.setDcPower(BigDecimal.ZERO); + pcsData.setTotalAcChargeEnergy(BigDecimal.ZERO); + pcsData.setTotalAcDischargeEnergy(BigDecimal.ZERO); + pcsData.setAcChargeActivePower(BigDecimal.ZERO); + pcsData.setAcCapacitiveReactivePower(BigDecimal.ZERO); + pcsData.setAcDischargeActivePower(BigDecimal.ZERO); + pcsData.setAcInductiveReactivePower(BigDecimal.ZERO); + pcsData.setMaxCapacitivePowerCapacity(BigDecimal.ZERO); + pcsData.setMaxInductivePowerCapacity(BigDecimal.ZERO); + pcsData.setMaxChargePowerCapacity(BigDecimal.ZERO); + pcsData.setMaxDischargePowerCapacity(BigDecimal.ZERO); // 温度与环境参数 - data.setPcsModuleTemperature(BigDecimal.ZERO); - data.setPcsEnvironmentTemperature(BigDecimal.ZERO); - data.setAcFrequency(BigDecimal.ZERO); + pcsData.setPcsModuleTemperature(BigDecimal.ZERO); + pcsData.setPcsEnvironmentTemperature(BigDecimal.ZERO); + pcsData.setAcFrequency(BigDecimal.ZERO); // 状态指示类 - data.setBranchStatus("A"); - data.setDischargeStatus("A"); - data.setAcSwitchStatus("A"); - data.setDcSwitchStatus("A"); - data.setRemoteControlStatus("A"); + pcsData.setBranchStatus("A"); + pcsData.setDischargeStatus("A"); + pcsData.setAcSwitchStatus("A"); + pcsData.setDcSwitchStatus("A"); + pcsData.setRemoteControlStatus("A"); // 直流参数 - data.setDcVoltage(BigDecimal.ZERO); - data.setDcCurrent(BigDecimal.ZERO); + pcsData.setDcVoltage(BigDecimal.ZERO); + pcsData.setDcCurrent(BigDecimal.ZERO); // 系统管理字段 // data.setCreateBy(BigDecimal.ZERO); @@ -232,17 +242,57 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { // data.setUpdateBy(BigDecimal.ZERO); // data.setUpdateTime(BigDecimal.ZERO); // data.setRemark(BigDecimal.ZERO); - data.setSiteId(("021")); - data.setDeviceId(deviceId); - data.setDateMonth(Long.parseLong("6")); - data.setDateDay(Long.parseLong("28")); + pcsData.setSiteId("021_FXX_01"); + pcsData.setDeviceId(deviceId); + pcsData.setDateMonth(DateUtils.getNowMonthLong()); + pcsData.setDateDay(DateUtils.getNowDayLong()); - data.setDeviceId(deviceId); + pcsData.setDeviceId(deviceId); - emsPcsDataService.insertEmsPcsData(data); + emsPcsDataService.insertEmsPcsData(pcsData); + + + Map> records = processDataPrefix(JSON.parseObject(jsonData, new TypeReference>() {})); + List list = new ArrayList<>(); + +//单体电池 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsPcsBranchData data = new EmsPcsBranchData(); + data.setDeviceId(recordId); + data.setDcPower(BigDecimal.ZERO); + data.setDcVoltage(BigDecimal.ZERO); + data.setDcCurrent(BigDecimal.ZERO); + data.setGridUVoltage(BigDecimal.ZERO); + data.setGridVVoltage(BigDecimal.ZERO); + data.setGridWVoltage(BigDecimal.ZERO); + data.setOutputUCurrent(BigDecimal.ZERO); + data.setOutputVCurrent(BigDecimal.ZERO); + data.setOutputWCurrent(BigDecimal.ZERO); + data.setApparentPower(BigDecimal.ZERO); + data.setActivePower(BigDecimal.ZERO); + data.setReactivePower(BigDecimal.ZERO); + data.setPowerFactor(BigDecimal.ZERO); + data.setFrequency(BigDecimal.ZERO); + data.setInternalTemp(BigDecimal.ZERO); + data.setuIgbtTemp(BigDecimal.ZERO); + data.setvIgbtTemp(BigDecimal.ZERO); + data.setwIgbtTemp(BigDecimal.ZERO); + data.setAvailablePower(BigDecimal.ZERO); + data.setTotalLoadRatio(BigDecimal.ZERO); + data.setAcLeakageCurrent(BigDecimal.ZERO); + data.setInsulationResistance(BigDecimal.ZERO); + + list.add(data); + } + if (list.size() > 0 ) { + emsPcsBranchDataService.insertEmsPcsBranchDataList(list); + } } @@ -275,4 +325,31 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } return records; } + + private static Map> processDataPrefix(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 确保键长度足够 + if (key.length() < 3) { + continue; + } + + // 提取记录ID(前3位) + String recordId = key.substring(0, 3); + if (!recordId.startsWith("DY")) { + continue; + } + + // 提取字段类型(剩余部分) + String fieldType = key.substring(3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + return records; + } } \ No newline at end of file diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 7e04abb..786575b 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -8,6 +8,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.util.Calendar; import java.util.Date; import org.apache.commons.lang3.time.DateFormatUtils; @@ -188,4 +189,15 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault()); return Date.from(zdt.toInstant()); } + + public static Long getNowMonthLong() { + Calendar calendar = Calendar.getInstance(); + long month = (long) calendar.get(Calendar.MONTH) + 1; // 月份从0开始,所以要加1 + return month; + } + public static Long getNowDayLong() { + Calendar calendar = Calendar.getInstance(); + long date = calendar.get(Calendar.DAY_OF_MONTH); // 月份从0开始,所以要加1 + return date; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java index 96cc5ff..ade3ca4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java @@ -68,4 +68,6 @@ public interface EmsPcsBranchDataMapper * @return */ public List getPcsBranchInfoList(@Param("siteId")String siteId, @Param("deviceId")String deviceId); + + int insertPcsBranchDataList(List list); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsBranchDataService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsBranchDataService.java new file mode 100644 index 0000000..8929301 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPcsBranchDataService.java @@ -0,0 +1,63 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsPcsBranchData; + +/** + * pcs支路数据Service接口 + * + * @author xzzn + * @date 2025-06-29 + */ +public interface IEmsPcsBranchDataService +{ + /** + * 查询pcs支路数据 + * + * @param id pcs支路数据主键 + * @return pcs支路数据 + */ + public EmsPcsBranchData selectEmsPcsBranchDataById(Long id); + + /** + * 查询pcs支路数据列表 + * + * @param emsPcsBranchData pcs支路数据 + * @return pcs支路数据集合 + */ + public List selectEmsPcsBranchDataList(EmsPcsBranchData emsPcsBranchData); + + /** + * 新增pcs支路数据 + * + * @param emsPcsBranchData pcs支路数据 + * @return 结果 + */ + public int insertEmsPcsBranchData(EmsPcsBranchData emsPcsBranchData); + + /** + * 修改pcs支路数据 + * + * @param emsPcsBranchData pcs支路数据 + * @return 结果 + */ + public int updateEmsPcsBranchData(EmsPcsBranchData emsPcsBranchData); + + /** + * 批量删除pcs支路数据 + * + * @param ids 需要删除的pcs支路数据主键集合 + * @return 结果 + */ + public int deleteEmsPcsBranchDataByIds(Long[] ids); + + /** + * 删除pcs支路数据信息 + * + * @param id pcs支路数据主键 + * @return 结果 + */ + public int deleteEmsPcsBranchDataById(Long id); + + int insertEmsPcsBranchDataList(List list); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsBranchDataServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsBranchDataServiceImpl.java new file mode 100644 index 0000000..111533b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPcsBranchDataServiceImpl.java @@ -0,0 +1,105 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsPcsBranchDataMapper; +import com.xzzn.ems.domain.EmsPcsBranchData; +import com.xzzn.ems.service.IEmsPcsBranchDataService; + +/** + * pcs支路数据Service业务层处理 + * + * @author xzzn + * @date 2025-06-29 + */ +@Service +public class EmsPcsBranchDataServiceImpl implements IEmsPcsBranchDataService +{ + @Autowired + private EmsPcsBranchDataMapper emsPcsBranchDataMapper; + + /** + * 查询pcs支路数据 + * + * @param id pcs支路数据主键 + * @return pcs支路数据 + */ + @Override + public EmsPcsBranchData selectEmsPcsBranchDataById(Long id) + { + return emsPcsBranchDataMapper.selectEmsPcsBranchDataById(id); + } + + /** + * 查询pcs支路数据列表 + * + * @param emsPcsBranchData pcs支路数据 + * @return pcs支路数据 + */ + @Override + public List selectEmsPcsBranchDataList(EmsPcsBranchData emsPcsBranchData) + { + return emsPcsBranchDataMapper.selectEmsPcsBranchDataList(emsPcsBranchData); + } + + /** + * 新增pcs支路数据 + * + * @param emsPcsBranchData pcs支路数据 + * @return 结果 + */ + @Override + public int insertEmsPcsBranchData(EmsPcsBranchData emsPcsBranchData) + { + emsPcsBranchData.setCreateTime(DateUtils.getNowDate()); + return emsPcsBranchDataMapper.insertEmsPcsBranchData(emsPcsBranchData); + } + + /** + * 修改pcs支路数据 + * + * @param emsPcsBranchData pcs支路数据 + * @return 结果 + */ + @Override + public int updateEmsPcsBranchData(EmsPcsBranchData emsPcsBranchData) + { + emsPcsBranchData.setUpdateTime(DateUtils.getNowDate()); + return emsPcsBranchDataMapper.updateEmsPcsBranchData(emsPcsBranchData); + } + + /** + * 批量删除pcs支路数据 + * + * @param ids 需要删除的pcs支路数据主键 + * @return 结果 + */ + @Override + public int deleteEmsPcsBranchDataByIds(Long[] ids) + { + return emsPcsBranchDataMapper.deleteEmsPcsBranchDataByIds(ids); + } + + /** + * 删除pcs支路数据信息 + * + * @param id pcs支路数据主键 + * @return 结果 + */ + @Override + public int deleteEmsPcsBranchDataById(Long id) + { + return emsPcsBranchDataMapper.deleteEmsPcsBranchDataById(id); + } + + @Override + public int insertEmsPcsBranchDataList(List list) { + for (EmsPcsBranchData item : list) { + item.setCreateTime(DateUtils.getNowDate()); + } + return emsPcsBranchDataMapper.insertPcsBranchDataList(list); + + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml index 79890d1..f9ec33c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml @@ -216,4 +216,77 @@ WHERE rn = 1 ORDER BY tmp.branch_id; + + + INSERT INTO ems_pcs_branch_data ( + discharge_status, + dc_power, + dc_voltage, + dc_current, + site_id, + device_id, + branch_id, + grid_u_voltage, + grid_v_voltage, + grid_w_voltage, + output_u_current, + output_v_current, + output_w_current, + apparent_power, + active_power, + reactive_power, + power_factor, + frequency, + internal_temp, + u_igbt_temp, + v_igbt_temp, + w_igbt_temp, + grid_status, + available_power, + total_load_ratio, + ac_leakage_current, + insulation_resistance, + create_by, + create_time, + update_by, + update_time, + remark + ) VALUES + + ( + #{item.dischargeStatus}, + #{item.dcPower}, + #{item.dcVoltage}, + #{item.dcCurrent}, + #{item.siteId}, + #{item.deviceId}, + #{item.branchId}, + #{item.gridUVoltage}, + #{item.gridVVoltage}, + #{item.gridWVoltage}, + #{item.outputUCurrent}, + #{item.outputVCurrent}, + #{item.outputWCurrent}, + #{item.apparentPower}, + #{item.activePower}, + #{item.reactivePower}, + #{item.powerFactor}, + #{item.frequency}, + #{item.internalTemp}, + #{item.uIgbtTemp}, + #{item.vIgbtTemp}, + #{item.wIgbtTemp}, + #{item.gridStatus}, + #{item.availablePower}, + #{item.totalLoadRatio}, + #{item.acLeakageCurrent}, + #{item.insulationResistance}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.remark} + ) + + \ No newline at end of file -- 2.49.0 From ae59143771cc6bc5b8848e9b91fea2e5210473bb Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 29 Jun 2025 15:38:31 +0800 Subject: [PATCH 015/336] =?UTF-8?q?=E5=8D=95=E7=AB=99=E7=9B=91=E6=8E=A7-?= =?UTF-8?q?=E6=95=85=E9=9A=9C=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsAlarmRecordsController.java | 37 +++++++ .../domain/vo/AlarmRecordListRequestVo.java | 65 +++++++++++ .../domain/vo/AlarmRecordListResponseVo.java | 78 +++++++++++++ .../ems/mapper/EmsAlarmRecordsMapper.java | 6 +- .../ems/service/IEmsAlarmRecordsService.java | 70 ++++++++++++ .../impl/EmsAlarmRecordsServiceImpl.java | 103 ++++++++++++++++++ .../mapper/ems/EmsAlarmRecordsMapper.xml | 20 ++++ 7 files changed, 376 insertions(+), 3 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java new file mode 100644 index 0000000..0caa8bc --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java @@ -0,0 +1,37 @@ +package com.xzzn.web.controller.ems; + +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.page.TableDataInfo; +import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; +import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; +import com.xzzn.ems.service.IEmsAlarmRecordsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 单站监控-故障告警 + * + * @author xzzn + */ +@RestController +@RequestMapping("/ems/siteAlarm") +public class EmsAlarmRecordsController extends BaseController +{ + + @Autowired + private IEmsAlarmRecordsService iEmsAlarmRecordsService; + + /** + * 获取告警详情列表 + */ + @GetMapping("/getAlarmDetailList") + public TableDataInfo getAlarmDetailList(AlarmRecordListRequestVo requestVo) + { + startPage(); + List list = iEmsAlarmRecordsService.getAlarmRecordDetailList(requestVo); + return getDataTable(list); + } + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java new file mode 100644 index 0000000..fccc19d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java @@ -0,0 +1,65 @@ +package com.xzzn.ems.domain.vo; + + +import java.util.Date; + +/** + * 单站监控-故障告警请求 + * + */ +public class AlarmRecordListRequestVo { + /** 站点id */ + private String siteId; + + /** 设备类型 */ + private String deviceType; + + /** 告警等级 */ + private String alarmLevel; + + /** 告警发生时间 */ + private String alarmStartTime; + + /** 告警结束时间 */ + private String alarmEndTime; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public String getAlarmLevel() { + return alarmLevel; + } + + public void setAlarmLevel(String alarmLevel) { + this.alarmLevel = alarmLevel; + } + + public String getAlarmStartTime() { + return alarmStartTime; + } + + public void setAlarmStartTime(String alarmStartTime) { + this.alarmStartTime = alarmStartTime; + } + + public String getAlarmEndTime() { + return alarmEndTime; + } + + public void setAlarmEndTime(String alarmEndTime) { + this.alarmEndTime = alarmEndTime; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java new file mode 100644 index 0000000..42137b8 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java @@ -0,0 +1,78 @@ +package com.xzzn.ems.domain.vo; + + +import com.xzzn.common.annotation.Excel; + +import java.util.Date; + +/** + * 单站监控-故障告警返回 + * + */ +public class AlarmRecordListResponseVo { + /** 设备名称 */ + private String deviceName; + + /** 告警等级 */ + private String alarmLevel; + + /** 告警内容 */ + private String alarmContent; + + /** 告警发生时间 */ + private Date alarmStartTime; + + /** 告警结束时间 */ + private Date alarmEndTime; + + /** 状态 */ + private String status; + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getAlarmLevel() { + return alarmLevel; + } + + public void setAlarmLevel(String alarmLevel) { + this.alarmLevel = alarmLevel; + } + + public String getAlarmContent() { + return alarmContent; + } + + public void setAlarmContent(String alarmContent) { + this.alarmContent = alarmContent; + } + + public Date getAlarmStartTime() { + return alarmStartTime; + } + + public void setAlarmStartTime(Date alarmStartTime) { + this.alarmStartTime = alarmStartTime; + } + + public Date getAlarmEndTime() { + return alarmEndTime; + } + + public void setAlarmEndTime(Date alarmEndTime) { + this.alarmEndTime = alarmEndTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java index 0127cc6..f6b7c86 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java @@ -2,9 +2,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsAlarmRecords; -import com.xzzn.ems.domain.vo.AlarmTrendList; -import com.xzzn.ems.domain.vo.DeviceAlarmProportionList; -import com.xzzn.ems.domain.vo.SiteMonitorHomeAlarmVo; +import com.xzzn.ems.domain.vo.*; /** * 告警记录Mapper接口 @@ -79,4 +77,6 @@ public interface EmsAlarmRecordsMapper * */ public List getDeviceAlarmPropList(); + + public List getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java new file mode 100644 index 0000000..ba58188 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -0,0 +1,70 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsAlarmRecords; +import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; +import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; + +/** + * 告警记录Service接口 + * + * @author xzzn + * @date 2025-06-29 + */ +public interface IEmsAlarmRecordsService +{ + /** + * 查询告警记录 + * + * @param id 告警记录主键 + * @return 告警记录 + */ + public EmsAlarmRecords selectEmsAlarmRecordsById(Long id); + + /** + * 查询告警记录列表 + * + * @param emsAlarmRecords 告警记录 + * @return 告警记录集合 + */ + public List selectEmsAlarmRecordsList(EmsAlarmRecords emsAlarmRecords); + + /** + * 新增告警记录 + * + * @param emsAlarmRecords 告警记录 + * @return 结果 + */ + public int insertEmsAlarmRecords(EmsAlarmRecords emsAlarmRecords); + + /** + * 修改告警记录 + * + * @param emsAlarmRecords 告警记录 + * @return 结果 + */ + public int updateEmsAlarmRecords(EmsAlarmRecords emsAlarmRecords); + + /** + * 批量删除告警记录 + * + * @param ids 需要删除的告警记录主键集合 + * @return 结果 + */ + public int deleteEmsAlarmRecordsByIds(Long[] ids); + + /** + * 删除告警记录信息 + * + * @param id 告警记录主键 + * @return 结果 + */ + public int deleteEmsAlarmRecordsById(Long id); + + /** + * 获取故障告警列表 + * @param requestVo + * @return + */ + public List getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java new file mode 100644 index 0000000..d4c545b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -0,0 +1,103 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; +import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; +import com.xzzn.ems.domain.EmsAlarmRecords; +import com.xzzn.ems.service.IEmsAlarmRecordsService; + +/** + * 告警记录Service业务层处理 + * + * @author xzzn + * @date 2025-06-29 + */ +@Service +public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService +{ + @Autowired + private EmsAlarmRecordsMapper emsAlarmRecordsMapper; + + /** + * 查询告警记录 + * + * @param id 告警记录主键 + * @return 告警记录 + */ + @Override + public EmsAlarmRecords selectEmsAlarmRecordsById(Long id) + { + return emsAlarmRecordsMapper.selectEmsAlarmRecordsById(id); + } + + /** + * 查询告警记录列表 + * + * @param emsAlarmRecords 告警记录 + * @return 告警记录 + */ + @Override + public List selectEmsAlarmRecordsList(EmsAlarmRecords emsAlarmRecords) + { + return emsAlarmRecordsMapper.selectEmsAlarmRecordsList(emsAlarmRecords); + } + + /** + * 新增告警记录 + * + * @param emsAlarmRecords 告警记录 + * @return 结果 + */ + @Override + public int insertEmsAlarmRecords(EmsAlarmRecords emsAlarmRecords) + { + emsAlarmRecords.setCreateTime(DateUtils.getNowDate()); + return emsAlarmRecordsMapper.insertEmsAlarmRecords(emsAlarmRecords); + } + + /** + * 修改告警记录 + * + * @param emsAlarmRecords 告警记录 + * @return 结果 + */ + @Override + public int updateEmsAlarmRecords(EmsAlarmRecords emsAlarmRecords) + { + emsAlarmRecords.setUpdateTime(DateUtils.getNowDate()); + return emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords); + } + + /** + * 批量删除告警记录 + * + * @param ids 需要删除的告警记录主键 + * @return 结果 + */ + @Override + public int deleteEmsAlarmRecordsByIds(Long[] ids) + { + return emsAlarmRecordsMapper.deleteEmsAlarmRecordsByIds(ids); + } + + /** + * 删除告警记录信息 + * + * @param id 告警记录主键 + * @return 结果 + */ + @Override + public int deleteEmsAlarmRecordsById(Long id) + { + return emsAlarmRecordsMapper.deleteEmsAlarmRecordsById(id); + } + + @Override + public List getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo) { + return emsAlarmRecordsMapper.getAlarmRecordDetailList(requestVo); + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index 5d7f60d..7a5d15f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -132,4 +132,24 @@ from ems_alarm_records group by device_type + + \ No newline at end of file -- 2.49.0 From c6fc7c00cc9e9a1383dd7c09086916b806220e47 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sun, 29 Jun 2025 15:41:24 +0800 Subject: [PATCH 016/336] =?UTF-8?q?=E5=A5=89=E8=B4=A4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 145 +++++++++++++++--- .../controller/ems/data/FXDataProcess.java | 29 ++++ 2 files changed, 150 insertions(+), 24 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 15d9d9a..542041a 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -6,10 +6,7 @@ import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.EmsBatteryData; -import com.xzzn.ems.domain.EmsMqttMessage; -import com.xzzn.ems.domain.EmsPcsBranchData; -import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.domain.*; import com.xzzn.ems.service.IEmsBatteryDataService; import com.xzzn.ems.service.IEmsMqttMessageService; import com.xzzn.ems.service.IEmsPcsBranchDataService; @@ -150,11 +147,115 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { log.info("===================="); log.info("BMS data:"+ jsonData); //BMS 电池簇 + EmsBatteryCluster data = new EmsBatteryCluster(); + // 设置所有 BigDecimal 类型字段为 ZERO + data.setChargeableCapacity(BigDecimal.ZERO); + data.setTotalChargedCapacity(BigDecimal.ZERO); + data.setDischargeableCapacity(BigDecimal.ZERO); + data.setTotalDischargedCapacity(BigDecimal.ZERO); + data.setSoh(BigDecimal.ZERO); + data.setAverageTemperature(BigDecimal.ZERO); + data.setInsulationResistance(BigDecimal.ZERO); + data.setCurrentSoc(BigDecimal.ZERO); + data.setMaxAllowedChargePower(BigDecimal.ZERO); + data.setMaxAllowedDischargePower(BigDecimal.ZERO); + data.setMaxAllowedChargeVoltage(BigDecimal.ZERO); + data.setMaxAllowedDischargeVoltage(BigDecimal.ZERO); + data.setMaxAllowedChargeCurrent(BigDecimal.ZERO); + data.setMaxAllowedDischargeCurrent(BigDecimal.ZERO); + data.setBatteryPackVoltage(BigDecimal.ZERO); + data.setBatteryPackCurrent(BigDecimal.ZERO); + data.setBatteryPackTemp(BigDecimal.ZERO); + data.setBatteryPackSoc(BigDecimal.ZERO); + data.setBatteryPackSoh(BigDecimal.ZERO); + data.setBatteryPackInsulationResistance(BigDecimal.ZERO); + data.setAvgCellVoltage(BigDecimal.ZERO); + data.setAvgCellTemp(BigDecimal.ZERO); + data.setMaxCellVoltage(BigDecimal.ZERO); + data.setMinCellVoltage(BigDecimal.ZERO); + data.setMaxCellTemp(BigDecimal.ZERO); + data.setMinCellTemp(BigDecimal.ZERO); + data.setMaxCellSoc(BigDecimal.ZERO); + data.setMinCellSoc(BigDecimal.ZERO); + data.setMaxCellSoh(BigDecimal.ZERO); + data.setMinCellSoh(BigDecimal.ZERO); + data.setTotalChargeEnergy(BigDecimal.ZERO); + data.setTotalDischargeEnergy(BigDecimal.ZERO); + // 其他非 BigDecimal 字段 + data.setWorkStatus("1"); // 或其他默认值 + data.setPcsCommunicationStatus("1"); + data.setEmsCommunicationStatus("1"); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + data.setSiteId("021_FXX_01"); + data.setDeviceId(deviceId); + data.setMaxCellVoltageId(Long.parseLong("1")); + data.setMinCellVoltageId(Long.parseLong("1")); + data.setMaxCellTempId(Long.parseLong("1")); + data.setMinCellTempId(Long.parseLong("1")); + data.setMaxCellSocId(Long.parseLong("1")); + data.setMinCellSocId(Long.parseLong("1")); + data.setMaxCellSohId(Long.parseLong("1")); + data.setMinCellSohId(Long.parseLong("1")); + //电池堆 + //BMS 电池簇 + EmsBatteryStack dataStack = new EmsBatteryStack(); + // 设置所有 BigDecimal 类型字段为 ZERO + dataStack.setChargeableCapacity(BigDecimal.ZERO); + dataStack.setTotalChargedCapacity(BigDecimal.ZERO); + dataStack.setDischargeableCapacity(BigDecimal.ZERO); + dataStack.setTotalDischargedCapacity(BigDecimal.ZERO); + dataStack.setSoh(BigDecimal.ZERO); + dataStack.setAverageTemperature(BigDecimal.ZERO); + dataStack.setInsulationResistance(BigDecimal.ZERO); + dataStack.setCurrentSoc(BigDecimal.ZERO); + dataStack.setMaxAllowedChargePower(BigDecimal.ZERO); + dataStack.setMaxAllowedDischargePower(BigDecimal.ZERO); + dataStack.setMaxAllowedChargeVoltage(BigDecimal.ZERO); + dataStack.setMaxAllowedDischargeVoltage(BigDecimal.ZERO); + dataStack.setMaxAllowedChargeCurrent(BigDecimal.ZERO); + dataStack.setMaxAllowedDischargeCurrent(BigDecimal.ZERO); + dataStack.setBatteryPackVoltage(BigDecimal.ZERO); + dataStack.setBatteryPackCurrent(BigDecimal.ZERO); + dataStack.setBatteryPackTemp(BigDecimal.ZERO); + dataStack.setBatteryPackSoc(BigDecimal.ZERO); + dataStack.setBatteryPackSoh(BigDecimal.ZERO); + dataStack.setBatteryPackInsulationResistance(BigDecimal.ZERO); + dataStack.setAvgCellVoltage(BigDecimal.ZERO); + dataStack.setAvgCellTemp(BigDecimal.ZERO); + dataStack.setMaxCellVoltage(BigDecimal.ZERO); + dataStack.setMinCellVoltage(BigDecimal.ZERO); + dataStack.setMaxCellTemp(BigDecimal.ZERO); + dataStack.setMinCellTemp(BigDecimal.ZERO); + dataStack.setMaxCellSoc(BigDecimal.ZERO); + dataStack.setMinCellSoc(BigDecimal.ZERO); + dataStack.setMaxCellSoh(BigDecimal.ZERO); + dataStack.setMinCellSoh(BigDecimal.ZERO); + dataStack.setTotalChargeEnergy(BigDecimal.ZERO); + dataStack.setTotalDischargeEnergy(BigDecimal.ZERO); - - + // 其他非 BigDecimal 字段 + dataStack.setWorkStatus("1"); // 或其他默认值 + dataStack.setPcsCommunicationStatus("1"); + dataStack.setEmsCommunicationStatus("1"); + dataStack.setCreateBy("system"); + dataStack.setCreateTime(DateUtils.getNowDate()); + dataStack.setUpdateBy("system"); + dataStack.setUpdateTime(DateUtils.getNowDate()); + dataStack.setSiteId("021_FXX_01"); + dataStack.setDeviceId(deviceId); + dataStack.setMaxCellVoltageId(Long.parseLong("1")); + dataStack.setMinCellVoltageId(Long.parseLong("1")); + dataStack.setMaxCellTempId(Long.parseLong("1")); + dataStack.setMinCellTempId(Long.parseLong("1")); + dataStack.setMaxCellSocId(Long.parseLong("1")); + dataStack.setMinCellSocId(Long.parseLong("1")); + dataStack.setMaxCellSohId(Long.parseLong("1")); + dataStack.setMinCellSohId(Long.parseLong("1")); //单体电池 Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); @@ -164,25 +265,25 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { String recordId = record.getKey(); Map fields = record.getValue(); - EmsBatteryData data = new EmsBatteryData(); - data.setDeviceId(recordId); - data.setBatteryCellId(recordId); - data.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); - data.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); - data.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); - data.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); + EmsBatteryData batteryData = new EmsBatteryData(); + batteryData.setDeviceId(recordId); + batteryData.setBatteryCellId(recordId); + batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); + batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); + batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); + batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); - data.setBatteryCluster(deviceId); - data.setBatteryPack(deviceId); + batteryData.setBatteryCluster(deviceId); + batteryData.setBatteryPack(deviceId); // 时间戳 - data.setDataTimestamp(new Date()); + batteryData.setDataTimestamp(new Date()); // ID字段 - data.setSiteId(("021")); - data.setClusterDeviceId(("021")); + batteryData.setSiteId(("021")); + batteryData.setClusterDeviceId(("021")); - list.add(data); + list.add(batteryData); } if (list.size() > 0 ) { emsBatteryDataService.insertEmsBatteryDataList(list); @@ -249,16 +350,12 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { pcsData.setDeviceId(deviceId); - - - emsPcsDataService.insertEmsPcsData(pcsData); - Map> records = processDataPrefix(JSON.parseObject(jsonData, new TypeReference>() {})); List list = new ArrayList<>(); -//单体电池 + //PCS支路 for (Map.Entry> record : records.entrySet()) { String recordId = record.getKey(); Map fields = record.getValue(); diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java new file mode 100644 index 0000000..8a78a8b --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java @@ -0,0 +1,29 @@ +package com.xzzn.web.controller.ems.data; + +public class FXDataProcess { + + + + public void batteryClusterProcess(String data) { + } + + public void batteryStackProcess(String data) { + } + + public void batteryDataProcess(String data) { + } + + public void pcsProcess(String data) { + } + + public void pcsBranchProcess(String data) { + } + + + public void coolingProcess(String data) { + } + + + public void ameterProcess(String data) { + } +} -- 2.49.0 From d0b98a0a8af7d56aa7477f212a4adcc566fc0301 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sun, 29 Jun 2025 16:20:13 +0800 Subject: [PATCH 017/336] =?UTF-8?q?=E5=A5=89=E8=B4=A4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 21 +++- .../service/IEmsBatteryClusterService.java | 61 ++++++++++++ .../ems/service/IEmsBatteryStackService.java | 61 ++++++++++++ .../impl/EmsBatteryClusterServiceImpl.java | 96 +++++++++++++++++++ .../impl/EmsBatteryStackServiceImpl.java | 96 +++++++++++++++++++ 5 files changed, 330 insertions(+), 5 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryClusterService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryStackService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryClusterServiceImpl.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryStackServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 542041a..1f923b2 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -7,10 +7,7 @@ import com.alibaba.fastjson2.TypeReference; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; -import com.xzzn.ems.service.IEmsBatteryDataService; -import com.xzzn.ems.service.IEmsMqttMessageService; -import com.xzzn.ems.service.IEmsPcsBranchDataService; -import com.xzzn.ems.service.IEmsPcsDataService; +import com.xzzn.ems.service.*; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.framework.web.service.MqttSubscriber; @@ -47,6 +44,14 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IEmsPcsBranchDataService emsPcsBranchDataService; + @Autowired + private IEmsBatteryClusterService emsBatteryClusterService; + + @Autowired + private IEmsBatteryStackService emsBatteryStackService; + + + @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { this.mqttLifecycleManager = mqttLifecycleManager; @@ -200,6 +205,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { data.setMinCellSocId(Long.parseLong("1")); data.setMaxCellSohId(Long.parseLong("1")); data.setMinCellSohId(Long.parseLong("1")); + data.setStackDeviceId("1"); + emsBatteryClusterService.insertEmsBatteryCluster(data); + //电池堆 //BMS 电池簇 @@ -257,6 +265,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { dataStack.setMaxCellSohId(Long.parseLong("1")); dataStack.setMinCellSohId(Long.parseLong("1")); + emsBatteryStackService.insertEmsBatteryStack(dataStack); + + //单体电池 Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); List list = new ArrayList<>(); @@ -384,7 +395,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { data.setTotalLoadRatio(BigDecimal.ZERO); data.setAcLeakageCurrent(BigDecimal.ZERO); data.setInsulationResistance(BigDecimal.ZERO); - + data.setBranchId(Long.parseLong("1")); list.add(data); } if (list.size() > 0 ) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryClusterService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryClusterService.java new file mode 100644 index 0000000..29a6998 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryClusterService.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsBatteryCluster; + +/** + * 电池簇数据Service接口 + * + * @author xzzn + * @date 2025-06-29 + */ +public interface IEmsBatteryClusterService +{ + /** + * 查询电池簇数据 + * + * @param id 电池簇数据主键 + * @return 电池簇数据 + */ + public EmsBatteryCluster selectEmsBatteryClusterById(Long id); + + /** + * 查询电池簇数据列表 + * + * @param emsBatteryCluster 电池簇数据 + * @return 电池簇数据集合 + */ + public List selectEmsBatteryClusterList(EmsBatteryCluster emsBatteryCluster); + + /** + * 新增电池簇数据 + * + * @param emsBatteryCluster 电池簇数据 + * @return 结果 + */ + public int insertEmsBatteryCluster(EmsBatteryCluster emsBatteryCluster); + + /** + * 修改电池簇数据 + * + * @param emsBatteryCluster 电池簇数据 + * @return 结果 + */ + public int updateEmsBatteryCluster(EmsBatteryCluster emsBatteryCluster); + + /** + * 批量删除电池簇数据 + * + * @param ids 需要删除的电池簇数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryClusterByIds(Long[] ids); + + /** + * 删除电池簇数据信息 + * + * @param id 电池簇数据主键 + * @return 结果 + */ + public int deleteEmsBatteryClusterById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryStackService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryStackService.java new file mode 100644 index 0000000..5d48c59 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryStackService.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsBatteryStack; + +/** + * 电池堆数据Service接口 + * + * @author xzzn + * @date 2025-06-29 + */ +public interface IEmsBatteryStackService +{ + /** + * 查询电池堆数据 + * + * @param id 电池堆数据主键 + * @return 电池堆数据 + */ + public EmsBatteryStack selectEmsBatteryStackById(Long id); + + /** + * 查询电池堆数据列表 + * + * @param emsBatteryStack 电池堆数据 + * @return 电池堆数据集合 + */ + public List selectEmsBatteryStackList(EmsBatteryStack emsBatteryStack); + + /** + * 新增电池堆数据 + * + * @param emsBatteryStack 电池堆数据 + * @return 结果 + */ + public int insertEmsBatteryStack(EmsBatteryStack emsBatteryStack); + + /** + * 修改电池堆数据 + * + * @param emsBatteryStack 电池堆数据 + * @return 结果 + */ + public int updateEmsBatteryStack(EmsBatteryStack emsBatteryStack); + + /** + * 批量删除电池堆数据 + * + * @param ids 需要删除的电池堆数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryStackByIds(Long[] ids); + + /** + * 删除电池堆数据信息 + * + * @param id 电池堆数据主键 + * @return 结果 + */ + public int deleteEmsBatteryStackById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryClusterServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryClusterServiceImpl.java new file mode 100644 index 0000000..d1f6b8f --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryClusterServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; +import com.xzzn.ems.domain.EmsBatteryCluster; +import com.xzzn.ems.service.IEmsBatteryClusterService; + +/** + * 电池簇数据Service业务层处理 + * + * @author xzzn + * @date 2025-06-29 + */ +@Service +public class EmsBatteryClusterServiceImpl implements IEmsBatteryClusterService +{ + @Autowired + private EmsBatteryClusterMapper emsBatteryClusterMapper; + + /** + * 查询电池簇数据 + * + * @param id 电池簇数据主键 + * @return 电池簇数据 + */ + @Override + public EmsBatteryCluster selectEmsBatteryClusterById(Long id) + { + return emsBatteryClusterMapper.selectEmsBatteryClusterById(id); + } + + /** + * 查询电池簇数据列表 + * + * @param emsBatteryCluster 电池簇数据 + * @return 电池簇数据 + */ + @Override + public List selectEmsBatteryClusterList(EmsBatteryCluster emsBatteryCluster) + { + return emsBatteryClusterMapper.selectEmsBatteryClusterList(emsBatteryCluster); + } + + /** + * 新增电池簇数据 + * + * @param emsBatteryCluster 电池簇数据 + * @return 结果 + */ + @Override + public int insertEmsBatteryCluster(EmsBatteryCluster emsBatteryCluster) + { + emsBatteryCluster.setCreateTime(DateUtils.getNowDate()); + return emsBatteryClusterMapper.insertEmsBatteryCluster(emsBatteryCluster); + } + + /** + * 修改电池簇数据 + * + * @param emsBatteryCluster 电池簇数据 + * @return 结果 + */ + @Override + public int updateEmsBatteryCluster(EmsBatteryCluster emsBatteryCluster) + { + emsBatteryCluster.setUpdateTime(DateUtils.getNowDate()); + return emsBatteryClusterMapper.updateEmsBatteryCluster(emsBatteryCluster); + } + + /** + * 批量删除电池簇数据 + * + * @param ids 需要删除的电池簇数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryClusterByIds(Long[] ids) + { + return emsBatteryClusterMapper.deleteEmsBatteryClusterByIds(ids); + } + + /** + * 删除电池簇数据信息 + * + * @param id 电池簇数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryClusterById(Long id) + { + return emsBatteryClusterMapper.deleteEmsBatteryClusterById(id); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryStackServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryStackServiceImpl.java new file mode 100644 index 0000000..f1b52bc --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryStackServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; +import com.xzzn.ems.domain.EmsBatteryStack; +import com.xzzn.ems.service.IEmsBatteryStackService; + +/** + * 电池堆数据Service业务层处理 + * + * @author xzzn + * @date 2025-06-29 + */ +@Service +public class EmsBatteryStackServiceImpl implements IEmsBatteryStackService +{ + @Autowired + private EmsBatteryStackMapper emsBatteryStackMapper; + + /** + * 查询电池堆数据 + * + * @param id 电池堆数据主键 + * @return 电池堆数据 + */ + @Override + public EmsBatteryStack selectEmsBatteryStackById(Long id) + { + return emsBatteryStackMapper.selectEmsBatteryStackById(id); + } + + /** + * 查询电池堆数据列表 + * + * @param emsBatteryStack 电池堆数据 + * @return 电池堆数据 + */ + @Override + public List selectEmsBatteryStackList(EmsBatteryStack emsBatteryStack) + { + return emsBatteryStackMapper.selectEmsBatteryStackList(emsBatteryStack); + } + + /** + * 新增电池堆数据 + * + * @param emsBatteryStack 电池堆数据 + * @return 结果 + */ + @Override + public int insertEmsBatteryStack(EmsBatteryStack emsBatteryStack) + { + emsBatteryStack.setCreateTime(DateUtils.getNowDate()); + return emsBatteryStackMapper.insertEmsBatteryStack(emsBatteryStack); + } + + /** + * 修改电池堆数据 + * + * @param emsBatteryStack 电池堆数据 + * @return 结果 + */ + @Override + public int updateEmsBatteryStack(EmsBatteryStack emsBatteryStack) + { + emsBatteryStack.setUpdateTime(DateUtils.getNowDate()); + return emsBatteryStackMapper.updateEmsBatteryStack(emsBatteryStack); + } + + /** + * 批量删除电池堆数据 + * + * @param ids 需要删除的电池堆数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryStackByIds(Long[] ids) + { + return emsBatteryStackMapper.deleteEmsBatteryStackByIds(ids); + } + + /** + * 删除电池堆数据信息 + * + * @param id 电池堆数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryStackById(Long id) + { + return emsBatteryStackMapper.deleteEmsBatteryStackById(id); + } +} -- 2.49.0 From 551ae90155a3d0ab7f624fde7b5e9e6d6f16565b Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sun, 29 Jun 2025 21:21:37 +0800 Subject: [PATCH 018/336] =?UTF-8?q?=E5=88=A0=E9=99=A4=20lombok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-framework/pom.xml | 5 -- .../config/properties/MqttProperties.java | 57 ++++++++++++++++++- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/ems-framework/pom.xml b/ems-framework/pom.xml index 06a1274..809fa4f 100644 --- a/ems-framework/pom.xml +++ b/ems-framework/pom.xml @@ -61,11 +61,6 @@ com.xzzn ems-system - - org.projectlombok - lombok - provided - diff --git a/ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java b/ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java index f751596..41bb162 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java +++ b/ems-framework/src/main/java/com/xzzn/framework/config/properties/MqttProperties.java @@ -1,10 +1,8 @@ package com.xzzn.framework.config.properties; -import lombok.Data; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; -@Data @Configuration public class MqttProperties { @Value("${mqtt.broker.url}") @@ -28,4 +26,59 @@ public class MqttProperties { @Value("${mqtt.automatic-reconnect:true}") private boolean automaticReconnect; + public String getBrokerUrl() { + return brokerUrl; + } + + public void setBrokerUrl(String brokerUrl) { + this.brokerUrl = brokerUrl; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public int getConnectionTimeout() { + return connectionTimeout; + } + + public void setConnectionTimeout(int connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public int getKeepAliveInterval() { + return keepAliveInterval; + } + + public void setKeepAliveInterval(int keepAliveInterval) { + this.keepAliveInterval = keepAliveInterval; + } + + public boolean isAutomaticReconnect() { + return automaticReconnect; + } + + public void setAutomaticReconnect(boolean automaticReconnect) { + this.automaticReconnect = automaticReconnect; + } } -- 2.49.0 From 49a3ce2c11c18ca8c92a1e15401378f253bbee1d Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 09:46:31 +0800 Subject: [PATCH 019/336] =?UTF-8?q?=E5=A2=9E=E5=8A=A0mqtt=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ems-admin/src/main/resources/application.yml b/ems-admin/src/main/resources/application.yml index 9a02bd4..bd1addd 100644 --- a/ems-admin/src/main/resources/application.yml +++ b/ems-admin/src/main/resources/application.yml @@ -131,8 +131,8 @@ xss: mqtt: broker.url: tcp://122.51.194.184:1883 client.id: ems-cloud - username: admin - password: pass123 + username: dmbroker + password: Setri@64335270 connection-timeout: 15 keep-alive-interval: 30 automatic-reconnect: true \ No newline at end of file -- 2.49.0 From cebd845af1430dc5ded2570b5ed27488f6f5d8fe Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 30 Jun 2025 13:11:05 +0800 Subject: [PATCH 020/336] =?UTF-8?q?sql=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/BMSBatteryClusterVo.java | 165 ++++++++++++++++++ .../ems/domain/vo/BMSBatteryDataList.java | 6 +- .../vo/SiteMonitorRunningHeadInfoVo.java | 13 ++ .../ems/mapper/EmsPcsBranchDataMapper.java | 2 +- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 12 +- .../ems/service/impl/HomePageServiceImpl.java | 36 ++-- .../service/impl/SingleSiteServiceImpl.java | 101 ++++------- .../mapper/ems/EmsAmmeterDataMapper.xml | 15 +- .../mapper/ems/EmsBatteryClusterMapper.xml | 50 ++++-- .../mapper/ems/EmsBatteryDataMapper.xml | 4 +- .../mapper/ems/EmsBatteryStackMapper.xml | 27 +-- .../mapper/ems/EmsPcsBranchDataMapper.xml | 2 +- .../resources/mapper/ems/EmsPcsDataMapper.xml | 92 ++++++---- 13 files changed, 356 insertions(+), 169 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java index 8de0dda..0b84a35 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java @@ -57,6 +57,51 @@ public class BMSBatteryClusterVo { /** 设备唯一标识符 */ private String deviceId; + /** 单体温度平均值 */ + private BigDecimal avgTemp; + + /** 单体温度最小值 */ + private BigDecimal minTemp; + + /** 单体温度最小值ID */ + private String minTempID; + + /** 单体温度最大值 */ + private BigDecimal maxTemp; + + /** 单体温度最大值ID */ + private String maxTempID; + + /** 单体电压平均值 */ + private BigDecimal avgVoltage; + + /** 单体电压最小值 */ + private BigDecimal minVoltage; + + /** 单体电压最小值ID */ + private String minVoltageID; + + /** 单体电压最大值 */ + private BigDecimal maxVoltage; + + /** 单体电压最大值ID */ + private String maxVoltageID; + + /** 单体Soc平均值 */ + private BigDecimal avgSoc; + + /** 单体Soc最小值 */ + private BigDecimal minSoc; + + /** 单体Soc最小值ID */ + private String minSocID; + + /** 单体Soc最大值 */ + private BigDecimal maxSoc; + + /** 单体Soc最大值ID */ + private String maxSocID; + private List batteryDataList; public String getDeviceName() { @@ -194,4 +239,124 @@ public class BMSBatteryClusterVo { public void setBatteryDataList(List batteryDataList) { this.batteryDataList = batteryDataList; } + + public String getMaxSocID() { + return maxSocID; + } + + public void setMaxSocID(String maxSocID) { + this.maxSocID = maxSocID; + } + + public BigDecimal getMaxSoc() { + return maxSoc; + } + + public void setMaxSoc(BigDecimal maxSoc) { + this.maxSoc = maxSoc; + } + + public String getMinSocID() { + return minSocID; + } + + public void setMinSocID(String minSocID) { + this.minSocID = minSocID; + } + + public BigDecimal getMinSoc() { + return minSoc; + } + + public void setMinSoc(BigDecimal minSoc) { + this.minSoc = minSoc; + } + + public BigDecimal getAvgSoc() { + return avgSoc; + } + + public void setAvgSoc(BigDecimal avgSoc) { + this.avgSoc = avgSoc; + } + + public String getMaxVoltageID() { + return maxVoltageID; + } + + public void setMaxVoltageID(String maxVoltageID) { + this.maxVoltageID = maxVoltageID; + } + + public BigDecimal getMaxVoltage() { + return maxVoltage; + } + + public void setMaxVoltage(BigDecimal maxVoltage) { + this.maxVoltage = maxVoltage; + } + + public String getMinVoltageID() { + return minVoltageID; + } + + public void setMinVoltageID(String minVoltageID) { + this.minVoltageID = minVoltageID; + } + + public BigDecimal getMinVoltage() { + return minVoltage; + } + + public void setMinVoltage(BigDecimal minVoltage) { + this.minVoltage = minVoltage; + } + + public BigDecimal getAvgVoltage() { + return avgVoltage; + } + + public void setAvgVoltage(BigDecimal avgVoltage) { + this.avgVoltage = avgVoltage; + } + + public String getMaxTempID() { + return maxTempID; + } + + public void setMaxTempID(String maxTempID) { + this.maxTempID = maxTempID; + } + + public BigDecimal getMaxTemp() { + return maxTemp; + } + + public void setMaxTemp(BigDecimal maxTemp) { + this.maxTemp = maxTemp; + } + + public String getMinTempID() { + return minTempID; + } + + public void setMinTempID(String minTempID) { + this.minTempID = minTempID; + } + + public BigDecimal getMinTemp() { + return minTemp; + } + + public void setMinTemp(BigDecimal minTemp) { + this.minTemp = minTemp; + } + + public BigDecimal getAvgTemp() { + return avgTemp; + } + + public void setAvgTemp(BigDecimal avgTemp) { + this.avgTemp = avgTemp; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java index 394c921..f1c6bbb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java @@ -9,7 +9,7 @@ public class BMSBatteryDataList { /** * 簇号 */ - private Long clusterId; + private String clusterId; /** 簇电压 (V) */ private BigDecimal clusterVoltage; @@ -38,11 +38,11 @@ public class BMSBatteryDataList { /** 堆id */ private String stackDeviceId; - public Long getClusterId() { + public String getClusterId() { return clusterId; } - public void setClusterId(Long clusterId) { + public void setClusterId(String clusterId) { this.clusterId = clusterId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRunningHeadInfoVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRunningHeadInfoVo.java index 50583fe..068f75f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRunningHeadInfoVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRunningHeadInfoVo.java @@ -37,6 +37,11 @@ public class SiteMonitorRunningHeadInfoVo { */ private BigDecimal dayDisChargedCap; + /** + * 站点id + */ + private String siteId; + public BigDecimal getTotalActivePower() { return totalActivePower; } @@ -84,4 +89,12 @@ public class SiteMonitorRunningHeadInfoVo { public void setDayDisChargedCap(BigDecimal dayDisChargedCap) { this.dayDisChargedCap = dayDisChargedCap; } + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java index ade3ca4..9c4b526 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsBranchDataMapper.java @@ -3,7 +3,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsPcsBranchData; import com.xzzn.ems.domain.vo.PcsBranchInfo; -import io.lettuce.core.dynamic.annotation.Param; +import org.apache.ibatis.annotations.Param; /** * pcs支路数据Mapper接口 diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index a0f7a00..c49ea50 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -9,6 +9,7 @@ import com.xzzn.ems.domain.vo.ElectricIndexList; import com.xzzn.ems.domain.vo.PcsDetailInfoVo; import com.xzzn.ems.domain.vo.SiteMonitorDataVo; import com.xzzn.ems.domain.vo.SiteMonitorRunningHeadInfoVo; +import org.apache.ibatis.annotations.Param; /** * PCS数据Mapper接口 @@ -71,14 +72,7 @@ public interface EmsPcsDataMapper * @param siteId * @return */ - public List getPcsDataBySiteId(String siteId); - - /** - * 根据站点获取电网实时功率=sum(总交流有功电率) - * @param siteId - * @return - */ - public BigDecimal getGridNrtPower(String siteId); + public List getPcsDataBySiteId(@Param("siteId")String siteId, @Param("limitTime")int limitTime); /** * 根据站点获取设备监控的实时运行头信息 @@ -104,5 +98,5 @@ public interface EmsPcsDataMapper * 获取总充+总放 * @return */ - public Map getPcsTotalChargeData(); + public Map getPcsTotalChargeData(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index 2c79290..cc11227 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -22,6 +22,7 @@ import java.util.*; @Service public class HomePageServiceImpl implements IHomePageService { + private static final int LIMIT_TIME = 6; @Autowired private IEmsSiteService emsSiteService; @@ -37,10 +38,11 @@ public class HomePageServiceImpl implements IHomePageService SiteTotalInfoVo siteTotalInfoVo = new SiteTotalInfoVo(); siteTotalInfoVo = emsSiteService.getSiteTotalInfo(); // 获取总充+总放 - Map pcsMap = new HashMap<>(); - pcsMap = emsPcsDataMapper.getPcsTotalChargeData(); - siteTotalInfoVo.setTotalChargedCap(pcsMap.get("totalChargedCap")); - siteTotalInfoVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap")); + Map pcsMap = emsPcsDataMapper.getPcsTotalChargeData(null); + if(pcsMap != null){ + siteTotalInfoVo.setTotalChargedCap(pcsMap.get("totalChargedCap")); + siteTotalInfoVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap")); + } return siteTotalInfoVo; } @@ -52,7 +54,7 @@ public class HomePageServiceImpl implements IHomePageService if (!StringUtils.isEmpty(siteId)) { // 站点基本信息 EmsSiteSetting emsSite = emsSiteMapper.selectEmsSiteSettingBySiteId(siteId); - if (StringUtils.isNotEmpty(siteId)) { + if (emsSite != null) { // 装机功率+装机容量 singleSiteBaseInfo.setSiteName(emsSite.getSiteName()); singleSiteBaseInfo.setInstalledCap(emsSite.getInstallCapacity()); @@ -64,8 +66,14 @@ public class HomePageServiceImpl implements IHomePageService singleSiteBaseInfo.setSiteAddress(emsSite.getSiteAddress()); singleSiteBaseInfo.setRunningTime(emsSite.getRunningTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd",emsSite.getRunningTime()));//投运时间 + // 获取单站点的总充+总放 + Map pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId); + if (pcsMap != null) { + singleSiteBaseInfo.setTotalChargedCap(pcsMap.get("totalChargedCap")); + singleSiteBaseInfo.setTotalDisChargedCap(pcsMap.get("totalDischargedCap")); + } // 七天放电数据统计 - List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId); + List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,LIMIT_TIME); singleSiteBaseInfo.setSevenDayDisChargeStats(siteMonitorDataVoList); // 充放电基本数据处理 dealSitePCSDate(singleSiteBaseInfo,siteMonitorDataVoList); @@ -77,27 +85,15 @@ public class HomePageServiceImpl implements IHomePageService private void dealSitePCSDate(SingleSiteBaseInfo singleSiteBaseInfo, List siteMonitorDataVoList) { if (siteMonitorDataVoList != null && !siteMonitorDataVoList.isEmpty()) { - BigDecimal dayChargeCap = new BigDecimal(0); - BigDecimal dayDisChargeCap = new BigDecimal(0); - BigDecimal totalChargeCap = new BigDecimal(0); - BigDecimal totalDisChargeCap = new BigDecimal(0); for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) { - // 总充电量 - totalChargeCap = totalChargeCap.add(sitePcsData.getChargedCap()); - // 总放电量 - totalDisChargeCap = totalDisChargeCap.add(sitePcsData.getDisChargedCap()); // 获取当天的充电量+放电量 String pcsDate = sitePcsData.getAmmeterDate(); boolean isToday= checkIsToday(pcsDate); if(isToday){ - dayChargeCap = dayChargeCap.add(sitePcsData.getChargedCap()); - dayDisChargeCap = dayDisChargeCap.add(sitePcsData.getDisChargedCap()); + singleSiteBaseInfo.setDayChargedCap(sitePcsData.getChargedCap()); + singleSiteBaseInfo.setDayDisChargedCap(sitePcsData.getDisChargedCap()); } } - singleSiteBaseInfo.setDayChargedCap(dayChargeCap); - singleSiteBaseInfo.setDayDisChargedCap(dayDisChargeCap); - singleSiteBaseInfo.setTotalChargedCap(totalChargeCap); - singleSiteBaseInfo.setTotalDisChargedCap(totalDisChargeCap); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 6bdc653..51aefae 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -50,40 +50,33 @@ public class SingleSiteServiceImpl implements ISingleSiteService { SiteMonitorHomeVo siteMonitorHomeVo = new SiteMonitorHomeVo(); if (!StringUtils.isEmpty(siteId)) { + // 获取单站点的总充+总放+电网实时功率 + Map pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId); + if (pcsMap != null) { + siteMonitorHomeVo.setTotalChargedCap(pcsMap.get("totalChargedCap")); + siteMonitorHomeVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap")); + siteMonitorHomeVo.setGridNrtPower(pcsMap.get("gridNrtPower")); + } // 实时告警数据 名称+状态+告警内容 List siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId); siteMonitorHomeVo.setSiteMonitorHomeAlarmVo(siteMonitorHomeAlarmVo); // 能量数据 - List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId); + List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,6); if (!CollectionUtils.isEmpty(siteMonitorDataVoList)) { - BigDecimal dayChargeCap = new BigDecimal(0); - BigDecimal dayDisChargeCap = new BigDecimal(0); - BigDecimal totalChargeCap = new BigDecimal(0); - BigDecimal totalDisChargeCap = new BigDecimal(0); for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) { - // 总充电量 - totalChargeCap = totalChargeCap.add(sitePcsData.getChargedCap()); - // 总放电量 - totalDisChargeCap = totalDisChargeCap.add(sitePcsData.getDisChargedCap()); // 获取当天的充电量+放电量 String pcsDate = sitePcsData.getAmmeterDate(); boolean isToday= checkIsToday(pcsDate); if(isToday){ - dayChargeCap = dayChargeCap.add(sitePcsData.getChargedCap()); - dayDisChargeCap = dayDisChargeCap.add(sitePcsData.getDisChargedCap()); + siteMonitorHomeVo.setDayChargedCap(sitePcsData.getChargedCap()); + siteMonitorHomeVo.setDayDisChargedCap(sitePcsData.getDisChargedCap()); } } - siteMonitorHomeVo.setDayChargedCap(dayChargeCap); - siteMonitorHomeVo.setDayDisChargedCap(dayDisChargeCap); - siteMonitorHomeVo.setTotalChargedCap(totalChargeCap); - siteMonitorHomeVo.setTotalDischargedCap(totalDisChargeCap); // 储能可用电量 BigDecimal energyStorageAvailElec = siteMonitorHomeVo.getTotalDischargedCap().subtract(siteMonitorHomeVo.getTotalChargedCap()); siteMonitorHomeVo.setEnergyStorageAvailElec(energyStorageAvailElec); } siteMonitorHomeVo.setSiteMonitorDataVo(siteMonitorDataVoList); - // 电网实时功率 - siteMonitorHomeVo.setGridNrtPower(emsPcsDataMapper.getGridNrtPower(siteId)); } return siteMonitorHomeVo; @@ -172,8 +165,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取单体电池数据 String stackDeviceId = bmsOverViewVo.getDeviceId(); if (!StringUtils.isEmpty(stackDeviceId)) { - List batteryDataList = new ArrayList<>(); - batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId); + List batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId); bmsOverViewVo.setBatteryDataList(batteryDataList); } } @@ -196,53 +188,34 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List clusterDataList = new ArrayList<>(); if (!StringUtils.isEmpty(clusterDeviceId)) { // 获取单体电池数据-平均/最大/最小 - BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId); + //BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId); // 处理数据 - if (batteryClusterDataDetailVo != null) { - BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList(); - BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList(); - BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList(); - // 设值 - voltageData.setDataName(CLUSTER_DATA_VOLTAGE); - voltageData.setAvgData(batteryClusterDataDetailVo.getAvgVoltage()); - voltageData.setMaxData(batteryClusterDataDetailVo.getMaxVoltage()); - voltageData.setMinData(batteryClusterDataDetailVo.getMinVoltage()); - tempData.setDataName(CLUSTER_DATA_TEP); - tempData.setAvgData(batteryClusterDataDetailVo.getAvgTemp()); - tempData.setMaxData(batteryClusterDataDetailVo.getMaxTemp()); - tempData.setMinData(batteryClusterDataDetailVo.getMinTemp()); - socData.setDataName(CLUSTER_DATA_SOC); - socData.setAvgData(batteryClusterDataDetailVo.getAvgSoc()); - socData.setMaxData(batteryClusterDataDetailVo.getMaxSoc()); - socData.setMinData(batteryClusterDataDetailVo.getMinSoc()); + BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList(); + BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList(); + BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList(); + // 设值 + voltageData.setDataName(CLUSTER_DATA_VOLTAGE); + voltageData.setAvgData(bmsBatteryClusterVo.getAvgVoltage()); + voltageData.setMaxData(bmsBatteryClusterVo.getMaxVoltage()); + voltageData.setMaxDataID(bmsBatteryClusterVo.getMaxVoltageID()); + voltageData.setMinData(bmsBatteryClusterVo.getMinVoltage()); + voltageData.setMinDataID(bmsBatteryClusterVo.getMinVoltageID()); + tempData.setDataName(CLUSTER_DATA_TEP); + tempData.setAvgData(bmsBatteryClusterVo.getAvgTemp()); + tempData.setMaxData(bmsBatteryClusterVo.getMaxTemp()); + tempData.setMaxDataID(bmsBatteryClusterVo.getMaxTempID()); + tempData.setMinData(bmsBatteryClusterVo.getMinTemp()); + tempData.setMinDataID(bmsBatteryClusterVo.getMinTempID()); + socData.setDataName(CLUSTER_DATA_SOC); + socData.setAvgData(bmsBatteryClusterVo.getAvgSoc()); + socData.setMaxData(bmsBatteryClusterVo.getMaxSoc()); + socData.setMaxDataID(bmsBatteryClusterVo.getMaxSocID()); + socData.setMinData(bmsBatteryClusterVo.getMinSoc()); + socData.setMinDataID(bmsBatteryClusterVo.getMinSocID()); - // 设置对应单体id - List> dataIdMapList = emsBatteryDataMapper.getDataIdsMap(batteryClusterDataDetailVo); - Map resultIdMap = new HashMap<>(); - if (!CollectionUtils.isEmpty(dataIdMapList)) { - resultIdMap = dataIdMapList.stream() - .filter(map -> map.containsKey("type") && map.containsKey("device_id")) // 过滤无效数据 - .filter(map -> map.get("type") instanceof String && map.get("device_id") instanceof Number) // 确保类型正确 - .collect(Collectors.toMap( - map -> (String) map.get("type"), // 键:type 字段 - map -> (String) map.get("device_id"), // 值:device_id 转为 int - (existing, replacement) -> existing // 处理键冲突的策略 - )); - - // 电压 - voltageData.setMaxDataID(resultIdMap.get("maxVoltageId")); - voltageData.setMaxDataID(resultIdMap.get("maxVoltageId")); - // 温度 - tempData.setMaxDataID(resultIdMap.get("maxTempId")); - tempData.setMinDataID(resultIdMap.get("minTempId")); - // soc - socData.setMaxDataID(resultIdMap.get("maxSocId")); - socData.setMinDataID(resultIdMap.get("minSocId")); - } - clusterDataList.add(voltageData); - clusterDataList.add(tempData); - clusterDataList.add(socData); - } + clusterDataList.add(voltageData); + clusterDataList.add(tempData); + clusterDataList.add(socData); bmsBatteryClusterVo.setBatteryDataList(clusterDataList); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 63edc13..1d57f80 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -115,7 +115,7 @@ \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 31349cb..1c4844f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -311,27 +311,45 @@ \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index 08a0921..dc0b436 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -126,8 +126,8 @@ - select td.device_name as deviceName,tmp.work_status as workStatus, - tmp.pcs_communication_status as pcsCommunicationStatus,tmp.ems_communication_status as emsCommunicationStatus, - tmp.total_voltage as totalVoltage,tmp.chargeable_capacity as chargeableCapacity,tmp.total_charged_capacity as totalChargedCapacity, - tmp.total_current as totalCurrent,tmp.dischargeable_capacity as dischargeableCapacity,tmp.total_discharged_capacity as totalDischargedCapacity, - tmp.soh as soh,tmp.average_temperature as averageTemperature,tmp.insulation_resistance as insulationResistance, - tmp.current_soc as currentSoc,tmp.site_id as siteId,tmp.device_id as deviceId - from ems_battery_stack tmp left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id - where tmp.site_id = #{siteId} - and tmp.update_time = (select MAX(t.update_time) FROM ems_battery_stack t where t.site_id = tmp.site_id - and t.device_id = tmp.device_id) + SELECT td.device_name as deviceName,tmp.work_status as workStatus, + tmp.pcs_communication_status as pcsCommunicationStatus,tmp.ems_communication_status as emsCommunicationStatus, + tmp.total_voltage as totalVoltage,tmp.chargeable_capacity as chargeableCapacity, + tmp.total_charged_capacity as totalChargedCapacity, + tmp.total_current as totalCurrent,tmp.dischargeable_capacity as dischargeableCapacity, + tmp.total_discharged_capacity as totalDischargedCapacity, + tmp.soh as soh,tmp.average_temperature as averageTemperature,tmp.insulation_resistance as insulationResistance, + tmp.current_soc as currentSoc,tmp.site_id as siteId,tmp.device_id as deviceId + FROM ems_battery_stack tmp + left join ems_devices_setting td on tmp.device_id = td.device_id and tmp.site_id = td.site_id + INNER JOIN ( + SELECT p.site_id, p.device_id, MAX(p.update_time) AS max_update_time + FROM ems_battery_stack p + WHERE p.site_id = #{siteId} + GROUP BY p.site_id,p.device_id + ) latest on tmp.device_id = latest.device_id and tmp.update_time = latest.max_update_time + WHERE tmp.site_id = #{siteId} order by tmp.device_id \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml index f9ec33c..7060ed3 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsBranchDataMapper.xml @@ -214,7 +214,7 @@ WHERE t.site_id = #{siteId} AND t.device_id = #{deviceId} ) tmp WHERE rn = 1 - ORDER BY tmp.branch_id; + ORDER BY tmp.branch_id diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index c3055cc..689968b 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -279,45 +279,57 @@ - - - + select CONCAT(t.date_month,'/',t.date_day) as ammeterDate, + sum(t.daily_ac_charge_energy) as chargedCap, + sum(t.daily_ac_discharge_energy) as disChargedCap + from ( + SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time + FROM ems_pcs_data p + where p.site_id = #{siteId} and p.create_time >= CURDATE() - INTERVAL #{limitTime} DAY + GROUP BY p.site_id,p.device_id,p.date_month,p.date_day + ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id + AND latest.device_id = t.device_id + AND latest.max_update_time = t.data_update_time + and latest.date_month = t.date_month + and latest.date_day = t.date_day + group by ammeterDate + order by ammeterDate desc; \ No newline at end of file -- 2.49.0 From 337599d1c6086009d4d36d53a5e321c2491b0cc7 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 13:39:51 +0800 Subject: [PATCH 021/336] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/ems/EmsTicketMapper.xml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml diff --git a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml new file mode 100644 index 0000000..11e9061 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + select id, ticket_no, user_id, title, content, images, status, create_time, complete_time, create_by, update_by, update_time, work_user_id from ems_ticket + + + + + + + + insert into ems_ticket + + ticket_no, + user_id, + title, + content, + images, + status, + create_time, + complete_time, + create_by, + update_by, + update_time, + work_user_id, + + + #{ticketNo}, + #{userId}, + #{title}, + #{content}, + #{images}, + #{status}, + #{createTime}, + #{completeTime}, + #{createBy}, + #{updateBy}, + #{updateTime}, + #{workUserId}, + + + + + update ems_ticket + + ticket_no = #{ticketNo}, + user_id = #{userId}, + title = #{title}, + content = #{content}, + images = #{images}, + status = #{status}, + create_time = #{createTime}, + complete_time = #{completeTime}, + create_by = #{createBy}, + update_by = #{updateBy}, + update_time = #{updateTime}, + work_user_id = #{workUserId}, + + where id = #{id} + + + + delete from ems_ticket where id = #{id} + + + + delete from ems_ticket where id in + + #{id} + + + \ No newline at end of file -- 2.49.0 From fbab6ea63165a14b2b7e9e2ae00d6a5c9a8552e9 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 30 Jun 2025 18:14:24 +0800 Subject: [PATCH 022/336] =?UTF-8?q?=E7=94=B5=E8=A1=A8=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/AmmeterDataDetailInfo.java | 2 +- .../com/xzzn/ems/domain/vo/AmmeterDataVo.java | 11 +++++++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 3 +- .../ems/mapper/EmsDevicesSettingMapper.java | 7 ++--- .../service/impl/SingleSiteServiceImpl.java | 29 ++++++++++++------- .../mapper/ems/EmsAmmeterDataMapper.xml | 8 ++--- .../mapper/ems/EmsDevicesSettingMapper.xml | 10 ++++--- 7 files changed, 45 insertions(+), 25 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java index 6dfdff3..797ef63 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java @@ -4,7 +4,7 @@ import java.math.BigDecimal; import java.util.Date; /** - * 总表详细数据 + * 电表详细数据 */ public class AmmeterDataDetailInfo { diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java index 5993239..119f4ab 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java @@ -10,6 +10,9 @@ import java.util.List; */ public class AmmeterDataVo { + /** 电表名称 */ + private String deviceName; + /** 通信状态 */ private String emsCommunicationStatus; @@ -19,6 +22,14 @@ public class AmmeterDataVo { private List ammeterDataDetailInfos; + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + public String getEmsCommunicationStatus() { return emsCommunicationStatus; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index 7c1d4e6..b96b482 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -3,6 +3,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsAmmeterData; import com.xzzn.ems.domain.vo.AmmeterDataDetailInfo; +import org.apache.ibatis.annotations.Param; /** * 总数据Mapper接口 @@ -65,5 +66,5 @@ public interface EmsAmmeterDataMapper * @param siteId * @return */ - public List getAmmeterDetailInfo(String siteId); + public List getAmmeterDetailInfo(@Param("siteId")String siteId,@Param("deviceId") String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index a565438..d9f8a91 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -74,11 +74,10 @@ public interface EmsDevicesSettingMapper * @return */ public List> getAllClusterInfoByStackId(String stackDeviceId); - /** - * 获取设备通信状态 - * @param deviceId + * 获取该设备下的所有电表 + * @param siteId * @return */ - public Map getDeviceStatus(String deviceId); + public List getAllBatteryDeviceBySiteId(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 51aefae..9bcd459 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -3,6 +3,7 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsCoolingData; +import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.ISingleSiteService; @@ -255,20 +256,26 @@ public class SingleSiteServiceImpl implements ISingleSiteService { @Override public List getAmmeterDataList(String siteId) { List ammeterDataVos = new ArrayList<>(); - AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); + if (!StringUtils.isEmpty(siteId)) { - List ammeterDataDetailInfos = emsAmmeterDataMapper.getAmmeterDetailInfo(siteId); - ammeterDataVo.setAmmeterDataDetailInfos(ammeterDataDetailInfos); - if (!CollectionUtils.isEmpty(ammeterDataDetailInfos)) { - // 获取通信状态 - String deviceId = ammeterDataDetailInfos.get(0).getDeviceId(); - Map map = emsDevicesSettingMapper.getDeviceStatus(deviceId); - ammeterDataVo.setEmsCommunicationStatus(map.get("communication_status").toString()); - // 数据更新时间 - ammeterDataVo.setDataUpdateTime(ammeterDataDetailInfos.get(0).getUpdateTime()); + // 先获取所有电表设备 + List devicesList = emsDevicesSettingMapper.getAllBatteryDeviceBySiteId(siteId); + if (!CollectionUtils.isEmpty(devicesList)) { + for (EmsDevicesSetting devicesSetting : devicesList) { + AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); + ammeterDataVo.setDeviceName(devicesSetting.getDeviceName()); + ammeterDataVo.setEmsCommunicationStatus(devicesSetting.getCommunicationStatus()); + String deviceId = devicesSetting.getDeviceId(); + // 获取类别数据 + List ammeterDataDetailInfos = emsAmmeterDataMapper.getAmmeterDetailInfo(siteId,deviceId); + ammeterDataVo.setAmmeterDataDetailInfos(ammeterDataDetailInfos); + // 数据更新时间 + ammeterDataVo.setDataUpdateTime(ammeterDataDetailInfos.get(0).getUpdateTime()); + + ammeterDataVos.add(ammeterDataVo); + } } } - ammeterDataVos.add(ammeterDataVo); return ammeterDataVos; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 1d57f80..81f17fc 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -114,23 +114,23 @@ - SELECT t.category as category, t.total_kwh as totalKwh, t.sharp_kwh as sharpKwh, t.flat_kwh as flatKwh, t.peak_kwh as peakKwh, - t.valley_kwh as valleyKwh, t.device_id as deviceId, + t.valley_kwh as valleyKwh, Max(t.data_update_time) as updateTime FROM ems_ammeter_data t INNER JOIN ( SELECT p.site_id, p.device_id,p.category,MAX(p.data_update_time) AS max_update_time FROM ems_ammeter_data p - WHERE p.site_id = #{siteId} + WHERE p.site_id = #{siteId} and p.device_id = #{deviceId} GROUP BY p.site_id,p.device_id,p.category ) latest on t.device_id = latest.device_id and t.data_update_time = latest.max_update_time - WHERE t.site_id = #{siteId} + WHERE t.site_id = #{siteId} and t.device_id = #{deviceId} group by t.category,t.total_kwh,t.sharp_kwh,t.flat_kwh,t.peak_kwh,t.valley_kwh,t.device_id order by updateTime desc diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 0df74f0..a74b748 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -151,9 +151,11 @@ where device_id in (select distinct eb.device_id from ems_battery_cluster eb where eb.stack_device_id = #{stackDeviceId}) - + select distinct e.device_id as deviceId, + t.device_name as deviceName, + t.communication_status as communicationStatus + from ems_devices_setting t INNER JOIN ems_ammeter_data e on t.site_id = e.site_id and t.device_id = e.device_id + where t.site_id = #{siteId} \ No newline at end of file -- 2.49.0 From f2e5e07857f7e0128917bc2a26a9f80948be6adc Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 18:58:53 +0800 Subject: [PATCH 023/336] =?UTF-8?q?=E7=B4=A7=E6=80=A5=E4=BF=AE=E6=94=B9=20?= =?UTF-8?q?siteid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/web/controller/ems/MqttMessageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 1f923b2..c7776c1 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -291,7 +291,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { batteryData.setDataTimestamp(new Date()); // ID字段 - batteryData.setSiteId(("021")); + batteryData.setSiteId(("021_FXX_01")); batteryData.setClusterDeviceId(("021")); list.add(batteryData); -- 2.49.0 From a6af1397e92978a32589ed5db8ba58345b650e8d Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 30 Jun 2025 20:01:55 +0800 Subject: [PATCH 024/336] =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/common/enums/AlarmLevelStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/AlarmStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/BranchStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/ChargeStatus.java | 30 +++++++++++++++++++ .../common/enums/CommunicationStatus.java | 30 +++++++++++++++++++ .../xzzn/common/enums/ControlModeStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/DeviceStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/DeviceType.java | 20 +++++++++++++ .../com/xzzn/common/enums/GridStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/StrategyStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/SwitchStatus.java | 30 +++++++++++++++++++ .../com/xzzn/common/enums/WorkStatus.java | 30 +++++++++++++++++++ 12 files changed, 350 insertions(+) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/AlarmLevelStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/AlarmStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/BranchStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/ChargeStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/CommunicationStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/ControlModeStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/DeviceStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/DeviceType.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/GridStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/StrategyStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/SwitchStatus.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java diff --git a/ems-common/src/main/java/com/xzzn/common/enums/AlarmLevelStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/AlarmLevelStatus.java new file mode 100644 index 0000000..c71d631 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/AlarmLevelStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * alarm-告警等级 + * + * @author xzzn + */ +public enum AlarmLevelStatus +{ + WARNING("A", "提示"), GENERAL("B", "一般"), SERIOUS("C", "严重"), EMERGENCY("D", "紧急"); + + private final String code; + private final String info; + + AlarmLevelStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/AlarmStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/AlarmStatus.java new file mode 100644 index 0000000..62cc7cb --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/AlarmStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * alarm-告警状态 + * + * @author xzzn + */ +public enum AlarmStatus +{ + WAITING("0", "待处理"), DONE("1", "已处理"),PROCESSING("2", "处理中"); + + private final String code; + private final String info; + + AlarmStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/BranchStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/BranchStatus.java new file mode 100644 index 0000000..cda7b2f --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/BranchStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * pcs-branch-支路状态 + * + * @author xzzn + */ +public enum BranchStatus +{ + STANDBY("0", "备用"), NORMAL("1", "正常"), SWITCHING("2", "切换中"); + + private final String code; + private final String info; + + BranchStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/ChargeStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/ChargeStatus.java new file mode 100644 index 0000000..96b67c4 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/ChargeStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * 充电状态&放电状态 + * + * @author xzzn + */ +public enum ChargeStatus +{ + CHARGING("1", "充电"), STANDBY("2", "待机"), DISCHARGING("3", "放电"); + + private final String code; + private final String info; + + ChargeStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/CommunicationStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/CommunicationStatus.java new file mode 100644 index 0000000..40b7d48 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/CommunicationStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * device-通信状态 + * + * @author xzzn + */ +public enum CommunicationStatus +{ + OK("0", "正常"), SUSPEND("1", "通信中断") ,EXCEPTION("1", "异常"); + + private final String code; + private final String info; + + CommunicationStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/ControlModeStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/ControlModeStatus.java new file mode 100644 index 0000000..3e17f14 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/ControlModeStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * pcs-控制模式 + * + * @author xzzn + */ +public enum ControlModeStatus +{ + REMOTE("0", "远程"), LOCAL("1", "本地"); + + private final String code; + private final String info; + + ControlModeStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceStatus.java new file mode 100644 index 0000000..07b41af --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * pcs-设备状态 + * + * @author xzzn + */ +public enum DeviceStatus +{ + ONLINE("0", "在线"), OFFLINE("1", "离线"), UNDER_REPAIR("2", "维修中"); + + private final String code; + private final String info; + + DeviceStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceType.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceType.java new file mode 100644 index 0000000..6270cdd --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceType.java @@ -0,0 +1,20 @@ +package com.xzzn.common.enums; + +/** + * device-设备类型 + * + * @author xzzn + */ + +public enum DeviceType +{ + /** + * 网络设备 + */ + TCP, + + /** + * 串口设备 + */ + RTU +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/GridStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/GridStatus.java new file mode 100644 index 0000000..e64ec8a --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/GridStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * pcs-并网状态 + * + * @author xzzn + */ +public enum GridStatus +{ + GRID("0", "并网"), NOTGRID("1", "未并网"); + + private final String code; + private final String info; + + GridStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/StrategyStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/StrategyStatus.java new file mode 100644 index 0000000..c77a0af --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/StrategyStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * strategy-策略状态 + * + * @author xzzn + */ +public enum StrategyStatus +{ + NOT_ENABLED("0", "未启用"), RUNNING("1", "已运行"),SUSPENDED("2", "已暂停"), DISABLE("1", "禁用"),DELETE("2", "删除"); + + private final String code; + private final String info; + + StrategyStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/SwitchStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/SwitchStatus.java new file mode 100644 index 0000000..1b07779 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/SwitchStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * pcs-开关状态 + * + * @author xzzn + */ +public enum SwitchStatus +{ + CLOSED("0", "闭合"), DISCONNECT("1", "断开"), FAULT_DISCONNECT("2", "故障断开"); + + private final String code; + private final String info; + + SwitchStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java new file mode 100644 index 0000000..e16999f --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * pcs-工作状态 + * + * @author xzzn + */ +public enum WorkStatus +{ + NORMAL("0", "正常"), ABNORMAL("1", "异常"), STOP("2", "停止"); + + private final String code; + private final String info; + + WorkStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} -- 2.49.0 From 3d71b9cabab560fa1d678414f5cedb1de4a4681c Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 30 Jun 2025 20:33:57 +0800 Subject: [PATCH 025/336] =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/enums/AmmeterCategoryStatus.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategoryStatus.java diff --git a/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategoryStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategoryStatus.java new file mode 100644 index 0000000..957e9f6 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategoryStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * ammeter-电表数据类别 + * + * @author xzzn + */ +public enum AmmeterCategoryStatus +{ + TOTAL_CHARGE("1", "累计充电量"), TOTAL_DISCHARGE("2", "累计放电量"), DAILY_CHARGE("3", "日充电量"), DAILY_DISCHARGE("4", "日放电量"); + + private final String code; + private final String info; + + AmmeterCategoryStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} -- 2.49.0 From 9fbc6dc6b826ee6dcee013204f1c4327400f17ea Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 21:15:20 +0800 Subject: [PATCH 026/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20mqtt=20=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-admin/src/main/resources/application.yml b/ems-admin/src/main/resources/application.yml index bd1addd..70ad9a7 100644 --- a/ems-admin/src/main/resources/application.yml +++ b/ems-admin/src/main/resources/application.yml @@ -132,7 +132,7 @@ mqtt: broker.url: tcp://122.51.194.184:1883 client.id: ems-cloud username: dmbroker - password: Setri@64335270 + password: qwer1234 connection-timeout: 15 keep-alive-interval: 30 automatic-reconnect: true \ No newline at end of file -- 2.49.0 From 790e4ca716328b3c39b188e209f41bbfd5bb2208 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 21:38:17 +0800 Subject: [PATCH 027/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index c7776c1..4cc56ba 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; +import com.xzzn.common.enums.*; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; @@ -188,9 +189,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { data.setTotalDischargeEnergy(BigDecimal.ZERO); // 其他非 BigDecimal 字段 - data.setWorkStatus("1"); // 或其他默认值 - data.setPcsCommunicationStatus("1"); - data.setEmsCommunicationStatus("1"); + data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setCreateBy("system"); data.setCreateTime(DateUtils.getNowDate()); data.setUpdateBy("system"); @@ -247,9 +248,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { dataStack.setTotalDischargeEnergy(BigDecimal.ZERO); // 其他非 BigDecimal 字段 - dataStack.setWorkStatus("1"); // 或其他默认值 - dataStack.setPcsCommunicationStatus("1"); - dataStack.setEmsCommunicationStatus("1"); + dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setCreateBy("system"); dataStack.setCreateTime(DateUtils.getNowDate()); dataStack.setUpdateBy("system"); @@ -307,10 +308,10 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { EmsPcsData pcsData = new EmsPcsData(); // 时间与状态类字段 pcsData.setDataUpdateTime(new Date()); - pcsData.setWorkStatus("A"); - pcsData.setGridStatus("B"); - pcsData.setDeviceStatus("C"); - pcsData.setControlMode("D"); + pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); + pcsData.setGridStatus(GridStatus.GRID.getCode()); + pcsData.setDeviceStatus(DeviceStatus.ONLINE.getCode()); + pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); // 功率与能量类字段 pcsData.setTotalActivePower(BigDecimal.ZERO); @@ -338,11 +339,11 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { pcsData.setAcFrequency(BigDecimal.ZERO); // 状态指示类 - pcsData.setBranchStatus("A"); - pcsData.setDischargeStatus("A"); - pcsData.setAcSwitchStatus("A"); - pcsData.setDcSwitchStatus("A"); - pcsData.setRemoteControlStatus("A"); + pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); + pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); + pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); + pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); + pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); // 直流参数 pcsData.setDcVoltage(BigDecimal.ZERO); @@ -359,8 +360,6 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { pcsData.setDateMonth(DateUtils.getNowMonthLong()); pcsData.setDateDay(DateUtils.getNowDayLong()); - pcsData.setDeviceId(deviceId); - emsPcsDataService.insertEmsPcsData(pcsData); Map> records = processDataPrefix(JSON.parseObject(jsonData, new TypeReference>() {})); -- 2.49.0 From d0db9e137a8b9fab03bbf965f6991c1d894cdab9 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 21:47:39 +0800 Subject: [PATCH 028/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 154 +++++++++++------- 1 file changed, 95 insertions(+), 59 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 4cc56ba..2c52393 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -149,65 +149,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { String jsonData = obj.get("Data").toString(); log.info("deviceId:" + deviceId); - if (deviceId.contains("BMS")) { - log.info("===================="); - log.info("BMS data:"+ jsonData); - //BMS 电池簇 - EmsBatteryCluster data = new EmsBatteryCluster(); - // 设置所有 BigDecimal 类型字段为 ZERO - data.setChargeableCapacity(BigDecimal.ZERO); - data.setTotalChargedCapacity(BigDecimal.ZERO); - data.setDischargeableCapacity(BigDecimal.ZERO); - data.setTotalDischargedCapacity(BigDecimal.ZERO); - data.setSoh(BigDecimal.ZERO); - data.setAverageTemperature(BigDecimal.ZERO); - data.setInsulationResistance(BigDecimal.ZERO); - data.setCurrentSoc(BigDecimal.ZERO); - data.setMaxAllowedChargePower(BigDecimal.ZERO); - data.setMaxAllowedDischargePower(BigDecimal.ZERO); - data.setMaxAllowedChargeVoltage(BigDecimal.ZERO); - data.setMaxAllowedDischargeVoltage(BigDecimal.ZERO); - data.setMaxAllowedChargeCurrent(BigDecimal.ZERO); - data.setMaxAllowedDischargeCurrent(BigDecimal.ZERO); - data.setBatteryPackVoltage(BigDecimal.ZERO); - data.setBatteryPackCurrent(BigDecimal.ZERO); - data.setBatteryPackTemp(BigDecimal.ZERO); - data.setBatteryPackSoc(BigDecimal.ZERO); - data.setBatteryPackSoh(BigDecimal.ZERO); - data.setBatteryPackInsulationResistance(BigDecimal.ZERO); - data.setAvgCellVoltage(BigDecimal.ZERO); - data.setAvgCellTemp(BigDecimal.ZERO); - data.setMaxCellVoltage(BigDecimal.ZERO); - data.setMinCellVoltage(BigDecimal.ZERO); - data.setMaxCellTemp(BigDecimal.ZERO); - data.setMinCellTemp(BigDecimal.ZERO); - data.setMaxCellSoc(BigDecimal.ZERO); - data.setMinCellSoc(BigDecimal.ZERO); - data.setMaxCellSoh(BigDecimal.ZERO); - data.setMinCellSoh(BigDecimal.ZERO); - data.setTotalChargeEnergy(BigDecimal.ZERO); - data.setTotalDischargeEnergy(BigDecimal.ZERO); - - // 其他非 BigDecimal 字段 - data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 - data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); - data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - data.setCreateBy("system"); - data.setCreateTime(DateUtils.getNowDate()); - data.setUpdateBy("system"); - data.setUpdateTime(DateUtils.getNowDate()); - data.setSiteId("021_FXX_01"); - data.setDeviceId(deviceId); - data.setMaxCellVoltageId(Long.parseLong("1")); - data.setMinCellVoltageId(Long.parseLong("1")); - data.setMaxCellTempId(Long.parseLong("1")); - data.setMinCellTempId(Long.parseLong("1")); - data.setMaxCellSocId(Long.parseLong("1")); - data.setMinCellSocId(Long.parseLong("1")); - data.setMaxCellSohId(Long.parseLong("1")); - data.setMinCellSohId(Long.parseLong("1")); - data.setStackDeviceId("1"); - emsBatteryClusterService.insertEmsBatteryCluster(data); + if (deviceId.contains("BMSD")) { //电池堆 @@ -269,6 +211,98 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { emsBatteryStackService.insertEmsBatteryStack(dataStack); + //单体电池 + Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); + List list = new ArrayList<>(); + //单体电池 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsBatteryData batteryData = new EmsBatteryData(); + batteryData.setDeviceId(recordId); + batteryData.setBatteryCellId(recordId); + batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); + batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); + batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); + batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); + + batteryData.setBatteryCluster(deviceId); + batteryData.setBatteryPack(deviceId); + + // 时间戳 + batteryData.setDataTimestamp(new Date()); + + // ID字段 + batteryData.setSiteId(("021_FXX_01")); + batteryData.setClusterDeviceId(("021")); + + list.add(batteryData); + } + if (list.size() > 0 ) { + emsBatteryDataService.insertEmsBatteryDataList(list); + } + } else if (deviceId.contains("DMSC")) { + log.info("===================="); + log.info("BMSC data:"+ jsonData); + //BMS 电池簇 + EmsBatteryCluster data = new EmsBatteryCluster(); + // 设置所有 BigDecimal 类型字段为 ZERO + data.setChargeableCapacity(BigDecimal.ZERO); + data.setTotalChargedCapacity(BigDecimal.ZERO); + data.setDischargeableCapacity(BigDecimal.ZERO); + data.setTotalDischargedCapacity(BigDecimal.ZERO); + data.setSoh(BigDecimal.ZERO); + data.setAverageTemperature(BigDecimal.ZERO); + data.setInsulationResistance(BigDecimal.ZERO); + data.setCurrentSoc(BigDecimal.ZERO); + data.setMaxAllowedChargePower(BigDecimal.ZERO); + data.setMaxAllowedDischargePower(BigDecimal.ZERO); + data.setMaxAllowedChargeVoltage(BigDecimal.ZERO); + data.setMaxAllowedDischargeVoltage(BigDecimal.ZERO); + data.setMaxAllowedChargeCurrent(BigDecimal.ZERO); + data.setMaxAllowedDischargeCurrent(BigDecimal.ZERO); + data.setBatteryPackVoltage(BigDecimal.ZERO); + data.setBatteryPackCurrent(BigDecimal.ZERO); + data.setBatteryPackTemp(BigDecimal.ZERO); + data.setBatteryPackSoc(BigDecimal.ZERO); + data.setBatteryPackSoh(BigDecimal.ZERO); + data.setBatteryPackInsulationResistance(BigDecimal.ZERO); + data.setAvgCellVoltage(BigDecimal.ZERO); + data.setAvgCellTemp(BigDecimal.ZERO); + data.setMaxCellVoltage(BigDecimal.ZERO); + data.setMinCellVoltage(BigDecimal.ZERO); + data.setMaxCellTemp(BigDecimal.ZERO); + data.setMinCellTemp(BigDecimal.ZERO); + data.setMaxCellSoc(BigDecimal.ZERO); + data.setMinCellSoc(BigDecimal.ZERO); + data.setMaxCellSoh(BigDecimal.ZERO); + data.setMinCellSoh(BigDecimal.ZERO); + data.setTotalChargeEnergy(BigDecimal.ZERO); + data.setTotalDischargeEnergy(BigDecimal.ZERO); + + // 其他非 BigDecimal 字段 + data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + data.setSiteId("021_FXX_01"); + data.setDeviceId(deviceId); + data.setMaxCellVoltageId(Long.parseLong("1")); + data.setMinCellVoltageId(Long.parseLong("1")); + data.setMaxCellTempId(Long.parseLong("1")); + data.setMinCellTempId(Long.parseLong("1")); + data.setMaxCellSocId(Long.parseLong("1")); + data.setMinCellSocId(Long.parseLong("1")); + data.setMaxCellSohId(Long.parseLong("1")); + data.setMinCellSohId(Long.parseLong("1")); + data.setStackDeviceId("1"); + emsBatteryClusterService.insertEmsBatteryCluster(data); + + //单体电池 Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); List list = new ArrayList<>(); @@ -304,6 +338,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { log.info("===================="); log.info("PCS data:"+ jsonData); + + //pcs EmsPcsData pcsData = new EmsPcsData(); // 时间与状态类字段 -- 2.49.0 From 7e265e21b17520da667e5fd460aeb7695af103ad Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 21:54:51 +0800 Subject: [PATCH 029/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/web/controller/ems/MqttMessageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 2c52393..a995230 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -327,7 +327,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { // ID字段 batteryData.setSiteId(("021_FXX_01")); - batteryData.setClusterDeviceId(("021")); + batteryData.setClusterDeviceId(deviceId); list.add(batteryData); } -- 2.49.0 From 93bd88b94c09bf09b83b691fc8ed23931143f1a2 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 30 Jun 2025 22:08:15 +0800 Subject: [PATCH 030/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/web/controller/ems/MqttMessageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index a995230..6097bce 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -242,7 +242,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { if (list.size() > 0 ) { emsBatteryDataService.insertEmsBatteryDataList(list); } - } else if (deviceId.contains("DMSC")) { + } else if (deviceId.contains("BMSC")) { log.info("===================="); log.info("BMSC data:"+ jsonData); //BMS 电池簇 -- 2.49.0 From 8663ab83252fc09753e76477966e784e3addbbc1 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 30 Jun 2025 22:22:47 +0800 Subject: [PATCH 031/336] =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=A5=E5=8F=82site=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 4 +-- .../xzzn/ems/mapper/EmsBatteryDataMapper.java | 2 +- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 9 ++++++ .../xzzn/ems/service/ISingleSiteService.java | 2 +- .../service/impl/SingleSiteServiceImpl.java | 4 +-- .../mapper/ems/EmsBatteryDataMapper.xml | 31 ++++++++++--------- .../resources/mapper/ems/EmsPcsDataMapper.xml | 17 ++++++++++ 7 files changed, 48 insertions(+), 21 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 3375e20..327d5bb 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -110,10 +110,10 @@ public class EmsSiteMonitorController extends BaseController{ * 获取电池簇下面的单体电池数据 */ @GetMapping("/getClusterDataInfoList") - public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId) + public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId) { startPage(); - List list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId); + List list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId); return getDataTable(list); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java index f20530d..675ee46 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java @@ -91,7 +91,7 @@ public interface EmsBatteryDataMapper * @param clusterDeviceId * @return */ - public List getAllBatteryDataByClusterId(String clusterDeviceId); + public List getAllBatteryDataByClusterId(@Param("clusterDeviceId") String clusterDeviceId,@Param("siteId") String siteId); int insertEmsBatteryDataList(List emsBatteryDataList); diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index c49ea50..7f4c5bc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -1,6 +1,7 @@ package com.xzzn.ems.mapper; import java.math.BigDecimal; +import java.util.Date; import java.util.List; import java.util.Map; @@ -99,4 +100,12 @@ public interface EmsPcsDataMapper * @return */ public Map getPcsTotalChargeData(String siteId); + + /** + * 根据时间按天获取充放电量 + * @param startDate + * @param endDate + * @return + */ + public List getPcsDataByDate(Date startDate, Date endDate); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index afa0287..9b97989 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -27,7 +27,7 @@ public interface ISingleSiteService public List getCoolingDataList(String siteId); - public List getClusterDataInfoList(String clusterDeviceId); + public List getClusterDataInfoList(String clusterDeviceId,String siteId); public List getAmmeterDataList(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 9bcd459..0d10ba9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -242,9 +242,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public List getClusterDataInfoList(String clusterDeviceId) { + public List getClusterDataInfoList(String clusterDeviceId,String siteId) { List batteryDataStatsListVo = new ArrayList<>(); - batteryDataStatsListVo = emsBatteryDataMapper.getAllBatteryDataByClusterId(clusterDeviceId); + batteryDataStatsListVo = emsBatteryDataMapper.getAllBatteryDataByClusterId(clusterDeviceId,siteId); return batteryDataStatsListVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index dc0b436..263c76e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -177,21 +177,22 @@ SELECT NULL AS type, NULL AS device_id FROM DUAL WHERE 1=0 - + SELECT t.update_time as updateTime, t.voltage, t.temperature, + t.soc, t.soh, t.device_id as deviceId + FROM ems_battery_data t + JOIN ( SELECT device_id, MAX(update_time) AS max_update_time + FROM ems_battery_data + WHERE site_id = #{siteId} + + and cluster_device_id = #{clusterDeviceId} + + GROUP BY device_id + ) latest ON t.device_id = latest.device_id AND t.update_time = latest.max_update_time + WHERE t.site_id = #{siteId} + + and t.cluster_device_id = #{clusterDeviceId} + diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 689968b..5ec821f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -371,4 +371,21 @@ WHERE tmp.site_id = #{siteId} order by tmp.device_id + + \ No newline at end of file -- 2.49.0 From 342439e3a94100973764b0be867c9b103b68214a Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 30 Jun 2025 23:01:41 +0800 Subject: [PATCH 032/336] =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ems/EmsBatteryDataMapper.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index 263c76e..29172e4 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -178,17 +178,17 @@ \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index 29172e4..3b7b470 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -179,16 +179,18 @@ @@ -51,6 +52,7 @@ and site_id = #{siteId} and communication_status = #{communicationStatus} and device_id = #{deviceId} + and parent_id = #{parentId} @@ -80,6 +82,7 @@ site_id, communication_status, device_id, + parent_id, #{deviceName}, @@ -100,6 +103,7 @@ #{siteId}, #{communicationStatus}, #{deviceId}, + #{parentId}, @@ -124,6 +128,7 @@ site_id = #{siteId}, communication_status = #{communicationStatus}, device_id = #{deviceId}, + parent_id = #{parentId}, where id = #{id} @@ -146,9 +151,7 @@ \ No newline at end of file -- 2.49.0 From 5eb8de692cdd44abc77920caf4f3ecbac13d1001 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Tue, 1 Jul 2025 21:21:20 +0800 Subject: [PATCH 035/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 387 +---------------- .../com/xzzn/common/utils/StringUtils.java | 20 + .../com/xzzn/ems/domain/EmsPcsBranchData.java | 6 +- .../ems/service/IFXXDataProcessService.java | 7 + .../impl/FXXDataProcessServiceImpl.java | 405 ++++++++++++++++++ 5 files changed, 440 insertions(+), 385 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 6097bce..e6283a5 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -1,14 +1,8 @@ package com.xzzn.web.controller.ems; -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.alibaba.fastjson2.TypeReference; -import com.xzzn.common.enums.*; -import com.xzzn.common.utils.DateUtils; -import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.*; -import com.xzzn.ems.service.*; +import com.xzzn.ems.domain.EmsMqttMessage; +import com.xzzn.ems.service.IEmsMqttMessageService; +import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.framework.web.service.MqttSubscriber; @@ -21,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; -import java.math.BigDecimal; -import java.util.*; @Service public class MqttMessageController implements MqttPublisher, MqttSubscriber { @@ -37,21 +29,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { private IEmsMqttMessageService emsMqttMessageService; @Autowired - private IEmsBatteryDataService emsBatteryDataService; - - @Autowired - private IEmsPcsDataService emsPcsDataService; - - @Autowired - private IEmsPcsBranchDataService emsPcsBranchDataService; - - @Autowired - private IEmsBatteryClusterService emsBatteryClusterService; - - @Autowired - private IEmsBatteryStackService emsBatteryStackService; - - + private IFXXDataProcessService fXXDataProcessService; @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { @@ -94,7 +72,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[DEVICE] data: " + payload); try { // 业务处理逻辑 - handleFxData(payload); + fXXDataProcessService.handleFxData(payload); EmsMqttMessage mqttMessage = new EmsMqttMessage(); @@ -139,360 +117,5 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } - private void handleFxData(String message) { - JSONArray arraylist = JSONArray.parseArray(message); - for (int i = 0; i < arraylist.size(); i++) { - JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); - - String deviceId = obj.get("Device").toString(); - String jsonData = obj.get("Data").toString(); - - log.info("deviceId:" + deviceId); - if (deviceId.contains("BMSD")) { - - - //电池堆 - //BMS 电池簇 - EmsBatteryStack dataStack = new EmsBatteryStack(); - // 设置所有 BigDecimal 类型字段为 ZERO - dataStack.setChargeableCapacity(BigDecimal.ZERO); - dataStack.setTotalChargedCapacity(BigDecimal.ZERO); - dataStack.setDischargeableCapacity(BigDecimal.ZERO); - dataStack.setTotalDischargedCapacity(BigDecimal.ZERO); - dataStack.setSoh(BigDecimal.ZERO); - dataStack.setAverageTemperature(BigDecimal.ZERO); - dataStack.setInsulationResistance(BigDecimal.ZERO); - dataStack.setCurrentSoc(BigDecimal.ZERO); - dataStack.setMaxAllowedChargePower(BigDecimal.ZERO); - dataStack.setMaxAllowedDischargePower(BigDecimal.ZERO); - dataStack.setMaxAllowedChargeVoltage(BigDecimal.ZERO); - dataStack.setMaxAllowedDischargeVoltage(BigDecimal.ZERO); - dataStack.setMaxAllowedChargeCurrent(BigDecimal.ZERO); - dataStack.setMaxAllowedDischargeCurrent(BigDecimal.ZERO); - dataStack.setBatteryPackVoltage(BigDecimal.ZERO); - dataStack.setBatteryPackCurrent(BigDecimal.ZERO); - dataStack.setBatteryPackTemp(BigDecimal.ZERO); - dataStack.setBatteryPackSoc(BigDecimal.ZERO); - dataStack.setBatteryPackSoh(BigDecimal.ZERO); - dataStack.setBatteryPackInsulationResistance(BigDecimal.ZERO); - dataStack.setAvgCellVoltage(BigDecimal.ZERO); - dataStack.setAvgCellTemp(BigDecimal.ZERO); - dataStack.setMaxCellVoltage(BigDecimal.ZERO); - dataStack.setMinCellVoltage(BigDecimal.ZERO); - dataStack.setMaxCellTemp(BigDecimal.ZERO); - dataStack.setMinCellTemp(BigDecimal.ZERO); - dataStack.setMaxCellSoc(BigDecimal.ZERO); - dataStack.setMinCellSoc(BigDecimal.ZERO); - dataStack.setMaxCellSoh(BigDecimal.ZERO); - dataStack.setMinCellSoh(BigDecimal.ZERO); - dataStack.setTotalChargeEnergy(BigDecimal.ZERO); - dataStack.setTotalDischargeEnergy(BigDecimal.ZERO); - - // 其他非 BigDecimal 字段 - dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 - dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); - dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - dataStack.setCreateBy("system"); - dataStack.setCreateTime(DateUtils.getNowDate()); - dataStack.setUpdateBy("system"); - dataStack.setUpdateTime(DateUtils.getNowDate()); - dataStack.setSiteId("021_FXX_01"); - dataStack.setDeviceId(deviceId); - dataStack.setMaxCellVoltageId(Long.parseLong("1")); - dataStack.setMinCellVoltageId(Long.parseLong("1")); - dataStack.setMaxCellTempId(Long.parseLong("1")); - dataStack.setMinCellTempId(Long.parseLong("1")); - dataStack.setMaxCellSocId(Long.parseLong("1")); - dataStack.setMinCellSocId(Long.parseLong("1")); - dataStack.setMaxCellSohId(Long.parseLong("1")); - dataStack.setMinCellSohId(Long.parseLong("1")); - - emsBatteryStackService.insertEmsBatteryStack(dataStack); - - - //单体电池 - Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); - List list = new ArrayList<>(); - //单体电池 - for (Map.Entry> record : records.entrySet()) { - String recordId = record.getKey(); - Map fields = record.getValue(); - - EmsBatteryData batteryData = new EmsBatteryData(); - batteryData.setDeviceId(recordId); - batteryData.setBatteryCellId(recordId); - batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); - batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); - batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); - batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); - - batteryData.setBatteryCluster(deviceId); - batteryData.setBatteryPack(deviceId); - - // 时间戳 - batteryData.setDataTimestamp(new Date()); - - // ID字段 - batteryData.setSiteId(("021_FXX_01")); - batteryData.setClusterDeviceId(("021")); - - list.add(batteryData); - } - if (list.size() > 0 ) { - emsBatteryDataService.insertEmsBatteryDataList(list); - } - } else if (deviceId.contains("BMSC")) { - log.info("===================="); - log.info("BMSC data:"+ jsonData); - //BMS 电池簇 - EmsBatteryCluster data = new EmsBatteryCluster(); - // 设置所有 BigDecimal 类型字段为 ZERO - data.setChargeableCapacity(BigDecimal.ZERO); - data.setTotalChargedCapacity(BigDecimal.ZERO); - data.setDischargeableCapacity(BigDecimal.ZERO); - data.setTotalDischargedCapacity(BigDecimal.ZERO); - data.setSoh(BigDecimal.ZERO); - data.setAverageTemperature(BigDecimal.ZERO); - data.setInsulationResistance(BigDecimal.ZERO); - data.setCurrentSoc(BigDecimal.ZERO); - data.setMaxAllowedChargePower(BigDecimal.ZERO); - data.setMaxAllowedDischargePower(BigDecimal.ZERO); - data.setMaxAllowedChargeVoltage(BigDecimal.ZERO); - data.setMaxAllowedDischargeVoltage(BigDecimal.ZERO); - data.setMaxAllowedChargeCurrent(BigDecimal.ZERO); - data.setMaxAllowedDischargeCurrent(BigDecimal.ZERO); - data.setBatteryPackVoltage(BigDecimal.ZERO); - data.setBatteryPackCurrent(BigDecimal.ZERO); - data.setBatteryPackTemp(BigDecimal.ZERO); - data.setBatteryPackSoc(BigDecimal.ZERO); - data.setBatteryPackSoh(BigDecimal.ZERO); - data.setBatteryPackInsulationResistance(BigDecimal.ZERO); - data.setAvgCellVoltage(BigDecimal.ZERO); - data.setAvgCellTemp(BigDecimal.ZERO); - data.setMaxCellVoltage(BigDecimal.ZERO); - data.setMinCellVoltage(BigDecimal.ZERO); - data.setMaxCellTemp(BigDecimal.ZERO); - data.setMinCellTemp(BigDecimal.ZERO); - data.setMaxCellSoc(BigDecimal.ZERO); - data.setMinCellSoc(BigDecimal.ZERO); - data.setMaxCellSoh(BigDecimal.ZERO); - data.setMinCellSoh(BigDecimal.ZERO); - data.setTotalChargeEnergy(BigDecimal.ZERO); - data.setTotalDischargeEnergy(BigDecimal.ZERO); - - // 其他非 BigDecimal 字段 - data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 - data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); - data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - data.setCreateBy("system"); - data.setCreateTime(DateUtils.getNowDate()); - data.setUpdateBy("system"); - data.setUpdateTime(DateUtils.getNowDate()); - data.setSiteId("021_FXX_01"); - data.setDeviceId(deviceId); - data.setMaxCellVoltageId(Long.parseLong("1")); - data.setMinCellVoltageId(Long.parseLong("1")); - data.setMaxCellTempId(Long.parseLong("1")); - data.setMinCellTempId(Long.parseLong("1")); - data.setMaxCellSocId(Long.parseLong("1")); - data.setMinCellSocId(Long.parseLong("1")); - data.setMaxCellSohId(Long.parseLong("1")); - data.setMinCellSohId(Long.parseLong("1")); - data.setStackDeviceId("1"); - emsBatteryClusterService.insertEmsBatteryCluster(data); - - - //单体电池 - Map> records = processData(JSON.parseObject(jsonData, new TypeReference>() {})); - List list = new ArrayList<>(); - //单体电池 - for (Map.Entry> record : records.entrySet()) { - String recordId = record.getKey(); - Map fields = record.getValue(); - - EmsBatteryData batteryData = new EmsBatteryData(); - batteryData.setDeviceId(recordId); - batteryData.setBatteryCellId(recordId); - batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); - batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); - batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); - batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); - - batteryData.setBatteryCluster(deviceId); - batteryData.setBatteryPack(deviceId); - - // 时间戳 - batteryData.setDataTimestamp(new Date()); - - // ID字段 - batteryData.setSiteId(("021_FXX_01")); - batteryData.setClusterDeviceId(deviceId); - - list.add(batteryData); - } - if (list.size() > 0 ) { - emsBatteryDataService.insertEmsBatteryDataList(list); - } - } else if (deviceId.contains("PCS")) { - log.info("===================="); - - log.info("PCS data:"+ jsonData); - - - //pcs - EmsPcsData pcsData = new EmsPcsData(); - // 时间与状态类字段 - pcsData.setDataUpdateTime(new Date()); - pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); - pcsData.setGridStatus(GridStatus.GRID.getCode()); - pcsData.setDeviceStatus(DeviceStatus.ONLINE.getCode()); - pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); - - // 功率与能量类字段 - pcsData.setTotalActivePower(BigDecimal.ZERO); - pcsData.setDailyAcChargeEnergy(BigDecimal.ZERO); - pcsData.setTotalReactivePower(BigDecimal.ZERO); - pcsData.setDailyAcDischargeEnergy(BigDecimal.ZERO); - pcsData.setTotalApparentPower(BigDecimal.ZERO); - pcsData.setTotalPowerFactor(BigDecimal.ZERO); - pcsData.setDcPower(BigDecimal.ZERO); - pcsData.setTotalAcChargeEnergy(BigDecimal.ZERO); - pcsData.setTotalAcDischargeEnergy(BigDecimal.ZERO); - pcsData.setAcChargeActivePower(BigDecimal.ZERO); - pcsData.setAcCapacitiveReactivePower(BigDecimal.ZERO); - pcsData.setAcDischargeActivePower(BigDecimal.ZERO); - pcsData.setAcInductiveReactivePower(BigDecimal.ZERO); - pcsData.setMaxCapacitivePowerCapacity(BigDecimal.ZERO); - pcsData.setMaxInductivePowerCapacity(BigDecimal.ZERO); - pcsData.setMaxChargePowerCapacity(BigDecimal.ZERO); - pcsData.setMaxDischargePowerCapacity(BigDecimal.ZERO); - - - // 温度与环境参数 - pcsData.setPcsModuleTemperature(BigDecimal.ZERO); - pcsData.setPcsEnvironmentTemperature(BigDecimal.ZERO); - pcsData.setAcFrequency(BigDecimal.ZERO); - - // 状态指示类 - pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); - pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); - pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); - pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); - pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); - - // 直流参数 - pcsData.setDcVoltage(BigDecimal.ZERO); - pcsData.setDcCurrent(BigDecimal.ZERO); - - // 系统管理字段 -// data.setCreateBy(BigDecimal.ZERO); -// data.setCreateTime(BigDecimal.ZERO); -// data.setUpdateBy(BigDecimal.ZERO); -// data.setUpdateTime(BigDecimal.ZERO); -// data.setRemark(BigDecimal.ZERO); - pcsData.setSiteId("021_FXX_01"); - pcsData.setDeviceId(deviceId); - pcsData.setDateMonth(DateUtils.getNowMonthLong()); - pcsData.setDateDay(DateUtils.getNowDayLong()); - - emsPcsDataService.insertEmsPcsData(pcsData); - - Map> records = processDataPrefix(JSON.parseObject(jsonData, new TypeReference>() {})); - List list = new ArrayList<>(); - - //PCS支路 - for (Map.Entry> record : records.entrySet()) { - String recordId = record.getKey(); - Map fields = record.getValue(); - - EmsPcsBranchData data = new EmsPcsBranchData(); - data.setDeviceId(recordId); - data.setDcPower(BigDecimal.ZERO); - data.setDcVoltage(BigDecimal.ZERO); - data.setDcCurrent(BigDecimal.ZERO); - data.setGridUVoltage(BigDecimal.ZERO); - data.setGridVVoltage(BigDecimal.ZERO); - data.setGridWVoltage(BigDecimal.ZERO); - data.setOutputUCurrent(BigDecimal.ZERO); - data.setOutputVCurrent(BigDecimal.ZERO); - data.setOutputWCurrent(BigDecimal.ZERO); - data.setApparentPower(BigDecimal.ZERO); - data.setActivePower(BigDecimal.ZERO); - data.setReactivePower(BigDecimal.ZERO); - data.setPowerFactor(BigDecimal.ZERO); - data.setFrequency(BigDecimal.ZERO); - data.setInternalTemp(BigDecimal.ZERO); - data.setuIgbtTemp(BigDecimal.ZERO); - data.setvIgbtTemp(BigDecimal.ZERO); - data.setwIgbtTemp(BigDecimal.ZERO); - data.setAvailablePower(BigDecimal.ZERO); - data.setTotalLoadRatio(BigDecimal.ZERO); - data.setAcLeakageCurrent(BigDecimal.ZERO); - data.setInsulationResistance(BigDecimal.ZERO); - data.setBranchId(Long.parseLong("1")); - list.add(data); - } - if (list.size() > 0 ) { - emsPcsBranchDataService.insertEmsPcsBranchDataList(list); - } - - } - - } - - - } - - // 数据分组处理 - private static Map> processData(Map rawData) { - Map> records = new HashMap<>(); - - for (Map.Entry entry : rawData.entrySet()) { - String key = entry.getKey(); - // 提取记录ID(最后3位) - String recordId = key.substring(key.length() - 3); - try { - Long.parseLong(recordId); - } catch (Exception e) { - continue; - } - - // 提取字段类型(前缀) - String fieldType = key.substring(0, key.length() - 3); - - // 初始化记录 - records.putIfAbsent(recordId, new HashMap<>()); - // 存入字段值 - records.get(recordId).put(fieldType, entry.getValue()); - } - return records; - } - - private static Map> processDataPrefix(Map rawData) { - Map> records = new HashMap<>(); - - for (Map.Entry entry : rawData.entrySet()) { - String key = entry.getKey(); - // 确保键长度足够 - if (key.length() < 3) { - continue; - } - - // 提取记录ID(前3位) - String recordId = key.substring(0, 3); - if (!recordId.startsWith("DY")) { - continue; - } - - // 提取字段类型(剩余部分) - String fieldType = key.substring(3); - - // 初始化记录 - records.putIfAbsent(recordId, new HashMap<>()); - // 存入字段值 - records.get(recordId).put(fieldType, entry.getValue()); - } - return records; - } } \ No newline at end of file diff --git a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java index 0eb43f4..501f549 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java @@ -731,4 +731,24 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } } + + public static Long getLong(Object s){ + + try { + return Long.parseLong(s.toString()); + } catch (NumberFormatException e) { + return Long.parseLong("0"); + } + + } + + public static String getString(Object s){ + + try { + return String.valueOf(s); + } catch (NumberFormatException e) { + return "0"; + } + + } } \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java index f981197..a954deb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsBranchData.java @@ -46,7 +46,7 @@ public class EmsPcsBranchData extends BaseEntity /** 支路id */ @Excel(name = "支路id") - private Long branchId; + private String branchId; /** 电网U相电压 */ @Excel(name = "电网U相电压") @@ -198,12 +198,12 @@ public class EmsPcsBranchData extends BaseEntity return deviceId; } - public void setBranchId(Long branchId) + public void setBranchId(String branchId) { this.branchId = branchId; } - public Long getBranchId() + public String getBranchId() { return branchId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java b/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java new file mode 100644 index 0000000..1c8219d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java @@ -0,0 +1,7 @@ +package com.xzzn.ems.service; + +public interface IFXXDataProcessService { + + public void handleFxData(String message); + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java new file mode 100644 index 0000000..3968249 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -0,0 +1,405 @@ +package com.xzzn.ems.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.alibaba.fastjson2.TypeReference; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.*; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.*; +import com.xzzn.ems.mapper.*; +import com.xzzn.ems.service.IFXXDataProcessService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.*; + +@Service +public class FXXDataProcessServiceImpl implements IFXXDataProcessService { + private static final Log log = LogFactory.getLog(FXXDataProcessServiceImpl.class); + + @Autowired + private EmsBatteryClusterMapper emsBatteryClusterMapper; + + @Autowired + private EmsBatteryStackMapper emsBatteryStackMapper; + + @Autowired + private EmsBatteryDataMapper emsBatteryDataMapper; + + @Autowired + private EmsPcsDataMapper emsPcsDataMapper; + + @Autowired + private EmsPcsBranchDataMapper emsPcsBranchDataMapper; + + @Autowired + private RedisCache redisCache; + + + @Override + public void handleFxData(String message) { + JSONArray arraylist = JSONArray.parseArray(message); + + for (int i = 0; i < arraylist.size(); i++) { + JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); + + String deviceId = obj.get("Device").toString(); + String jsonData = obj.get("Data").toString(); + + log.info("deviceId:" + deviceId); + if (deviceId.contains("BMSD")) { + batteryStackDataProcess(deviceId, jsonData); + + } else if (deviceId.contains("BMSC")) { + log.info("BMSC data:"+ jsonData); + batteryCluserDataProcess(deviceId, jsonData); + batteryDataProcess(deviceId, jsonData); + + } else if (deviceId.contains("PCS")) { + pcsDataProcess(deviceId, jsonData); + pcsBranchDataProcess(deviceId, jsonData); + } + } + } + private void batteryStackDataProcess(String deviceId, String dataJson) { + + //电池堆 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + //BMS 电池簇 + EmsBatteryStack dataStack = new EmsBatteryStack(); + // 设置所有 BigDecimal 类型字段为 ZERO + dataStack.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); + dataStack.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); + dataStack.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); + dataStack.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); + dataStack.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + dataStack.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); + dataStack.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + dataStack.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + dataStack.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); + dataStack.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); + dataStack.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); + dataStack.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); + dataStack.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); + dataStack.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); + dataStack.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + dataStack.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + dataStack.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); + dataStack.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + dataStack.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + dataStack.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + dataStack.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); + dataStack.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); + dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); + dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); + dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); + dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); + dataStack.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); + dataStack.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); + dataStack.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); + dataStack.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); + dataStack.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); + dataStack.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); + + // 其他非 BigDecimal 字段 + dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + dataStack.setCreateBy("system"); + dataStack.setCreateTime(DateUtils.getNowDate()); + dataStack.setUpdateBy("system"); + dataStack.setUpdateTime(DateUtils.getNowDate()); + dataStack.setSiteId("021_FXX_01"); + dataStack.setDeviceId(deviceId); + dataStack.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD"))); + dataStack.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD"))); + dataStack.setMaxCellTempId(StringUtils.getLong(obj.get("ZGDTWDDYD"))); + dataStack.setMinCellTempId(StringUtils.getLong(obj.get("ZDDTWDDYD"))); + dataStack.setMaxCellSocId(StringUtils.getLong(obj.get("ZGDTSOCDYD"))); + dataStack.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); + dataStack.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); + dataStack.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); + + emsBatteryStackMapper.insertEmsBatteryStack(dataStack); + + + } + + + private void batteryCluserDataProcess(String deviceId, String dataJson) { + + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + //BMS 电池簇 + EmsBatteryCluster data = new EmsBatteryCluster(); + // 设置所有 BigDecimal 类型字段为 ZERO + data.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); + data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); + data.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); + data.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); + data.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); + data.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); + data.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); + data.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); + data.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); + data.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); + data.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); + data.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); + data.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); + data.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); + data.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); + data.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); + data.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); + data.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); + data.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); + data.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); + data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); + data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); + + // 其他非 BigDecimal 字段 + data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + data.setSiteId("021_FXX_01"); + data.setDeviceId(deviceId); + data.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD"))); + data.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD"))); + data.setMaxCellTempId(StringUtils.getLong(obj.get("ZGDTWDDYD"))); + data.setMinCellTempId(StringUtils.getLong(obj.get("ZDDTWDDYD"))); + data.setMaxCellSocId(StringUtils.getLong(obj.get("ZGDTSOCDYD"))); + data.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); + data.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); + data.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); + data.setStackDeviceId("1"); + emsBatteryClusterMapper.insertEmsBatteryCluster(data); + + + } + + private void batteryDataProcess(String deviceId, String dataJson) { + + //单体电池 + Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() {})); + List list = new ArrayList<>(); + //单体电池 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsBatteryData batteryData = new EmsBatteryData(); + batteryData.setDeviceId(recordId); + batteryData.setBatteryCellId(recordId); + batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); + batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); + batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); + batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); + + batteryData.setBatteryCluster(deviceId); + batteryData.setBatteryPack(deviceId); + + // 时间戳 + batteryData.setDataTimestamp(new Date()); + + // ID字段 + batteryData.setSiteId(("021_FXX_01")); + batteryData.setClusterDeviceId(("021")); + + list.add(batteryData); + } + if (list.size() > 0 ) { + emsBatteryDataMapper.insertEmsBatteryDataList(list); + + redisCache.setCacheList(deviceId + "_DATA_LIST", list); + } + } + + + private void pcsDataProcess(String deviceId, String dataJson) { + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + //pcs + EmsPcsData pcsData = new EmsPcsData(); + // 时间与状态类字段 + pcsData.setDataUpdateTime(new Date()); + pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); + pcsData.setGridStatus(GridStatus.GRID.getCode()); + pcsData.setDeviceStatus(DeviceStatus.ONLINE.getCode()); + pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); + + // 功率与能量类字段 + pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); + pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); + pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); + pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); + pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); + pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("ZCDL"))); + pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFDL"))); + pcsData.setAcChargeActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); + pcsData.setAcCapacitiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); + pcsData.setAcDischargeActivePower(StringUtils.getBigDecimal(obj.get("JLCFDYGGL"))); + pcsData.setAcInductiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCGXWGGL"))); + pcsData.setMaxCapacitivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDRXWGNL"))); + pcsData.setMaxInductivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDGXWGNL"))); + pcsData.setMaxChargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKCGL"))); + pcsData.setMaxDischargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKFGL"))); + + + // 温度与环境参数 +// pcsData.setPcsModuleTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setPcsEnvironmentTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setAcFrequency(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + + // 状态指示类 + pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); + pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); + String acSwitchStatus = StringUtils.getString(obj.get("JLKGZT")); + pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String dcSwitchStatus = StringUtils.getString(obj.get("ZLKGZT")); + pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String controlMode = StringUtils.getString(obj.get("YCTT")); + pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); + + // 直流参数 +// pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + + // 系统管理字段 + pcsData.setCreateBy("system"); + pcsData.setCreateTime(DateUtils.getNowDate()); + pcsData.setUpdateBy("system"); + pcsData.setUpdateTime(DateUtils.getNowDate()); + pcsData.setSiteId("021_FXX_01"); + pcsData.setDeviceId(deviceId); + pcsData.setDateMonth(DateUtils.getNowMonthLong()); + pcsData.setDateDay(DateUtils.getNowDayLong()); + + emsPcsDataMapper.insertEmsPcsData(pcsData); + + } + + + private void pcsBranchDataProcess(String deviceId, String dataJson) { + + Map> records = processDataPrefix(JSON.parseObject(dataJson, new TypeReference>() {})); + List list = new ArrayList<>(); + + //PCS支路 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsPcsBranchData data = new EmsPcsBranchData(); + data.setDeviceId(deviceId); + data.setGridStatus(GridStatus.GRID.getCode()); + data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); + data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); + data.setDcCurrent(StringUtils.getBigDecimal(fields.get("ZLDL"))); + data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWVXDY"))); + data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWUXDY"))); + data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWWXDY"))); + data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("SCUXDL"))); + data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("SCVXDL"))); + data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("SCWXDL"))); + data.setApparentPower(StringUtils.getBigDecimal(fields.get("SZGL"))); + data.setActivePower(StringUtils.getBigDecimal(fields.get("YGGL"))); + data.setReactivePower(StringUtils.getBigDecimal(fields.get("WGGL"))); + data.setPowerFactor(StringUtils.getBigDecimal(fields.get("GLYS"))); + data.setFrequency(StringUtils.getBigDecimal(fields.get("PL"))); + data.setInternalTemp(StringUtils.getBigDecimal(fields.get("DY1WD"))); + data.setuIgbtTemp(StringUtils.getBigDecimal(fields.get("UXIGBTWD"))); + data.setvIgbtTemp(StringUtils.getBigDecimal(fields.get("VXIGBTWD"))); + data.setwIgbtTemp(StringUtils.getBigDecimal(fields.get("WXIGBTWD"))); + data.setAvailablePower(StringUtils.getBigDecimal(fields.get("KYGL"))); + data.setTotalLoadRatio(StringUtils.getBigDecimal(fields.get("ZFZB"))); + data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); + data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); + data.setBranchId(recordId); + list.add(data); + } + if (list.size() > 0 ) { + emsPcsBranchDataMapper.insertPcsBranchDataList(list); + } + + } + + + // 数据分组处理 + private static Map> processData(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 提取记录ID(最后3位) + String recordId = key.substring(key.length() - 3); + try { + Long.parseLong(recordId); + } catch (Exception e) { + continue; + } + + // 提取字段类型(前缀) + String fieldType = key.substring(0, key.length() - 3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + return records; + } + + private static Map> processDataPrefix(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 确保键长度足够 + if (key.length() < 3) { + continue; + } + + // 提取记录ID(前3位) + String recordId = key.substring(0, 3); + if (!recordId.startsWith("DY")) { + continue; + } + + // 提取字段类型(剩余部分) + String fieldType = key.substring(3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + return records; + } + +} -- 2.49.0 From 259784f525977329dbe74a45bd1f4c49a209db67 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 1 Jul 2025 21:21:55 +0800 Subject: [PATCH 036/336] =?UTF-8?q?=E6=A6=82=E7=8E=87=E7=BB=9F=E8=AE=A1-?= =?UTF-8?q?=E7=94=B5=E9=87=8F=E6=8C=87=E6=A0=87=E9=BB=98=E8=AE=A47?= =?UTF-8?q?=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 2 -- .../service/impl/EmsStatsReportServiceImpl.java | 15 +++++++++++++++ .../resources/mapper/ems/EmsPcsDataMapper.xml | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index 7786264..761484f 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -10,8 +10,6 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Date; - /** * 单站监控-统计报表 * diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 631dab7..bd59fc7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -1,16 +1,21 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.vo.DateSearchRequest; import com.xzzn.ems.domain.vo.ElectricDataInfoVo; import com.xzzn.ems.domain.vo.SiteMonitorDataVo; import com.xzzn.ems.mapper.EmsPcsDataMapper; import com.xzzn.ems.service.IEmsStatsReportService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDate; +import java.util.Date; import java.util.List; /** @@ -23,6 +28,8 @@ import java.util.List; public class EmsStatsReportServiceImpl implements IEmsStatsReportService { + private static final Logger log = LoggerFactory.getLogger(EmsStatsReportServiceImpl.class); + @Autowired private EmsPcsDataMapper emsPcsDataMapper; @@ -30,6 +37,14 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { ElectricDataInfoVo electricDataInfoVo = new ElectricDataInfoVo(); + Date startDate = requestVo.getStartDate(); + Date endDate = requestVo.getEndDate(); + if (startDate == null && endDate == null) { + // 如果没有传时间,默认从今天往前7天 + LocalDate sevenDaysAgo = LocalDate.now().minusDays(6); + startDate = DateUtils.toDate(sevenDaysAgo); + requestVo.setStartDate(startDate); + } // 根据时间获取每天的充放电量 List dataList = emsPcsDataMapper.getPcsDataByDate(requestVo); if (!CollectionUtils.isEmpty(dataList)){ diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 20dcad0..919d039 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -379,8 +379,10 @@ from ( SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time FROM ems_pcs_data p where p.site_id = #{siteId} - + and p.data_update_time >= #{startDate} + + and p.data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) GROUP BY p.site_id,p.device_id,p.date_month,p.date_day -- 2.49.0 From b2c624f45262900e5bcb240d29957efc7695bac0 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Tue, 1 Jul 2025 21:28:25 +0800 Subject: [PATCH 037/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/common/utils/StringUtils.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java index 501f549..00676c1 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java @@ -723,32 +723,32 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils public static BigDecimal getBigDecimal(Object s){ - + BigDecimal result; try { - return new BigDecimal(s.toString()); + result = new BigDecimal(s.toString()); } catch (NumberFormatException e) { return BigDecimal.ZERO; } - + return result; } public static Long getLong(Object s){ - + Long result; try { - return Long.parseLong(s.toString()); + result = Long.parseLong(s.toString()); } catch (NumberFormatException e) { return Long.parseLong("0"); } - + return result; } public static String getString(Object s){ - + String result; try { - return String.valueOf(s); + result = String.valueOf(s); } catch (NumberFormatException e) { return "0"; } - + return result; } } \ No newline at end of file -- 2.49.0 From 4d5f2adef4310ced3c143accb68d14054b04eae2 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Tue, 1 Jul 2025 21:39:32 +0800 Subject: [PATCH 038/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/xzzn/common/utils/StringUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java index 00676c1..555f8a4 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java @@ -726,7 +726,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils BigDecimal result; try { result = new BigDecimal(s.toString()); - } catch (NumberFormatException e) { + } catch (Exception e) { return BigDecimal.ZERO; } return result; @@ -736,7 +736,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils Long result; try { result = Long.parseLong(s.toString()); - } catch (NumberFormatException e) { + } catch (Exception e) { return Long.parseLong("0"); } return result; @@ -746,7 +746,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils String result; try { result = String.valueOf(s); - } catch (NumberFormatException e) { + } catch (Exception e) { return "0"; } return result; -- 2.49.0 From 9efb87ed24a68509b861b5122c430dea2a67adb2 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Tue, 1 Jul 2025 21:50:54 +0800 Subject: [PATCH 039/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FXXDataProcessServiceImpl.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 3968249..417f965 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -41,6 +41,8 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { @Autowired private RedisCache redisCache; + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper;; @Override public void handleFxData(String message) { @@ -138,7 +140,13 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); - + EmsDevicesSetting joken = new EmsDevicesSetting(); + joken.setDeviceId(deviceId); + List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); + String stackDeviceId = ""; + if (up != null && up.size() >0) { + stackDeviceId = up.get(0).getParentId(); + } //BMS 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); // 设置所有 BigDecimal 类型字段为 ZERO @@ -195,14 +203,20 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { data.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); data.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); data.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); - data.setStackDeviceId("1"); + data.setStackDeviceId(stackDeviceId); emsBatteryClusterMapper.insertEmsBatteryCluster(data); } private void batteryDataProcess(String deviceId, String dataJson) { - + EmsDevicesSetting joken = new EmsDevicesSetting(); + joken.setDeviceId(deviceId); + List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); + String stackDeviceId = ""; + if (up != null && up.size() >0) { + stackDeviceId = up.get(0).getParentId(); + } //单体电池 Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() {})); List list = new ArrayList<>(); @@ -220,14 +234,14 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); batteryData.setBatteryCluster(deviceId); - batteryData.setBatteryPack(deviceId); + batteryData.setBatteryPack(stackDeviceId); // 时间戳 batteryData.setDataTimestamp(new Date()); // ID字段 batteryData.setSiteId(("021_FXX_01")); - batteryData.setClusterDeviceId(("021")); + batteryData.setClusterDeviceId(deviceId); list.add(batteryData); } -- 2.49.0 From 2c5d4ddd1bcd6059ccb898c7142e1d07b8c68c2e Mon Sep 17 00:00:00 2001 From: dashixiong Date: Tue, 1 Jul 2025 21:58:26 +0800 Subject: [PATCH 040/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/service/impl/FXXDataProcessServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 417f965..6f230b3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -146,6 +146,9 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { String stackDeviceId = ""; if (up != null && up.size() >0) { stackDeviceId = up.get(0).getParentId(); + if (stackDeviceId != null || stackDeviceId.isEmpty()) { + stackDeviceId = "1"; + } } //BMS 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); @@ -216,6 +219,9 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { String stackDeviceId = ""; if (up != null && up.size() >0) { stackDeviceId = up.get(0).getParentId(); + if (stackDeviceId != null || stackDeviceId.isEmpty()) { + stackDeviceId = "1"; + } } //单体电池 Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() {})); -- 2.49.0 From a7e33afb19c357db25423fa7acc91045ab4144bb Mon Sep 17 00:00:00 2001 From: dashixiong Date: Tue, 1 Jul 2025 22:03:43 +0800 Subject: [PATCH 041/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/service/impl/FXXDataProcessServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 6f230b3..32fef12 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -206,7 +206,11 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { data.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); data.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); data.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); - data.setStackDeviceId(stackDeviceId); + if (StringUtils.isNotBlank(stackDeviceId)) { + data.setStackDeviceId(stackDeviceId); + } else { + data.setStackDeviceId("1"); + } emsBatteryClusterMapper.insertEmsBatteryCluster(data); -- 2.49.0 From a3f77113c91067790d699a6f3970679f7059c109 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 1 Jul 2025 22:09:16 +0800 Subject: [PATCH 042/336] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=80=BC=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/vo/PcsBranchInfo.java | 6 +++--- .../ems/domain/vo/SingleSiteBaseInfo.java | 20 +++++++++---------- .../ems/service/impl/HomePageServiceImpl.java | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java index 4b0d923..e75cc2c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsBranchInfo.java @@ -31,7 +31,7 @@ public class PcsBranchInfo private String deviceId; /** 支路id */ - private Long branchId; + private String branchId; public String getDischargeStatus() { return dischargeStatus; @@ -81,11 +81,11 @@ public class PcsBranchInfo this.deviceId = deviceId; } - public Long getBranchId() { + public String getBranchId() { return branchId; } - public void setBranchId(Long branchId) { + public void setBranchId(String branchId) { this.branchId = branchId; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SingleSiteBaseInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SingleSiteBaseInfo.java index 2ed5d77..4bd14b9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SingleSiteBaseInfo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SingleSiteBaseInfo.java @@ -51,12 +51,12 @@ public class SingleSiteBaseInfo { /** * 装机功率(MW) */ - private BigDecimal installedPower; + private BigDecimal installPower; /** * 装机容量(MW) */ - private BigDecimal installedCap; + private BigDecimal installCapacity; /** * 七天放电统计 @@ -79,20 +79,20 @@ public class SingleSiteBaseInfo { this.dayChargedCap = dayChargedCap; } - public BigDecimal getInstalledCap() { - return installedCap; + public BigDecimal getInstallPower() { + return installPower; } - public void setInstalledCap(BigDecimal installedCap) { - this.installedCap = installedCap; + public void setInstallPower(BigDecimal installPower) { + this.installPower = installPower; } - public BigDecimal getInstalledPower() { - return installedPower; + public BigDecimal getInstallCapacity() { + return installCapacity; } - public void setInstalledPower(BigDecimal installedPower) { - this.installedPower = installedPower; + public void setInstallCapacity(BigDecimal installCapacity) { + this.installCapacity = installCapacity; } public String getRunningTime() { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index cc11227..744645a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -57,8 +57,8 @@ public class HomePageServiceImpl implements IHomePageService if (emsSite != null) { // 装机功率+装机容量 singleSiteBaseInfo.setSiteName(emsSite.getSiteName()); - singleSiteBaseInfo.setInstalledCap(emsSite.getInstallCapacity()); - singleSiteBaseInfo.setInstalledPower(emsSite.getInstallPower()); + singleSiteBaseInfo.setInstallCapacity(emsSite.getInstallCapacity()); + singleSiteBaseInfo.setInstallPower(emsSite.getInstallPower()); String[] siteLocation = new String[2]; siteLocation[0] = emsSite.getLongitude() == null ? "" : emsSite.getLongitude().toString(); siteLocation[1] = emsSite.getLatitude() == null ? "" : emsSite.getLatitude().toString(); -- 2.49.0 From f73ba23b52d178a5c1b09ce8145ae6030b2c41ff Mon Sep 17 00:00:00 2001 From: dashixiong Date: Wed, 2 Jul 2025 11:40:23 +0800 Subject: [PATCH 043/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/EmsBatteryStack.java | 1050 ++++++++--------- .../impl/FXXDataProcessServiceImpl.java | 96 +- .../mapper/ems/EmsBatteryStackMapper.xml | 442 +++---- 3 files changed, 738 insertions(+), 850 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java index 82409b9..989c612 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * 电池堆数据对象 ems_battery_stack * * @author xzzn - * @date 2025-06-29 + * @date 2025-07-02 */ public class EmsBatteryStack extends BaseEntity { @@ -20,193 +20,173 @@ public class EmsBatteryStack extends BaseEntity /** */ private Long id; - /** 工作状态 */ - @Excel(name = "工作状态") + /** 工作状态:0-正常 1-异常 2-停止 */ + @Excel(name = "工作状态:0-正常 1-异常 2-停止") private String workStatus; - /** 与PCS通信状态 */ - @Excel(name = "与PCS通信状态") + /** 与PCS通信状态:0-正常 1-通信中断 2-异常 */ + @Excel(name = "与PCS通信状态:0-正常 1-通信中断 2-异常") private String pcsCommunicationStatus; - /** 与EMS通信状态 */ - @Excel(name = "与EMS通信状态") + /** 与EMS通信状态:0-正常 1-通信中断 2-异常 */ + @Excel(name = "与EMS通信状态:0-正常 1-通信中断 2-异常") private String emsCommunicationStatus; - /** 电池堆总电压 (V) */ - @Excel(name = "电池堆总电压 (V)") - private BigDecimal totalVoltage; + /** 电操状态 */ + @Excel(name = "电操状态") + private String operationStatus; - /** 可充电量 (kWh) */ - @Excel(name = "可充电量 (kWh)") - private BigDecimal chargeableCapacity; + /** 电池堆电压/V */ + @Excel(name = "电池堆电压/V") + private BigDecimal stackVoltage; - /** 累计充电量 (kWh) */ - @Excel(name = "累计充电量 (kWh)") - private BigDecimal totalChargedCapacity; + /** 电池堆电流/A */ + @Excel(name = "电池堆电流/A") + private BigDecimal stackCurrent; - /** 电池堆总电流 (A) */ - @Excel(name = "电池堆总电流 (A)") - private BigDecimal totalCurrent; + /** 电池堆SOC/% */ + @Excel(name = "电池堆SOC/%") + private BigDecimal stackSoc; - /** 可放电量 (kWh) */ - @Excel(name = "可放电量 (kWh)") - private BigDecimal dischargeableCapacity; + /** 电池堆SOH/% */ + @Excel(name = "电池堆SOH/%") + private BigDecimal stackSoh; - /** 累计放电量 (kWh) */ - @Excel(name = "累计放电量 (kWh)") - private BigDecimal totalDischargedCapacity; - - /** SOH (%) */ - @Excel(name = "SOH (%)") - private BigDecimal soh; - - /** 平均温度 (℃) */ - @Excel(name = "平均温度 (℃)") - private BigDecimal averageTemperature; - - /** 绝缘电阻 (Ω) */ - @Excel(name = "绝缘电阻 (Ω)") - private BigDecimal insulationResistance; - - /** 当前SOC (%) */ - @Excel(name = "当前SOC (%)") - private BigDecimal currentSoc; - - /** 站点id */ - @Excel(name = "站点id") - private String siteId; - - /** 设备唯一标识符 */ - @Excel(name = "设备唯一标识符") - private String deviceId; - - /** 允许充电最大功率 */ - @Excel(name = "允许充电最大功率") - private BigDecimal maxAllowedChargePower; - - /** 允许放电最大功率 */ - @Excel(name = "允许放电最大功率") - private BigDecimal maxAllowedDischargePower; - - /** 允许充电最大电压 */ - @Excel(name = "允许充电最大电压") - private BigDecimal maxAllowedChargeVoltage; - - /** 允许放电最大电压 */ - @Excel(name = "允许放电最大电压") - private BigDecimal maxAllowedDischargeVoltage; - - /** 允许充电最大电流 */ - @Excel(name = "允许充电最大电流") - private BigDecimal maxAllowedChargeCurrent; - - /** 允许放电最大电流 */ - @Excel(name = "允许放电最大电流") - private BigDecimal maxAllowedDischargeCurrent; - - /** 组电压 */ - @Excel(name = "组电压") - private BigDecimal batteryPackVoltage; - - /** 组电流 */ - @Excel(name = "组电流") - private BigDecimal batteryPackCurrent; - - /** 模块温度 */ - @Excel(name = "模块温度") - private BigDecimal batteryPackTemp; - - /** 组SOC */ - @Excel(name = "组SOC") - private BigDecimal batteryPackSoc; - - /** 组SOH */ - @Excel(name = "组SOH") - private BigDecimal batteryPackSoh; - - /** 组绝缘电阻 */ - @Excel(name = "组绝缘电阻") - private BigDecimal batteryPackInsulationResistance; - - /** 平均单体电压 */ - @Excel(name = "平均单体电压") - private BigDecimal avgCellVoltage; - - /** 平均单体温度 */ - @Excel(name = "平均单体温度") - private BigDecimal avgCellTemp; - - /** 最高单体电压 */ - @Excel(name = "最高单体电压") + /** 最高电池电压/V */ + @Excel(name = "最高电池电压/V") private BigDecimal maxCellVoltage; - /** 最高单体电压对应点号 */ - @Excel(name = "最高单体电压对应点号") - private Long maxCellVoltageId; + /** 最高电池电压组号 */ + @Excel(name = "最高电池电压组号") + private Long maxVoltageGroupId; - /** 最低单体电压 */ - @Excel(name = "最低单体电压") + /** 高电压电池所在组中的点号 */ + @Excel(name = "高电压电池所在组中的点号") + private Long maxVoltageCellId; + + /** 最低电池电压/V */ + @Excel(name = "最低电池电压/V") private BigDecimal minCellVoltage; - /** 最低单体电压对应点号 */ - @Excel(name = "最低单体电压对应点号") - private Long minCellVoltageId; + /** 最低电池电压组号 */ + @Excel(name = "最低电池电压组号") + private Long minVoltageGroupId; - /** 最高单体温度 */ - @Excel(name = "最高单体温度") + /** 最低电压电池所在组中的点号 */ + @Excel(name = "最低电压电池所在组中的点号") + private Long minVoltageCellId; + + /** 最高电池温度/℃ */ + @Excel(name = "最高电池温度/℃") private BigDecimal maxCellTemp; - /** 最高单体温度对应点号 */ - @Excel(name = "最高单体温度对应点号") - private Long maxCellTempId; + /** 最高温度电池组号 */ + @Excel(name = "最高温度电池组号") + private Long maxTempGroupId; - /** 最低单体温度 */ - @Excel(name = "最低单体温度") + /** 最高温度电池所在组中的点号 */ + @Excel(name = "最高温度电池所在组中的点号") + private Long maxTempCellId; + + /** 最低电池温度/℃ */ + @Excel(name = "最低电池温度/℃") private BigDecimal minCellTemp; - /** 最低单体温度对应点号 */ - @Excel(name = "最低单体温度对应点号") - private Long minCellTempId; + /** 最低电池温度组号 */ + @Excel(name = "最低电池温度组号") + private Long minTempGroupId; - /** 最高单体SOC */ - @Excel(name = "最高单体SOC") - private BigDecimal maxCellSoc; + /** 最低温度电池所在组中的点号 */ + @Excel(name = "最低温度电池所在组中的点号") + private Long minTempCellId; - /** 最高单体SOC对应点号 */ - @Excel(name = "最高单体SOC对应点号") - private Long maxCellSocId; + /** 堆累计充电电量/kWh */ + @Excel(name = "堆累计充电电量/kWh") + private BigDecimal totalChargeCapacity; - /** 最低单体SOC */ - @Excel(name = "最低单体SOC") - private BigDecimal minCellSoc; + /** 堆累计放电电量/kWh */ + @Excel(name = "堆累计放电电量/kWh") + private BigDecimal totalDischargeCapacity; - /** 最低单体SOC对应点号 */ - @Excel(name = "最低单体SOC对应点号") - private Long minCellSocId; + /** 堆单次累计充电电量/kWh */ + @Excel(name = "堆单次累计充电电量/kWh") + private BigDecimal sessionChargeCapacity; - /** 最高单体SOH */ - @Excel(name = "最高单体SOH") - private BigDecimal maxCellSoh; + /** 堆单次累计放电电量/kWh */ + @Excel(name = "堆单次累计放电电量/kWh") + private BigDecimal sessionDischargeCapacity; - /** 最高单体SOH对应点号 */ - @Excel(name = "最高单体SOH对应点号") - private Long maxCellSohId; + /** 堆可充电量/kWh */ + @Excel(name = "堆可充电量/kWh") + private BigDecimal availableChargeCapacity; - /** 最低单体SOH */ - @Excel(name = "最低单体SOH") - private BigDecimal minCellSoh; + /** 堆可放电量/kWh */ + @Excel(name = "堆可放电量/kWh") + private BigDecimal availableDischargeCapacity; - /** 最低单体SOH对应点号 */ - @Excel(name = "最低单体SOH对应点号") - private Long minCellSohId; + /** 可用放电时间/min */ + @Excel(name = "可用放电时间/min") + private Long remainingDischargeTime; - /** 单次累计充电电量 */ - @Excel(name = "单次累计充电电量") - private BigDecimal totalChargeEnergy; + /** 可用充电时间/min */ + @Excel(name = "可用充电时间/min") + private Long remainingChargeTime; - /** 单次累计放电电量 */ - @Excel(name = "单次累计放电电量") - private BigDecimal totalDischargeEnergy; + /** 允许最大放电功率/kW */ + @Excel(name = "允许最大放电功率/kW") + private BigDecimal maxDischargePower; + + /** 允许最大充电功率/kW */ + @Excel(name = "允许最大充电功率/kW") + private BigDecimal maxChargePower; + + /** 允许最大放电电流/A */ + @Excel(name = "允许最大放电电流/A") + private BigDecimal maxDischargeCurrent; + + /** 允许最大充电电流/A */ + @Excel(name = "允许最大充电电流/A") + private BigDecimal maxChargeCurrent; + + /** 当天放电次数 */ + @Excel(name = "当天放电次数") + private Long dailyDischargeCycles; + + /** 当天充电次数 */ + @Excel(name = "当天充电次数") + private Long dailyChargeCycles; + + /** 当天放电电量/kWh */ + @Excel(name = "当天放电电量/kWh") + private BigDecimal dailyDischargeCapacity; + + /** 当天充电电量/kWh */ + @Excel(name = "当天充电电量/kWh") + private BigDecimal dailyChargeCapacity; + + /** 运行温度/℃ */ + @Excel(name = "运行温度/℃") + private BigDecimal operatingTemp; + + /** BMS堆当前状态 */ + @Excel(name = "BMS堆当前状态") + private String bmsStatus; + + /** BMS充放电状态 */ + @Excel(name = "BMS充放电状态") + private String bmsChargeStatus; + + /** 电池堆绝缘电阻/kΩ */ + @Excel(name = "电池堆绝缘电阻/kΩ") + private BigDecimal stackInsulationResistance; + + /** 站点 id */ + @Excel(name = "站点 id") + private String siteId; + + /** 设备id */ + @Excel(name = "设备id") + private String deviceId; public void setId(Long id) { @@ -248,104 +228,374 @@ public class EmsBatteryStack extends BaseEntity return emsCommunicationStatus; } - public void setTotalVoltage(BigDecimal totalVoltage) + public void setOperationStatus(String operationStatus) { - this.totalVoltage = totalVoltage; + this.operationStatus = operationStatus; } - public BigDecimal getTotalVoltage() + public String getOperationStatus() { - return totalVoltage; + return operationStatus; } - public void setChargeableCapacity(BigDecimal chargeableCapacity) + public void setStackVoltage(BigDecimal stackVoltage) { - this.chargeableCapacity = chargeableCapacity; + this.stackVoltage = stackVoltage; } - public BigDecimal getChargeableCapacity() + public BigDecimal getStackVoltage() { - return chargeableCapacity; + return stackVoltage; } - public void setTotalChargedCapacity(BigDecimal totalChargedCapacity) + public void setStackCurrent(BigDecimal stackCurrent) { - this.totalChargedCapacity = totalChargedCapacity; + this.stackCurrent = stackCurrent; } - public BigDecimal getTotalChargedCapacity() + public BigDecimal getStackCurrent() { - return totalChargedCapacity; + return stackCurrent; } - public void setTotalCurrent(BigDecimal totalCurrent) + public void setStackSoc(BigDecimal stackSoc) { - this.totalCurrent = totalCurrent; + this.stackSoc = stackSoc; } - public BigDecimal getTotalCurrent() + public BigDecimal getStackSoc() { - return totalCurrent; + return stackSoc; } - public void setDischargeableCapacity(BigDecimal dischargeableCapacity) + public void setStackSoh(BigDecimal stackSoh) { - this.dischargeableCapacity = dischargeableCapacity; + this.stackSoh = stackSoh; } - public BigDecimal getDischargeableCapacity() + public BigDecimal getStackSoh() { - return dischargeableCapacity; + return stackSoh; } - public void setTotalDischargedCapacity(BigDecimal totalDischargedCapacity) + public void setMaxCellVoltage(BigDecimal maxCellVoltage) { - this.totalDischargedCapacity = totalDischargedCapacity; + this.maxCellVoltage = maxCellVoltage; } - public BigDecimal getTotalDischargedCapacity() + public BigDecimal getMaxCellVoltage() { - return totalDischargedCapacity; + return maxCellVoltage; } - public void setSoh(BigDecimal soh) + public void setMaxVoltageGroupId(Long maxVoltageGroupId) { - this.soh = soh; + this.maxVoltageGroupId = maxVoltageGroupId; } - public BigDecimal getSoh() + public Long getMaxVoltageGroupId() { - return soh; + return maxVoltageGroupId; } - public void setAverageTemperature(BigDecimal averageTemperature) + public void setMaxVoltageCellId(Long maxVoltageCellId) { - this.averageTemperature = averageTemperature; + this.maxVoltageCellId = maxVoltageCellId; } - public BigDecimal getAverageTemperature() + public Long getMaxVoltageCellId() { - return averageTemperature; + return maxVoltageCellId; } - public void setInsulationResistance(BigDecimal insulationResistance) + public void setMinCellVoltage(BigDecimal minCellVoltage) { - this.insulationResistance = insulationResistance; + this.minCellVoltage = minCellVoltage; } - public BigDecimal getInsulationResistance() + public BigDecimal getMinCellVoltage() { - return insulationResistance; + return minCellVoltage; } - public void setCurrentSoc(BigDecimal currentSoc) + public void setMinVoltageGroupId(Long minVoltageGroupId) { - this.currentSoc = currentSoc; + this.minVoltageGroupId = minVoltageGroupId; } - public BigDecimal getCurrentSoc() + public Long getMinVoltageGroupId() { - return currentSoc; + return minVoltageGroupId; + } + + public void setMinVoltageCellId(Long minVoltageCellId) + { + this.minVoltageCellId = minVoltageCellId; + } + + public Long getMinVoltageCellId() + { + return minVoltageCellId; + } + + public void setMaxCellTemp(BigDecimal maxCellTemp) + { + this.maxCellTemp = maxCellTemp; + } + + public BigDecimal getMaxCellTemp() + { + return maxCellTemp; + } + + public void setMaxTempGroupId(Long maxTempGroupId) + { + this.maxTempGroupId = maxTempGroupId; + } + + public Long getMaxTempGroupId() + { + return maxTempGroupId; + } + + public void setMaxTempCellId(Long maxTempCellId) + { + this.maxTempCellId = maxTempCellId; + } + + public Long getMaxTempCellId() + { + return maxTempCellId; + } + + public void setMinCellTemp(BigDecimal minCellTemp) + { + this.minCellTemp = minCellTemp; + } + + public BigDecimal getMinCellTemp() + { + return minCellTemp; + } + + public void setMinTempGroupId(Long minTempGroupId) + { + this.minTempGroupId = minTempGroupId; + } + + public Long getMinTempGroupId() + { + return minTempGroupId; + } + + public void setMinTempCellId(Long minTempCellId) + { + this.minTempCellId = minTempCellId; + } + + public Long getMinTempCellId() + { + return minTempCellId; + } + + public void setTotalChargeCapacity(BigDecimal totalChargeCapacity) + { + this.totalChargeCapacity = totalChargeCapacity; + } + + public BigDecimal getTotalChargeCapacity() + { + return totalChargeCapacity; + } + + public void setTotalDischargeCapacity(BigDecimal totalDischargeCapacity) + { + this.totalDischargeCapacity = totalDischargeCapacity; + } + + public BigDecimal getTotalDischargeCapacity() + { + return totalDischargeCapacity; + } + + public void setSessionChargeCapacity(BigDecimal sessionChargeCapacity) + { + this.sessionChargeCapacity = sessionChargeCapacity; + } + + public BigDecimal getSessionChargeCapacity() + { + return sessionChargeCapacity; + } + + public void setSessionDischargeCapacity(BigDecimal sessionDischargeCapacity) + { + this.sessionDischargeCapacity = sessionDischargeCapacity; + } + + public BigDecimal getSessionDischargeCapacity() + { + return sessionDischargeCapacity; + } + + public void setAvailableChargeCapacity(BigDecimal availableChargeCapacity) + { + this.availableChargeCapacity = availableChargeCapacity; + } + + public BigDecimal getAvailableChargeCapacity() + { + return availableChargeCapacity; + } + + public void setAvailableDischargeCapacity(BigDecimal availableDischargeCapacity) + { + this.availableDischargeCapacity = availableDischargeCapacity; + } + + public BigDecimal getAvailableDischargeCapacity() + { + return availableDischargeCapacity; + } + + public void setRemainingDischargeTime(Long remainingDischargeTime) + { + this.remainingDischargeTime = remainingDischargeTime; + } + + public Long getRemainingDischargeTime() + { + return remainingDischargeTime; + } + + public void setRemainingChargeTime(Long remainingChargeTime) + { + this.remainingChargeTime = remainingChargeTime; + } + + public Long getRemainingChargeTime() + { + return remainingChargeTime; + } + + public void setMaxDischargePower(BigDecimal maxDischargePower) + { + this.maxDischargePower = maxDischargePower; + } + + public BigDecimal getMaxDischargePower() + { + return maxDischargePower; + } + + public void setMaxChargePower(BigDecimal maxChargePower) + { + this.maxChargePower = maxChargePower; + } + + public BigDecimal getMaxChargePower() + { + return maxChargePower; + } + + public void setMaxDischargeCurrent(BigDecimal maxDischargeCurrent) + { + this.maxDischargeCurrent = maxDischargeCurrent; + } + + public BigDecimal getMaxDischargeCurrent() + { + return maxDischargeCurrent; + } + + public void setMaxChargeCurrent(BigDecimal maxChargeCurrent) + { + this.maxChargeCurrent = maxChargeCurrent; + } + + public BigDecimal getMaxChargeCurrent() + { + return maxChargeCurrent; + } + + public void setDailyDischargeCycles(Long dailyDischargeCycles) + { + this.dailyDischargeCycles = dailyDischargeCycles; + } + + public Long getDailyDischargeCycles() + { + return dailyDischargeCycles; + } + + public void setDailyChargeCycles(Long dailyChargeCycles) + { + this.dailyChargeCycles = dailyChargeCycles; + } + + public Long getDailyChargeCycles() + { + return dailyChargeCycles; + } + + public void setDailyDischargeCapacity(BigDecimal dailyDischargeCapacity) + { + this.dailyDischargeCapacity = dailyDischargeCapacity; + } + + public BigDecimal getDailyDischargeCapacity() + { + return dailyDischargeCapacity; + } + + public void setDailyChargeCapacity(BigDecimal dailyChargeCapacity) + { + this.dailyChargeCapacity = dailyChargeCapacity; + } + + public BigDecimal getDailyChargeCapacity() + { + return dailyChargeCapacity; + } + + public void setOperatingTemp(BigDecimal operatingTemp) + { + this.operatingTemp = operatingTemp; + } + + public BigDecimal getOperatingTemp() + { + return operatingTemp; + } + + public void setBmsStatus(String bmsStatus) + { + this.bmsStatus = bmsStatus; + } + + public String getBmsStatus() + { + return bmsStatus; + } + + public void setBmsChargeStatus(String bmsChargeStatus) + { + this.bmsChargeStatus = bmsChargeStatus; + } + + public String getBmsChargeStatus() + { + return bmsChargeStatus; + } + + public void setStackInsulationResistance(BigDecimal stackInsulationResistance) + { + this.stackInsulationResistance = stackInsulationResistance; + } + + public BigDecimal getStackInsulationResistance() + { + return stackInsulationResistance; } public void setSiteId(String siteId) @@ -368,326 +618,6 @@ public class EmsBatteryStack extends BaseEntity return deviceId; } - public void setMaxAllowedChargePower(BigDecimal maxAllowedChargePower) - { - this.maxAllowedChargePower = maxAllowedChargePower; - } - - public BigDecimal getMaxAllowedChargePower() - { - return maxAllowedChargePower; - } - - public void setMaxAllowedDischargePower(BigDecimal maxAllowedDischargePower) - { - this.maxAllowedDischargePower = maxAllowedDischargePower; - } - - public BigDecimal getMaxAllowedDischargePower() - { - return maxAllowedDischargePower; - } - - public void setMaxAllowedChargeVoltage(BigDecimal maxAllowedChargeVoltage) - { - this.maxAllowedChargeVoltage = maxAllowedChargeVoltage; - } - - public BigDecimal getMaxAllowedChargeVoltage() - { - return maxAllowedChargeVoltage; - } - - public void setMaxAllowedDischargeVoltage(BigDecimal maxAllowedDischargeVoltage) - { - this.maxAllowedDischargeVoltage = maxAllowedDischargeVoltage; - } - - public BigDecimal getMaxAllowedDischargeVoltage() - { - return maxAllowedDischargeVoltage; - } - - public void setMaxAllowedChargeCurrent(BigDecimal maxAllowedChargeCurrent) - { - this.maxAllowedChargeCurrent = maxAllowedChargeCurrent; - } - - public BigDecimal getMaxAllowedChargeCurrent() - { - return maxAllowedChargeCurrent; - } - - public void setMaxAllowedDischargeCurrent(BigDecimal maxAllowedDischargeCurrent) - { - this.maxAllowedDischargeCurrent = maxAllowedDischargeCurrent; - } - - public BigDecimal getMaxAllowedDischargeCurrent() - { - return maxAllowedDischargeCurrent; - } - - public void setBatteryPackVoltage(BigDecimal batteryPackVoltage) - { - this.batteryPackVoltage = batteryPackVoltage; - } - - public BigDecimal getBatteryPackVoltage() - { - return batteryPackVoltage; - } - - public void setBatteryPackCurrent(BigDecimal batteryPackCurrent) - { - this.batteryPackCurrent = batteryPackCurrent; - } - - public BigDecimal getBatteryPackCurrent() - { - return batteryPackCurrent; - } - - public void setBatteryPackTemp(BigDecimal batteryPackTemp) - { - this.batteryPackTemp = batteryPackTemp; - } - - public BigDecimal getBatteryPackTemp() - { - return batteryPackTemp; - } - - public void setBatteryPackSoc(BigDecimal batteryPackSoc) - { - this.batteryPackSoc = batteryPackSoc; - } - - public BigDecimal getBatteryPackSoc() - { - return batteryPackSoc; - } - - public void setBatteryPackSoh(BigDecimal batteryPackSoh) - { - this.batteryPackSoh = batteryPackSoh; - } - - public BigDecimal getBatteryPackSoh() - { - return batteryPackSoh; - } - - public void setBatteryPackInsulationResistance(BigDecimal batteryPackInsulationResistance) - { - this.batteryPackInsulationResistance = batteryPackInsulationResistance; - } - - public BigDecimal getBatteryPackInsulationResistance() - { - return batteryPackInsulationResistance; - } - - public void setAvgCellVoltage(BigDecimal avgCellVoltage) - { - this.avgCellVoltage = avgCellVoltage; - } - - public BigDecimal getAvgCellVoltage() - { - return avgCellVoltage; - } - - public void setAvgCellTemp(BigDecimal avgCellTemp) - { - this.avgCellTemp = avgCellTemp; - } - - public BigDecimal getAvgCellTemp() - { - return avgCellTemp; - } - - public void setMaxCellVoltage(BigDecimal maxCellVoltage) - { - this.maxCellVoltage = maxCellVoltage; - } - - public BigDecimal getMaxCellVoltage() - { - return maxCellVoltage; - } - - public void setMaxCellVoltageId(Long maxCellVoltageId) - { - this.maxCellVoltageId = maxCellVoltageId; - } - - public Long getMaxCellVoltageId() - { - return maxCellVoltageId; - } - - public void setMinCellVoltage(BigDecimal minCellVoltage) - { - this.minCellVoltage = minCellVoltage; - } - - public BigDecimal getMinCellVoltage() - { - return minCellVoltage; - } - - public void setMinCellVoltageId(Long minCellVoltageId) - { - this.minCellVoltageId = minCellVoltageId; - } - - public Long getMinCellVoltageId() - { - return minCellVoltageId; - } - - public void setMaxCellTemp(BigDecimal maxCellTemp) - { - this.maxCellTemp = maxCellTemp; - } - - public BigDecimal getMaxCellTemp() - { - return maxCellTemp; - } - - public void setMaxCellTempId(Long maxCellTempId) - { - this.maxCellTempId = maxCellTempId; - } - - public Long getMaxCellTempId() - { - return maxCellTempId; - } - - public void setMinCellTemp(BigDecimal minCellTemp) - { - this.minCellTemp = minCellTemp; - } - - public BigDecimal getMinCellTemp() - { - return minCellTemp; - } - - public void setMinCellTempId(Long minCellTempId) - { - this.minCellTempId = minCellTempId; - } - - public Long getMinCellTempId() - { - return minCellTempId; - } - - public void setMaxCellSoc(BigDecimal maxCellSoc) - { - this.maxCellSoc = maxCellSoc; - } - - public BigDecimal getMaxCellSoc() - { - return maxCellSoc; - } - - public void setMaxCellSocId(Long maxCellSocId) - { - this.maxCellSocId = maxCellSocId; - } - - public Long getMaxCellSocId() - { - return maxCellSocId; - } - - public void setMinCellSoc(BigDecimal minCellSoc) - { - this.minCellSoc = minCellSoc; - } - - public BigDecimal getMinCellSoc() - { - return minCellSoc; - } - - public void setMinCellSocId(Long minCellSocId) - { - this.minCellSocId = minCellSocId; - } - - public Long getMinCellSocId() - { - return minCellSocId; - } - - public void setMaxCellSoh(BigDecimal maxCellSoh) - { - this.maxCellSoh = maxCellSoh; - } - - public BigDecimal getMaxCellSoh() - { - return maxCellSoh; - } - - public void setMaxCellSohId(Long maxCellSohId) - { - this.maxCellSohId = maxCellSohId; - } - - public Long getMaxCellSohId() - { - return maxCellSohId; - } - - public void setMinCellSoh(BigDecimal minCellSoh) - { - this.minCellSoh = minCellSoh; - } - - public BigDecimal getMinCellSoh() - { - return minCellSoh; - } - - public void setMinCellSohId(Long minCellSohId) - { - this.minCellSohId = minCellSohId; - } - - public Long getMinCellSohId() - { - return minCellSohId; - } - - public void setTotalChargeEnergy(BigDecimal totalChargeEnergy) - { - this.totalChargeEnergy = totalChargeEnergy; - } - - public BigDecimal getTotalChargeEnergy() - { - return totalChargeEnergy; - } - - public void setTotalDischargeEnergy(BigDecimal totalDischargeEnergy) - { - this.totalDischargeEnergy = totalDischargeEnergy; - } - - public BigDecimal getTotalDischargeEnergy() - { - return totalDischargeEnergy; - } - @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -695,55 +625,49 @@ public class EmsBatteryStack extends BaseEntity .append("workStatus", getWorkStatus()) .append("pcsCommunicationStatus", getPcsCommunicationStatus()) .append("emsCommunicationStatus", getEmsCommunicationStatus()) - .append("totalVoltage", getTotalVoltage()) - .append("chargeableCapacity", getChargeableCapacity()) - .append("totalChargedCapacity", getTotalChargedCapacity()) - .append("totalCurrent", getTotalCurrent()) - .append("dischargeableCapacity", getDischargeableCapacity()) - .append("totalDischargedCapacity", getTotalDischargedCapacity()) - .append("soh", getSoh()) - .append("averageTemperature", getAverageTemperature()) - .append("insulationResistance", getInsulationResistance()) - .append("currentSoc", getCurrentSoc()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) + .append("operationStatus", getOperationStatus()) + .append("stackVoltage", getStackVoltage()) + .append("stackCurrent", getStackCurrent()) + .append("stackSoc", getStackSoc()) + .append("stackSoh", getStackSoh()) + .append("maxCellVoltage", getMaxCellVoltage()) + .append("maxVoltageGroupId", getMaxVoltageGroupId()) + .append("maxVoltageCellId", getMaxVoltageCellId()) + .append("minCellVoltage", getMinCellVoltage()) + .append("minVoltageGroupId", getMinVoltageGroupId()) + .append("minVoltageCellId", getMinVoltageCellId()) + .append("maxCellTemp", getMaxCellTemp()) + .append("maxTempGroupId", getMaxTempGroupId()) + .append("maxTempCellId", getMaxTempCellId()) + .append("minCellTemp", getMinCellTemp()) + .append("minTempGroupId", getMinTempGroupId()) + .append("minTempCellId", getMinTempCellId()) + .append("totalChargeCapacity", getTotalChargeCapacity()) + .append("totalDischargeCapacity", getTotalDischargeCapacity()) + .append("sessionChargeCapacity", getSessionChargeCapacity()) + .append("sessionDischargeCapacity", getSessionDischargeCapacity()) + .append("availableChargeCapacity", getAvailableChargeCapacity()) + .append("availableDischargeCapacity", getAvailableDischargeCapacity()) + .append("remainingDischargeTime", getRemainingDischargeTime()) + .append("remainingChargeTime", getRemainingChargeTime()) + .append("maxDischargePower", getMaxDischargePower()) + .append("maxChargePower", getMaxChargePower()) + .append("maxDischargeCurrent", getMaxDischargeCurrent()) + .append("maxChargeCurrent", getMaxChargeCurrent()) + .append("dailyDischargeCycles", getDailyDischargeCycles()) + .append("dailyChargeCycles", getDailyChargeCycles()) + .append("dailyDischargeCapacity", getDailyDischargeCapacity()) + .append("dailyChargeCapacity", getDailyChargeCapacity()) + .append("operatingTemp", getOperatingTemp()) + .append("bmsStatus", getBmsStatus()) + .append("bmsChargeStatus", getBmsChargeStatus()) + .append("stackInsulationResistance", getStackInsulationResistance()) .append("siteId", getSiteId()) .append("deviceId", getDeviceId()) - .append("maxAllowedChargePower", getMaxAllowedChargePower()) - .append("maxAllowedDischargePower", getMaxAllowedDischargePower()) - .append("maxAllowedChargeVoltage", getMaxAllowedChargeVoltage()) - .append("maxAllowedDischargeVoltage", getMaxAllowedDischargeVoltage()) - .append("maxAllowedChargeCurrent", getMaxAllowedChargeCurrent()) - .append("maxAllowedDischargeCurrent", getMaxAllowedDischargeCurrent()) - .append("batteryPackVoltage", getBatteryPackVoltage()) - .append("batteryPackCurrent", getBatteryPackCurrent()) - .append("batteryPackTemp", getBatteryPackTemp()) - .append("batteryPackSoc", getBatteryPackSoc()) - .append("batteryPackSoh", getBatteryPackSoh()) - .append("batteryPackInsulationResistance", getBatteryPackInsulationResistance()) - .append("avgCellVoltage", getAvgCellVoltage()) - .append("avgCellTemp", getAvgCellTemp()) - .append("maxCellVoltage", getMaxCellVoltage()) - .append("maxCellVoltageId", getMaxCellVoltageId()) - .append("minCellVoltage", getMinCellVoltage()) - .append("minCellVoltageId", getMinCellVoltageId()) - .append("maxCellTemp", getMaxCellTemp()) - .append("maxCellTempId", getMaxCellTempId()) - .append("minCellTemp", getMinCellTemp()) - .append("minCellTempId", getMinCellTempId()) - .append("maxCellSoc", getMaxCellSoc()) - .append("maxCellSocId", getMaxCellSocId()) - .append("minCellSoc", getMinCellSoc()) - .append("minCellSocId", getMinCellSocId()) - .append("maxCellSoh", getMaxCellSoh()) - .append("maxCellSohId", getMaxCellSohId()) - .append("minCellSoh", getMinCellSoh()) - .append("minCellSohId", getMinCellSohId()) - .append("totalChargeEnergy", getTotalChargeEnergy()) - .append("totalDischargeEnergy", getTotalDischargeEnergy()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 32fef12..d6f91f5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -77,58 +77,72 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { //BMS 电池簇 EmsBatteryStack dataStack = new EmsBatteryStack(); - // 设置所有 BigDecimal 类型字段为 ZERO - dataStack.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); - dataStack.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); - dataStack.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); - dataStack.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); - dataStack.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - dataStack.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); - dataStack.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - dataStack.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - dataStack.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); - dataStack.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); - dataStack.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); - dataStack.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); - dataStack.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); - dataStack.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); - dataStack.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); - dataStack.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); - dataStack.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); - dataStack.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - dataStack.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - dataStack.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - dataStack.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); - dataStack.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); - dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); - dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); - dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); - dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); - dataStack.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); - dataStack.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); - dataStack.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); - dataStack.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); - dataStack.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); - dataStack.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); // 其他非 BigDecimal 字段 dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + + // 电池堆状态数据设置 + dataStack.setOperationStatus(StringUtils.getString(obj.get("DCZT"))); + dataStack.setStackVoltage(StringUtils.getBigDecimal(obj.get("DCDDY"))); + dataStack.setStackCurrent(StringUtils.getBigDecimal(obj.get("DCDDL"))); + dataStack.setStackSoc(StringUtils.getBigDecimal(obj.get("DCDSOC"))); + dataStack.setStackSoh(StringUtils.getBigDecimal(obj.get("DCDSOH"))); + + // 电压极值信息 + dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDCDY"))); + dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("ZGDCDYZH"))); + dataStack.setMaxVoltageCellId(StringUtils.getLong(obj.get("ZGDCDYZHDH"))); + dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDCDY"))); + dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("ZDDCDYZH"))); + dataStack.setMinVoltageCellId(StringUtils.getLong(obj.get("ZDDCDYZHDH"))); + + // 温度极值信息 + dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDCWD"))); + dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("ZGDCWDZH"))); + dataStack.setMaxTempCellId(StringUtils.getLong(obj.get("ZGDCWDZHDH"))); + dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDCWD"))); + dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("ZDDCWDZH"))); + dataStack.setMinTempCellId(StringUtils.getLong(obj.get("ZDDCWDZHDH"))); + + // 电量统计信息 + dataStack.setTotalChargeCapacity(StringUtils.getBigDecimal(obj.get("DLJCDDL"))); + dataStack.setTotalDischargeCapacity(StringUtils.getBigDecimal(obj.get("DLCFDDL"))); + dataStack.setSessionChargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJCDDL"))); + dataStack.setSessionDischargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJFDDL"))); + dataStack.setAvailableChargeCapacity(StringUtils.getBigDecimal(obj.get("DKCDL"))); + dataStack.setAvailableDischargeCapacity(StringUtils.getBigDecimal(obj.get("DKFDL"))); + +// 时间信息 + dataStack.setRemainingDischargeTime(StringUtils.getLong(obj.get("KYFDSJ"))); + dataStack.setRemainingChargeTime(StringUtils.getLong(obj.get("KYCDSJ"))); + +// 功率/电流限制 + dataStack.setMaxDischargePower(StringUtils.getBigDecimal(obj.get("YXZDFDGL"))); + dataStack.setMaxChargePower(StringUtils.getBigDecimal(obj.get("YXZDCDGL"))); + dataStack.setMaxDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDFDDL"))); + dataStack.setMaxChargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDCDDL"))); + + // 当日统计 + dataStack.setDailyDischargeCycles(StringUtils.getLong(obj.get("DTFDCS"))); + dataStack.setDailyChargeCycles(StringUtils.getLong(obj.get("DTCDCS"))); + dataStack.setDailyDischargeCapacity(StringUtils.getBigDecimal(obj.get("DTFDDL"))); + dataStack.setDailyChargeCapacity(StringUtils.getBigDecimal(obj.get("DTCDDL"))); + + // 系统状态 + dataStack.setOperatingTemp(StringUtils.getBigDecimal(obj.get("YXWD"))); + dataStack.setBmsStatus(StringUtils.getString(obj.get("BMSDDQZT"))); + dataStack.setBmsChargeStatus(StringUtils.getString(obj.get("BMSCFDZT"))); + dataStack.setStackInsulationResistance(StringUtils.getBigDecimal(obj.get("DCDJYDZ"))); + + dataStack.setCreateBy("system"); dataStack.setCreateTime(DateUtils.getNowDate()); dataStack.setUpdateBy("system"); dataStack.setUpdateTime(DateUtils.getNowDate()); dataStack.setSiteId("021_FXX_01"); dataStack.setDeviceId(deviceId); - dataStack.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD"))); - dataStack.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD"))); - dataStack.setMaxCellTempId(StringUtils.getLong(obj.get("ZGDTWDDYD"))); - dataStack.setMinCellTempId(StringUtils.getLong(obj.get("ZDDTWDDYD"))); - dataStack.setMaxCellSocId(StringUtils.getLong(obj.get("ZGDTSOCDYD"))); - dataStack.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); - dataStack.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); - dataStack.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); emsBatteryStackMapper.insertEmsBatteryStack(dataStack); diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 3421457..c8f23c5 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -9,59 +9,53 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - select id, work_status, pcs_communication_status, ems_communication_status, total_voltage, chargeable_capacity, total_charged_capacity, total_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id, max_allowed_charge_power, max_allowed_discharge_power, max_allowed_charge_voltage, max_allowed_discharge_voltage, max_allowed_charge_current, max_allowed_discharge_current, battery_pack_voltage, battery_pack_current, battery_pack_temp, battery_pack_soc, battery_pack_soh, battery_pack_insulation_resistance, avg_cell_voltage, avg_cell_temp, max_cell_voltage, max_cell_voltage_id, min_cell_voltage, min_cell_voltage_id, max_cell_temp, max_cell_temp_id, min_cell_temp, min_cell_temp_id, max_cell_soc, max_cell_soc_id, min_cell_soc, min_cell_soc_id, max_cell_soh, max_cell_soh_id, min_cell_soh, min_cell_soh_id, total_charge_energy, total_discharge_energy from ems_battery_stack + select id, work_status, pcs_communication_status, ems_communication_status, operation_status, stack_voltage, stack_current, stack_soc, stack_soh, max_cell_voltage, max_voltage_group_id, max_voltage_cell_id, min_cell_voltage, min_voltage_group_id, min_voltage_cell_id, max_cell_temp, max_temp_group_id, max_temp_cell_id, min_cell_temp, min_temp_group_id, min_temp_cell_id, total_charge_capacity, total_discharge_capacity, session_charge_capacity, session_discharge_capacity, available_charge_capacity, available_discharge_capacity, remaining_discharge_time, remaining_charge_time, max_discharge_power, max_charge_power, max_discharge_current, max_charge_current, daily_discharge_cycles, daily_charge_cycles, daily_discharge_capacity, daily_charge_capacity, operating_temp, bms_status, bms_charge_status, stack_insulation_resistance, site_id, device_id, create_time, create_by, update_time, update_by from ems_battery_stack @@ -128,109 +117,97 @@ work_status, pcs_communication_status, ems_communication_status, - total_voltage, - chargeable_capacity, - total_charged_capacity, - total_current, - dischargeable_capacity, - total_discharged_capacity, - soh, - average_temperature, - insulation_resistance, - current_soc, - create_by, - create_time, - update_by, - update_time, - remark, - site_id, - device_id, - max_allowed_charge_power, - max_allowed_discharge_power, - max_allowed_charge_voltage, - max_allowed_discharge_voltage, - max_allowed_charge_current, - max_allowed_discharge_current, - battery_pack_voltage, - battery_pack_current, - battery_pack_temp, - battery_pack_soc, - battery_pack_soh, - battery_pack_insulation_resistance, - avg_cell_voltage, - avg_cell_temp, + operation_status, + stack_voltage, + stack_current, + stack_soc, + stack_soh, max_cell_voltage, - max_cell_voltage_id, + max_voltage_group_id, + max_voltage_cell_id, min_cell_voltage, - min_cell_voltage_id, + min_voltage_group_id, + min_voltage_cell_id, max_cell_temp, - max_cell_temp_id, + max_temp_group_id, + max_temp_cell_id, min_cell_temp, - min_cell_temp_id, - max_cell_soc, - max_cell_soc_id, - min_cell_soc, - min_cell_soc_id, - max_cell_soh, - max_cell_soh_id, - min_cell_soh, - min_cell_soh_id, - total_charge_energy, - total_discharge_energy, + min_temp_group_id, + min_temp_cell_id, + total_charge_capacity, + total_discharge_capacity, + session_charge_capacity, + session_discharge_capacity, + available_charge_capacity, + available_discharge_capacity, + remaining_discharge_time, + remaining_charge_time, + max_discharge_power, + max_charge_power, + max_discharge_current, + max_charge_current, + daily_discharge_cycles, + daily_charge_cycles, + daily_discharge_capacity, + daily_charge_capacity, + operating_temp, + bms_status, + bms_charge_status, + stack_insulation_resistance, + site_id, + device_id, + create_time, + create_by, + update_time, + update_by, #{workStatus}, #{pcsCommunicationStatus}, #{emsCommunicationStatus}, - #{totalVoltage}, - #{chargeableCapacity}, - #{totalChargedCapacity}, - #{totalCurrent}, - #{dischargeableCapacity}, - #{totalDischargedCapacity}, - #{soh}, - #{averageTemperature}, - #{insulationResistance}, - #{currentSoc}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - #{remark}, - #{siteId}, - #{deviceId}, - #{maxAllowedChargePower}, - #{maxAllowedDischargePower}, - #{maxAllowedChargeVoltage}, - #{maxAllowedDischargeVoltage}, - #{maxAllowedChargeCurrent}, - #{maxAllowedDischargeCurrent}, - #{batteryPackVoltage}, - #{batteryPackCurrent}, - #{batteryPackTemp}, - #{batteryPackSoc}, - #{batteryPackSoh}, - #{batteryPackInsulationResistance}, - #{avgCellVoltage}, - #{avgCellTemp}, + #{operationStatus}, + #{stackVoltage}, + #{stackCurrent}, + #{stackSoc}, + #{stackSoh}, #{maxCellVoltage}, - #{maxCellVoltageId}, + #{maxVoltageGroupId}, + #{maxVoltageCellId}, #{minCellVoltage}, - #{minCellVoltageId}, + #{minVoltageGroupId}, + #{minVoltageCellId}, #{maxCellTemp}, - #{maxCellTempId}, + #{maxTempGroupId}, + #{maxTempCellId}, #{minCellTemp}, - #{minCellTempId}, - #{maxCellSoc}, - #{maxCellSocId}, - #{minCellSoc}, - #{minCellSocId}, - #{maxCellSoh}, - #{maxCellSohId}, - #{minCellSoh}, - #{minCellSohId}, - #{totalChargeEnergy}, - #{totalDischargeEnergy}, + #{minTempGroupId}, + #{minTempCellId}, + #{totalChargeCapacity}, + #{totalDischargeCapacity}, + #{sessionChargeCapacity}, + #{sessionDischargeCapacity}, + #{availableChargeCapacity}, + #{availableDischargeCapacity}, + #{remainingDischargeTime}, + #{remainingChargeTime}, + #{maxDischargePower}, + #{maxChargePower}, + #{maxDischargeCurrent}, + #{maxChargeCurrent}, + #{dailyDischargeCycles}, + #{dailyChargeCycles}, + #{dailyDischargeCapacity}, + #{dailyChargeCapacity}, + #{operatingTemp}, + #{bmsStatus}, + #{bmsChargeStatus}, + #{stackInsulationResistance}, + #{siteId}, + #{deviceId}, + #{createTime}, + #{createBy}, + #{updateTime}, + #{updateBy}, @@ -240,55 +217,49 @@ work_status = #{workStatus}, pcs_communication_status = #{pcsCommunicationStatus}, ems_communication_status = #{emsCommunicationStatus}, - total_voltage = #{totalVoltage}, - chargeable_capacity = #{chargeableCapacity}, - total_charged_capacity = #{totalChargedCapacity}, - total_current = #{totalCurrent}, - dischargeable_capacity = #{dischargeableCapacity}, - total_discharged_capacity = #{totalDischargedCapacity}, - soh = #{soh}, - average_temperature = #{averageTemperature}, - insulation_resistance = #{insulationResistance}, - current_soc = #{currentSoc}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - remark = #{remark}, - site_id = #{siteId}, - device_id = #{deviceId}, - max_allowed_charge_power = #{maxAllowedChargePower}, - max_allowed_discharge_power = #{maxAllowedDischargePower}, - max_allowed_charge_voltage = #{maxAllowedChargeVoltage}, - max_allowed_discharge_voltage = #{maxAllowedDischargeVoltage}, - max_allowed_charge_current = #{maxAllowedChargeCurrent}, - max_allowed_discharge_current = #{maxAllowedDischargeCurrent}, - battery_pack_voltage = #{batteryPackVoltage}, - battery_pack_current = #{batteryPackCurrent}, - battery_pack_temp = #{batteryPackTemp}, - battery_pack_soc = #{batteryPackSoc}, - battery_pack_soh = #{batteryPackSoh}, - battery_pack_insulation_resistance = #{batteryPackInsulationResistance}, - avg_cell_voltage = #{avgCellVoltage}, - avg_cell_temp = #{avgCellTemp}, + operation_status = #{operationStatus}, + stack_voltage = #{stackVoltage}, + stack_current = #{stackCurrent}, + stack_soc = #{stackSoc}, + stack_soh = #{stackSoh}, max_cell_voltage = #{maxCellVoltage}, - max_cell_voltage_id = #{maxCellVoltageId}, + max_voltage_group_id = #{maxVoltageGroupId}, + max_voltage_cell_id = #{maxVoltageCellId}, min_cell_voltage = #{minCellVoltage}, - min_cell_voltage_id = #{minCellVoltageId}, + min_voltage_group_id = #{minVoltageGroupId}, + min_voltage_cell_id = #{minVoltageCellId}, max_cell_temp = #{maxCellTemp}, - max_cell_temp_id = #{maxCellTempId}, + max_temp_group_id = #{maxTempGroupId}, + max_temp_cell_id = #{maxTempCellId}, min_cell_temp = #{minCellTemp}, - min_cell_temp_id = #{minCellTempId}, - max_cell_soc = #{maxCellSoc}, - max_cell_soc_id = #{maxCellSocId}, - min_cell_soc = #{minCellSoc}, - min_cell_soc_id = #{minCellSocId}, - max_cell_soh = #{maxCellSoh}, - max_cell_soh_id = #{maxCellSohId}, - min_cell_soh = #{minCellSoh}, - min_cell_soh_id = #{minCellSohId}, - total_charge_energy = #{totalChargeEnergy}, - total_discharge_energy = #{totalDischargeEnergy}, + min_temp_group_id = #{minTempGroupId}, + min_temp_cell_id = #{minTempCellId}, + total_charge_capacity = #{totalChargeCapacity}, + total_discharge_capacity = #{totalDischargeCapacity}, + session_charge_capacity = #{sessionChargeCapacity}, + session_discharge_capacity = #{sessionDischargeCapacity}, + available_charge_capacity = #{availableChargeCapacity}, + available_discharge_capacity = #{availableDischargeCapacity}, + remaining_discharge_time = #{remainingDischargeTime}, + remaining_charge_time = #{remainingChargeTime}, + max_discharge_power = #{maxDischargePower}, + max_charge_power = #{maxChargePower}, + max_discharge_current = #{maxDischargeCurrent}, + max_charge_current = #{maxChargeCurrent}, + daily_discharge_cycles = #{dailyDischargeCycles}, + daily_charge_cycles = #{dailyChargeCycles}, + daily_discharge_capacity = #{dailyDischargeCapacity}, + daily_charge_capacity = #{dailyChargeCapacity}, + operating_temp = #{operatingTemp}, + bms_status = #{bmsStatus}, + bms_charge_status = #{bmsChargeStatus}, + stack_insulation_resistance = #{stackInsulationResistance}, + site_id = #{siteId}, + device_id = #{deviceId}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, where id = #{id} @@ -303,25 +274,4 @@ #{id} - - \ No newline at end of file -- 2.49.0 From 37fd07b0c844ca83abd3646d08ae5e8621f6e4f2 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Wed, 2 Jul 2025 12:10:46 +0800 Subject: [PATCH 044/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/service/impl/FXXDataProcessServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index d6f91f5..8afd260 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -146,7 +146,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { emsBatteryStackMapper.insertEmsBatteryStack(dataStack); - + redisCache.setCacheObject(deviceId + "_DATA", dataStack); } @@ -227,6 +227,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } emsBatteryClusterMapper.insertEmsBatteryCluster(data); + redisCache.setCacheObject(deviceId + "_DATA", data); } @@ -339,6 +340,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { pcsData.setDateDay(DateUtils.getNowDayLong()); emsPcsDataMapper.insertEmsPcsData(pcsData); + redisCache.setCacheObject(deviceId + "_DATA", pcsData); } @@ -383,6 +385,9 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } if (list.size() > 0 ) { emsPcsBranchDataMapper.insertPcsBranchDataList(list); + + redisCache.setCacheObject(deviceId + "_DATA", list); + } } -- 2.49.0 From 170bae19f8b803c4cb480cc97a9290cfd8b238b1 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Wed, 2 Jul 2025 12:26:09 +0800 Subject: [PATCH 045/336] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/service/impl/FXXDataProcessServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 8afd260..61ac5a1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -146,7 +146,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { emsBatteryStackMapper.insertEmsBatteryStack(dataStack); - redisCache.setCacheObject(deviceId + "_DATA", dataStack); + redisCache.setCacheObject("STACK_021_FXX_01_"+deviceId, dataStack); } @@ -227,7 +227,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } emsBatteryClusterMapper.insertEmsBatteryCluster(data); - redisCache.setCacheObject(deviceId + "_DATA", data); + redisCache.setCacheObject("CLUSTER_021_FXX_01_"+deviceId, data); } @@ -265,7 +265,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { batteryData.setDataTimestamp(new Date()); // ID字段 - batteryData.setSiteId(("021_FXX_01")); + batteryData.setSiteId("021_FXX_01"); batteryData.setClusterDeviceId(deviceId); list.add(batteryData); @@ -273,7 +273,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { if (list.size() > 0 ) { emsBatteryDataMapper.insertEmsBatteryDataList(list); - redisCache.setCacheList(deviceId + "_DATA_LIST", list); + redisCache.setCacheList("BATTERY_021_FXX_01_"+deviceId, list); } } @@ -340,7 +340,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { pcsData.setDateDay(DateUtils.getNowDayLong()); emsPcsDataMapper.insertEmsPcsData(pcsData); - redisCache.setCacheObject(deviceId + "_DATA", pcsData); + redisCache.setCacheObject("PCS_021_FXX_01_"+deviceId, pcsData); } @@ -386,7 +386,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { if (list.size() > 0 ) { emsPcsBranchDataMapper.insertPcsBranchDataList(list); - redisCache.setCacheObject(deviceId + "_DATA", list); + redisCache.setCacheObject("BRANCH_021_FXX_01_"+deviceId, list); } -- 2.49.0 From 8415e2749ecad4127c3ba3ec18c4d0d2942e2f9e Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 2 Jul 2025 16:08:50 +0800 Subject: [PATCH 046/336] =?UTF-8?q?=E4=BB=8Eredis=E5=8F=96=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/common/core/redis/RedisCache.java | 11 ++ .../com/xzzn/common/enums/DeviceCategory.java | 35 ++++ .../web/service/SysLoginService.java | 1 + .../xzzn/ems/domain/EmsDevicesSetting.java | 17 +- .../ems/domain/vo/BMSBatteryClusterVo.java | 165 ---------------- .../com/xzzn/ems/domain/vo/BMSOverViewVo.java | 116 +++++------ .../ems/domain/vo/BatteryDataStatsListVo.java | 14 +- .../ems/mapper/EmsBatteryClusterMapper.java | 8 - .../ems/mapper/EmsDevicesSettingMapper.java | 24 +-- .../ems/service/impl/EmsSiteServiceImpl.java | 11 +- .../impl/FXXDataProcessServiceImpl.java | 1 + .../service/impl/SingleSiteServiceImpl.java | 181 ++++++++++++------ .../mapper/ems/EmsBatteryClusterMapper.xml | 27 --- .../mapper/ems/EmsDevicesSettingMapper.xml | 24 ++- 14 files changed, 289 insertions(+), 346 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java diff --git a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java index 3a55f42..eb9dfdf 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java +++ b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java @@ -265,4 +265,15 @@ public class RedisCache { return redisTemplate.keys(pattern); } + + /** + * 删除list + * + * @param key Redis键 + * @return 对象列表 + */ + public boolean deleteList(final String key) + { + return redisTemplate.delete(key); + } } diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java new file mode 100644 index 0000000..aefa25a --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java @@ -0,0 +1,35 @@ +package com.xzzn.common.enums; + +/** + * device-设备类别 + * + * @author xzzn + */ +public enum DeviceCategory +{ + PCS("PCS", "PCS设备"), + BRANCH("BRANCH", "PCS分支设备"), + STACK("STACK", "电池堆"), + CLUSTER("CLUSTER", "电池簇"), + BATTERY("BATTERY", "单体电池"), + AMMETER("AMMETER", "电表"); + + private final String code; + private final String info; + + DeviceCategory(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java b/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java index e1917d8..39520b9 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java +++ b/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java @@ -111,6 +111,7 @@ public class SysLoginService public void validateCaptcha(String username, String code, String uuid) { boolean captchaEnabled = configService.selectCaptchaEnabled(); + captchaEnabled = false; if (captchaEnabled) { String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, ""); diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java index 6522bed..0f174ca 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * Modbus设备配置对象 ems_devices_setting * * @author xzzn - * @date 2025-07-01 + * @date 2025-07-02 */ public class EmsDevicesSetting extends BaseEntity { @@ -98,6 +98,10 @@ public class EmsDevicesSetting extends BaseEntity @Excel(name = "上级设备id") private String parentId; + /** 设备类别,例如“STACK/CLUSTER/PCS等” */ + @Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”") + private String deviceCategory; + public void setId(Long id) { this.id = id; @@ -298,6 +302,16 @@ public class EmsDevicesSetting extends BaseEntity return parentId; } + public void setDeviceCategory(String deviceCategory) + { + this.deviceCategory = deviceCategory; + } + + public String getDeviceCategory() + { + return deviceCategory; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -321,6 +335,7 @@ public class EmsDevicesSetting extends BaseEntity .append("communicationStatus", getCommunicationStatus()) .append("deviceId", getDeviceId()) .append("parentId", getParentId()) + .append("deviceCategory", getDeviceCategory()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java index 0b84a35..8de0dda 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java @@ -57,51 +57,6 @@ public class BMSBatteryClusterVo { /** 设备唯一标识符 */ private String deviceId; - /** 单体温度平均值 */ - private BigDecimal avgTemp; - - /** 单体温度最小值 */ - private BigDecimal minTemp; - - /** 单体温度最小值ID */ - private String minTempID; - - /** 单体温度最大值 */ - private BigDecimal maxTemp; - - /** 单体温度最大值ID */ - private String maxTempID; - - /** 单体电压平均值 */ - private BigDecimal avgVoltage; - - /** 单体电压最小值 */ - private BigDecimal minVoltage; - - /** 单体电压最小值ID */ - private String minVoltageID; - - /** 单体电压最大值 */ - private BigDecimal maxVoltage; - - /** 单体电压最大值ID */ - private String maxVoltageID; - - /** 单体Soc平均值 */ - private BigDecimal avgSoc; - - /** 单体Soc最小值 */ - private BigDecimal minSoc; - - /** 单体Soc最小值ID */ - private String minSocID; - - /** 单体Soc最大值 */ - private BigDecimal maxSoc; - - /** 单体Soc最大值ID */ - private String maxSocID; - private List batteryDataList; public String getDeviceName() { @@ -239,124 +194,4 @@ public class BMSBatteryClusterVo { public void setBatteryDataList(List batteryDataList) { this.batteryDataList = batteryDataList; } - - public String getMaxSocID() { - return maxSocID; - } - - public void setMaxSocID(String maxSocID) { - this.maxSocID = maxSocID; - } - - public BigDecimal getMaxSoc() { - return maxSoc; - } - - public void setMaxSoc(BigDecimal maxSoc) { - this.maxSoc = maxSoc; - } - - public String getMinSocID() { - return minSocID; - } - - public void setMinSocID(String minSocID) { - this.minSocID = minSocID; - } - - public BigDecimal getMinSoc() { - return minSoc; - } - - public void setMinSoc(BigDecimal minSoc) { - this.minSoc = minSoc; - } - - public BigDecimal getAvgSoc() { - return avgSoc; - } - - public void setAvgSoc(BigDecimal avgSoc) { - this.avgSoc = avgSoc; - } - - public String getMaxVoltageID() { - return maxVoltageID; - } - - public void setMaxVoltageID(String maxVoltageID) { - this.maxVoltageID = maxVoltageID; - } - - public BigDecimal getMaxVoltage() { - return maxVoltage; - } - - public void setMaxVoltage(BigDecimal maxVoltage) { - this.maxVoltage = maxVoltage; - } - - public String getMinVoltageID() { - return minVoltageID; - } - - public void setMinVoltageID(String minVoltageID) { - this.minVoltageID = minVoltageID; - } - - public BigDecimal getMinVoltage() { - return minVoltage; - } - - public void setMinVoltage(BigDecimal minVoltage) { - this.minVoltage = minVoltage; - } - - public BigDecimal getAvgVoltage() { - return avgVoltage; - } - - public void setAvgVoltage(BigDecimal avgVoltage) { - this.avgVoltage = avgVoltage; - } - - public String getMaxTempID() { - return maxTempID; - } - - public void setMaxTempID(String maxTempID) { - this.maxTempID = maxTempID; - } - - public BigDecimal getMaxTemp() { - return maxTemp; - } - - public void setMaxTemp(BigDecimal maxTemp) { - this.maxTemp = maxTemp; - } - - public String getMinTempID() { - return minTempID; - } - - public void setMinTempID(String minTempID) { - this.minTempID = minTempID; - } - - public BigDecimal getMinTemp() { - return minTemp; - } - - public void setMinTemp(BigDecimal minTemp) { - this.minTemp = minTemp; - } - - public BigDecimal getAvgTemp() { - return avgTemp; - } - - public void setAvgTemp(BigDecimal avgTemp) { - this.avgTemp = avgTemp; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java index d209cd7..3aac017 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSOverViewVo.java @@ -22,34 +22,34 @@ public class BMSOverViewVo { private String emsCommunicationStatus; /** 电池堆总电压 (V) */ - private BigDecimal totalVoltage; + private BigDecimal stackVoltage; /** 可充电量 (kWh) */ - private BigDecimal chargeableCapacity; + private BigDecimal availableChargeCapacity; /** 累计充电量 (kWh) */ - private BigDecimal totalChargedCapacity; + private BigDecimal totalChargeCapacity; /** 电池堆总电流 (A) */ - private BigDecimal totalCurrent; + private BigDecimal stackCurrent; /** 可放电量 (kWh) */ - private BigDecimal dischargeableCapacity; + private BigDecimal availableDischargeCapacity; /** 累计放电量 (kWh) */ - private BigDecimal totalDischargedCapacity; + private BigDecimal totalDischargeCapacity; /** SOH (%) */ - private BigDecimal soh; + private BigDecimal stackSoh; /** 平均温度 (℃) */ - private BigDecimal averageTemperature; + private BigDecimal operatingTemp; /** 绝缘电阻 (Ω) */ - private BigDecimal insulationResistance; + private BigDecimal stackInsulationResistance; /** 当前SOC (%) */ - private BigDecimal currentSoc; + private BigDecimal stackSoc; /** 站点id */ private String siteId; @@ -91,92 +91,84 @@ public class BMSOverViewVo { this.emsCommunicationStatus = emsCommunicationStatus; } - public BigDecimal getTotalVoltage() { - return totalVoltage; + public BigDecimal getStackVoltage() { + return stackVoltage; } - public void setTotalVoltage(BigDecimal totalVoltage) { - this.totalVoltage = totalVoltage; + public void setStackVoltage(BigDecimal stackVoltage) { + this.stackVoltage = stackVoltage; } - public BigDecimal getChargeableCapacity() { - return chargeableCapacity; + public BigDecimal getAvailableChargeCapacity() { + return availableChargeCapacity; } - public void setChargeableCapacity(BigDecimal chargeableCapacity) { - this.chargeableCapacity = chargeableCapacity; + public void setAvailableChargeCapacity(BigDecimal availableChargeCapacity) { + this.availableChargeCapacity = availableChargeCapacity; } - public BigDecimal getTotalChargedCapacity() { - return totalChargedCapacity; + public BigDecimal getTotalChargeCapacity() { + return totalChargeCapacity; } - public void setTotalChargedCapacity(BigDecimal totalChargedCapacity) { - this.totalChargedCapacity = totalChargedCapacity; + public void setTotalChargeCapacity(BigDecimal totalChargeCapacity) { + this.totalChargeCapacity = totalChargeCapacity; } - public BigDecimal getTotalCurrent() { - return totalCurrent; + public BigDecimal getStackCurrent() { + return stackCurrent; } - public void setTotalCurrent(BigDecimal totalCurrent) { - this.totalCurrent = totalCurrent; + public void setStackCurrent(BigDecimal stackCurrent) { + this.stackCurrent = stackCurrent; } - public BigDecimal getDischargeableCapacity() { - return dischargeableCapacity; + public BigDecimal getAvailableDischargeCapacity() { + return availableDischargeCapacity; } - public void setDischargeableCapacity(BigDecimal dischargeableCapacity) { - this.dischargeableCapacity = dischargeableCapacity; + public void setAvailableDischargeCapacity(BigDecimal availableDischargeCapacity) { + this.availableDischargeCapacity = availableDischargeCapacity; } - public BigDecimal getTotalDischargedCapacity() { - return totalDischargedCapacity; + public BigDecimal getTotalDischargeCapacity() { + return totalDischargeCapacity; } - public void setTotalDischargedCapacity(BigDecimal totalDischargedCapacity) { - this.totalDischargedCapacity = totalDischargedCapacity; + public void setTotalDischargeCapacity(BigDecimal totalDischargeCapacity) { + this.totalDischargeCapacity = totalDischargeCapacity; } - public BigDecimal getSoh() { - return soh; + public BigDecimal getStackSoh() { + return stackSoh; } - public void setSoh(BigDecimal soh) { - this.soh = soh; + public void setStackSoh(BigDecimal stackSoh) { + this.stackSoh = stackSoh; } - public BigDecimal getAverageTemperature() { - return averageTemperature; + public BigDecimal getOperatingTemp() { + return operatingTemp; } - public void setAverageTemperature(BigDecimal averageTemperature) { - this.averageTemperature = averageTemperature; + public void setOperatingTemp(BigDecimal operatingTemp) { + this.operatingTemp = operatingTemp; } - public BigDecimal getInsulationResistance() { - return insulationResistance; + public BigDecimal getStackInsulationResistance() { + return stackInsulationResistance; } - public void setInsulationResistance(BigDecimal insulationResistance) { - this.insulationResistance = insulationResistance; + public void setStackInsulationResistance(BigDecimal stackInsulationResistance) { + this.stackInsulationResistance = stackInsulationResistance; } - public BigDecimal getCurrentSoc() { - return currentSoc; + public BigDecimal getStackSoc() { + return stackSoc; } - public void setCurrentSoc(BigDecimal currentSoc) { - this.currentSoc = currentSoc; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; + public void setStackSoc(BigDecimal stackSoc) { + this.stackSoc = stackSoc; } public String getSiteId() { @@ -187,6 +179,14 @@ public class BMSOverViewVo { this.siteId = siteId; } + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + public List getBatteryDataList() { return batteryDataList; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java index ef0db2d..95cacf5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryDataStatsListVo.java @@ -1,5 +1,6 @@ package com.xzzn.ems.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import java.math.BigDecimal; import java.util.Date; @@ -23,8 +24,9 @@ public class BatteryDataStatsListVo { /** SOH (%) */ private BigDecimal soh; - - private Date updateTime; + + @JsonFormat(pattern = "yyyy-MM-dd") + private Date dataTimestamp; /** 簇号 */ private String clusterDeviceId; @@ -69,12 +71,12 @@ public class BatteryDataStatsListVo { this.soh = soh; } - public Date getUpdateTime() { - return updateTime; + public Date getDataTimestamp() { + return dataTimestamp; } - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; + public void setDataTimestamp(Date dataTimestamp) { + this.dataTimestamp = dataTimestamp; } public String getClusterDeviceId() { diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java index 8502f5e..aa6017e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java @@ -2,7 +2,6 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsBatteryCluster; -import com.xzzn.ems.domain.vo.BMSBatteryClusterVo; import com.xzzn.ems.domain.vo.BMSBatteryDataList; import org.apache.ibatis.annotations.Param; @@ -62,13 +61,6 @@ public interface EmsBatteryClusterMapper */ public int deleteEmsBatteryClusterByIds(Long[] ids); - /** - * 根据site_id获取电池簇数据 - * @param siteId - * @return - */ - public List getBMSBatteryCluster(String siteId); - /** * 根据site_di和堆id获取簇数据和单体数据 * @param siteId diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index d9f8a91..4d9ee15 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import com.xzzn.ems.domain.EmsDevicesSetting; +import org.apache.ibatis.annotations.Param; /** * Modbus设备配置Mapper接口 @@ -60,24 +61,25 @@ public interface EmsDevicesSettingMapper * @return 结果 */ public int deleteEmsDevicesSettingByIds(Long[] ids); - /** - * 根据site_id获取所有电池堆 - * @param siteId + * 根据父类设备id获取子设备id + * @param parentId * @return */ - public List> getAllStackInfoBySiteId(String siteId); - - /** - * 根据电池堆id获取所有电池簇 - * @param stackDeviceId - * @return - */ - public List> getAllClusterInfoByStackId(String stackDeviceId); + public List> getDeviceInfoByParentId(String parentId); /** * 获取该设备下的所有电表 * @param siteId * @return */ public List getAllBatteryDeviceBySiteId(String siteId); + + + /** + * 根据site_id和device_category获取指定设备信息 + * @param siteId + * @param deviceCategory + * @return + */ + public List> getDeviceInfosBySiteIdAndCategory(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index 1519a79..ed572b0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -1,5 +1,6 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.enums.DeviceCategory; import com.xzzn.ems.domain.EmsSiteSetting; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; @@ -41,17 +42,17 @@ public class EmsSiteServiceImpl implements IEmsSiteService */ @Override public List> getAllStackInfo(String siteId) { - return emsDevicesMapper.getAllStackInfoBySiteId(siteId); + return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.STACK.getCode()); } /** - * 根据电池堆Id获取电池簇 - * @param stackDeviceId + * 根据父类设备id获取子设备id + * @param parentId * @return */ @Override - public List> getAllClusterInfo(String stackDeviceId) { - return emsDevicesMapper.getAllClusterInfoByStackId(stackDeviceId); + public List> getAllClusterInfo(String parentId) { + return emsDevicesMapper.getDeviceInfoByParentId(parentId); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 61ac5a1..ef49d2e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -273,6 +273,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { if (list.size() > 0 ) { emsBatteryDataMapper.insertEmsBatteryDataList(list); + redisCache.deleteList("BATTERY_021_FXX_01_"+deviceId); redisCache.setCacheList("BATTERY_021_FXX_01_"+deviceId, list); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 0d10ba9..bafee76 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -1,19 +1,19 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.EmsBatteryData; -import com.xzzn.ems.domain.EmsCoolingData; -import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.*; import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.ISingleSiteService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.*; -import java.util.stream.Collectors; /** * 单点监控 服务层实现 @@ -46,6 +46,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { @Autowired private EmsDevicesSettingMapper emsDevicesSettingMapper; + @Autowired + private RedisCache redisCache; + @Override public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { SiteMonitorHomeVo siteMonitorHomeVo = new SiteMonitorHomeVo(); @@ -137,39 +140,66 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List pcsDetailInfoVoList = new ArrayList<>(); if (!StringUtils.isEmpty(siteId)) { - // 获取pcs最新数据 - pcsDetailInfoVoList = emsPcsDataMapper.getPcsDetailInfoBySiteId(siteId); - if (!CollectionUtils.isEmpty(pcsDetailInfoVoList)) { - for (PcsDetailInfoVo pcsDetailInfoVo : pcsDetailInfoVoList) { - String deviceId = pcsDetailInfoVo.getDeviceId(); - // 获取支路最新数据 - if (!StringUtils.isEmpty(deviceId)) { - List pcsBranchInfoList = emsPcsBranchDataMapper.getPcsBranchInfoList(siteId, deviceId); - pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList); - } + // 获取该设备下所有pcs的id + List> pcsIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode()); + + for (Map pcsDevice : pcsIds) { + PcsDetailInfoVo pcsDetailInfoVo = new PcsDetailInfoVo(); + pcsDetailInfoVo.setDeviceName(pcsDevice.get("deviceName").toString()); + pcsDetailInfoVo.setCommunicationStatus(pcsDevice.get("communicationStatus").toString()); + // 从redis取pcs单个详细数据 + String pcsId = pcsDevice.get("id").toString(); + EmsPcsData pcsData = redisCache.getCacheObject("PCS_"+siteId+"_"+pcsId); + if (pcsData != null) { + BeanUtils.copyProperties(pcsData, pcsDetailInfoVo); } + // 支路信息数据 + List pcsBranchInfoList = new ArrayList<>(); + processBranchDataInfo(siteId,pcsId,pcsBranchInfoList); + pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList); + + pcsDetailInfoVoList.add(pcsDetailInfoVo); } } return pcsDetailInfoVoList; } + private void processBranchDataInfo(String siteId, String pcsId, List pcsBranchInfoList) { + if (!StringUtils.isEmpty(pcsId)) { + List pcsBranchData = redisCache.getCacheObject("BRANCH_"+siteId+"_"+pcsId); + if (pcsBranchData != null) { + for(EmsPcsBranchData emsPcsBranchData : pcsBranchData) { + PcsBranchInfo pcsBranchInfo = new PcsBranchInfo(); + BeanUtils.copyProperties(emsPcsBranchData, pcsBranchInfo); + pcsBranchInfoList.add(pcsBranchInfo); + } + } + } + } + // 获取BMS总览数据 @Override public List getBMSOverView(String siteId) { List bmsOverViewVoList = new ArrayList<>(); + // 获取所有电池堆 if (!StringUtils.isEmpty(siteId)) { - // 获取电池堆list - bmsOverViewVoList = emsBatteryStackMapper.selectEmsBatteryStackBySiteId(siteId); - if (!CollectionUtils.isEmpty(bmsOverViewVoList)) { - for (BMSOverViewVo bmsOverViewVo : bmsOverViewVoList) { - // 获取单体电池数据 - String stackDeviceId = bmsOverViewVo.getDeviceId(); - if (!StringUtils.isEmpty(stackDeviceId)) { - List batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackDeviceId); - bmsOverViewVo.setBatteryDataList(batteryDataList); - } + List> stackIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.STACK.getCode()); + for (Map stackDevice : stackIds) { + BMSOverViewVo bmsOverViewVo = new BMSOverViewVo(); + bmsOverViewVo.setDeviceName(stackDevice.get("deviceName").toString()); + // 从redis取堆单个详细数据 + String stackId = stackDevice.get("id").toString(); + EmsBatteryStack stackData = redisCache.getCacheObject("STACK_"+siteId+"_"+stackId); + if (stackData != null) { + BeanUtils.copyProperties(stackData, bmsOverViewVo); } + // 列表数据 + if (!StringUtils.isEmpty(stackId)) { + List batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackId); + bmsOverViewVo.setBatteryDataList(batteryDataList); + } + bmsOverViewVoList.add(bmsOverViewVo); } } return bmsOverViewVoList; @@ -181,50 +211,58 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List bmsBatteryClusterVoList = new ArrayList<>(); if (!StringUtils.isEmpty(siteId)) { - bmsBatteryClusterVoList = emsBatteryClusterMapper.getBMSBatteryCluster(siteId); - if (!CollectionUtils.isEmpty(bmsBatteryClusterVoList)) { - for (BMSBatteryClusterVo bmsBatteryClusterVo : bmsBatteryClusterVoList) { - - String clusterDeviceId = bmsBatteryClusterVo.getDeviceId(); + // 获取所有设备下的电池簇id + List> clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode()); + for (Map clusterDevice : clusterIds) { + BMSBatteryClusterVo bmsBatteryClusterVo = new BMSBatteryClusterVo(); + bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString()); + // 从redis取单个簇详细数据 + String clusterId = clusterDevice.get("id").toString(); + EmsBatteryCluster clusterData = redisCache.getCacheObject("CLUSTER_"+siteId+"_"+clusterId); + if (clusterData != null) { + BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo); + // 处理单体电池数据-平均/最大/最小 List clusterDataList = new ArrayList<>(); - if (!StringUtils.isEmpty(clusterDeviceId)) { - // 获取单体电池数据-平均/最大/最小 - //BatteryClusterDataDetailVo batteryClusterDataDetailVo = emsBatteryDataMapper.getBatteryDataByClusterId(siteId,clusterDeviceId); - // 处理数据 - BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList(); - BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList(); - BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList(); - // 设值 - voltageData.setDataName(CLUSTER_DATA_VOLTAGE); - voltageData.setAvgData(bmsBatteryClusterVo.getAvgVoltage()); - voltageData.setMaxData(bmsBatteryClusterVo.getMaxVoltage()); - voltageData.setMaxDataID(bmsBatteryClusterVo.getMaxVoltageID()); - voltageData.setMinData(bmsBatteryClusterVo.getMinVoltage()); - voltageData.setMinDataID(bmsBatteryClusterVo.getMinVoltageID()); - tempData.setDataName(CLUSTER_DATA_TEP); - tempData.setAvgData(bmsBatteryClusterVo.getAvgTemp()); - tempData.setMaxData(bmsBatteryClusterVo.getMaxTemp()); - tempData.setMaxDataID(bmsBatteryClusterVo.getMaxTempID()); - tempData.setMinData(bmsBatteryClusterVo.getMinTemp()); - tempData.setMinDataID(bmsBatteryClusterVo.getMinTempID()); - socData.setDataName(CLUSTER_DATA_SOC); - socData.setAvgData(bmsBatteryClusterVo.getAvgSoc()); - socData.setMaxData(bmsBatteryClusterVo.getMaxSoc()); - socData.setMaxDataID(bmsBatteryClusterVo.getMaxSocID()); - socData.setMinData(bmsBatteryClusterVo.getMinSoc()); - socData.setMinDataID(bmsBatteryClusterVo.getMinSocID()); - - clusterDataList.add(voltageData); - clusterDataList.add(tempData); - clusterDataList.add(socData); - bmsBatteryClusterVo.setBatteryDataList(clusterDataList); - } + dealWithBatteryClusterData(clusterData,clusterDataList); + bmsBatteryClusterVo.setBatteryDataList(clusterDataList); } + + bmsBatteryClusterVoList.add(bmsBatteryClusterVo); } } return bmsBatteryClusterVoList; } + private void dealWithBatteryClusterData(EmsBatteryCluster clusterData, List clusterDataList) { + BMSBatteryClusterDataList voltageData = new BMSBatteryClusterDataList(); + BMSBatteryClusterDataList tempData = new BMSBatteryClusterDataList(); + BMSBatteryClusterDataList socData = new BMSBatteryClusterDataList(); + + // 设值 + voltageData.setDataName(CLUSTER_DATA_VOLTAGE); + voltageData.setAvgData(clusterData.getAvgCellVoltage()); + voltageData.setMaxData(clusterData.getMaxCellVoltage()); + voltageData.setMaxDataID(clusterData.getMaxCellVoltageId().toString()); + voltageData.setMinData(clusterData.getMinCellVoltage()); + voltageData.setMinDataID(clusterData.getMinCellVoltageId().toString()); + tempData.setDataName(CLUSTER_DATA_TEP); + tempData.setAvgData(clusterData.getAvgCellTemp()); + tempData.setMaxData(clusterData.getMaxCellTemp()); + tempData.setMaxDataID(clusterData.getMaxCellTempId().toString()); + tempData.setMinData(clusterData.getMinCellTemp()); + tempData.setMinDataID(clusterData.getMinCellTempId().toString()); + socData.setDataName(CLUSTER_DATA_SOC); + socData.setAvgData(clusterData.getCurrentSoc()); + socData.setMaxData(clusterData.getMaxCellSoc()); + socData.setMaxDataID(clusterData.getMaxCellSocId().toString()); + socData.setMinData(clusterData.getMinCellSoc()); + socData.setMinDataID(clusterData.getMinCellSocId().toString()); + + clusterDataList.add(voltageData); + clusterDataList.add(tempData); + clusterDataList.add(socData); + } + // 获取液冷设备参数 @Override public List getCoolingDataList(String siteId) { @@ -244,7 +282,26 @@ public class SingleSiteServiceImpl implements ISingleSiteService { @Override public List getClusterDataInfoList(String clusterDeviceId,String siteId) { List batteryDataStatsListVo = new ArrayList<>(); - batteryDataStatsListVo = emsBatteryDataMapper.getAllBatteryDataByClusterId(clusterDeviceId,siteId); + List> clusterIds = new ArrayList<>(); + if (StringUtils.isEmpty(clusterDeviceId)) { + clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode()); + } else { + Map map = new HashMap<>(); + map.put("id", clusterDeviceId); + clusterIds.add(map); + } + for (Map clusterDevice : clusterIds) { + // 从redis取单个簇详细数据 + String clusterId = clusterDevice.get("id").toString(); + List batteryDataList = redisCache.getCacheList("BATTERY_"+siteId+"_"+clusterId); + if (batteryDataList != null) { + for (EmsBatteryData batteryData : batteryDataList) { + BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo(); + BeanUtils.copyProperties(batteryData, batteryDataStatsVo); + batteryDataStatsListVo.add(batteryDataStatsVo); + } + } + } return batteryDataStatsListVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 1c4844f..637a727 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -309,33 +309,6 @@ - - @@ -53,6 +54,7 @@ and communication_status = #{communicationStatus} and device_id = #{deviceId} and parent_id = #{parentId} + and device_category = #{deviceCategory} @@ -83,6 +85,7 @@ communication_status, device_id, parent_id, + device_category, #{deviceName}, @@ -104,6 +107,7 @@ #{communicationStatus}, #{deviceId}, #{parentId}, + #{deviceCategory}, @@ -129,6 +133,7 @@ communication_status = #{communicationStatus}, device_id = #{deviceId}, parent_id = #{parentId}, + device_category = #{deviceCategory}, where id = #{id} @@ -150,8 +155,8 @@ select distinct eb.device_id from ems_battery_stack eb where eb.site_id = #{siteId}) - + select distinct t.device_id as id,t.device_name as deviceName from ems_devices_setting t where t.parent_id = #{parentId} + + + + \ No newline at end of file -- 2.49.0 From 8081e38d5eb6705251822a494a027e4eba4307bc Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 2 Jul 2025 16:10:22 +0800 Subject: [PATCH 047/336] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=B0=83=E8=AF=95-?= =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/framework/web/service/SysLoginService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java b/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java index 39520b9..e1917d8 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java +++ b/ems-framework/src/main/java/com/xzzn/framework/web/service/SysLoginService.java @@ -111,7 +111,6 @@ public class SysLoginService public void validateCaptcha(String username, String code, String uuid) { boolean captchaEnabled = configService.selectCaptchaEnabled(); - captchaEnabled = false; if (captchaEnabled) { String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, ""); -- 2.49.0 From 88fee64f461aedfe959640814d337317e5c03cf2 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 2 Jul 2025 17:32:17 +0800 Subject: [PATCH 048/336] =?UTF-8?q?redis=20key=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 2 +- .../common/constant/RedisKeyConstants.java | 34 +++++++++++++++++++ .../core/controller/BaseController.java | 33 ++++++++++++++++++ .../service/impl/SingleSiteServiceImpl.java | 13 +++---- 4 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 327d5bb..23b224b 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -114,7 +114,7 @@ public class EmsSiteMonitorController extends BaseController{ { startPage(); List list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId); - return getDataTable(list); + return getDataTable2(list); } /** diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java new file mode 100644 index 0000000..79cd77f --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -0,0 +1,34 @@ +package com.xzzn.common.constant; + +/** + * 数据存储 Redis key 常量 + * + * @author xzzn + */ +public class RedisKeyConstants +{ + /** + * pcs数据 redis key + */ + public static final String PCS = "PCS_"; + + /** + * pcs branch数据 redis key + */ + public static final String BRANCH = "BRANCH_"; + + /** + * stack电池堆数据 redis key + */ + public static final String STACK = "STACK_"; + + /** + * cluster电池簇数据 redis key + */ + public static final String CLUSTER = "CLUSTER_"; + + /** + * battery单体电池数据 redis key + */ + public static final String BATTERY = "BATTERY_"; +} diff --git a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java index c3f46a6..2eb7f8f 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java +++ b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java @@ -1,6 +1,8 @@ package com.xzzn.common.core.controller; import java.beans.PropertyEditorSupport; +import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; import org.slf4j.Logger; @@ -199,4 +201,35 @@ public class BaseController { return getLoginUser().getUsername(); } + + /** + * 手动处理分页 + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected TableDataInfo getDataTable2(List list) + { + List subList = new ArrayList<>(); + // 分页梳理 + PageDomain pageDomain = TableSupport.buildPageRequest(); + int pageNum = pageDomain.getPageNum(); + int pageSize = pageDomain.getPageSize(); + if (pageNum > 0 && pageSize > 0) { + // 计算分页起始和结束索引 + int startIndex = (pageNum - 1) * pageSize; + int endIndex = Math.min(startIndex + pageSize, list.size()); + // 防止越界 + if (startIndex >= list.size()) { + subList = Collections.emptyList(); + } + // 截取当前页数据 + subList = list.subList(startIndex, endIndex); + } + + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(subList); + rspData.setTotal(list.size()); + return rspData; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index bafee76..0621ecc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -1,5 +1,6 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.StringUtils; @@ -149,7 +150,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { pcsDetailInfoVo.setCommunicationStatus(pcsDevice.get("communicationStatus").toString()); // 从redis取pcs单个详细数据 String pcsId = pcsDevice.get("id").toString(); - EmsPcsData pcsData = redisCache.getCacheObject("PCS_"+siteId+"_"+pcsId); + EmsPcsData pcsData = redisCache.getCacheObject(RedisKeyConstants.PCS +siteId+"_"+pcsId); if (pcsData != null) { BeanUtils.copyProperties(pcsData, pcsDetailInfoVo); } @@ -166,7 +167,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private void processBranchDataInfo(String siteId, String pcsId, List pcsBranchInfoList) { if (!StringUtils.isEmpty(pcsId)) { - List pcsBranchData = redisCache.getCacheObject("BRANCH_"+siteId+"_"+pcsId); + List pcsBranchData = redisCache.getCacheObject(RedisKeyConstants.BRANCH +siteId+"_"+pcsId); if (pcsBranchData != null) { for(EmsPcsBranchData emsPcsBranchData : pcsBranchData) { PcsBranchInfo pcsBranchInfo = new PcsBranchInfo(); @@ -190,7 +191,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { bmsOverViewVo.setDeviceName(stackDevice.get("deviceName").toString()); // 从redis取堆单个详细数据 String stackId = stackDevice.get("id").toString(); - EmsBatteryStack stackData = redisCache.getCacheObject("STACK_"+siteId+"_"+stackId); + EmsBatteryStack stackData = redisCache.getCacheObject(RedisKeyConstants.STACK +siteId+"_"+stackId); if (stackData != null) { BeanUtils.copyProperties(stackData, bmsOverViewVo); } @@ -218,7 +219,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString()); // 从redis取单个簇详细数据 String clusterId = clusterDevice.get("id").toString(); - EmsBatteryCluster clusterData = redisCache.getCacheObject("CLUSTER_"+siteId+"_"+clusterId); + EmsBatteryCluster clusterData = redisCache.getCacheObject(RedisKeyConstants.CLUSTER +siteId+"_"+clusterId); if (clusterData != null) { BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo); // 处理单体电池数据-平均/最大/最小 @@ -275,7 +276,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { /** - * 根据电池堆获取单体柱状数据 + * 根据电池堆获取单体电池数据 * @param clusterDeviceId * @return */ @@ -293,7 +294,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { for (Map clusterDevice : clusterIds) { // 从redis取单个簇详细数据 String clusterId = clusterDevice.get("id").toString(); - List batteryDataList = redisCache.getCacheList("BATTERY_"+siteId+"_"+clusterId); + List batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); if (batteryDataList != null) { for (EmsBatteryData batteryData : batteryDataList) { BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo(); -- 2.49.0 From b4302edd8abbf037a1c3948f8a86aad37ffe7e56 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 2 Jul 2025 17:34:09 +0800 Subject: [PATCH 049/336] =?UTF-8?q?redis=20key=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FXXDataProcessServiceImpl.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index ef49d2e..2fe446f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; +import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.*; import com.xzzn.common.utils.DateUtils; @@ -22,7 +23,7 @@ import java.util.*; @Service public class FXXDataProcessServiceImpl implements IFXXDataProcessService { private static final Log log = LogFactory.getLog(FXXDataProcessServiceImpl.class); - + private static final String SITE_ID = "021_FXX_01"; @Autowired private EmsBatteryClusterMapper emsBatteryClusterMapper; @@ -141,12 +142,12 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { dataStack.setCreateTime(DateUtils.getNowDate()); dataStack.setUpdateBy("system"); dataStack.setUpdateTime(DateUtils.getNowDate()); - dataStack.setSiteId("021_FXX_01"); + dataStack.setSiteId(SITE_ID); dataStack.setDeviceId(deviceId); emsBatteryStackMapper.insertEmsBatteryStack(dataStack); - redisCache.setCacheObject("STACK_021_FXX_01_"+deviceId, dataStack); + redisCache.setCacheObject(RedisKeyConstants.STACK + SITE_ID + "_" +deviceId, dataStack); } @@ -210,7 +211,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { data.setCreateTime(DateUtils.getNowDate()); data.setUpdateBy("system"); data.setUpdateTime(DateUtils.getNowDate()); - data.setSiteId("021_FXX_01"); + data.setSiteId(SITE_ID); data.setDeviceId(deviceId); data.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD"))); data.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD"))); @@ -227,7 +228,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } emsBatteryClusterMapper.insertEmsBatteryCluster(data); - redisCache.setCacheObject("CLUSTER_021_FXX_01_"+deviceId, data); + redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); } @@ -265,7 +266,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { batteryData.setDataTimestamp(new Date()); // ID字段 - batteryData.setSiteId("021_FXX_01"); + batteryData.setSiteId(SITE_ID); batteryData.setClusterDeviceId(deviceId); list.add(batteryData); @@ -273,8 +274,8 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { if (list.size() > 0 ) { emsBatteryDataMapper.insertEmsBatteryDataList(list); - redisCache.deleteList("BATTERY_021_FXX_01_"+deviceId); - redisCache.setCacheList("BATTERY_021_FXX_01_"+deviceId, list); + redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId); + redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, list); } } @@ -335,13 +336,13 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { pcsData.setCreateTime(DateUtils.getNowDate()); pcsData.setUpdateBy("system"); pcsData.setUpdateTime(DateUtils.getNowDate()); - pcsData.setSiteId("021_FXX_01"); + pcsData.setSiteId(SITE_ID); pcsData.setDeviceId(deviceId); pcsData.setDateMonth(DateUtils.getNowMonthLong()); pcsData.setDateDay(DateUtils.getNowDayLong()); emsPcsDataMapper.insertEmsPcsData(pcsData); - redisCache.setCacheObject("PCS_021_FXX_01_"+deviceId, pcsData); + redisCache.setCacheObject(RedisKeyConstants.PCS + SITE_ID + "_" +deviceId, pcsData); } @@ -387,7 +388,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { if (list.size() > 0 ) { emsPcsBranchDataMapper.insertPcsBranchDataList(list); - redisCache.setCacheObject("BRANCH_021_FXX_01_"+deviceId, list); + redisCache.setCacheObject(RedisKeyConstants.BRANCH + SITE_ID + "_" +deviceId, list); } -- 2.49.0 From 7964806b94655680255d5f74deb689371e95b4d3 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 2 Jul 2025 19:43:17 +0800 Subject: [PATCH 050/336] =?UTF-8?q?=E7=AB=99=E7=82=B9=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=AB=99=E7=82=B9=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 38 +++++++++++++++++++ .../com/xzzn/ems/domain/EmsSiteSetting.java | 4 +- .../xzzn/ems/mapper/EmsSiteSettingMapper.java | 11 ++++++ .../com/xzzn/ems/service/IEmsSiteService.java | 1 + .../ems/service/impl/EmsSiteServiceImpl.java | 12 ++++++ .../mapper/ems/EmsSiteSettingMapper.xml | 12 ++++++ 6 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteConfigController.java 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 new file mode 100644 index 0000000..5b5e480 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteConfigController.java @@ -0,0 +1,38 @@ +package com.xzzn.web.controller.ems; + +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.page.TableDataInfo; +import com.xzzn.ems.domain.EmsSiteSetting; +import com.xzzn.ems.service.IEmsSiteService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * + * 站点配置 + * + */ +@RestController +@RequestMapping("/ems/siteConfig") +public class EmsSiteConfigController extends BaseController{ + + @Autowired + private IEmsSiteService iEmsSiteService; + + /** + * 获取站点列表 + */ + @GetMapping("/getSiteInfoList") + public TableDataInfo getSiteInfoList(@RequestParam String siteName, @RequestParam String startTime, @RequestParam String endTime) + { + startPage(); + List list = iEmsSiteService.getAllSiteInfoList(siteName,startTime,endTime); + return getDataTable(list); + } + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java index d70f537..9ef28ee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsSiteSetting.java @@ -30,8 +30,8 @@ public class EmsSiteSetting extends BaseEntity private String siteAddress; /** 运营时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "运营时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "运营时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date runningTime; /** 纬度 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java index 152726c..09bc548 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java @@ -3,6 +3,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsSiteSetting; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; +import org.apache.ibatis.annotations.Param; /** * 站点Mapper接口 @@ -72,4 +73,14 @@ public interface EmsSiteSettingMapper * @return */ public EmsSiteSetting selectEmsSiteSettingBySiteId(String siteId); + + + /** + * 根据站点名称和投运时间获取站点列表 + * @param siteName + * @param startTime + * @param endTime + * @return + */ + public List getSiteInfoList(@Param("siteName")String siteName, @Param("startTime")String startTime, @Param("endTime")String endTime); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index ef3ee31..a463947 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -23,4 +23,5 @@ public interface IEmsSiteService public List> getAllClusterInfo(String stackDeviceId); + public List getAllSiteInfoList(String siteName, String startTime, String endTime); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index ed572b0..9893d9f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -55,4 +55,16 @@ public class EmsSiteServiceImpl implements IEmsSiteService return emsDevicesMapper.getDeviceInfoByParentId(parentId); } + /** + * 获取站点列表 + * @param siteName + * @param startTime + * @param endTime + * @return + */ + @Override + public List getAllSiteInfoList(String siteName, String startTime, String endTime) { + return emsSiteMapper.getSiteInfoList(siteName,startTime,endTime); + } + } diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index 186c39d..9c03318 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -120,4 +120,16 @@ where site_id = #{siteId} + + \ No newline at end of file -- 2.49.0 From 0e726a214d84c90a6b54e69c2fae6bbeaffd710c Mon Sep 17 00:00:00 2001 From: dashixiong Date: Thu, 3 Jul 2025 14:47:27 +0800 Subject: [PATCH 051/336] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/data/FXDataProcess.java | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java deleted file mode 100644 index 8a78a8b..0000000 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/data/FXDataProcess.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.xzzn.web.controller.ems.data; - -public class FXDataProcess { - - - - public void batteryClusterProcess(String data) { - } - - public void batteryStackProcess(String data) { - } - - public void batteryDataProcess(String data) { - } - - public void pcsProcess(String data) { - } - - public void pcsBranchProcess(String data) { - } - - - public void coolingProcess(String data) { - } - - - public void ameterProcess(String data) { - } -} -- 2.49.0 From 7bf4baf85f9704ba8977a6f751a43e1952f0ac53 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 3 Jul 2025 15:40:27 +0800 Subject: [PATCH 052/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 25 +++++++ .../xzzn/ems/domain/vo/SiteDeviceListVo.java | 68 +++++++++++++++++++ .../ems/mapper/EmsDevicesSettingMapper.java | 8 ++- .../xzzn/ems/mapper/EmsSiteSettingMapper.java | 7 ++ .../ems/service/IEmsDeviceSettingService.java | 13 ++++ .../com/xzzn/ems/service/IEmsSiteService.java | 4 +- .../impl/EmsDeviceSettingServiceImpl.java | 28 ++++++++ .../ems/service/impl/EmsSiteServiceImpl.java | 11 +++ .../mapper/ems/EmsDevicesSettingMapper.xml | 6 ++ .../mapper/ems/EmsSiteSettingMapper.xml | 11 +++ 10 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceSettingService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java 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 5b5e480..be2e0e2 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 @@ -2,7 +2,10 @@ package com.xzzn.web.controller.ems; import com.xzzn.common.core.controller.BaseController; 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; import com.xzzn.ems.service.IEmsSiteService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -24,6 +27,9 @@ public class EmsSiteConfigController extends BaseController{ @Autowired private IEmsSiteService iEmsSiteService; + @Autowired + private IEmsDeviceSettingService iEmsDeviceSettingService; + /** * 获取站点列表 */ @@ -35,4 +41,23 @@ public class EmsSiteConfigController extends BaseController{ return getDataTable(list); } + /** + * 获取设备列表 + */ + @GetMapping("/getDeviceInfoList") + public TableDataInfo getDeviceInfoList(@RequestParam String siteId) + { + startPage(); + List list = iEmsSiteService.getAllDeviceList(siteId); + return getDataTable(list); + } + + /** + * 获取设备详细信息 + */ + @GetMapping("/getDeviceDetailInfo") + public EmsDevicesSetting getDeviceDetailInfo(@RequestParam String deviceId) + { + return iEmsDeviceSettingService.getDeviceDetailInfo(deviceId); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java new file mode 100644 index 0000000..5dc4155 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -0,0 +1,68 @@ +package com.xzzn.ems.domain.vo; + +/** + * 站点管理-站点设备列表 + * + */ +public class SiteDeviceListVo { + /** 站点id */ + private String siteId; + /** 站点名称 */ + private String siteName; + /** 设备id */ + private String deviceId; + /** 设备名称 */ + private String deviceName; + /** 设备类型 */ + private String deviceType; + /** 通信状态 */ + private String communicationStatus; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getSiteName() { + return siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public String getCommunicationStatus() { + return communicationStatus; + } + + public void setCommunicationStatus(String communicationStatus) { + this.communicationStatus = communicationStatus; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 4d9ee15..9b6dd71 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -74,7 +74,6 @@ public interface EmsDevicesSettingMapper */ public List getAllBatteryDeviceBySiteId(String siteId); - /** * 根据site_id和device_category获取指定设备信息 * @param siteId @@ -82,4 +81,11 @@ public interface EmsDevicesSettingMapper * @return */ public List> getDeviceInfosBySiteIdAndCategory(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); + + /** + * 获取该设备的详细数据 + * @param deviceId + * @return + */ + public EmsDevicesSetting getDeviceDetailInfo(String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java index 09bc548..abcc74a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java @@ -2,6 +2,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsSiteSetting; +import com.xzzn.ems.domain.vo.SiteDeviceListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import org.apache.ibatis.annotations.Param; @@ -83,4 +84,10 @@ public interface EmsSiteSettingMapper * @return */ public List getSiteInfoList(@Param("siteName")String siteName, @Param("startTime")String startTime, @Param("endTime")String endTime); + + /** + * 获取站点的设备列表 + * @return + */ + public List getAllSiteDeviceList(String siteId); } 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 new file mode 100644 index 0000000..970d040 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceSettingService.java @@ -0,0 +1,13 @@ +package com.xzzn.ems.service; + +import com.xzzn.ems.domain.EmsDevicesSetting; + +/** + * 设备信息 服务层 + * + */ +public interface IEmsDeviceSettingService +{ + + public EmsDevicesSetting getDeviceDetailInfo(String deviceId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index a463947..8a742a7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -1,6 +1,7 @@ package com.xzzn.ems.service; import com.xzzn.ems.domain.EmsSiteSetting; +import com.xzzn.ems.domain.vo.SiteDeviceListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import java.util.List; @@ -22,6 +23,7 @@ public interface IEmsSiteService public List> getAllClusterInfo(String stackDeviceId); - public List getAllSiteInfoList(String siteName, String startTime, String endTime); + + public List getAllDeviceList(String siteId); } 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 new file mode 100644 index 0000000..b8485a1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java @@ -0,0 +1,28 @@ +package com.xzzn.ems.service.impl; + +import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.service.IEmsDeviceSettingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 站点信息 服务层实现 + * + */ +@Service +public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService +{ + @Autowired + private EmsDevicesSettingMapper emsDevicesMapper; + + /** + * 获取设备详细信息 + * @param deviceId + * @return + */ + @Override + public EmsDevicesSetting getDeviceDetailInfo(String deviceId) { + return emsDevicesMapper.getDeviceDetailInfo(deviceId); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index 9893d9f..f05f59b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -2,6 +2,7 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.enums.DeviceCategory; import com.xzzn.ems.domain.EmsSiteSetting; +import com.xzzn.ems.domain.vo.SiteDeviceListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsSiteSettingMapper; @@ -67,4 +68,14 @@ public class EmsSiteServiceImpl implements IEmsSiteService return emsSiteMapper.getSiteInfoList(siteName,startTime,endTime); } + /** + * 获取设备列表 + * + * @param siteId + * @return + */ + @Override + public List getAllDeviceList(String siteId) { + return emsSiteMapper.getAllSiteDeviceList(siteId); + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index e5729ac..c227e2c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -179,4 +179,10 @@ communication_status as communicationStatus from ems_devices_setting where site_id = #{siteId} and device_category = #{deviceCategory} + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index 9c03318..e182b46 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -132,4 +132,15 @@ AND running_time < DATE_ADD(STR_TO_DATE( #{endTime}, '%Y-%m-%d'), INTERVAL 1 DAY) + + \ No newline at end of file -- 2.49.0 From 126b637932695d97e86e706c724dd507e1407811 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 3 Jul 2025 16:12:19 +0800 Subject: [PATCH 053/336] =?UTF-8?q?BMS=E6=80=BB=E8=A7=88-=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=A0=86=E4=B8=8B=E9=9D=A2=E7=B0=87=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/BMSBatteryDataList.java | 56 ++++++++++++------- .../service/impl/SingleSiteServiceImpl.java | 24 +++++++- 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java index f1c6bbb..da1b3af 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java @@ -21,16 +21,16 @@ public class BMSBatteryDataList { private BigDecimal currentSoc; /** 单体最高电压 (V) */ - private BigDecimal maxVoltage; + private BigDecimal maxCellVoltage; /** 单体最低电压 (V) */ - private BigDecimal minVoltage; + private BigDecimal minCellVoltage; /** 单体最高温度 (℃) */ - private BigDecimal maxTemperature; + private BigDecimal maxCellTemp; /** 单体最低温度 (℃) */ - private BigDecimal minTemperature; + private BigDecimal minCellTemp; /** 换电站id */ private String siteId; @@ -46,36 +46,52 @@ public class BMSBatteryDataList { this.clusterId = clusterId; } - public BigDecimal getMinTemperature() { - return minTemperature; + public String getStackDeviceId() { + return stackDeviceId; } - public void setMinTemperature(BigDecimal minTemperature) { - this.minTemperature = minTemperature; + public void setStackDeviceId(String stackDeviceId) { + this.stackDeviceId = stackDeviceId; } - public BigDecimal getMaxTemperature() { - return maxTemperature; + public String getSiteId() { + return siteId; } - public void setMaxTemperature(BigDecimal maxTemperature) { - this.maxTemperature = maxTemperature; + public void setSiteId(String siteId) { + this.siteId = siteId; } - public BigDecimal getMinVoltage() { - return minVoltage; + public BigDecimal getMinCellTemp() { + return minCellTemp; } - public void setMinVoltage(BigDecimal minVoltage) { - this.minVoltage = minVoltage; + public void setMinCellTemp(BigDecimal minCellTemp) { + this.minCellTemp = minCellTemp; } - public BigDecimal getMaxVoltage() { - return maxVoltage; + public BigDecimal getMaxCellTemp() { + return maxCellTemp; } - public void setMaxVoltage(BigDecimal maxVoltage) { - this.maxVoltage = maxVoltage; + public void setMaxCellTemp(BigDecimal maxCellTemp) { + this.maxCellTemp = maxCellTemp; + } + + public BigDecimal getMinCellVoltage() { + return minCellVoltage; + } + + public void setMinCellVoltage(BigDecimal minCellVoltage) { + this.minCellVoltage = minCellVoltage; + } + + public BigDecimal getMaxCellVoltage() { + return maxCellVoltage; + } + + public void setMaxCellVoltage(BigDecimal maxCellVoltage) { + this.maxCellVoltage = maxCellVoltage; } public BigDecimal getCurrentSoc() { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 0621ecc..4a27b11 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -195,10 +195,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (stackData != null) { BeanUtils.copyProperties(stackData, bmsOverViewVo); } - // 列表数据 + // 下面簇列表数据 if (!StringUtils.isEmpty(stackId)) { - List batteryDataList = emsBatteryClusterMapper.getBmsBatteryData(siteId,stackId); - bmsOverViewVo.setBatteryDataList(batteryDataList); + getBMSClusterListInfo(siteId,stackId,bmsOverViewVo); } bmsOverViewVoList.add(bmsOverViewVo); } @@ -206,6 +205,25 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return bmsOverViewVoList; } + private void getBMSClusterListInfo(String siteId, String stackId, BMSOverViewVo bmsOverViewVo) { + List batteryDataList = new ArrayList(); + + List> clusterIds = emsDevicesSettingMapper.getDeviceInfoByParentId(stackId); + for (Map clusterDevice : clusterIds) { + BMSBatteryDataList bmsBatteryDataList= new BMSBatteryDataList(); + // 从redis取单个簇的详细数据 + String clusterId = clusterDevice.get("id").toString(); + bmsBatteryDataList.setClusterId(clusterId); + EmsBatteryCluster clusterData = redisCache.getCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + clusterId); + if (clusterData != null) { + BeanUtils.copyProperties(clusterData, bmsBatteryDataList); + } + batteryDataList.add(bmsBatteryDataList); + } + + bmsOverViewVo.setBatteryDataList(batteryDataList); + } + // 获取BMS电池簇数据 @Override public List getBMSBatteryCluster(String siteId) { -- 2.49.0 From 4bb23a7c75d88916ed1f2f693842ed8ff460d9ba Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 4 Jul 2025 12:37:18 +0800 Subject: [PATCH 054/336] =?UTF-8?q?=E5=A5=89=E8=B4=A4=E7=94=B5=E8=A1=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 5 +- .../common/constant/RedisKeyConstants.java | 5 + .../com/xzzn/ems/domain/EmsAmmeterData.java | 1411 ++++++++++++++++- .../java/com/xzzn/ems/domain/EmsPcsData.java | 4 +- .../ems/domain/vo/AmmeterDataDetailInfo.java | 10 +- .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 4 +- .../impl/FXXDataProcessServiceImpl.java | 205 ++- .../service/impl/SingleSiteServiceImpl.java | 60 +- .../mapper/ems/EmsAmmeterDataMapper.xml | 513 +++++- 9 files changed, 2093 insertions(+), 124 deletions(-) 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 be2e0e2..0ff205f 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 @@ -1,6 +1,7 @@ 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; @@ -56,8 +57,8 @@ public class EmsSiteConfigController extends BaseController{ * 获取设备详细信息 */ @GetMapping("/getDeviceDetailInfo") - public EmsDevicesSetting getDeviceDetailInfo(@RequestParam String deviceId) + public AjaxResult getDeviceDetailInfo(@RequestParam String deviceId) { - return iEmsDeviceSettingService.getDeviceDetailInfo(deviceId); + return success(iEmsDeviceSettingService.getDeviceDetailInfo(deviceId)); } } diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 79cd77f..986830b 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -31,4 +31,9 @@ public class RedisKeyConstants * battery单体电池数据 redis key */ public static final String BATTERY = "BATTERY_"; + + /** + * 电表数据 redis key + */ + public static final String AMMETER = "AMMETER_"; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java index 7509603..b3b6b61 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * 总数据对象 ems_ammeter_data * * @author xzzn - * @date 2025-06-29 + * @date 2025-07-03 */ public class EmsAmmeterData extends BaseEntity { @@ -22,33 +22,245 @@ public class EmsAmmeterData extends BaseEntity private Long id; /** 数据更新时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date dataUpdateTime; - /** 类别 */ - @Excel(name = "类别") - private String category; + /** 当前组合有功总电能 */ + @Excel(name = "当前组合有功总电能") + private BigDecimal currentCombActiveTotal; - /** 总 (kWh) */ - @Excel(name = "总 (kWh)") - private BigDecimal totalKwh; + /** 当前组合有功尖电能 */ + @Excel(name = "当前组合有功尖电能") + private BigDecimal currentCombActivePeak; - /** 尖 (kWh) */ - @Excel(name = "尖 (kWh)") - private BigDecimal sharpKwh; + /** 当前组合有功峰电能 */ + @Excel(name = "当前组合有功峰电能") + private BigDecimal currentCombActiveHigh; - /** 峰 (kWh) */ - @Excel(name = "峰 (kWh)") - private BigDecimal peakKwh; + /** 当前组合有功平电能 */ + @Excel(name = "当前组合有功平电能") + private BigDecimal currentCombActiveFlat; - /** 平 (kWh) */ - @Excel(name = "平 (kWh)") - private BigDecimal flatKwh; + /** 当前组合有功谷电能 */ + @Excel(name = "当前组合有功谷电能") + private BigDecimal currentCombActiveValley; - /** 谷 (kWh) */ - @Excel(name = "谷 (kWh)") - private BigDecimal valleyKwh; + /** 当前正向总有功电能 */ + @Excel(name = "当前正向总有功电能") + private BigDecimal currentForwardActiveTotal; + + /** 当前正向有功尖电能 */ + @Excel(name = "当前正向有功尖电能") + private BigDecimal currentForwardActivePeak; + + /** 当前正向有功峰电能 */ + @Excel(name = "当前正向有功峰电能") + private BigDecimal currentForwardActiveHigh; + + /** 当前正向有功平电能 */ + @Excel(name = "当前正向有功平电能") + private BigDecimal currentForwardActiveFlat; + + /** 当前正向有功谷电能 */ + @Excel(name = "当前正向有功谷电能") + private BigDecimal currentForwardActiveValley; + + /** 当前反向总有功电能 */ + @Excel(name = "当前反向总有功电能") + private BigDecimal currentReverseActiveTotal; + + /** 当前反向有功尖电能 */ + @Excel(name = "当前反向有功尖电能") + private BigDecimal currentReverseActivePeak; + + /** 当前反向有功峰电能 */ + @Excel(name = "当前反向有功峰电能") + private BigDecimal currentReverseActiveHigh; + + /** 当前反向有功平电能 */ + @Excel(name = "当前反向有功平电能") + private BigDecimal currentReverseActiveFlat; + + /** 当前反向有功谷电能 */ + @Excel(name = "当前反向有功谷电能") + private BigDecimal currentReverseActiveValley; + + /** 当前组合无功总电能 */ + @Excel(name = "当前组合无功总电能") + private BigDecimal currentCombReactiveTotal; + + /** 当前组合无功尖电能 */ + @Excel(name = "当前组合无功尖电能") + private BigDecimal currentCombReactivePeak; + + /** 当前组合无功峰电能 */ + @Excel(name = "当前组合无功峰电能") + private BigDecimal currentCombReactiveHigh; + + /** 当前组合无功平电能 */ + @Excel(name = "当前组合无功平电能") + private BigDecimal currentCombReactiveFlat; + + /** 当前组合无功谷电能 */ + @Excel(name = "当前组合无功谷电能") + private BigDecimal currentCombReactiveValley; + + /** 当前正向总无功电能 */ + @Excel(name = "当前正向总无功电能") + private BigDecimal currentForwardReactiveTotal; + + /** 当前正向无功尖电能 */ + @Excel(name = "当前正向无功尖电能") + private BigDecimal currentForwardReactivePeak; + + /** 当前正向无功峰电能 */ + @Excel(name = "当前正向无功峰电能") + private BigDecimal currentForwardReactiveHigh; + + /** 当前正向无功平电能 */ + @Excel(name = "当前正向无功平电能") + private BigDecimal currentForwardReactiveFlat; + + /** 当前正向无功谷电能 */ + @Excel(name = "当前正向无功谷电能") + private BigDecimal currentForwardReactiveValley; + + /** 当前反向总无功电能 */ + @Excel(name = "当前反向总无功电能") + private BigDecimal currentReverseReactiveTotal; + + /** 当前反向无功尖电能 */ + @Excel(name = "当前反向无功尖电能") + private BigDecimal currentReverseReactivePeak; + + /** 当前反向无功峰电能 */ + @Excel(name = "当前反向无功峰电能") + private BigDecimal currentReverseReactiveHigh; + + /** 当前反向无功平电能 */ + @Excel(name = "当前反向无功平电能") + private BigDecimal currentReverseReactiveFlat; + + /** 当前反向无功谷电能 */ + @Excel(name = "当前反向无功谷电能") + private BigDecimal currentReverseReactiveValley; + + /** A相电压 */ + @Excel(name = "A相电压") + private BigDecimal phaseAVoltage; + + /** B相电压 */ + @Excel(name = "B相电压") + private BigDecimal phaseBVoltage; + + /** C相电压 */ + @Excel(name = "C相电压") + private BigDecimal phaseCVoltage; + + /** A相电流 */ + @Excel(name = "A相电流") + private BigDecimal phaseACurrent; + + /** B相电流 */ + @Excel(name = "B相电流") + private BigDecimal phaseBCurrent; + + /** C相电流 */ + @Excel(name = "C相电流") + private BigDecimal phaseCCurrent; + + /** 频率 */ + @Excel(name = "频率") + private BigDecimal frequency; + + /** A-B线电压 */ + @Excel(name = "A-B线电压") + private BigDecimal abLineVoltage; + + /** C-B线电压 */ + @Excel(name = "C-B线电压") + private BigDecimal cbLineVoltage; + + /** A-C线电压 */ + @Excel(name = "A-C线电压") + private BigDecimal acLineVoltage; + + /** 正向有功最大需量 */ + @Excel(name = "正向有功最大需量") + private BigDecimal forwardAcMaxDemand; + + /** 反向有功最大需量 */ + @Excel(name = "反向有功最大需量") + private BigDecimal reverseAcMaxDemand; + + /** A相有功功率 */ + @Excel(name = "A相有功功率") + private BigDecimal phaseAActivePower; + + /** B相有功功率 */ + @Excel(name = "B相有功功率") + private BigDecimal phaseBActivePower; + + /** C相有功功率 */ + @Excel(name = "C相有功功率") + private BigDecimal phaseCActivePower; + + /** 总有功功率 */ + @Excel(name = "总有功功率") + private BigDecimal totalActivePower; + + /** A相无功功率 */ + @Excel(name = "A相无功功率") + private BigDecimal phaseAReactivePower; + + /** B相无功功率 */ + @Excel(name = "B相无功功率") + private BigDecimal phaseBReactivePower; + + /** C相无功功率 */ + @Excel(name = "C相无功功率") + private BigDecimal phaseCReactivePower; + + /** 总无功功率 */ + @Excel(name = "总无功功率") + private BigDecimal totalReactivePower; + + /** A相视在功率 */ + @Excel(name = "A相视在功率") + private BigDecimal phaseAApparentPower; + + /** B相视在功率 */ + @Excel(name = "B相视在功率") + private BigDecimal phaseBApparentPower; + + /** C相视在功率 */ + @Excel(name = "C相视在功率") + private BigDecimal phaseCApparentPower; + + /** 总视在功率 */ + @Excel(name = "总视在功率") + private BigDecimal totalApparentPower; + + /** A相功率因数 */ + @Excel(name = "A相功率因数") + private BigDecimal phaseAPowerFactor; + + /** B相功率因数 */ + @Excel(name = "B相功率因数") + private BigDecimal phaseBPowerFactor; + + /** C相功率因数 */ + @Excel(name = "C相功率因数") + private BigDecimal phaseCPowerFactor; + + /** 总功率因数 */ + @Excel(name = "总功率因数") + private BigDecimal totalPowerFactor; + + /** 当日正向有功最大需量 */ + @Excel(name = "当日正向有功最大需量") + private BigDecimal dailyForwardMaxDemand; /** 站点id */ @Excel(name = "站点id") @@ -58,6 +270,142 @@ public class EmsAmmeterData extends BaseEntity @Excel(name = "设备唯一标识符") private String deviceId; + /** 二次-AB 线电压 */ + @Excel(name = "二次-AB 线电压") + private BigDecimal secondaryAbLineVoltage; + + /** 二次-A 相电流 */ + @Excel(name = "二次-A 相电流") + private BigDecimal secondaryAPhaseCurrent; + + /** 二次-A 相电压 */ + @Excel(name = "二次-A 相电压") + private BigDecimal secondaryAPhaseVoltage; + + /** 二次-A 相功率因数 */ + @Excel(name = "二次-A 相功率因数") + private BigDecimal secondaryAPowerFactor; + + /** 二次-A 相视在功率 */ + @Excel(name = "二次-A 相视在功率") + private BigDecimal secondaryAApparentPower; + + /** 二次-A 相无功功率 */ + @Excel(name = "二次-A 相无功功率") + private BigDecimal secondaryAReactivePower; + + /** 二次-A 相有功功率 */ + @Excel(name = "二次-A 相有功功率") + private BigDecimal secondaryAActivePower; + + /** 二次-BC 线电压 */ + @Excel(name = "二次-BC 线电压") + private BigDecimal secondaryBcLineVoltage; + + /** 二次-B 相电流 */ + @Excel(name = "二次-B 相电流") + private BigDecimal secondaryBPhaseCurrent; + + /** 二次-B 相电压 */ + @Excel(name = "二次-B 相电压") + private BigDecimal secondaryBPhaseVoltage; + + /** 二次-B 相功率因数 */ + @Excel(name = "二次-B 相功率因数") + private BigDecimal secondaryBPowerFactor; + + /** 二次-B 相视在功率 */ + @Excel(name = "二次-B 相视在功率") + private BigDecimal secondaryBApparentPower; + + /** 二次-B 相无功功率 */ + @Excel(name = "二次-B 相无功功率") + private BigDecimal secondaryBReactivePower; + + /** 二次-B 相有功功率 */ + @Excel(name = "二次-B 相有功功率") + private BigDecimal secondaryBActivePower; + + /** 二次-CA 线电压 */ + @Excel(name = "二次-CA 线电压") + private BigDecimal secondaryCaLineVoltage; + + /** 二次-C 相电流 */ + @Excel(name = "二次-C 相电流") + private BigDecimal secondaryCPhaseCurrent; + + /** 二次-C 相电压 */ + @Excel(name = "二次-C 相电压") + private BigDecimal secondaryCPhaseVoltage; + + /** 二次-C 相功率因数 */ + @Excel(name = "二次-C 相功率因数") + private BigDecimal secondaryCPowerFactor; + + /** 二次-C 相视在功率 */ + @Excel(name = "二次-C 相视在功率") + private BigDecimal secondaryCApparentPower; + + /** 二次-C 相无功功率 */ + @Excel(name = "二次-C 相无功功率") + private BigDecimal secondaryCReactivePower; + + /** 二次-C 相有功功率 */ + @Excel(name = "二次-C 相有功功率") + private BigDecimal secondaryCActivePower; + + /** 二次-电网频率 */ + @Excel(name = "二次-电网频率") + private BigDecimal secondaryGridFrequency; + + /** 二次-反向无功电能 */ + @Excel(name = "二次-反向无功电能") + private BigDecimal secondaryReverseReactiveEnergy; + + /** 二次-负向有功电能 */ + @Excel(name = "二次-负向有功电能") + private BigDecimal secondaryNegativeActiveEnergy; + + /** 二次-总功率因数 */ + @Excel(name = "二次-总功率因数") + private BigDecimal secondaryTotalPowerFactor; + + /** 二次-总视在功率 */ + @Excel(name = "二次-总视在功率") + private BigDecimal secondaryTotalApparentPower; + + /** 二次-总无功功率 */ + @Excel(name = "二次-总无功功率") + private BigDecimal secondaryTotalReactivePower; + + /** 二次-正向无功电能 */ + @Excel(name = "二次-正向无功电能") + private BigDecimal secondaryPositiveReactiveEnergy; + + /** 二次-正向有功电能 */ + @Excel(name = "二次-正向有功电能") + private BigDecimal secondaryPositiveActiveEnergy; + + /** 二次-总有功功率 */ + @Excel(name = "二次-总有功功率") + private BigDecimal secondaryTotalActivePower; + + /** 反向无功电能 EQ- */ + @Excel(name = "反向无功电能 EQ-") + private BigDecimal reverseReactiveEnergyEqMinus; + + /** 反向有功电能 EP- */ + @Excel(name = "反向有功电能 EP-") + private BigDecimal reverseActiveEnergyEpMinus; + + /** 正向无功电能 EQ+ */ + @Excel(name = "正向无功电能 EQ+") + private BigDecimal positiveReactiveEnergyEqPlus; + + /** 正向有功电能 EP+ */ + @Excel(name = "正向有功电能 EP+") + private BigDecimal positiveActiveEnergyEpPlus; + public void setId(Long id) { this.id = id; @@ -78,64 +426,594 @@ public class EmsAmmeterData extends BaseEntity return dataUpdateTime; } - public void setCategory(String category) + public void setCurrentCombActiveTotal(BigDecimal currentCombActiveTotal) { - this.category = category; + this.currentCombActiveTotal = currentCombActiveTotal; } - public String getCategory() + public BigDecimal getCurrentCombActiveTotal() { - return category; + return currentCombActiveTotal; } - public void setTotalKwh(BigDecimal totalKwh) + public void setCurrentCombActivePeak(BigDecimal currentCombActivePeak) { - this.totalKwh = totalKwh; + this.currentCombActivePeak = currentCombActivePeak; } - public BigDecimal getTotalKwh() + public BigDecimal getCurrentCombActivePeak() { - return totalKwh; + return currentCombActivePeak; } - public void setSharpKwh(BigDecimal sharpKwh) + public void setCurrentCombActiveHigh(BigDecimal currentCombActiveHigh) { - this.sharpKwh = sharpKwh; + this.currentCombActiveHigh = currentCombActiveHigh; } - public BigDecimal getSharpKwh() + public BigDecimal getCurrentCombActiveHigh() { - return sharpKwh; + return currentCombActiveHigh; } - public void setPeakKwh(BigDecimal peakKwh) + public void setCurrentCombActiveFlat(BigDecimal currentCombActiveFlat) { - this.peakKwh = peakKwh; + this.currentCombActiveFlat = currentCombActiveFlat; } - public BigDecimal getPeakKwh() + public BigDecimal getCurrentCombActiveFlat() { - return peakKwh; + return currentCombActiveFlat; } - public void setFlatKwh(BigDecimal flatKwh) + public void setCurrentCombActiveValley(BigDecimal currentCombActiveValley) { - this.flatKwh = flatKwh; + this.currentCombActiveValley = currentCombActiveValley; } - public BigDecimal getFlatKwh() + public BigDecimal getCurrentCombActiveValley() { - return flatKwh; + return currentCombActiveValley; } - public void setValleyKwh(BigDecimal valleyKwh) + public void setCurrentForwardActiveTotal(BigDecimal currentForwardActiveTotal) { - this.valleyKwh = valleyKwh; + this.currentForwardActiveTotal = currentForwardActiveTotal; } - public BigDecimal getValleyKwh() + public BigDecimal getCurrentForwardActiveTotal() { - return valleyKwh; + return currentForwardActiveTotal; + } + + public void setCurrentForwardActivePeak(BigDecimal currentForwardActivePeak) + { + this.currentForwardActivePeak = currentForwardActivePeak; + } + + public BigDecimal getCurrentForwardActivePeak() + { + return currentForwardActivePeak; + } + + public void setCurrentForwardActiveHigh(BigDecimal currentForwardActiveHigh) + { + this.currentForwardActiveHigh = currentForwardActiveHigh; + } + + public BigDecimal getCurrentForwardActiveHigh() + { + return currentForwardActiveHigh; + } + + public void setCurrentForwardActiveFlat(BigDecimal currentForwardActiveFlat) + { + this.currentForwardActiveFlat = currentForwardActiveFlat; + } + + public BigDecimal getCurrentForwardActiveFlat() + { + return currentForwardActiveFlat; + } + + public void setCurrentForwardActiveValley(BigDecimal currentForwardActiveValley) + { + this.currentForwardActiveValley = currentForwardActiveValley; + } + + public BigDecimal getCurrentForwardActiveValley() + { + return currentForwardActiveValley; + } + + public void setCurrentReverseActiveTotal(BigDecimal currentReverseActiveTotal) + { + this.currentReverseActiveTotal = currentReverseActiveTotal; + } + + public BigDecimal getCurrentReverseActiveTotal() + { + return currentReverseActiveTotal; + } + + public void setCurrentReverseActivePeak(BigDecimal currentReverseActivePeak) + { + this.currentReverseActivePeak = currentReverseActivePeak; + } + + public BigDecimal getCurrentReverseActivePeak() + { + return currentReverseActivePeak; + } + + public void setCurrentReverseActiveHigh(BigDecimal currentReverseActiveHigh) + { + this.currentReverseActiveHigh = currentReverseActiveHigh; + } + + public BigDecimal getCurrentReverseActiveHigh() + { + return currentReverseActiveHigh; + } + + public void setCurrentReverseActiveFlat(BigDecimal currentReverseActiveFlat) + { + this.currentReverseActiveFlat = currentReverseActiveFlat; + } + + public BigDecimal getCurrentReverseActiveFlat() + { + return currentReverseActiveFlat; + } + + public void setCurrentReverseActiveValley(BigDecimal currentReverseActiveValley) + { + this.currentReverseActiveValley = currentReverseActiveValley; + } + + public BigDecimal getCurrentReverseActiveValley() + { + return currentReverseActiveValley; + } + + public void setCurrentCombReactiveTotal(BigDecimal currentCombReactiveTotal) + { + this.currentCombReactiveTotal = currentCombReactiveTotal; + } + + public BigDecimal getCurrentCombReactiveTotal() + { + return currentCombReactiveTotal; + } + + public void setCurrentCombReactivePeak(BigDecimal currentCombReactivePeak) + { + this.currentCombReactivePeak = currentCombReactivePeak; + } + + public BigDecimal getCurrentCombReactivePeak() + { + return currentCombReactivePeak; + } + + public void setCurrentCombReactiveHigh(BigDecimal currentCombReactiveHigh) + { + this.currentCombReactiveHigh = currentCombReactiveHigh; + } + + public BigDecimal getCurrentCombReactiveHigh() + { + return currentCombReactiveHigh; + } + + public void setCurrentCombReactiveFlat(BigDecimal currentCombReactiveFlat) + { + this.currentCombReactiveFlat = currentCombReactiveFlat; + } + + public BigDecimal getCurrentCombReactiveFlat() + { + return currentCombReactiveFlat; + } + + public void setCurrentCombReactiveValley(BigDecimal currentCombReactiveValley) + { + this.currentCombReactiveValley = currentCombReactiveValley; + } + + public BigDecimal getCurrentCombReactiveValley() + { + return currentCombReactiveValley; + } + + public void setCurrentForwardReactiveTotal(BigDecimal currentForwardReactiveTotal) + { + this.currentForwardReactiveTotal = currentForwardReactiveTotal; + } + + public BigDecimal getCurrentForwardReactiveTotal() + { + return currentForwardReactiveTotal; + } + + public void setCurrentForwardReactivePeak(BigDecimal currentForwardReactivePeak) + { + this.currentForwardReactivePeak = currentForwardReactivePeak; + } + + public BigDecimal getCurrentForwardReactivePeak() + { + return currentForwardReactivePeak; + } + + public void setCurrentForwardReactiveHigh(BigDecimal currentForwardReactiveHigh) + { + this.currentForwardReactiveHigh = currentForwardReactiveHigh; + } + + public BigDecimal getCurrentForwardReactiveHigh() + { + return currentForwardReactiveHigh; + } + + public void setCurrentForwardReactiveFlat(BigDecimal currentForwardReactiveFlat) + { + this.currentForwardReactiveFlat = currentForwardReactiveFlat; + } + + public BigDecimal getCurrentForwardReactiveFlat() + { + return currentForwardReactiveFlat; + } + + public void setCurrentForwardReactiveValley(BigDecimal currentForwardReactiveValley) + { + this.currentForwardReactiveValley = currentForwardReactiveValley; + } + + public BigDecimal getCurrentForwardReactiveValley() + { + return currentForwardReactiveValley; + } + + public void setCurrentReverseReactiveTotal(BigDecimal currentReverseReactiveTotal) + { + this.currentReverseReactiveTotal = currentReverseReactiveTotal; + } + + public BigDecimal getCurrentReverseReactiveTotal() + { + return currentReverseReactiveTotal; + } + + public void setCurrentReverseReactivePeak(BigDecimal currentReverseReactivePeak) + { + this.currentReverseReactivePeak = currentReverseReactivePeak; + } + + public BigDecimal getCurrentReverseReactivePeak() + { + return currentReverseReactivePeak; + } + + public void setCurrentReverseReactiveHigh(BigDecimal currentReverseReactiveHigh) + { + this.currentReverseReactiveHigh = currentReverseReactiveHigh; + } + + public BigDecimal getCurrentReverseReactiveHigh() + { + return currentReverseReactiveHigh; + } + + public void setCurrentReverseReactiveFlat(BigDecimal currentReverseReactiveFlat) + { + this.currentReverseReactiveFlat = currentReverseReactiveFlat; + } + + public BigDecimal getCurrentReverseReactiveFlat() + { + return currentReverseReactiveFlat; + } + + public void setCurrentReverseReactiveValley(BigDecimal currentReverseReactiveValley) + { + this.currentReverseReactiveValley = currentReverseReactiveValley; + } + + public BigDecimal getCurrentReverseReactiveValley() + { + return currentReverseReactiveValley; + } + + public void setPhaseAVoltage(BigDecimal phaseAVoltage) + { + this.phaseAVoltage = phaseAVoltage; + } + + public BigDecimal getPhaseAVoltage() + { + return phaseAVoltage; + } + + public void setPhaseBVoltage(BigDecimal phaseBVoltage) + { + this.phaseBVoltage = phaseBVoltage; + } + + public BigDecimal getPhaseBVoltage() + { + return phaseBVoltage; + } + + public void setPhaseCVoltage(BigDecimal phaseCVoltage) + { + this.phaseCVoltage = phaseCVoltage; + } + + public BigDecimal getPhaseCVoltage() + { + return phaseCVoltage; + } + + public void setPhaseACurrent(BigDecimal phaseACurrent) + { + this.phaseACurrent = phaseACurrent; + } + + public BigDecimal getPhaseACurrent() + { + return phaseACurrent; + } + + public void setPhaseBCurrent(BigDecimal phaseBCurrent) + { + this.phaseBCurrent = phaseBCurrent; + } + + public BigDecimal getPhaseBCurrent() + { + return phaseBCurrent; + } + + public void setPhaseCCurrent(BigDecimal phaseCCurrent) + { + this.phaseCCurrent = phaseCCurrent; + } + + public BigDecimal getPhaseCCurrent() + { + return phaseCCurrent; + } + + public void setFrequency(BigDecimal frequency) + { + this.frequency = frequency; + } + + public BigDecimal getFrequency() + { + return frequency; + } + + public void setAbLineVoltage(BigDecimal abLineVoltage) + { + this.abLineVoltage = abLineVoltage; + } + + public BigDecimal getAbLineVoltage() + { + return abLineVoltage; + } + + public void setCbLineVoltage(BigDecimal cbLineVoltage) + { + this.cbLineVoltage = cbLineVoltage; + } + + public BigDecimal getCbLineVoltage() + { + return cbLineVoltage; + } + + public void setAcLineVoltage(BigDecimal acLineVoltage) + { + this.acLineVoltage = acLineVoltage; + } + + public BigDecimal getAcLineVoltage() + { + return acLineVoltage; + } + + public void setForwardAcMaxDemand(BigDecimal forwardAcMaxDemand) + { + this.forwardAcMaxDemand = forwardAcMaxDemand; + } + + public BigDecimal getForwardAcMaxDemand() + { + return forwardAcMaxDemand; + } + + public void setReverseAcMaxDemand(BigDecimal reverseAcMaxDemand) + { + this.reverseAcMaxDemand = reverseAcMaxDemand; + } + + public BigDecimal getReverseAcMaxDemand() + { + return reverseAcMaxDemand; + } + + public void setPhaseAActivePower(BigDecimal phaseAActivePower) + { + this.phaseAActivePower = phaseAActivePower; + } + + public BigDecimal getPhaseAActivePower() + { + return phaseAActivePower; + } + + public void setPhaseBActivePower(BigDecimal phaseBActivePower) + { + this.phaseBActivePower = phaseBActivePower; + } + + public BigDecimal getPhaseBActivePower() + { + return phaseBActivePower; + } + + public void setPhaseCActivePower(BigDecimal phaseCActivePower) + { + this.phaseCActivePower = phaseCActivePower; + } + + public BigDecimal getPhaseCActivePower() + { + return phaseCActivePower; + } + + public void setTotalActivePower(BigDecimal totalActivePower) + { + this.totalActivePower = totalActivePower; + } + + public BigDecimal getTotalActivePower() + { + return totalActivePower; + } + + public void setPhaseAReactivePower(BigDecimal phaseAReactivePower) + { + this.phaseAReactivePower = phaseAReactivePower; + } + + public BigDecimal getPhaseAReactivePower() + { + return phaseAReactivePower; + } + + public void setPhaseBReactivePower(BigDecimal phaseBReactivePower) + { + this.phaseBReactivePower = phaseBReactivePower; + } + + public BigDecimal getPhaseBReactivePower() + { + return phaseBReactivePower; + } + + public void setPhaseCReactivePower(BigDecimal phaseCReactivePower) + { + this.phaseCReactivePower = phaseCReactivePower; + } + + public BigDecimal getPhaseCReactivePower() + { + return phaseCReactivePower; + } + + public void setTotalReactivePower(BigDecimal totalReactivePower) + { + this.totalReactivePower = totalReactivePower; + } + + public BigDecimal getTotalReactivePower() + { + return totalReactivePower; + } + + public void setPhaseAApparentPower(BigDecimal phaseAApparentPower) + { + this.phaseAApparentPower = phaseAApparentPower; + } + + public BigDecimal getPhaseAApparentPower() + { + return phaseAApparentPower; + } + + public void setPhaseBApparentPower(BigDecimal phaseBApparentPower) + { + this.phaseBApparentPower = phaseBApparentPower; + } + + public BigDecimal getPhaseBApparentPower() + { + return phaseBApparentPower; + } + + public void setPhaseCApparentPower(BigDecimal phaseCApparentPower) + { + this.phaseCApparentPower = phaseCApparentPower; + } + + public BigDecimal getPhaseCApparentPower() + { + return phaseCApparentPower; + } + + public void setTotalApparentPower(BigDecimal totalApparentPower) + { + this.totalApparentPower = totalApparentPower; + } + + public BigDecimal getTotalApparentPower() + { + return totalApparentPower; + } + + public void setPhaseAPowerFactor(BigDecimal phaseAPowerFactor) + { + this.phaseAPowerFactor = phaseAPowerFactor; + } + + public BigDecimal getPhaseAPowerFactor() + { + return phaseAPowerFactor; + } + + public void setPhaseBPowerFactor(BigDecimal phaseBPowerFactor) + { + this.phaseBPowerFactor = phaseBPowerFactor; + } + + public BigDecimal getPhaseBPowerFactor() + { + return phaseBPowerFactor; + } + + public void setPhaseCPowerFactor(BigDecimal phaseCPowerFactor) + { + this.phaseCPowerFactor = phaseCPowerFactor; + } + + public BigDecimal getPhaseCPowerFactor() + { + return phaseCPowerFactor; + } + + public void setTotalPowerFactor(BigDecimal totalPowerFactor) + { + this.totalPowerFactor = totalPowerFactor; + } + + public BigDecimal getTotalPowerFactor() + { + return totalPowerFactor; + } + + public void setDailyForwardMaxDemand(BigDecimal dailyForwardMaxDemand) + { + this.dailyForwardMaxDemand = dailyForwardMaxDemand; + } + + public BigDecimal getDailyForwardMaxDemand() + { + return dailyForwardMaxDemand; } public void setSiteId(String siteId) @@ -158,24 +1036,451 @@ public class EmsAmmeterData extends BaseEntity return deviceId; } + public void setSecondaryAbLineVoltage(BigDecimal secondaryAbLineVoltage) + { + this.secondaryAbLineVoltage = secondaryAbLineVoltage; + } + + public BigDecimal getSecondaryAbLineVoltage() + { + return secondaryAbLineVoltage; + } + + public void setSecondaryAPhaseCurrent(BigDecimal secondaryAPhaseCurrent) + { + this.secondaryAPhaseCurrent = secondaryAPhaseCurrent; + } + + public BigDecimal getSecondaryAPhaseCurrent() + { + return secondaryAPhaseCurrent; + } + + public void setSecondaryAPhaseVoltage(BigDecimal secondaryAPhaseVoltage) + { + this.secondaryAPhaseVoltage = secondaryAPhaseVoltage; + } + + public BigDecimal getSecondaryAPhaseVoltage() + { + return secondaryAPhaseVoltage; + } + + public void setSecondaryAPowerFactor(BigDecimal secondaryAPowerFactor) + { + this.secondaryAPowerFactor = secondaryAPowerFactor; + } + + public BigDecimal getSecondaryAPowerFactor() + { + return secondaryAPowerFactor; + } + + public void setSecondaryAApparentPower(BigDecimal secondaryAApparentPower) + { + this.secondaryAApparentPower = secondaryAApparentPower; + } + + public BigDecimal getSecondaryAApparentPower() + { + return secondaryAApparentPower; + } + + public void setSecondaryAReactivePower(BigDecimal secondaryAReactivePower) + { + this.secondaryAReactivePower = secondaryAReactivePower; + } + + public BigDecimal getSecondaryAReactivePower() + { + return secondaryAReactivePower; + } + + public void setSecondaryAActivePower(BigDecimal secondaryAActivePower) + { + this.secondaryAActivePower = secondaryAActivePower; + } + + public BigDecimal getSecondaryAActivePower() + { + return secondaryAActivePower; + } + + public void setSecondaryBcLineVoltage(BigDecimal secondaryBcLineVoltage) + { + this.secondaryBcLineVoltage = secondaryBcLineVoltage; + } + + public BigDecimal getSecondaryBcLineVoltage() + { + return secondaryBcLineVoltage; + } + + public void setSecondaryBPhaseCurrent(BigDecimal secondaryBPhaseCurrent) + { + this.secondaryBPhaseCurrent = secondaryBPhaseCurrent; + } + + public BigDecimal getSecondaryBPhaseCurrent() + { + return secondaryBPhaseCurrent; + } + + public void setSecondaryBPhaseVoltage(BigDecimal secondaryBPhaseVoltage) + { + this.secondaryBPhaseVoltage = secondaryBPhaseVoltage; + } + + public BigDecimal getSecondaryBPhaseVoltage() + { + return secondaryBPhaseVoltage; + } + + public void setSecondaryBPowerFactor(BigDecimal secondaryBPowerFactor) + { + this.secondaryBPowerFactor = secondaryBPowerFactor; + } + + public BigDecimal getSecondaryBPowerFactor() + { + return secondaryBPowerFactor; + } + + public void setSecondaryBApparentPower(BigDecimal secondaryBApparentPower) + { + this.secondaryBApparentPower = secondaryBApparentPower; + } + + public BigDecimal getSecondaryBApparentPower() + { + return secondaryBApparentPower; + } + + public void setSecondaryBReactivePower(BigDecimal secondaryBReactivePower) + { + this.secondaryBReactivePower = secondaryBReactivePower; + } + + public BigDecimal getSecondaryBReactivePower() + { + return secondaryBReactivePower; + } + + public void setSecondaryBActivePower(BigDecimal secondaryBActivePower) + { + this.secondaryBActivePower = secondaryBActivePower; + } + + public BigDecimal getSecondaryBActivePower() + { + return secondaryBActivePower; + } + + public void setSecondaryCaLineVoltage(BigDecimal secondaryCaLineVoltage) + { + this.secondaryCaLineVoltage = secondaryCaLineVoltage; + } + + public BigDecimal getSecondaryCaLineVoltage() + { + return secondaryCaLineVoltage; + } + + public void setSecondaryCPhaseCurrent(BigDecimal secondaryCPhaseCurrent) + { + this.secondaryCPhaseCurrent = secondaryCPhaseCurrent; + } + + public BigDecimal getSecondaryCPhaseCurrent() + { + return secondaryCPhaseCurrent; + } + + public void setSecondaryCPhaseVoltage(BigDecimal secondaryCPhaseVoltage) + { + this.secondaryCPhaseVoltage = secondaryCPhaseVoltage; + } + + public BigDecimal getSecondaryCPhaseVoltage() + { + return secondaryCPhaseVoltage; + } + + public void setSecondaryCPowerFactor(BigDecimal secondaryCPowerFactor) + { + this.secondaryCPowerFactor = secondaryCPowerFactor; + } + + public BigDecimal getSecondaryCPowerFactor() + { + return secondaryCPowerFactor; + } + + public void setSecondaryCApparentPower(BigDecimal secondaryCApparentPower) + { + this.secondaryCApparentPower = secondaryCApparentPower; + } + + public BigDecimal getSecondaryCApparentPower() + { + return secondaryCApparentPower; + } + + public void setSecondaryCReactivePower(BigDecimal secondaryCReactivePower) + { + this.secondaryCReactivePower = secondaryCReactivePower; + } + + public BigDecimal getSecondaryCReactivePower() + { + return secondaryCReactivePower; + } + + public void setSecondaryCActivePower(BigDecimal secondaryCActivePower) + { + this.secondaryCActivePower = secondaryCActivePower; + } + + public BigDecimal getSecondaryCActivePower() + { + return secondaryCActivePower; + } + + public void setSecondaryGridFrequency(BigDecimal secondaryGridFrequency) + { + this.secondaryGridFrequency = secondaryGridFrequency; + } + + public BigDecimal getSecondaryGridFrequency() + { + return secondaryGridFrequency; + } + + public void setSecondaryReverseReactiveEnergy(BigDecimal secondaryReverseReactiveEnergy) + { + this.secondaryReverseReactiveEnergy = secondaryReverseReactiveEnergy; + } + + public BigDecimal getSecondaryReverseReactiveEnergy() + { + return secondaryReverseReactiveEnergy; + } + + public void setSecondaryNegativeActiveEnergy(BigDecimal secondaryNegativeActiveEnergy) + { + this.secondaryNegativeActiveEnergy = secondaryNegativeActiveEnergy; + } + + public BigDecimal getSecondaryNegativeActiveEnergy() + { + return secondaryNegativeActiveEnergy; + } + + public void setSecondaryTotalPowerFactor(BigDecimal secondaryTotalPowerFactor) + { + this.secondaryTotalPowerFactor = secondaryTotalPowerFactor; + } + + public BigDecimal getSecondaryTotalPowerFactor() + { + return secondaryTotalPowerFactor; + } + + public void setSecondaryTotalApparentPower(BigDecimal secondaryTotalApparentPower) + { + this.secondaryTotalApparentPower = secondaryTotalApparentPower; + } + + public BigDecimal getSecondaryTotalApparentPower() + { + return secondaryTotalApparentPower; + } + + public void setSecondaryTotalReactivePower(BigDecimal secondaryTotalReactivePower) + { + this.secondaryTotalReactivePower = secondaryTotalReactivePower; + } + + public BigDecimal getSecondaryTotalReactivePower() + { + return secondaryTotalReactivePower; + } + + public void setSecondaryPositiveReactiveEnergy(BigDecimal secondaryPositiveReactiveEnergy) + { + this.secondaryPositiveReactiveEnergy = secondaryPositiveReactiveEnergy; + } + + public BigDecimal getSecondaryPositiveReactiveEnergy() + { + return secondaryPositiveReactiveEnergy; + } + + public void setSecondaryPositiveActiveEnergy(BigDecimal secondaryPositiveActiveEnergy) + { + this.secondaryPositiveActiveEnergy = secondaryPositiveActiveEnergy; + } + + public BigDecimal getSecondaryPositiveActiveEnergy() + { + return secondaryPositiveActiveEnergy; + } + + public void setSecondaryTotalActivePower(BigDecimal secondaryTotalActivePower) + { + this.secondaryTotalActivePower = secondaryTotalActivePower; + } + + public BigDecimal getSecondaryTotalActivePower() + { + return secondaryTotalActivePower; + } + + public void setReverseReactiveEnergyEqMinus(BigDecimal reverseReactiveEnergyEqMinus) + { + this.reverseReactiveEnergyEqMinus = reverseReactiveEnergyEqMinus; + } + + public BigDecimal getReverseReactiveEnergyEqMinus() + { + return reverseReactiveEnergyEqMinus; + } + + public void setReverseActiveEnergyEpMinus(BigDecimal reverseActiveEnergyEpMinus) + { + this.reverseActiveEnergyEpMinus = reverseActiveEnergyEpMinus; + } + + public BigDecimal getReverseActiveEnergyEpMinus() + { + return reverseActiveEnergyEpMinus; + } + + public void setPositiveReactiveEnergyEqPlus(BigDecimal positiveReactiveEnergyEqPlus) + { + this.positiveReactiveEnergyEqPlus = positiveReactiveEnergyEqPlus; + } + + public BigDecimal getPositiveReactiveEnergyEqPlus() + { + return positiveReactiveEnergyEqPlus; + } + + public void setPositiveActiveEnergyEpPlus(BigDecimal positiveActiveEnergyEpPlus) + { + this.positiveActiveEnergyEpPlus = positiveActiveEnergyEpPlus; + } + + public BigDecimal getPositiveActiveEnergyEpPlus() + { + return positiveActiveEnergyEpPlus; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("dataUpdateTime", getDataUpdateTime()) - .append("category", getCategory()) - .append("totalKwh", getTotalKwh()) - .append("sharpKwh", getSharpKwh()) - .append("peakKwh", getPeakKwh()) - .append("flatKwh", getFlatKwh()) - .append("valleyKwh", getValleyKwh()) + .append("currentCombActiveTotal", getCurrentCombActiveTotal()) + .append("currentCombActivePeak", getCurrentCombActivePeak()) + .append("currentCombActiveHigh", getCurrentCombActiveHigh()) + .append("currentCombActiveFlat", getCurrentCombActiveFlat()) + .append("currentCombActiveValley", getCurrentCombActiveValley()) + .append("currentForwardActiveTotal", getCurrentForwardActiveTotal()) + .append("currentForwardActivePeak", getCurrentForwardActivePeak()) + .append("currentForwardActiveHigh", getCurrentForwardActiveHigh()) + .append("currentForwardActiveFlat", getCurrentForwardActiveFlat()) + .append("currentForwardActiveValley", getCurrentForwardActiveValley()) + .append("currentReverseActiveTotal", getCurrentReverseActiveTotal()) + .append("currentReverseActivePeak", getCurrentReverseActivePeak()) + .append("currentReverseActiveHigh", getCurrentReverseActiveHigh()) + .append("currentReverseActiveFlat", getCurrentReverseActiveFlat()) + .append("currentReverseActiveValley", getCurrentReverseActiveValley()) + .append("currentCombReactiveTotal", getCurrentCombReactiveTotal()) + .append("currentCombReactivePeak", getCurrentCombReactivePeak()) + .append("currentCombReactiveHigh", getCurrentCombReactiveHigh()) + .append("currentCombReactiveFlat", getCurrentCombReactiveFlat()) + .append("currentCombReactiveValley", getCurrentCombReactiveValley()) + .append("currentForwardReactiveTotal", getCurrentForwardReactiveTotal()) + .append("currentForwardReactivePeak", getCurrentForwardReactivePeak()) + .append("currentForwardReactiveHigh", getCurrentForwardReactiveHigh()) + .append("currentForwardReactiveFlat", getCurrentForwardReactiveFlat()) + .append("currentForwardReactiveValley", getCurrentForwardReactiveValley()) + .append("currentReverseReactiveTotal", getCurrentReverseReactiveTotal()) + .append("currentReverseReactivePeak", getCurrentReverseReactivePeak()) + .append("currentReverseReactiveHigh", getCurrentReverseReactiveHigh()) + .append("currentReverseReactiveFlat", getCurrentReverseReactiveFlat()) + .append("currentReverseReactiveValley", getCurrentReverseReactiveValley()) + .append("phaseAVoltage", getPhaseAVoltage()) + .append("phaseBVoltage", getPhaseBVoltage()) + .append("phaseCVoltage", getPhaseCVoltage()) + .append("phaseACurrent", getPhaseACurrent()) + .append("phaseBCurrent", getPhaseBCurrent()) + .append("phaseCCurrent", getPhaseCCurrent()) + .append("frequency", getFrequency()) + .append("abLineVoltage", getAbLineVoltage()) + .append("cbLineVoltage", getCbLineVoltage()) + .append("acLineVoltage", getAcLineVoltage()) + .append("forwardAcMaxDemand", getForwardAcMaxDemand()) + .append("reverseAcMaxDemand", getReverseAcMaxDemand()) + .append("phaseAActivePower", getPhaseAActivePower()) + .append("phaseBActivePower", getPhaseBActivePower()) + .append("phaseCActivePower", getPhaseCActivePower()) + .append("totalActivePower", getTotalActivePower()) + .append("phaseAReactivePower", getPhaseAReactivePower()) + .append("phaseBReactivePower", getPhaseBReactivePower()) + .append("phaseCReactivePower", getPhaseCReactivePower()) + .append("totalReactivePower", getTotalReactivePower()) + .append("phaseAApparentPower", getPhaseAApparentPower()) + .append("phaseBApparentPower", getPhaseBApparentPower()) + .append("phaseCApparentPower", getPhaseCApparentPower()) + .append("totalApparentPower", getTotalApparentPower()) + .append("phaseAPowerFactor", getPhaseAPowerFactor()) + .append("phaseBPowerFactor", getPhaseBPowerFactor()) + .append("phaseCPowerFactor", getPhaseCPowerFactor()) + .append("totalPowerFactor", getTotalPowerFactor()) + .append("dailyForwardMaxDemand", getDailyForwardMaxDemand()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("remark", getRemark()) - .append("siteId", getSiteId()) - .append("deviceId", getDeviceId()) + .append("secondaryAbLineVoltage", getSecondaryAbLineVoltage()) + .append("secondaryAPhaseCurrent", getSecondaryAPhaseCurrent()) + .append("secondaryAPhaseVoltage", getSecondaryAPhaseVoltage()) + .append("secondaryAPowerFactor", getSecondaryAPowerFactor()) + .append("secondaryAApparentPower", getSecondaryAApparentPower()) + .append("secondaryAReactivePower", getSecondaryAReactivePower()) + .append("secondaryAActivePower", getSecondaryAActivePower()) + .append("secondaryBcLineVoltage", getSecondaryBcLineVoltage()) + .append("secondaryBPhaseCurrent", getSecondaryBPhaseCurrent()) + .append("secondaryBPhaseVoltage", getSecondaryBPhaseVoltage()) + .append("secondaryBPowerFactor", getSecondaryBPowerFactor()) + .append("secondaryBApparentPower", getSecondaryBApparentPower()) + .append("secondaryBReactivePower", getSecondaryBReactivePower()) + .append("secondaryBActivePower", getSecondaryBActivePower()) + .append("secondaryCaLineVoltage", getSecondaryCaLineVoltage()) + .append("secondaryCPhaseCurrent", getSecondaryCPhaseCurrent()) + .append("secondaryCPhaseVoltage", getSecondaryCPhaseVoltage()) + .append("secondaryCPowerFactor", getSecondaryCPowerFactor()) + .append("secondaryCApparentPower", getSecondaryCApparentPower()) + .append("secondaryCReactivePower", getSecondaryCReactivePower()) + .append("secondaryCActivePower", getSecondaryCActivePower()) + .append("secondaryGridFrequency", getSecondaryGridFrequency()) + .append("secondaryReverseReactiveEnergy", getSecondaryReverseReactiveEnergy()) + .append("secondaryNegativeActiveEnergy", getSecondaryNegativeActiveEnergy()) + .append("secondaryTotalPowerFactor", getSecondaryTotalPowerFactor()) + .append("secondaryTotalApparentPower", getSecondaryTotalApparentPower()) + .append("secondaryTotalReactivePower", getSecondaryTotalReactivePower()) + .append("secondaryPositiveReactiveEnergy", getSecondaryPositiveReactiveEnergy()) + .append("secondaryPositiveActiveEnergy", getSecondaryPositiveActiveEnergy()) + .append("secondaryTotalActivePower", getSecondaryTotalActivePower()) + .append("reverseReactiveEnergyEqMinus", getReverseReactiveEnergyEqMinus()) + .append("reverseActiveEnergyEpMinus", getReverseActiveEnergyEpMinus()) + .append("positiveReactiveEnergyEqPlus", getPositiveReactiveEnergyEqPlus()) + .append("positiveActiveEnergyEpPlus", getPositiveActiveEnergyEpPlus()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index 079294f..bebfb80 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -22,8 +22,8 @@ public class EmsPcsData extends BaseEntity private Long id; /** 数据更新时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date dataUpdateTime; /** 工作状态 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java index 797ef63..7ef28fa 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java @@ -12,19 +12,19 @@ public class AmmeterDataDetailInfo private String category; /** 总 (kWh) */ - private BigDecimal totalKwh; + private BigDecimal totalKwh = BigDecimal.ZERO; /** 尖 (kWh) */ - private BigDecimal sharpKwh; + private BigDecimal sharpKwh = BigDecimal.ZERO; /** 峰 (kWh) */ - private BigDecimal peakKwh; + private BigDecimal peakKwh = BigDecimal.ZERO; /** 平 (kWh) */ - private BigDecimal flatKwh; + private BigDecimal flatKwh = BigDecimal.ZERO; /** 谷 (kWh) */ - private BigDecimal valleyKwh; + private BigDecimal valleyKwh = BigDecimal.ZERO; /** 总表设备Id */ private String deviceId; diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index b96b482..d308762 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Param; * 总数据Mapper接口 * * @author xzzn - * @date 2025-06-27 + * @date 2025-07-03 */ public interface EmsAmmeterDataMapper { @@ -66,5 +66,5 @@ public interface EmsAmmeterDataMapper * @param siteId * @return */ - public List getAmmeterDetailInfo(@Param("siteId")String siteId,@Param("deviceId") String deviceId); + public List getAmmeterDetailInfo(@Param("siteId")String siteId, @Param("deviceId") String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 2fe446f..4ffb995 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -17,7 +17,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.math.BigDecimal; import java.util.*; @Service @@ -43,7 +42,10 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { private RedisCache redisCache; @Autowired - private EmsDevicesSettingMapper emsDevicesSettingMapper;; + private EmsDevicesSettingMapper emsDevicesSettingMapper; + + @Autowired + private EmsAmmeterDataMapper emsAmmeterDataMapper;; @Override public void handleFxData(String message) { @@ -61,15 +63,20 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } else if (deviceId.contains("BMSC")) { log.info("BMSC data:"+ jsonData); - batteryCluserDataProcess(deviceId, jsonData); + batteryClusterDataProcess(deviceId, jsonData); batteryDataProcess(deviceId, jsonData); } else if (deviceId.contains("PCS")) { pcsDataProcess(deviceId, jsonData); pcsBranchDataProcess(deviceId, jsonData); + } else if (deviceId.contains("LOAD")) { + loadDataProcess(deviceId, jsonData); + } else if (deviceId.contains("METE")) { + meteDataProcess(deviceId, jsonData); } } } + private void batteryStackDataProcess(String deviceId, String dataJson) { //电池堆 @@ -151,7 +158,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } - private void batteryCluserDataProcess(String deviceId, String dataJson) { + private void batteryClusterDataProcess(String deviceId, String dataJson) { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); @@ -161,7 +168,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { String stackDeviceId = ""; if (up != null && up.size() >0) { stackDeviceId = up.get(0).getParentId(); - if (stackDeviceId != null || stackDeviceId.isEmpty()) { + if (stackDeviceId == null || stackDeviceId.isEmpty()) { stackDeviceId = "1"; } } @@ -239,7 +246,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { String stackDeviceId = ""; if (up != null && up.size() >0) { stackDeviceId = up.get(0).getParentId(); - if (stackDeviceId != null || stackDeviceId.isEmpty()) { + if (stackDeviceId == null || stackDeviceId.isEmpty()) { stackDeviceId = "1"; } } @@ -346,7 +353,6 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } - private void pcsBranchDataProcess(String deviceId, String dataJson) { Map> records = processDataPrefix(JSON.parseObject(dataJson, new TypeReference>() {})); @@ -394,7 +400,192 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { } + private void loadDataProcess(String deviceId, String dataJson) { + //总表 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + EmsAmmeterData dataLoad = new EmsAmmeterData(); + // 更新时间 + dataLoad.setDataUpdateTime(new Date()); + + // 电能设置-组合有功 + dataLoad.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); + dataLoad.setCurrentCombActivePeak(StringUtils.getBigDecimal(obj.get("DQZHYGJDN"))); + dataLoad.setCurrentCombActiveHigh(StringUtils.getBigDecimal(obj.get("DQZHYGFDN"))); + dataLoad.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); + dataLoad.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); + // 电能设置-正向有功 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); + dataLoad.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); + dataLoad.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); + dataLoad.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); + dataLoad.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); + // 电能设置-反向有功 + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); + dataLoad.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); + dataLoad.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); + dataLoad.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); + dataLoad.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))); + // 电能设置-组合无功 + dataLoad.setCurrentCombReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZHWGZDN"))); + dataLoad.setCurrentCombReactivePeak(StringUtils.getBigDecimal(obj.get("DQZHWGJDN"))); + dataLoad.setCurrentCombReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZHWGFDN"))); + dataLoad.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); + dataLoad.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); + // 电能设置-正向无功 + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); + dataLoad.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); + dataLoad.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); + dataLoad.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); + dataLoad.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); + // 电能设置-反向无功 + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); + dataLoad.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); + dataLoad.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); + dataLoad.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); + dataLoad.setCurrentReverseReactiveValley(StringUtils.getBigDecimal(obj.get("DQFXWGGDN"))); + + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("CBXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("ACXDY"))); + + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("PL"))); + + // 功率 有功+总+无功+无总+视在 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataLoad.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); + dataLoad.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); + dataLoad.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + + // 功率因数 + dataLoad.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); + dataLoad.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); + dataLoad.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + + // 需量 + dataLoad.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); + dataLoad.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); + dataLoad.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); + + dataLoad.setCreateBy("system"); + dataLoad.setCreateTime(DateUtils.getNowDate()); + dataLoad.setUpdateBy("system"); + dataLoad.setUpdateTime(DateUtils.getNowDate()); + dataLoad.setSiteId(SITE_ID); + dataLoad.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + } + + private void meteDataProcess(String deviceId, String dataJson) { + + //总表 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + EmsAmmeterData dataLoad = new EmsAmmeterData(); + // 更新时间 + dataLoad.setDataUpdateTime(new Date()); + + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); + + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); + + // 功率 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + + // 二次相关数据 + dataLoad.setSecondaryAbLineVoltage(StringUtils.getBigDecimal(obj.get("ECABXDY"))); + dataLoad.setSecondaryAPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECAXDL"))); + dataLoad.setSecondaryAPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECAXDY"))); + dataLoad.setSecondaryAPowerFactor(StringUtils.getBigDecimal(obj.get("ECAXGLYS"))); + dataLoad.setSecondaryAApparentPower(StringUtils.getBigDecimal(obj.get("ECAXSZGL"))); + dataLoad.setSecondaryAReactivePower(StringUtils.getBigDecimal(obj.get("ECAXWGGL"))); + dataLoad.setSecondaryAActivePower(StringUtils.getBigDecimal(obj.get("ECAXYGGL"))); + dataLoad.setSecondaryBcLineVoltage(StringUtils.getBigDecimal(obj.get("ECBCXDY"))); + dataLoad.setSecondaryBPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECBXDL"))); + dataLoad.setSecondaryBPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECBXDY"))); + dataLoad.setSecondaryBPowerFactor(StringUtils.getBigDecimal(obj.get("ECBXGLYS"))); + dataLoad.setSecondaryBApparentPower(StringUtils.getBigDecimal(obj.get("ECBXSZGL"))); + dataLoad.setSecondaryBReactivePower(StringUtils.getBigDecimal(obj.get("ECBXWGGL"))); + dataLoad.setSecondaryBActivePower(StringUtils.getBigDecimal(obj.get("ECBXYGGL"))); + dataLoad.setSecondaryCaLineVoltage(StringUtils.getBigDecimal(obj.get("ECCAXDY"))); + dataLoad.setSecondaryCPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECCXDL"))); + dataLoad.setSecondaryCPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECCXDY"))); + dataLoad.setSecondaryCPowerFactor(StringUtils.getBigDecimal(obj.get("ECCXGLYS"))); + dataLoad.setSecondaryCApparentPower(StringUtils.getBigDecimal(obj.get("ECCXSZGL"))); + dataLoad.setSecondaryCReactivePower(StringUtils.getBigDecimal(obj.get("ECCXWGGL"))); + dataLoad.setSecondaryCActivePower(StringUtils.getBigDecimal(obj.get("ECCXYGGL"))); + dataLoad.setSecondaryGridFrequency(StringUtils.getBigDecimal(obj.get("ECDWPL"))); + dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXWGDN"))); + dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXYGDN"))); + dataLoad.setSecondaryTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ECZGLYS"))); + dataLoad.setSecondaryTotalApparentPower(StringUtils.getBigDecimal(obj.get("ECZSZFL"))); + dataLoad.setSecondaryTotalReactivePower(StringUtils.getBigDecimal(obj.get("ECZWGGL"))); + dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXWGDN"))); + dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXYGDN"))); + dataLoad.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ECZYGGL"))); + + // 需量 + dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("FXYGDN"))); + dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); + dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + + dataLoad.setCreateBy("system"); + dataLoad.setCreateTime(DateUtils.getNowDate()); + dataLoad.setUpdateBy("system"); + dataLoad.setUpdateTime(DateUtils.getNowDate()); + dataLoad.setSiteId(SITE_ID); + dataLoad.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + } // 数据分组处理 private static Map> processData(Map rawData) { Map> records = new HashMap<>(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 4a27b11..2637a16 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -2,6 +2,7 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.AmmeterCategoryStatus; import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; @@ -334,25 +335,56 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List ammeterDataVos = new ArrayList<>(); if (!StringUtils.isEmpty(siteId)) { - // 先获取所有电表设备 - List devicesList = emsDevicesSettingMapper.getAllBatteryDeviceBySiteId(siteId); - if (!CollectionUtils.isEmpty(devicesList)) { - for (EmsDevicesSetting devicesSetting : devicesList) { - AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); - ammeterDataVo.setDeviceName(devicesSetting.getDeviceName()); - ammeterDataVo.setEmsCommunicationStatus(devicesSetting.getCommunicationStatus()); - String deviceId = devicesSetting.getDeviceId(); - // 获取类别数据 - List ammeterDataDetailInfos = emsAmmeterDataMapper.getAmmeterDetailInfo(siteId,deviceId); + // 先获取总表设备 + List> ammeterIdList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.AMMETER.getCode()); + for (Map ammeterDevice : ammeterIdList) { + AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); + ammeterDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); + ammeterDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus").toString()); + // 从redis取总表详细数据 + String ammeterId = ammeterDevice.get("id").toString(); + EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); + if (ammeterData != null) { + ammeterDataVo.setDataUpdateTime(ammeterData.getDataUpdateTime()); + // 处理类别数据 + List ammeterDataDetailInfos = new ArrayList<>(); + dealAmmeterCategoryDataInfo(ammeterData,ammeterDataDetailInfos); ammeterDataVo.setAmmeterDataDetailInfos(ammeterDataDetailInfos); - // 数据更新时间 - ammeterDataVo.setDataUpdateTime(ammeterDataDetailInfos.get(0).getUpdateTime()); - - ammeterDataVos.add(ammeterDataVo); } + + ammeterDataVos.add(ammeterDataVo); } } return ammeterDataVos; } + private void dealAmmeterCategoryDataInfo(EmsAmmeterData ammeterData, List ammeterDataDetailInfos) { + // 累计放电量 + AmmeterDataDetailInfo ammeterDataDetailInfo1 = new AmmeterDataDetailInfo(); + ammeterDataDetailInfo1.setCategory(AmmeterCategoryStatus.TOTAL_CHARGE.getInfo()); + ammeterDataDetailInfo1.setTotalKwh(ammeterData.getCurrentCombActiveTotal()); + ammeterDataDetailInfo1.setSharpKwh(ammeterData.getCurrentCombActivePeak()); + ammeterDataDetailInfo1.setPeakKwh(ammeterData.getCurrentCombActiveHigh()); + ammeterDataDetailInfo1.setFlatKwh(ammeterData.getCurrentCombActiveFlat()); + ammeterDataDetailInfo1.setValleyKwh(ammeterData.getCurrentCombActiveValley()); + ammeterDataDetailInfos.add(ammeterDataDetailInfo1); + // 累计放电量 + AmmeterDataDetailInfo ammeterDataDetailInfo2 = new AmmeterDataDetailInfo(); + ammeterDataDetailInfo2.setCategory(AmmeterCategoryStatus.TOTAL_DISCHARGE.getInfo()); + ammeterDataDetailInfo2.setTotalKwh(ammeterData.getCurrentCombReactiveTotal()); + ammeterDataDetailInfo2.setSharpKwh(ammeterData.getCurrentCombReactivePeak()); + ammeterDataDetailInfo2.setPeakKwh(ammeterData.getCurrentCombReactiveHigh()); + ammeterDataDetailInfo2.setFlatKwh(ammeterData.getCurrentCombReactiveFlat()); + ammeterDataDetailInfo2.setValleyKwh(ammeterData.getCurrentCombReactiveValley()); + ammeterDataDetailInfos.add(ammeterDataDetailInfo2); + // 日放电量 + AmmeterDataDetailInfo ammeterDataDetailInfo3 = new AmmeterDataDetailInfo(); + ammeterDataDetailInfo3.setCategory(AmmeterCategoryStatus.DAILY_CHARGE.getInfo()); + ammeterDataDetailInfos.add(ammeterDataDetailInfo3); + // 日充电量 + AmmeterDataDetailInfo ammeterDataDetailInfo4 = new AmmeterDataDetailInfo(); + ammeterDataDetailInfo4.setCategory(AmmeterCategoryStatus.DAILY_DISCHARGE.getInfo()); + ammeterDataDetailInfos.add(ammeterDataDetailInfo4); + } + } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 81f17fc..01c652e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -7,37 +7,211 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - select id, data_update_time, category, total_kwh, sharp_kwh, peak_kwh, flat_kwh, valley_kwh, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_ammeter_data + select id, data_update_time, current_comb_active_total, current_comb_active_peak, current_comb_active_high, current_comb_active_flat, current_comb_active_valley, current_forward_active_total, current_forward_active_peak, current_forward_active_high, current_forward_active_flat, current_forward_active_valley, current_reverse_active_total, current_reverse_active_peak, current_reverse_active_high, current_reverse_active_flat, current_reverse_active_valley, current_comb_reactive_total, current_comb_reactive_peak, current_comb_reactive_high, current_comb_reactive_flat, current_comb_reactive_valley, current_forward_reactive_total, current_forward_reactive_peak, current_forward_reactive_high, current_forward_reactive_flat, current_forward_reactive_valley, current_reverse_reactive_total, current_reverse_reactive_peak, current_reverse_reactive_high, current_reverse_reactive_flat, current_reverse_reactive_valley, phase_a_voltage, phase_b_voltage, phase_c_voltage, phase_a_current, phase_b_current, phase_c_current, frequency, ab_line_voltage, cb_line_voltage, ac_line_voltage, forward_ac_max_demand, reverse_ac_max_demand, phase_a_active_power, phase_b_active_power, phase_c_active_power, total_active_power, phase_a_reactive_power, phase_b_reactive_power, phase_c_reactive_power, total_reactive_power, phase_a_apparent_power, phase_b_apparent_power, phase_c_apparent_power, total_apparent_power, phase_a_power_factor, phase_b_power_factor, phase_c_power_factor, total_power_factor, daily_forward_max_demand, site_id, device_id, create_by, create_time, update_by, update_time, remark, secondary_ab_line_voltage, secondary_a_phase_current, secondary_a_phase_voltage, secondary_a_power_factor, secondary_a_apparent_power, secondary_a_reactive_power, secondary_a_active_power, secondary_bc_line_voltage, secondary_b_phase_current, secondary_b_phase_voltage, secondary_b_power_factor, secondary_b_apparent_power, secondary_b_reactive_power, secondary_b_active_power, secondary_ca_line_voltage, secondary_c_phase_current, secondary_c_phase_voltage, secondary_c_power_factor, secondary_c_apparent_power, secondary_c_reactive_power, secondary_c_active_power, secondary_grid_frequency, secondary_reverse_reactive_energy, secondary_negative_active_energy, secondary_total_power_factor, secondary_total_apparent_power, secondary_total_reactive_power, secondary_positive_reactive_energy, secondary_positive_active_energy, secondary_total_active_power, reverse_reactive_energy_eq_minus, reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus from ems_ammeter_data @@ -50,35 +224,209 @@ insert into ems_ammeter_data data_update_time, - category, - total_kwh, - sharp_kwh, - peak_kwh, - flat_kwh, - valley_kwh, + current_comb_active_total, + current_comb_active_peak, + current_comb_active_high, + current_comb_active_flat, + current_comb_active_valley, + current_forward_active_total, + current_forward_active_peak, + current_forward_active_high, + current_forward_active_flat, + current_forward_active_valley, + current_reverse_active_total, + current_reverse_active_peak, + current_reverse_active_high, + current_reverse_active_flat, + current_reverse_active_valley, + current_comb_reactive_total, + current_comb_reactive_peak, + current_comb_reactive_high, + current_comb_reactive_flat, + current_comb_reactive_valley, + current_forward_reactive_total, + current_forward_reactive_peak, + current_forward_reactive_high, + current_forward_reactive_flat, + current_forward_reactive_valley, + current_reverse_reactive_total, + current_reverse_reactive_peak, + current_reverse_reactive_high, + current_reverse_reactive_flat, + current_reverse_reactive_valley, + phase_a_voltage, + phase_b_voltage, + phase_c_voltage, + phase_a_current, + phase_b_current, + phase_c_current, + frequency, + ab_line_voltage, + cb_line_voltage, + ac_line_voltage, + forward_ac_max_demand, + reverse_ac_max_demand, + phase_a_active_power, + phase_b_active_power, + phase_c_active_power, + total_active_power, + phase_a_reactive_power, + phase_b_reactive_power, + phase_c_reactive_power, + total_reactive_power, + phase_a_apparent_power, + phase_b_apparent_power, + phase_c_apparent_power, + total_apparent_power, + phase_a_power_factor, + phase_b_power_factor, + phase_c_power_factor, + total_power_factor, + daily_forward_max_demand, + site_id, + device_id, create_by, create_time, update_by, update_time, remark, - site_id, - device_id, + secondary_ab_line_voltage, + secondary_a_phase_current, + secondary_a_phase_voltage, + secondary_a_power_factor, + secondary_a_apparent_power, + secondary_a_reactive_power, + secondary_a_active_power, + secondary_bc_line_voltage, + secondary_b_phase_current, + secondary_b_phase_voltage, + secondary_b_power_factor, + secondary_b_apparent_power, + secondary_b_reactive_power, + secondary_b_active_power, + secondary_ca_line_voltage, + secondary_c_phase_current, + secondary_c_phase_voltage, + secondary_c_power_factor, + secondary_c_apparent_power, + secondary_c_reactive_power, + secondary_c_active_power, + secondary_grid_frequency, + secondary_reverse_reactive_energy, + secondary_negative_active_energy, + secondary_total_power_factor, + secondary_total_apparent_power, + secondary_total_reactive_power, + secondary_positive_reactive_energy, + secondary_positive_active_energy, + secondary_total_active_power, + reverse_reactive_energy_eq_minus, + reverse_active_energy_ep_minus, + positive_reactive_energy_eq_plus, + positive_active_energy_ep_plus, #{dataUpdateTime}, - #{category}, - #{totalKwh}, - #{sharpKwh}, - #{peakKwh}, - #{flatKwh}, - #{valleyKwh}, + #{currentCombActiveTotal}, + #{currentCombActivePeak}, + #{currentCombActiveHigh}, + #{currentCombActiveFlat}, + #{currentCombActiveValley}, + #{currentForwardActiveTotal}, + #{currentForwardActivePeak}, + #{currentForwardActiveHigh}, + #{currentForwardActiveFlat}, + #{currentForwardActiveValley}, + #{currentReverseActiveTotal}, + #{currentReverseActivePeak}, + #{currentReverseActiveHigh}, + #{currentReverseActiveFlat}, + #{currentReverseActiveValley}, + #{currentCombReactiveTotal}, + #{currentCombReactivePeak}, + #{currentCombReactiveHigh}, + #{currentCombReactiveFlat}, + #{currentCombReactiveValley}, + #{currentForwardReactiveTotal}, + #{currentForwardReactivePeak}, + #{currentForwardReactiveHigh}, + #{currentForwardReactiveFlat}, + #{currentForwardReactiveValley}, + #{currentReverseReactiveTotal}, + #{currentReverseReactivePeak}, + #{currentReverseReactiveHigh}, + #{currentReverseReactiveFlat}, + #{currentReverseReactiveValley}, + #{phaseAVoltage}, + #{phaseBVoltage}, + #{phaseCVoltage}, + #{phaseACurrent}, + #{phaseBCurrent}, + #{phaseCCurrent}, + #{frequency}, + #{abLineVoltage}, + #{cbLineVoltage}, + #{acLineVoltage}, + #{forwardAcMaxDemand}, + #{reverseAcMaxDemand}, + #{phaseAActivePower}, + #{phaseBActivePower}, + #{phaseCActivePower}, + #{totalActivePower}, + #{phaseAReactivePower}, + #{phaseBReactivePower}, + #{phaseCReactivePower}, + #{totalReactivePower}, + #{phaseAApparentPower}, + #{phaseBApparentPower}, + #{phaseCApparentPower}, + #{totalApparentPower}, + #{phaseAPowerFactor}, + #{phaseBPowerFactor}, + #{phaseCPowerFactor}, + #{totalPowerFactor}, + #{dailyForwardMaxDemand}, + #{siteId}, + #{deviceId}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark}, - #{siteId}, - #{deviceId}, + #{secondaryAbLineVoltage}, + #{secondaryAPhaseCurrent}, + #{secondaryAPhaseVoltage}, + #{secondaryAPowerFactor}, + #{secondaryAApparentPower}, + #{secondaryAReactivePower}, + #{secondaryAActivePower}, + #{secondaryBcLineVoltage}, + #{secondaryBPhaseCurrent}, + #{secondaryBPhaseVoltage}, + #{secondaryBPowerFactor}, + #{secondaryBApparentPower}, + #{secondaryBReactivePower}, + #{secondaryBActivePower}, + #{secondaryCaLineVoltage}, + #{secondaryCPhaseCurrent}, + #{secondaryCPhaseVoltage}, + #{secondaryCPowerFactor}, + #{secondaryCApparentPower}, + #{secondaryCReactivePower}, + #{secondaryCActivePower}, + #{secondaryGridFrequency}, + #{secondaryReverseReactiveEnergy}, + #{secondaryNegativeActiveEnergy}, + #{secondaryTotalPowerFactor}, + #{secondaryTotalApparentPower}, + #{secondaryTotalReactivePower}, + #{secondaryPositiveReactiveEnergy}, + #{secondaryPositiveActiveEnergy}, + #{secondaryTotalActivePower}, + #{reverseReactiveEnergyEqMinus}, + #{reverseActiveEnergyEpMinus}, + #{positiveReactiveEnergyEqPlus}, + #{positiveActiveEnergyEpPlus}, @@ -86,19 +434,106 @@ update ems_ammeter_data data_update_time = #{dataUpdateTime}, - category = #{category}, - total_kwh = #{totalKwh}, - sharp_kwh = #{sharpKwh}, - peak_kwh = #{peakKwh}, - flat_kwh = #{flatKwh}, - valley_kwh = #{valleyKwh}, + current_comb_active_total = #{currentCombActiveTotal}, + current_comb_active_peak = #{currentCombActivePeak}, + current_comb_active_high = #{currentCombActiveHigh}, + current_comb_active_flat = #{currentCombActiveFlat}, + current_comb_active_valley = #{currentCombActiveValley}, + current_forward_active_total = #{currentForwardActiveTotal}, + current_forward_active_peak = #{currentForwardActivePeak}, + current_forward_active_high = #{currentForwardActiveHigh}, + current_forward_active_flat = #{currentForwardActiveFlat}, + current_forward_active_valley = #{currentForwardActiveValley}, + current_reverse_active_total = #{currentReverseActiveTotal}, + current_reverse_active_peak = #{currentReverseActivePeak}, + current_reverse_active_high = #{currentReverseActiveHigh}, + current_reverse_active_flat = #{currentReverseActiveFlat}, + current_reverse_active_valley = #{currentReverseActiveValley}, + current_comb_reactive_total = #{currentCombReactiveTotal}, + current_comb_reactive_peak = #{currentCombReactivePeak}, + current_comb_reactive_high = #{currentCombReactiveHigh}, + current_comb_reactive_flat = #{currentCombReactiveFlat}, + current_comb_reactive_valley = #{currentCombReactiveValley}, + current_forward_reactive_total = #{currentForwardReactiveTotal}, + current_forward_reactive_peak = #{currentForwardReactivePeak}, + current_forward_reactive_high = #{currentForwardReactiveHigh}, + current_forward_reactive_flat = #{currentForwardReactiveFlat}, + current_forward_reactive_valley = #{currentForwardReactiveValley}, + current_reverse_reactive_total = #{currentReverseReactiveTotal}, + current_reverse_reactive_peak = #{currentReverseReactivePeak}, + current_reverse_reactive_high = #{currentReverseReactiveHigh}, + current_reverse_reactive_flat = #{currentReverseReactiveFlat}, + current_reverse_reactive_valley = #{currentReverseReactiveValley}, + phase_a_voltage = #{phaseAVoltage}, + phase_b_voltage = #{phaseBVoltage}, + phase_c_voltage = #{phaseCVoltage}, + phase_a_current = #{phaseACurrent}, + phase_b_current = #{phaseBCurrent}, + phase_c_current = #{phaseCCurrent}, + frequency = #{frequency}, + ab_line_voltage = #{abLineVoltage}, + cb_line_voltage = #{cbLineVoltage}, + ac_line_voltage = #{acLineVoltage}, + forward_ac_max_demand = #{forwardAcMaxDemand}, + reverse_ac_max_demand = #{reverseAcMaxDemand}, + phase_a_active_power = #{phaseAActivePower}, + phase_b_active_power = #{phaseBActivePower}, + phase_c_active_power = #{phaseCActivePower}, + total_active_power = #{totalActivePower}, + phase_a_reactive_power = #{phaseAReactivePower}, + phase_b_reactive_power = #{phaseBReactivePower}, + phase_c_reactive_power = #{phaseCReactivePower}, + total_reactive_power = #{totalReactivePower}, + phase_a_apparent_power = #{phaseAApparentPower}, + phase_b_apparent_power = #{phaseBApparentPower}, + phase_c_apparent_power = #{phaseCApparentPower}, + total_apparent_power = #{totalApparentPower}, + phase_a_power_factor = #{phaseAPowerFactor}, + phase_b_power_factor = #{phaseBPowerFactor}, + phase_c_power_factor = #{phaseCPowerFactor}, + total_power_factor = #{totalPowerFactor}, + daily_forward_max_demand = #{dailyForwardMaxDemand}, + site_id = #{siteId}, + device_id = #{deviceId}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, - site_id = #{siteId}, - device_id = #{deviceId}, + secondary_ab_line_voltage = #{secondaryAbLineVoltage}, + secondary_a_phase_current = #{secondaryAPhaseCurrent}, + secondary_a_phase_voltage = #{secondaryAPhaseVoltage}, + secondary_a_power_factor = #{secondaryAPowerFactor}, + secondary_a_apparent_power = #{secondaryAApparentPower}, + secondary_a_reactive_power = #{secondaryAReactivePower}, + secondary_a_active_power = #{secondaryAActivePower}, + secondary_bc_line_voltage = #{secondaryBcLineVoltage}, + secondary_b_phase_current = #{secondaryBPhaseCurrent}, + secondary_b_phase_voltage = #{secondaryBPhaseVoltage}, + secondary_b_power_factor = #{secondaryBPowerFactor}, + secondary_b_apparent_power = #{secondaryBApparentPower}, + secondary_b_reactive_power = #{secondaryBReactivePower}, + secondary_b_active_power = #{secondaryBActivePower}, + secondary_ca_line_voltage = #{secondaryCaLineVoltage}, + secondary_c_phase_current = #{secondaryCPhaseCurrent}, + secondary_c_phase_voltage = #{secondaryCPhaseVoltage}, + secondary_c_power_factor = #{secondaryCPowerFactor}, + secondary_c_apparent_power = #{secondaryCApparentPower}, + secondary_c_reactive_power = #{secondaryCReactivePower}, + secondary_c_active_power = #{secondaryCActivePower}, + secondary_grid_frequency = #{secondaryGridFrequency}, + secondary_reverse_reactive_energy = #{secondaryReverseReactiveEnergy}, + secondary_negative_active_energy = #{secondaryNegativeActiveEnergy}, + secondary_total_power_factor = #{secondaryTotalPowerFactor}, + secondary_total_apparent_power = #{secondaryTotalApparentPower}, + secondary_total_reactive_power = #{secondaryTotalReactivePower}, + secondary_positive_reactive_energy = #{secondaryPositiveReactiveEnergy}, + secondary_positive_active_energy = #{secondaryPositiveActiveEnergy}, + secondary_total_active_power = #{secondaryTotalActivePower}, + reverse_reactive_energy_eq_minus = #{reverseReactiveEnergyEqMinus}, + reverse_active_energy_ep_minus = #{reverseActiveEnergyEpMinus}, + positive_reactive_energy_eq_plus = #{positiveReactiveEnergyEqPlus}, + positive_active_energy_ep_plus = #{positiveActiveEnergyEpPlus}, where id = #{id} -- 2.49.0 From f42e8549b124bed800db8ee4acdb0997c74165bd Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 4 Jul 2025 13:51:42 +0800 Subject: [PATCH 055/336] =?UTF-8?q?=E5=8D=95=E7=AB=99=E7=9B=91=E6=8E=A7-?= =?UTF-8?q?=E7=94=B5=E8=A1=A8=E5=8F=96=E6=95=B0=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tegoryStatus.java => AmmeterCategory.java} | 10 +- .../ems/domain/vo/AmmeterDataResponse.java | 31 ++++ ...eterDataVo.java => AmmeterLoadDataVo.java} | 15 +- .../xzzn/ems/domain/vo/AmmeterMeteDataVo.java | 57 ++++++++ ...etailInfo.java => LoadDataDetailInfo.java} | 38 ++--- .../ems/domain/vo/MeteDataDetailInfo.java | 42 ++++++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 9 -- .../xzzn/ems/service/ISingleSiteService.java | 2 +- .../service/impl/SingleSiteServiceImpl.java | 134 ++++++++++++------ .../mapper/ems/EmsAmmeterDataMapper.xml | 20 --- 10 files changed, 241 insertions(+), 117 deletions(-) rename ems-common/src/main/java/com/xzzn/common/enums/{AmmeterCategoryStatus.java => AmmeterCategory.java} (55%) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java rename ems-system/src/main/java/com/xzzn/ems/domain/vo/{AmmeterDataVo.java => AmmeterLoadDataVo.java} (72%) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java rename ems-system/src/main/java/com/xzzn/ems/domain/vo/{AmmeterDataDetailInfo.java => LoadDataDetailInfo.java} (63%) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/MeteDataDetailInfo.java diff --git a/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategoryStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java similarity index 55% rename from ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategoryStatus.java rename to ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java index 957e9f6..978b342 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategoryStatus.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java @@ -5,14 +5,18 @@ package com.xzzn.common.enums; * * @author xzzn */ -public enum AmmeterCategoryStatus +public enum AmmeterCategory { - TOTAL_CHARGE("1", "累计充电量"), TOTAL_DISCHARGE("2", "累计放电量"), DAILY_CHARGE("3", "日充电量"), DAILY_DISCHARGE("4", "日放电量"); + CURRENT_COMB_ACTIVE("1", "当前组合有功电能"), + CURRENT_COMB_REACTIVE("2", "当前组合无功"), + A_POWER("3", "A相功率"), + B_POWER("4", "B相功率"), + C_POWER("5", "C相功率"); private final String code; private final String info; - AmmeterCategoryStatus(String code, String info) + AmmeterCategory(String code, String info) { this.code = code; this.info = info; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java new file mode 100644 index 0000000..b5f0994 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java @@ -0,0 +1,31 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; + +/** + * 电表数据 + */ +public class AmmeterDataResponse { + + /** 总表信息 */ + private AmmeterLoadDataVo ammeterLoadData; + + /** 储能表信息 */ + private AmmeterMeteDataVo ammeterMeteData; + + public AmmeterLoadDataVo getAmmeterLoadData() { + return ammeterLoadData; + } + + public void setAmmeterLoadDataVoList(AmmeterLoadDataVo ammeterLoadData) { + this.ammeterLoadData = ammeterLoadData; + } + + public AmmeterMeteDataVo getAmmeterMeteData() { + return ammeterMeteData; + } + + public void setAmmeterMeteDataVoList(AmmeterMeteDataVo ammeterMeteData) { + this.ammeterMeteData = ammeterMeteData; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java similarity index 72% rename from ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java rename to ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java index 119f4ab..f443390 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java @@ -6,9 +6,9 @@ import java.util.Date; import java.util.List; /** - * 电表数据 + * 电表-总表数据 */ -public class AmmeterDataVo { +public class AmmeterLoadDataVo { /** 电表名称 */ private String deviceName; @@ -20,7 +20,8 @@ public class AmmeterDataVo { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date dataUpdateTime; - private List ammeterDataDetailInfos; + /** 总表数据信息 */ + private List loadDataDetailInfo; public String getDeviceName() { return deviceName; @@ -46,11 +47,11 @@ public class AmmeterDataVo { this.dataUpdateTime = dataUpdateTime; } - public List getAmmeterDataDetailInfos() { - return ammeterDataDetailInfos; + public List getLoadDataDetailInfo() { + return loadDataDetailInfo; } - public void setAmmeterDataDetailInfos(List ammeterDataDetailInfos) { - this.ammeterDataDetailInfos = ammeterDataDetailInfos; + public void setLoadDataDetailInfo(List loadDataDetailInfo) { + this.loadDataDetailInfo = loadDataDetailInfo; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java new file mode 100644 index 0000000..a9a941d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java @@ -0,0 +1,57 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; +import java.util.List; + +/** + * 电表-总表数据 + */ +public class AmmeterMeteDataVo { + + /** 电表名称 */ + private String deviceName; + + /** 通信状态 */ + private String emsCommunicationStatus; + + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date dataUpdateTime; + + /** 储能表数据信息 */ + private List meteDataDetailInfo; + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getEmsCommunicationStatus() { + return emsCommunicationStatus; + } + + public void setEmsCommunicationStatus(String emsCommunicationStatus) { + this.emsCommunicationStatus = emsCommunicationStatus; + } + + public Date getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(Date dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + + public List getMeteDataDetailInfo() { + return meteDataDetailInfo; + } + + public void setMeteDataDetailInfo(List meteDataDetailInfo) { + this.meteDataDetailInfo = meteDataDetailInfo; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/LoadDataDetailInfo.java similarity index 63% rename from ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java rename to ems-system/src/main/java/com/xzzn/ems/domain/vo/LoadDataDetailInfo.java index 7ef28fa..a019f26 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataDetailInfo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/LoadDataDetailInfo.java @@ -1,12 +1,11 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; -import java.util.Date; /** - * 电表详细数据 + * 电表-总表数据展示 */ -public class AmmeterDataDetailInfo +public class LoadDataDetailInfo { /** 类别 */ private String category; @@ -15,10 +14,10 @@ public class AmmeterDataDetailInfo private BigDecimal totalKwh = BigDecimal.ZERO; /** 尖 (kWh) */ - private BigDecimal sharpKwh = BigDecimal.ZERO; + private BigDecimal peakKwh = BigDecimal.ZERO; /** 峰 (kWh) */ - private BigDecimal peakKwh = BigDecimal.ZERO; + private BigDecimal highKwh = BigDecimal.ZERO; /** 平 (kWh) */ private BigDecimal flatKwh = BigDecimal.ZERO; @@ -26,11 +25,6 @@ public class AmmeterDataDetailInfo /** 谷 (kWh) */ private BigDecimal valleyKwh = BigDecimal.ZERO; - /** 总表设备Id */ - private String deviceId; - - /** 数据更新时间 */ - private Date updateTime; public BigDecimal getValleyKwh() { return valleyKwh; @@ -56,12 +50,12 @@ public class AmmeterDataDetailInfo this.peakKwh = peakKwh; } - public BigDecimal getSharpKwh() { - return sharpKwh; + public BigDecimal getHighKwh() { + return highKwh; } - public void setSharpKwh(BigDecimal sharpKwh) { - this.sharpKwh = sharpKwh; + public void setHighKwh(BigDecimal highKwh) { + this.highKwh = highKwh; } public BigDecimal getTotalKwh() { @@ -79,20 +73,4 @@ public class AmmeterDataDetailInfo public void setCategory(String category) { this.category = category; } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/MeteDataDetailInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/MeteDataDetailInfo.java new file mode 100644 index 0000000..ede89d8 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/MeteDataDetailInfo.java @@ -0,0 +1,42 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 电表-储能表数据展示 + */ +public class MeteDataDetailInfo +{ + /** 类别:A相 B相 C相*/ + private String category; + + /** 有功功率 */ + private BigDecimal activePower = BigDecimal.ZERO; + + /** 无功功率 */ + private BigDecimal reactivePower = BigDecimal.ZERO; + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public BigDecimal getActivePower() { + return activePower; + } + + public void setActivePower(BigDecimal activePower) { + this.activePower = activePower; + } + + public BigDecimal getReactivePower() { + return reactivePower; + } + + public void setReactivePower(BigDecimal reactivePower) { + this.reactivePower = reactivePower; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index d308762..bff726e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -2,8 +2,6 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsAmmeterData; -import com.xzzn.ems.domain.vo.AmmeterDataDetailInfo; -import org.apache.ibatis.annotations.Param; /** * 总数据Mapper接口 @@ -60,11 +58,4 @@ public interface EmsAmmeterDataMapper * @return 结果 */ public int deleteEmsAmmeterDataByIds(Long[] ids); - - /** - * 获取总表详细数据 - * @param siteId - * @return - */ - public List getAmmeterDetailInfo(@Param("siteId")String siteId, @Param("deviceId") String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 9b97989..684b56b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -29,5 +29,5 @@ public interface ISingleSiteService public List getClusterDataInfoList(String clusterDeviceId,String siteId); - public List getAmmeterDataList(String siteId); + public AmmeterDataResponse getAmmeterDataList(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 2637a16..c5ccee9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -2,7 +2,7 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; -import com.xzzn.common.enums.AmmeterCategoryStatus; +import com.xzzn.common.enums.AmmeterCategory; import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; @@ -29,6 +29,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private static final String CLUSTER_DATA_SOC = "SOC"; + private static final String AMMETER_DEVICE_LOAD = "LOAD"; + + private static final String AMMETER_DEVICE_METE = "METE"; + @Autowired private EmsPcsDataMapper emsPcsDataMapper; @Autowired @@ -331,60 +335,96 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public List getAmmeterDataList(String siteId) { - List ammeterDataVos = new ArrayList<>(); + public AmmeterDataResponse getAmmeterDataList(String siteId) { + AmmeterDataResponse ammeterResponse = new AmmeterDataResponse(); if (!StringUtils.isEmpty(siteId)) { - // 先获取总表设备 + // 先获取电表设备 List> ammeterIdList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.AMMETER.getCode()); - for (Map ammeterDevice : ammeterIdList) { - AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); - ammeterDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); - ammeterDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus").toString()); - // 从redis取总表详细数据 - String ammeterId = ammeterDevice.get("id").toString(); - EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); - if (ammeterData != null) { - ammeterDataVo.setDataUpdateTime(ammeterData.getDataUpdateTime()); - // 处理类别数据 - List ammeterDataDetailInfos = new ArrayList<>(); - dealAmmeterCategoryDataInfo(ammeterData,ammeterDataDetailInfos); - ammeterDataVo.setAmmeterDataDetailInfos(ammeterDataDetailInfos); - } - ammeterDataVos.add(ammeterDataVo); + for (Map ammeterDevice : ammeterIdList) { + String ammeterId = ammeterDevice.get("id").toString(); + // 从redis取总表详细数据 + EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); + // 判断电表类型 + if (AMMETER_DEVICE_LOAD.equals(ammeterId)) { + AmmeterLoadDataVo ammeterLoadDataVo = new AmmeterLoadDataVo(); + ammeterLoadDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); + ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus").toString()); + // 处理总表数据 + dealAmmeterLoadData(ammeterData,ammeterLoadDataVo); + ammeterResponse.setAmmeterLoadDataVoList(ammeterLoadDataVo); + } else if (AMMETER_DEVICE_METE.equals(ammeterId)) { + AmmeterMeteDataVo ammeterMeteDataVo = new AmmeterMeteDataVo(); + ammeterMeteDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); + ammeterMeteDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus").toString()); + // 处理储能表数据 + dealAmmeterMeteData(ammeterData,ammeterMeteDataVo); + ammeterResponse.setAmmeterMeteDataVoList(ammeterMeteDataVo); + } } } - return ammeterDataVos; + return ammeterResponse; } - private void dealAmmeterCategoryDataInfo(EmsAmmeterData ammeterData, List ammeterDataDetailInfos) { - // 累计放电量 - AmmeterDataDetailInfo ammeterDataDetailInfo1 = new AmmeterDataDetailInfo(); - ammeterDataDetailInfo1.setCategory(AmmeterCategoryStatus.TOTAL_CHARGE.getInfo()); - ammeterDataDetailInfo1.setTotalKwh(ammeterData.getCurrentCombActiveTotal()); - ammeterDataDetailInfo1.setSharpKwh(ammeterData.getCurrentCombActivePeak()); - ammeterDataDetailInfo1.setPeakKwh(ammeterData.getCurrentCombActiveHigh()); - ammeterDataDetailInfo1.setFlatKwh(ammeterData.getCurrentCombActiveFlat()); - ammeterDataDetailInfo1.setValleyKwh(ammeterData.getCurrentCombActiveValley()); - ammeterDataDetailInfos.add(ammeterDataDetailInfo1); - // 累计放电量 - AmmeterDataDetailInfo ammeterDataDetailInfo2 = new AmmeterDataDetailInfo(); - ammeterDataDetailInfo2.setCategory(AmmeterCategoryStatus.TOTAL_DISCHARGE.getInfo()); - ammeterDataDetailInfo2.setTotalKwh(ammeterData.getCurrentCombReactiveTotal()); - ammeterDataDetailInfo2.setSharpKwh(ammeterData.getCurrentCombReactivePeak()); - ammeterDataDetailInfo2.setPeakKwh(ammeterData.getCurrentCombReactiveHigh()); - ammeterDataDetailInfo2.setFlatKwh(ammeterData.getCurrentCombReactiveFlat()); - ammeterDataDetailInfo2.setValleyKwh(ammeterData.getCurrentCombReactiveValley()); - ammeterDataDetailInfos.add(ammeterDataDetailInfo2); - // 日放电量 - AmmeterDataDetailInfo ammeterDataDetailInfo3 = new AmmeterDataDetailInfo(); - ammeterDataDetailInfo3.setCategory(AmmeterCategoryStatus.DAILY_CHARGE.getInfo()); - ammeterDataDetailInfos.add(ammeterDataDetailInfo3); - // 日充电量 - AmmeterDataDetailInfo ammeterDataDetailInfo4 = new AmmeterDataDetailInfo(); - ammeterDataDetailInfo4.setCategory(AmmeterCategoryStatus.DAILY_DISCHARGE.getInfo()); - ammeterDataDetailInfos.add(ammeterDataDetailInfo4); + private void dealAmmeterMeteData(EmsAmmeterData ammeterData, AmmeterMeteDataVo ammeterMeteDataVo) { + if (ammeterData != null) { + // 数据更新时间 + ammeterMeteDataVo.setDataUpdateTime(ammeterData.getDataUpdateTime()); + + List meteDataDetailInfos = new ArrayList<>(); + // 拼接数据 + // a相 + MeteDataDetailInfo meteDataDetailInfo1 = new MeteDataDetailInfo(); + meteDataDetailInfo1.setCategory(AmmeterCategory.A_POWER.getInfo()); + meteDataDetailInfo1.setActivePower(ammeterData.getPhaseAActivePower()); + meteDataDetailInfo1.setReactivePower(ammeterData.getPhaseAReactivePower()); + meteDataDetailInfos.add(meteDataDetailInfo1); + // b相 + MeteDataDetailInfo meteDataDetailInfo2 = new MeteDataDetailInfo(); + meteDataDetailInfo2.setCategory(AmmeterCategory.B_POWER.getInfo()); + meteDataDetailInfo2.setActivePower(ammeterData.getPhaseBActivePower()); + meteDataDetailInfo2.setReactivePower(ammeterData.getPhaseBReactivePower()); + meteDataDetailInfos.add(meteDataDetailInfo2); + // c相 + MeteDataDetailInfo meteDataDetailInfo3 = new MeteDataDetailInfo(); + meteDataDetailInfo3.setCategory(AmmeterCategory.C_POWER.getInfo()); + meteDataDetailInfo3.setActivePower(ammeterData.getPhaseCActivePower()); + meteDataDetailInfo3.setReactivePower(ammeterData.getPhaseCReactivePower()); + meteDataDetailInfos.add(meteDataDetailInfo3); + ammeterMeteDataVo.setMeteDataDetailInfo(meteDataDetailInfos); + } + } + + private void dealAmmeterLoadData(EmsAmmeterData ammeterData, AmmeterLoadDataVo ammeterDataVo) { + if (ammeterData != null) { + // 数据更新时间 + ammeterDataVo.setDataUpdateTime(ammeterData.getDataUpdateTime()); + + List loadDataDetailInfos = new ArrayList<>(); + // 拼接数据 + // 组合有功 + LoadDataDetailInfo ammeterDataDetailInfo1 = new LoadDataDetailInfo(); + ammeterDataDetailInfo1.setCategory(AmmeterCategory.CURRENT_COMB_ACTIVE.getInfo()); + ammeterDataDetailInfo1.setTotalKwh(ammeterData.getCurrentCombActiveTotal()); + ammeterDataDetailInfo1.setPeakKwh(ammeterData.getCurrentCombActivePeak()); + ammeterDataDetailInfo1.setHighKwh(ammeterData.getCurrentCombActiveHigh()); + ammeterDataDetailInfo1.setFlatKwh(ammeterData.getCurrentCombActiveFlat()); + ammeterDataDetailInfo1.setValleyKwh(ammeterData.getCurrentCombActiveValley()); + loadDataDetailInfos.add(ammeterDataDetailInfo1); + // 组合无功 + LoadDataDetailInfo ammeterDataDetailInfo2 = new LoadDataDetailInfo(); + ammeterDataDetailInfo2.setCategory(AmmeterCategory.CURRENT_COMB_REACTIVE.getInfo()); + ammeterDataDetailInfo2.setTotalKwh(ammeterData.getCurrentCombReactiveTotal()); + ammeterDataDetailInfo2.setPeakKwh(ammeterData.getCurrentCombReactivePeak()); + ammeterDataDetailInfo2.setHighKwh(ammeterData.getCurrentCombReactiveHigh()); + ammeterDataDetailInfo2.setFlatKwh(ammeterData.getCurrentCombReactiveFlat()); + ammeterDataDetailInfo2.setValleyKwh(ammeterData.getCurrentCombReactiveValley()); + loadDataDetailInfos.add(ammeterDataDetailInfo2); + + ammeterDataVo.setLoadDataDetailInfo(loadDataDetailInfos); + } + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 01c652e..f16f592 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -549,24 +549,4 @@ - \ No newline at end of file -- 2.49.0 From 6a5504434d5b16aff7cbf24aff48da0e74fcb8e7 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 5 Jul 2025 23:24:13 +0800 Subject: [PATCH 056/336] =?UTF-8?q?=E7=94=B5=E9=87=8F=E6=8C=87=E6=A0=87-?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=AD=9B=E9=80=89=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/vo/BatteryAveSOCVo.java | 26 ++-- .../xzzn/ems/domain/vo/BatteryAveTempVo.java | 27 ++--- .../ems/domain/vo/ElectricDataInfoVo.java | 13 ++ .../ems/domain/vo/EnergyStoragePowVo.java | 38 ++---- .../com/xzzn/ems/domain/vo/PCSAveTempVo.java | 25 ++-- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 44 ++++++- .../impl/EmsStatsReportServiceImpl.java | 25 +++- .../impl/FXXDataProcessServiceImpl.java | 4 +- .../service/impl/SingleSiteServiceImpl.java | 12 ++ .../resources/mapper/ems/EmsPcsDataMapper.xml | 112 +++++++++++++++++- 10 files changed, 225 insertions(+), 101 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java index 5c216e3..806491d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java @@ -1,6 +1,7 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; +import java.util.Date; /** * 实时运行-电池平均SOC数据 @@ -8,26 +9,21 @@ import java.math.BigDecimal; */ public class BatteryAveSOCVo { /** - * 月份 月+日 + * 数据时间 */ - private String monthDay; + private Date createDate; /** * 实时SOC */ private BigDecimal batterySOC; - /** - * 昨日SOC - */ - private BigDecimal ytdBatterySOC; - - public String getMonthDay() { - return monthDay; + public Date getCreateDate() { + return createDate; } - public void setMonthDay(String monthDay) { - this.monthDay = monthDay; + public void setCreateDate(Date createDate) { + this.createDate = createDate; } public BigDecimal getBatterySOC() { @@ -37,12 +33,4 @@ public class BatteryAveSOCVo { public void setBatterySOC(BigDecimal batterySOC) { this.batterySOC = batterySOC; } - - public BigDecimal getYtdBatterySOC() { - return ytdBatterySOC; - } - - public void setYtdBatterySOC(BigDecimal ytdBatterySOC) { - this.ytdBatterySOC = ytdBatterySOC; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java index 7b89800..bcab5d4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java @@ -1,6 +1,7 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; +import java.util.Date; /** * 实时运行-电池平均温度数据 @@ -8,27 +9,21 @@ import java.math.BigDecimal; */ public class BatteryAveTempVo { /** - * 月份 月+日 + * 数据时间 */ - private String monthDay; + private Date createDate; /** * 实时温度 */ private BigDecimal batteryTemp; - /** - * 昨日温度 - */ - private BigDecimal batteryYtdTemp; - - - public String getMonthDay() { - return monthDay; + public Date getCreateDate() { + return createDate; } - public void setMonthDay(String monthDay) { - this.monthDay = monthDay; + public void setCreateDate(Date createDate) { + this.createDate = createDate; } public BigDecimal getBatteryTemp() { @@ -38,12 +33,4 @@ public class BatteryAveTempVo { public void setBatteryTemp(BigDecimal batteryTemp) { this.batteryTemp = batteryTemp; } - - public BigDecimal getBatteryYtdTemp() { - return batteryYtdTemp; - } - - public void setBatteryYtdTemp(BigDecimal batteryYtdTemp) { - this.batteryYtdTemp = batteryYtdTemp; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricDataInfoVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricDataInfoVo.java index 5827ba6..1743d70 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricDataInfoVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricDataInfoVo.java @@ -9,6 +9,11 @@ import java.util.List; */ public class ElectricDataInfoVo { + /** + * 显示时间单位 + */ + private String unit; + /** * 总充电量 */ @@ -29,6 +34,14 @@ public class ElectricDataInfoVo { */ private List sevenDayDisChargeStats; + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + public BigDecimal getTotalChargedCap() { return totalChargedCap; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java index 82d583b..44e5534 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java @@ -1,6 +1,7 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; +import java.util.Date; /** * 实时运行-储能功率数据 @@ -8,9 +9,9 @@ import java.math.BigDecimal; */ public class EnergyStoragePowVo { /** - * 月份 月+日 + * 显示日期 */ - private String monthDay; + private Date createDate; /** * pcs实时有功功率 @@ -22,22 +23,13 @@ public class EnergyStoragePowVo { */ private BigDecimal pcsTotalReactivePower; - /** - * pcs昨日有功功率 - */ - private BigDecimal pcsYtdActPower; - /** - * pcs昨日无功功率 - */ - private BigDecimal pcsYtdReactivePower; - - public String getMonthDay() { - return monthDay; + public Date getCreateDate() { + return createDate; } - public void setMonthDay(String monthDay) { - this.monthDay = monthDay; + public void setCreateDate(Date createDate) { + this.createDate = createDate; } public BigDecimal getPcsTotalActPower() { @@ -55,20 +47,4 @@ public class EnergyStoragePowVo { public void setPcsTotalReactivePower(BigDecimal pcsTotalReactivePower) { this.pcsTotalReactivePower = pcsTotalReactivePower; } - - public BigDecimal getPcsYtdActPower() { - return pcsYtdActPower; - } - - public void setPcsYtdActPower(BigDecimal pcsYtdActPower) { - this.pcsYtdActPower = pcsYtdActPower; - } - - public BigDecimal getPcsYtdReactivePower() { - return pcsYtdReactivePower; - } - - public void setPcsYtdReactivePower(BigDecimal pcsYtdReactivePower) { - this.pcsYtdReactivePower = pcsYtdReactivePower; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSAveTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSAveTempVo.java index 7dac945..1af5cbf 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSAveTempVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSAveTempVo.java @@ -1,6 +1,7 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; +import java.util.Date; /** * 实时运行-pcs平均温度数据 @@ -8,26 +9,22 @@ import java.math.BigDecimal; */ public class PCSAveTempVo { /** - * 月份 月+日 + * 数据时间 */ - private String monthDay; + private Date createDate; /** * 实时温度 */ private BigDecimal pcsTemp; - /** - * 昨日同时段温度(到分) - */ - private BigDecimal pcsYtdTemp; - public String getMonthDay() { - return monthDay; + public Date getCreateDate() { + return createDate; } - public void setMonthDay(String monthDay) { - this.monthDay = monthDay; + public void setCreateDate(Date createDate) { + this.createDate = createDate; } public BigDecimal getPcsTemp() { @@ -37,12 +34,4 @@ public class PCSAveTempVo { public void setPcsTemp(BigDecimal pcsTemp) { this.pcsTemp = pcsTemp; } - - public BigDecimal getPcsYtdTemp() { - return pcsYtdTemp; - } - - public void setPcsYtdTemp(BigDecimal pcsYtdTemp) { - this.pcsYtdTemp = pcsYtdTemp; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index ad02af4..f7c704e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -100,8 +100,48 @@ public interface EmsPcsDataMapper /** * 根据时间按天获取充放电量 - * @param requestVo + * @param siteId + * @param startDate + * @param endDate * @return */ - public List getPcsDataByDate(DateSearchRequest requestVo); + public List getPcsDataByDay(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + /** + * 根据时间按月获取充放电量 + * @param siteId + * @param startDate + * @param endDate + * @return + */ + public List getPcsDataByMonth(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + /** + * 根据时间按小时获取充放电量 + * @param siteId + * @param startDate + * @param endDate + * @return + */ + public List getPcsDataByHour(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + + /** + * 获取实时运行-储能功率 + * @param siteId + * @param startDate + * @param endDate + * @return + */ + public List getStoragePowerList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + + /** + * 获取实时运行-pcs平均温度 + * @param siteId + * @param startDate + * @param endDate + * @return + */ + public List getPcsAveTempList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + + public List getAveSocList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + + public List getBatteryAveTempList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index bd59fc7..2b757d0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -43,10 +44,28 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // 如果没有传时间,默认从今天往前7天 LocalDate sevenDaysAgo = LocalDate.now().minusDays(6); startDate = DateUtils.toDate(sevenDaysAgo); - requestVo.setStartDate(startDate); + endDate = new Date(); } - // 根据时间获取每天的充放电量 - List dataList = emsPcsDataMapper.getPcsDataByDate(requestVo); + + List dataList = new ArrayList(); + // 开始日期和结束日期同一天,展示 0-24 小时数据 + if (DateUtils.isSameDay(startDate, endDate)){ + electricDataInfoVo.setUnit("时"); + endDate = DateUtils.addDays(endDate, 1); + dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 + && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ + electricDataInfoVo.setUnit("日"); + endDate = DateUtils.addDays(endDate, 1); + // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 + dataList = emsPcsDataMapper.getPcsDataByDay(requestVo.getSiteId(), startDate, endDate); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ + electricDataInfoVo.setUnit("月"); + endDate = DateUtils.addDays(endDate, 1); + // 开始日期-结束日期大于 1 个月,按月展示数据 + dataList = emsPcsDataMapper.getPcsDataByMonth(requestVo.getSiteId(), startDate, endDate); + } + // 根据时间获取每天的充放电量 if (!CollectionUtils.isEmpty(dataList)){ // 总充、总放、效率 BigDecimal totalDischarge = new BigDecimal(0); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 4ffb995..87e0733 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -300,9 +300,9 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); // 功率与能量类字段 - pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); + pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("YGGL"))); pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); - pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); + pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("XTWGGL"))); pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index c5ccee9..0a6fa42 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -4,6 +4,7 @@ import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.AmmeterCategory; import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.domain.vo.*; @@ -132,10 +133,21 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public SiteMonitorRuningInfoVo getRunningGraph(String siteId) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); if (!StringUtils.isEmpty(siteId)) { + // 时间暂定今日+昨日 + Date today = new Date(); + Date yesterday = DateUtils.addDays(today, -1); //储能功率list + List energyStoragePowList = emsPcsDataMapper.getStoragePowerList(siteId, yesterday, today); + siteMonitorRuningInfoVo.setEnergyStoragePowList(energyStoragePowList); //pcs平均温度list + List pcsAveTempVos = emsPcsDataMapper.getPcsAveTempList(siteId, yesterday, today); + siteMonitorRuningInfoVo.setPcsAveTempList(pcsAveTempVos); //电池平均soclist + List batteryAveSOCList = emsPcsDataMapper.getAveSocList(siteId, yesterday, today); + siteMonitorRuningInfoVo.setBatteryAveSOCList(batteryAveSOCList); //电池平均温度list + List batteryAveTempList = emsPcsDataMapper.getBatteryAveTempList(siteId, yesterday, today); + siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); } return siteMonitorRuningInfoVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 919d039..d73b87a 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -372,10 +372,10 @@ order by tmp.device_id - select CONCAT(t.date_month,'/',t.date_day) as ammeterDate, - sum(t.daily_ac_charge_energy) as chargedCap, - sum(t.daily_ac_discharge_energy) as disChargedCap + sum(t.total_ac_charge_energy) as chargedCap, + sum(t.total_ac_discharge_energy) as disChargedCap from ( SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time FROM ems_pcs_data p where p.site_id = #{siteId} @@ -383,15 +383,115 @@ and p.data_update_time >= #{startDate} - and p.data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) + and p.data_update_time < #{endDate} - GROUP BY p.site_id,p.device_id,p.date_month,p.date_day + GROUP BY p.site_id,p.device_id,p.date_month,p.date_day ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id AND latest.device_id = t.device_id AND latest.max_update_time = t.data_update_time and latest.date_month = t.date_month and latest.date_day = t.date_day group by ammeterDate - order by ammeterDate desc; + order by ammeterDate desc + + + + + + + + + + + + + \ No newline at end of file -- 2.49.0 From 733afa99bd592a66311a7d173faa28e474e78c6b Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 5 Jul 2025 23:24:46 +0800 Subject: [PATCH 057/336] =?UTF-8?q?=E7=94=B5=E8=A1=A8=E7=B1=BB=E5=88=AB-?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/xzzn/common/enums/AmmeterCategory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java index 978b342..406c628 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java @@ -8,7 +8,7 @@ package com.xzzn.common.enums; public enum AmmeterCategory { CURRENT_COMB_ACTIVE("1", "当前组合有功电能"), - CURRENT_COMB_REACTIVE("2", "当前组合无功"), + CURRENT_COMB_REACTIVE("2", "当前组合无功电能"), A_POWER("3", "A相功率"), B_POWER("4", "B相功率"), C_POWER("5", "C相功率"); -- 2.49.0 From b2a964cb826f1a5896b48e6c6c5b7d61e9a01583 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 7 Jul 2025 15:00:59 +0800 Subject: [PATCH 058/336] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 24 ++++++++++-- .../xzzn/ems/service/ISingleSiteService.java | 8 +++- .../service/impl/SingleSiteServiceImpl.java | 37 ++++++++++++++++++- .../resources/mapper/ems/EmsPcsDataMapper.xml | 6 +-- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 23b224b..b0cc3b7 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -46,10 +46,28 @@ public class EmsSiteMonitorController extends BaseController{ /** * 单站监控-设备监控-实时运行曲线图数据 */ - @GetMapping("/runningGraph") - public AjaxResult getRunningGraph(@RequestParam String siteId) + @GetMapping("/runningGraph/storagePower") + public AjaxResult getRunningGraphStorage(@RequestParam String siteId) { - return success(iSingleSiteService.getRunningGraph(siteId)); + return success(iSingleSiteService.getRunningGraphStorage(siteId)); + } + + @GetMapping("/runningGraph/pcsAveTemp") + public AjaxResult getRunningGraphPcsTemp(@RequestParam String siteId) + { + return success(iSingleSiteService.getRunningGraphPcsTemp(siteId)); + } + + @GetMapping("/runningGraph/batteryAveSoc") + public AjaxResult getRunningGraphBatterySoc(@RequestParam String siteId) + { + return success(iSingleSiteService.getRunningGraphBatterySoc(siteId)); + } + + @GetMapping("/runningGraph/batteryAveTemp") + public AjaxResult getRunningGraphBatteryTemp(@RequestParam String siteId) + { + return success(iSingleSiteService.getRunningGraphBatteryTemp(siteId)); } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 684b56b..a6af0a3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -17,7 +17,7 @@ public interface ISingleSiteService public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId); - public SiteMonitorRuningInfoVo getRunningGraph(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphStorage(String siteId); public List getPcsDetailInfo(String siteId); @@ -30,4 +30,10 @@ public interface ISingleSiteService public List getClusterDataInfoList(String clusterDeviceId,String siteId); public AmmeterDataResponse getAmmeterDataList(String siteId); + + public SiteMonitorRuningInfoVo getRunningGraphPcsTemp(String siteId); + + public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId); + + public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 0a6fa42..13279bf 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -128,9 +128,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return siteMonitorRunningHeadInfoVo; } - // 获取单站监控实时运行曲线图数据 + // 获取单站监控实时运行-储能功率数据 @Override - public SiteMonitorRuningInfoVo getRunningGraph(String siteId) { + public SiteMonitorRuningInfoVo getRunningGraphStorage(String siteId) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); if (!StringUtils.isEmpty(siteId)) { // 时间暂定今日+昨日 @@ -139,12 +139,45 @@ public class SingleSiteServiceImpl implements ISingleSiteService { //储能功率list List energyStoragePowList = emsPcsDataMapper.getStoragePowerList(siteId, yesterday, today); siteMonitorRuningInfoVo.setEnergyStoragePowList(energyStoragePowList); + } + return siteMonitorRuningInfoVo; + } + // 获取单站监控实时运行-poc平均温度 + @Override + public SiteMonitorRuningInfoVo getRunningGraphPcsTemp(String siteId) { + SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); + if (!StringUtils.isEmpty(siteId)) { + // 时间暂定今日+昨日 + Date today = new Date(); + Date yesterday = DateUtils.addDays(today, -1); //pcs平均温度list List pcsAveTempVos = emsPcsDataMapper.getPcsAveTempList(siteId, yesterday, today); siteMonitorRuningInfoVo.setPcsAveTempList(pcsAveTempVos); + } + return siteMonitorRuningInfoVo; + } + // 获取单站监控实时运行-电池平均soc + @Override + public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId) { + SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); + if (!StringUtils.isEmpty(siteId)) { + // 时间暂定今日+昨日 + Date today = new Date(); + Date yesterday = DateUtils.addDays(today, -1); //电池平均soclist List batteryAveSOCList = emsPcsDataMapper.getAveSocList(siteId, yesterday, today); siteMonitorRuningInfoVo.setBatteryAveSOCList(batteryAveSOCList); + } + return siteMonitorRuningInfoVo; + } + // 获取单站监控实时运行-电池平均温度 + @Override + public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId) { + SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); + if (!StringUtils.isEmpty(siteId)) { + // 时间暂定今日+昨日 + Date today = new Date(); + Date yesterday = DateUtils.addDays(today, -1); //电池平均温度list List batteryAveTempList = emsPcsDataMapper.getBatteryAveTempList(siteId, yesterday, today); siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index d73b87a..bb20358 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -373,7 +373,7 @@ @@ -104,6 +107,9 @@ and ac_switch_status = #{acSwitchStatus} and dc_switch_status = #{dcSwitchStatus} and remote_control_status = #{remoteControlStatus} + and sys_u_current = #{sysUCurrent} + and sys_v_current = #{sysVCurrent} + and sys_w_current = #{sysWCurrent} @@ -162,6 +168,9 @@ ac_switch_status, dc_switch_status, remote_control_status, + sys_u_current, + sys_v_current, + sys_w_current, #{dataUpdateTime}, @@ -211,6 +220,9 @@ #{acSwitchStatus}, #{dcSwitchStatus}, #{remoteControlStatus}, + #{sysUCurrent}, + #{sysVCurrent}, + #{sysWCurrent}, @@ -264,6 +276,9 @@ ac_switch_status = #{acSwitchStatus}, dc_switch_status = #{dcSwitchStatus}, remote_control_status = #{remoteControlStatus}, + sys_u_current = #{sysUCurrent}, + sys_v_current = #{sysVCurrent}, + sys_w_current = #{sysWCurrent}, where id = #{id} -- 2.49.0 From 7d1f1836d8f076f1367772adc55020f07be44d6a Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 7 Jul 2025 22:15:01 +0800 Subject: [PATCH 060/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-pc?= =?UTF-8?q?s=E6=9B=B2=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 6 +- .../ems/EmsStatisticalReportController.java | 15 ++ .../xzzn/ems/domain/vo/DateSearchRequest.java | 20 +++ .../xzzn/ems/domain/vo/ElectricIndexList.java | 2 +- .../domain/vo/SiteMonitorRuningInfoVo.java | 10 +- ...{PCSAveTempVo.java => StackAveTempVo.java} | 14 +- .../ems/mapper/EmsBatteryClusterMapper.java | 15 ++ .../ems/mapper/EmsBatteryStackMapper.java | 10 +- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 12 +- .../ems/service/IEmsStatsReportService.java | 7 +- .../xzzn/ems/service/ISingleSiteService.java | 2 +- .../impl/EmsStatsReportServiceImpl.java | 53 +++++- .../service/impl/SingleSiteServiceImpl.java | 12 +- .../mapper/ems/EmsBatteryClusterMapper.xml | 29 ++++ .../mapper/ems/EmsBatteryStackMapper.xml | 14 ++ .../resources/mapper/ems/EmsPcsDataMapper.xml | 164 +++++++++++------- 16 files changed, 282 insertions(+), 103 deletions(-) rename ems-system/src/main/java/com/xzzn/ems/domain/vo/{PCSAveTempVo.java => StackAveTempVo.java} (61%) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index b0cc3b7..bbbdd7e 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -52,10 +52,10 @@ public class EmsSiteMonitorController extends BaseController{ return success(iSingleSiteService.getRunningGraphStorage(siteId)); } - @GetMapping("/runningGraph/pcsAveTemp") - public AjaxResult getRunningGraphPcsTemp(@RequestParam String siteId) + @GetMapping("/runningGraph/stackAveTemp") + public AjaxResult getRunningGraphStackTemp(@RequestParam String siteId) { - return success(iSingleSiteService.getRunningGraphPcsTemp(siteId)); + return success(iSingleSiteService.getRunningGraphStackTemp(siteId)); } @GetMapping("/runningGraph/batteryAveSoc") diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index 761484f..ba31ec0 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -45,4 +45,19 @@ public class EmsStatisticalReportController extends BaseController } } + /** + * 概率统计-PCS曲线 + */ + @GetMapping("/getPCSData") + public AjaxResult getPCSData(DateSearchRequest requestVo) + { + if (!StringUtils.isEmpty(requestVo.getSiteId()) && + !StringUtils.isEmpty(requestVo.getDeviceId()) && + requestVo.getDataType() != 0) { + return success(ieEmsStatsReportService.getPCSDataResult(requestVo)); + } else { + return error("缺少必传项"); + } + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java index 123d55d..966e6c2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java @@ -21,6 +21,10 @@ public class DateSearchRequest { private String siteId; + private String deviceId; + + private int dataType; + public Date getStartDate() { return startDate; } @@ -44,4 +48,20 @@ public class DateSearchRequest { public void setSiteId(String siteId) { this.siteId = siteId; } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public int getDataType() { + return dataType; + } + + public void setDataType(int dataType) { + this.dataType = dataType; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java index bc99c36..78d2df5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java @@ -3,7 +3,7 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; /** - * 首页看板数据概览-电量指标 + * 数据统计-电量指标 */ public class ElectricIndexList { /** diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java index 8b52473..fd2dcd1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java @@ -15,7 +15,7 @@ public class SiteMonitorRuningInfoVo { /** * pcs平均温度list */ - private List pcsAveTempList; + private List stackAveTempList; /** * 电池平均soclist @@ -35,12 +35,12 @@ public class SiteMonitorRuningInfoVo { this.energyStoragePowList = energyStoragePowList; } - public List getPcsAveTempList() { - return pcsAveTempList; + public List getStackAveTempList() { + return stackAveTempList; } - public void setPcsAveTempList(List pcsAveTempList) { - this.pcsAveTempList = pcsAveTempList; + public void setStackAveTempList(List stackAveTempList) { + this.stackAveTempList = stackAveTempList; } public List getBatteryAveSOCList() { diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSAveTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackAveTempVo.java similarity index 61% rename from ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSAveTempVo.java rename to ems-system/src/main/java/com/xzzn/ems/domain/vo/StackAveTempVo.java index 1af5cbf..1fe2c2d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSAveTempVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackAveTempVo.java @@ -4,10 +4,10 @@ import java.math.BigDecimal; import java.util.Date; /** - * 实时运行-pcs平均温度数据 + * 实时运行-堆平均温度数据 * */ -public class PCSAveTempVo { +public class StackAveTempVo { /** * 数据时间 */ @@ -16,7 +16,7 @@ public class PCSAveTempVo { /** * 实时温度 */ - private BigDecimal pcsTemp; + private BigDecimal temp; public Date getCreateDate() { @@ -27,11 +27,11 @@ public class PCSAveTempVo { this.createDate = createDate; } - public BigDecimal getPcsTemp() { - return pcsTemp; + public BigDecimal getTemp() { + return temp; } - public void setPcsTemp(BigDecimal pcsTemp) { - this.pcsTemp = pcsTemp; + public void setTemp(BigDecimal temp) { + this.temp = temp; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java index aa6017e..e641c30 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java @@ -1,8 +1,11 @@ package com.xzzn.ems.mapper; +import java.util.Date; import java.util.List; import com.xzzn.ems.domain.EmsBatteryCluster; import com.xzzn.ems.domain.vo.BMSBatteryDataList; +import com.xzzn.ems.domain.vo.BatteryAveSOCVo; +import com.xzzn.ems.domain.vo.BatteryAveTempVo; import org.apache.ibatis.annotations.Param; /** @@ -68,4 +71,16 @@ public interface EmsBatteryClusterMapper * @return */ public List getBmsBatteryData(@Param("siteId")String siteId, @Param("stackDeviceId")String stackDeviceId); + + /** + * 实时运行-平均soc+平均温度 + * @param siteId + * @param startDate + * @param endDate + * @return + */ + public List getAveSocList(@Param("siteId")String siteId, @Param("startDate") Date startDate, @Param("endDate")Date endDate); + + public List getBatteryAveTempList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java index 7347fc6..be1fe01 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java @@ -1,8 +1,10 @@ package com.xzzn.ems.mapper; +import java.util.Date; import java.util.List; import com.xzzn.ems.domain.EmsBatteryStack; -import com.xzzn.ems.domain.vo.BMSOverViewVo; +import com.xzzn.ems.domain.vo.StackAveTempVo; +import org.apache.ibatis.annotations.Param; /** * 电池堆数据Mapper接口 @@ -61,9 +63,11 @@ public interface EmsBatteryStackMapper public int deleteEmsBatteryStackByIds(Long[] ids); /** - * 获取电池堆信息 + * 获取实时运行-堆平均温度 * @param siteId + * @param startDate + * @param endDate * @return */ - public List selectEmsBatteryStackBySiteId(String siteId); + public List getStackAveTempList(@Param("siteId")String siteId, @Param("startDate") Date startDate, @Param("endDate")Date endDate); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index f7c704e..0c8fab4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -133,15 +133,13 @@ public interface EmsPcsDataMapper public List getStoragePowerList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); /** - * 获取实时运行-pcs平均温度 - * @param siteId - * @param startDate - * @param endDate + * pcs曲线运行数据 + * @param requestVo * @return */ - public List getPcsAveTempList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + public List getPcsActivePowerByDay(DateSearchRequest requestVo); - public List getAveSocList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + public List getPcsActivePowerByHour(DateSearchRequest requestVo); - public List getBatteryAveTempList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + public List getPcsActivePowerByMonth(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java index 114bf3b..11ede39 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java @@ -1,7 +1,10 @@ package com.xzzn.ems.service; import com.xzzn.ems.domain.vo.DateSearchRequest; -import com.xzzn.ems.domain.vo.ElectricDataInfoVo;;import java.util.Date; +import com.xzzn.ems.domain.vo.ElectricDataInfoVo; +import com.xzzn.ems.domain.vo.PcsStatisListVo; + +import java.util.List; /** * 统计报表数据Service接口 @@ -13,4 +16,6 @@ public interface IEmsStatsReportService { public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo); + + public List getPCSDataResult(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index a6af0a3..398e12b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -31,7 +31,7 @@ public interface ISingleSiteService public AmmeterDataResponse getAmmeterDataList(String siteId); - public SiteMonitorRuningInfoVo getRunningGraphPcsTemp(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphStackTemp(String siteId); public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 2b757d0..6b0aba3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -3,6 +3,7 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.vo.DateSearchRequest; import com.xzzn.ems.domain.vo.ElectricDataInfoVo; +import com.xzzn.ems.domain.vo.PcsStatisListVo; import com.xzzn.ems.domain.vo.SiteMonitorDataVo; import com.xzzn.ems.mapper.EmsPcsDataMapper; import com.xzzn.ems.service.IEmsStatsReportService; @@ -38,14 +39,10 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { ElectricDataInfoVo electricDataInfoVo = new ElectricDataInfoVo(); + // 默认时间处理 + dealRequestTime(requestVo); Date startDate = requestVo.getStartDate(); Date endDate = requestVo.getEndDate(); - if (startDate == null && endDate == null) { - // 如果没有传时间,默认从今天往前7天 - LocalDate sevenDaysAgo = LocalDate.now().minusDays(6); - startDate = DateUtils.toDate(sevenDaysAgo); - endDate = new Date(); - } List dataList = new ArrayList(); // 开始日期和结束日期同一天,展示 0-24 小时数据 @@ -93,4 +90,48 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService } return electricDataInfoVo; } + + @Override + public List getPCSDataResult(DateSearchRequest requestVo) { + List dataList = new ArrayList(); + + // 默认时间-7天 + dealRequestTime(requestVo); + Date startDate = requestVo.getStartDate(); + Date endDate = requestVo.getEndDate(); + + // 开始日期和结束日期同一天,展示 0-24 小时数据 + if (DateUtils.isSameDay(startDate, endDate)){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + dataList = emsPcsDataMapper.getPcsActivePowerByHour(requestVo); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 + && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 + dataList = emsPcsDataMapper.getPcsActivePowerByDay(requestVo); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 个月,按月展示数据 + dataList = emsPcsDataMapper.getPcsActivePowerByMonth(requestVo); + } + return dataList; + } + + // 统计入参时间处理 + public void dealRequestTime(DateSearchRequest requestVo){ + + Date startDate = requestVo.getStartDate(); + Date endDate = requestVo.getEndDate(); + if (startDate == null && endDate == null) { + // 如果没有传时间,默认从今天往前7天 + LocalDate sevenDaysAgo = LocalDate.now().minusDays(6); + startDate = DateUtils.toDate(sevenDaysAgo); + endDate = new Date(); + requestVo.setStartDate(startDate); + requestVo.setEndDate(endDate); + } + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 13279bf..7771d46 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -142,17 +142,17 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } return siteMonitorRuningInfoVo; } - // 获取单站监控实时运行-poc平均温度 + // 获取单站监控实时运行-stack平均温度 @Override - public SiteMonitorRuningInfoVo getRunningGraphPcsTemp(String siteId) { + public SiteMonitorRuningInfoVo getRunningGraphStackTemp(String siteId) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); if (!StringUtils.isEmpty(siteId)) { // 时间暂定今日+昨日 Date today = new Date(); Date yesterday = DateUtils.addDays(today, -1); //pcs平均温度list - List pcsAveTempVos = emsPcsDataMapper.getPcsAveTempList(siteId, yesterday, today); - siteMonitorRuningInfoVo.setPcsAveTempList(pcsAveTempVos); + List stackAveTempVos = emsBatteryStackMapper.getStackAveTempList(siteId, yesterday, today); + siteMonitorRuningInfoVo.setStackAveTempList(stackAveTempVos); } return siteMonitorRuningInfoVo; } @@ -165,7 +165,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { Date today = new Date(); Date yesterday = DateUtils.addDays(today, -1); //电池平均soclist - List batteryAveSOCList = emsPcsDataMapper.getAveSocList(siteId, yesterday, today); + List batteryAveSOCList = emsBatteryClusterMapper.getAveSocList(siteId, yesterday, today); siteMonitorRuningInfoVo.setBatteryAveSOCList(batteryAveSOCList); } return siteMonitorRuningInfoVo; @@ -179,7 +179,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { Date today = new Date(); Date yesterday = DateUtils.addDays(today, -1); //电池平均温度list - List batteryAveTempList = emsPcsDataMapper.getBatteryAveTempList(siteId, yesterday, today); + List batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, yesterday, today); siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); } return siteMonitorRuningInfoVo; diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 637a727..d476469 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -325,4 +325,33 @@ group by t.cluster_voltage,t.cluster_current,t.current_soc,t.site_id,t.device_id,t.max_cell_voltage,t.min_cell_voltage, t.max_cell_temp,t.min_cell_temp + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index c8f23c5..a954f18 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -274,4 +274,18 @@ #{id} + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index a6f1ae8..69b287e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -387,19 +387,23 @@ order by tmp.device_id + + WHERE p.site_id = #{siteId} + + AND p.data_update_time >= #{startDate} + + + AND p.data_update_time < #{endDate} + + + - - - - - - + + + WHERE p.site_id = #{siteId} + and p.device_id = #{deviceId} + + AND p.data_update_time >= DATE(#{startDate}) + + + AND p.data_update_time < DATE(#{endDate}) + + + + + + + t.total_active_power as activePower + + + t.total_reactive_power as reactivePower + + + t.sys_u_current as uCurrent, + t.sys_v_current as vCurrent, + t.sys_w_current as wCurrent + + + + + + + + ,activePower + + + ,reactivePower + + + ,uCurrent,vCurrent,wCurrent + + + + + + + + \ No newline at end of file -- 2.49.0 From 13266bdbd56fa1f134c7005aabec1aeef5d5ef7d Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 8 Jul 2025 14:46:42 +0800 Subject: [PATCH 061/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E7=94=B5=E6=B1=A0=E5=A0=86=E6=9B=B2=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 15 ++++ .../xzzn/ems/domain/vo/PcsStatisListVo.java | 86 ++++++++++++++++++ .../xzzn/ems/domain/vo/StackStatisListVo.java | 73 +++++++++++++++ .../ems/mapper/EmsBatteryStackMapper.java | 13 +++ .../ems/service/IEmsStatsReportService.java | 3 + .../impl/EmsStatsReportServiceImpl.java | 39 +++++++- .../mapper/ems/EmsBatteryStackMapper.xml | 89 +++++++++++++++++++ 7 files changed, 314 insertions(+), 4 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index ba31ec0..fa9b256 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -60,4 +60,19 @@ public class EmsStatisticalReportController extends BaseController } } + /** + * 概率统计-电池堆曲线 + */ + @GetMapping("/getStackData") + public AjaxResult getStackData(DateSearchRequest requestVo) + { + if (!StringUtils.isEmpty(requestVo.getSiteId()) && + !StringUtils.isEmpty(requestVo.getDeviceId()) && + requestVo.getDataType() != 0) { + return success(ieEmsStatsReportService.getStackDataResult(requestVo)); + } else { + return error("缺少必传项"); + } + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java new file mode 100644 index 0000000..e22fa71 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java @@ -0,0 +1,86 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 数据统计-pcs曲线-通用对象 + */ +public class PcsStatisListVo { + /** + * 数据日期 + */ + private String statisDate; + + /** + * 有功 + */ + private BigDecimal activePower; + + /** + * 无功 + */ + private BigDecimal reactivePower; + + /** + * u电流 + */ + private BigDecimal uCurrent; + + /** + * v电流 + */ + private BigDecimal vCurrent; + + /** + * w电流 + */ + private BigDecimal wCurrent; + + public String getStatisDate() { + return statisDate; + } + + public void setStatisDate(String statisDate) { + this.statisDate = statisDate; + } + + public BigDecimal getActivePower() { + return activePower; + } + + public void setActivePower(BigDecimal activePower) { + this.activePower = activePower; + } + + public BigDecimal getReactivePower() { + return reactivePower; + } + + public void setReactivePower(BigDecimal reactivePower) { + this.reactivePower = reactivePower; + } + + public BigDecimal getuCurrent() { + return uCurrent; + } + + public void setuCurrent(BigDecimal uCurrent) { + this.uCurrent = uCurrent; + } + + public BigDecimal getvCurrent() { + return vCurrent; + } + + public void setvCurrent(BigDecimal vCurrent) { + this.vCurrent = vCurrent; + } + + public BigDecimal getwCurrent() { + return wCurrent; + } + + public void setwCurrent(BigDecimal wCurrent) { + this.wCurrent = wCurrent; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java new file mode 100644 index 0000000..3038d51 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java @@ -0,0 +1,73 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 数据统计-堆曲线-通用对象 + */ +public class StackStatisListVo { + /** + * 数据日期 + */ + private String statisDate; + + /** + * 有功 + */ + private BigDecimal temp; + + /** + * 无功 + */ + private BigDecimal voltage; + + /** + * u电流 + */ + private BigDecimal current; + + /** + * v电流 + */ + private BigDecimal soc; + + public String getStatisDate() { + return statisDate; + } + + public void setStatisDate(String statisDate) { + this.statisDate = statisDate; + } + + public BigDecimal getTemp() { + return temp; + } + + public void setTemp(BigDecimal temp) { + this.temp = temp; + } + + public BigDecimal getVoltage() { + return voltage; + } + + public void setVoltage(BigDecimal voltage) { + this.voltage = voltage; + } + + public BigDecimal getCurrent() { + return current; + } + + public void setCurrent(BigDecimal current) { + this.current = current; + } + + public BigDecimal getSoc() { + return soc; + } + + public void setSoc(BigDecimal soc) { + this.soc = soc; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java index be1fe01..1d13252 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java @@ -3,7 +3,9 @@ package com.xzzn.ems.mapper; import java.util.Date; import java.util.List; import com.xzzn.ems.domain.EmsBatteryStack; +import com.xzzn.ems.domain.vo.DateSearchRequest; import com.xzzn.ems.domain.vo.StackAveTempVo; +import com.xzzn.ems.domain.vo.StackStatisListVo; import org.apache.ibatis.annotations.Param; /** @@ -70,4 +72,15 @@ public interface EmsBatteryStackMapper * @return */ public List getStackAveTempList(@Param("siteId")String siteId, @Param("startDate") Date startDate, @Param("endDate")Date endDate); + + /** + * 堆曲线数据-按小时区分 + * @param requestVo + * @return + */ + public List getStackDataByHour(DateSearchRequest requestVo); + + public List getStackDataByDay(DateSearchRequest requestVo); + + public List getStackDataByMonth(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java index 11ede39..e71a1ee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java @@ -3,6 +3,7 @@ package com.xzzn.ems.service; import com.xzzn.ems.domain.vo.DateSearchRequest; import com.xzzn.ems.domain.vo.ElectricDataInfoVo; import com.xzzn.ems.domain.vo.PcsStatisListVo; +import com.xzzn.ems.domain.vo.StackStatisListVo; import java.util.List; @@ -18,4 +19,6 @@ public interface IEmsStatsReportService public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo); public List getPCSDataResult(DateSearchRequest requestVo); + + public List getStackDataResult(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 6b0aba3..8078de9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -1,10 +1,9 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.utils.DateUtils; -import com.xzzn.ems.domain.vo.DateSearchRequest; -import com.xzzn.ems.domain.vo.ElectricDataInfoVo; -import com.xzzn.ems.domain.vo.PcsStatisListVo; -import com.xzzn.ems.domain.vo.SiteMonitorDataVo; +import com.xzzn.ems.domain.vo.*; +import com.xzzn.ems.mapper.EmsBatteryDataMapper; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; import com.xzzn.ems.mapper.EmsPcsDataMapper; import com.xzzn.ems.service.IEmsStatsReportService; import org.slf4j.Logger; @@ -34,6 +33,10 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Autowired private EmsPcsDataMapper emsPcsDataMapper; + @Autowired + private EmsBatteryDataMapper emsBatteryDataMapper; + @Autowired + private EmsBatteryStackMapper emsBatteryStackMapper; @Override public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { @@ -120,6 +123,34 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return dataList; } + @Override + public List getStackDataResult(DateSearchRequest requestVo) { + List dataList = new ArrayList(); + // 默认时间-7天 + dealRequestTime(requestVo); + Date startDate = requestVo.getStartDate(); + Date endDate = requestVo.getEndDate(); + + // 开始日期和结束日期同一天,展示 0-24 小时数据 + if (DateUtils.isSameDay(startDate, endDate)){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + dataList = emsBatteryStackMapper.getStackDataByHour(requestVo); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 + && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 + dataList = emsBatteryStackMapper.getStackDataByDay(requestVo); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 个月,按月展示数据 + dataList = emsBatteryStackMapper.getStackDataByMonth(requestVo); + } + return dataList; + } + // 统计入参时间处理 public void dealRequestTime(DateSearchRequest requestVo){ diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index a954f18..a1516ca 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -288,4 +288,93 @@ GROUP BY site_id,create_time ) temp on t.site_id = temp.site_id and t.create_time = temp.create_time and t.device_id = temp.device_id + + + WHERE p.site_id = #{siteId} + and p.device_id = #{deviceId} + + AND p.update_time >= DATE(#{startDate}) + + + AND p.update_time < DATE(#{endDate}) + + + + + + + t.operating_temp AS temp + + + t.stack_voltage as voltage + + + t.stack_current as current + + + t.stack_soc as soc + + + + + + + + ,temp + + + ,voltage + + + ,current + + + ,soc + + + + + + + + \ No newline at end of file -- 2.49.0 From b0264ebe4665f1639bbea7a318d7773d017b2401 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 8 Jul 2025 16:43:33 +0800 Subject: [PATCH 062/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E7=94=B5=E6=B1=A0=E6=B8=A9=E5=BA=A6=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 23 ++++ .../ems/domain/vo/ClusterStatisListVo.java | 109 ++++++++++++++++++ .../domain/vo/StatisClusterDateRequest.java | 47 ++++++++ .../ems/mapper/EmsBatteryClusterMapper.java | 6 +- .../ems/service/IEmsStatsReportService.java | 7 +- .../impl/EmsStatsReportServiceImpl.java | 16 +++ .../mapper/ems/EmsBatteryClusterMapper.xml | 32 ++++- 7 files changed, 229 insertions(+), 11 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/ClusterStatisListVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index fa9b256..dc8e7e9 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -2,14 +2,20 @@ 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.common.utils.StringUtils; +import com.xzzn.ems.domain.vo.ClusterStatisListVo; import com.xzzn.ems.domain.vo.DateSearchRequest; +import com.xzzn.ems.domain.vo.StatisClusterDateRequest; import com.xzzn.ems.service.IEmsStatsReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.List; + /** * 单站监控-统计报表 * @@ -75,4 +81,21 @@ public class EmsStatisticalReportController extends BaseController } } + /** + * 概率统计-电池温度等数据 + */ + @GetMapping("/getClusterData") + public TableDataInfo getClusterData(StatisClusterDateRequest requestVo) + { + startPage(); + List dataList = new ArrayList<>(); + if (!StringUtils.isEmpty(requestVo.getStackId()) && + !StringUtils.isEmpty(requestVo.getClusterId())) { + dataList = ieEmsStatsReportService.getClusterDataResult(requestVo); + return getDataTable(dataList); + } else { + return getDataTable(dataList); + } + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ClusterStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ClusterStatisListVo.java new file mode 100644 index 0000000..fe66392 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ClusterStatisListVo.java @@ -0,0 +1,109 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 电池簇-电池温度等数据入参 + * + */ +public class ClusterStatisListVo { + + /** 统计时间 */ + private String statisDate; + + /** 最高温度 */ + private BigDecimal maxTemp; + + /** 最高温度单体ID */ + private String maxTempId; + + /** 最低温度 */ + private BigDecimal minTemp; + + /** 最低温度单体ID */ + private String minTempId; + + /** 最高电压 */ + private BigDecimal maxVoltage; + + /** 最高电压单体ID */ + private String maxVoltageId; + + /** 最低电压 */ + private BigDecimal minVoltage; + + /** 最低电压单体ID */ + private String minVoltageId; + + public String getStatisDate() { + return statisDate; + } + + public void setStatisDate(String statisDate) { + this.statisDate = statisDate; + } + + public BigDecimal getMaxTemp() { + return maxTemp; + } + + public void setMaxTemp(BigDecimal maxTemp) { + this.maxTemp = maxTemp; + } + + public String getMaxTempId() { + return maxTempId; + } + + public void setMaxTempId(String maxTempId) { + this.maxTempId = maxTempId; + } + + public BigDecimal getMinTemp() { + return minTemp; + } + + public void setMinTemp(BigDecimal minTemp) { + this.minTemp = minTemp; + } + + public String getMinTempId() { + return minTempId; + } + + public void setMinTempId(String minTempId) { + this.minTempId = minTempId; + } + + public BigDecimal getMaxVoltage() { + return maxVoltage; + } + + public void setMaxVoltage(BigDecimal maxVoltage) { + this.maxVoltage = maxVoltage; + } + + public String getMaxVoltageId() { + return maxVoltageId; + } + + public void setMaxVoltageId(String maxVoltageId) { + this.maxVoltageId = maxVoltageId; + } + + public BigDecimal getMinVoltage() { + return minVoltage; + } + + public void setMinVoltage(BigDecimal minVoltage) { + this.minVoltage = minVoltage; + } + + public String getMinVoltageId() { + return minVoltageId; + } + + public void setMinVoltageId(String minVoltageId) { + this.minVoltageId = minVoltageId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java new file mode 100644 index 0000000..f4c67c8 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java @@ -0,0 +1,47 @@ +package com.xzzn.ems.domain.vo; + + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +/** + * 电池簇-电池温度等数据入参 + * + */ +public class StatisClusterDateRequest { + + /** + * 筛选时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date dateTime; + + private String stackId; + + private String clusterId; + + public Date getDateTime() { + return dateTime; + } + + public void setDateTime(Date dateTime) { + this.dateTime = dateTime; + } + + public String getStackId() { + return stackId; + } + + public void setStackId(String stackId) { + this.stackId = stackId; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java index e641c30..fe0e99a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java @@ -3,9 +3,7 @@ package com.xzzn.ems.mapper; import java.util.Date; import java.util.List; import com.xzzn.ems.domain.EmsBatteryCluster; -import com.xzzn.ems.domain.vo.BMSBatteryDataList; -import com.xzzn.ems.domain.vo.BatteryAveSOCVo; -import com.xzzn.ems.domain.vo.BatteryAveTempVo; +import com.xzzn.ems.domain.vo.*; import org.apache.ibatis.annotations.Param; /** @@ -83,4 +81,6 @@ public interface EmsBatteryClusterMapper public List getBatteryAveTempList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + /** 堆电池温度数据-获取当天每小时簇 */ + public List getClusterDataByHour(StatisClusterDateRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java index e71a1ee..eae3edb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java @@ -1,9 +1,6 @@ package com.xzzn.ems.service; -import com.xzzn.ems.domain.vo.DateSearchRequest; -import com.xzzn.ems.domain.vo.ElectricDataInfoVo; -import com.xzzn.ems.domain.vo.PcsStatisListVo; -import com.xzzn.ems.domain.vo.StackStatisListVo; +import com.xzzn.ems.domain.vo.*; import java.util.List; @@ -21,4 +18,6 @@ public interface IEmsStatsReportService public List getPCSDataResult(DateSearchRequest requestVo); public List getStackDataResult(DateSearchRequest requestVo); + + public List getClusterDataResult(StatisClusterDateRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 8078de9..925d874 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -2,6 +2,7 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.vo.*; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; import com.xzzn.ems.mapper.EmsBatteryDataMapper; import com.xzzn.ems.mapper.EmsBatteryStackMapper; import com.xzzn.ems.mapper.EmsPcsDataMapper; @@ -37,6 +38,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService private EmsBatteryDataMapper emsBatteryDataMapper; @Autowired private EmsBatteryStackMapper emsBatteryStackMapper; + @Autowired + private EmsBatteryClusterMapper emsBatteryClusterMapper; @Override public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { @@ -151,6 +154,19 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return dataList; } + @Override + public List getClusterDataResult(StatisClusterDateRequest requestVo) { + List dataList = new ArrayList(); + // 时间不传默认当天 + if (requestVo.getDateTime() == null) { + requestVo.setDateTime(new Date()); + } + + // 根据时间获取每小时最新数据 + dataList = emsBatteryClusterMapper.getClusterDataByHour(requestVo); + return dataList; + } + // 统计入参时间处理 public void dealRequestTime(DateSearchRequest requestVo){ diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index d476469..96809e0 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -346,12 +346,36 @@ t.avg_cell_temp as batteryTemp, t.create_time as createDate from ems_battery_cluster t - inner join (select site_id,create_time,MIN(device_id) as device_id + inner join (select site_id,create_time,MIN(device_id) as device_id from ems_battery_cluster where site_id = #{siteId} - AND create_time >= Date(#{startDate}) - AND create_time <= #{endDate} - GROUP BY site_id,create_time + AND create_time >= Date(#{startDate}) + AND create_time <= #{endDate} + GROUP BY site_id,create_time ) temp on t.site_id = temp.site_id and t.create_time = temp.create_time and t.device_id = temp.device_id + + \ No newline at end of file -- 2.49.0 From 84d77c2d33700a40f1cb85ad28f4188d3affd803 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 8 Jul 2025 20:13:24 +0800 Subject: [PATCH 063/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E8=8E=B7=E5=8F=96pcs=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/ems/EmsSiteMonitorController.java | 9 +++++++++ .../java/com/xzzn/ems/service/IEmsSiteService.java | 2 ++ .../com/xzzn/ems/service/impl/EmsSiteServiceImpl.java | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index bbbdd7e..5690ef4 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -106,6 +106,15 @@ public class EmsSiteMonitorController extends BaseController{ return success(iEmsSiteService.getAllStackInfo(siteId)); } + /** + * 获取所有pcs + */ + @GetMapping("/getPcsNameList") + public AjaxResult getPcsNameList(@RequestParam String siteId) + { + return success(iEmsSiteService.getAllPcsInfo(siteId)); + } + /** * 获取所有电池簇 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index 8a742a7..51a7a05 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -26,4 +26,6 @@ public interface IEmsSiteService public List getAllSiteInfoList(String siteName, String startTime, String endTime); public List getAllDeviceList(String siteId); + + public List> getAllPcsInfo(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index f05f59b..c73f716 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -78,4 +78,14 @@ public class EmsSiteServiceImpl implements IEmsSiteService public List getAllDeviceList(String siteId) { return emsSiteMapper.getAllSiteDeviceList(siteId); } + + /** + * 根据site_id获取所有pcs + * @param siteId + * @return + */ + @Override + public List> getAllPcsInfo(String siteId) { + return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode()); + } } -- 2.49.0 From 3eb8636e53a72f7eb67405f99e5882b1343a692b Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 9 Jul 2025 14:36:11 +0800 Subject: [PATCH 064/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-sq?= =?UTF-8?q?l=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/ems/EmsBatteryClusterMapper.xml | 8 +++--- .../mapper/ems/EmsBatteryStackMapper.xml | 26 ++----------------- .../resources/mapper/ems/EmsPcsDataMapper.xml | 23 ++-------------- 3 files changed, 7 insertions(+), 50 deletions(-) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 96809e0..7eee732 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -322,7 +322,6 @@ GROUP BY p.site_id,p.device_id ) latest on t.device_id = latest.device_id and t.update_time = latest.max_update_time where t.site_id = #{siteId} and t.stack_device_id = #{stackDeviceId} - group by t.cluster_voltage,t.cluster_current,t.current_soc,t.site_id,t.device_id,t.max_cell_voltage,t.min_cell_voltage, t.max_cell_temp,t.min_cell_temp @@ -335,7 +334,7 @@ inner join (select site_id,create_time,MIN(device_id) as device_id from ems_battery_cluster where site_id = #{siteId} - AND create_time >= Date(#{startDate}) + AND create_time >= #{startDate} AND create_time <= #{endDate} GROUP BY site_id,create_time ) temp on t.site_id = temp.site_id and t.create_time = temp.create_time and t.device_id = temp.device_id @@ -349,7 +348,7 @@ inner join (select site_id,create_time,MIN(device_id) as device_id from ems_battery_cluster where site_id = #{siteId} - AND create_time >= Date(#{startDate}) + AND create_time >= #{startDate} AND create_time <= #{endDate} GROUP BY site_id,create_time ) temp on t.site_id = temp.site_id and t.create_time = temp.create_time and t.device_id = temp.device_id @@ -369,13 +368,12 @@ FROM ems_battery_cluster p WHERE p.stack_device_id = #{stackId} AND p.device_id = #{clusterId} - AND DATE( p.update_time) = DATE(#{dateTime}) + AND DATE(p.update_time) = #{dateTime} GROUP BY p.site_id, p.device_id, statisDate ) latest INNER JOIN ems_battery_cluster t ON latest.site_id = t.site_id AND latest.device_id = t.device_id AND latest.max_update_time = t.update_time - GROUP BY statisDate, maxTemp, maxTempId, minTemp, minTempId, maxVoltage, maxVoltageId, minVoltage, minVoltageId ORDER BY statisDate \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index a1516ca..12d2aba 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -293,10 +293,10 @@ WHERE p.site_id = #{siteId} and p.device_id = #{deviceId} - AND p.update_time >= DATE(#{startDate}) + AND p.update_time >= #{startDate} - AND p.update_time < DATE(#{endDate}) + AND p.update_time < #{endDate} @@ -317,22 +317,6 @@ - - - - ,temp - - - ,voltage - - - ,current - - - ,soc - - - @@ -358,8 +340,6 @@ ) latest inner join ems_battery_stack t ON latest.site_id = t.site_id AND latest.device_id = t.device_id AND latest.max_update_time = t.update_time - group by statisDate - order by statisDate desc @@ -373,8 +353,6 @@ ) latest inner join ems_battery_stack t ON latest.site_id = t.site_id AND latest.device_id = t.device_id AND latest.max_update_time = t.update_time - group by statisDate - order by statisDate desc \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 69b287e..3bdd797 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -464,10 +464,10 @@ WHERE p.site_id = #{siteId} and p.device_id = #{deviceId} - AND p.data_update_time >= DATE(#{startDate}) + AND p.data_update_time >= #{startDate} - AND p.data_update_time < DATE(#{endDate}) + AND p.data_update_time < #{endDate} @@ -487,19 +487,6 @@ - - - - ,activePower - - - ,reactivePower - - - ,uCurrent,vCurrent,wCurrent - - - @@ -528,8 +513,6 @@ AND latest.device_id = t.device_id AND latest.max_update_time = t.data_update_time and latest.date_month = t.date_month - group by statisDate - order by statisDate desc @@ -543,8 +526,6 @@ ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id AND latest.device_id = t.device_id AND latest.max_update_time = t.data_update_time - group by statisDate - order by statisDate desc \ No newline at end of file -- 2.49.0 From 29c5ffc15ca55f8b7410162318f73e138c8aa4f6 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 9 Jul 2025 16:57:41 +0800 Subject: [PATCH 065/336] =?UTF-8?q?=E9=A6=96=E9=A1=B5-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A6=82=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/EmsHomePageController.java | 8 +++-- .../xzzn/ems/domain/vo/AlarmGradeList.java | 34 ++++++++++--------- .../xzzn/ems/domain/vo/ElectricIndexList.java | 6 ++-- .../ems/domain/vo/SystemEfficiencyList.java | 6 ++-- .../ems/mapper/EmsAlarmRecordsMapper.java | 7 ++++ .../impl/EmsStatsReportServiceImpl.java | 4 ++- .../ems/service/impl/HomePageServiceImpl.java | 34 +++++++++++++++++++ .../mapper/ems/EmsAlarmRecordsMapper.xml | 4 +++ .../resources/mapper/ems/EmsPcsDataMapper.xml | 25 ++++++++------ 9 files changed, 92 insertions(+), 36 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsHomePageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsHomePageController.java index 6aa2e3f..23cca2d 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsHomePageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsHomePageController.java @@ -34,9 +34,13 @@ public class EmsHomePageController extends BaseController{ * 首页看板数据 */ @GetMapping("/dataList") - public AjaxResult list() + public AjaxResult list() throws Exception { - return success(homePageService.getHomePageDataList()); + try { + return success(homePageService.getHomePageDataList()); + } catch (Exception e) { + return error(e.getMessage()); + } } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmGradeList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmGradeList.java index 50e9bd0..8378a40 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmGradeList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmGradeList.java @@ -1,5 +1,7 @@ package com.xzzn.ems.domain.vo; +import java.math.BigDecimal; + /** * 首页看板数据概览-告警等级分布 */ @@ -7,39 +9,39 @@ public class AlarmGradeList { /** * 告警等级 */ - private String grade; + private String level; /** * 数据一 */ - private int num1; + private int dataNum; /** - * 数据三 + * 数据占比 */ - private int num2; + private BigDecimal percent; - public String getGrade() { - return grade; + public String getLevel() { + return level; } - public void setGrade(String grade) { - this.grade = grade; + public void setLevel(String level) { + this.level = level; } - public int getNum1() { - return num1; + public int getDataNum() { + return dataNum; } - public void setNum1(int num1) { - this.num1 = num1; + public void setDataNum(int dataNum) { + this.dataNum = dataNum; } - public int getNum2() { - return num2; + public BigDecimal getPercent() { + return percent; } - public void setNum2(int num2) { - this.num2 = num2; + public void setPercent(BigDecimal percent) { + this.percent = percent; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java index 78d2df5..4047b09 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ElectricIndexList.java @@ -9,7 +9,7 @@ public class ElectricIndexList { /** * 月份 */ - private int dateMonth; + private String dateMonth; /** * 充电量 @@ -21,11 +21,11 @@ public class ElectricIndexList { */ private BigDecimal disChargeEnergy; - public int getDateMonth() { + public String getDateMonth() { return dateMonth; } - public void setDateMonth(int dateMonth) { + public void setDateMonth(String dateMonth) { this.dateMonth = dateMonth; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SystemEfficiencyList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SystemEfficiencyList.java index 7fe89f8..6fe7c40 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SystemEfficiencyList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SystemEfficiencyList.java @@ -9,18 +9,18 @@ public class SystemEfficiencyList { /** * 月份 */ - private int dateMonth; + private String dateMonth; /** * 系统效率 */ private BigDecimal systemEfficiency; - public int getDateMonth() { + public String getDateMonth() { return dateMonth; } - public void setDateMonth(int dateMonth) { + public void setDateMonth(String dateMonth) { this.dateMonth = dateMonth; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java index f6b7c86..9f42370 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java @@ -78,5 +78,12 @@ public interface EmsAlarmRecordsMapper */ public List getDeviceAlarmPropList(); + /** + * 获取设备等级分布 + * + */ + public List getAlarmGradeList(); + + public List getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 925d874..dbc7e66 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -81,13 +81,15 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // 计算单天的效率 BigDecimal dailyEfficiency = new BigDecimal(0); - if ( siteMonitorDataVo.getDisChargedCap().compareTo(BigDecimal.ZERO)>0){ + if ( siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){ dailyEfficiency = siteMonitorDataVo.getDisChargedCap().divide(siteMonitorDataVo.getChargedCap(), 2, RoundingMode.HALF_UP); + dailyEfficiency = dailyEfficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); } siteMonitorDataVo.setDailyEfficiency(dailyEfficiency); } if ( totalCharge.compareTo(BigDecimal.ZERO)>0){ efficiency = totalDischarge.divide(totalCharge, 2, RoundingMode.HALF_UP); + efficiency = efficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); } electricDataInfoVo.setSevenDayDisChargeStats(dataList); electricDataInfoVo.setTotalDisChargedCap(totalDischarge); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index 744645a..48f1f4a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.*; /** @@ -122,6 +123,26 @@ public class HomePageServiceImpl implements IHomePageService List electricDataList = emsPcsDataMapper.getElectDataList(); homePageDataViewVo.setElecDataList(electricDataList); // 系统效率 + List systemEfficiencyLists = new ArrayList<>(); + if (electricDataList != null && !electricDataList.isEmpty()) { + for (ElectricIndexList electricIndexList : electricDataList) { + SystemEfficiencyList systemEfficiency = new SystemEfficiencyList(); + systemEfficiency.setDateMonth(electricIndexList.getDateMonth()); + + BigDecimal dailyEfficiency = new BigDecimal(0); + BigDecimal chargeEnergy = electricIndexList.getChargeEnergy(); + BigDecimal disChargeEnergy = electricIndexList.getDisChargeEnergy(); + if (chargeEnergy != null && disChargeEnergy != null + && chargeEnergy.compareTo(BigDecimal.ZERO) > 0 + && disChargeEnergy.compareTo(BigDecimal.ZERO) >= 0) { + dailyEfficiency = electricIndexList.getDisChargeEnergy().divide(electricIndexList.getChargeEnergy(), 2, RoundingMode.HALF_UP); + dailyEfficiency = dailyEfficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); + } + systemEfficiency.setSystemEfficiency(dailyEfficiency); + systemEfficiencyLists.add(systemEfficiency); + } + } + homePageDataViewVo.setSysEfficList(systemEfficiencyLists); // 告警趋势 List alarmTrendList = alarmRecordsMapper.getAlarmTrendList(); homePageDataViewVo.setAlarmDataList(alarmTrendList); @@ -129,6 +150,19 @@ public class HomePageServiceImpl implements IHomePageService List deviceAlarmPropList = alarmRecordsMapper.getDeviceAlarmPropList(); homePageDataViewVo.setDeviceAlarmList(deviceAlarmPropList); // 告警等级分布 + List alarmLevelList = alarmRecordsMapper.getAlarmGradeList(); + if (alarmLevelList != null && !alarmLevelList.isEmpty()) { + BigDecimal total = new BigDecimal(alarmLevelList.size()); + for (AlarmGradeList alarmGradeList : alarmLevelList) { + if (alarmGradeList.getDataNum() != 0 + && total.compareTo(BigDecimal.ZERO) > 0) { + BigDecimal percent = new BigDecimal(alarmGradeList.getDataNum()).divide(total, 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); + alarmGradeList.setPercent(percent); + } + } + } + homePageDataViewVo.setAlarmLevelList(alarmLevelList); return homePageDataViewVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index 1ad3fbd..0c83cd3 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -133,6 +133,10 @@ group by device_type + + select CONCAT(t.date_month,'/',t.date_day) as statisDate, -- 2.49.0 From 53f515ad6c83d0cd1e881ab05abf5a4120231254 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 9 Jul 2025 19:15:59 +0800 Subject: [PATCH 066/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E7=94=B5=E8=A1=A8=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 27 ++++ .../ems/domain/vo/AmmeterStatisListVo.java | 142 ++++++++++++++++++ .../domain/vo/StatisAmmeterDateRequest.java | 47 ++++++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 9 ++ .../ems/mapper/EmsDevicesSettingMapper.java | 13 +- .../ems/service/IEmsStatsReportService.java | 5 + .../impl/EmsStatsReportServiceImpl.java | 83 ++++++++-- .../mapper/ems/EmsAmmeterDataMapper.xml | 24 +++ .../mapper/ems/EmsDevicesSettingMapper.xml | 4 + 9 files changed, 336 insertions(+), 18 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index dc8e7e9..b51117b 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -6,6 +6,7 @@ import com.xzzn.common.core.page.TableDataInfo; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.vo.ClusterStatisListVo; import com.xzzn.ems.domain.vo.DateSearchRequest; +import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest; import com.xzzn.ems.domain.vo.StatisClusterDateRequest; import com.xzzn.ems.service.IEmsStatsReportService; import org.springframework.beans.factory.annotation.Autowired; @@ -98,4 +99,30 @@ public class EmsStatisticalReportController extends BaseController } } + /** + * 概率统计-获取总表 + */ + @GetMapping("/getLoadNameList") + public AjaxResult getLoadNameList(String siteId) + { + if (!StringUtils.isEmpty(siteId)) { + return success(ieEmsStatsReportService.getLoadNameList(siteId)); + } else { + return error("缺少必传项"); + } + } + + /** + * 概率统计-电表报表 + */ + @GetMapping("/getAmmeterData") + public AjaxResult getAmmeterData(StatisAmmeterDateRequest requestVo) + { + if (!StringUtils.isEmpty(requestVo.getDeviceId())) { + return success(ieEmsStatsReportService.getAmmeterDataResult(requestVo)); + } else { + return error("缺少必传项"); + } + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java new file mode 100644 index 0000000..91b69bf --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java @@ -0,0 +1,142 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 电表数据 + */ +public class AmmeterStatisListVo { + + + /** 类别 */ + private String dataTime; + + /** 组合有功-总 (kWh) */ + private BigDecimal activeTotalKwh = BigDecimal.ZERO; + + /** 组合有功-尖 (kWh) */ + private BigDecimal activePeakKwh = BigDecimal.ZERO; + + /** 组合有功-峰 (kWh) */ + private BigDecimal activeHighKwh = BigDecimal.ZERO; + + /** 组合有功-平 (kWh) */ + private BigDecimal activeFlatKwh = BigDecimal.ZERO; + + /** 组合有功-谷 (kWh) */ + private BigDecimal activeValleyKwh = BigDecimal.ZERO; + + /** 组合无功-总 (kWh) */ + private BigDecimal reActiveTotalKwh = BigDecimal.ZERO; + + /** 组合无功-尖 (kWh) */ + private BigDecimal reActivePeakKwh = BigDecimal.ZERO; + + /** 组合无功-峰 (kWh) */ + private BigDecimal reActiveHighKwh = BigDecimal.ZERO; + + /** 组合无功-平 (kWh) */ + private BigDecimal reActiveFlatKwh = BigDecimal.ZERO; + + /** 组合无功-谷 (kWh) */ + private BigDecimal reActiveValleyKwh = BigDecimal.ZERO; + + /** 效率-有功总/无功总 */ + private BigDecimal effect = BigDecimal.ZERO; + + public String getDataTime() { + return dataTime; + } + + public void setDataTime(String dataTime) { + this.dataTime = dataTime; + } + + public BigDecimal getActiveTotalKwh() { + return activeTotalKwh; + } + + public void setActiveTotalKwh(BigDecimal activeTotalKwh) { + this.activeTotalKwh = activeTotalKwh; + } + + public BigDecimal getActivePeakKwh() { + return activePeakKwh; + } + + public void setActivePeakKwh(BigDecimal activePeakKwh) { + this.activePeakKwh = activePeakKwh; + } + + public BigDecimal getActiveHighKwh() { + return activeHighKwh; + } + + public void setActiveHighKwh(BigDecimal activeHighKwh) { + this.activeHighKwh = activeHighKwh; + } + + public BigDecimal getActiveFlatKwh() { + return activeFlatKwh; + } + + public void setActiveFlatKwh(BigDecimal activeFlatKwh) { + this.activeFlatKwh = activeFlatKwh; + } + + public BigDecimal getActiveValleyKwh() { + return activeValleyKwh; + } + + public void setActiveValleyKwh(BigDecimal activeValleyKwh) { + this.activeValleyKwh = activeValleyKwh; + } + + public BigDecimal getReActiveTotalKwh() { + return reActiveTotalKwh; + } + + public void setReActiveTotalKwh(BigDecimal reActiveTotalKwh) { + this.reActiveTotalKwh = reActiveTotalKwh; + } + + public BigDecimal getReActivePeakKwh() { + return reActivePeakKwh; + } + + public void setReActivePeakKwh(BigDecimal reActivePeakKwh) { + this.reActivePeakKwh = reActivePeakKwh; + } + + public BigDecimal getReActiveHighKwh() { + return reActiveHighKwh; + } + + public void setReActiveHighKwh(BigDecimal reActiveHighKwh) { + this.reActiveHighKwh = reActiveHighKwh; + } + + public BigDecimal getReActiveFlatKwh() { + return reActiveFlatKwh; + } + + public void setReActiveFlatKwh(BigDecimal reActiveFlatKwh) { + this.reActiveFlatKwh = reActiveFlatKwh; + } + + public BigDecimal getReActiveValleyKwh() { + return reActiveValleyKwh; + } + + public void setReActiveValleyKwh(BigDecimal reActiveValleyKwh) { + this.reActiveValleyKwh = reActiveValleyKwh; + } + + public BigDecimal getEffect() { + return effect; + } + + public void setEffect(BigDecimal effect) { + this.effect = effect; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java new file mode 100644 index 0000000..6ff5897 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java @@ -0,0 +1,47 @@ +package com.xzzn.ems.domain.vo; + + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +/** + * 报表统计-电表报表入参 + * + */ +public class StatisAmmeterDateRequest { + + /** + * 筛选时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date dateTime; + + private String siteId; + + private String deviceId; + + public Date getDateTime() { + return dateTime; + } + + public void setDateTime(Date dateTime) { + this.dateTime = dateTime; + } + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index bff726e..5ffe8de 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -2,6 +2,8 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsAmmeterData; +import com.xzzn.ems.domain.vo.AmmeterStatisListVo; +import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest; /** * 总数据Mapper接口 @@ -58,4 +60,11 @@ public interface EmsAmmeterDataMapper * @return 结果 */ public int deleteEmsAmmeterDataByIds(Long[] ids); + + /** + * 按小时获取当天电表曲线数据 + * @param requestVo + * @return + */ + public List getLoadDataByHour(StatisAmmeterDateRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 9b6dd71..6e0ef1f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -67,12 +67,6 @@ public interface EmsDevicesSettingMapper * @return */ public List> getDeviceInfoByParentId(String parentId); - /** - * 获取该设备下的所有电表 - * @param siteId - * @return - */ - public List getAllBatteryDeviceBySiteId(String siteId); /** * 根据site_id和device_category获取指定设备信息 @@ -88,4 +82,11 @@ public interface EmsDevicesSettingMapper * @return */ public EmsDevicesSetting getDeviceDetailInfo(String deviceId); + + /** + * 获取该设备下的总表 + * @param siteId + * @return + */ + public List> getLoadNameList(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java index eae3edb..9c2a958 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java @@ -3,6 +3,7 @@ package com.xzzn.ems.service; import com.xzzn.ems.domain.vo.*; import java.util.List; +import java.util.Map; /** * 统计报表数据Service接口 @@ -20,4 +21,8 @@ public interface IEmsStatsReportService public List getStackDataResult(DateSearchRequest requestVo); public List getClusterDataResult(StatisClusterDateRequest requestVo); + + public List> getLoadNameList(String siteId); + + public List getAmmeterDataResult(StatisAmmeterDateRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index dbc7e66..a0338f2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -2,13 +2,8 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.vo.*; -import com.xzzn.ems.mapper.EmsBatteryClusterMapper; -import com.xzzn.ems.mapper.EmsBatteryDataMapper; -import com.xzzn.ems.mapper.EmsBatteryStackMapper; -import com.xzzn.ems.mapper.EmsPcsDataMapper; +import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsStatsReportService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -19,6 +14,7 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; /** * 统计报表数据Service业务层处理 @@ -29,17 +25,16 @@ import java.util.List; @Service public class EmsStatsReportServiceImpl implements IEmsStatsReportService { - - private static final Logger log = LoggerFactory.getLogger(EmsStatsReportServiceImpl.class); - @Autowired private EmsPcsDataMapper emsPcsDataMapper; @Autowired - private EmsBatteryDataMapper emsBatteryDataMapper; - @Autowired private EmsBatteryStackMapper emsBatteryStackMapper; @Autowired private EmsBatteryClusterMapper emsBatteryClusterMapper; + @Autowired + private EmsAmmeterDataMapper emsAmmeterDataMapper; + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; @Override public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { @@ -161,7 +156,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService List dataList = new ArrayList(); // 时间不传默认当天 if (requestVo.getDateTime() == null) { - requestVo.setDateTime(new Date()); + String now = DateUtils.getDate(); + requestVo.setDateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD, now)); } // 根据时间获取每小时最新数据 @@ -169,6 +165,69 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return dataList; } + public List> getLoadNameList(String siteId) { + return emsDevicesSettingMapper.getLoadNameList(siteId); + } + + public List getAmmeterDataResult(StatisAmmeterDateRequest requestVo){ + List dataList = new ArrayList(); + // 时间不传默认当天 + if (requestVo.getDateTime() == null) { + String now = DateUtils.getDate(); + requestVo.setDateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD, now)); + } + dataList = emsAmmeterDataMapper.getLoadDataByHour(requestVo); + if (dataList.size()>0){ + AmmeterStatisListVo totalVo = new AmmeterStatisListVo(); + totalVo.setDataTime("汇总"); + for (AmmeterStatisListVo ammeterStatisListVo : dataList) { + BigDecimal effect = new BigDecimal(0); + BigDecimal activePower = ammeterStatisListVo.getActiveTotalKwh(); + BigDecimal reactivePower = ammeterStatisListVo.getReActiveTotalKwh(); + if ( activePower != null && reactivePower !=null + && activePower.compareTo(BigDecimal.ZERO) >= 0 + && reactivePower.compareTo(BigDecimal.ZERO) >= 0){ + effect = reactivePower.divide(activePower, 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); + } + // 每小时的效率 + ammeterStatisListVo.setEffect(effect); + + // 处理汇总数据 + dealWithAmmeterTotalDate(ammeterStatisListVo,totalVo); + } + + // 处理汇总的效率 + BigDecimal totalActive = totalVo.getActiveTotalKwh(); + BigDecimal totalReactive = totalVo.getReActiveTotalKwh(); + if ( totalActive != null && totalReactive !=null + && totalActive.compareTo(BigDecimal.ZERO) >= 0 + && totalReactive.compareTo(BigDecimal.ZERO) >= 0){ + BigDecimal totalEffect = new BigDecimal(0); + totalEffect = totalReactive.divide(totalActive, 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); + totalVo.setEffect(totalEffect); + } + dataList.add(totalVo); + } + return dataList; + } + + private void dealWithAmmeterTotalDate(AmmeterStatisListVo ammeterStatisListVo, AmmeterStatisListVo totalVo) { + // 有功 + totalVo.setActiveTotalKwh(totalVo.getActiveTotalKwh().add(ammeterStatisListVo.getActiveTotalKwh())); + totalVo.setActivePeakKwh(totalVo.getActivePeakKwh().add(ammeterStatisListVo.getActivePeakKwh())); + totalVo.setActiveHighKwh(totalVo.getActiveHighKwh().add(ammeterStatisListVo.getActiveHighKwh())); + totalVo.setActiveFlatKwh(totalVo.getActiveFlatKwh().add(ammeterStatisListVo.getActiveFlatKwh())); + totalVo.setActiveValleyKwh(totalVo.getActiveValleyKwh().add(ammeterStatisListVo.getActiveValleyKwh())); + // 无功 + totalVo.setReActiveTotalKwh(totalVo.getReActiveTotalKwh().add(ammeterStatisListVo.getReActiveTotalKwh())); + totalVo.setReActivePeakKwh(totalVo.getReActivePeakKwh().add(ammeterStatisListVo.getReActivePeakKwh())); + totalVo.setReActiveHighKwh(totalVo.getReActiveHighKwh().add(ammeterStatisListVo.getReActiveHighKwh())); + totalVo.setReActiveFlatKwh(totalVo.getReActiveFlatKwh().add(ammeterStatisListVo.getReActiveFlatKwh())); + totalVo.setReActiveValleyKwh(totalVo.getReActiveValleyKwh().add(ammeterStatisListVo.getReActiveValleyKwh())); + } + // 统计入参时间处理 public void dealRequestTime(DateSearchRequest requestVo){ diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index f16f592..23e41eb 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -549,4 +549,28 @@ + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index c227e2c..1b2deb0 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -185,4 +185,8 @@ where device_id = #{deviceId} limit 1 + + \ No newline at end of file -- 2.49.0 From 406cc59b25f3d6cde0c088278491281d92ef2e84 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 9 Jul 2025 22:41:14 +0800 Subject: [PATCH 067/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E5=8A=9F=E7=8E=87=E6=9B=B2=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 19 ++++- .../xzzn/ems/domain/vo/DateSearchRequest.java | 6 +- .../xzzn/ems/domain/vo/PowerStatisListVo.java | 73 +++++++++++++++++++ .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 11 +++ .../ems/service/IEmsStatsReportService.java | 2 + .../impl/EmsStatsReportServiceImpl.java | 32 ++++++++ .../mapper/ems/EmsBatteryStackMapper.xml | 11 ++- .../mapper/ems/EmsDevicesSettingMapper.xml | 2 +- .../resources/mapper/ems/EmsPcsDataMapper.xml | 71 +++++++++++++++++- 9 files changed, 213 insertions(+), 14 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index b51117b..1f557f5 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -60,7 +60,7 @@ public class EmsStatisticalReportController extends BaseController { if (!StringUtils.isEmpty(requestVo.getSiteId()) && !StringUtils.isEmpty(requestVo.getDeviceId()) && - requestVo.getDataType() != 0) { + !StringUtils.isEmpty(requestVo.getDataType())) { return success(ieEmsStatsReportService.getPCSDataResult(requestVo)); } else { return error("缺少必传项"); @@ -75,7 +75,7 @@ public class EmsStatisticalReportController extends BaseController { if (!StringUtils.isEmpty(requestVo.getSiteId()) && !StringUtils.isEmpty(requestVo.getDeviceId()) && - requestVo.getDataType() != 0) { + !StringUtils.isEmpty(requestVo.getDataType())) { return success(ieEmsStatsReportService.getStackDataResult(requestVo)); } else { return error("缺少必传项"); @@ -125,4 +125,19 @@ public class EmsStatisticalReportController extends BaseController } } + /** + * 概率统计-功率曲线 + */ + @GetMapping("/getPowerData") + public AjaxResult getPowerData(DateSearchRequest requestVo) + { + if (!StringUtils.isEmpty(requestVo.getSiteId()) + && !StringUtils.isEmpty(requestVo.getDeviceId()) + && !StringUtils.isEmpty(requestVo.getDataType())) { + return success(ieEmsStatsReportService.getPowerDataList(requestVo)); + } else { + return error("缺少必传项"); + } + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java index 966e6c2..54e5d50 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DateSearchRequest.java @@ -23,7 +23,7 @@ public class DateSearchRequest { private String deviceId; - private int dataType; + private String dataType; public Date getStartDate() { return startDate; @@ -57,11 +57,11 @@ public class DateSearchRequest { this.deviceId = deviceId; } - public int getDataType() { + public String getDataType() { return dataType; } - public void setDataType(int dataType) { + public void setDataType(String dataType) { this.dataType = dataType; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java new file mode 100644 index 0000000..5159437 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java @@ -0,0 +1,73 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 数据统计-功率曲线 + */ +public class PowerStatisListVo { + /** + * 数据日期 + */ + private String statisDate; + + /** + * 电网功率-total_apparent_power总交流视在功率 + */ + private BigDecimal gridPower; + + /** + * 负载功率-total_active_power总交流有功电率 + */ + private BigDecimal loadPower; + + /** + * 储能功率-max_discharge_power_capacity最大可放功率 + */ + private BigDecimal storagePower; + + /** + * 光伏功率-ac_capacitive_reactive_power交流侧容性无功功率 + */ + private BigDecimal pvPower; + + public String getStatisDate() { + return statisDate; + } + + public void setStatisDate(String statisDate) { + this.statisDate = statisDate; + } + + public BigDecimal getGridPower() { + return gridPower; + } + + public void setGridPower(BigDecimal gridPower) { + this.gridPower = gridPower; + } + + public BigDecimal getLoadPower() { + return loadPower; + } + + public void setLoadPower(BigDecimal loadPower) { + this.loadPower = loadPower; + } + + public BigDecimal getStoragePower() { + return storagePower; + } + + public void setStoragePower(BigDecimal storagePower) { + this.storagePower = storagePower; + } + + public BigDecimal getPvPower() { + return pvPower; + } + + public void setPvPower(BigDecimal pvPower) { + this.pvPower = pvPower; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index 0c8fab4..938137d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -142,4 +142,15 @@ public interface EmsPcsDataMapper public List getPcsActivePowerByHour(DateSearchRequest requestVo); public List getPcsActivePowerByMonth(DateSearchRequest requestVo); + + /** + * 获取pcs功率曲线数据 + * @param requestVo + * @return + */ + public List getPowerDataByHour(DateSearchRequest requestVo); + + public List getPowerDataByDay(DateSearchRequest requestVo); + + public List getPowerDataByMonth(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java index 9c2a958..4acc8b6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java @@ -25,4 +25,6 @@ public interface IEmsStatsReportService public List> getLoadNameList(String siteId); public List getAmmeterDataResult(StatisAmmeterDateRequest requestVo); + + public List getPowerDataList(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index a0338f2..9cf689e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -165,10 +165,12 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return dataList; } + @Override public List> getLoadNameList(String siteId) { return emsDevicesSettingMapper.getLoadNameList(siteId); } + @Override public List getAmmeterDataResult(StatisAmmeterDateRequest requestVo){ List dataList = new ArrayList(); // 时间不传默认当天 @@ -228,6 +230,36 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService totalVo.setReActiveValleyKwh(totalVo.getReActiveValleyKwh().add(ammeterStatisListVo.getReActiveValleyKwh())); } + @Override + public List getPowerDataList(DateSearchRequest requestVo) { + List dataList = new ArrayList<>(); + + // 默认时间-7天 + dealRequestTime(requestVo); + Date startDate = requestVo.getStartDate(); + Date endDate = requestVo.getEndDate(); + + // 开始日期和结束日期同一天,展示 0-24 小时数据 + if (DateUtils.isSameDay(startDate, endDate)){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + dataList = emsPcsDataMapper.getPowerDataByHour(requestVo); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 + && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 + dataList = emsPcsDataMapper.getPowerDataByDay(requestVo); + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 个月,按月展示数据 + dataList = emsPcsDataMapper.getPowerDataByMonth(requestVo); + } + + return dataList; + } + // 统计入参时间处理 public void dealRequestTime(DateSearchRequest requestVo){ diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 12d2aba..bbc602e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -302,18 +302,21 @@ - + t.operating_temp AS temp - + t.stack_voltage as voltage - + t.stack_current as current - + t.stack_soc as soc + + 0 AS temp + diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 1b2deb0..679568b 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -187,6 +187,6 @@ \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index de1818c..272a030 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -475,23 +475,26 @@ - + t.total_active_power as activePower - + t.total_reactive_power as reactivePower - + t.sys_u_current as uCurrent, t.sys_v_current as vCurrent, t.sys_w_current as wCurrent + + 0 as activePower + + + + + + t.total_apparent_power as gridPower + + + t.total_active_power as loadPower + + + t.max_discharge_power_capacity as storagePower + + + t.ac_capacitive_reactive_power as pvPower + + + 0 as gridPower + + + + + + + + + \ No newline at end of file -- 2.49.0 From d37fb949e1bd61fcb1965d28ebdf138454153694 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 10 Jul 2025 12:42:04 +0800 Subject: [PATCH 068/336] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/EmsStatsReportServiceImpl.java | 6 +++++ .../service/impl/SingleSiteServiceImpl.java | 2 +- .../resources/mapper/ems/EmsPcsDataMapper.xml | 26 +++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 9cf689e..7c69e29 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -36,6 +36,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Autowired private EmsDevicesSettingMapper emsDevicesSettingMapper; + // 电量指标 @Override public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { ElectricDataInfoVo electricDataInfoVo = new ElectricDataInfoVo(); @@ -94,6 +95,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return electricDataInfoVo; } + // pcs曲线数据 @Override public List getPCSDataResult(DateSearchRequest requestVo) { List dataList = new ArrayList(); @@ -123,6 +125,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return dataList; } + // 电池堆曲线 @Override public List getStackDataResult(DateSearchRequest requestVo) { List dataList = new ArrayList(); @@ -151,6 +154,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return dataList; } + // 电池温度 @Override public List getClusterDataResult(StatisClusterDateRequest requestVo) { List dataList = new ArrayList(); @@ -170,6 +174,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return emsDevicesSettingMapper.getLoadNameList(siteId); } + // 电表报表 @Override public List getAmmeterDataResult(StatisAmmeterDateRequest requestVo){ List dataList = new ArrayList(); @@ -230,6 +235,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService totalVo.setReActiveValleyKwh(totalVo.getReActiveValleyKwh().add(ammeterStatisListVo.getReActiveValleyKwh())); } + // 功率曲线 @Override public List getPowerDataList(DateSearchRequest requestVo) { List dataList = new ArrayList<>(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 7771d46..a456966 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -99,7 +99,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { int todayMonth = calendar.get(Calendar.MONTH) + 1; int todayDay = calendar.get(Calendar.DAY_OF_MONTH); if (StringUtils.isNotEmpty(pcsDate)){ - String[] pcsDateArray = pcsDate.split("/"); + String[] pcsDateArray = pcsDate.split("-"); if (todayMonth == Integer.parseInt(pcsDateArray[0]) && todayDay == Integer.parseInt(pcsDateArray[1])) { flag = true; diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 272a030..18bad13 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -295,21 +295,19 @@ - select DATE(latest.max_update_time) as ammeterDate, + select latest.dateDay as ammeterDate, sum(t.total_ac_charge_energy) as chargedCap, sum(t.total_ac_discharge_energy) as disChargedCap - from ( SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time + from ( SELECT p.site_id, p.device_id,DATE(p.data_update_time) as dateDay, MAX(p.data_update_time) AS max_update_time FROM ems_pcs_data p - GROUP BY p.site_id,p.device_id,p.date_month,p.date_day + GROUP BY p.site_id,p.device_id,dateDay ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id AND latest.device_id = t.device_id AND latest.max_update_time = t.data_update_time - and latest.date_month = t.date_month - and latest.date_day = t.date_day group by ammeterDate order by ammeterDate desc @@ -494,17 +490,15 @@ -- 2.49.0 From 8ce403eff255cb88201a8cab0947294d3c21efd8 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 10 Jul 2025 12:57:06 +0800 Subject: [PATCH 069/336] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/service/impl/HomePageServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index 48f1f4a..9029cd6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -104,7 +104,7 @@ public class HomePageServiceImpl implements IHomePageService int todayMonth = calendar.get(Calendar.MONTH) + 1; int todayDay = calendar.get(Calendar.DAY_OF_MONTH); if (StringUtils.isNotEmpty(pcsDate)){ - String[] pcsDateArray = pcsDate.split("/"); + String[] pcsDateArray = pcsDate.split("-"); if (todayMonth == Integer.parseInt(pcsDateArray[0]) && todayDay == Integer.parseInt(pcsDateArray[1])) { flag = true; -- 2.49.0 From 21ce358638d7dee437c89bb464e4700706677a9b Mon Sep 17 00:00:00 2001 From: dashixiong Date: Thu, 10 Jul 2025 17:03:07 +0800 Subject: [PATCH 070/336] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20dds=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 17 +- .../ems/service/IDDSDataProcessService.java | 7 + .../impl/DDSDataProcessServiceImpl.java | 646 ++++++++++++++++++ 3 files changed, 668 insertions(+), 2 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IDDSDataProcessService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index e6283a5..437a6c0 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -1,6 +1,7 @@ package com.xzzn.web.controller.ems; import com.xzzn.ems.domain.EmsMqttMessage; +import com.xzzn.ems.service.IDDSDataProcessService; import com.xzzn.ems.service.IEmsMqttMessageService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.framework.manager.MqttLifecycleManager; @@ -31,6 +32,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IFXXDataProcessService fXXDataProcessService; + @Autowired + private IDDSDataProcessService dDSDataProcessService; @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { this.mqttLifecycleManager = mqttLifecycleManager; @@ -38,12 +41,18 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @PostConstruct public void init() { - // 订阅系统状态主题 + // 订阅奉贤系统状态主题 subscribe("021_FXX_01_UP", 1, this::handleDeviceData); subscribe("021_FXX_01_RECALL", 1, this::handleDeviceData); subscribe("021_FXX_01_DOWN", 1, this::handleDeviceData); subscribe("021_FXX_01", 1, this::handleSystemStatus); + // 订阅电动所系统状态主题 + subscribe("021_DDS_01_UP", 1, this::handleDeviceData); + subscribe("021_DDS_01_RECALL", 1, this::handleDeviceData); + subscribe("021_DDS_01_DOWN", 1, this::handleDeviceData); + subscribe("021_DDS_01", 1, this::handleSystemStatus); + } // 处理系统状态消息 @@ -72,7 +81,11 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[DEVICE] data: " + payload); try { // 业务处理逻辑 - fXXDataProcessService.handleFxData(payload); + if (topic.startsWith("021_DDS")) { + dDSDataProcessService.handleDdsData(payload); + } else if (topic.startsWith("021_FXX")) { + fXXDataProcessService.handleFxData(payload); + } EmsMqttMessage mqttMessage = new EmsMqttMessage(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IDDSDataProcessService.java b/ems-system/src/main/java/com/xzzn/ems/service/IDDSDataProcessService.java new file mode 100644 index 0000000..c1ab276 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IDDSDataProcessService.java @@ -0,0 +1,7 @@ +package com.xzzn.ems.service; + +public interface IDDSDataProcessService { + + public void handleDdsData(String message); + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java new file mode 100644 index 0000000..77d21f8 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -0,0 +1,646 @@ +package com.xzzn.ems.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.alibaba.fastjson2.TypeReference; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.*; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.*; +import com.xzzn.ems.mapper.*; +import com.xzzn.ems.service.IDDSDataProcessService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +public class DDSDataProcessServiceImpl implements IDDSDataProcessService { + private static final Log log = LogFactory.getLog(DDSDataProcessServiceImpl.class); + private static final String SITE_ID = "021_DDS_01"; + @Autowired + private EmsBatteryClusterMapper emsBatteryClusterMapper; + + @Autowired + private EmsBatteryStackMapper emsBatteryStackMapper; + + @Autowired + private EmsBatteryDataMapper emsBatteryDataMapper; + + @Autowired + private EmsPcsDataMapper emsPcsDataMapper; + + @Autowired + private EmsPcsBranchDataMapper emsPcsBranchDataMapper; + + @Autowired + private RedisCache redisCache; + + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; + + @Autowired + private EmsAmmeterDataMapper emsAmmeterDataMapper; + + @Override + public void handleDdsData(String message) { + JSONArray arraylist = JSONArray.parseArray(message); + + for (int i = 0; i < arraylist.size(); i++) { + JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); + + String deviceId = obj.get("Device").toString(); + String jsonData = obj.get("Data").toString(); + + log.info("deviceId:" + deviceId); + if (deviceId.contains("BMSD")) { + batteryStackDataProcess(deviceId, jsonData); + + } else if (deviceId.contains("BMSC")) { + log.info("BMSC data:"+ jsonData); + batteryClusterDataProcess(deviceId, jsonData); + batteryDataProcess(deviceId, jsonData); + + } else if (deviceId.contains("PCS")) { + pcsDataProcess(deviceId, jsonData); + pcsBranchDataProcess(deviceId, jsonData); + } else if (deviceId.contains("LOAD")) { + loadDataProcess(deviceId, jsonData); + } else if (deviceId.contains("METE")) { + meteDataProcess(deviceId, jsonData); + } + } + } + + private void batteryStackDataProcess(String deviceId, String dataJson) { + + //电池堆 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + //BMS 电池簇 + EmsBatteryStack dataStack = new EmsBatteryStack(); + + // 其他非 BigDecimal 字段 + dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + + // 电池堆状态数据设置 + dataStack.setOperationStatus(StringUtils.getString(obj.get("DCZT"))); + dataStack.setStackVoltage(StringUtils.getBigDecimal(obj.get("DCDDY"))); + dataStack.setStackCurrent(StringUtils.getBigDecimal(obj.get("DCDDL"))); + dataStack.setStackSoc(StringUtils.getBigDecimal(obj.get("DCDSOC"))); + dataStack.setStackSoh(StringUtils.getBigDecimal(obj.get("DCDSOH"))); + + // 电压极值信息 + dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDCDY"))); + dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("ZGDCDYZH"))); + dataStack.setMaxVoltageCellId(StringUtils.getLong(obj.get("ZGDCDYZHDH"))); + dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDCDY"))); + dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("ZDDCDYZH"))); + dataStack.setMinVoltageCellId(StringUtils.getLong(obj.get("ZDDCDYZHDH"))); + + // 温度极值信息 + dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDCWD"))); + dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("ZGDCWDZH"))); + dataStack.setMaxTempCellId(StringUtils.getLong(obj.get("ZGDCWDZHDH"))); + dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDCWD"))); + dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("ZDDCWDZH"))); + dataStack.setMinTempCellId(StringUtils.getLong(obj.get("ZDDCWDZHDH"))); + + // 电量统计信息 + dataStack.setTotalChargeCapacity(StringUtils.getBigDecimal(obj.get("DLJCDDL"))); + dataStack.setTotalDischargeCapacity(StringUtils.getBigDecimal(obj.get("DLCFDDL"))); + dataStack.setSessionChargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJCDDL"))); + dataStack.setSessionDischargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJFDDL"))); + dataStack.setAvailableChargeCapacity(StringUtils.getBigDecimal(obj.get("DKCDL"))); + dataStack.setAvailableDischargeCapacity(StringUtils.getBigDecimal(obj.get("DKFDL"))); + +// 时间信息 + dataStack.setRemainingDischargeTime(StringUtils.getLong(obj.get("KYFDSJ"))); + dataStack.setRemainingChargeTime(StringUtils.getLong(obj.get("KYCDSJ"))); + +// 功率/电流限制 + dataStack.setMaxDischargePower(StringUtils.getBigDecimal(obj.get("YXZDFDGL"))); + dataStack.setMaxChargePower(StringUtils.getBigDecimal(obj.get("YXZDCDGL"))); + dataStack.setMaxDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDFDDL"))); + dataStack.setMaxChargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDCDDL"))); + + // 当日统计 + dataStack.setDailyDischargeCycles(StringUtils.getLong(obj.get("DTFDCS"))); + dataStack.setDailyChargeCycles(StringUtils.getLong(obj.get("DTCDCS"))); + dataStack.setDailyDischargeCapacity(StringUtils.getBigDecimal(obj.get("DTFDDL"))); + dataStack.setDailyChargeCapacity(StringUtils.getBigDecimal(obj.get("DTCDDL"))); + + // 系统状态 + dataStack.setOperatingTemp(StringUtils.getBigDecimal(obj.get("YXWD"))); + dataStack.setBmsStatus(StringUtils.getString(obj.get("BMSDDQZT"))); + dataStack.setBmsChargeStatus(StringUtils.getString(obj.get("BMSCFDZT"))); + dataStack.setStackInsulationResistance(StringUtils.getBigDecimal(obj.get("DCDJYDZ"))); + + + dataStack.setCreateBy("system"); + dataStack.setCreateTime(DateUtils.getNowDate()); + dataStack.setUpdateBy("system"); + dataStack.setUpdateTime(DateUtils.getNowDate()); + dataStack.setSiteId(SITE_ID); + dataStack.setDeviceId(deviceId); + + emsBatteryStackMapper.insertEmsBatteryStack(dataStack); + + redisCache.setCacheObject(RedisKeyConstants.STACK + SITE_ID + "_" +deviceId, dataStack); + } + + + private void batteryClusterDataProcess(String deviceId, String dataJson) { + + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + EmsDevicesSetting joken = new EmsDevicesSetting(); + joken.setDeviceId(deviceId); + List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); + String stackDeviceId = ""; + if (up != null && up.size() >0) { + stackDeviceId = up.get(0).getParentId(); + if (stackDeviceId == null || stackDeviceId.isEmpty()) { + stackDeviceId = "1"; + } + } + //BMS 电池簇 + EmsBatteryCluster data = new EmsBatteryCluster(); + // 设置所有 BigDecimal 类型字段为 ZERO + data.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); + data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); + data.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); + data.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); + data.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); + data.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); + data.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); + data.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); + data.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); + data.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); + data.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); + data.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); + data.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); + data.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); + data.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); + data.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); + data.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); + data.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); + data.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); + data.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); + data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); + data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); + + // 其他非 BigDecimal 字段 + data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + data.setSiteId(SITE_ID); + data.setDeviceId(deviceId); + data.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD"))); + data.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD"))); + data.setMaxCellTempId(StringUtils.getLong(obj.get("ZGDTWDDYD"))); + data.setMinCellTempId(StringUtils.getLong(obj.get("ZDDTWDDYD"))); + data.setMaxCellSocId(StringUtils.getLong(obj.get("ZGDTSOCDYD"))); + data.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); + data.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); + data.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); + if (StringUtils.isNotBlank(stackDeviceId)) { + data.setStackDeviceId(stackDeviceId); + } else { + data.setStackDeviceId("1"); + } + emsBatteryClusterMapper.insertEmsBatteryCluster(data); + + redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); + + } + + private void batteryDataProcess(String deviceId, String dataJson) { + EmsDevicesSetting joken = new EmsDevicesSetting(); + joken.setDeviceId(deviceId); + List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); + String stackDeviceId = ""; + if (up != null && up.size() >0) { + stackDeviceId = up.get(0).getParentId(); + if (stackDeviceId == null || stackDeviceId.isEmpty()) { + stackDeviceId = "1"; + } + } + //单体电池 + Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() {})); + List list = new ArrayList<>(); + //单体电池 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsBatteryData batteryData = new EmsBatteryData(); + batteryData.setDeviceId(recordId); + batteryData.setBatteryCellId(recordId); + batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); + batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); + batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); + batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); + + batteryData.setBatteryCluster(deviceId); + batteryData.setBatteryPack(stackDeviceId); + + // 时间戳 + batteryData.setDataTimestamp(new Date()); + + // ID字段 + batteryData.setSiteId(SITE_ID); + batteryData.setClusterDeviceId(deviceId); + + list.add(batteryData); + } + if (list.size() > 0 ) { + emsBatteryDataMapper.insertEmsBatteryDataList(list); + + redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId); + redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, list); + } + } + + + private void pcsDataProcess(String deviceId, String dataJson) { + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + //pcs + EmsPcsData pcsData = new EmsPcsData(); + // 时间与状态类字段 + pcsData.setDataUpdateTime(new Date()); + pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); + pcsData.setGridStatus(GridStatus.GRID.getCode()); + pcsData.setDeviceStatus(DeviceStatus.ONLINE.getCode()); + pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); + + // 功率与能量类字段 + pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("YGGL"))); + pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); + pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("XTWGGL"))); + pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); + pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); + pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("ZCDL"))); + pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFDL"))); + pcsData.setAcChargeActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); + pcsData.setAcCapacitiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); + pcsData.setAcDischargeActivePower(StringUtils.getBigDecimal(obj.get("JLCFDYGGL"))); + pcsData.setAcInductiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCGXWGGL"))); + pcsData.setMaxCapacitivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDRXWGNL"))); + pcsData.setMaxInductivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDGXWGNL"))); + pcsData.setMaxChargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKCGL"))); + pcsData.setMaxDischargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKFGL"))); + + + // 温度与环境参数 +// pcsData.setPcsModuleTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setPcsEnvironmentTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setAcFrequency(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + + // 状态指示类 + pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); + pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); + String acSwitchStatus = StringUtils.getString(obj.get("JLKGZT")); + pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String dcSwitchStatus = StringUtils.getString(obj.get("ZLKGZT")); + pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String controlMode = StringUtils.getString(obj.get("YCTT")); + pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); + + // 电流参数 + pcsData.setSysUCurrent(StringUtils.getBigDecimal(obj.get("XTSCUXDL"))); + pcsData.setSysVCurrent(StringUtils.getBigDecimal(obj.get("XTSCVXDL"))); + pcsData.setSysWCurrent(StringUtils.getBigDecimal(obj.get("XTSCWXDL"))); + + // 直流参数 +// pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + + // 系统管理字段 + pcsData.setCreateBy("system"); + pcsData.setCreateTime(DateUtils.getNowDate()); + pcsData.setUpdateBy("system"); + pcsData.setUpdateTime(DateUtils.getNowDate()); + pcsData.setSiteId(SITE_ID); + pcsData.setDeviceId(deviceId); + pcsData.setDateMonth(DateUtils.getNowMonthLong()); + pcsData.setDateDay(DateUtils.getNowDayLong()); + + emsPcsDataMapper.insertEmsPcsData(pcsData); + redisCache.setCacheObject(RedisKeyConstants.PCS + SITE_ID + "_" +deviceId, pcsData); + + } + + private void pcsBranchDataProcess(String deviceId, String dataJson) { + + Map> records = processDataPrefix(JSON.parseObject(dataJson, new TypeReference>() {})); + List list = new ArrayList<>(); + + //PCS支路 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsPcsBranchData data = new EmsPcsBranchData(); + data.setDeviceId(deviceId); + data.setGridStatus(GridStatus.GRID.getCode()); + data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); + data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); + data.setDcCurrent(StringUtils.getBigDecimal(fields.get("ZLDL"))); + data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWVXDY"))); + data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWUXDY"))); + data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWWXDY"))); + data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("SCUXDL"))); + data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("SCVXDL"))); + data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("SCWXDL"))); + data.setApparentPower(StringUtils.getBigDecimal(fields.get("SZGL"))); + data.setActivePower(StringUtils.getBigDecimal(fields.get("YGGL"))); + data.setReactivePower(StringUtils.getBigDecimal(fields.get("WGGL"))); + data.setPowerFactor(StringUtils.getBigDecimal(fields.get("GLYS"))); + data.setFrequency(StringUtils.getBigDecimal(fields.get("PL"))); + data.setInternalTemp(StringUtils.getBigDecimal(fields.get("DY1WD"))); + data.setuIgbtTemp(StringUtils.getBigDecimal(fields.get("UXIGBTWD"))); + data.setvIgbtTemp(StringUtils.getBigDecimal(fields.get("VXIGBTWD"))); + data.setwIgbtTemp(StringUtils.getBigDecimal(fields.get("WXIGBTWD"))); + data.setAvailablePower(StringUtils.getBigDecimal(fields.get("KYGL"))); + data.setTotalLoadRatio(StringUtils.getBigDecimal(fields.get("ZFZB"))); + data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); + data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); + data.setBranchId(recordId); + list.add(data); + } + if (list.size() > 0 ) { + emsPcsBranchDataMapper.insertPcsBranchDataList(list); + + redisCache.setCacheObject(RedisKeyConstants.BRANCH + SITE_ID + "_" +deviceId, list); + + } + + } + + private void loadDataProcess(String deviceId, String dataJson) { + + //总表 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + EmsAmmeterData dataLoad = new EmsAmmeterData(); + // 更新时间 + dataLoad.setDataUpdateTime(new Date()); + + // 电能设置-组合有功 + dataLoad.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); + dataLoad.setCurrentCombActivePeak(StringUtils.getBigDecimal(obj.get("DQZHYGJDN"))); + dataLoad.setCurrentCombActiveHigh(StringUtils.getBigDecimal(obj.get("DQZHYGFDN"))); + dataLoad.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); + dataLoad.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); + // 电能设置-正向有功 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); + dataLoad.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); + dataLoad.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); + dataLoad.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); + dataLoad.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); + // 电能设置-反向有功 + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); + dataLoad.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); + dataLoad.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); + dataLoad.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); + dataLoad.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))); + // 电能设置-组合无功 + dataLoad.setCurrentCombReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZHWGZDN"))); + dataLoad.setCurrentCombReactivePeak(StringUtils.getBigDecimal(obj.get("DQZHWGJDN"))); + dataLoad.setCurrentCombReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZHWGFDN"))); + dataLoad.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); + dataLoad.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); + // 电能设置-正向无功 + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); + dataLoad.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); + dataLoad.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); + dataLoad.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); + dataLoad.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); + // 电能设置-反向无功 + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); + dataLoad.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); + dataLoad.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); + dataLoad.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); + dataLoad.setCurrentReverseReactiveValley(StringUtils.getBigDecimal(obj.get("DQFXWGGDN"))); + + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("CBXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("ACXDY"))); + + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("PL"))); + + // 功率 有功+总+无功+无总+视在 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataLoad.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); + dataLoad.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); + dataLoad.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + + // 功率因数 + dataLoad.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); + dataLoad.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); + dataLoad.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + + // 需量 + dataLoad.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); + dataLoad.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); + dataLoad.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); + + dataLoad.setCreateBy("system"); + dataLoad.setCreateTime(DateUtils.getNowDate()); + dataLoad.setUpdateBy("system"); + dataLoad.setUpdateTime(DateUtils.getNowDate()); + dataLoad.setSiteId(SITE_ID); + dataLoad.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + } + + private void meteDataProcess(String deviceId, String dataJson) { + + //总表 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + EmsAmmeterData dataLoad = new EmsAmmeterData(); + // 更新时间 + dataLoad.setDataUpdateTime(new Date()); + + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); + + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); + + // 功率 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + + // 二次相关数据 + dataLoad.setSecondaryAbLineVoltage(StringUtils.getBigDecimal(obj.get("ECABXDY"))); + dataLoad.setSecondaryAPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECAXDL"))); + dataLoad.setSecondaryAPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECAXDY"))); + dataLoad.setSecondaryAPowerFactor(StringUtils.getBigDecimal(obj.get("ECAXGLYS"))); + dataLoad.setSecondaryAApparentPower(StringUtils.getBigDecimal(obj.get("ECAXSZGL"))); + dataLoad.setSecondaryAReactivePower(StringUtils.getBigDecimal(obj.get("ECAXWGGL"))); + dataLoad.setSecondaryAActivePower(StringUtils.getBigDecimal(obj.get("ECAXYGGL"))); + dataLoad.setSecondaryBcLineVoltage(StringUtils.getBigDecimal(obj.get("ECBCXDY"))); + dataLoad.setSecondaryBPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECBXDL"))); + dataLoad.setSecondaryBPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECBXDY"))); + dataLoad.setSecondaryBPowerFactor(StringUtils.getBigDecimal(obj.get("ECBXGLYS"))); + dataLoad.setSecondaryBApparentPower(StringUtils.getBigDecimal(obj.get("ECBXSZGL"))); + dataLoad.setSecondaryBReactivePower(StringUtils.getBigDecimal(obj.get("ECBXWGGL"))); + dataLoad.setSecondaryBActivePower(StringUtils.getBigDecimal(obj.get("ECBXYGGL"))); + dataLoad.setSecondaryCaLineVoltage(StringUtils.getBigDecimal(obj.get("ECCAXDY"))); + dataLoad.setSecondaryCPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECCXDL"))); + dataLoad.setSecondaryCPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECCXDY"))); + dataLoad.setSecondaryCPowerFactor(StringUtils.getBigDecimal(obj.get("ECCXGLYS"))); + dataLoad.setSecondaryCApparentPower(StringUtils.getBigDecimal(obj.get("ECCXSZGL"))); + dataLoad.setSecondaryCReactivePower(StringUtils.getBigDecimal(obj.get("ECCXWGGL"))); + dataLoad.setSecondaryCActivePower(StringUtils.getBigDecimal(obj.get("ECCXYGGL"))); + dataLoad.setSecondaryGridFrequency(StringUtils.getBigDecimal(obj.get("ECDWPL"))); + dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXWGDN"))); + dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXYGDN"))); + dataLoad.setSecondaryTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ECZGLYS"))); + dataLoad.setSecondaryTotalApparentPower(StringUtils.getBigDecimal(obj.get("ECZSZFL"))); + dataLoad.setSecondaryTotalReactivePower(StringUtils.getBigDecimal(obj.get("ECZWGGL"))); + dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXWGDN"))); + dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXYGDN"))); + dataLoad.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ECZYGGL"))); + + // 需量 + dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("FXYGDN"))); + dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); + dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + + dataLoad.setCreateBy("system"); + dataLoad.setCreateTime(DateUtils.getNowDate()); + dataLoad.setUpdateBy("system"); + dataLoad.setUpdateTime(DateUtils.getNowDate()); + dataLoad.setSiteId(SITE_ID); + dataLoad.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + } + // 数据分组处理 + private static Map> processData(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 提取记录ID(最后3位) + String recordId = key.substring(key.length() - 3); + try { + Long.parseLong(recordId); + } catch (Exception e) { + continue; + } + + // 提取字段类型(前缀) + String fieldType = key.substring(0, key.length() - 3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + return records; + } + + private static Map> processDataPrefix(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 确保键长度足够 + if (key.length() < 3) { + continue; + } + + // 提取记录ID(前3位) + String recordId = key.substring(0, 3); + if (!recordId.startsWith("DY")) { + continue; + } + + // 提取字段类型(剩余部分) + String fieldType = key.substring(3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + return records; + } + +} -- 2.49.0 From d6ec98eab9d315012d269ca55a8563f7c021e029 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 10 Jul 2025 17:47:19 +0800 Subject: [PATCH 071/336] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsAlarmRecordsController.java | 21 +++++++ .../controller/ems/EmsTicketController.java | 11 ++++ .../com/xzzn/ems/domain/EmsAlarmRecords.java | 13 ++++ .../java/com/xzzn/ems/domain/EmsTicket.java | 13 ++++ .../domain/vo/AlarmRecordListResponseVo.java | 22 +++++++ .../ems/domain/vo/SiteMonitorHomeAlarmVo.java | 24 ++++++++ .../com/xzzn/ems/mapper/EmsTicketMapper.java | 7 +++ .../ems/service/IEmsAlarmRecordsService.java | 9 +++ .../xzzn/ems/service/IEmsTicketService.java | 7 +++ .../impl/EmsAlarmRecordsServiceImpl.java | 61 +++++++++++++++++++ .../service/impl/EmsTicketServiceImpl.java | 12 ++++ .../mapper/ems/EmsAlarmRecordsMapper.xml | 16 ++++- .../resources/mapper/ems/EmsTicketMapper.xml | 12 +++- 13 files changed, 224 insertions(+), 4 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java index 0caa8bc..e3fc301 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsAlarmRecordsController.java @@ -1,7 +1,10 @@ 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.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsAlarmRecords; import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; import com.xzzn.ems.service.IEmsAlarmRecordsService; @@ -34,4 +37,22 @@ public class EmsAlarmRecordsController extends BaseController return getDataTable(list); } + /** + * 生成工单 + */ + @PostMapping("/createTicketNo") + public AjaxResult createTicketNo(@RequestBody EmsAlarmRecords emsAlarmRecords) + { + Long id = emsAlarmRecords.getId(); + if (id == null) { + return error("告警id不能为空"); + } + String ticketNo= iEmsAlarmRecordsService.createTicketNo(id,getUserId()); + if (StringUtils.isNotEmpty(ticketNo) && ticketNo.contains("T")) { + return AjaxResult.success("操作成功", ticketNo); + } else { + return error(ticketNo); + } + } + } diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java index 38e393d..1970124 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java @@ -102,4 +102,15 @@ public class EmsTicketController extends BaseController { return toAjax(emsTicketService.deleteEmsTicketByIds(ids)); } + + /** + * 废弃工单 + */ + @PreAuthorize("@ss.hasPermi('system:ticket:delete')") + @Log(title = "工单主", businessType = BusinessType.DELETE) + @PostMapping("/drop") + public AjaxResult drop(@RequestBody EmsTicket emsTicket) + { + return toAjax(emsTicketService.dropEmsTicketById(emsTicket.getId())); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java index fe5cb52..258d3b5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java @@ -58,6 +58,10 @@ public class EmsAlarmRecords extends BaseEntity @Excel(name = "设备名称,用于标识设备") private String deviceName; + /** 工单号(规则:T+日期+6位随机) */ + @Excel(name = "工单号", readConverterExp = "规=则:T+日期+6位随机") + private String ticketNo; + public void setId(Long id) { this.id = id; @@ -158,6 +162,14 @@ public class EmsAlarmRecords extends BaseEntity return deviceName; } + public String getTicketNo() { + return ticketNo; + } + + public void setTicketNo(String ticketNo) { + this.ticketNo = ticketNo; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -176,6 +188,7 @@ public class EmsAlarmRecords extends BaseEntity .append("siteId", getSiteId()) .append("deviceId", getDeviceId()) .append("deviceName", getDeviceName()) + .append("ticketNo", getTicketNo()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java index bcd31ce..da19310 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java @@ -53,6 +53,10 @@ public class EmsTicket extends BaseEntity @Excel(name = "处理人ID") private Long workUserId; + /** 0-已废弃 1-有效 */ + @Excel(name = "0-已废弃 1-有效") + private Long isDelete; + public void setId(String id) { this.id = id; @@ -143,6 +147,14 @@ public class EmsTicket extends BaseEntity return workUserId; } + public Long getIsDelete() { + return isDelete; + } + + public void setIsDelete(Long isDelete) { + this.isDelete = isDelete; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -159,6 +171,7 @@ public class EmsTicket extends BaseEntity .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("workUserId", getWorkUserId()) + .append("isDelete", getIsDelete()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java index 42137b8..6aa4203 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListResponseVo.java @@ -28,6 +28,12 @@ public class AlarmRecordListResponseVo { /** 状态 */ private String status; + /** 工单号 */ + private String ticketNo; + + /** 告警唯一标识 */ + private String id; + public String getDeviceName() { return deviceName; } @@ -75,4 +81,20 @@ public class AlarmRecordListResponseVo { public void setStatus(String status) { this.status = status; } + + public String getTicketNo() { + return ticketNo; + } + + public void setTicketNo(String ticketNo) { + this.ticketNo = ticketNo; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeAlarmVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeAlarmVo.java index f8f29e3..87722c7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeAlarmVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeAlarmVo.java @@ -20,6 +20,14 @@ public class SiteMonitorHomeAlarmVo { */ private String alarmContent; + /** + * 工单号 + */ + private String ticketNo; + + /** 告警唯一标识 */ + private String id; + public String getDeviceName() { return deviceName; } @@ -43,4 +51,20 @@ public class SiteMonitorHomeAlarmVo { public void setStatus(int status) { this.status = status; } + + public String getTicketNo() { + return ticketNo; + } + + public void setTicketNo(String ticketNo) { + this.ticketNo = ticketNo; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java index e29578a..f944a4c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java @@ -59,4 +59,11 @@ public interface EmsTicketMapper * @return 结果 */ public int deleteEmsTicketByIds(String[] ids); + + /** + * 废弃工单-isDelete=0 + * @param id + * @return + */ + public int dropEmsTicketById(String id); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java index ba58188..2a29700 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -67,4 +67,13 @@ public interface IEmsAlarmRecordsService * @return */ public List getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo); + + /** + * 生产工单号 + * + * @param id + * @param userId + * @return + */ + public String createTicketNo(Long id, Long userId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java index 069b94c..7fe9993 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java @@ -59,4 +59,11 @@ public interface IEmsTicketService * @return 结果 */ public int deleteEmsTicketById(String id); + + /** + * 废弃工单-物理删除 + * @param id + * @return + */ + public int dropEmsTicketById(String id); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index d4c545b..18ec20e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -1,9 +1,18 @@ package com.xzzn.ems.service.impl; import java.util.List; +import java.util.Random; + +import com.xzzn.common.core.domain.entity.SysUser; +import com.xzzn.common.core.domain.model.LoginUser; import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsTicket; import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; +import com.xzzn.ems.mapper.EmsTicketMapper; +import com.xzzn.ems.service.IEmsTicketService; +import com.xzzn.system.mapper.SysUserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; @@ -21,6 +30,12 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService { @Autowired private EmsAlarmRecordsMapper emsAlarmRecordsMapper; + @Autowired + private IEmsTicketService emsTicketService; + @Autowired + private EmsTicketMapper emsTicketMapper; + @Autowired + private SysUserMapper sysUserMapper; /** * 查询告警记录 @@ -100,4 +115,50 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService public List getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo) { return emsAlarmRecordsMapper.getAlarmRecordDetailList(requestVo); } + + @Override + public String createTicketNo(Long id, Long userId) { + String ticketNo = ""; + // 校验告警记录是否存在 + EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.selectEmsAlarmRecordsById(id); + if (emsAlarmRecords == null) { + return "告警记录不存在"; + } + // 工单号是否存在 + if (StringUtils.isNotEmpty(emsAlarmRecords.getTicketNo())) { + return "工单号已存在"; + } + // 随机生成工单:T+日期+6位随机 + ticketNo = createRandomTicketNo(); + // 更新告警表 + emsAlarmRecords.setTicketNo(ticketNo); + emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords); + // 不存在-默认userId + if (userId == null) { + userId = 1L; + } + SysUser user = sysUserMapper.selectUserById(userId); + // 插入工单表 + EmsTicket emsTicket = new EmsTicket(); + emsTicket.setTicketNo(ticketNo); + emsTicket.setTitle("工单"+id.toString()); + emsTicket.setContent(emsAlarmRecords.getAlarmContent()); + emsTicket.setUserId(userId.toString()); + emsTicket.setWorkUserId(userId); + emsTicket.setCreateTime(DateUtils.getNowDate()); + emsTicket.setCreateBy(user.getUserName()); + emsTicket.setUpdateTime(DateUtils.getNowDate()); + emsTicket.setUpdateBy(user.getUserName()); + emsTicketMapper.insertEmsTicket(emsTicket); + return ticketNo; + } + + private String createRandomTicketNo() { + String ticketNo = ""; + String nowDate = DateUtils.dateTime(); + ticketNo = "T" + nowDate + String.format("%06d", new Random().nextInt(1000000)); + return ticketNo; + } + + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java index 83c2442..f9917ec 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java @@ -94,4 +94,16 @@ public class EmsTicketServiceImpl implements IEmsTicketService { return emsTicketMapper.deleteEmsTicketById(id); } + + /** + * 删除工单主信息-物理删除 + * + * @param id 工单主主键 + * @return 结果 + */ + @Override + public int dropEmsTicketById(String id) + { + return emsTicketMapper.dropEmsTicketById(id); + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index 0c83cd3..775ab0c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -20,10 +20,11 @@ + - select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, device_name from ems_alarm_records + select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, device_name, ticket_no from ems_alarm_records @@ -63,6 +65,7 @@ site_id, device_id, device_name, + ticket_no, #{deviceType}, @@ -79,6 +82,7 @@ #{siteId}, #{deviceId}, #{deviceName}, + #{ticketNo}, @@ -99,6 +103,7 @@ site_id = #{siteId}, device_id = #{deviceId}, device_name = #{deviceName}, + ticket_no = #{ticketNo}, where id = #{id} @@ -116,7 +121,10 @@ @@ -140,7 +148,9 @@ + isDelete = 1 and ticket_no = #{ticketNo} and user_id = #{userId} and title = #{title} @@ -41,6 +43,7 @@ @@ -58,6 +61,7 @@ update_by, update_time, work_user_id, + isDelete, #{ticketNo}, @@ -72,6 +76,7 @@ #{updateBy}, #{updateTime}, #{workUserId}, + #{isDelete}, @@ -90,6 +95,7 @@ update_by = #{updateBy}, update_time = #{updateTime}, work_user_id = #{workUserId}, + isDelete = #{isDelete}, where id = #{id} @@ -104,4 +110,8 @@ #{id} + + + update ems_ticket set isDelete = 0 where id = #{id} + \ No newline at end of file -- 2.49.0 From 020d145a1f2874f3384d7f1aae8fd20e05367e1b Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 10 Jul 2025 22:30:56 +0800 Subject: [PATCH 072/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 1 - .../controller/ems/EmsStrategyController.java | 67 ++++++++++ .../java/com/xzzn/ems/domain/EmsStrategy.java | 114 +++++++++++++++++ .../xzzn/ems/domain/EmsStrategyRunning.java | 115 ++++++++++++++++++ .../xzzn/ems/domain/vo/SiteDeviceListVo.java | 10 ++ .../xzzn/ems/domain/vo/StrategyRunningVo.java | 82 +++++++++++++ .../xzzn/ems/mapper/EmsStrategyMapper.java | 63 ++++++++++ .../ems/mapper/EmsStrategyRunningMapper.java | 71 +++++++++++ .../xzzn/ems/service/IEmsStrategyService.java | 30 +++++ .../service/impl/EmsStrategyServiceImpl.java | 62 ++++++++++ .../mapper/ems/EmsSiteSettingMapper.xml | 3 +- .../mapper/ems/EmsStrategyMapper.xml | 92 ++++++++++++++ .../mapper/ems/EmsStrategyRunningMapper.xml | 113 +++++++++++++++++ 13 files changed, 821 insertions(+), 2 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategy.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyRunning.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyRunningVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsStrategyMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.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 0ff205f..61bf378 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 @@ -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; diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java new file mode 100644 index 0000000..5f82dda --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java @@ -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)); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategy.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategy.java new file mode 100644 index 0000000..1eaea3d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategy.java @@ -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(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyRunning.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyRunning.java new file mode 100644 index 0000000..3b4e26c --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyRunning.java @@ -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(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java index 5dc4155..13e95b0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -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; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyRunningVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyRunningVo.java new file mode 100644 index 0000000..5531027 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyRunningVo.java @@ -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; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java new file mode 100644 index 0000000..6d430fc --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java @@ -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 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 getStrategyListByType(Long type); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java new file mode 100644 index 0000000..2443df7 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java @@ -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 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 getRunningList(String siteId); + + // 停止策略 + public int stopEmsStrategyRunning(Long id); + + // 根据主策略id、辅助策略id、siteId 获取运行策略 + public EmsStrategyRunning selectEmsStrategyRunning(EmsStrategyRunning emsStrategyRunning); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java new file mode 100644 index 0000000..dfeefff --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java @@ -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 selectEmsStrategyRunningList(String siteId); + + // 停止策略 + public int stopRunningStrategy(Long id); + + // 获取主策略 + public List getMainStrategyList(); + + // 获取辅助策略 + public List getAuxStrategyList(); + + public int configStrategy(EmsStrategyRunning emsStrategyRunning); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java new file mode 100644 index 0000000..78054e3 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java @@ -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 selectEmsStrategyRunningList(String siteId) { + List dataList = emsStrategyRunningMapper.getRunningList(siteId); + return dataList; + } + + @Override + public int stopRunningStrategy(Long id) { + return emsStrategyRunningMapper.stopEmsStrategyRunning(id); + } + + @Override + public List getMainStrategyList() { + return emsStrategyMapper.getStrategyListByType(1L); + } + + @Override + public List 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); + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index e182b46..4968384 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -136,7 +136,8 @@ + + + and strategy_name like concat('%', #{strategyName}, '%') + and strategy_type = #{strategyType} + and status = #{status} + and description = #{description} + and main_strategy = #{mainStrategy} + + + + + + + insert into ems_strategy + + strategy_name, + strategy_type, + status, + create_time, + update_time, + description, + main_strategy, + + + #{strategyName}, + #{strategyType}, + #{status}, + #{createTime}, + #{updateTime}, + #{description}, + #{mainStrategy}, + + + + + update ems_strategy + + strategy_name = #{strategyName}, + strategy_type = #{strategyType}, + status = #{status}, + create_time = #{createTime}, + update_time = #{updateTime}, + description = #{description}, + main_strategy = #{mainStrategy}, + + where id = #{id} + + + + delete from ems_strategy where id = #{id} + + + + delete from ems_strategy where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml new file mode 100644 index 0000000..d35175b --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + select id, main_strategy_id, auxiliary_strategy_id, status, create_time, update_time, site_id, device_id, remark from ems_strategy_running + + + + + + + + insert into ems_strategy_running + + main_strategy_id, + auxiliary_strategy_id, + status, + create_time, + update_time, + site_id, + device_id, + remark, + + + #{mainStrategyId}, + #{auxiliaryStrategyId}, + #{status}, + #{createTime}, + #{updateTime}, + #{siteId}, + #{deviceId}, + #{remark}, + + + + + update ems_strategy_running + + main_strategy_id = #{mainStrategyId}, + auxiliary_strategy_id = #{auxiliaryStrategyId}, + status = #{status}, + create_time = #{createTime}, + update_time = #{updateTime}, + site_id = #{siteId}, + device_id = #{deviceId}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_strategy_running where id = #{id} + + + + delete from ems_strategy_running where id in + + #{id} + + + + + + + update ems_strategy_running set `status`= 4 where id = #{id} + + + + \ No newline at end of file -- 2.49.0 From 05a2af8c929455303f4e122937c507442a63f690 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 11 Jul 2025 15:04:46 +0800 Subject: [PATCH 073/336] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/EmsTicketController.java | 5 ++- .../controller/system/SysUserController.java | 13 ++++++ .../com/xzzn/ems/domain/vo/TicketListVo.java | 40 +++++++++++++++++++ .../com/xzzn/ems/mapper/EmsTicketMapper.java | 8 ++++ .../xzzn/ems/service/IEmsTicketService.java | 9 +++++ .../service/impl/EmsTicketServiceImpl.java | 13 ++++++ .../resources/mapper/ems/EmsTicketMapper.xml | 15 +++++++ 7 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/TicketListVo.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java index 1970124..754cac1 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java @@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse; import com.xzzn.common.utils.poi.ExcelUtil; import com.xzzn.ems.domain.EmsTicket; +import com.xzzn.ems.domain.vo.TicketListVo; import com.xzzn.ems.service.IEmsTicketService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -43,7 +44,7 @@ public class EmsTicketController extends BaseController public TableDataInfo list(EmsTicket emsTicket) { startPage(); - List list = emsTicketService.selectEmsTicketList(emsTicket); + List list = emsTicketService.getAllTicketList(emsTicket); return getDataTable(list); } @@ -111,6 +112,6 @@ public class EmsTicketController extends BaseController @PostMapping("/drop") public AjaxResult drop(@RequestBody EmsTicket emsTicket) { - return toAjax(emsTicketService.dropEmsTicketById(emsTicket.getId())); + return toAjax(emsTicketService.dropEmsTicketById(emsTicket.getTicketNo())); } } diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/system/SysUserController.java b/ems-admin/src/main/java/com/xzzn/web/controller/system/SysUserController.java index ffe93bb..842620f 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/system/SysUserController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/system/SysUserController.java @@ -3,6 +3,8 @@ package com.xzzn.web.controller.system; import java.util.List; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import com.xzzn.system.service.impl.SysUserServiceImpl; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -52,6 +54,8 @@ public class SysUserController extends BaseController @Autowired private ISysPostService postService; + @Autowired + private SysUserServiceImpl sysUserServiceImpl; /** * 获取用户列表 @@ -253,4 +257,13 @@ public class SysUserController extends BaseController { return success(deptService.selectDeptTreeList(dept)); } + + /** + * 获取所有用户 + */ + @GetMapping("/getAllUser") + public AjaxResult getAllUser(SysUser user) + { + return success(userService.selectUserList(user)); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/TicketListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/TicketListVo.java new file mode 100644 index 0000000..22d90ec --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/TicketListVo.java @@ -0,0 +1,40 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xzzn.common.annotation.Excel; +import com.xzzn.common.core.domain.BaseEntity; +import com.xzzn.ems.domain.EmsTicket; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; + +/** + * 工单列表对象 + * + */ +public class TicketListVo extends EmsTicket +{ + private static final long serialVersionUID = 1L; + + // 提交人姓名 + private String userName; + // 处理人姓名 + private String workName; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getWorkName() { + return workName; + } + + public void setWorkName(String workName) { + this.workName = workName; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java index f944a4c..7dcf5a9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java @@ -1,6 +1,7 @@ package com.xzzn.ems.mapper; import com.xzzn.ems.domain.EmsTicket; +import com.xzzn.ems.domain.vo.TicketListVo; import java.util.List; @@ -66,4 +67,11 @@ public interface EmsTicketMapper * @return */ public int dropEmsTicketById(String id); + + /** + * 获取工单列表 + * @param emsTicket + * @return + */ + public List getAllTicketList(EmsTicket emsTicket); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java index 7fe9993..6eac8e2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java @@ -1,6 +1,7 @@ package com.xzzn.ems.service; import com.xzzn.ems.domain.EmsTicket; +import com.xzzn.ems.domain.vo.TicketListVo; import java.util.List; @@ -66,4 +67,12 @@ public interface IEmsTicketService * @return */ public int dropEmsTicketById(String id); + + /** + * 获取工单列表 + * + * @param emsTicket 工单主 + * @return 工单主集合 + */ + public List getAllTicketList(EmsTicket emsTicket); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java index f9917ec..a63f057 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java @@ -1,8 +1,11 @@ package com.xzzn.ems.service.impl; import java.util.List; +import java.util.Random; + import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsTicket; +import com.xzzn.ems.domain.vo.TicketListVo; import com.xzzn.ems.mapper.EmsTicketMapper; import com.xzzn.ems.service.IEmsTicketService; import org.springframework.beans.factory.annotation.Autowired; @@ -54,6 +57,11 @@ public class EmsTicketServiceImpl implements IEmsTicketService @Override public int insertEmsTicket(EmsTicket emsTicket) { + // 工单号随机生产 + String ticketNo = ""; + String nowDate = DateUtils.dateTime(); + ticketNo = "T" + nowDate + String.format("%06d", new Random().nextInt(1000000)); + emsTicket.setTicketNo(ticketNo); emsTicket.setCreateTime(DateUtils.getNowDate()); return emsTicketMapper.insertEmsTicket(emsTicket); } @@ -106,4 +114,9 @@ public class EmsTicketServiceImpl implements IEmsTicketService { return emsTicketMapper.dropEmsTicketById(id); } + + @Override + public List getAllTicketList(EmsTicket emsTicket) { + return emsTicketMapper.getAllTicketList(emsTicket); + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml index f0901b2..eb0041e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml @@ -114,4 +114,19 @@ update ems_ticket set isDelete = 0 where id = #{id} + + \ No newline at end of file -- 2.49.0 From 84757ab358c6b47f3b13ed049fd7a2952ba64f73 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 11 Jul 2025 16:43:47 +0800 Subject: [PATCH 074/336] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java | 6 +++--- .../xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java index da19310..ea401d1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java @@ -26,7 +26,7 @@ public class EmsTicket extends BaseEntity /** 提交用户ID */ @Excel(name = "提交用户ID") - private String userId; + private Long userId; /** 工单标题 */ @Excel(name = "工单标题") @@ -77,12 +77,12 @@ public class EmsTicket extends BaseEntity return ticketNo; } - public void setUserId(String userId) + public void setUserId(Long userId) { this.userId = userId; } - public String getUserId() + public Long getUserId() { return userId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index 18ec20e..6e38d64 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -143,7 +143,7 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService emsTicket.setTicketNo(ticketNo); emsTicket.setTitle("工单"+id.toString()); emsTicket.setContent(emsAlarmRecords.getAlarmContent()); - emsTicket.setUserId(userId.toString()); + emsTicket.setUserId(userId); emsTicket.setWorkUserId(userId); emsTicket.setCreateTime(DateUtils.getNowDate()); emsTicket.setCreateBy(user.getUserName()); -- 2.49.0 From 3b55f3d05328fa7ec93779abfc27b19d6936454b Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 11 Jul 2025 19:47:15 +0800 Subject: [PATCH 075/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E8=AF=A6=E6=83=85=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStrategyCurveController.java | 102 +++++++++ .../ems/EmsStrategyTempController.java | 110 ++++++++++ .../ems/EmsStrategyTimeConfigController.java | 101 +++++++++ .../controller/ems/EmsTicketController.java | 2 +- .../com/xzzn/ems/domain/EmsStrategyCurve.java | 136 ++++++++++++ .../com/xzzn/ems/domain/EmsStrategyTemp.java | 194 ++++++++++++++++++ .../ems/domain/EmsStrategyTimeConfig.java | 102 +++++++++ .../ems/mapper/EmsStrategyCurveMapper.java | 61 ++++++ .../ems/mapper/EmsStrategyTempMapper.java | 64 ++++++ .../mapper/EmsStrategyTimeConfigMapper.java | 61 ++++++ .../ems/service/IEmsStrategyCurveService.java | 61 ++++++ .../ems/service/IEmsStrategyTempService.java | 63 ++++++ .../IEmsStrategyTimeConfigService.java | 61 ++++++ .../impl/EmsStrategyCurveServiceImpl.java | 96 +++++++++ .../impl/EmsStrategyTempServiceImpl.java | 101 +++++++++ .../EmsStrategyTimeConfigServiceImpl.java | 96 +++++++++ .../mapper/ems/EmsStrategyCurveMapper.xml | 101 +++++++++ .../mapper/ems/EmsStrategyTempMapper.xml | 128 ++++++++++++ .../ems/EmsStrategyTimeConfigMapper.xml | 92 +++++++++ 19 files changed, 1731 insertions(+), 1 deletion(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTimeConfigController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java new file mode 100644 index 0000000..f66bcc1 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java @@ -0,0 +1,102 @@ +package com.xzzn.web.controller.ems; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.xzzn.common.annotation.Log; +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.BusinessType; +import com.xzzn.ems.domain.EmsStrategyCurve; +import com.xzzn.ems.service.IEmsStrategyCurveService; +import com.xzzn.common.utils.poi.ExcelUtil; +import com.xzzn.common.core.page.TableDataInfo; + +/** + * 策曲线Controller + * + * @author xzzn + * @date 2025-07-11 + */ +@RestController +@RequestMapping("/strategy/curve") +public class EmsStrategyCurveController extends BaseController +{ + @Autowired + private IEmsStrategyCurveService emsStrategyCurveService; + + /** + * 查询策曲线列表 + */ + @PreAuthorize("@ss.hasPermi('system:curve:list')") + @GetMapping("/list") + public AjaxResult list(EmsStrategyCurve emsStrategyCurve) + { + return success(emsStrategyCurveService.selectEmsStrategyCurveList(emsStrategyCurve)); + } + + /** + * 导出策曲线列表 + */ + @PreAuthorize("@ss.hasPermi('system:curve:export')") + @Log(title = "策曲线", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsStrategyCurve emsStrategyCurve) + { + List list = emsStrategyCurveService.selectEmsStrategyCurveList(emsStrategyCurve); + ExcelUtil util = new ExcelUtil(EmsStrategyCurve.class); + util.exportExcel(response, list, "策曲线数据"); + } + + /** + * 获取策曲线详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:curve:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(emsStrategyCurveService.selectEmsStrategyCurveById(id)); + } + + /** + * 新增策曲线 + */ + @PreAuthorize("@ss.hasPermi('system:curve:add')") + @Log(title = "策曲线", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsStrategyCurve emsStrategyCurve) + { + return toAjax(emsStrategyCurveService.insertEmsStrategyCurve(emsStrategyCurve)); + } + + /** + * 修改策曲线 + */ + @PreAuthorize("@ss.hasPermi('system:curve:edit')") + @Log(title = "策曲线", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsStrategyCurve emsStrategyCurve) + { + return toAjax(emsStrategyCurveService.updateEmsStrategyCurve(emsStrategyCurve)); + } + + /** + * 删除策曲线 + */ + @PreAuthorize("@ss.hasPermi('system:curve:remove')") + @Log(title = "策曲线", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(emsStrategyCurveService.deleteEmsStrategyCurveByIds(ids)); + } +} diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java new file mode 100644 index 0000000..647c943 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java @@ -0,0 +1,110 @@ +package com.xzzn.web.controller.ems; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.xzzn.common.annotation.Log; +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.BusinessType; +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.service.IEmsStrategyTempService; +import com.xzzn.common.utils.poi.ExcelUtil; + +/** + * 模板Controller + * + * @author xzzn + * @date 2025-07-11 + */ +@RestController +@RequestMapping("/strategy/temp") +public class EmsStrategyTempController extends BaseController +{ + @Autowired + private IEmsStrategyTempService emsStrategyTempService; + + /** + * 查询模板列表 + */ + @PreAuthorize("@ss.hasPermi('system:temp:list')") + @GetMapping("/list") + public AjaxResult list(EmsStrategyTemp emsStrategyTemp) + { + return success(emsStrategyTempService.selectEmsStrategyTempList(emsStrategyTemp)); + } + + /** + * 导出模板列表 + */ + @PreAuthorize("@ss.hasPermi('system:temp:export')") + @Log(title = "模板", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsStrategyTemp emsStrategyTemp) + { + List list = emsStrategyTempService.selectEmsStrategyTempList(emsStrategyTemp); + ExcelUtil util = new ExcelUtil(EmsStrategyTemp.class); + util.exportExcel(response, list, "模板数据"); + } + + /** + * 获取模板详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:temp:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(emsStrategyTempService.selectEmsStrategyTempById(id)); + } + + /** + * 新增模板 + */ + @PreAuthorize("@ss.hasPermi('system:temp:add')") + @Log(title = "模板", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsStrategyTemp emsStrategyTemp) + { + return toAjax(emsStrategyTempService.insertEmsStrategyTemp(emsStrategyTemp)); + } + + /** + * 修改模板 + */ + @PreAuthorize("@ss.hasPermi('system:temp:edit')") + @Log(title = "模板", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsStrategyTemp emsStrategyTemp) + { + return toAjax(emsStrategyTempService.updateEmsStrategyTemp(emsStrategyTemp)); + } + + /** + * 删除模板 + */ + @PreAuthorize("@ss.hasPermi('system:temp:remove')") + @Log(title = "模板", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(emsStrategyTempService.deleteEmsStrategyTempByIds(ids)); + } + + /** + * 根据策略id站点id获取所有模板名称 + */ + @GetMapping("/getTempNameList") + public AjaxResult getTempNameList(Long strategyId, String siteId) + { + return success(emsStrategyTempService.getTempNameList(strategyId, siteId)); + } +} diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTimeConfigController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTimeConfigController.java new file mode 100644 index 0000000..1267d36 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTimeConfigController.java @@ -0,0 +1,101 @@ +package com.xzzn.web.controller.ems; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.xzzn.common.annotation.Log; +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.BusinessType; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; +import com.xzzn.ems.service.IEmsStrategyTimeConfigService; +import com.xzzn.common.utils.poi.ExcelUtil; + +/** + * 时间配置Controller + * + * @author xzzn + * @date 2025-07-11 + */ +@RestController +@RequestMapping("/strategy/timeConfig") +public class EmsStrategyTimeConfigController extends BaseController +{ + @Autowired + private IEmsStrategyTimeConfigService emsStrategyTimeConfigService; + + /** + * 查询时间配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:config:list')") + @GetMapping("/list") + public AjaxResult list(EmsStrategyTimeConfig emsStrategyTimeConfig) + { + return success(emsStrategyTimeConfigService.selectEmsStrategyTimeConfigList(emsStrategyTimeConfig)); + } + + /** + * 导出时间配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:config:export')") + @Log(title = "时间配置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsStrategyTimeConfig emsStrategyTimeConfig) + { + List list = emsStrategyTimeConfigService.selectEmsStrategyTimeConfigList(emsStrategyTimeConfig); + ExcelUtil util = new ExcelUtil(EmsStrategyTimeConfig.class); + util.exportExcel(response, list, "时间配置数据"); + } + + /** + * 获取时间配置详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:config:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(emsStrategyTimeConfigService.selectEmsStrategyTimeConfigById(id)); + } + + /** + * 新增时间配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:add')") + @Log(title = "时间配置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsStrategyTimeConfig emsStrategyTimeConfig) + { + return toAjax(emsStrategyTimeConfigService.insertEmsStrategyTimeConfig(emsStrategyTimeConfig)); + } + + /** + * 修改时间配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:edit')") + @Log(title = "时间配置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsStrategyTimeConfig emsStrategyTimeConfig) + { + return toAjax(emsStrategyTimeConfigService.updateEmsStrategyTimeConfig(emsStrategyTimeConfig)); + } + + /** + * 删除时间配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:remove')") + @Log(title = "时间配置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(emsStrategyTimeConfigService.deleteEmsStrategyTimeConfigByIds(ids)); + } +} diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java index 754cac1..f1c26d9 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java @@ -112,6 +112,6 @@ public class EmsTicketController extends BaseController @PostMapping("/drop") public AjaxResult drop(@RequestBody EmsTicket emsTicket) { - return toAjax(emsTicketService.dropEmsTicketById(emsTicket.getTicketNo())); + return toAjax(emsTicketService.dropEmsTicketById(emsTicket.getId())); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java new file mode 100644 index 0000000..dff611c --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java @@ -0,0 +1,136 @@ +package com.xzzn.ems.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_curve + * + * @author xzzn + * @date 2025-07-11 + */ +public class EmsStrategyCurve extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 关联的策略ID */ + @Excel(name = "关联的策略ID") + private Long strategyId; + + /** 任务编号 */ + @Excel(name = "任务编号") + private Long taskNumber; + + /** 开始日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date startDate; + + /** 结束日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date endDate; + + /** 功率数据,可以是JSON格式存储曲线数据 */ + @Excel(name = "功率数据,可以是JSON格式存储曲线数据") + private String powerData; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setStrategyId(Long strategyId) + { + this.strategyId = strategyId; + } + + public Long getStrategyId() + { + return strategyId; + } + + public void setTaskNumber(Long taskNumber) + { + this.taskNumber = taskNumber; + } + + public Long getTaskNumber() + { + return taskNumber; + } + + public void setStartDate(Date startDate) + { + this.startDate = startDate; + } + + public Date getStartDate() + { + return startDate; + } + + public void setEndDate(Date endDate) + { + this.endDate = endDate; + } + + public Date getEndDate() + { + return endDate; + } + + public void setPowerData(String powerData) + { + this.powerData = powerData; + } + + public String getPowerData() + { + return powerData; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("strategyId", getStrategyId()) + .append("taskNumber", getTaskNumber()) + .append("startDate", getStartDate()) + .append("endDate", getEndDate()) + .append("powerData", getPowerData()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java new file mode 100644 index 0000000..20d8064 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java @@ -0,0 +1,194 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.time.LocalTime; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_temp + * + * @author xzzn + * @date 2025-07-11 + */ +public class EmsStrategyTemp extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 关联的策略ID */ + @Excel(name = "关联的策略ID") + private Long strategyId; + + /** 模板名称,如“模板一” */ + @Excel(name = "模板名称,如“模板一”") + private String templateName; + + /** SDC限制 (%) */ + @Excel(name = "SDC限制 (%)") + private BigDecimal sdcLimit; + + /** SDC下限 (%) */ + @Excel(name = "SDC下限 (%)") + private BigDecimal sdcDown; + + /** SDC上限 (%) */ + @Excel(name = "SDC上限 (%)") + private BigDecimal sdcUp; + + /** 开始时间 */ + @JsonFormat(pattern = "HH:mm:ss") + @Excel(name = "开始时间", width = 30, dateFormat = "HH:mm:ss") + private LocalTime startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "HH:mm:ss") + @Excel(name = "结束时间", width = 30, dateFormat = "HH:mm:ss") + private LocalTime endTime; + + /** 充放功率 (kW) */ + @Excel(name = "充放功率 (kW)") + private BigDecimal chargeDischargePower; + + /** 充电状态,如“1-充电”、“2-待机” */ + @Excel(name = "充电状态,如“1-充电”、“2-待机”") + private String chargeStatus; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setStrategyId(Long strategyId) + { + this.strategyId = strategyId; + } + + public Long getStrategyId() + { + return strategyId; + } + + public void setTemplateName(String templateName) + { + this.templateName = templateName; + } + + public String getTemplateName() + { + return templateName; + } + + public void setSdcLimit(BigDecimal sdcLimit) + { + this.sdcLimit = sdcLimit; + } + + public BigDecimal getSdcLimit() + { + return sdcLimit; + } + + public void setSdcDown(BigDecimal sdcDown) + { + this.sdcDown = sdcDown; + } + + public BigDecimal getSdcDown() + { + return sdcDown; + } + + public void setSdcUp(BigDecimal sdcUp) + { + this.sdcUp = sdcUp; + } + + public BigDecimal getSdcUp() + { + return sdcUp; + } + + public LocalTime getStartTime() { + return startTime; + } + + public void setStartTime(LocalTime startTime) { + this.startTime = startTime; + } + + public LocalTime getEndTime() { + return endTime; + } + + public void setEndTime(LocalTime endTime) { + this.endTime = endTime; + } + + public void setChargeDischargePower(BigDecimal chargeDischargePower) + { + this.chargeDischargePower = chargeDischargePower; + } + + public BigDecimal getChargeDischargePower() + { + return chargeDischargePower; + } + + public void setChargeStatus(String chargeStatus) + { + this.chargeStatus = chargeStatus; + } + + public String getChargeStatus() + { + return chargeStatus; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("strategyId", getStrategyId()) + .append("templateName", getTemplateName()) + .append("sdcLimit", getSdcLimit()) + .append("sdcDown", getSdcDown()) + .append("sdcUp", getSdcUp()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("chargeDischargePower", getChargeDischargePower()) + .append("chargeStatus", getChargeStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java new file mode 100644 index 0000000..250f68f --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java @@ -0,0 +1,102 @@ +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_time_config + * + * @author xzzn + * @date 2025-07-11 + */ +public class EmsStrategyTimeConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 关联的策略ID */ + @Excel(name = "关联的策略ID") + private Long strategyId; + + /** 月份,1-12 */ + @Excel(name = "月份,1-12") + private Long month; + + /** 充放电模式,如“两充两放” */ + @Excel(name = "充放电模式,如“两充两放”") + private String chargeDischargeMode; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setStrategyId(Long strategyId) + { + this.strategyId = strategyId; + } + + public Long getStrategyId() + { + return strategyId; + } + + public void setMonth(Long month) + { + this.month = month; + } + + public Long getMonth() + { + return month; + } + + public void setChargeDischargeMode(String chargeDischargeMode) + { + this.chargeDischargeMode = chargeDischargeMode; + } + + public String getChargeDischargeMode() + { + return chargeDischargeMode; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("strategyId", getStrategyId()) + .append("month", getMonth()) + .append("chargeDischargeMode", getChargeDischargeMode()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java new file mode 100644 index 0000000..9776cd1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsStrategyCurve; + +/** + * 策曲线Mapper接口 + * + * @author xzzn + * @date 2025-07-11 + */ +public interface EmsStrategyCurveMapper +{ + /** + * 查询策曲线 + * + * @param id 策曲线主键 + * @return 策曲线 + */ + public EmsStrategyCurve selectEmsStrategyCurveById(Long id); + + /** + * 查询策曲线列表 + * + * @param emsStrategyCurve 策曲线 + * @return 策曲线集合 + */ + public List selectEmsStrategyCurveList(EmsStrategyCurve emsStrategyCurve); + + /** + * 新增策曲线 + * + * @param emsStrategyCurve 策曲线 + * @return 结果 + */ + public int insertEmsStrategyCurve(EmsStrategyCurve emsStrategyCurve); + + /** + * 修改策曲线 + * + * @param emsStrategyCurve 策曲线 + * @return 结果 + */ + public int updateEmsStrategyCurve(EmsStrategyCurve emsStrategyCurve); + + /** + * 删除策曲线 + * + * @param id 策曲线主键 + * @return 结果 + */ + public int deleteEmsStrategyCurveById(Long id); + + /** + * 批量删除策曲线 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsStrategyCurveByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java new file mode 100644 index 0000000..4ee49b1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java @@ -0,0 +1,64 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsStrategyTemp; +import org.apache.ibatis.annotations.Param; + +/** + * 模板Mapper接口 + * + * @author xzzn + * @date 2025-07-11 + */ +public interface EmsStrategyTempMapper +{ + /** + * 查询模板 + * + * @param id 模板主键 + * @return 模板 + */ + public EmsStrategyTemp selectEmsStrategyTempById(Long id); + + /** + * 查询模板列表 + * + * @param emsStrategyTemp 模板 + * @return 模板集合 + */ + public List selectEmsStrategyTempList(EmsStrategyTemp emsStrategyTemp); + + /** + * 新增模板 + * + * @param emsStrategyTemp 模板 + * @return 结果 + */ + public int insertEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp); + + /** + * 修改模板 + * + * @param emsStrategyTemp 模板 + * @return 结果 + */ + public int updateEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp); + + /** + * 删除模板 + * + * @param id 模板主键 + * @return 结果 + */ + public int deleteEmsStrategyTempById(Long id); + + /** + * 批量删除模板 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsStrategyTempByIds(Long[] ids); + + public List getTempNameList(@Param("strategyId")Long strategyId, @Param("siteId")String siteId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java new file mode 100644 index 0000000..2662826 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; + +/** + * 时间配置Mapper接口 + * + * @author xzzn + * @date 2025-07-11 + */ +public interface EmsStrategyTimeConfigMapper +{ + /** + * 查询时间配置 + * + * @param id 时间配置主键 + * @return 时间配置 + */ + public EmsStrategyTimeConfig selectEmsStrategyTimeConfigById(Long id); + + /** + * 查询时间配置列表 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 时间配置集合 + */ + public List selectEmsStrategyTimeConfigList(EmsStrategyTimeConfig emsStrategyTimeConfig); + + /** + * 新增时间配置 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 结果 + */ + public int insertEmsStrategyTimeConfig(EmsStrategyTimeConfig emsStrategyTimeConfig); + + /** + * 修改时间配置 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 结果 + */ + public int updateEmsStrategyTimeConfig(EmsStrategyTimeConfig emsStrategyTimeConfig); + + /** + * 删除时间配置 + * + * @param id 时间配置主键 + * @return 结果 + */ + public int deleteEmsStrategyTimeConfigById(Long id); + + /** + * 批量删除时间配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsStrategyTimeConfigByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java new file mode 100644 index 0000000..74e883a --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsStrategyCurve; + +/** + * 策曲线Service接口 + * + * @author xzzn + * @date 2025-07-11 + */ +public interface IEmsStrategyCurveService +{ + /** + * 查询策曲线 + * + * @param id 策曲线主键 + * @return 策曲线 + */ + public EmsStrategyCurve selectEmsStrategyCurveById(Long id); + + /** + * 查询策曲线列表 + * + * @param emsStrategyCurve 策曲线 + * @return 策曲线集合 + */ + public List selectEmsStrategyCurveList(EmsStrategyCurve emsStrategyCurve); + + /** + * 新增策曲线 + * + * @param emsStrategyCurve 策曲线 + * @return 结果 + */ + public int insertEmsStrategyCurve(EmsStrategyCurve emsStrategyCurve); + + /** + * 修改策曲线 + * + * @param emsStrategyCurve 策曲线 + * @return 结果 + */ + public int updateEmsStrategyCurve(EmsStrategyCurve emsStrategyCurve); + + /** + * 批量删除策曲线 + * + * @param ids 需要删除的策曲线主键集合 + * @return 结果 + */ + public int deleteEmsStrategyCurveByIds(Long[] ids); + + /** + * 删除策曲线信息 + * + * @param id 策曲线主键 + * @return 结果 + */ + public int deleteEmsStrategyCurveById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java new file mode 100644 index 0000000..21e2fd7 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java @@ -0,0 +1,63 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsStrategyTemp; + +/** + * 模板Service接口 + * + * @author xzzn + * @date 2025-07-11 + */ +public interface IEmsStrategyTempService +{ + /** + * 查询模板 + * + * @param id 模板主键 + * @return 模板 + */ + public EmsStrategyTemp selectEmsStrategyTempById(Long id); + + /** + * 查询模板列表 + * + * @param emsStrategyTemp 模板 + * @return 模板集合 + */ + public List selectEmsStrategyTempList(EmsStrategyTemp emsStrategyTemp); + + /** + * 新增模板 + * + * @param emsStrategyTemp 模板 + * @return 结果 + */ + public int insertEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp); + + /** + * 修改模板 + * + * @param emsStrategyTemp 模板 + * @return 结果 + */ + public int updateEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp); + + /** + * 批量删除模板 + * + * @param ids 需要删除的模板主键集合 + * @return 结果 + */ + public int deleteEmsStrategyTempByIds(Long[] ids); + + /** + * 删除模板信息 + * + * @param id 模板主键 + * @return 结果 + */ + public int deleteEmsStrategyTempById(Long id); + + public List getTempNameList(Long strategyId, String siteId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java new file mode 100644 index 0000000..dd658d6 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; + +/** + * 时间配置Service接口 + * + * @author xzzn + * @date 2025-07-11 + */ +public interface IEmsStrategyTimeConfigService +{ + /** + * 查询时间配置 + * + * @param id 时间配置主键 + * @return 时间配置 + */ + public EmsStrategyTimeConfig selectEmsStrategyTimeConfigById(Long id); + + /** + * 查询时间配置列表 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 时间配置集合 + */ + public List selectEmsStrategyTimeConfigList(EmsStrategyTimeConfig emsStrategyTimeConfig); + + /** + * 新增时间配置 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 结果 + */ + public int insertEmsStrategyTimeConfig(EmsStrategyTimeConfig emsStrategyTimeConfig); + + /** + * 修改时间配置 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 结果 + */ + public int updateEmsStrategyTimeConfig(EmsStrategyTimeConfig emsStrategyTimeConfig); + + /** + * 批量删除时间配置 + * + * @param ids 需要删除的时间配置主键集合 + * @return 结果 + */ + public int deleteEmsStrategyTimeConfigByIds(Long[] ids); + + /** + * 删除时间配置信息 + * + * @param id 时间配置主键 + * @return 结果 + */ + public int deleteEmsStrategyTimeConfigById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java new file mode 100644 index 0000000..62a0bb2 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsStrategyCurveMapper; +import com.xzzn.ems.domain.EmsStrategyCurve; +import com.xzzn.ems.service.IEmsStrategyCurveService; + +/** + * 策曲线Service业务层处理 + * + * @author xzzn + * @date 2025-07-11 + */ +@Service +public class EmsStrategyCurveServiceImpl implements IEmsStrategyCurveService +{ + @Autowired + private EmsStrategyCurveMapper emsStrategyCurveMapper; + + /** + * 查询策曲线 + * + * @param id 策曲线主键 + * @return 策曲线 + */ + @Override + public EmsStrategyCurve selectEmsStrategyCurveById(Long id) + { + return emsStrategyCurveMapper.selectEmsStrategyCurveById(id); + } + + /** + * 查询策曲线列表 + * + * @param emsStrategyCurve 策曲线 + * @return 策曲线 + */ + @Override + public List selectEmsStrategyCurveList(EmsStrategyCurve emsStrategyCurve) + { + return emsStrategyCurveMapper.selectEmsStrategyCurveList(emsStrategyCurve); + } + + /** + * 新增策曲线 + * + * @param emsStrategyCurve 策曲线 + * @return 结果 + */ + @Override + public int insertEmsStrategyCurve(EmsStrategyCurve emsStrategyCurve) + { + emsStrategyCurve.setCreateTime(DateUtils.getNowDate()); + return emsStrategyCurveMapper.insertEmsStrategyCurve(emsStrategyCurve); + } + + /** + * 修改策曲线 + * + * @param emsStrategyCurve 策曲线 + * @return 结果 + */ + @Override + public int updateEmsStrategyCurve(EmsStrategyCurve emsStrategyCurve) + { + emsStrategyCurve.setUpdateTime(DateUtils.getNowDate()); + return emsStrategyCurveMapper.updateEmsStrategyCurve(emsStrategyCurve); + } + + /** + * 批量删除策曲线 + * + * @param ids 需要删除的策曲线主键 + * @return 结果 + */ + @Override + public int deleteEmsStrategyCurveByIds(Long[] ids) + { + return emsStrategyCurveMapper.deleteEmsStrategyCurveByIds(ids); + } + + /** + * 删除策曲线信息 + * + * @param id 策曲线主键 + * @return 结果 + */ + @Override + public int deleteEmsStrategyCurveById(Long id) + { + return emsStrategyCurveMapper.deleteEmsStrategyCurveById(id); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java new file mode 100644 index 0000000..8e426fe --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -0,0 +1,101 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsStrategyTempMapper; +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.service.IEmsStrategyTempService; + +/** + * 模板Service业务层处理 + * + * @author xzzn + * @date 2025-07-11 + */ +@Service +public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService +{ + @Autowired + private EmsStrategyTempMapper emsStrategyTempMapper; + + /** + * 查询模板 + * + * @param id 模板主键 + * @return 模板 + */ + @Override + public EmsStrategyTemp selectEmsStrategyTempById(Long id) + { + return emsStrategyTempMapper.selectEmsStrategyTempById(id); + } + + /** + * 查询模板列表 + * + * @param emsStrategyTemp 模板 + * @return 模板 + */ + @Override + public List selectEmsStrategyTempList(EmsStrategyTemp emsStrategyTemp) + { + return emsStrategyTempMapper.selectEmsStrategyTempList(emsStrategyTemp); + } + + /** + * 新增模板 + * + * @param emsStrategyTemp 模板 + * @return 结果 + */ + @Override + public int insertEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp) + { + emsStrategyTemp.setCreateTime(DateUtils.getNowDate()); + return emsStrategyTempMapper.insertEmsStrategyTemp(emsStrategyTemp); + } + + /** + * 修改模板 + * + * @param emsStrategyTemp 模板 + * @return 结果 + */ + @Override + public int updateEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp) + { + emsStrategyTemp.setUpdateTime(DateUtils.getNowDate()); + return emsStrategyTempMapper.updateEmsStrategyTemp(emsStrategyTemp); + } + + /** + * 批量删除模板 + * + * @param ids 需要删除的模板主键 + * @return 结果 + */ + @Override + public int deleteEmsStrategyTempByIds(Long[] ids) + { + return emsStrategyTempMapper.deleteEmsStrategyTempByIds(ids); + } + + /** + * 删除模板信息 + * + * @param id 模板主键 + * @return 结果 + */ + @Override + public int deleteEmsStrategyTempById(Long id) + { + return emsStrategyTempMapper.deleteEmsStrategyTempById(id); + } + + @Override + public List getTempNameList(Long strategyId, String siteId) { + return emsStrategyTempMapper.getTempNameList(strategyId, siteId); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java new file mode 100644 index 0000000..fb35ed4 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; +import com.xzzn.ems.service.IEmsStrategyTimeConfigService; + +/** + * 时间配置Service业务层处理 + * + * @author xzzn + * @date 2025-07-11 + */ +@Service +public class EmsStrategyTimeConfigServiceImpl implements IEmsStrategyTimeConfigService +{ + @Autowired + private EmsStrategyTimeConfigMapper emsStrategyTimeConfigMapper; + + /** + * 查询时间配置 + * + * @param id 时间配置主键 + * @return 时间配置 + */ + @Override + public EmsStrategyTimeConfig selectEmsStrategyTimeConfigById(Long id) + { + return emsStrategyTimeConfigMapper.selectEmsStrategyTimeConfigById(id); + } + + /** + * 查询时间配置列表 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 时间配置 + */ + @Override + public List selectEmsStrategyTimeConfigList(EmsStrategyTimeConfig emsStrategyTimeConfig) + { + return emsStrategyTimeConfigMapper.selectEmsStrategyTimeConfigList(emsStrategyTimeConfig); + } + + /** + * 新增时间配置 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 结果 + */ + @Override + public int insertEmsStrategyTimeConfig(EmsStrategyTimeConfig emsStrategyTimeConfig) + { + emsStrategyTimeConfig.setCreateTime(DateUtils.getNowDate()); + return emsStrategyTimeConfigMapper.insertEmsStrategyTimeConfig(emsStrategyTimeConfig); + } + + /** + * 修改时间配置 + * + * @param emsStrategyTimeConfig 时间配置 + * @return 结果 + */ + @Override + public int updateEmsStrategyTimeConfig(EmsStrategyTimeConfig emsStrategyTimeConfig) + { + emsStrategyTimeConfig.setUpdateTime(DateUtils.getNowDate()); + return emsStrategyTimeConfigMapper.updateEmsStrategyTimeConfig(emsStrategyTimeConfig); + } + + /** + * 批量删除时间配置 + * + * @param ids 需要删除的时间配置主键 + * @return 结果 + */ + @Override + public int deleteEmsStrategyTimeConfigByIds(Long[] ids) + { + return emsStrategyTimeConfigMapper.deleteEmsStrategyTimeConfigByIds(ids); + } + + /** + * 删除时间配置信息 + * + * @param id 时间配置主键 + * @return 结果 + */ + @Override + public int deleteEmsStrategyTimeConfigById(Long id) + { + return emsStrategyTimeConfigMapper.deleteEmsStrategyTimeConfigById(id); + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml new file mode 100644 index 0000000..21666b5 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + select id, strategy_id, task_number, start_date, end_date, power_data, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_curve + + + + + + + + insert into ems_strategy_curve + + strategy_id, + task_number, + start_date, + end_date, + power_data, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + + + #{strategyId}, + #{taskNumber}, + #{startDate}, + #{endDate}, + #{powerData}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + + + + + update ems_strategy_curve + + strategy_id = #{strategyId}, + task_number = #{taskNumber}, + start_date = #{startDate}, + end_date = #{endDate}, + power_data = #{powerData}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + + where id = #{id} + + + + delete from ems_strategy_curve where id = #{id} + + + + delete from ems_strategy_curve where id in + + #{id} + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml new file mode 100644 index 0000000..886c4a0 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select id, strategy_id, template_name, sdc_limit, sdc_down, sdc_up, start_time, end_time, charge_discharge_power, charge_status, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_temp + + + + + + + + insert into ems_strategy_temp + + strategy_id, + template_name, + sdc_limit, + sdc_down, + sdc_up, + start_time, + end_time, + charge_discharge_power, + charge_status, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + + + #{strategyId}, + #{templateName}, + #{sdcLimit}, + #{sdcDown}, + #{sdcUp}, + #{startTime}, + #{endTime}, + #{chargeDischargePower}, + #{chargeStatus}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + + + + + update ems_strategy_temp + + strategy_id = #{strategyId}, + template_name = #{templateName}, + sdc_limit = #{sdcLimit}, + sdc_down = #{sdcDown}, + sdc_up = #{sdcUp}, + start_time = #{startTime}, + end_time = #{endTime}, + charge_discharge_power = #{chargeDischargePower}, + charge_status = #{chargeStatus}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + + where id = #{id} + + + + delete from ems_strategy_temp where id = #{id} + + + + delete from ems_strategy_temp where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml new file mode 100644 index 0000000..6408e38 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + select id, strategy_id, month, charge_discharge_mode, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_time_config + + + + + + + + insert into ems_strategy_time_config + + strategy_id, + month, + charge_discharge_mode, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + + + #{strategyId}, + #{month}, + #{chargeDischargeMode}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + + + + + update ems_strategy_time_config + + strategy_id = #{strategyId}, + month = #{month}, + charge_discharge_mode = #{chargeDischargeMode}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + + where id = #{id} + + + + delete from ems_strategy_time_config where id = #{id} + + + + delete from ems_strategy_time_config where id in + + #{id} + + + \ No newline at end of file -- 2.49.0 From 7dc664446eafcad26f8b8573288bf75d9dbee1f3 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 11 Jul 2025 20:58:55 +0800 Subject: [PATCH 076/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8-?= =?UTF-8?q?=E4=B8=8D=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/ems/EmsSiteConfigController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 61bf378..b0559c8 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 @@ -42,7 +42,7 @@ public class EmsSiteConfigController extends BaseController{ } /** - * 获取设备列表 + * 获取设备列表-分页 */ @GetMapping("/getDeviceInfoList") public TableDataInfo getDeviceInfoList(@RequestParam String siteId) @@ -60,4 +60,13 @@ public class EmsSiteConfigController extends BaseController{ { return success(iEmsDeviceSettingService.getDeviceDetailInfo(deviceId)); } + + /** + * 获取设备列表-不分页 + */ + @GetMapping("/getDeviceList") + public AjaxResult getDeviceInfoList2(@RequestParam String siteId) + { + return success(iEmsSiteService.getAllDeviceList(siteId)); + } } -- 2.49.0 From 118be05c8a7c6f2703276c1cddc9695d918dd04e Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 12 Jul 2025 14:48:35 +0800 Subject: [PATCH 077/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8-?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 79 +++++++++++++++-- .../com/xzzn/common/enums/DeviceCategory.java | 3 +- .../xzzn/ems/domain/EmsDevicesSetting.java | 17 +++- .../xzzn/ems/domain/vo/SiteDeviceListVo.java | 20 +++++ .../ems/mapper/EmsDevicesSettingMapper.java | 9 +- .../ems/service/IEmsDeviceSettingService.java | 13 ++- .../impl/EmsDeviceSettingServiceImpl.java | 87 ++++++++++++++++++- .../service/impl/SingleSiteServiceImpl.java | 3 +- .../mapper/ems/EmsDevicesSettingMapper.xml | 10 ++- .../mapper/ems/EmsSiteSettingMapper.xml | 4 +- 10 files changed, 222 insertions(+), 23 deletions(-) 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 b0559c8..099fff5 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 @@ -1,17 +1,19 @@ package com.xzzn.web.controller.ems; +import com.xzzn.common.config.RuoYiConfig; import com.xzzn.common.core.controller.BaseController; 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.SiteDeviceListVo; import com.xzzn.ems.service.IEmsDeviceSettingService; import com.xzzn.ems.service.IEmsSiteService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -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.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -56,9 +58,9 @@ public class EmsSiteConfigController extends BaseController{ * 获取设备详细信息 */ @GetMapping("/getDeviceDetailInfo") - public AjaxResult getDeviceDetailInfo(@RequestParam String deviceId) + public AjaxResult getDeviceDetailInfo(@RequestParam Long id) { - return success(iEmsDeviceSettingService.getDeviceDetailInfo(deviceId)); + return success(iEmsDeviceSettingService.getDeviceDetailInfo(id)); } /** @@ -69,4 +71,69 @@ public class EmsSiteConfigController extends BaseController{ { return success(iEmsSiteService.getAllDeviceList(siteId)); } + + /** + * 获取所有设备类别 + */ + @GetMapping("/getDeviceCategory") + public AjaxResult getDeviceCategory() + { + return success(iEmsDeviceSettingService.getDeviceCategory()); + } + + /** + * 新增设备 + */ + @PostMapping("/addDevice") + public AjaxResult addDevice(@RequestBody EmsDevicesSetting devicesSetting) + { + int result = iEmsDeviceSettingService.addDevice(devicesSetting); + if (result > 0) { + return AjaxResult.success(result); + } else { + return AjaxResult.error("该设备已存在"); + } + } + + /** + * 上传设备图片 + */ + @PostMapping("/uploadDeviceImg") + public AjaxResult uploadDeviceImg(@RequestParam("avatarfile") MultipartFile file) throws Exception + { + if (!file.isEmpty()) { + String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION); + + AjaxResult ajax = AjaxResult.success(); + ajax.put("imgUrl", avatar); + return ajax; + } + return error("上传图片异常,请联系管理员"); + } + + /** + * 修改Modbus设备配置 + */ + @PostMapping("/updateDevice") + public AjaxResult updateDevice(@RequestBody EmsDevicesSetting emsDevicesSetting) + { + int result = iEmsDeviceSettingService.updateDevice(emsDevicesSetting); + if (result > 0) { + return AjaxResult.success(result); + } else if (result == -1) { + return AjaxResult.error("数据不存在"); + } else if (result == -2) { + return AjaxResult.error("该设备已存在"); + } + return AjaxResult.success(result); + } + + /** + * 删除Modbus设备配置 + */ + @DeleteMapping("/deleteService/{id}") + public AjaxResult deleteService(@PathVariable Long id) + { + return toAjax(iEmsDeviceSettingService.deleteEmsDevicesSettingById(id)); + } } diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java index aefa25a..3b48820 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java @@ -12,7 +12,8 @@ public enum DeviceCategory STACK("STACK", "电池堆"), CLUSTER("CLUSTER", "电池簇"), BATTERY("BATTERY", "单体电池"), - AMMETER("AMMETER", "电表"); + AMMETER("AMMETER", "电表"), + COOLING("COOLING", "冷液体"); private final String code; private final String info; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java index 0f174ca..694d0e8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * Modbus设备配置对象 ems_devices_setting * * @author xzzn - * @date 2025-07-02 + * @date 2025-07-12 */ public class EmsDevicesSetting extends BaseEntity { @@ -102,6 +102,10 @@ public class EmsDevicesSetting extends BaseEntity @Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”") private String deviceCategory; + /** 设备图像地址 */ + @Excel(name = "设备图像地址") + private String pictureUrl; + public void setId(Long id) { this.id = id; @@ -312,6 +316,16 @@ public class EmsDevicesSetting extends BaseEntity return deviceCategory; } + public void setPictureUrl(String pictureUrl) + { + this.pictureUrl = pictureUrl; + } + + public String getPictureUrl() + { + return pictureUrl; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -336,6 +350,7 @@ public class EmsDevicesSetting extends BaseEntity .append("deviceId", getDeviceId()) .append("parentId", getParentId()) .append("deviceCategory", getDeviceCategory()) + .append("pictureUrl", getPictureUrl()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java index 13e95b0..387b64c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -19,6 +19,10 @@ public class SiteDeviceListVo { private String communicationStatus; /** 设备类型 */ private String deviceCategory; + /** 设备类型 */ + private String pictureUrl; + /** 唯一标识 */ + private String id; public String getSiteId() { return siteId; @@ -75,4 +79,20 @@ public class SiteDeviceListVo { public void setDeviceCategory(String deviceCategory) { this.deviceCategory = deviceCategory; } + + public String getPictureUrl() { + return pictureUrl; + } + + public void setPictureUrl(String pictureUrl) { + this.pictureUrl = pictureUrl; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 6e0ef1f..66f78af 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -76,17 +76,12 @@ public interface EmsDevicesSettingMapper */ public List> getDeviceInfosBySiteIdAndCategory(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); - /** - * 获取该设备的详细数据 - * @param deviceId - * @return - */ - public EmsDevicesSetting getDeviceDetailInfo(String deviceId); - /** * 获取该设备下的总表 * @param siteId * @return */ public List> getLoadNameList(String siteId); + + public EmsDevicesSetting getDeviceBySiteAndDeviceId(@Param("deviceId")String deviceId, @Param("siteId")String siteId); } 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 970d040..3340e50 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 @@ -1,7 +1,10 @@ package com.xzzn.ems.service; +import com.xzzn.common.enums.DeviceCategory; import com.xzzn.ems.domain.EmsDevicesSetting; +import java.util.List; + /** * 设备信息 服务层 * @@ -9,5 +12,13 @@ import com.xzzn.ems.domain.EmsDevicesSetting; public interface IEmsDeviceSettingService { - public EmsDevicesSetting getDeviceDetailInfo(String deviceId); + public EmsDevicesSetting getDeviceDetailInfo(Long deviceId); + + public int addDevice(EmsDevicesSetting devicesSetting); + + public int updateDevice(EmsDevicesSetting emsDevicesSetting); + + public int deleteEmsDevicesSettingById(Long id); + + public List getDeviceCategory(); } 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 b8485a1..1837a49 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 @@ -1,11 +1,17 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.service.IEmsDeviceSettingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Arrays; +import java.util.List; + /** * 站点信息 服务层实现 * @@ -18,11 +24,86 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService /** * 获取设备详细信息 - * @param deviceId + * @param id * @return */ @Override - public EmsDevicesSetting getDeviceDetailInfo(String deviceId) { - return emsDevicesMapper.getDeviceDetailInfo(deviceId); + public EmsDevicesSetting getDeviceDetailInfo(Long id) { + return emsDevicesMapper.selectEmsDevicesSettingById(id); + } + + /** + * 新增设备 + * @param devicesSetting + * @return + */ + @Override + public int addDevice(EmsDevicesSetting devicesSetting) { + boolean flag = checkDeviceExist(devicesSetting); + if (flag) { + return -1; + } + devicesSetting.setCreateTime(DateUtils.getNowDate()); + return emsDevicesMapper.insertEmsDevicesSetting(devicesSetting); + } + + /** + * 更新设备 + * @param devicesSetting + * @return + */ + @Override + public int updateDevice(EmsDevicesSetting devicesSetting) { + boolean checkExist = false; + if (devicesSetting.getId() != null) { + // 根据id判断该数据是否存在 + EmsDevicesSetting existDevice = emsDevicesMapper.selectEmsDevicesSettingById(devicesSetting.getId()); + if (existDevice == null) { + return -1; + } + // 存在判断是否修改deviceId和siteId + String deviceId = existDevice.getDeviceId(); + String siteId = existDevice.getSiteId(); + if (!deviceId.equals(devicesSetting.getDeviceId()) + || !siteId.equals(devicesSetting.getSiteId())) { + checkExist = checkDeviceExist(devicesSetting); + } + } + // 已修改校验修改后数据是否存在 + if (checkExist) { + return -2; + } + devicesSetting.setUpdateTime(DateUtils.getNowDate()); + return emsDevicesMapper.updateEmsDevicesSetting(devicesSetting); + } + + private boolean checkDeviceExist(EmsDevicesSetting devicesSetting) { + String deviceId = devicesSetting.getDeviceId(); + String siteId = devicesSetting.getSiteId(); + if (!StringUtils.isEmpty(deviceId) && !StringUtils.isEmpty(siteId)) { + EmsDevicesSetting emsDevicesSetting = emsDevicesMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); + if (emsDevicesSetting != null) { + return true; + } + } + return false; + } + + /** + * 删除设备配置信息 + * + * @param id Modbus设备配置主键 + * @return 结果 + */ + @Override + public int deleteEmsDevicesSettingById(Long id){ + + return emsDevicesMapper.deleteEmsDevicesSettingById(id); + } + + @Override + public List getDeviceCategory() { + List deviceList = Arrays.asList(DeviceCategory.values()); + return deviceList; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index a456966..a67127e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -402,7 +402,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } else if (AMMETER_DEVICE_METE.equals(ammeterId)) { AmmeterMeteDataVo ammeterMeteDataVo = new AmmeterMeteDataVo(); ammeterMeteDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); - ammeterMeteDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus").toString()); + ammeterMeteDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : + ammeterDevice.get("communicationStatus").toString()); // 处理储能表数据 dealAmmeterMeteData(ammeterData,ammeterMeteDataVo); ammeterResponse.setAmmeterMeteDataVoList(ammeterMeteDataVo); diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 679568b..df9a946 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -26,10 +26,11 @@ + - select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category from ems_devices_setting + select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category, picture_url from ems_devices_setting @@ -86,6 +88,7 @@ device_id, parent_id, device_category, + picture_url, #{deviceName}, @@ -108,6 +111,7 @@ #{deviceId}, #{parentId}, #{deviceCategory}, + #{pictureUrl}, @@ -134,6 +138,7 @@ device_id = #{deviceId}, parent_id = #{parentId}, device_category = #{deviceCategory}, + picture_url = #{pictureUrl}, where id = #{id} @@ -180,9 +185,10 @@ from ems_devices_setting where site_id = #{siteId} and device_category = #{deviceCategory} - where device_id = #{deviceId} + AND site_id = #{siteId} limit 1 diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index 4968384..9b83f92 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -137,7 +137,9 @@ 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_category as deviceCategory + ed.device_category as deviceCategory, + ed.picture_url as pictureUrl, + ed.id from ems_site_setting es INNER JOIN ems_devices_setting ed on es.site_id = ed.site_id where 1=1 -- 2.49.0 From eafb0ec2c63a0960513802ee2fa71c443d1aabfd Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 12 Jul 2025 14:54:18 +0800 Subject: [PATCH 078/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8-?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=AE=BE=E5=A4=87=E5=9B=BE=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/web/controller/ems/EmsSiteConfigController.java | 2 +- .../src/main/java/com/xzzn/common/config/RuoYiConfig.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 099fff5..50d2276 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 @@ -102,7 +102,7 @@ public class EmsSiteConfigController extends BaseController{ public AjaxResult uploadDeviceImg(@RequestParam("avatarfile") MultipartFile file) throws Exception { if (!file.isEmpty()) { - String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION); + String avatar = FileUploadUtils.upload(RuoYiConfig.getDevicePath(), file, MimeTypeUtils.IMAGE_EXTENSION); AjaxResult ajax = AjaxResult.success(); ajax.put("imgUrl", avatar); diff --git a/ems-common/src/main/java/com/xzzn/common/config/RuoYiConfig.java b/ems-common/src/main/java/com/xzzn/common/config/RuoYiConfig.java index 39db47a..d56e411 100644 --- a/ems-common/src/main/java/com/xzzn/common/config/RuoYiConfig.java +++ b/ems-common/src/main/java/com/xzzn/common/config/RuoYiConfig.java @@ -119,4 +119,12 @@ public class RuoYiConfig { return getProfile() + "/upload"; } + + /** + * 获取头像上传路径 + */ + public static String getDevicePath() + { + return getProfile() + "/device"; + } } -- 2.49.0 From aa751464b49ceb5cf7c027540c03d5e6f889aa0c Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 12 Jul 2025 18:51:23 +0800 Subject: [PATCH 079/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E4=BF=AE=E6=94=B9&=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/EmsStrategyController.java | 11 +- .../ems/EmsStrategyTempController.java | 51 +++--- .../com/xzzn/common/enums/SdcLimitType.java | 30 ++++ ems-system/pom.xml | 4 + .../com/xzzn/ems/domain/EmsStrategyTemp.java | 76 +-------- .../ems/domain/EmsStrategyTempTimeConfig.java | 122 ++++++++++++++ .../ems/domain/EmsStrategyTimeConfig.java | 19 ++- .../domain/vo/StrategyTempConfigRequest.java | 107 ++++++++++++ .../domain/vo/StrategyTempTimeConfigVo.java | 152 ++++++++++++++++++ .../ems/mapper/EmsStrategyRunningMapper.java | 2 +- .../ems/mapper/EmsStrategyTempMapper.java | 8 +- .../EmsStrategyTempTimeConfigMapper.java | 67 ++++++++ .../ems/service/IEmsStrategyTempService.java | 33 ++-- .../service/impl/EmsStrategyServiceImpl.java | 2 +- .../impl/EmsStrategyTempServiceImpl.java | 88 ++++++---- .../mapper/ems/EmsStrategyRunningMapper.xml | 2 +- .../mapper/ems/EmsStrategyTempMapper.xml | 30 +--- .../ems/EmsStrategyTempTimeConfigMapper.xml | 105 ++++++++++++ .../ems/EmsStrategyTimeConfigMapper.xml | 8 +- 19 files changed, 733 insertions(+), 184 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/SdcLimitType.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempTimeConfigVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java index 5f82dda..e534224 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyController.java @@ -1,5 +1,6 @@ package com.xzzn.web.controller.ems; +import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsStrategyRunning; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -60,8 +61,16 @@ public class EmsStrategyController extends BaseController @PostMapping(value = "/configStrategy") public AjaxResult configStrategy(@RequestBody EmsStrategyRunning emsStrategyRunning) { + if (emsStrategyRunning.getMainStrategyId() == null + || StringUtils.isEmpty(emsStrategyRunning.getSiteId())){ + return error("缺少必填字段"); + } emsStrategyRunning.setCreateBy(getUsername()); emsStrategyRunning.setUpdateBy(getUsername()); - return toAjax(emsStrategyService.configStrategy(emsStrategyRunning)); + int result = emsStrategyService.configStrategy(emsStrategyRunning); + if (result == -1){ + return error("站点该策略配置运行中"); + } + return success(result); } } diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java index 647c943..548a971 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java @@ -2,6 +2,8 @@ package com.xzzn.web.controller.ems; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -34,47 +36,24 @@ public class EmsStrategyTempController extends BaseController private IEmsStrategyTempService emsStrategyTempService; /** - * 查询模板列表 + * 获取单个模板时间配置详细信息 */ @PreAuthorize("@ss.hasPermi('system:temp:list')") @GetMapping("/list") - public AjaxResult list(EmsStrategyTemp emsStrategyTemp) + public AjaxResult list(Long templateId) { - return success(emsStrategyTempService.selectEmsStrategyTempList(emsStrategyTemp)); + return success(emsStrategyTempService.selectEmsStrategyTempList(templateId)); } /** - * 导出模板列表 - */ - @PreAuthorize("@ss.hasPermi('system:temp:export')") - @Log(title = "模板", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, EmsStrategyTemp emsStrategyTemp) - { - List list = emsStrategyTempService.selectEmsStrategyTempList(emsStrategyTemp); - ExcelUtil util = new ExcelUtil(EmsStrategyTemp.class); - util.exportExcel(response, list, "模板数据"); - } - - /** - * 获取模板详细信息 - */ - @PreAuthorize("@ss.hasPermi('system:temp:query')") - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { - return success(emsStrategyTempService.selectEmsStrategyTempById(id)); - } - - /** - * 新增模板 + * 新增模板及时间配置 */ @PreAuthorize("@ss.hasPermi('system:temp:add')") @Log(title = "模板", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody EmsStrategyTemp emsStrategyTemp) + public AjaxResult add(@RequestBody StrategyTempConfigRequest requestVo) { - return toAjax(emsStrategyTempService.insertEmsStrategyTemp(emsStrategyTemp)); + return success(emsStrategyTempService.addNewTempAndTimeConfig(requestVo)); } /** @@ -85,7 +64,12 @@ public class EmsStrategyTempController extends BaseController @PutMapping public AjaxResult edit(@RequestBody EmsStrategyTemp emsStrategyTemp) { - return toAjax(emsStrategyTempService.updateEmsStrategyTemp(emsStrategyTemp)); + int result = emsStrategyTempService.updateEmsStrategyTemp(emsStrategyTemp); + if (result > 0) { + return success(result); + } else { + return AjaxResult.error("新增失败请重试!"); + } } /** @@ -93,10 +77,11 @@ public class EmsStrategyTempController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:temp:remove')") @Log(title = "模板", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) + @DeleteMapping("/{id}") + public AjaxResult remove(@PathVariable Long id) { - return toAjax(emsStrategyTempService.deleteEmsStrategyTempByIds(ids)); + emsStrategyTempService.deleteStrategyTempById(id); + return success(); } /** diff --git a/ems-common/src/main/java/com/xzzn/common/enums/SdcLimitType.java b/ems-common/src/main/java/com/xzzn/common/enums/SdcLimitType.java new file mode 100644 index 0000000..d7a60f6 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/SdcLimitType.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * strategy模板-sdc限制 + * + * @author xzzn + */ +public enum SdcLimitType +{ + OFF("0", "关"), ON("1", "开"); + + private final String code; + private final String info; + + SdcLimitType(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-system/pom.xml b/ems-system/pom.xml index 458ffa1..7f2b1e1 100644 --- a/ems-system/pom.xml +++ b/ems-system/pom.xml @@ -22,6 +22,10 @@ com.xzzn ems-common + + org.glassfish.jaxb + jaxb-runtime + diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java index 20d8064..3a68e7f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java @@ -1,9 +1,7 @@ package com.xzzn.ems.domain; import java.math.BigDecimal; -import java.time.LocalTime; -import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; + import com.xzzn.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -13,13 +11,13 @@ import com.xzzn.common.annotation.Excel; * 模板对象 ems_strategy_temp * * @author xzzn - * @date 2025-07-11 + * @date 2025-07-12 */ public class EmsStrategyTemp extends BaseEntity { private static final long serialVersionUID = 1L; - /** $column.columnComment */ + /** */ private Long id; /** 关联的策略ID */ @@ -30,9 +28,9 @@ public class EmsStrategyTemp extends BaseEntity @Excel(name = "模板名称,如“模板一”") private String templateName; - /** SDC限制 (%) */ - @Excel(name = "SDC限制 (%)") - private BigDecimal sdcLimit; + /** SDC限制 (%) 1 = 开,0 = 关 */ + @Excel(name = "SDC限制 (%) 1 = 开,0 = 关") + private Integer sdcLimit; /** SDC下限 (%) */ @Excel(name = "SDC下限 (%)") @@ -42,24 +40,6 @@ public class EmsStrategyTemp extends BaseEntity @Excel(name = "SDC上限 (%)") private BigDecimal sdcUp; - /** 开始时间 */ - @JsonFormat(pattern = "HH:mm:ss") - @Excel(name = "开始时间", width = 30, dateFormat = "HH:mm:ss") - private LocalTime startTime; - - /** 结束时间 */ - @JsonFormat(pattern = "HH:mm:ss") - @Excel(name = "结束时间", width = 30, dateFormat = "HH:mm:ss") - private LocalTime endTime; - - /** 充放功率 (kW) */ - @Excel(name = "充放功率 (kW)") - private BigDecimal chargeDischargePower; - - /** 充电状态,如“1-充电”、“2-待机” */ - @Excel(name = "充电状态,如“1-充电”、“2-待机”") - private String chargeStatus; - /** 站点id */ @Excel(name = "站点id") private String siteId; @@ -94,12 +74,12 @@ public class EmsStrategyTemp extends BaseEntity return templateName; } - public void setSdcLimit(BigDecimal sdcLimit) + public void setSdcLimit(Integer sdcLimit) { this.sdcLimit = sdcLimit; } - public BigDecimal getSdcLimit() + public Integer getSdcLimit() { return sdcLimit; } @@ -124,42 +104,6 @@ public class EmsStrategyTemp extends BaseEntity return sdcUp; } - public LocalTime getStartTime() { - return startTime; - } - - public void setStartTime(LocalTime startTime) { - this.startTime = startTime; - } - - public LocalTime getEndTime() { - return endTime; - } - - public void setEndTime(LocalTime endTime) { - this.endTime = endTime; - } - - public void setChargeDischargePower(BigDecimal chargeDischargePower) - { - this.chargeDischargePower = chargeDischargePower; - } - - public BigDecimal getChargeDischargePower() - { - return chargeDischargePower; - } - - public void setChargeStatus(String chargeStatus) - { - this.chargeStatus = chargeStatus; - } - - public String getChargeStatus() - { - return chargeStatus; - } - public void setSiteId(String siteId) { this.siteId = siteId; @@ -179,10 +123,6 @@ public class EmsStrategyTemp extends BaseEntity .append("sdcLimit", getSdcLimit()) .append("sdcDown", getSdcDown()) .append("sdcUp", getSdcUp()) - .append("startTime", getStartTime()) - .append("endTime", getEndTime()) - .append("chargeDischargePower", getChargeDischargePower()) - .append("chargeStatus", getChargeStatus()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java new file mode 100644 index 0000000..3740ef7 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java @@ -0,0 +1,122 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_temp_time_config + * + * @author xzzn + * @date 2025-07-12 + */ +public class EmsStrategyTempTimeConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** 充放功率 (kW) */ + @Excel(name = "充放功率 (kW)") + private BigDecimal chargeDischargePower; + + /** 充电状态,如“1-充电”、“2-待机” */ + @Excel(name = "充电状态,如“1-充电”、“2-待机”") + private String chargeStatus; + + /** 模板id */ + @Excel(name = "模板id") + private Long templateId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + + public void setChargeDischargePower(BigDecimal chargeDischargePower) + { + this.chargeDischargePower = chargeDischargePower; + } + + public BigDecimal getChargeDischargePower() + { + return chargeDischargePower; + } + + public void setChargeStatus(String chargeStatus) + { + this.chargeStatus = chargeStatus; + } + + public String getChargeStatus() + { + return chargeStatus; + } + + public void setTemplateId(Long templateId) + { + this.templateId = templateId; + } + + public Long getTemplateId() + { + return templateId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("chargeDischargePower", getChargeDischargePower()) + .append("chargeStatus", getChargeStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("templateId", getTemplateId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java index 250f68f..17256d6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java @@ -9,13 +9,13 @@ import com.xzzn.common.annotation.Excel; * 时间配置对象 ems_strategy_time_config * * @author xzzn - * @date 2025-07-11 + * @date 2025-07-12 */ public class EmsStrategyTimeConfig extends BaseEntity { private static final long serialVersionUID = 1L; - /** $column.columnComment */ + /** */ private Long id; /** 关联的策略ID */ @@ -34,6 +34,10 @@ public class EmsStrategyTimeConfig extends BaseEntity @Excel(name = "站点id") private String siteId; + /** 模板id */ + @Excel(name = "模板id") + private String templateId; + public void setId(Long id) { this.id = id; @@ -84,6 +88,16 @@ public class EmsStrategyTimeConfig extends BaseEntity return siteId; } + public void setTemplateId(String templateId) + { + this.templateId = templateId; + } + + public String getTemplateId() + { + return templateId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -97,6 +111,7 @@ public class EmsStrategyTimeConfig extends BaseEntity .append("updateTime", getUpdateTime()) .append("remark", getRemark()) .append("siteId", getSiteId()) + .append("templateId", getTemplateId()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java new file mode 100644 index 0000000..2c9ac93 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java @@ -0,0 +1,107 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 新增模板+模板时间数据 + * + * @author xzzn + * @date 2025-07-12 + */ +public class StrategyTempConfigRequest +{ + + /** 模板id */ + private Long id; + /** 站点id */ + private String siteId; + + /** 关联的策略ID */ + private Long strategyId; + + /** 模板名称,如“模板一” */ + private String templateName; + + /** SDC限制 (%) 1 = 开,0 = 关 */ + private Integer sdcLimit; + + /** SDC下限 (%) */ + private BigDecimal sdcDown; + + /** SDC上限 (%) */ + private BigDecimal sdcUp; + + /** 模板时间 */ + private List timeConfigList; + + public void setStrategyId(Long strategyId) + { + this.strategyId = strategyId; + } + + public Long getStrategyId() + { + return strategyId; + } + + public void setTemplateName(String templateName) + { + this.templateName = templateName; + } + + public String getTemplateName() + { + return templateName; + } + + public void setSdcLimit(Integer sdcLimit) + { + this.sdcLimit = sdcLimit; + } + + public Integer getSdcLimit() + { + return sdcLimit; + } + + public void setSdcDown(BigDecimal sdcDown) + { + this.sdcDown = sdcDown; + } + + public BigDecimal getSdcDown() + { + return sdcDown; + } + + public void setSdcUp(BigDecimal sdcUp) + { + this.sdcUp = sdcUp; + } + + public BigDecimal getSdcUp() + { + return sdcUp; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public List getTimeConfigList() { + return timeConfigList; + } + + public void setTimeConfigList(List timeConfigList) { + this.timeConfigList = timeConfigList; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempTimeConfigVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempTimeConfigVo.java new file mode 100644 index 0000000..b631cff --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempTimeConfigVo.java @@ -0,0 +1,152 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 模板+模板时间数据 + * + * @author xzzn + * @date 2025-07-12 + */ +public class StrategyTempTimeConfigVo +{ + /** 模版id */ + private Long id; + + /** 关联的策略ID */ + private Long strategyId; + + /** 模板名称,如“模板一” */ + private String templateName; + + /** SDC限制 (%) 1 = 开,0 = 关 */ + private Integer sdcLimit; + + /** SDC下限 (%) */ + private BigDecimal sdcDown; + + /** SDC上限 (%) */ + private BigDecimal sdcUp; + + /** 站点id */ + private String siteId; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date endTime; + + /** 充放功率 (kW) */ + private BigDecimal chargeDischargePower; + + /** 充电状态,如“1-充电”、“2-待机” */ + private String chargeStatus; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setStrategyId(Long strategyId) + { + this.strategyId = strategyId; + } + + public Long getStrategyId() + { + return strategyId; + } + + public void setTemplateName(String templateName) + { + this.templateName = templateName; + } + + public String getTemplateName() + { + return templateName; + } + + public void setSdcLimit(Integer sdcLimit) + { + this.sdcLimit = sdcLimit; + } + + public Integer getSdcLimit() + { + return sdcLimit; + } + + public void setSdcDown(BigDecimal sdcDown) + { + this.sdcDown = sdcDown; + } + + public BigDecimal getSdcDown() + { + return sdcDown; + } + + public void setSdcUp(BigDecimal sdcUp) + { + this.sdcUp = sdcUp; + } + + public BigDecimal getSdcUp() + { + return sdcUp; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public BigDecimal getChargeDischargePower() { + return chargeDischargePower; + } + + public void setChargeDischargePower(BigDecimal chargeDischargePower) { + this.chargeDischargePower = chargeDischargePower; + } + + public String getChargeStatus() { + return chargeStatus; + } + + public void setChargeStatus(String chargeStatus) { + this.chargeStatus = chargeStatus; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java index 2443df7..8d52260 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java @@ -60,7 +60,7 @@ public interface EmsStrategyRunningMapper */ public int deleteEmsStrategyRunningByIds(Long[] ids); - // 获取站点运行策略 + // 获取站点运行策略列表 public List getRunningList(String siteId); // 停止策略 diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java index 4ee49b1..b59e610 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java @@ -1,6 +1,8 @@ package com.xzzn.ems.mapper; import java.util.List; +import java.util.Map; + import com.xzzn.ems.domain.EmsStrategyTemp; import org.apache.ibatis.annotations.Param; @@ -60,5 +62,9 @@ public interface EmsStrategyTempMapper */ public int deleteEmsStrategyTempByIds(Long[] ids); - public List getTempNameList(@Param("strategyId")Long strategyId, @Param("siteId")String siteId); + // 获取模板名称和id + public List> getTempNameList(@Param("strategyId")Long strategyId, @Param("siteId")String siteId); + + // 删除模板 + public int deleteEmsStrategyTempByIds(Long id); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java new file mode 100644 index 0000000..b02f10d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java @@ -0,0 +1,67 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; + +/** + * 模板配置Mapper接口 + * + * @author xzzn + * @date 2025-07-12 + */ +public interface EmsStrategyTempTimeConfigMapper +{ + /** + * 查询模板配置 + * + * @param id 模板配置主键 + * @return 模板配置 + */ + public EmsStrategyTempTimeConfig selectEmsStrategyTempTimeConfigById(Long id); + + /** + * 查询模板配置列表 + * + * @param emsStrategyTempTimeConfig 模板配置 + * @return 模板配置集合 + */ + public List selectEmsStrategyTempTimeConfigList(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig); + + /** + * 新增模板配置 + * + * @param emsStrategyTempTimeConfig 模板配置 + * @return 结果 + */ + public int insertEmsStrategyTempTimeConfig(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig); + + /** + * 修改模板配置 + * + * @param emsStrategyTempTimeConfig 模板配置 + * @return 结果 + */ + public int updateEmsStrategyTempTimeConfig(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig); + + /** + * 删除模板配置 + * + * @param id 模板配置主键 + * @return 结果 + */ + public int deleteEmsStrategyTempTimeConfigById(Long id); + + /** + * 批量删除模板配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsStrategyTempTimeConfigByIds(Long[] ids); + + // 获取模板的时间 + public List getTimeListByTempId(Long templateId); + + // 根据模板id删除时间配置 + public void deleteTimeConfigByTempId(Long templateId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java index 21e2fd7..f80bee7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java @@ -1,7 +1,11 @@ package com.xzzn.ems.service; import java.util.List; +import java.util.Map; + import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; +import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo; /** * 模板Service接口 @@ -11,29 +15,12 @@ import com.xzzn.ems.domain.EmsStrategyTemp; */ public interface IEmsStrategyTempService { - /** - * 查询模板 - * - * @param id 模板主键 - * @return 模板 - */ - public EmsStrategyTemp selectEmsStrategyTempById(Long id); - /** - * 查询模板列表 - * - * @param emsStrategyTemp 模板 - * @return 模板集合 - */ - public List selectEmsStrategyTempList(EmsStrategyTemp emsStrategyTemp); + // 获取该模板下的时间配置 + public List selectEmsStrategyTempList(Long id); - /** - * 新增模板 - * - * @param emsStrategyTemp 模板 - * @return 结果 - */ - public int insertEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp); + // 新增模板及时间配置 + public int addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo); /** * 修改模板 @@ -59,5 +46,7 @@ public interface IEmsStrategyTempService */ public int deleteEmsStrategyTempById(Long id); - public List getTempNameList(Long strategyId, String siteId); + public List> getTempNameList(Long strategyId, String siteId); + + public void deleteStrategyTempById(Long id); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java index 78054e3..4bce076 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java @@ -48,7 +48,7 @@ public class EmsStrategyServiceImpl implements IEmsStrategyService @Override public int configStrategy(EmsStrategyRunning emsStrategyRunning) { - // 校验改策略是否已存在 + // 校验是否已存在已运行的相同策略 EmsStrategyRunning existStrategy = emsStrategyRunningMapper.selectEmsStrategyRunning(emsStrategyRunning); if (existStrategy != null) { return -1; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index 8e426fe..532cacd 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -1,7 +1,15 @@ package com.xzzn.ems.service.impl; +import java.util.ArrayList; import java.util.List; +import java.util.Map; + import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.bean.BeanUtils; +import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; +import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; +import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo; +import com.xzzn.ems.mapper.EmsStrategyTempTimeConfigMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsStrategyTempMapper; @@ -19,42 +27,36 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService { @Autowired private EmsStrategyTempMapper emsStrategyTempMapper; - - /** - * 查询模板 - * - * @param id 模板主键 - * @return 模板 - */ - @Override - public EmsStrategyTemp selectEmsStrategyTempById(Long id) - { - return emsStrategyTempMapper.selectEmsStrategyTempById(id); - } + @Autowired + private EmsStrategyTempTimeConfigMapper emsStrategyTempTimeConfigMapper; /** * 查询模板列表 * - * @param emsStrategyTemp 模板 + * @param templateId 模板 * @return 模板 */ @Override - public List selectEmsStrategyTempList(EmsStrategyTemp emsStrategyTemp) + public List selectEmsStrategyTempList(Long templateId) { - return emsStrategyTempMapper.selectEmsStrategyTempList(emsStrategyTemp); - } - - /** - * 新增模板 - * - * @param emsStrategyTemp 模板 - * @return 结果 - */ - @Override - public int insertEmsStrategyTemp(EmsStrategyTemp emsStrategyTemp) - { - emsStrategyTemp.setCreateTime(DateUtils.getNowDate()); - return emsStrategyTempMapper.insertEmsStrategyTemp(emsStrategyTemp); + List dataList = new ArrayList<>(); + EmsStrategyTemp temp = emsStrategyTempMapper.selectEmsStrategyTempById(templateId); + if (temp != null) { + List timeList = emsStrategyTempTimeConfigMapper.getTimeListByTempId(templateId); + if (timeList != null) { + for (EmsStrategyTempTimeConfig timeConfig : timeList) { + StrategyTempTimeConfigVo vo = new StrategyTempTimeConfigVo(); + BeanUtils.copyProperties(timeConfig, vo); + BeanUtils.copyProperties(temp, vo); + dataList.add(vo); + } + } else { + StrategyTempTimeConfigVo vo = new StrategyTempTimeConfigVo(); + BeanUtils.copyProperties(temp, vo); + dataList.add(vo); + } + } + return dataList; } /** @@ -95,7 +97,35 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService } @Override - public List getTempNameList(Long strategyId, String siteId) { + public List> getTempNameList(Long strategyId, String siteId) { return emsStrategyTempMapper.getTempNameList(strategyId, siteId); } + + @Override + public int addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo) { + EmsStrategyTemp emsStrategyTemp = new EmsStrategyTemp(); + BeanUtils.copyProperties(requestVo, emsStrategyTemp); + emsStrategyTemp.setCreateTime(DateUtils.getNowDate()); + emsStrategyTempMapper.insertEmsStrategyTemp(emsStrategyTemp); + + List timeList = requestVo.getTimeConfigList(); + if (timeList != null) { + for (EmsStrategyTempTimeConfig timeConfig : timeList) { + timeConfig.setCreateTime(DateUtils.getNowDate()); + timeConfig.setTemplateId(emsStrategyTemp.getId()); + emsStrategyTempTimeConfigMapper.insertEmsStrategyTempTimeConfig(timeConfig); + } + } + return 1; + } + + + @Override + public void deleteStrategyTempById(Long id) { + // 先删除时间配置 + emsStrategyTempTimeConfigMapper.deleteTimeConfigByTempId(id); + + // 再删除模板 + emsStrategyTempMapper.deleteEmsStrategyTempById(id); + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml index d35175b..19d5206 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml @@ -108,6 +108,6 @@ where site_id = #{siteId} and main_strategy_id = #{mainStrategyId} and auxiliary_strategy_id = #{auxiliaryStrategyId} - and `status` != 4 + and `status` = 1 \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml index 886c4a0..08b914d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml @@ -11,10 +11,6 @@ - - - - @@ -24,7 +20,7 @@ - select id, strategy_id, template_name, sdc_limit, sdc_down, sdc_up, start_time, end_time, charge_discharge_power, charge_status, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_temp + select id, strategy_id, template_name, sdc_limit, sdc_down, sdc_up, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_temp @@ -56,10 +48,6 @@ sdc_limit, sdc_down, sdc_up, - start_time, - end_time, - charge_discharge_power, - charge_status, create_by, create_time, update_by, @@ -73,10 +61,6 @@ #{sdcLimit}, #{sdcDown}, #{sdcUp}, - #{startTime}, - #{endTime}, - #{chargeDischargePower}, - #{chargeStatus}, #{createBy}, #{createTime}, #{updateBy}, @@ -94,10 +78,6 @@ sdc_limit = #{sdcLimit}, sdc_down = #{sdcDown}, sdc_up = #{sdcUp}, - start_time = #{startTime}, - end_time = #{endTime}, - charge_discharge_power = #{chargeDischargePower}, - charge_status = #{chargeStatus}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, @@ -119,10 +99,14 @@ - + select DISTINCT id as templateId,template_name as templateName from ems_strategy_temp where site_id = #{siteId} and strategy_id = #{strategyId} + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml new file mode 100644 index 0000000..c639a86 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + select id, start_time, end_time, charge_discharge_power, charge_status, create_by, create_time, update_by, update_time, remark, template_id from ems_strategy_temp_time_config + + + + + + + + insert into ems_strategy_temp_time_config + + start_time, + end_time, + charge_discharge_power, + charge_status, + create_by, + create_time, + update_by, + update_time, + remark, + template_id, + + + #{startTime}, + #{endTime}, + #{chargeDischargePower}, + #{chargeStatus}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{templateId}, + + + + + update ems_strategy_temp_time_config + + start_time = #{startTime}, + end_time = #{endTime}, + charge_discharge_power = #{chargeDischargePower}, + charge_status = #{chargeStatus}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + template_id = #{templateId}, + + where id = #{id} + + + + delete from ems_strategy_temp_time_config where id = #{id} + + + + delete from ems_strategy_temp_time_config where id in + + #{id} + + + + + + + delete from ems_strategy_temp_time_config where template_id = #{templateId} + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index 6408e38..49175c1 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -15,10 +15,11 @@ + - select id, strategy_id, month, charge_discharge_mode, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_time_config + select id, strategy_id, month, charge_discharge_mode, create_by, create_time, update_by, update_time, remark, site_id, template_id from ems_strategy_time_config @@ -93,4 +93,18 @@ #{id} + + + \ No newline at end of file -- 2.49.0 From 7b798f8323e7aebd6273a12d4801aa02f83b0b71 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 13 Jul 2025 11:58:40 +0800 Subject: [PATCH 083/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E6=A8=A1=E6=9D=BF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStrategyTempController.java | 32 ++-- .../com/xzzn/ems/domain/EmsStrategyTemp.java | 82 ++++++++++- .../ems/domain/EmsStrategyTempTimeConfig.java | 8 +- .../domain/vo/StrategyTempConfigRequest.java | 10 +- .../ems/mapper/EmsStrategyTempMapper.java | 7 +- .../EmsStrategyTempTimeConfigMapper.java | 67 --------- .../ems/service/IEmsStrategyTempService.java | 33 +---- .../impl/EmsStrategyTempServiceImpl.java | 138 ++++++------------ .../mapper/ems/EmsStrategyTempMapper.xml | 38 ++++- .../ems/EmsStrategyTempTimeConfigMapper.xml | 105 ------------- 10 files changed, 195 insertions(+), 325 deletions(-) delete mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java delete mode 100644 ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java index 0a994f6..b8a5071 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyTempController.java @@ -1,8 +1,5 @@ package com.xzzn.web.controller.ems; -import java.util.List; -import javax.servlet.http.HttpServletResponse; - import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -18,9 +15,7 @@ import com.xzzn.common.annotation.Log; import com.xzzn.common.core.controller.BaseController; import com.xzzn.common.core.domain.AjaxResult; import com.xzzn.common.enums.BusinessType; -import com.xzzn.ems.domain.EmsStrategyTemp; import com.xzzn.ems.service.IEmsStrategyTempService; -import com.xzzn.common.utils.poi.ExcelUtil; /** * 模板Controller @@ -35,12 +30,21 @@ public class EmsStrategyTempController extends BaseController @Autowired private IEmsStrategyTempService emsStrategyTempService; + /** + * 根据策略id站点id获取所有模板名称 + */ + @GetMapping("/getTempNameList") + public AjaxResult getTempNameList(Long strategyId, String siteId) + { + return success(emsStrategyTempService.getTempNameList(strategyId, siteId)); + } + /** * 获取单个模板时间配置详细信息 */ @PreAuthorize("@ss.hasPermi('system:temp:list')") @GetMapping("/list") - public AjaxResult list(Long templateId) + public AjaxResult list(String templateId) { return success(emsStrategyTempService.selectEmsStrategyTempList(templateId)); } @@ -82,19 +86,9 @@ public class EmsStrategyTempController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:temp:remove')") @Log(title = "模板", businessType = BusinessType.DELETE) - @DeleteMapping("/{id}") - public AjaxResult remove(@PathVariable Long id) + @DeleteMapping("/{templateId}") + public AjaxResult remove(@PathVariable String templateId) { - emsStrategyTempService.deleteStrategyTempById(id); - return success(); - } - - /** - * 根据策略id站点id获取所有模板名称 - */ - @GetMapping("/getTempNameList") - public AjaxResult getTempNameList(Long strategyId, String siteId) - { - return success(emsStrategyTempService.getTempNameList(strategyId, siteId)); + return success(emsStrategyTempService.deleteStrategyTempById(templateId)); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java index 3a68e7f..8b05e5b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTemp.java @@ -1,7 +1,8 @@ package com.xzzn.ems.domain; import java.math.BigDecimal; - +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import com.xzzn.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -11,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * 模板对象 ems_strategy_temp * * @author xzzn - * @date 2025-07-12 + * @date 2025-07-13 */ public class EmsStrategyTemp extends BaseEntity { @@ -40,10 +41,32 @@ public class EmsStrategyTemp extends BaseEntity @Excel(name = "SDC上限 (%)") private BigDecimal sdcUp; + /** 开始时间 */ + @JsonFormat(pattern = "HH:mm") + @Excel(name = "开始时间", width = 30, dateFormat = "HH:mm") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "HH:mm") + @Excel(name = "结束时间", width = 30, dateFormat = "HH:mm") + private Date endTime; + + /** 充放功率 (kW) */ + @Excel(name = "充放功率 (kW)") + private BigDecimal chargeDischargePower; + + /** 充电状态,如“1-充电”、“2-待机” */ + @Excel(name = "充电状态,如“1-充电”、“2-待机”") + private String chargeStatus; + /** 站点id */ @Excel(name = "站点id") private String siteId; + /** 模板id */ + @Excel(name = "模板id") + private String templateId; + public void setId(Long id) { this.id = id; @@ -104,6 +127,46 @@ public class EmsStrategyTemp extends BaseEntity return sdcUp; } + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + + public void setChargeDischargePower(BigDecimal chargeDischargePower) + { + this.chargeDischargePower = chargeDischargePower; + } + + public BigDecimal getChargeDischargePower() + { + return chargeDischargePower; + } + + public void setChargeStatus(String chargeStatus) + { + this.chargeStatus = chargeStatus; + } + + public String getChargeStatus() + { + return chargeStatus; + } + public void setSiteId(String siteId) { this.siteId = siteId; @@ -114,6 +177,16 @@ public class EmsStrategyTemp extends BaseEntity return siteId; } + public void setTemplateId(String templateId) + { + this.templateId = templateId; + } + + public String getTemplateId() + { + return templateId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -123,12 +196,17 @@ public class EmsStrategyTemp extends BaseEntity .append("sdcLimit", getSdcLimit()) .append("sdcDown", getSdcDown()) .append("sdcUp", getSdcUp()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("chargeDischargePower", getChargeDischargePower()) + .append("chargeStatus", getChargeStatus()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("remark", getRemark()) .append("siteId", getSiteId()) + .append("templateId", getTemplateId()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java index cc01298..9bb2f52 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java @@ -22,13 +22,13 @@ public class EmsStrategyTempTimeConfig extends BaseEntity private Long id; /** 开始时间 */ - @JsonFormat(pattern = "HH:mm:ss") - @Excel(name = "开始时间", width = 30, dateFormat = "HH:mm:ss") + @JsonFormat(pattern = "HH:mm") + @Excel(name = "开始时间", width = 30, dateFormat = "HH:mm") private Date startTime; /** 结束时间 */ - @JsonFormat(pattern = "HH:mm:ss") - @Excel(name = "结束时间", width = 30, dateFormat = "HH:mm:ss") + @JsonFormat(pattern = "HH:mm") + @Excel(name = "结束时间", width = 30, dateFormat = "HH:mm") private Date endTime; /** 充放功率 (kW) */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java index 53f086e..f05d001 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTempConfigRequest.java @@ -15,7 +15,7 @@ public class StrategyTempConfigRequest { /** 模板id */ - private Long id; + private String templateId; /** 站点id */ private String siteId; @@ -37,12 +37,12 @@ public class StrategyTempConfigRequest /** 模板时间 */ private List timeConfigList; - public Long getId() { - return id; + public String getTemplateId() { + return templateId; } - public void setId(Long id) { - this.id = id; + public void setTemplateId(String templateId) { + this.templateId = templateId; } public void setStrategyId(Long strategyId) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java index b59e610..24db8da 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempMapper.java @@ -65,6 +65,9 @@ public interface EmsStrategyTempMapper // 获取模板名称和id public List> getTempNameList(@Param("strategyId")Long strategyId, @Param("siteId")String siteId); - // 删除模板 - public int deleteEmsStrategyTempByIds(Long id); + // 根据模板id获取模板所有的时间配置 + public List selectStrategyTempByTempId(String templateId); + + // 根据模板id全部删除 + public int deleteTempByTempId(String templateId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java deleted file mode 100644 index b02f10d..0000000 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTempTimeConfigMapper.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.xzzn.ems.mapper; - -import java.util.List; -import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; - -/** - * 模板配置Mapper接口 - * - * @author xzzn - * @date 2025-07-12 - */ -public interface EmsStrategyTempTimeConfigMapper -{ - /** - * 查询模板配置 - * - * @param id 模板配置主键 - * @return 模板配置 - */ - public EmsStrategyTempTimeConfig selectEmsStrategyTempTimeConfigById(Long id); - - /** - * 查询模板配置列表 - * - * @param emsStrategyTempTimeConfig 模板配置 - * @return 模板配置集合 - */ - public List selectEmsStrategyTempTimeConfigList(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig); - - /** - * 新增模板配置 - * - * @param emsStrategyTempTimeConfig 模板配置 - * @return 结果 - */ - public int insertEmsStrategyTempTimeConfig(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig); - - /** - * 修改模板配置 - * - * @param emsStrategyTempTimeConfig 模板配置 - * @return 结果 - */ - public int updateEmsStrategyTempTimeConfig(EmsStrategyTempTimeConfig emsStrategyTempTimeConfig); - - /** - * 删除模板配置 - * - * @param id 模板配置主键 - * @return 结果 - */ - public int deleteEmsStrategyTempTimeConfigById(Long id); - - /** - * 批量删除模板配置 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteEmsStrategyTempTimeConfigByIds(Long[] ids); - - // 获取模板的时间 - public List getTimeListByTempId(Long templateId); - - // 根据模板id删除时间配置 - public void deleteTimeConfigByTempId(Long templateId); -} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java index b3e9386..35ac3b8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java @@ -5,7 +5,6 @@ import java.util.Map; import com.xzzn.ems.domain.EmsStrategyTemp; import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; -import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo; /** * 模板Service接口 @@ -15,13 +14,6 @@ import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo; */ public interface IEmsStrategyTempService { - - // 获取该模板下的时间配置 - public List selectEmsStrategyTempList(Long id); - - // 新增模板及时间配置 - public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo); - /** * 修改模板 * @@ -30,23 +22,14 @@ public interface IEmsStrategyTempService */ public boolean updateEmsStrategyTemp(StrategyTempConfigRequest requestVo); - /** - * 批量删除模板 - * - * @param ids 需要删除的模板主键集合 - * @return 结果 - */ - public int deleteEmsStrategyTempByIds(Long[] ids); - - /** - * 删除模板信息 - * - * @param id 模板主键 - * @return 结果 - */ - public int deleteEmsStrategyTempById(Long id); - public List> getTempNameList(Long strategyId, String siteId); - public void deleteStrategyTempById(Long id); + // 获取该模板下的时间配置 + public List selectEmsStrategyTempList(String templateId); + + // 新增模板及时间配置 + public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo); + + //根据templateId删除模板 + public int deleteStrategyTempById(String templateId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index c7e5d75..32b08eb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -1,15 +1,13 @@ package com.xzzn.ems.service.impl; -import java.util.ArrayList; import java.util.List; import java.util.Map; import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanUtils; import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; -import com.xzzn.ems.domain.vo.StrategyTempTimeConfigVo; -import com.xzzn.ems.mapper.EmsStrategyTempTimeConfigMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsStrategyTempMapper; @@ -26,10 +24,9 @@ import org.springframework.transaction.annotation.Transactional; @Service public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService { + private static final String PREFIX= "Temp"; @Autowired private EmsStrategyTempMapper emsStrategyTempMapper; - @Autowired - private EmsStrategyTempTimeConfigMapper emsStrategyTempTimeConfigMapper; /** * 查询模板列表 @@ -38,26 +35,42 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService * @return 模板 */ @Override - public List selectEmsStrategyTempList(Long templateId) + public List selectEmsStrategyTempList(String templateId) { - List dataList = new ArrayList<>(); - EmsStrategyTemp temp = emsStrategyTempMapper.selectEmsStrategyTempById(templateId); - if (temp != null) { - List timeList = emsStrategyTempTimeConfigMapper.getTimeListByTempId(templateId); - if (timeList != null && !timeList.isEmpty()) { - for (EmsStrategyTempTimeConfig timeConfig : timeList) { - StrategyTempTimeConfigVo vo = new StrategyTempTimeConfigVo(); - BeanUtils.copyProperties(timeConfig, vo); - BeanUtils.copyProperties(temp, vo); - dataList.add(vo); - } - } else { - StrategyTempTimeConfigVo vo = new StrategyTempTimeConfigVo(); - BeanUtils.copyProperties(temp, vo); - dataList.add(vo); - } + return emsStrategyTempMapper.selectStrategyTempByTempId(templateId); + } + + /** + * 新增模板和时间配置 + * @param requestVo + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo) { + // 随机生产模板id格式:Temp+时间戳 + String templateId = requestVo.getTemplateId(); + if (StringUtils.isEmpty(templateId)) { + templateId = PREFIX + DateUtils.dateTimeNow(); } - return dataList; + + EmsStrategyTemp publicTemp = new EmsStrategyTemp(); + BeanUtils.copyProperties(requestVo, publicTemp); + publicTemp.setTemplateId(templateId); + publicTemp.setCreateTime(DateUtils.getNowDate()); + + List timeList = requestVo.getTimeConfigList(); + if (timeList != null && !timeList.isEmpty()) { + for (EmsStrategyTempTimeConfig timeConfig : timeList) { + EmsStrategyTemp temp = new EmsStrategyTemp(); + BeanUtils.copyProperties(publicTemp, temp); + BeanUtils.copyProperties(timeConfig, temp); + emsStrategyTempMapper.insertEmsStrategyTemp(temp); + } + } else {// 无时间配置只配置模板基本信息 + emsStrategyTempMapper.insertEmsStrategyTemp(publicTemp); + } + return true; } /** @@ -70,88 +83,25 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService @Transactional(rollbackFor = Exception.class) public boolean updateEmsStrategyTemp(StrategyTempConfigRequest requestVo) { - Long id = requestVo.getId(); - // 根据模板id校验该模板是否存在 - EmsStrategyTemp temp = emsStrategyTempMapper.selectEmsStrategyTempById(id); - if (temp == null) { - return false; - } - // 更新模板数据 - BeanUtils.copyProperties(requestVo, temp); - emsStrategyTempMapper.updateEmsStrategyTemp(temp); + String templateId = requestVo.getTemplateId(); + // 无发匹配原数据 + // 全删 + emsStrategyTempMapper.deleteTempByTempId(templateId); - // 先删除再加 - emsStrategyTempTimeConfigMapper.deleteTimeConfigByTempId(id); - - List timeList = requestVo.getTimeConfigList(); - if (timeList != null) { - for (EmsStrategyTempTimeConfig timeConfig : timeList) { - timeConfig.setTemplateId(id); - timeConfig.setCreateTime(DateUtils.getNowDate()); - timeConfig.setUpdateTime(DateUtils.getNowDate()); - emsStrategyTempTimeConfigMapper.insertEmsStrategyTempTimeConfig(timeConfig); - } - } + // 重新新增 + addNewTempAndTimeConfig(requestVo); return true; } - /** - * 批量删除模板 - * - * @param ids 需要删除的模板主键 - * @return 结果 - */ - @Override - public int deleteEmsStrategyTempByIds(Long[] ids) - { - return emsStrategyTempMapper.deleteEmsStrategyTempByIds(ids); - } - - /** - * 删除模板信息 - * - * @param id 模板主键 - * @return 结果 - */ - @Override - public int deleteEmsStrategyTempById(Long id) - { - return emsStrategyTempMapper.deleteEmsStrategyTempById(id); - } - @Override public List> getTempNameList(Long strategyId, String siteId) { return emsStrategyTempMapper.getTempNameList(strategyId, siteId); } - // 新增模板和时间配置 - @Override - @Transactional(rollbackFor = Exception.class) - public boolean addNewTempAndTimeConfig(StrategyTempConfigRequest requestVo) { - EmsStrategyTemp emsStrategyTemp = new EmsStrategyTemp(); - BeanUtils.copyProperties(requestVo, emsStrategyTemp); - emsStrategyTemp.setCreateTime(DateUtils.getNowDate()); - emsStrategyTempMapper.insertEmsStrategyTemp(emsStrategyTemp); - - List timeList = requestVo.getTimeConfigList(); - if (timeList != null) { - for (EmsStrategyTempTimeConfig timeConfig : timeList) { - timeConfig.setCreateTime(DateUtils.getNowDate()); - timeConfig.setTemplateId(emsStrategyTemp.getId()); - emsStrategyTempTimeConfigMapper.insertEmsStrategyTempTimeConfig(timeConfig); - } - } - return true; - } - @Override - public void deleteStrategyTempById(Long id) { - // 先删除时间配置 - emsStrategyTempTimeConfigMapper.deleteTimeConfigByTempId(id); - - // 再删除模板 - emsStrategyTempMapper.deleteEmsStrategyTempById(id); + public int deleteStrategyTempById(String templateId) { + return emsStrategyTempMapper.deleteTempByTempId(templateId); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml index 08b914d..b297a52 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempMapper.xml @@ -11,16 +11,21 @@ + + + + + - select id, strategy_id, template_name, sdc_limit, sdc_down, sdc_up, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_temp + select id, strategy_id, template_name, sdc_limit, sdc_down, sdc_up, start_time, end_time, charge_discharge_power, charge_status, create_by, create_time, update_by, update_time, remark, site_id, template_id from ems_strategy_temp @@ -48,12 +58,17 @@ sdc_limit, sdc_down, sdc_up, + start_time, + end_time, + charge_discharge_power, + charge_status, create_by, create_time, update_by, update_time, remark, site_id, + template_id, #{strategyId}, @@ -61,12 +76,17 @@ #{sdcLimit}, #{sdcDown}, #{sdcUp}, + #{startTime}, + #{endTime}, + #{chargeDischargePower}, + #{chargeStatus}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark}, #{siteId}, + #{templateId}, @@ -78,12 +98,17 @@ sdc_limit = #{sdcLimit}, sdc_down = #{sdcDown}, sdc_up = #{sdcUp}, + start_time = #{startTime}, + end_time = #{endTime}, + charge_discharge_power = #{chargeDischargePower}, + charge_status = #{chargeStatus}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, + template_id = #{templateId}, where id = #{id} @@ -100,7 +125,7 @@ select count(1) from ems_strategy_temp where template_id = #{templateId} + + + + + delete from ems_strategy_temp where template_id = #{templateId} + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml deleted file mode 100644 index c639a86..0000000 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTempTimeConfigMapper.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - select id, start_time, end_time, charge_discharge_power, charge_status, create_by, create_time, update_by, update_time, remark, template_id from ems_strategy_temp_time_config - - - - - - - - insert into ems_strategy_temp_time_config - - start_time, - end_time, - charge_discharge_power, - charge_status, - create_by, - create_time, - update_by, - update_time, - remark, - template_id, - - - #{startTime}, - #{endTime}, - #{chargeDischargePower}, - #{chargeStatus}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - #{remark}, - #{templateId}, - - - - - update ems_strategy_temp_time_config - - start_time = #{startTime}, - end_time = #{endTime}, - charge_discharge_power = #{chargeDischargePower}, - charge_status = #{chargeStatus}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - remark = #{remark}, - template_id = #{templateId}, - - where id = #{id} - - - - delete from ems_strategy_temp_time_config where id = #{id} - - - - delete from ems_strategy_temp_time_config where id in - - #{id} - - - - - - - delete from ems_strategy_temp_time_config where template_id = #{templateId} - - \ No newline at end of file -- 2.49.0 From 819e4cd3a7fa95e114b42bca049c2b6914142e70 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 13 Jul 2025 14:14:07 +0800 Subject: [PATCH 084/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java | 6 +++--- .../java/com/xzzn/ems/domain/vo/StrategyTimeConfigVo.java | 6 +++--- .../resources/mapper/ems/EmsStrategyTimeConfigMapper.xml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java index 5ba82ef..de02b59 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java @@ -36,7 +36,7 @@ public class EmsStrategyTimeConfig extends BaseEntity /** 模版id */ @Excel(name = "模版id") - private Long templateId; + private String templateId; public void setId(Long id) { @@ -88,12 +88,12 @@ public class EmsStrategyTimeConfig extends BaseEntity return siteId; } - public void setTemplateId(Long templateId) + public void setTemplateId(String templateId) { this.templateId = templateId; } - public Long getTemplateId() + public String getTemplateId() { return templateId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTimeConfigVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTimeConfigVo.java index 18862ce..4d7a202 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTimeConfigVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyTimeConfigVo.java @@ -24,7 +24,7 @@ public class StrategyTimeConfigVo private String chargeDischargeMode; /** 模板id */ - private Long templateId; + private String templateId; /** 模板名称 */ private String templateName; @@ -79,12 +79,12 @@ public class StrategyTimeConfigVo return siteId; } - public void setTemplateId(Long templateId) + public void setTemplateId(String templateId) { this.templateId = templateId; } - public Long getTemplateId() + public String getTemplateId() { return templateId; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index e67ef9e..1e526f9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -29,7 +29,7 @@ and month = #{month} and charge_discharge_mode = #{chargeDischargeMode} and site_id = #{siteId} - and template_id = #{templateId} + and template_id = #{templateId} -- 2.49.0 From a0b83fc8a48a91adba4419e6cab4370e1cef540c Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 13 Jul 2025 15:02:00 +0800 Subject: [PATCH 085/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=85=8D=E7=BD=AE=E5=AD=97=E6=AE=B5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java | 3 +++ .../xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java | 5 +++++ .../resources/mapper/ems/EmsStrategyTimeConfigMapper.xml | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java index 0754ce5..0dc81b6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java @@ -62,4 +62,7 @@ public interface EmsStrategyTimeConfigMapper // 获取该策略下的时间配置 public List getStrategyTimeList(EmsStrategyTimeConfig emsStrategyTimeConfig); + + // 删除模板时间配置 + public void deleteTimeConfigByTemplateId(String templateId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index 32b08eb..1674340 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -8,6 +8,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanUtils; import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; +import com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsStrategyTempMapper; @@ -27,6 +28,8 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService private static final String PREFIX= "Temp"; @Autowired private EmsStrategyTempMapper emsStrategyTempMapper; + @Autowired + private EmsStrategyTimeConfigMapper emsStrategyTimeConfigMapper; /** * 查询模板列表 @@ -102,6 +105,8 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService @Override public int deleteStrategyTempById(String templateId) { + // 先删除模板的时间配置 + emsStrategyTimeConfigMapper.deleteTimeConfigByTemplateId(templateId); return emsStrategyTempMapper.deleteTempByTempId(templateId); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index 1e526f9..397ae7a 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -101,10 +101,13 @@ t.template_id as templateId, temp.template_name as templateName from ems_strategy_time_config t - LEFT JOIN ems_strategy_temp temp on t.template_id = temp.id + LEFT JOIN ems_strategy_temp temp on t.template_id = temp.template_id where t.site_id = #{siteId} and t.strategy_id = #{strategyId} order by month + + delete from ems_strategy_time_config where template_id = #{templateId} + \ No newline at end of file -- 2.49.0 From 9fcc81fbac58038312b091086d0799cf8562791d Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 13 Jul 2025 15:27:38 +0800 Subject: [PATCH 086/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=85=8D=E7=BD=AE=E5=AD=97=E6=AE=B5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java | 6 +++--- .../resources/mapper/ems/EmsStrategyTimeConfigMapper.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java index 9bb2f52..1cf9f9f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTempTimeConfig.java @@ -41,7 +41,7 @@ public class EmsStrategyTempTimeConfig extends BaseEntity /** 模板id */ @Excel(name = "模板id") - private Long templateId; + private String templateId; public void setId(Long id) { @@ -93,12 +93,12 @@ public class EmsStrategyTempTimeConfig extends BaseEntity return chargeStatus; } - public void setTemplateId(Long templateId) + public void setTemplateId(String templateId) { this.templateId = templateId; } - public Long getTemplateId() + public String getTemplateId() { return templateId; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index 397ae7a..dd01db4 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -95,7 +95,7 @@ - - delete from ems_strategy_time_config where template_id = #{templateId} - + + update ems_strategy_time_config set template_id = '' where template_id = #{templateId} + \ No newline at end of file -- 2.49.0 From cceafdca921c40f332cf18aca7c9a221c5785260 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 14 Jul 2025 10:53:36 +0800 Subject: [PATCH 089/336] =?UTF-8?q?log=E7=BA=A7=E5=88=AB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ems-admin/src/main/resources/application.yml b/ems-admin/src/main/resources/application.yml index 70ad9a7..7b1963f 100644 --- a/ems-admin/src/main/resources/application.yml +++ b/ems-admin/src/main/resources/application.yml @@ -34,7 +34,7 @@ server: # 日志配置 logging: level: - com.xzzn: debug + com.xzzn: info org.springframework: warn # 用户配置 @@ -135,4 +135,4 @@ mqtt: password: qwer1234 connection-timeout: 15 keep-alive-interval: 30 - automatic-reconnect: true \ No newline at end of file + automatic-reconnect: true -- 2.49.0 From bf1d70c9539362f8df83e60edb757e6e96ef3a21 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Mon, 14 Jul 2025 16:16:14 +0800 Subject: [PATCH 090/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20mqtt=20=E6=BA=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 21 +++---------------- .../ems/service/IEmsMqttMessageService.java | 9 ++++++++ .../impl/EmsMqttMessageServiceImpl.java | 13 ++++++++++++ 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 437a6c0..734a155 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -61,15 +61,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[SYSTEM] Status update: " + payload); try { - // 业务处理逻辑 - EmsMqttMessage mqttMessage = new EmsMqttMessage(); - mqttMessage.setMqttTopic(topic); - mqttMessage.setMqttMessage(payload); - mqttMessage.setCreateTime(new java.util.Date()); - mqttMessage.setUpdateTime(new java.util.Date()); - mqttMessage.setCreateBy("system"); - mqttMessage.setUpdateBy("system"); - emsMqttMessageService.insertEmsMqttMessage(mqttMessage); + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + } catch (Exception e) { log.error("Failed to process system status message: " + e.getMessage(), e); } @@ -87,15 +80,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { fXXDataProcessService.handleFxData(payload); } - - EmsMqttMessage mqttMessage = new EmsMqttMessage(); - mqttMessage.setMqttTopic(topic); - mqttMessage.setMqttMessage(payload); - mqttMessage.setCreateTime(new java.util.Date()); - mqttMessage.setUpdateTime(new java.util.Date()); - mqttMessage.setCreateBy("system"); - mqttMessage.setUpdateBy("system"); - emsMqttMessageService.insertEmsMqttMessage(mqttMessage); + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); } catch (Exception e) { log.error("Failed to process system status message: " + e.getMessage(), e); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java index c7355cb..5979855 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttMessageService.java @@ -59,4 +59,13 @@ public interface IEmsMqttMessageService * @return 结果 */ public int deleteEmsMqttMessageById(Long id); + + /** + * 新增【请填写功能名称】 + * + * @param topic 【请填写功能名称】 + * @param message 【请填写功能名称】 + * @return 结果 + */ + public int insertMqttOriginalMessage(String topic, String message); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java index 8c6e158..10ae7c7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java @@ -93,4 +93,17 @@ public class EmsMqttMessageServiceImpl implements IEmsMqttMessageService { return emsMqttMessageMapper.deleteEmsMqttMessageById(id); } + + @Override + public int insertMqttOriginalMessage(String topic, String message) { + EmsMqttMessage mqttMessage = new EmsMqttMessage(); + mqttMessage.setMqttTopic(topic); + mqttMessage.setMqttMessage(message); + mqttMessage.setCreateTime(new java.util.Date()); + mqttMessage.setUpdateTime(new java.util.Date()); + mqttMessage.setCreateBy("system"); + mqttMessage.setUpdateBy("system"); + mqttMessage.setUpdateTime(DateUtils.getNowDate()); + return emsMqttMessageMapper.updateEmsMqttMessage(mqttMessage); + } } -- 2.49.0 From e6d6f806e477d0f121dfde66c714f3d36f92fe63 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 15 Jul 2025 12:57:00 +0800 Subject: [PATCH 091/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E6=9B=B2=E7=BA=BF=E5=9B=BE=E6=A8=A1=E5=9E=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStrategyCurveController.java | 13 ++++- .../com/xzzn/ems/domain/EmsStrategyCurve.java | 13 +++++ .../xzzn/ems/domain/vo/StrategyCurveVo.java | 47 +++++++++++++++++++ .../ems/mapper/EmsStrategyCurveMapper.java | 7 +++ .../ems/service/IEmsStrategyCurveService.java | 5 ++ .../impl/EmsStrategyCurveServiceImpl.java | 35 ++++++++++++++ .../service/impl/SingleSiteServiceImpl.java | 6 ++- .../mapper/ems/EmsStrategyCurveMapper.xml | 13 ++++- 8 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java index f66bcc1..6761295 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStrategyCurveController.java @@ -2,6 +2,9 @@ package com.xzzn.web.controller.ems; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -19,7 +22,6 @@ import com.xzzn.common.enums.BusinessType; import com.xzzn.ems.domain.EmsStrategyCurve; import com.xzzn.ems.service.IEmsStrategyCurveService; import com.xzzn.common.utils.poi.ExcelUtil; -import com.xzzn.common.core.page.TableDataInfo; /** * 策曲线Controller @@ -99,4 +101,13 @@ public class EmsStrategyCurveController extends BaseController { return toAjax(emsStrategyCurveService.deleteEmsStrategyCurveByIds(ids)); } + + /** + * 获取策略曲线图数据 + */ + @GetMapping("/curveList") + public AjaxResult getCurveList(EmsStrategyTemp tempConfig) + { + return success(emsStrategyCurveService.getStrategyCurveList(tempConfig)); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java index dff611c..8c3bc3a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java @@ -46,6 +46,10 @@ public class EmsStrategyCurve extends BaseEntity @Excel(name = "站点id") private String siteId; + /** 模板id */ + @Excel(name = "模板id") + private String templateId; + public void setId(Long id) { this.id = id; @@ -116,6 +120,14 @@ public class EmsStrategyCurve extends BaseEntity return siteId; } + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -131,6 +143,7 @@ public class EmsStrategyCurve extends BaseEntity .append("updateTime", getUpdateTime()) .append("remark", getRemark()) .append("siteId", getSiteId()) + .append("templateId", getTemplateId()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java new file mode 100644 index 0000000..4108c50 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java @@ -0,0 +1,47 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.ems.domain.EmsStrategyCurve; + +import java.util.List; + +/** + *策略模块曲线图 + * + * @author xzzn + * @date 2025-07-13 + */ +public class StrategyCurveVo +{ + + /** 模板名称 */ + private String templateName; + + /** 模板id */ + private String templateId; + + List cureList; + + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + public List getCureList() { + return cureList; + } + + public void setCureList(List cureList) { + this.cureList = cureList; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java index 9776cd1..9157524 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java @@ -58,4 +58,11 @@ public interface EmsStrategyCurveMapper * @return 结果 */ public int deleteEmsStrategyCurveByIds(Long[] ids); + + /** + * 根据模板id获取曲线图数据 + * @param templateId + * @return + */ + public List getTemplateCurve(String templateId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java index 74e883a..d5510bb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyCurveService.java @@ -2,6 +2,8 @@ package com.xzzn.ems.service; import java.util.List; import com.xzzn.ems.domain.EmsStrategyCurve; +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.domain.vo.StrategyCurveVo; /** * 策曲线Service接口 @@ -58,4 +60,7 @@ public interface IEmsStrategyCurveService * @return 结果 */ public int deleteEmsStrategyCurveById(Long id); + + // 获取站点策略的运行曲线数据 + public List getStrategyCurveList(EmsStrategyTemp tempConfig); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java index 62a0bb2..bb5088e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java @@ -1,7 +1,14 @@ package com.xzzn.ems.service.impl; +import java.util.ArrayList; import java.util.List; +import java.util.Map; + import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.domain.vo.StrategyCurveVo; +import com.xzzn.ems.mapper.EmsStrategyTempMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsStrategyCurveMapper; @@ -19,6 +26,8 @@ public class EmsStrategyCurveServiceImpl implements IEmsStrategyCurveService { @Autowired private EmsStrategyCurveMapper emsStrategyCurveMapper; + @Autowired + private EmsStrategyTempMapper emsStrategyTempMapper; /** * 查询策曲线 @@ -93,4 +102,30 @@ public class EmsStrategyCurveServiceImpl implements IEmsStrategyCurveService { return emsStrategyCurveMapper.deleteEmsStrategyCurveById(id); } + + @Override + public List getStrategyCurveList(EmsStrategyTemp tempConfig) { + List dataList = new ArrayList(); + String siteId = tempConfig.getSiteId(); + Long strategyId = tempConfig.getStrategyId(); + // 获取该策略的所有模板配置 + List> tempList = emsStrategyTempMapper.getTempNameList(strategyId, siteId); + + if (tempList != null && !tempList.isEmpty()) { + for (Map map : tempList) { + StrategyCurveVo vo = new StrategyCurveVo(); + String tempName = map.get("templateName"); + String tempId = map.get("templateId"); + vo.setTemplateName(tempName); + vo.setTemplateId(tempId); + + if (StringUtils.isNotEmpty(tempId)) { + List taskList = emsStrategyCurveMapper.getTemplateCurve(tempId); + vo.setCureList(taskList); + } + dataList.add(vo); + } + } + return dataList; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index a67127e..f7aa66e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -197,7 +197,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { for (Map pcsDevice : pcsIds) { PcsDetailInfoVo pcsDetailInfoVo = new PcsDetailInfoVo(); pcsDetailInfoVo.setDeviceName(pcsDevice.get("deviceName").toString()); - pcsDetailInfoVo.setCommunicationStatus(pcsDevice.get("communicationStatus").toString()); + pcsDetailInfoVo.setCommunicationStatus(pcsDevice.get("communicationStatus") == null ? + "" :pcsDevice.get("communicationStatus").toString()); // 从redis取pcs单个详细数据 String pcsId = pcsDevice.get("id").toString(); EmsPcsData pcsData = redisCache.getCacheObject(RedisKeyConstants.PCS +siteId+"_"+pcsId); @@ -395,7 +396,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (AMMETER_DEVICE_LOAD.equals(ammeterId)) { AmmeterLoadDataVo ammeterLoadDataVo = new AmmeterLoadDataVo(); ammeterLoadDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); - ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus").toString()); + ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : + ammeterDevice.get("communicationStatus").toString()); // 处理总表数据 dealAmmeterLoadData(ammeterData,ammeterLoadDataVo); ammeterResponse.setAmmeterLoadDataVoList(ammeterLoadDataVo); diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml index 21666b5..1939ca5 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml @@ -17,10 +17,11 @@ + - select id, strategy_id, task_number, start_date, end_date, power_data, create_by, create_time, update_by, update_time, remark, site_id from ems_strategy_curve + select id, strategy_id, task_number, start_date, end_date, power_data, create_by, create_time, update_by, update_time, remark, site_id, template_id from ems_strategy_curve @@ -54,6 +56,7 @@ update_time, remark, site_id, + template_id, #{strategyId}, @@ -67,6 +70,7 @@ #{updateTime}, #{remark}, #{siteId}, + #{templateId}, @@ -84,6 +88,7 @@ update_time = #{updateTime}, remark = #{remark}, site_id = #{siteId}, + template_id = #{templateId}, where id = #{id} @@ -98,4 +103,10 @@ #{id} + + \ No newline at end of file -- 2.49.0 From 1e970c9d19a1eb0d243a9a274867d29647a23a1c Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 15 Jul 2025 13:37:58 +0800 Subject: [PATCH 092/336] =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0-?= =?UTF-8?q?=E6=8C=89deviceId=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/SingleSiteServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index f7aa66e..c04af21 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -17,6 +17,7 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * 单点监控 服务层实现 @@ -372,7 +373,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } } } - return batteryDataStatsListVo; + // 排序 + List sortedList = batteryDataStatsListVo.stream() + .sorted((u1, u2) -> Integer.parseInt(u1.getDeviceId()) - Integer.parseInt(u2.getDeviceId())) + .collect(Collectors.toList()); + return sortedList; } /** -- 2.49.0 From af32d62c808f9526c6225ba78b5f46300e83ae76 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 15 Jul 2025 15:34:13 +0800 Subject: [PATCH 093/336] =?UTF-8?q?Mqtt=E6=95=B0=E6=8D=AE=E6=8F=92?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java index 10ae7c7..83f0b46 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttMessageServiceImpl.java @@ -104,6 +104,6 @@ public class EmsMqttMessageServiceImpl implements IEmsMqttMessageService mqttMessage.setCreateBy("system"); mqttMessage.setUpdateBy("system"); mqttMessage.setUpdateTime(DateUtils.getNowDate()); - return emsMqttMessageMapper.updateEmsMqttMessage(mqttMessage); + return emsMqttMessageMapper.insertEmsMqttMessage(mqttMessage); } } -- 2.49.0 From 161c54b6efe9ac8e86c7d75726bd6ae4908e17a2 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 15 Jul 2025 17:59:57 +0800 Subject: [PATCH 094/336] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/domain/EmsTicket.java | 98 +++++++++++-------- .../resources/mapper/ems/EmsTicketMapper.xml | 22 +++-- 2 files changed, 72 insertions(+), 48 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java index ea401d1..fd5a8b2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsTicket.java @@ -9,15 +9,15 @@ import com.xzzn.common.annotation.Excel; /** * 工单主对象 ems_ticket - * + * * @author xzzn - * @date 2025-06-26 + * @date 2025-07-15 */ public class EmsTicket extends BaseEntity { private static final long serialVersionUID = 1L; - /** $column.columnComment */ + /** */ private String id; /** 工单号(规则:T+日期+6位随机) */ @@ -44,9 +44,14 @@ public class EmsTicket extends BaseEntity @Excel(name = "1待处理 2处理中 3已完成") private Long status; + /** 期望完成时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "期望完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date expectedCompleteTime; + /** 完成时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date completeTime; /** 处理人ID */ @@ -57,22 +62,22 @@ public class EmsTicket extends BaseEntity @Excel(name = "0-已废弃 1-有效") private Long isDelete; - public void setId(String id) + public void setId(String id) { this.id = id; } - public String getId() + public String getId() { return id; } - public void setTicketNo(String ticketNo) + public void setTicketNo(String ticketNo) { this.ticketNo = ticketNo; } - public String getTicketNo() + public String getTicketNo() { return ticketNo; } @@ -87,91 +92,104 @@ public class EmsTicket extends BaseEntity return userId; } - public void setTitle(String title) + public void setTitle(String title) { this.title = title; } - public String getTitle() + public String getTitle() { return title; } - public void setContent(String content) + public void setContent(String content) { this.content = content; } - public String getContent() + public String getContent() { return content; } - public void setImages(String images) + public void setImages(String images) { this.images = images; } - public String getImages() + public String getImages() { return images; } - public void setStatus(Long status) + public void setStatus(Long status) { this.status = status; } - public Long getStatus() + public Long getStatus() { return status; } - public void setCompleteTime(Date completeTime) + public void setExpectedCompleteTime(Date expectedCompleteTime) + { + this.expectedCompleteTime = expectedCompleteTime; + } + + public Date getExpectedCompleteTime() + { + return expectedCompleteTime; + } + + public void setCompleteTime(Date completeTime) { this.completeTime = completeTime; } - public Date getCompleteTime() + public Date getCompleteTime() { return completeTime; } - public void setWorkUserId(Long workUserId) + public void setWorkUserId(Long workUserId) { this.workUserId = workUserId; } - public Long getWorkUserId() + public Long getWorkUserId() { return workUserId; } - public Long getIsDelete() { - return isDelete; + public void setIsDelete(Long isDelete) + { + this.isDelete = isDelete; } - public void setIsDelete(Long isDelete) { - this.isDelete = isDelete; + public Long getIsDelete() + { + return isDelete; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("ticketNo", getTicketNo()) - .append("userId", getUserId()) - .append("title", getTitle()) - .append("content", getContent()) - .append("images", getImages()) - .append("status", getStatus()) - .append("createTime", getCreateTime()) - .append("completeTime", getCompleteTime()) - .append("createBy", getCreateBy()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("workUserId", getWorkUserId()) - .append("isDelete", getIsDelete()) - .toString(); + .append("id", getId()) + .append("ticketNo", getTicketNo()) + .append("userId", getUserId()) + .append("title", getTitle()) + .append("content", getContent()) + .append("images", getImages()) + .append("status", getStatus()) + .append("expectedCompleteTime", getExpectedCompleteTime()) + .append("completeTime", getCompleteTime()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("workUserId", getWorkUserId()) + .append("isDelete", getIsDelete()) + .toString(); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml index eb0041e..f2862f0 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml @@ -12,8 +12,9 @@ - + + @@ -22,28 +23,28 @@ - select id, ticket_no, user_id, title, content, images, status, create_time, complete_time, create_by, update_by, update_time, work_user_id, isDelete from ems_ticket + select id, ticket_no, user_id, title, content, images, status, expected_complete_time, complete_time, create_time, create_by, update_by, update_time, work_user_id, isDelete from ems_ticket @@ -55,8 +56,9 @@ content, images, status, - create_time, + expected_complete_time, complete_time, + create_time, create_by, update_by, update_time, @@ -70,8 +72,9 @@ #{content}, #{images}, #{status}, - #{createTime}, + #{expectedCompleteTime}, #{completeTime}, + #{createTime}, #{createBy}, #{updateBy}, #{updateTime}, @@ -89,8 +92,9 @@ content = #{content}, images = #{images}, status = #{status}, - create_time = #{createTime}, + expected_complete_time = #{expectedCompleteTime}, complete_time = #{completeTime}, + create_time = #{createTime}, create_by = #{createBy}, update_by = #{updateBy}, update_time = #{updateTime}, @@ -123,7 +127,9 @@ s.user_name as userName, s1.user_name as workName, t.create_time as createTime, - t.id + t.id, + t.images, + t.expected_complete_time as expectedCompleteTime FROM ems_ticket t LEFT JOIN sys_user s on t.user_id = s.user_id LEFT JOIN sys_user s1 on t.work_user_id = s1.user_id -- 2.49.0 From 587e9f86b1ec34f0c67f86ab7e8ddb590d25e312 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 15 Jul 2025 19:31:07 +0800 Subject: [PATCH 095/336] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E8=AF=A6=E6=83=85=E6=96=B0=E5=A2=9E=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/mapper/EmsTicketMapper.java | 7 +++++++ .../xzzn/ems/service/IEmsTicketService.java | 2 +- .../service/impl/EmsTicketServiceImpl.java | 4 ++-- .../resources/mapper/ems/EmsTicketMapper.xml | 21 ++++++++++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java index 7dcf5a9..60c983a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java @@ -74,4 +74,11 @@ public interface EmsTicketMapper * @return */ public List getAllTicketList(EmsTicket emsTicket); + + /** + * 工单详情 + * @param id + * @return + */ + public TicketListVo getTicketDetailInfo(String id); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java index 6eac8e2..e8c54f0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java @@ -19,7 +19,7 @@ public interface IEmsTicketService * @param id 工单主主键 * @return 工单主 */ - public EmsTicket selectEmsTicketById(String id); + public TicketListVo selectEmsTicketById(String id); /** * 查询工单主列表 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java index a63f057..35721d1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java @@ -31,9 +31,9 @@ public class EmsTicketServiceImpl implements IEmsTicketService * @return 工单主 */ @Override - public EmsTicket selectEmsTicketById(String id) + public TicketListVo selectEmsTicketById(String id) { - return emsTicketMapper.selectEmsTicketById(id); + return emsTicketMapper.getTicketDetailInfo(id); } /** diff --git a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml index f2862f0..665b414 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml @@ -134,5 +134,24 @@ LEFT JOIN sys_user s on t.user_id = s.user_id LEFT JOIN sys_user s1 on t.work_user_id = s1.user_id where isDelete = 1 - + + + \ No newline at end of file -- 2.49.0 From e2663b18d5c3b6eb11666a174d7fe6f6f23120df Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 16 Jul 2025 16:18:35 +0800 Subject: [PATCH 096/336] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E5=88=97=E8=A1=A8=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/web/controller/ems/EmsTicketController.java | 4 ++-- .../java/com/xzzn/ems/mapper/EmsTicketMapper.java | 5 +++-- .../java/com/xzzn/ems/service/IEmsTicketService.java | 6 +++--- .../xzzn/ems/service/impl/EmsTicketServiceImpl.java | 12 +++++++++--- .../main/resources/mapper/ems/EmsTicketMapper.xml | 6 ++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java index f1c26d9..d7e1e29 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsTicketController.java @@ -41,10 +41,10 @@ public class EmsTicketController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:ticket:list')") @GetMapping("/list") - public TableDataInfo list(EmsTicket emsTicket) + public TableDataInfo list(Long[] status) { startPage(); - List list = emsTicketService.getAllTicketList(emsTicket); + List list = emsTicketService.getAllTicketList(status); return getDataTable(list); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java index 60c983a..eb26916 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsTicketMapper.java @@ -2,6 +2,7 @@ package com.xzzn.ems.mapper; import com.xzzn.ems.domain.EmsTicket; import com.xzzn.ems.domain.vo.TicketListVo; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -70,10 +71,10 @@ public interface EmsTicketMapper /** * 获取工单列表 - * @param emsTicket + * @param statusList * @return */ - public List getAllTicketList(EmsTicket emsTicket); + public List getAllTicketList(@Param("statusList")Long[] statusList); /** * 工单详情 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java index e8c54f0..e32bec4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsTicketService.java @@ -69,10 +69,10 @@ public interface IEmsTicketService public int dropEmsTicketById(String id); /** - * 获取工单列表 + * 获取工单列表 - 根据工单状态获取 * - * @param emsTicket 工单主 + * @param statusList 工单主 * @return 工单主集合 */ - public List getAllTicketList(EmsTicket emsTicket); + public List getAllTicketList(Long[] statusList); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java index 35721d1..588cc1a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java @@ -25,7 +25,7 @@ public class EmsTicketServiceImpl implements IEmsTicketService private EmsTicketMapper emsTicketMapper; /** - * 查询工单主 + * 查询工单主-工单详情 * * @param id 工单主主键 * @return 工单主 @@ -62,6 +62,7 @@ public class EmsTicketServiceImpl implements IEmsTicketService String nowDate = DateUtils.dateTime(); ticketNo = "T" + nowDate + String.format("%06d", new Random().nextInt(1000000)); emsTicket.setTicketNo(ticketNo); + emsTicket.setStatus(1L);//默认待处理 emsTicket.setCreateTime(DateUtils.getNowDate()); return emsTicketMapper.insertEmsTicket(emsTicket); } @@ -115,8 +116,13 @@ public class EmsTicketServiceImpl implements IEmsTicketService return emsTicketMapper.dropEmsTicketById(id); } + /** + * 根据工单状态数组获取-工单列表 + * @param statusList + * @return + */ @Override - public List getAllTicketList(EmsTicket emsTicket) { - return emsTicketMapper.getAllTicketList(emsTicket); + public List getAllTicketList(Long[] statusList) { + return emsTicketMapper.getAllTicketList(statusList); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml index 665b414..fe7ef31 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsTicketMapper.xml @@ -134,6 +134,12 @@ LEFT JOIN sys_user s on t.user_id = s.user_id LEFT JOIN sys_user s1 on t.work_user_id = s1.user_id where isDelete = 1 + + AND t.status IN + + #{status} + + - INSERT INTO ems_battery_data ( battery_pack, battery_cluster, battery_cell_id, @@ -214,4 +213,25 @@ ) + + \ No newline at end of file -- 2.49.0 From 9125ce735cc4138f13637b39a6eb4ca1c29b0d7e Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 17 Jul 2025 15:58:08 +0800 Subject: [PATCH 099/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8B=E5=8F=91=E5=A4=A7=E6=A6=82=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/framework/config/AsyncConfig.java | 16 ++ .../framework/scheduler/StrategyPoller.java | 161 ++++++++++++++++++ .../mapper/EmsStrategyTimeConfigMapper.java | 3 + .../mapper/ems/EmsStrategyRunningMapper.xml | 6 +- .../ems/EmsStrategyTimeConfigMapper.xml | 5 + 5 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java diff --git a/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java b/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java index d80ce10..d6bead0 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java +++ b/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java @@ -24,4 +24,20 @@ public class AsyncConfig { executor.initialize(); return executor; } + + /** + * 策略下方定时任务 + */ + /*@Bean("strategyTaskExecutor") + public Executor strategyTaskExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(5); + executor.setMaxPoolSize(10); + executor.setQueueCapacity(100); + executor.setKeepAliveSeconds(300); + executor.setThreadNamePrefix("StrategyPoller-"); + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.initialize(); + return executor; + }*/ } diff --git a/ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java b/ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java new file mode 100644 index 0000000..a8b19d1 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java @@ -0,0 +1,161 @@ +package com.xzzn.framework.scheduler; + +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsStrategyCurve; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; +import com.xzzn.ems.domain.vo.StrategyRunningVo; +import com.xzzn.ems.mapper.*; +import com.xzzn.framework.manager.ModbusConnectionManager; +import com.xzzn.framework.manager.MqttLifecycleManager; +import com.xzzn.framework.web.service.ModbusService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.time.LocalDate; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +@Component +@EnableScheduling +public class StrategyPoller { + private static final Logger logger = LoggerFactory.getLogger(StrategyPoller.class); + + private final MqttLifecycleManager mqttLifecycleManager; + + @Autowired + private ModbusConnectionManager connectionManager; + @Autowired + private ModbusService modbusService; + @Autowired + private EmsDevicesSettingMapper deviceRepo; + @Autowired + private EmsMqttMessageMapper emsMqttMessageMapper; + @Autowired + private EmsStrategyRunningMapper emsStrategyRunningMapper; + @Autowired + private EmsStrategyTempMapper emsStrategyTempMapper; + @Autowired + private EmsStrategyTimeConfigMapper emsStrategyTimeConfigMapper; + @Autowired + private EmsStrategyCurveMapper emsStrategyCurveMapper; + + @Autowired + public StrategyPoller(MqttLifecycleManager mqttLifecycleManager) { + this.mqttLifecycleManager = mqttLifecycleManager; + } + // 每1分钟触发(支持cron表达式动态配置) + //@Scheduled(cron = "0 */5 * * * *") + //@Async("strategyTaskExecutor") + public void pollAllDevices() { + logger.info("开始执行策略数据轮询..."); + List strategyRunningVoList = emsStrategyRunningMapper.getRunningList(null); + strategyRunningVoList.forEach(strategyVo -> { + try { + CompletableFuture.runAsync(() -> { + processData(strategyVo); + }) + .exceptionally(e -> { + logger.error("策略{}轮询异常", strategyVo.getId(), e); + return null; + }); + } catch (Exception e) { + logger.error("策略下方{}任务失败", strategyVo.getId(), e); + } + }); + /* + try { + pollSingleDevice(device); + } catch (Exception e) { + logger.error("调度设备{}任务失败", device.getId(), e); + }*/ + /*activeDevices.forEach(device -> { + try { + CompletableFuture.runAsync(() -> processData(device)) + .exceptionally(e -> { + logger.error("设备{}轮询异常", device.getId(), e); + return null; + }); + } catch (Exception e) { + logger.error("调度设备{}任务失败", device.getId(), e); + } + });*/ + } + // 处理获取到的数据,发到mqtt服务上 + private void processData(StrategyRunningVo strategyVo) { + logger.info("策略下发数据处理开始"); + // 根据运行策略获取主副策略的模板数据 + Long minStrategyId = strategyVo.getMainStrategyId(); + Long auxStrategyId = strategyVo.getAuxStrategyId(); + String siteId = strategyVo.getSiteId(); + // 处理主策略数据 + if (minStrategyId != null && StringUtils.isNotBlank(siteId)) { + // 获取当前策略的所有模板 + List> temps = emsStrategyTempMapper.getTempNameList(minStrategyId,siteId); + if (temps != null && temps.size() > 0) { + for (Map temp : temps) { + String tempId = temp.get("templateId"); + List timeConfigs = emsStrategyTimeConfigMapper.getAllTimeConfigByTempId(tempId); + if (timeConfigs != null && timeConfigs.size() > 0) { + for (EmsStrategyTimeConfig timeConfig : timeConfigs) { + EmsStrategyCurve curve = new EmsStrategyCurve(); + curve.setStrategyId(minStrategyId); + curve.setSiteId(strategyVo.getSiteId()); + curve.setTemplateId(tempId); + curve.setCreateBy("system"); + curve.setCreateTime(DateUtils.getNowDate()); + curve.setUpdateBy("system"); + curve.setUpdateTime(DateUtils.getNowDate()); + // 时间设置 + String[] dateList= dealWithMonth(Integer.parseInt(timeConfig.getMonth().toString())); + curve.setStartDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,dateList[0])); + curve.setEndDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,dateList[1])); + // powerData暂时不处理 + + // 策略数据下发-下方格式暂无 + + // 记录推送记录 + emsStrategyCurveMapper.insertEmsStrategyCurve(curve); + } + } + } + } + } + // 处理副策略数据 + if (auxStrategyId != null && StringUtils.isNotBlank(siteId)) { + + } + logger.info("策略下发结束"); + } + + private String[] dealWithMonth(int month) { + // 获取当前年份 + int currentYear = LocalDate.now().getYear(); + + // 创建YearMonth对象表示当年指定的月份 + YearMonth yearMonth = YearMonth.of(currentYear, month); + + // 获取当月的第一天和最后一天 + LocalDate firstDay = yearMonth.atDay(1); + LocalDate lastDay = yearMonth.atEndOfMonth(); + + // 定义日期格式(年月日) + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + // 格式化日期 + return new String[]{ + firstDay.format(formatter), + lastDay.format(formatter) + }; + + } + +} \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java index 8b0d4d4..174b2ae 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java @@ -65,4 +65,7 @@ public interface EmsStrategyTimeConfigMapper // 清空该月的模板信息 public void cleanTemplateId(String templateId); + + // 获取该策略下的时间配置 + List getAllTimeConfigByTempId(String templateId); } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml index 030e983..23c859b 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml @@ -97,8 +97,10 @@ 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 + where t.`status` != 4 + + and t.site_id = #{siteId} + diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index 08707c1..701e00f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -110,4 +110,9 @@ update ems_strategy_time_config set template_id = '' where template_id = #{templateId} + + \ No newline at end of file -- 2.49.0 From 41af74b33ab809b6a18e6e63f01b38ff419871d6 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 17 Jul 2025 17:12:44 +0800 Subject: [PATCH 100/336] =?UTF-8?q?jar=E5=8C=85=E6=9B=BF=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-framework/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ems-framework/pom.xml b/ems-framework/pom.xml index 62d4c64..044a5d4 100644 --- a/ems-framework/pom.xml +++ b/ems-framework/pom.xml @@ -62,7 +62,7 @@ io.github.resilience4j - resilience4j-circuitbreaker + resilience4j-annotations diff --git a/pom.xml b/pom.xml index 68a3378..ad983de 100644 --- a/pom.xml +++ b/pom.xml @@ -174,7 +174,7 @@ io.github.resilience4j - resilience4j-circuitbreaker + resilience4j-annotations 1.7.1 -- 2.49.0 From 34c2647495f82de09b34dce303851bdbddeaa655 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 18 Jul 2025 01:38:30 +0800 Subject: [PATCH 101/336] =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0?= =?UTF-8?q?=E6=AF=8F=E6=97=A5=E6=9C=80=E6=96=B0=E6=95=B0=E6=8D=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/EmsBatteryDataDailyLatest.java | 213 ++++++++++++++++++ .../mapper/EmsBatteryDailyLatestMapper.java | 68 ++++++ .../xzzn/ems/mapper/EmsBatteryDataMapper.java | 6 - .../IEmsBatteryDailyLatestService.java | 67 ++++++ .../EmsBatteryDailyLatestServiceImpl.java | 105 +++++++++ .../impl/EmsStatsReportServiceImpl.java | 16 +- .../impl/FXXDataProcessServiceImpl.java | 19 ++ .../ems/EmsBatteryDataDailyLatestMapper.xml | 179 +++++++++++++++ .../mapper/ems/EmsBatteryDataMapper.xml | 20 -- .../resources/mapper/ems/EmsPcsDataMapper.xml | 2 +- 10 files changed, 658 insertions(+), 37 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDailyLatest.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDailyLatestMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDailyLatestService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDailyLatestServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsBatteryDataDailyLatestMapper.xml diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDailyLatest.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDailyLatest.java new file mode 100644 index 0000000..fad9485 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDailyLatest.java @@ -0,0 +1,213 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_battery_data_daily_latest + * + * @author xzzn + * @date 2025-07-17 + */ +public class EmsBatteryDataDailyLatest extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 电池堆 */ + @Excel(name = "电池堆") + private String batteryPack; + + /** 电池簇 */ + @Excel(name = "电池簇") + private String batteryCluster; + + /** 单体编号 */ + @Excel(name = "单体编号") + private String batteryCellId; + + /** 电压 (V) */ + @Excel(name = "电压 (V)") + private BigDecimal voltage; + + /** 温度 (℃) */ + @Excel(name = "温度 (℃)") + private BigDecimal temperature; + + /** SOC (%) */ + @Excel(name = "SOC (%)") + private BigDecimal soc; + + /** SOH (%) */ + @Excel(name = "SOH (%)") + private BigDecimal soh; + + /** 日期:yyyy-MM-dd */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "日期:yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd") + private Date dateDay; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date dataTimestamp; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 簇设备id */ + @Excel(name = "簇设备id") + private String clusterDeviceId; + + public void setBatteryPack(String batteryPack) + { + this.batteryPack = batteryPack; + } + + public String getBatteryPack() + { + return batteryPack; + } + + public void setBatteryCluster(String batteryCluster) + { + this.batteryCluster = batteryCluster; + } + + public String getBatteryCluster() + { + return batteryCluster; + } + + public void setBatteryCellId(String batteryCellId) + { + this.batteryCellId = batteryCellId; + } + + public String getBatteryCellId() + { + return batteryCellId; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setTemperature(BigDecimal temperature) + { + this.temperature = temperature; + } + + public BigDecimal getTemperature() + { + return temperature; + } + + public void setSoc(BigDecimal soc) + { + this.soc = soc; + } + + public BigDecimal getSoc() + { + return soc; + } + + public void setSoh(BigDecimal soh) + { + this.soh = soh; + } + + public BigDecimal getSoh() + { + return soh; + } + + public void setDateDay(Date dateDay) + { + this.dateDay = dateDay; + } + + public Date getDateDay() + { + return dateDay; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setClusterDeviceId(String clusterDeviceId) + { + this.clusterDeviceId = clusterDeviceId; + } + + public String getClusterDeviceId() + { + return clusterDeviceId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("batteryPack", getBatteryPack()) + .append("batteryCluster", getBatteryCluster()) + .append("batteryCellId", getBatteryCellId()) + .append("voltage", getVoltage()) + .append("temperature", getTemperature()) + .append("soc", getSoc()) + .append("soh", getSoh()) + .append("dateDay", getDateDay()) + .append("dataTimestamp", getDataTimestamp()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("clusterDeviceId", getClusterDeviceId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDailyLatestMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDailyLatestMapper.java new file mode 100644 index 0000000..b21d49e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDailyLatestMapper.java @@ -0,0 +1,68 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsBatteryDataDailyLatest; +import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; +import com.xzzn.ems.domain.vo.DateSearchRequest; +import org.apache.ibatis.annotations.Param; + +/** + * 单体电池每日最新数据Mapper接口 + * + * @author xzzn + * @date 2025-07-18 + */ +public interface EmsBatteryDailyLatestMapper +{ + /** + * 查询单体电池每日最新数据 + * + * @param batteryPack 单体电池每日最新数据主键 + * @return 单体电池每日最新数据 + */ + public EmsBatteryDataDailyLatest selectEmsBatteryDataDailyLatestByBatteryPack(String batteryPack); + + /** + * 查询单体电池每日最新数据列表 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 单体电池每日最新数据集合 + */ + public List selectEmsBatteryDataDailyLatestList(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest); + + /** + * 新增单体电池每日最新数据 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 结果 + */ + public int insertEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest); + + /** + * 修改单体电池每日最新数据 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 结果 + */ + public int updateEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest); + + /** + * 删除单体电池每日最新数据 + * + * @param batteryPack 单体电池每日最新数据主键 + * @return 结果 + */ + public int deleteEmsBatteryDataDailyLatestByBatteryPack(String batteryPack); + + /** + * 批量删除单体电池每日最新数据 + * + * @param batteryPacks 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryDataDailyLatestByBatteryPacks(String[] batteryPacks); + + public void batchUpsert(@Param("list") List dataList); + + public List getBatteryDailyLatest(DateSearchRequest requestVo); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java index 60fb85e..1bd9546 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java @@ -97,10 +97,4 @@ public interface EmsBatteryDataMapper int insertEmsBatteryDataList(List emsBatteryDataList); - /** - * 获取单个单体电池数据 - * @param requestVo - * @return - */ - public List getSingleBatteryData(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDailyLatestService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDailyLatestService.java new file mode 100644 index 0000000..43df589 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsBatteryDailyLatestService.java @@ -0,0 +1,67 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsBatteryDataDailyLatest; + +/** + * 单体电池每日最新数据Service接口 + * + * @author xzzn + * @date 2025-07-18 + */ +public interface IEmsBatteryDailyLatestService +{ + /** + * 查询单体电池每日最新数据 + * + * @param batteryPack 单体电池每日最新数据主键 + * @return 单体电池每日最新数据 + */ + public EmsBatteryDataDailyLatest selectEmsBatteryDataDailyLatestByBatteryPack(String batteryPack); + + /** + * 查询单体电池每日最新数据列表 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 单体电池每日最新数据集合 + */ + public List selectEmsBatteryDataDailyLatestList(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest); + + /** + * 新增单体电池每日最新数据 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 结果 + */ + public int insertEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest); + + /** + * 修改单体电池每日最新数据 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 结果 + */ + public int updateEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest); + + /** + * 批量删除单体电池每日最新数据 + * + * @param batteryPacks 需要删除的单体电池每日最新数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryDataDailyLatestByBatteryPacks(String[] batteryPacks); + + /** + * 删除单体电池每日最新数据信息 + * + * @param batteryPack 单体电池每日最新数据主键 + * @return 结果 + */ + public int deleteEmsBatteryDataDailyLatestByBatteryPack(String batteryPack); + + /** + * 批量处理每日数据 + * @param dailyList + */ + public void batchProcessBatteryData(List dailyList); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDailyLatestServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDailyLatestServiceImpl.java new file mode 100644 index 0000000..fed6827 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsBatteryDailyLatestServiceImpl.java @@ -0,0 +1,105 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; + +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsBatteryDailyLatestMapper; +import com.xzzn.ems.domain.EmsBatteryDataDailyLatest; +import com.xzzn.ems.service.IEmsBatteryDailyLatestService; +import org.springframework.transaction.annotation.Transactional; + +/** + * 单体电池每日最新数据Service业务层处理 + * + * @author xzzn + * @date 2025-07-18 + */ +@Service +public class EmsBatteryDailyLatestServiceImpl implements IEmsBatteryDailyLatestService +{ + @Autowired + private EmsBatteryDailyLatestMapper emsBatteryDataDailyLatestMapper; + + /** + * 查询单体电池每日最新数据 + * + * @param batteryPack 单体电池每日最新数据主键 + * @return 单体电池每日最新数据 + */ + @Override + public EmsBatteryDataDailyLatest selectEmsBatteryDataDailyLatestByBatteryPack(String batteryPack) + { + return emsBatteryDataDailyLatestMapper.selectEmsBatteryDataDailyLatestByBatteryPack(batteryPack); + } + + /** + * 查询单体电池每日最新数据列表 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 单体电池每日最新数据 + */ + @Override + public List selectEmsBatteryDataDailyLatestList(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest) + { + return emsBatteryDataDailyLatestMapper.selectEmsBatteryDataDailyLatestList(emsBatteryDataDailyLatest); + } + + /** + * 新增单体电池每日最新数据 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 结果 + */ + @Override + public int insertEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest) + { + emsBatteryDataDailyLatest.setCreateTime(DateUtils.getNowDate()); + return emsBatteryDataDailyLatestMapper.insertEmsBatteryDataDailyLatest(emsBatteryDataDailyLatest); + } + + /** + * 修改单体电池每日最新数据 + * + * @param emsBatteryDataDailyLatest 单体电池每日最新数据 + * @return 结果 + */ + @Override + public int updateEmsBatteryDataDailyLatest(EmsBatteryDataDailyLatest emsBatteryDataDailyLatest) + { + emsBatteryDataDailyLatest.setUpdateTime(DateUtils.getNowDate()); + return emsBatteryDataDailyLatestMapper.updateEmsBatteryDataDailyLatest(emsBatteryDataDailyLatest); + } + + /** + * 批量删除单体电池每日最新数据 + * + * @param batteryPacks 需要删除的单体电池每日最新数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryDataDailyLatestByBatteryPacks(String[] batteryPacks) + { + return emsBatteryDataDailyLatestMapper.deleteEmsBatteryDataDailyLatestByBatteryPacks(batteryPacks); + } + + /** + * 删除单体电池每日最新数据信息 + * + * @param batteryPack 单体电池每日最新数据主键 + * @return 结果 + */ + @Override + public int deleteEmsBatteryDataDailyLatestByBatteryPack(String batteryPack) + { + return emsBatteryDataDailyLatestMapper.deleteEmsBatteryDataDailyLatestByBatteryPack(batteryPack); + } + + @Override + @Transactional + public void batchProcessBatteryData(List dailyList) { + // 批量更新每日最新数据表(使用 ON DUPLICATE KEY UPDATE) + emsBatteryDataDailyLatestMapper.batchUpsert(dailyList); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 32f2ac4..78aa227 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -37,6 +37,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService private EmsDevicesSettingMapper emsDevicesSettingMapper; @Autowired private EmsBatteryDataMapper emsBatteryDataMapper; + @Autowired + private EmsBatteryDailyLatestMapper emsBatteryDailyLatestMapper; // 电量指标 @Override @@ -194,8 +196,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService BigDecimal activePower = ammeterStatisListVo.getActiveTotalKwh(); BigDecimal reactivePower = ammeterStatisListVo.getReActiveTotalKwh(); if ( activePower != null && reactivePower !=null - && activePower.compareTo(BigDecimal.ZERO) >= 0 - && reactivePower.compareTo(BigDecimal.ZERO) >= 0){ + && activePower.compareTo(BigDecimal.ZERO) > 0 + && reactivePower.compareTo(BigDecimal.ZERO) > 0){ effect = reactivePower.divide(activePower, 2, RoundingMode.HALF_UP) .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); } @@ -210,7 +212,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService BigDecimal totalActive = totalVo.getActiveTotalKwh(); BigDecimal totalReactive = totalVo.getReActiveTotalKwh(); if ( totalActive != null && totalReactive !=null - && totalActive.compareTo(BigDecimal.ZERO) >= 0 + && totalActive.compareTo(BigDecimal.ZERO) > 0 && totalReactive.compareTo(BigDecimal.ZERO) >= 0){ BigDecimal totalEffect = new BigDecimal(0); totalEffect = totalReactive.divide(totalActive, 2, RoundingMode.HALF_UP) @@ -290,14 +292,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService */ @Override public List getSingleBatteryData(DateSearchRequest requestVo) { - List dataList = new ArrayList<>(); // 默认时间-7天 dealRequestTime(requestVo); - - // 按天比较endDate+1 - Date endDate = requestVo.getEndDate(); - requestVo.setEndDate(DateUtils.addDays(endDate, 1)); - dataList = emsBatteryDataMapper.getSingleBatteryData(requestVo); - return dataList; + return emsBatteryDailyLatestMapper.getBatteryDailyLatest(requestVo); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 61b32e9..ac782da 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -14,6 +14,7 @@ import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IFXXDataProcessService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -46,6 +47,8 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { @Autowired private EmsAmmeterDataMapper emsAmmeterDataMapper;; + @Autowired + private EmsBatteryDailyLatestServiceImpl emsBatteryDailyLatestServiceImpl; @Override public void handleFxData(String message) { @@ -253,6 +256,7 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { //单体电池 Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() {})); List list = new ArrayList<>(); + List dailyList = new ArrayList<>(); //单体电池 for (Map.Entry> record : records.entrySet()) { String recordId = record.getKey(); @@ -277,6 +281,12 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { batteryData.setClusterDeviceId(deviceId); list.add(batteryData); + + // 每日最新数据 + EmsBatteryDataDailyLatest daily = new EmsBatteryDataDailyLatest(); + BeanUtils.copyProperties(batteryData, daily); + daily.setDateDay(DateUtils.getNowDate()); + dailyList.add(daily); } if (list.size() > 0 ) { emsBatteryDataMapper.insertEmsBatteryDataList(list); @@ -284,6 +294,15 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId); redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, list); } + + // 批量处理每日最新数据 + batchProcessDailyData(dailyList); + } + + private void batchProcessDailyData(List dailyList) { + if (dailyList != null && dailyList.size() > 0) { + emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList); + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDailyLatestMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDailyLatestMapper.xml new file mode 100644 index 0000000..e9da985 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDailyLatestMapper.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + select battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, date_day, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id from ems_battery_data_daily_latest + + + + + + + + insert into ems_battery_data_daily_latest + + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + date_day, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + + + #{batteryPack}, + #{batteryCluster}, + #{batteryCellId}, + #{voltage}, + #{temperature}, + #{soc}, + #{soh}, + #{dateDay}, + #{dataTimestamp}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + #{clusterDeviceId}, + + + + + update ems_battery_data_daily_latest + + battery_cluster = #{batteryCluster}, + battery_cell_id = #{batteryCellId}, + voltage = #{voltage}, + temperature = #{temperature}, + soc = #{soc}, + soh = #{soh}, + date_day = #{dateDay}, + data_timestamp = #{dataTimestamp}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + cluster_device_id = #{clusterDeviceId}, + + where battery_pack = #{batteryPack} + + + + delete from ems_battery_data_daily_latest where battery_pack = #{batteryPack} + + + + delete from ems_battery_data_daily_latest where battery_pack in + + #{batteryPack} + + + + + INSERT INTO ems_battery_data_daily_latest ( + battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, date_day, + data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id + ) VALUES + + ( + #{item.batteryPack}, + #{item.batteryCluster}, + #{item.batteryCellId}, + #{item.voltage}, + #{item.temperature}, + #{item.soc}, + #{item.soh}, + #{item.dateDay}, + #{item.dataTimestamp}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.remark}, + #{item.siteId}, + #{item.deviceId}, + #{item.clusterDeviceId} + ) + + ON DUPLICATE KEY UPDATE + voltage = VALUES(voltage), + temperature = VALUES(temperature), + soc = VALUES(soc), + soh = VALUES(soh), + data_timestamp = VALUES(data_timestamp), + update_time = NOW(), + remark = VALUES(remark) + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index 5eacc1a..3760a95 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -214,24 +214,4 @@ - \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 18bad13..4f6e3d6 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -358,7 +358,7 @@ AND t.date_day = max_dates.date_day AND t.data_update_time = max_dates.max_update_time GROUP BY dateMonth - ORDER BY dateMonth; + ORDER BY dateMonth select t.site_id, - t.battery_pack_soc as batterySOC, - t.create_time as createDate + avg(t.battery_pack_soc) as batterySOC, + DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') AS createDate from ems_battery_cluster t - inner join (select site_id,create_time,MIN(device_id) as device_id - from ems_battery_cluster - where site_id = #{siteId} - AND create_time >= #{startDate} - AND create_time <= #{endDate} - GROUP BY site_id,create_time - ) temp on t.site_id = temp.site_id and t.create_time = temp.create_time and t.device_id = temp.device_id + where t.site_id = #{siteId} + AND t.create_time >= Date(#{startDate}) + AND t.create_time <= #{endDate} + GROUP BY t.site_id,DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') + order by createDate select t.site_id, - t.operating_temp as temp, - t.create_time as createDate + avg(t.operating_temp) as temp, + DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') AS createDate from ems_battery_stack t - inner join (select site_id,create_time,MIN(device_id) as device_id - from ems_battery_stack - where site_id = #{siteId} - AND create_time >= Date(#{startDate}) - AND create_time <= #{endDate} - GROUP BY site_id,create_time - ) temp on t.site_id = temp.site_id and t.create_time = temp.create_time and t.device_id = temp.device_id + where t.site_id = #{siteId} + AND t.create_time >= Date(#{startDate}) + AND t.create_time <= #{endDate} + GROUP BY t.site_id,createDate + order by createDate @@ -358,4 +356,19 @@ AND latest.max_update_time = t.update_time order by statisDate desc + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 4f6e3d6..add5bff 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -295,36 +295,43 @@ @@ -212,6 +220,14 @@ and reverse_active_energy_ep_minus = #{reverseActiveEnergyEpMinus} and positive_reactive_energy_eq_plus = #{positiveReactiveEnergyEqPlus} and positive_active_energy_ep_plus = #{positiveActiveEnergyEpPlus} + and absorbs_active_eneryg_second_side = #{absorbsActiveEnerygSecondSide} + and release_active_eneryg_second_side = #{releaseActiveEnerygSecondSide} + and inductor_reactive_enery_seconde_side = #{inductorReactiveEnerySecondeSide} + and capacitor_reactive_enery_seconde_side = #{capacitorReactiveEnerySecondeSide} + and absorbs_active_eneryg_one_side = #{absorbsActiveEnerygOneSide} + and release_active_eneryg_one_side = #{releaseActiveEnerygOneSide} + and inductor_reactive_enery_one_side = #{inductorReactiveEneryOneSide} + and capacitor_reactive_enery_one_side = #{capacitorReactiveEneryOneSide} @@ -324,6 +340,14 @@ reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus, + absorbs_active_eneryg_second_side, + release_active_eneryg_second_side, + inductor_reactive_enery_seconde_side, + capacitor_reactive_enery_seconde_side, + absorbs_active_eneryg_one_side, + release_active_eneryg_one_side, + inductor_reactive_enery_one_side, + capacitor_reactive_enery_one_side, #{dataUpdateTime}, @@ -427,6 +451,14 @@ #{reverseActiveEnergyEpMinus}, #{positiveReactiveEnergyEqPlus}, #{positiveActiveEnergyEpPlus}, + #{absorbsActiveEnerygSecondSide}, + #{releaseActiveEnerygSecondSide}, + #{inductorReactiveEnerySecondeSide}, + #{capacitorReactiveEnerySecondeSide}, + #{absorbsActiveEnerygOneSide}, + #{releaseActiveEnerygOneSide}, + #{inductorReactiveEneryOneSide}, + #{capacitorReactiveEneryOneSide}, @@ -534,6 +566,14 @@ reverse_active_energy_ep_minus = #{reverseActiveEnergyEpMinus}, positive_reactive_energy_eq_plus = #{positiveReactiveEnergyEqPlus}, positive_active_energy_ep_plus = #{positiveActiveEnergyEpPlus}, + absorbs_active_eneryg_second_side = #{absorbsActiveEnerygSecondSide}, + release_active_eneryg_second_side = #{releaseActiveEnerygSecondSide}, + inductor_reactive_enery_seconde_side = #{inductorReactiveEnerySecondeSide}, + capacitor_reactive_enery_seconde_side = #{capacitorReactiveEnerySecondeSide}, + absorbs_active_eneryg_one_side = #{absorbsActiveEnerygOneSide}, + release_active_eneryg_one_side = #{releaseActiveEnerygOneSide}, + inductor_reactive_enery_one_side = #{inductorReactiveEneryOneSide}, + capacitor_reactive_enery_one_side = #{capacitorReactiveEneryOneSide}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 43c09f8..951fca9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -364,7 +364,8 @@ FROM ems_battery_cluster p WHERE p.stack_device_id = #{stackId} AND p.device_id = #{clusterId} - AND DATE(p.update_time) = #{dateTime} + AND p.update_time >= #{dateTime} + AND p.update_time < DATE_ADD(#{dateTime}, INTERVAL 1 DAY) GROUP BY p.site_id, p.device_id, statisDate ) latest INNER JOIN ems_battery_cluster t ON latest.site_id = t.site_id -- 2.49.0 From b4cbf0b34e2119fb4b11874995c1989ba94f710f Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 22 Jul 2025 13:54:07 +0800 Subject: [PATCH 106/336] =?UTF-8?q?=E7=94=B5=E9=87=8F=E6=8C=87=E6=A0=87-?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/vo/StatisClusterDateRequest.java | 10 +++++++ .../impl/EmsStatsReportServiceImpl.java | 29 ++++++++++--------- .../mapper/ems/EmsBatteryClusterMapper.xml | 3 +- .../resources/mapper/ems/EmsPcsDataMapper.xml | 3 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java index f4c67c8..214949e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisClusterDateRequest.java @@ -21,6 +21,8 @@ public class StatisClusterDateRequest { private String clusterId; + private String siteId; + public Date getDateTime() { return dateTime; } @@ -44,4 +46,12 @@ public class StatisClusterDateRequest { public void setClusterId(String clusterId) { this.clusterId = clusterId; } + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 78aa227..2cdb178 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -50,6 +50,20 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService Date startDate = requestVo.getStartDate(); Date endDate = requestVo.getEndDate(); + // 总充总放 + Map totalMap = emsPcsDataMapper.getPcsTotalChargeData(requestVo.getSiteId()); + BigDecimal totalDischarge = totalMap.get("totalDischargedCap") != null ? totalMap.get("totalDischargedCap") : BigDecimal.ZERO; + BigDecimal totalCharge = totalMap.get("totalChargedCap") != null ? totalMap.get("totalChargedCap") : BigDecimal.ZERO; + BigDecimal efficiency = new BigDecimal(0); + if ( totalCharge.compareTo(BigDecimal.ZERO)>0){ + efficiency = totalDischarge.divide(totalCharge, 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); + } + electricDataInfoVo.setTotalDisChargedCap(totalDischarge); + electricDataInfoVo.setTotalChargedCap(totalCharge); + electricDataInfoVo.setEfficiency(efficiency); + + // 日期筛选 List dataList = new ArrayList(); // 开始日期和结束日期同一天,展示 0-24 小时数据 if (DateUtils.isSameDay(startDate, endDate)){ @@ -70,15 +84,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService } // 根据时间获取每天的充放电量 if (!CollectionUtils.isEmpty(dataList)){ - // 总充、总放、效率 - BigDecimal totalDischarge = new BigDecimal(0); - BigDecimal totalCharge = new BigDecimal(0); - BigDecimal efficiency = new BigDecimal(0); for (SiteMonitorDataVo siteMonitorDataVo : dataList) { - totalDischarge = totalDischarge.add(siteMonitorDataVo.getDisChargedCap() == null ? BigDecimal.ZERO : siteMonitorDataVo.getDisChargedCap()); - totalCharge = totalCharge.add(siteMonitorDataVo.getChargedCap() == null ? BigDecimal.ZERO : siteMonitorDataVo.getChargedCap()); - // 计算单天的效率 BigDecimal dailyEfficiency = new BigDecimal(0); if ( siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){ @@ -87,14 +94,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService } siteMonitorDataVo.setDailyEfficiency(dailyEfficiency); } - if ( totalCharge.compareTo(BigDecimal.ZERO)>0){ - efficiency = totalDischarge.divide(totalCharge, 2, RoundingMode.HALF_UP); - efficiency = efficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); - } + electricDataInfoVo.setSevenDayDisChargeStats(dataList); - electricDataInfoVo.setTotalDisChargedCap(totalDischarge); - electricDataInfoVo.setTotalChargedCap(totalCharge); - electricDataInfoVo.setEfficiency(efficiency); } return electricDataInfoVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 951fca9..55be7aa 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -362,7 +362,8 @@ t.min_cell_voltage_id as minVoltageId FROM ( SELECT p.site_id, p.device_id, DATE_FORMAT( p.update_time, '%H' ) AS statisDate, MAX(p.update_time) AS max_update_time FROM ems_battery_cluster p - WHERE p.stack_device_id = #{stackId} + WHERE p.site_id = #{siteId} + AND p.stack_device_id = #{stackId} AND p.device_id = #{clusterId} AND p.update_time >= #{dateTime} AND p.update_time < DATE_ADD(#{dateTime}, INTERVAL 1 DAY) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index add5bff..0bf766c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -339,8 +339,7 @@ SUM(t.total_active_power) as totalActivePower, SUM(t.total_reactive_power) as totalReactivePower, sum(t.daily_ac_charge_energy) as dayChargedCap, - sum(t.daily_ac_discharge_energy) as dayDisChargedCap, - #{siteId} as siteId + sum(t.daily_ac_discharge_energy) as dayDisChargedCap FROM ( SELECT p.device_id, MAX(p.data_update_time) AS max_update_time FROM ems_pcs_data p -- 2.49.0 From e3e3dc1d96165b37db08e7e13a7cb8303b1ee6f3 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 22 Jul 2025 22:27:12 +0800 Subject: [PATCH 107/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E6=9B=B2=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/scheduler/StrategyPoller.java | 109 ++++++++++-------- .../com/xzzn/ems/domain/EmsStrategyCurve.java | 26 +++++ .../ems/domain/EmsStrategyTimeConfig.java | 13 +++ .../xzzn/ems/domain/vo/StrategyCurveVo.java | 53 +++++++-- .../ems/mapper/EmsStrategyCurveMapper.java | 5 + .../impl/EmsStrategyCurveServiceImpl.java | 22 +++- .../impl/EmsStrategyTempServiceImpl.java | 9 ++ .../EmsStrategyTimeConfigServiceImpl.java | 11 ++ .../mapper/ems/EmsStrategyCurveMapper.xml | 24 +++- .../ems/EmsStrategyTimeConfigMapper.xml | 12 +- 10 files changed, 217 insertions(+), 67 deletions(-) diff --git a/ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java b/ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java index a8b19d1..235af73 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java +++ b/ems-framework/src/main/java/com/xzzn/framework/scheduler/StrategyPoller.java @@ -1,9 +1,12 @@ package com.xzzn.framework.scheduler; +import com.alibaba.fastjson2.JSON; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsStrategyCurve; +import com.xzzn.ems.domain.EmsStrategyTemp; import com.xzzn.ems.domain.EmsStrategyTimeConfig; +import com.xzzn.ems.domain.vo.StrategyPowerDataVo; import com.xzzn.ems.domain.vo.StrategyRunningVo; import com.xzzn.ems.mapper.*; import com.xzzn.framework.manager.ModbusConnectionManager; @@ -20,6 +23,7 @@ import org.springframework.stereotype.Component; import java.time.LocalDate; import java.time.YearMonth; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -53,8 +57,8 @@ public class StrategyPoller { this.mqttLifecycleManager = mqttLifecycleManager; } // 每1分钟触发(支持cron表达式动态配置) - //@Scheduled(cron = "0 */5 * * * *") - //@Async("strategyTaskExecutor") + @Scheduled(cron = "0 */1 * * * *") + @Async("strategyTaskExecutor") public void pollAllDevices() { logger.info("开始执行策略数据轮询..."); List strategyRunningVoList = emsStrategyRunningMapper.getRunningList(null); @@ -71,69 +75,74 @@ public class StrategyPoller { logger.error("策略下方{}任务失败", strategyVo.getId(), e); } }); - /* - try { - pollSingleDevice(device); - } catch (Exception e) { - logger.error("调度设备{}任务失败", device.getId(), e); - }*/ - /*activeDevices.forEach(device -> { - try { - CompletableFuture.runAsync(() -> processData(device)) - .exceptionally(e -> { - logger.error("设备{}轮询异常", device.getId(), e); - return null; - }); - } catch (Exception e) { - logger.error("调度设备{}任务失败", device.getId(), e); - } - });*/ } // 处理获取到的数据,发到mqtt服务上 private void processData(StrategyRunningVo strategyVo) { logger.info("策略下发数据处理开始"); // 根据运行策略获取主副策略的模板数据 - Long minStrategyId = strategyVo.getMainStrategyId(); + Long mainStrategyId = strategyVo.getMainStrategyId(); Long auxStrategyId = strategyVo.getAuxStrategyId(); String siteId = strategyVo.getSiteId(); // 处理主策略数据 - if (minStrategyId != null && StringUtils.isNotBlank(siteId)) { - // 获取当前策略的所有模板 - List> temps = emsStrategyTempMapper.getTempNameList(minStrategyId,siteId); - if (temps != null && temps.size() > 0) { - for (Map temp : temps) { - String tempId = temp.get("templateId"); - List timeConfigs = emsStrategyTimeConfigMapper.getAllTimeConfigByTempId(tempId); - if (timeConfigs != null && timeConfigs.size() > 0) { - for (EmsStrategyTimeConfig timeConfig : timeConfigs) { - EmsStrategyCurve curve = new EmsStrategyCurve(); - curve.setStrategyId(minStrategyId); - curve.setSiteId(strategyVo.getSiteId()); - curve.setTemplateId(tempId); - curve.setCreateBy("system"); - curve.setCreateTime(DateUtils.getNowDate()); - curve.setUpdateBy("system"); - curve.setUpdateTime(DateUtils.getNowDate()); - // 时间设置 - String[] dateList= dealWithMonth(Integer.parseInt(timeConfig.getMonth().toString())); - curve.setStartDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,dateList[0])); - curve.setEndDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,dateList[1])); - // powerData暂时不处理 + if (mainStrategyId != null && StringUtils.isNotBlank(siteId)) { + dealStrategyCurveData(mainStrategyId, siteId); + } + // 处理副策略数据 + if (auxStrategyId != null && StringUtils.isNotBlank(siteId)) { + dealStrategyCurveData(auxStrategyId, siteId); + } - // 策略数据下发-下方格式暂无 + // 策略数据下发-下方格式暂无 - // 记录推送记录 - emsStrategyCurveMapper.insertEmsStrategyCurve(curve); + logger.info("策略下发结束"); + } + + private void dealStrategyCurveData(Long mainStrategyId, String siteId) { + // 获取当前策略的所有模板 + List> temps = emsStrategyTempMapper.getTempNameList(mainStrategyId,siteId); + if (temps != null && temps.size() > 0) { + for (Map temp : temps) { + String tempId = temp.get("templateId"); + List timeConfigs = emsStrategyTimeConfigMapper.getAllTimeConfigByTempId(tempId); + if (timeConfigs != null && timeConfigs.size() > 0) { + for (EmsStrategyTimeConfig timeConfig : timeConfigs) { + EmsStrategyCurve curve = new EmsStrategyCurve(); + curve.setStrategyId(mainStrategyId); + curve.setSiteId(siteId); + curve.setTemplateId(tempId); + curve.setCreateBy("system"); + curve.setCreateTime(DateUtils.getNowDate()); + curve.setUpdateBy("system"); + curve.setUpdateTime(DateUtils.getNowDate()); + // 时间设置 + int month = Integer.parseInt(timeConfig.getMonth().toString()); + String[] dateList= dealWithMonth(month); + curve.setMonth(Long.valueOf(month)); + curve.setStartDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,dateList[0])); + curve.setEndDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,dateList[1])); + // powerData-存json格式 + List powerConfig = emsStrategyTempMapper.selectStrategyTempByTempId(tempId); + List powerDataVoList = new ArrayList<>(); + for (int i = 0; i < powerConfig.size(); i++) { + EmsStrategyTemp powerTemp = powerConfig.get(i); + StrategyPowerDataVo powerDataVo = new StrategyPowerDataVo(); + powerDataVo.setPowerData(powerTemp.getChargeDischargePower()); + powerDataVo.setEndTime(DateUtils.parseDateToStr("HH:mm:ss",powerTemp.getEndTime())); + powerDataVo.setStartTime(DateUtils.parseDateToStr("HH:mm:ss",powerTemp.getStartTime())); + powerDataVoList.add(powerDataVo); } + curve.setPowerData(powerDataVoList !=null ? JSON.toJSON(powerDataVoList).toString() : ""); + + // 记录推送记录 + emsStrategyCurveMapper.insertEmsStrategyCurve(curve); + + // 设置已下发 + timeConfig.setIsPost(0); + emsStrategyTimeConfigMapper.updateEmsStrategyTimeConfig(timeConfig); } } } } - // 处理副策略数据 - if (auxStrategyId != null && StringUtils.isNotBlank(siteId)) { - - } - logger.info("策略下发结束"); } private String[] dealWithMonth(int month) { diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java index 8c3bc3a..fbd89f5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyCurve.java @@ -50,6 +50,14 @@ public class EmsStrategyCurve extends BaseEntity @Excel(name = "模板id") private String templateId; + /** 月份,1-12 */ + @Excel(name = "月份,1-12") + private Long month; + + /** 是否删除 0-已删除 1-未删除 */ + @Excel(name = "是否删除 0-已删除 1-未删除") + private Long isDelete; + public void setId(Long id) { this.id = id; @@ -128,6 +136,22 @@ public class EmsStrategyCurve extends BaseEntity this.templateId = templateId; } + public Long getMonth() { + return month; + } + + public void setMonth(Long month) { + this.month = month; + } + + public Long getIsDelete() { + return isDelete; + } + + public void setIsDelete(Long isDelete) { + this.isDelete = isDelete; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -144,6 +168,8 @@ public class EmsStrategyCurve extends BaseEntity .append("remark", getRemark()) .append("siteId", getSiteId()) .append("templateId", getTemplateId()) + .append("month", getMonth()) + .append("isDelete", getIsDelete()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java index de02b59..e6a9ff8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStrategyTimeConfig.java @@ -38,6 +38,10 @@ public class EmsStrategyTimeConfig extends BaseEntity @Excel(name = "模版id") private String templateId; + /** 是否下发 0-已下发 1-未下发 */ + @Excel(name = "是否下发 0-已下发 1-未下发") + private int isPost; + public void setId(Long id) { this.id = id; @@ -98,6 +102,14 @@ public class EmsStrategyTimeConfig extends BaseEntity return templateId; } + public int getIsPost() { + return isPost; + } + + public void setIsPost(int isPost) { + this.isPost = isPost; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -112,6 +124,7 @@ public class EmsStrategyTimeConfig extends BaseEntity .append("remark", getRemark()) .append("siteId", getSiteId()) .append("templateId", getTemplateId()) + .append("isPost", getIsPost()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java index 4108c50..2d7959f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StrategyCurveVo.java @@ -1,5 +1,6 @@ package com.xzzn.ems.domain.vo; +import com.xzzn.common.annotation.Excel; import com.xzzn.ems.domain.EmsStrategyCurve; import java.util.List; @@ -13,13 +14,39 @@ import java.util.List; public class StrategyCurveVo { + /** 站点id */ + private String siteId; + + /** 关联的策略ID */ + private Long strategyId; + /** 模板名称 */ private String templateName; /** 模板id */ private String templateId; - List cureList; + /** 月份 */ + private Long month; + + /** 模板时间功率 */ + List powerList; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public Long getStrategyId() { + return strategyId; + } + + public void setStrategyId(Long strategyId) { + this.strategyId = strategyId; + } public String getTemplateName() { return templateName; @@ -29,14 +56,6 @@ public class StrategyCurveVo this.templateName = templateName; } - public List getCureList() { - return cureList; - } - - public void setCureList(List cureList) { - this.cureList = cureList; - } - public String getTemplateId() { return templateId; } @@ -44,4 +63,20 @@ public class StrategyCurveVo public void setTemplateId(String templateId) { this.templateId = templateId; } + + public Long getMonth() { + return month; + } + + public void setMonth(Long month) { + this.month = month; + } + + public List getPowerList() { + return powerList; + } + + public void setPowerList(List powerList) { + this.powerList = powerList; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java index 9157524..e7a759e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyCurveMapper.java @@ -2,6 +2,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsStrategyCurve; +import org.apache.ibatis.annotations.Param; /** * 策曲线Mapper接口 @@ -65,4 +66,8 @@ public interface EmsStrategyCurveMapper * @return */ public List getTemplateCurve(String templateId); + + public void physicalDeleteCurve(@Param("strategyId")Long strategyId,@Param("siteId")String siteId); + // 根据模版id 删除推送的曲线图数据 + public void physicalDeleteByTemplateId(String templateId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java index bb5088e..c7e2d43 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyCurveServiceImpl.java @@ -4,10 +4,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import com.alibaba.fastjson2.JSON; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsStrategyTemp; import com.xzzn.ems.domain.vo.StrategyCurveVo; +import com.xzzn.ems.domain.vo.StrategyPowerDataVo; import com.xzzn.ems.mapper.EmsStrategyTempMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -113,17 +115,27 @@ public class EmsStrategyCurveServiceImpl implements IEmsStrategyCurveService if (tempList != null && !tempList.isEmpty()) { for (Map map : tempList) { - StrategyCurveVo vo = new StrategyCurveVo(); String tempName = map.get("templateName"); String tempId = map.get("templateId"); - vo.setTemplateName(tempName); - vo.setTemplateId(tempId); if (StringUtils.isNotEmpty(tempId)) { List taskList = emsStrategyCurveMapper.getTemplateCurve(tempId); - vo.setCureList(taskList); + + for (int i = 0; i < taskList.size(); i++) { + StrategyCurveVo vo = new StrategyCurveVo(); + vo.setTemplateName(tempName); + vo.setTemplateId(tempId); + vo.setStrategyId(taskList.get(i).getStrategyId()); + vo.setSiteId(taskList.get(i).getSiteId()); + vo.setMonth(taskList.get(i).getMonth()); + // 时间功率 + String powerJson = taskList.get(i).getPowerData(); + List powerList = JSON.parseArray(powerJson, StrategyPowerDataVo.class); + vo.setPowerList(powerList); + + dataList.add(vo); + } } - dataList.add(vo); } } return dataList; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index 6352059..1c5a3f2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -8,6 +8,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanUtils; import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; +import com.xzzn.ems.mapper.EmsStrategyCurveMapper; import com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -30,6 +31,8 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService private EmsStrategyTempMapper emsStrategyTempMapper; @Autowired private EmsStrategyTimeConfigMapper emsStrategyTimeConfigMapper; + @Autowired + private EmsStrategyCurveMapper emsStrategyCurveMapper; /** * 查询模板列表 @@ -95,6 +98,9 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService // 全删 emsStrategyTempMapper.deleteTempByTempId(templateId); + + // 根据模版id 删除推送的曲线图数据 + emsStrategyCurveMapper.physicalDeleteByTemplateId(templateId); // 重新新增 addNewTempAndTimeConfig(requestVo); @@ -111,6 +117,9 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService public int deleteStrategyTempById(String templateId) { // 先更新配置该模板的月份数据 emsStrategyTimeConfigMapper.cleanTemplateId(templateId); + // 根据模版id 删除推送的曲线图数据 + emsStrategyCurveMapper.physicalDeleteByTemplateId(templateId); + return emsStrategyTempMapper.deleteTempByTempId(templateId); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java index 42f9d2b..9a6c42e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java @@ -2,7 +2,9 @@ package com.xzzn.ems.service.impl; import java.util.List; import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.vo.StrategyTimeConfigVo; +import com.xzzn.ems.mapper.EmsStrategyCurveMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper; @@ -20,6 +22,8 @@ public class EmsStrategyTimeConfigServiceImpl implements IEmsStrategyTimeConfigS { @Autowired private EmsStrategyTimeConfigMapper emsStrategyTimeConfigMapper; + @Autowired + private EmsStrategyCurveMapper emsStrategyCurveMapper; /** * 查询时间配置 @@ -57,6 +61,9 @@ public class EmsStrategyTimeConfigServiceImpl implements IEmsStrategyTimeConfigS if (timeConfigList != null) { for (EmsStrategyTimeConfig strategyTimeConfig : timeConfigList) { Long id = strategyTimeConfig.getId(); + Long strategyId = strategyTimeConfig.getStrategyId(); + String siteId = strategyTimeConfig.getSiteId(); + strategyTimeConfig.setIsPost(1);//默认未下发 // 新增 if (id == null) { strategyTimeConfig.setCreateTime(DateUtils.getNowDate()); @@ -65,6 +72,10 @@ public class EmsStrategyTimeConfigServiceImpl implements IEmsStrategyTimeConfigS strategyTimeConfig.setUpdateTime(DateUtils.getNowDate()); emsStrategyTimeConfigMapper.updateEmsStrategyTimeConfig(strategyTimeConfig); } + // 处理曲线图:物理删除该策略的曲线图 + if (StringUtils.isNotEmpty(siteId) && strategyId != null) { + emsStrategyCurveMapper.physicalDeleteCurve(strategyId,siteId); + } } } else { return false; diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml index 1939ca5..c651646 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyCurveMapper.xml @@ -18,10 +18,12 @@ + + - select id, strategy_id, task_number, start_date, end_date, power_data, create_by, create_time, update_by, update_time, remark, site_id, template_id from ems_strategy_curve + select id, strategy_id, task_number, start_date, end_date, power_data, create_by, create_time, update_by, update_time, remark, site_id, template_id, month, isDelete from ems_strategy_curve @@ -57,6 +61,8 @@ remark, site_id, template_id, + month, + isDelete, #{strategyId}, @@ -71,6 +77,8 @@ #{remark}, #{siteId}, #{templateId}, + #{month}, + #{isDelete}, @@ -89,6 +97,8 @@ remark = #{remark}, site_id = #{siteId}, template_id = #{templateId}, + month = #{month}, + isDelete = #{isDelete}, where id = #{id} @@ -107,6 +117,18 @@ + + + update ems_strategy_curve set isDelete = 0 + where site_id = #{siteId} + and strategy_id = #{strategyId} + + + + update ems_strategy_curve set isDelete = 0 + where template_id = #{templateId} + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index 701e00f..4ee7edb 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -16,10 +16,11 @@ + - select id, strategy_id, month, charge_discharge_mode, create_by, create_time, update_by, update_time, remark, site_id, template_id from ems_strategy_time_config + select id, strategy_id, month, charge_discharge_mode, create_by, create_time, update_by, update_time, remark, site_id, template_id, isPost from ems_strategy_time_config @@ -51,6 +53,7 @@ remark, site_id, template_id, + isPost, #{strategyId}, @@ -63,6 +66,7 @@ #{remark}, #{siteId}, #{templateId}, + #{isPost}, @@ -79,6 +83,7 @@ remark = #{remark}, site_id = #{siteId}, template_id = #{templateId}, + isPost = #{isPost}, where id = #{id} @@ -99,7 +104,9 @@ t.month, t.charge_discharge_mode as chargeDischargeMode, t.template_id as templateId, - temp.template_name as templateName + temp.template_name as templateName, + t.site_id as siteId, + t.strategy_id as strategyId from ems_strategy_time_config t LEFT JOIN ems_strategy_temp temp on t.template_id = temp.template_id where t.site_id = #{siteId} @@ -114,5 +121,6 @@ \ No newline at end of file -- 2.49.0 From 7ea52a897284becd0dd83d88b4bd5ef1b35c9dad Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 22 Jul 2025 22:49:54 +0800 Subject: [PATCH 108/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E6=9B=B2=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java | 3 +++ .../com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java | 3 ++- .../main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java index 174b2ae..b6eb10e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java @@ -68,4 +68,7 @@ public interface EmsStrategyTimeConfigMapper // 获取该策略下的时间配置 List getAllTimeConfigByTempId(String templateId); + + // 设置该模版的时间配置为待下发 + public void updateTimeConfigWaitingPost(String templateId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index 1c5a3f2..ace1826 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -98,9 +98,10 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService // 全删 emsStrategyTempMapper.deleteTempByTempId(templateId); - // 根据模版id 删除推送的曲线图数据 emsStrategyCurveMapper.physicalDeleteByTemplateId(templateId); + // 设置该模版的时间配置为待下发 + emsStrategyTimeConfigMapper.updateTimeConfigWaitingPost(templateId); // 重新新增 addNewTempAndTimeConfig(requestVo); diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index 4ee7edb..bfe9938 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -123,4 +123,8 @@ where template_id = #{templateId} and isPost = 1 + + + update ems_strategy_time_config set isPost = 1 where template_id = #{templateId} + \ No newline at end of file -- 2.49.0 From 281e0f57c409dd06766af2973826d98c80d6af70 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 27 Jul 2025 13:49:36 +0800 Subject: [PATCH 109/336] =?UTF-8?q?modbus=E8=BD=AE=E8=AF=A2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application.yml | 9 -- .../xzzn/framework/config/AsyncConfig.java | 14 ++- .../manager/ModbusConnectionManager.java | 103 ++++++++++++++---- .../framework/scheduler/ModbusPoller.java | 4 +- 4 files changed, 96 insertions(+), 34 deletions(-) diff --git a/ems-admin/src/main/resources/application.yml b/ems-admin/src/main/resources/application.yml index 828ca58..afad4c3 100644 --- a/ems-admin/src/main/resources/application.yml +++ b/ems-admin/src/main/resources/application.yml @@ -145,12 +145,3 @@ modbus: poll: interval: "0 */5 * * * *" # 5分钟间隔 timeout: 30000 # 30秒超时 - -resilience4j: - circuitbreaker: - instances: - modbusOperation: - failure-rate-threshold: 50 - minimum-number-of-calls: 5 - sliding-window-size: 10 - wait-duration-in-open-state: 10s \ No newline at end of file diff --git a/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java b/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java index d6bead0..f0271d7 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java +++ b/ems-framework/src/main/java/com/xzzn/framework/config/AsyncConfig.java @@ -1,3 +1,4 @@ +/* package com.xzzn.framework.config; import org.springframework.context.annotation.Bean; @@ -25,10 +26,13 @@ public class AsyncConfig { return executor; } - /** + */ +/** * 策略下方定时任务 - */ - /*@Bean("strategyTaskExecutor") + *//* + + */ +/*@Bean("strategyTaskExecutor") public Executor strategyTaskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(5); @@ -39,5 +43,7 @@ public class AsyncConfig { executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.initialize(); return executor; - }*/ + }*//* + } +*/ diff --git a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java index 386c919..9529d6d 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java +++ b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java @@ -2,17 +2,22 @@ package com.xzzn.framework.manager; import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import org.apache.commons.pool2.impl.GenericObjectPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import java.net.InetAddress; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.concurrent.*; +import java.util.stream.Collectors; @Component public class ModbusConnectionManager implements ApplicationRunner { @@ -27,16 +32,18 @@ public class ModbusConnectionManager implements ApplicationRunner { private long timeBetweenEvictionRunsMillis = 30000; private long minEvictableIdleTimeMillis = 60000; + private ScheduledExecutorService scheduler; + @Autowired + private EmsDevicesSettingMapper deviceRepo; @Override - public void run(ApplicationArguments args) throws Exception { + public void run(ApplicationArguments args) throws Exception { init(); } - @PostConstruct public void init() { // 启动心跳检测线程 - ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); + scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(this::heartbeatCheck, 1, 5, TimeUnit.MINUTES); logger.info("Modbus连接管理器已初始化"); } @@ -84,27 +91,49 @@ public class ModbusConnectionManager implements ApplicationRunner { * 心跳检测 */ private void heartbeatCheck() { - logger.debug("开始监控Modbus连接池状态"); + logger.info("开始监控Modbus连接池状态,当前连接数: {}", connectionPool.size()); - connectionPool.forEach((id, wrapper) -> { + // 步骤1:获取所有活跃设备列表(与轮询逻辑共用同一批设备) + List activeDevices = null; + if (activeDevices == null || activeDevices.isEmpty()) { + logger.warn("无活跃设备,心跳检测仅清理无效连接"); + } + + // 步骤2:清理无效连接(遍历连接池,移除已失效的连接) + List invalidDeviceIds = new ArrayList<>(); + connectionPool.forEach((deviceId, wrapper) -> { try { if (!wrapper.isActive()) { - logger.warn("连接{}已失效,移除连接", id); - connectionPool.remove(id); + logger.info("连接{}已失效,移除连接", deviceId); + invalidDeviceIds.add(deviceId); wrapper.close(); } } catch (Exception e) { - logger.error("心跳检测异常: {}", id, e); + logger.error("心跳检测异常: {}", deviceId, e); } }); - // 维持最小空闲连接 - try { - while (connectionPool.size() < minIdle) { - preloadCriticalConnection(); + // 批量移除无效连接(避免边遍历边修改) + invalidDeviceIds.forEach(connectionPool::remove); + logger.debug("移除无效连接后,连接池大小: {}", connectionPool.size()); + + // 步骤3:补充关键设备的连接(优先保障活跃设备的连接存在) + if (!activeDevices.isEmpty()) { + // 3.1 先为所有活跃设备预加载连接(确保需要轮询的设备有连接) + preloadCriticalConnection(activeDevices); + + // 3.2 若连接数仍不足minIdle,补充额外连接(可选,避免连接池过小) + int currentSize = connectionPool.size(); + if (currentSize < minIdle) { + logger.info("连接数{}不足最小空闲数{},补充额外连接", currentSize, minIdle); + // 从活跃设备中选未创建连接的设备补充(避免重复创建) + List needMoreDevices = activeDevices.stream() + .filter(device -> !connectionPool.containsKey(Math.toIntExact(device.getId()))) + .limit(minIdle - currentSize) // 只补充差额 + .collect(Collectors.toList()); + + preloadCriticalConnection(needMoreDevices); // 复用预加载方法 } - } catch (Exception e) { - logger.error("预加载连接失败", e); } } @@ -112,17 +141,29 @@ public class ModbusConnectionManager implements ApplicationRunner { * 预加载关键连接 */ - private void preloadCriticalConnection() { - // 这里应根据实际业务逻辑选择需要预加载的设备 + private void preloadCriticalConnection(List devices) { // 简化示例,不实现具体逻辑 - logger.debug("预加载连接: 连接池当前大小={}, 最小空闲={}", connectionPool.size(), minIdle); + logger.info("预加载连接: 连接池当前大小={}, 最小空闲={}", connectionPool.size(), minIdle); + devices.forEach(device -> { + try { + Integer deviceId = Math.toIntExact(device.getId()); + if (!connectionPool.containsKey(deviceId)) { + getConnection(device); // 复用已有创建逻辑 + } + } catch (Exception e) { + logger.warn("预加载设备{}连接失败", device.getId(), e); + } + }); } /** * 移除最久未使用的空闲连接 */ - private void evictIdleConnection() { + if (connectionPool.isEmpty()) { + return; + } + ModbusConnectionWrapper oldestWrapper = null; long oldestAccessTime = Long.MAX_VALUE; @@ -140,6 +181,15 @@ public class ModbusConnectionManager implements ApplicationRunner { } } + // 移除指定设备连接 + public void removeConnection(Integer deviceId) { + ModbusConnectionWrapper wrapper = connectionPool.remove(deviceId); + if (wrapper != null) { + wrapper.close(); // 双重保障,确保连接关闭 + logger.info("连接池主动移除设备{}的连接", deviceId); + } + } + /** * 判断是否应该移除空连接池 */ @@ -162,6 +212,21 @@ public class ModbusConnectionManager implements ApplicationRunner { } } + // 容器销毁时关闭线程池 + @PreDestroy + public void destroy() { + if (scheduler != null) { + scheduler.shutdown(); + try { + if (!scheduler.awaitTermination(5, TimeUnit.SECONDS)) { + scheduler.shutdownNow(); + } + } catch (InterruptedException e) { + scheduler.shutdownNow(); + } + } + } + // Getters and Setters public void setMaxTotal(int maxTotal) { this.maxTotal = maxTotal; diff --git a/ems-framework/src/main/java/com/xzzn/framework/scheduler/ModbusPoller.java b/ems-framework/src/main/java/com/xzzn/framework/scheduler/ModbusPoller.java index 94a244a..8133d7b 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/scheduler/ModbusPoller.java +++ b/ems-framework/src/main/java/com/xzzn/framework/scheduler/ModbusPoller.java @@ -93,9 +93,9 @@ public class ModbusPoller { // 标记连接为无效 if (wrapper != null) { wrapper.close(); + connectionManager.removeConnection(Integer.parseInt(device.getDeviceId())); } - // 重试机制会在这里触发 - throw new RuntimeException("轮询设备失败", e); + throw new RuntimeException("轮询设备失败", e); } } -- 2.49.0 From 9da5047148c1506e34e33e234998d4837b874f05 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 27 Jul 2025 17:34:38 +0800 Subject: [PATCH 110/336] =?UTF-8?q?DDS=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/EmsAmmeterData.java | 125 ++----- .../xzzn/ems/domain/EmsBatteryCluster.java | 344 +++++++++++++++++- .../com/xzzn/ems/domain/EmsBatteryStack.java | 210 +++++++++++ .../java/com/xzzn/ems/domain/EmsPcsData.java | 15 + .../impl/DDSDataProcessServiceImpl.java | 305 ++++++++-------- .../mapper/ems/EmsAmmeterDataMapper.xml | 57 +-- .../mapper/ems/EmsBatteryClusterMapper.xml | 112 +++++- .../mapper/ems/EmsBatteryStackMapper.xml | 72 +++- .../resources/mapper/ems/EmsPcsDataMapper.xml | 7 +- 9 files changed, 944 insertions(+), 303 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java index 53bb893..beacd93 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * 总数据对象 ems_ammeter_data * * @author xzzn - * @date 2025-07-03 + * @date 2025-07-27 */ public class EmsAmmeterData extends BaseEntity { @@ -406,37 +406,17 @@ public class EmsAmmeterData extends BaseEntity @Excel(name = "正向有功电能 EP+") private BigDecimal positiveActiveEnergyEpPlus; - /** 吸收有功电度二次侧 */ - @Excel(name = "吸收有功电度二次侧") - private BigDecimal absorbsActiveEnerygSecondSide; + /** 电流变比 */ + @Excel(name = "电流变比") + private BigDecimal currentPercent; - /** 释放有功电度二次侧 */ - @Excel(name = "释放有功电度二次侧") - private BigDecimal releaseActiveEnerygSecondSide; + /** 电压变比 */ + @Excel(name = "电压变比") + private BigDecimal voltagePercent; - /** 感性无功电度二次侧 */ - @Excel(name = "感性无功电度二次侧") - private BigDecimal inductorReactiveEnerySecondeSide; - - /** 容性无功电度二次侧 */ - @Excel(name = "容性无功电度二次侧") - private BigDecimal capacitorReactiveEnerySecondeSide; - - /** 吸收有功电度一次侧 */ - @Excel(name = "吸收有功电度一次侧") - private BigDecimal absorbsActiveEnerygOneSide; - - /** 释放有功电度一次侧 */ - @Excel(name = "释放有功电度一次侧") - private BigDecimal releaseActiveEnerygOneSide; - - /** 感性无功电度一次侧 */ - @Excel(name = "感性无功电度一次侧") - private BigDecimal inductorReactiveEneryOneSide; - - /** 容性无功电度一次侧 */ - @Excel(name = "容性无功电度一次侧") - private BigDecimal capacitorReactiveEneryOneSide; + /** 平均电流 */ + @Excel(name = "平均电流") + private BigDecimal avgCurrent; public void setId(Long id) { @@ -1408,84 +1388,34 @@ public class EmsAmmeterData extends BaseEntity return positiveActiveEnergyEpPlus; } - public void setAbsorbsActiveEnerygSecondSide(BigDecimal absorbsActiveEnerygSecondSide) + public void setCurrentPercent(BigDecimal currentPercent) { - this.absorbsActiveEnerygSecondSide = absorbsActiveEnerygSecondSide; + this.currentPercent = currentPercent; } - public BigDecimal getAbsorbsActiveEnerygSecondSide() + public BigDecimal getCurrentPercent() { - return absorbsActiveEnerygSecondSide; + return currentPercent; } - public void setReleaseActiveEnerygSecondSide(BigDecimal releaseActiveEnerygSecondSide) + public void setVoltagePercent(BigDecimal voltagePercent) { - this.releaseActiveEnerygSecondSide = releaseActiveEnerygSecondSide; + this.voltagePercent = voltagePercent; } - public BigDecimal getReleaseActiveEnerygSecondSide() + public BigDecimal getVoltagePercent() { - return releaseActiveEnerygSecondSide; + return voltagePercent; } - public void setInductorReactiveEnerySecondeSide(BigDecimal inductorReactiveEnerySecondeSide) + public void setAvgCurrent(BigDecimal avgCurrent) { - this.inductorReactiveEnerySecondeSide = inductorReactiveEnerySecondeSide; + this.avgCurrent = avgCurrent; } - public BigDecimal getInductorReactiveEnerySecondeSide() + public BigDecimal getAvgCurrent() { - return inductorReactiveEnerySecondeSide; - } - - public void setCapacitorReactiveEnerySecondeSide(BigDecimal capacitorReactiveEnerySecondeSide) - { - this.capacitorReactiveEnerySecondeSide = capacitorReactiveEnerySecondeSide; - } - - public BigDecimal getCapacitorReactiveEnerySecondeSide() - { - return capacitorReactiveEnerySecondeSide; - } - - public void setAbsorbsActiveEnerygOneSide(BigDecimal absorbsActiveEnerygOneSide) - { - this.absorbsActiveEnerygOneSide = absorbsActiveEnerygOneSide; - } - - public BigDecimal getAbsorbsActiveEnerygOneSide() - { - return absorbsActiveEnerygOneSide; - } - - public void setReleaseActiveEnerygOneSide(BigDecimal releaseActiveEnerygOneSide) - { - this.releaseActiveEnerygOneSide = releaseActiveEnerygOneSide; - } - - public BigDecimal getReleaseActiveEnerygOneSide() - { - return releaseActiveEnerygOneSide; - } - - public void setInductorReactiveEneryOneSide(BigDecimal inductorReactiveEneryOneSide) - { - this.inductorReactiveEneryOneSide = inductorReactiveEneryOneSide; - } - - public BigDecimal getInductorReactiveEneryOneSide() - { - return inductorReactiveEneryOneSide; - } - - public void setCapacitorReactiveEneryOneSide(BigDecimal capacitorReactiveEneryOneSide) - { - this.capacitorReactiveEneryOneSide = capacitorReactiveEneryOneSide; - } - - public BigDecimal getCapacitorReactiveEneryOneSide() - { - return capacitorReactiveEneryOneSide; + return avgCurrent; } @Override @@ -1593,14 +1523,9 @@ public class EmsAmmeterData extends BaseEntity .append("reverseActiveEnergyEpMinus", getReverseActiveEnergyEpMinus()) .append("positiveReactiveEnergyEqPlus", getPositiveReactiveEnergyEqPlus()) .append("positiveActiveEnergyEpPlus", getPositiveActiveEnergyEpPlus()) - .append("absorbsActiveEnerygSecondSide", getAbsorbsActiveEnerygSecondSide()) - .append("releaseActiveEnerygSecondSide", getReleaseActiveEnerygSecondSide()) - .append("inductorReactiveEnerySecondeSide", getInductorReactiveEnerySecondeSide()) - .append("capacitorReactiveEnerySecondeSide", getCapacitorReactiveEnerySecondeSide()) - .append("absorbsActiveEnerygOneSide", getAbsorbsActiveEnerygOneSide()) - .append("releaseActiveEnerygOneSide", getReleaseActiveEnerygOneSide()) - .append("inductorReactiveEneryOneSide", getInductorReactiveEneryOneSide()) - .append("capacitorReactiveEneryOneSide", getCapacitorReactiveEneryOneSide()) + .append("currentPercent", getCurrentPercent()) + .append("voltagePercent", getVoltagePercent()) + .append("avgCurrent", getAvgCurrent()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java index 05718b5..de570e5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * 电池簇数据对象 ems_battery_cluster * * @author xzzn - * @date 2025-06-29 + * @date 2025-07-27 */ public class EmsBatteryCluster extends BaseEntity { @@ -20,16 +20,16 @@ public class EmsBatteryCluster extends BaseEntity /** */ private Long id; - /** 工作状态 */ - @Excel(name = "工作状态") + /** 工作状态:0-正常 1-异常 2-停止 */ + @Excel(name = "工作状态:0-正常 1-异常 2-停止") private String workStatus; - /** 与PCS通信状态 */ - @Excel(name = "与PCS通信状态") + /** 与PCS通信状态:0-正常 1-通信中断 2-异常 */ + @Excel(name = "与PCS通信状态:0-正常 1-通信中断 2-异常") private String pcsCommunicationStatus; - /** 与EMS通信状态 */ - @Excel(name = "与EMS通信状态") + /** 与EMS通信状态:0-正常 1-通信中断 2-异常 */ + @Excel(name = "与EMS通信状态:0-正常 1-通信中断 2-异常") private String emsCommunicationStatus; /** 簇电压 (V) */ @@ -212,6 +212,94 @@ public class EmsBatteryCluster extends BaseEntity @Excel(name = "单次累计放电电量") private BigDecimal totalDischargeEnergy; + /** 断线检测指示 */ + @Excel(name = "断线检测指示") + private String disconnectDetectionIndication; + + /** 电压变比 */ + @Excel(name = "电压变比") + private BigDecimal voltageTransforRatio; + + /** 额定一次电流值 */ + @Excel(name = "额定一次电流值") + private BigDecimal ratedPrimaryCurrentValue; + + /** 开关量输入输出状态 */ + @Excel(name = "开关量输入输出状态") + private String switchInputOutputStatus; + + /** 报警状态 */ + @Excel(name = "报警状态") + private String alarmStatus; + + /** 当前总电压百分比 */ + @Excel(name = "当前总电压百分比") + private BigDecimal currentTotalVoltagePercent; + + /** 电压直流含量百分比 */ + @Excel(name = "电压直流含量百分比") + private BigDecimal voltageContentPercent; + + /** 电压交流含量百分比 */ + @Excel(name = "电压交流含量百分比") + private BigDecimal voltageAcPercent; + + /** 当前总电流百分比 */ + @Excel(name = "当前总电流百分比") + private BigDecimal currentTotalCurrentPercent; + + /** 电流直流含量百分比 */ + @Excel(name = "电流直流含量百分比") + private BigDecimal currentContentPercent; + + /** 电流交流含量百分比 */ + @Excel(name = "电流交流含量百分比") + private BigDecimal currentAcPercent; + + /** 当前总功率百分比 */ + @Excel(name = "当前总功率百分比") + private BigDecimal currentTotalPowerPercent; + + /** 功率直流含量百分比 */ + @Excel(name = "功率直流含量百分比") + private BigDecimal powerContentPercent; + + /** 功率交流含量百分比 */ + @Excel(name = "功率交流含量百分比") + private BigDecimal powerAcPercent; + + /** 日期时间设置(年月) */ + @Excel(name = "日期时间设置", readConverterExp = "年=月") + private String dataSettingYearMonth; + + /** 日期时间设置(日时) */ + @Excel(name = "日期时间设置", readConverterExp = "日=时") + private String dataSettingDayHour; + + /** 日期时间设置(分秒) */ + @Excel(name = "日期时间设置", readConverterExp = "分=秒") + private String dataSettingMinutesSeconds; + + /** 当前抄表日(高)、当前费率(低) */ + @Excel(name = "当前抄表日", readConverterExp = "高=") + private BigDecimal currentRate; + + /** 软件版本号 */ + @Excel(name = "软件版本号") + private String versionNumber; + + /** 电压 */ + @Excel(name = "电压") + private BigDecimal voltage; + + /** 电流 */ + @Excel(name = "电流") + private BigDecimal current; + + /** 功率 */ + @Excel(name = "功率") + private BigDecimal power; + public void setId(Long id) { this.id = id; @@ -702,6 +790,226 @@ public class EmsBatteryCluster extends BaseEntity return totalDischargeEnergy; } + public void setDisconnectDetectionIndication(String disconnectDetectionIndication) + { + this.disconnectDetectionIndication = disconnectDetectionIndication; + } + + public String getDisconnectDetectionIndication() + { + return disconnectDetectionIndication; + } + + public void setVoltageTransforRatio(BigDecimal voltageTransforRatio) + { + this.voltageTransforRatio = voltageTransforRatio; + } + + public BigDecimal getVoltageTransforRatio() + { + return voltageTransforRatio; + } + + public void setRatedPrimaryCurrentValue(BigDecimal ratedPrimaryCurrentValue) + { + this.ratedPrimaryCurrentValue = ratedPrimaryCurrentValue; + } + + public BigDecimal getRatedPrimaryCurrentValue() + { + return ratedPrimaryCurrentValue; + } + + public void setSwitchInputOutputStatus(String switchInputOutputStatus) + { + this.switchInputOutputStatus = switchInputOutputStatus; + } + + public String getSwitchInputOutputStatus() + { + return switchInputOutputStatus; + } + + public void setAlarmStatus(String alarmStatus) + { + this.alarmStatus = alarmStatus; + } + + public String getAlarmStatus() + { + return alarmStatus; + } + + public void setCurrentTotalVoltagePercent(BigDecimal currentTotalVoltagePercent) + { + this.currentTotalVoltagePercent = currentTotalVoltagePercent; + } + + public BigDecimal getCurrentTotalVoltagePercent() + { + return currentTotalVoltagePercent; + } + + public void setVoltageContentPercent(BigDecimal voltageContentPercent) + { + this.voltageContentPercent = voltageContentPercent; + } + + public BigDecimal getVoltageContentPercent() + { + return voltageContentPercent; + } + + public void setVoltageAcPercent(BigDecimal voltageAcPercent) + { + this.voltageAcPercent = voltageAcPercent; + } + + public BigDecimal getVoltageAcPercent() + { + return voltageAcPercent; + } + + public void setCurrentTotalCurrentPercent(BigDecimal currentTotalCurrentPercent) + { + this.currentTotalCurrentPercent = currentTotalCurrentPercent; + } + + public BigDecimal getCurrentTotalCurrentPercent() + { + return currentTotalCurrentPercent; + } + + public void setCurrentContentPercent(BigDecimal currentContentPercent) + { + this.currentContentPercent = currentContentPercent; + } + + public BigDecimal getCurrentContentPercent() + { + return currentContentPercent; + } + + public void setCurrentAcPercent(BigDecimal currentAcPercent) + { + this.currentAcPercent = currentAcPercent; + } + + public BigDecimal getCurrentAcPercent() + { + return currentAcPercent; + } + + public void setCurrentTotalPowerPercent(BigDecimal currentTotalPowerPercent) + { + this.currentTotalPowerPercent = currentTotalPowerPercent; + } + + public BigDecimal getCurrentTotalPowerPercent() + { + return currentTotalPowerPercent; + } + + public void setPowerContentPercent(BigDecimal powerContentPercent) + { + this.powerContentPercent = powerContentPercent; + } + + public BigDecimal getPowerContentPercent() + { + return powerContentPercent; + } + + public void setPowerAcPercent(BigDecimal powerAcPercent) + { + this.powerAcPercent = powerAcPercent; + } + + public BigDecimal getPowerAcPercent() + { + return powerAcPercent; + } + + public void setDataSettingYearMonth(String dataSettingYearMonth) + { + this.dataSettingYearMonth = dataSettingYearMonth; + } + + public String getDataSettingYearMonth() + { + return dataSettingYearMonth; + } + + public void setDataSettingDayHour(String dataSettingDayHour) + { + this.dataSettingDayHour = dataSettingDayHour; + } + + public String getDataSettingDayHour() + { + return dataSettingDayHour; + } + + public void setDataSettingMinutesSeconds(String dataSettingMinutesSeconds) + { + this.dataSettingMinutesSeconds = dataSettingMinutesSeconds; + } + + public String getDataSettingMinutesSeconds() + { + return dataSettingMinutesSeconds; + } + + public void setCurrentRate(BigDecimal currentRate) + { + this.currentRate = currentRate; + } + + public BigDecimal getCurrentRate() + { + return currentRate; + } + + public void setVersionNumber(String versionNumber) + { + this.versionNumber = versionNumber; + } + + public String getVersionNumber() + { + return versionNumber; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setCurrent(BigDecimal current) + { + this.current = current; + } + + public BigDecimal getCurrent() + { + return current; + } + + public void setPower(BigDecimal power) + { + this.power = power; + } + + public BigDecimal getPower() + { + return power; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -759,6 +1067,28 @@ public class EmsBatteryCluster extends BaseEntity .append("minCellSohId", getMinCellSohId()) .append("totalChargeEnergy", getTotalChargeEnergy()) .append("totalDischargeEnergy", getTotalDischargeEnergy()) + .append("disconnectDetectionIndication", getDisconnectDetectionIndication()) + .append("voltageTransforRatio", getVoltageTransforRatio()) + .append("ratedPrimaryCurrentValue", getRatedPrimaryCurrentValue()) + .append("switchInputOutputStatus", getSwitchInputOutputStatus()) + .append("alarmStatus", getAlarmStatus()) + .append("currentTotalVoltagePercent", getCurrentTotalVoltagePercent()) + .append("voltageContentPercent", getVoltageContentPercent()) + .append("voltageAcPercent", getVoltageAcPercent()) + .append("currentTotalCurrentPercent", getCurrentTotalCurrentPercent()) + .append("currentContentPercent", getCurrentContentPercent()) + .append("currentAcPercent", getCurrentAcPercent()) + .append("currentTotalPowerPercent", getCurrentTotalPowerPercent()) + .append("powerContentPercent", getPowerContentPercent()) + .append("powerAcPercent", getPowerAcPercent()) + .append("dataSettingYearMonth", getDataSettingYearMonth()) + .append("dataSettingDayHour", getDataSettingDayHour()) + .append("dataSettingMinutesSeconds", getDataSettingMinutesSeconds()) + .append("currentRate", getCurrentRate()) + .append("versionNumber", getVersionNumber()) + .append("voltage", getVoltage()) + .append("current", getCurrent()) + .append("power", getPower()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java index 989c612..117d9f1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java @@ -188,6 +188,62 @@ public class EmsBatteryStack extends BaseEntity @Excel(name = "设备id") private String deviceId; + /** 单体个数 */ + @Excel(name = "单体个数") + private Long batteryNumber; + + /** 单体平均电压 */ + @Excel(name = "单体平均电压") + private BigDecimal batteryAvgVoltage; + + /** 单体电池压差 */ + @Excel(name = "单体电池压差") + private BigDecimal batteryDifferentPressure; + + /** 平均温度 */ + @Excel(name = "平均温度") + private BigDecimal avgTemperature; + + /** 单体电池温度差 */ + @Excel(name = "单体电池温度差") + private BigDecimal batteryDifferentTemperature; + + /** 最大单体内阻 */ + @Excel(name = "最大单体内阻") + private BigDecimal maxInternalResistance; + + /** 最小单体内阻 */ + @Excel(name = "最小单体内阻") + private BigDecimal minInternalResistance; + + /** 平均单体内阻 */ + @Excel(name = "平均单体内阻") + private BigDecimal avgInternalResistance; + + /** 单体内阻差 */ + @Excel(name = "单体内阻差") + private BigDecimal batteryDefferentResistance; + + /** 最大单体内阻编号 */ + @Excel(name = "最大单体内阻编号") + private Long maxResistanceCellId; + + /** 最小单体内阻编号 */ + @Excel(name = "最小单体内阻编号") + private Long minResistanceCellId; + + /** 环境温度 */ + @Excel(name = "环境温度") + private BigDecimal environmentTemperature; + + /** 环境湿度 */ + @Excel(name = "环境湿度") + private BigDecimal environmentHumidity; + + /** 断路器状态 */ + @Excel(name = "断路器状态") + private String circuitBreakerStatus; + public void setId(Long id) { this.id = id; @@ -618,6 +674,146 @@ public class EmsBatteryStack extends BaseEntity return deviceId; } + public void setBatteryNumber(Long batteryNumber) + { + this.batteryNumber = batteryNumber; + } + + public Long getBatteryNumber() + { + return batteryNumber; + } + + public void setBatteryAvgVoltage(BigDecimal batteryAvgVoltage) + { + this.batteryAvgVoltage = batteryAvgVoltage; + } + + public BigDecimal getBatteryAvgVoltage() + { + return batteryAvgVoltage; + } + + public void setBatteryDifferentPressure(BigDecimal batteryDifferentPressure) + { + this.batteryDifferentPressure = batteryDifferentPressure; + } + + public BigDecimal getBatteryDifferentPressure() + { + return batteryDifferentPressure; + } + + public void setAvgTemperature(BigDecimal avgTemperature) + { + this.avgTemperature = avgTemperature; + } + + public BigDecimal getAvgTemperature() + { + return avgTemperature; + } + + public void setBatteryDifferentTemperature(BigDecimal batteryDifferentTemperature) + { + this.batteryDifferentTemperature = batteryDifferentTemperature; + } + + public BigDecimal getBatteryDifferentTemperature() + { + return batteryDifferentTemperature; + } + + public void setMaxInternalResistance(BigDecimal maxInternalResistance) + { + this.maxInternalResistance = maxInternalResistance; + } + + public BigDecimal getMaxInternalResistance() + { + return maxInternalResistance; + } + + public void setMinInternalResistance(BigDecimal minInternalResistance) + { + this.minInternalResistance = minInternalResistance; + } + + public BigDecimal getMinInternalResistance() + { + return minInternalResistance; + } + + public void setAvgInternalResistance(BigDecimal avgInternalResistance) + { + this.avgInternalResistance = avgInternalResistance; + } + + public BigDecimal getAvgInternalResistance() + { + return avgInternalResistance; + } + + public void setBatteryDefferentResistance(BigDecimal batteryDefferentResistance) + { + this.batteryDefferentResistance = batteryDefferentResistance; + } + + public BigDecimal getBatteryDefferentResistance() + { + return batteryDefferentResistance; + } + + public void setMaxResistanceCellId(Long maxResistanceCellId) + { + this.maxResistanceCellId = maxResistanceCellId; + } + + public Long getMaxResistanceCellId() + { + return maxResistanceCellId; + } + + public void setMinResistanceCellId(Long minResistanceCellId) + { + this.minResistanceCellId = minResistanceCellId; + } + + public Long getMinResistanceCellId() + { + return minResistanceCellId; + } + + public void setEnvironmentTemperature(BigDecimal environmentTemperature) + { + this.environmentTemperature = environmentTemperature; + } + + public BigDecimal getEnvironmentTemperature() + { + return environmentTemperature; + } + + public void setEnvironmentHumidity(BigDecimal environmentHumidity) + { + this.environmentHumidity = environmentHumidity; + } + + public BigDecimal getEnvironmentHumidity() + { + return environmentHumidity; + } + + public void setCircuitBreakerStatus(String circuitBreakerStatus) + { + this.circuitBreakerStatus = circuitBreakerStatus; + } + + public String getCircuitBreakerStatus() + { + return circuitBreakerStatus; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -668,6 +864,20 @@ public class EmsBatteryStack extends BaseEntity .append("createBy", getCreateBy()) .append("updateTime", getUpdateTime()) .append("updateBy", getUpdateBy()) + .append("batteryNumber", getBatteryNumber()) + .append("batteryAvgVoltage", getBatteryAvgVoltage()) + .append("batteryDifferentPressure", getBatteryDifferentPressure()) + .append("avgTemperature", getAvgTemperature()) + .append("batteryDifferentTemperature", getBatteryDifferentTemperature()) + .append("maxInternalResistance", getMaxInternalResistance()) + .append("minInternalResistance", getMinInternalResistance()) + .append("avgInternalResistance", getAvgInternalResistance()) + .append("batteryDefferentResistance", getBatteryDefferentResistance()) + .append("maxResistanceCellId", getMaxResistanceCellId()) + .append("minResistanceCellId", getMinResistanceCellId()) + .append("environmentTemperature", getEnvironmentTemperature()) + .append("environmentHumidity", getEnvironmentHumidity()) + .append("circuitBreakerStatus", getCircuitBreakerStatus()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index 746a5d6..98c642f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -202,6 +202,10 @@ public class EmsPcsData extends BaseEntity @Excel(name = "系统输出W相电流") private BigDecimal sysWCurrent; + /** 电网频率 */ + @Excel(name = "电网频率") + private BigDecimal dwFrequency; + public void setId(Long id) { this.id = id; @@ -662,6 +666,16 @@ public class EmsPcsData extends BaseEntity return sysWCurrent; } + public void setDwFrequency(BigDecimal dwFrequency) + { + this.dwFrequency = dwFrequency; + } + + public BigDecimal getDwFrequency() + { + return dwFrequency; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -716,6 +730,7 @@ public class EmsPcsData extends BaseEntity .append("sysUCurrent", getSysUCurrent()) .append("sysVCurrent", getSysVCurrent()) .append("sysWCurrent", getSysWCurrent()) + .append("dwFrequency", getDwFrequency()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 4bf03bb..e5724d4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -62,7 +62,6 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { batteryStackDataProcess(deviceId, jsonData); } else if (deviceId.contains("BMSC")) { - log.info("BMSC data:" + jsonData); batteryClusterDataProcess(deviceId, jsonData); batteryDataProcess(deviceId, jsonData); @@ -71,7 +70,11 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { pcsBranchDataProcess(deviceId, jsonData); } else if (deviceId.contains("LOAD")) { loadDataProcess(deviceId, jsonData); + } else if (deviceId.contains("METEGF")) { + log.info("METEGF DATA PROCESS"); + meteGFDataProcess(deviceId, jsonData); } else if (deviceId.contains("METE")) { + log.info("OTHER METE DATA PROCESS"); meteDataProcess(deviceId, jsonData); } } @@ -90,59 +93,33 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - // 电池堆状态数据设置 - dataStack.setOperationStatus(StringUtils.getString(obj.get("DCZT"))); - dataStack.setStackVoltage(StringUtils.getBigDecimal(obj.get("DCDDY"))); - dataStack.setStackCurrent(StringUtils.getBigDecimal(obj.get("DCDDL"))); - dataStack.setStackSoc(StringUtils.getBigDecimal(obj.get("DCDSOC"))); - dataStack.setStackSoh(StringUtils.getBigDecimal(obj.get("DCDSOH"))); - // 电压极值信息 - dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDCDY"))); - dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("ZGDCDYZH"))); - dataStack.setMaxVoltageCellId(StringUtils.getLong(obj.get("ZGDCDYZHDH"))); - dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDCDY"))); - dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("ZDDCDYZH"))); - dataStack.setMinVoltageCellId(StringUtils.getLong(obj.get("ZDDCDYZHDH"))); + dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("DTZDDY"))); + dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("DTZDDYXH"))); + dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("DTZXDY"))); + dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("DTZXDYXH"))); // 温度极值信息 - dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDCWD"))); - dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("ZGDCWDZH"))); - dataStack.setMaxTempCellId(StringUtils.getLong(obj.get("ZGDCWDZHDH"))); - dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDCWD"))); - dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("ZDDCWDZH"))); - dataStack.setMinTempCellId(StringUtils.getLong(obj.get("ZDDCWDZHDH"))); - - // 电量统计信息 - dataStack.setTotalChargeCapacity(StringUtils.getBigDecimal(obj.get("DLJCDDL"))); - dataStack.setTotalDischargeCapacity(StringUtils.getBigDecimal(obj.get("DLCFDDL"))); - dataStack.setSessionChargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJCDDL"))); - dataStack.setSessionDischargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJFDDL"))); - dataStack.setAvailableChargeCapacity(StringUtils.getBigDecimal(obj.get("DKCDL"))); - dataStack.setAvailableDischargeCapacity(StringUtils.getBigDecimal(obj.get("DKFDL"))); - -// 时间信息 - dataStack.setRemainingDischargeTime(StringUtils.getLong(obj.get("KYFDSJ"))); - dataStack.setRemainingChargeTime(StringUtils.getLong(obj.get("KYCDSJ"))); - -// 功率/电流限制 - dataStack.setMaxDischargePower(StringUtils.getBigDecimal(obj.get("YXZDFDGL"))); - dataStack.setMaxChargePower(StringUtils.getBigDecimal(obj.get("YXZDCDGL"))); - dataStack.setMaxDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDFDDL"))); - dataStack.setMaxChargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDCDDL"))); - - // 当日统计 - dataStack.setDailyDischargeCycles(StringUtils.getLong(obj.get("DTFDCS"))); - dataStack.setDailyChargeCycles(StringUtils.getLong(obj.get("DTCDCS"))); - dataStack.setDailyDischargeCapacity(StringUtils.getBigDecimal(obj.get("DTFDDL"))); - dataStack.setDailyChargeCapacity(StringUtils.getBigDecimal(obj.get("DTCDDL"))); - - // 系统状态 - dataStack.setOperatingTemp(StringUtils.getBigDecimal(obj.get("YXWD"))); - dataStack.setBmsStatus(StringUtils.getString(obj.get("BMSDDQZT"))); - dataStack.setBmsChargeStatus(StringUtils.getString(obj.get("BMSCFDZT"))); - dataStack.setStackInsulationResistance(StringUtils.getBigDecimal(obj.get("DCDJYDZ"))); + dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("DTZGWD"))); + dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("DTZGWDXH"))); + dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("DTZDWD"))); + dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("DTZDWDXH"))); + // 干节点信号状态 + dataStack.setBatteryNumber(StringUtils.getLong(obj.get("DTGS"))); + dataStack.setBatteryAvgVoltage(StringUtils.getBigDecimal(obj.get("DTPJDY"))); + dataStack.setBatteryDifferentPressure(StringUtils.getBigDecimal(obj.get("DTDCYC"))); + dataStack.setAvgTemperature(StringUtils.getBigDecimal(obj.get("DTPJWD"))); + dataStack.setBatteryDifferentTemperature(StringUtils.getBigDecimal(obj.get("DTDCWC"))); + dataStack.setMaxInternalResistance(StringUtils.getBigDecimal(obj.get("DTZDNZ"))); + dataStack.setMinInternalResistance(StringUtils.getBigDecimal(obj.get("DTZXNZ"))); + dataStack.setAvgInternalResistance(StringUtils.getBigDecimal(obj.get("DTPJNZ"))); + dataStack.setBatteryDefferentResistance(StringUtils.getBigDecimal(obj.get("DTDCNZC"))); + dataStack.setMaxResistanceCellId(StringUtils.getLong(obj.get("DTZDNZXH"))); + dataStack.setMinResistanceCellId(StringUtils.getLong(obj.get("DTZXNZXH"))); + dataStack.setEnvironmentTemperature(StringUtils.getBigDecimal(obj.get("HJWD"))); + dataStack.setEnvironmentHumidity(StringUtils.getBigDecimal(obj.get("HJSD"))); + dataStack.setCircuitBreakerStatus(StringUtils.getString(obj.get("LDQZT"))); dataStack.setCreateBy("system"); dataStack.setCreateTime(DateUtils.getNowDate()); @@ -173,43 +150,39 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { } //BMS 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); - // 设置所有 BigDecimal 类型字段为 ZERO - data.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); - data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); - data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); - data.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); - data.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); - data.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); - data.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - data.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); - data.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - data.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); - data.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); - data.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); - data.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); - data.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); - data.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); - data.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); - data.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); - data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); - data.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - data.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - data.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - data.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); - data.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); - data.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); - data.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); - data.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); - data.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); - data.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); - data.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); - data.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); - data.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); - data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); - data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); + // 电流电压功率 + data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZLDYZ"))); + data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZLDLZ"))); + data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("GLZ"))); + data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("ZZXYGDN1"))); + data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFXYGDN1"))); + + // 特殊字段 + data.setDisconnectDetectionIndication(StringUtils.getString(obj.get("DXJCZS"))); + data.setVoltageTransforRatio(StringUtils.getBigDecimal(obj.get("DYBB"))); + data.setRatedPrimaryCurrentValue(StringUtils.getBigDecimal(obj.get("EDYCDLZ"))); + data.setSwitchInputOutputStatus(StringUtils.getString(obj.get("KGLSRSCZT"))); + data.setAlarmStatus(StringUtils.getString(obj.get("BJZT"))); + data.setCurrentTotalVoltagePercent(StringUtils.getBigDecimal(obj.get("DQZDYBFB"))); + data.setVoltageContentPercent(StringUtils.getBigDecimal(obj.get("DYZLHLBFB"))); + data.setVoltageAcPercent(StringUtils.getBigDecimal(obj.get("DYJLHLBFB"))); + data.setCurrentTotalCurrentPercent(StringUtils.getBigDecimal(obj.get("DQZDLBFB"))); + data.setCurrentContentPercent(StringUtils.getBigDecimal(obj.get("DLZLHLBFB"))); + data.setCurrentAcPercent(StringUtils.getBigDecimal(obj.get("DLJLHLBFB"))); + data.setCurrentTotalPowerPercent(StringUtils.getBigDecimal(obj.get("DQZGLBFB"))); + data.setPowerContentPercent(StringUtils.getBigDecimal(obj.get("GLZLHLBFB"))); + data.setPowerAcPercent(StringUtils.getBigDecimal(obj.get("GLJLHLBFB"))); + data.setDataSettingYearMonth(StringUtils.getString(obj.get("RQSJSZNY"))); + data.setDataSettingDayHour(StringUtils.getString(obj.get("RQSJSZRS"))); + data.setDataSettingMinutesSeconds(StringUtils.getString(obj.get("RQSJSZFM"))); + data.setCurrentRate(StringUtils.getBigDecimal(obj.get("DQCBRFL"))); + data.setVersionNumber(StringUtils.getString(obj.get("RJBBH"))); + data.setVoltage(StringUtils.getBigDecimal(obj.get("DY"))); + data.setCurrent(StringUtils.getBigDecimal(obj.get("DL"))); + data.setPower(StringUtils.getBigDecimal(obj.get("GL"))); // 其他非 BigDecimal 字段 + data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("NBWD"))); data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); @@ -219,14 +192,6 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { data.setUpdateTime(DateUtils.getNowDate()); data.setSiteId(SITE_ID); data.setDeviceId(deviceId); - data.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD"))); - data.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD"))); - data.setMaxCellTempId(StringUtils.getLong(obj.get("ZGDTWDDYD"))); - data.setMinCellTempId(StringUtils.getLong(obj.get("ZDDTWDDYD"))); - data.setMaxCellSocId(StringUtils.getLong(obj.get("ZGDTSOCDYD"))); - data.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); - data.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); - data.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); if (StringUtils.isNotBlank(stackDeviceId)) { data.setStackDeviceId(stackDeviceId); } else { @@ -309,30 +274,22 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { pcsData.setDeviceStatus(DeviceStatus.ONLINE.getCode()); pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); + // 电流 + pcsData.setaPhaseCurrent(StringUtils.getBigDecimal(obj.get("PCSJLDLIA"))); + pcsData.setbPhaseCurrent(StringUtils.getBigDecimal(obj.get("PCSJLDLIB"))); + pcsData.setcPhaseCurrent(StringUtils.getBigDecimal(obj.get("PCSJLDLIC"))); + // 功率与能量类字段 + pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("ZLZGL"))); + pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ZLDY"))); + pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ZLDL"))); pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("JLYGGL"))); - pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("JLWGGL"))); - pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); - pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); - pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); - pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); - pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("ZCDL"))); - pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFDL"))); - pcsData.setAcChargeActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); - pcsData.setAcCapacitiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); - pcsData.setAcDischargeActivePower(StringUtils.getBigDecimal(obj.get("JLCFDYGGL"))); - pcsData.setAcInductiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCGXWGGL"))); - pcsData.setMaxCapacitivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDRXWGNL"))); - pcsData.setMaxInductivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDGXWGNL"))); - pcsData.setMaxChargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKCGL"))); - pcsData.setMaxDischargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKFGL"))); + pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("CDDN"))); + pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("FDDN"))); - - // 温度与环境参数 -// pcsData.setPcsModuleTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); -// pcsData.setPcsEnvironmentTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); -// pcsData.setAcFrequency(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + // 电网频率 + pcsData.setDwFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); // 状态指示类 pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); @@ -349,10 +306,6 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { pcsData.setSysVCurrent(StringUtils.getBigDecimal(obj.get("XTSCVXDL"))); pcsData.setSysWCurrent(StringUtils.getBigDecimal(obj.get("XTSCWXDL"))); - // 直流参数 -// pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); -// pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); - // 系统管理字段 pcsData.setCreateBy("system"); pcsData.setCreateTime(DateUtils.getNowDate()); @@ -381,28 +334,17 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { EmsPcsBranchData data = new EmsPcsBranchData(); data.setDeviceId(deviceId); data.setGridStatus(GridStatus.GRID.getCode()); - data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); - data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); - data.setDcCurrent(StringUtils.getBigDecimal(fields.get("ZLDL"))); - data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWVXDY"))); - data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWUXDY"))); - data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWWXDY"))); - data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("SCUXDL"))); - data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("SCVXDL"))); - data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("SCWXDL"))); - data.setApparentPower(StringUtils.getBigDecimal(fields.get("SZGL"))); - data.setActivePower(StringUtils.getBigDecimal(fields.get("YGGL"))); - data.setReactivePower(StringUtils.getBigDecimal(fields.get("WGGL"))); - data.setPowerFactor(StringUtils.getBigDecimal(fields.get("GLYS"))); - data.setFrequency(StringUtils.getBigDecimal(fields.get("PL"))); - data.setInternalTemp(StringUtils.getBigDecimal(fields.get("DY1WD"))); - data.setuIgbtTemp(StringUtils.getBigDecimal(fields.get("UXIGBTWD"))); - data.setvIgbtTemp(StringUtils.getBigDecimal(fields.get("VXIGBTWD"))); - data.setwIgbtTemp(StringUtils.getBigDecimal(fields.get("WXIGBTWD"))); - data.setAvailablePower(StringUtils.getBigDecimal(fields.get("KYGL"))); - data.setTotalLoadRatio(StringUtils.getBigDecimal(fields.get("ZFZB"))); - data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); - data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); + data.setDcPower(StringUtils.getBigDecimal(fields.get("BMSC01ZLSCGL"))); + data.setDcVoltage(StringUtils.getBigDecimal(fields.get("BMSC01ZLDY"))); + data.setDcCurrent(StringUtils.getBigDecimal(fields.get("BMSC01ZLDL"))); + + data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUAB"))); + data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUBC"))); + data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUCA"))); + data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("PCSJLDLIA"))); + data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("PCSJLDLIB"))); + data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("PCSJLDLIC"))); + data.setBranchId(recordId); list.add(data); } @@ -415,6 +357,70 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { } + private void meteGFDataProcess(String deviceId, String dataJson) { + + //总表 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + EmsAmmeterData dataGF = new EmsAmmeterData(); + // 更新时间 + dataGF.setDataUpdateTime(new Date()); + + // 电压+电流 - dds字段 + dataGF.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataGF.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataGF.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataGF.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataGF.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataGF.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + + dataGF.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataGF.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); + dataGF.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); + + // 频率 + dataGF.setFrequency(StringUtils.getBigDecimal(obj.get("PL"))); + + // 功率 有功+总+无功+无总+视在 + dataGF.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataGF.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataGF.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataGF.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataGF.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataGF.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataGF.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataGF.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataGF.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); + dataGF.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); + dataGF.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); + dataGF.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + + // 功率因数 + dataGF.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); + dataGF.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); + dataGF.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); + dataGF.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + + // 其他字段 + dataGF.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("WGDN"))); + dataGF.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("WGDN"))); + dataGF.setCurrentPercent(StringUtils.getBigDecimal(obj.get("DLBB"))); + dataGF.setVoltagePercent(StringUtils.getBigDecimal(obj.get("DYBB"))); + dataGF.setAvgCurrent(StringUtils.getBigDecimal(obj.get("PJDL"))); + + dataGF.setCreateBy("system"); + dataGF.setCreateTime(DateUtils.getNowDate()); + dataGF.setUpdateBy("system"); + dataGF.setUpdateTime(DateUtils.getNowDate()); + dataGF.setSiteId(SITE_ID); + dataGF.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataGF); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataGF); + } + private void loadDataProcess(String deviceId, String dataJson) { //总表 @@ -460,20 +466,15 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { dataLoad.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); - // 需量 - dataLoad.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); - dataLoad.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); - dataLoad.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); - // 电度 - dataLoad.setAbsorbsActiveEnerygSecondSide(StringUtils.getBigDecimal(obj.get("XSYGDDECC"))); - dataLoad.setReleaseActiveEnerygSecondSide(StringUtils.getBigDecimal(obj.get("SFTGDDECC"))); - dataLoad.setInductorReactiveEnerySecondeSide(StringUtils.getBigDecimal(obj.get("GXWGDDECC"))); - dataLoad.setCapacitorReactiveEnerySecondeSide(StringUtils.getBigDecimal(obj.get("RXWGDDECC"))); - dataLoad.setAbsorbsActiveEnerygOneSide(StringUtils.getBigDecimal(obj.get("XSYGDDYCC"))); - dataLoad.setReleaseActiveEnerygOneSide(StringUtils.getBigDecimal(obj.get("SFYGDDYCC"))); - dataLoad.setInductorReactiveEneryOneSide(StringUtils.getBigDecimal(obj.get("GXWGDDYCC"))); - dataLoad.setCapacitorReactiveEneryOneSide(StringUtils.getBigDecimal(obj.get("RXWGDDYCC"))); + dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("GXWGDDECC"))); + dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("SFTGDDECC"))); + dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("RXWGDDECC"))); + dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("XSYGDDECC"))); + dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("RXWGDDYCC"))); + dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("SFYGDDYCC"))); + dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("GXWGDDYCC"))); + dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("XSYGDDYCC"))); dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 0c27240..ec1fdfc 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -107,18 +107,13 @@ - - - - - - - - + + + - select id, data_update_time, current_comb_active_total, current_comb_active_peak, current_comb_active_high, current_comb_active_flat, current_comb_active_valley, current_forward_active_total, current_forward_active_peak, current_forward_active_high, current_forward_active_flat, current_forward_active_valley, current_reverse_active_total, current_reverse_active_peak, current_reverse_active_high, current_reverse_active_flat, current_reverse_active_valley, current_comb_reactive_total, current_comb_reactive_peak, current_comb_reactive_high, current_comb_reactive_flat, current_comb_reactive_valley, current_forward_reactive_total, current_forward_reactive_peak, current_forward_reactive_high, current_forward_reactive_flat, current_forward_reactive_valley, current_reverse_reactive_total, current_reverse_reactive_peak, current_reverse_reactive_high, current_reverse_reactive_flat, current_reverse_reactive_valley, phase_a_voltage, phase_b_voltage, phase_c_voltage, phase_a_current, phase_b_current, phase_c_current, frequency, ab_line_voltage, cb_line_voltage, ac_line_voltage, forward_ac_max_demand, reverse_ac_max_demand, phase_a_active_power, phase_b_active_power, phase_c_active_power, total_active_power, phase_a_reactive_power, phase_b_reactive_power, phase_c_reactive_power, total_reactive_power, phase_a_apparent_power, phase_b_apparent_power, phase_c_apparent_power, total_apparent_power, phase_a_power_factor, phase_b_power_factor, phase_c_power_factor, total_power_factor, daily_forward_max_demand, site_id, device_id, create_by, create_time, update_by, update_time, remark, secondary_ab_line_voltage, secondary_a_phase_current, secondary_a_phase_voltage, secondary_a_power_factor, secondary_a_apparent_power, secondary_a_reactive_power, secondary_a_active_power, secondary_bc_line_voltage, secondary_b_phase_current, secondary_b_phase_voltage, secondary_b_power_factor, secondary_b_apparent_power, secondary_b_reactive_power, secondary_b_active_power, secondary_ca_line_voltage, secondary_c_phase_current, secondary_c_phase_voltage, secondary_c_power_factor, secondary_c_apparent_power, secondary_c_reactive_power, secondary_c_active_power, secondary_grid_frequency, secondary_reverse_reactive_energy, secondary_negative_active_energy, secondary_total_power_factor, secondary_total_apparent_power, secondary_total_reactive_power, secondary_positive_reactive_energy, secondary_positive_active_energy, secondary_total_active_power, reverse_reactive_energy_eq_minus, reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus, absorbs_active_eneryg_second_side, release_active_eneryg_second_side, inductor_reactive_enery_seconde_side, capacitor_reactive_enery_seconde_side, absorbs_active_eneryg_one_side, release_active_eneryg_one_side, inductor_reactive_enery_one_side, capacitor_reactive_enery_one_side from ems_ammeter_data + select id, data_update_time, current_comb_active_total, current_comb_active_peak, current_comb_active_high, current_comb_active_flat, current_comb_active_valley, current_forward_active_total, current_forward_active_peak, current_forward_active_high, current_forward_active_flat, current_forward_active_valley, current_reverse_active_total, current_reverse_active_peak, current_reverse_active_high, current_reverse_active_flat, current_reverse_active_valley, current_comb_reactive_total, current_comb_reactive_peak, current_comb_reactive_high, current_comb_reactive_flat, current_comb_reactive_valley, current_forward_reactive_total, current_forward_reactive_peak, current_forward_reactive_high, current_forward_reactive_flat, current_forward_reactive_valley, current_reverse_reactive_total, current_reverse_reactive_peak, current_reverse_reactive_high, current_reverse_reactive_flat, current_reverse_reactive_valley, phase_a_voltage, phase_b_voltage, phase_c_voltage, phase_a_current, phase_b_current, phase_c_current, frequency, ab_line_voltage, cb_line_voltage, ac_line_voltage, forward_ac_max_demand, reverse_ac_max_demand, phase_a_active_power, phase_b_active_power, phase_c_active_power, total_active_power, phase_a_reactive_power, phase_b_reactive_power, phase_c_reactive_power, total_reactive_power, phase_a_apparent_power, phase_b_apparent_power, phase_c_apparent_power, total_apparent_power, phase_a_power_factor, phase_b_power_factor, phase_c_power_factor, total_power_factor, daily_forward_max_demand, site_id, device_id, create_by, create_time, update_by, update_time, remark, secondary_ab_line_voltage, secondary_a_phase_current, secondary_a_phase_voltage, secondary_a_power_factor, secondary_a_apparent_power, secondary_a_reactive_power, secondary_a_active_power, secondary_bc_line_voltage, secondary_b_phase_current, secondary_b_phase_voltage, secondary_b_power_factor, secondary_b_apparent_power, secondary_b_reactive_power, secondary_b_active_power, secondary_ca_line_voltage, secondary_c_phase_current, secondary_c_phase_voltage, secondary_c_power_factor, secondary_c_apparent_power, secondary_c_reactive_power, secondary_c_active_power, secondary_grid_frequency, secondary_reverse_reactive_energy, secondary_negative_active_energy, secondary_total_power_factor, secondary_total_apparent_power, secondary_total_reactive_power, secondary_positive_reactive_energy, secondary_positive_active_energy, secondary_total_active_power, reverse_reactive_energy_eq_minus, reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus, current_percent, voltage_percent, avg_current from ems_ammeter_data @@ -340,14 +330,9 @@ reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus, - absorbs_active_eneryg_second_side, - release_active_eneryg_second_side, - inductor_reactive_enery_seconde_side, - capacitor_reactive_enery_seconde_side, - absorbs_active_eneryg_one_side, - release_active_eneryg_one_side, - inductor_reactive_enery_one_side, - capacitor_reactive_enery_one_side, + current_percent, + voltage_percent, + avg_current, #{dataUpdateTime}, @@ -451,14 +436,9 @@ #{reverseActiveEnergyEpMinus}, #{positiveReactiveEnergyEqPlus}, #{positiveActiveEnergyEpPlus}, - #{absorbsActiveEnerygSecondSide}, - #{releaseActiveEnerygSecondSide}, - #{inductorReactiveEnerySecondeSide}, - #{capacitorReactiveEnerySecondeSide}, - #{absorbsActiveEnerygOneSide}, - #{releaseActiveEnerygOneSide}, - #{inductorReactiveEneryOneSide}, - #{capacitorReactiveEneryOneSide}, + #{currentPercent}, + #{voltagePercent}, + #{avgCurrent}, @@ -566,14 +546,9 @@ reverse_active_energy_ep_minus = #{reverseActiveEnergyEpMinus}, positive_reactive_energy_eq_plus = #{positiveReactiveEnergyEqPlus}, positive_active_energy_ep_plus = #{positiveActiveEnergyEpPlus}, - absorbs_active_eneryg_second_side = #{absorbsActiveEnerygSecondSide}, - release_active_eneryg_second_side = #{releaseActiveEnerygSecondSide}, - inductor_reactive_enery_seconde_side = #{inductorReactiveEnerySecondeSide}, - capacitor_reactive_enery_seconde_side = #{capacitorReactiveEnerySecondeSide}, - absorbs_active_eneryg_one_side = #{absorbsActiveEnerygOneSide}, - release_active_eneryg_one_side = #{releaseActiveEnerygOneSide}, - inductor_reactive_enery_one_side = #{inductorReactiveEneryOneSide}, - capacitor_reactive_enery_one_side = #{capacitorReactiveEneryOneSide}, + current_percent = #{currentPercent}, + voltage_percent = #{voltagePercent}, + avg_current = #{avgCurrent}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 55be7aa..3522724 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -59,10 +59,32 @@ + + + + + + + + + + + + + + + + + + + + + + - select id, work_status, pcs_communication_status, ems_communication_status, cluster_voltage, chargeable_capacity, total_charged_capacity, cluster_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id, stack_device_id, max_allowed_charge_power, max_allowed_discharge_power, max_allowed_charge_voltage, max_allowed_discharge_voltage, max_allowed_charge_current, max_allowed_discharge_current, battery_pack_voltage, battery_pack_current, battery_pack_temp, battery_pack_soc, battery_pack_soh, battery_pack_insulation_resistance, avg_cell_voltage, avg_cell_temp, max_cell_voltage, max_cell_voltage_id, min_cell_voltage, min_cell_voltage_id, max_cell_temp, max_cell_temp_id, min_cell_temp, min_cell_temp_id, max_cell_soc, max_cell_soc_id, min_cell_soc, min_cell_soc_id, max_cell_soh, max_cell_soh_id, min_cell_soh, min_cell_soh_id, total_charge_energy, total_discharge_energy from ems_battery_cluster + select id, work_status, pcs_communication_status, ems_communication_status, cluster_voltage, chargeable_capacity, total_charged_capacity, cluster_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id, stack_device_id, max_allowed_charge_power, max_allowed_discharge_power, max_allowed_charge_voltage, max_allowed_discharge_voltage, max_allowed_charge_current, max_allowed_discharge_current, battery_pack_voltage, battery_pack_current, battery_pack_temp, battery_pack_soc, battery_pack_soh, battery_pack_insulation_resistance, avg_cell_voltage, avg_cell_temp, max_cell_voltage, max_cell_voltage_id, min_cell_voltage, min_cell_voltage_id, max_cell_temp, max_cell_temp_id, min_cell_temp, min_cell_temp_id, max_cell_soc, max_cell_soc_id, min_cell_soc, min_cell_soc_id, max_cell_soh, max_cell_soh_id, min_cell_soh, min_cell_soh_id, total_charge_energy, total_discharge_energy, disconnect_detection_indication, voltage_transfor_ratio, rated_primary_current_value, switch_input_output_status, alarm_status, current_total_voltage_percent, voltage_content_percent, voltage_ac_percent, current_total_current_percent, current_content_percent, current_ac_percent, current_total_power_percent, power_content_percent, power_ac_percent, data_setting_year_month, data_setting_day_hour, data_setting_minutes_seconds, current_rate, version_number, voltage, current, power from ems_battery_cluster @@ -180,6 +224,28 @@ min_cell_soh_id, total_charge_energy, total_discharge_energy, + disconnect_detection_indication, + voltage_transfor_ratio, + rated_primary_current_value, + switch_input_output_status, + alarm_status, + current_total_voltage_percent, + voltage_content_percent, + voltage_ac_percent, + current_total_current_percent, + current_content_percent, + current_ac_percent, + current_total_power_percent, + power_content_percent, + power_ac_percent, + data_setting_year_month, + data_setting_day_hour, + data_setting_minutes_seconds, + current_rate, + version_number, + voltage, + current, + power, #{workStatus}, @@ -235,6 +301,28 @@ #{minCellSohId}, #{totalChargeEnergy}, #{totalDischargeEnergy}, + #{disconnectDetectionIndication}, + #{voltageTransforRatio}, + #{ratedPrimaryCurrentValue}, + #{switchInputOutputStatus}, + #{alarmStatus}, + #{currentTotalVoltagePercent}, + #{voltageContentPercent}, + #{voltageAcPercent}, + #{currentTotalCurrentPercent}, + #{currentContentPercent}, + #{currentAcPercent}, + #{currentTotalPowerPercent}, + #{powerContentPercent}, + #{powerAcPercent}, + #{dataSettingYearMonth}, + #{dataSettingDayHour}, + #{dataSettingMinutesSeconds}, + #{currentRate}, + #{versionNumber}, + #{voltage}, + #{current}, + #{power}, @@ -294,6 +382,28 @@ min_cell_soh_id = #{minCellSohId}, total_charge_energy = #{totalChargeEnergy}, total_discharge_energy = #{totalDischargeEnergy}, + disconnect_detection_indication = #{disconnectDetectionIndication}, + voltage_transfor_ratio = #{voltageTransforRatio}, + rated_primary_current_value = #{ratedPrimaryCurrentValue}, + switch_input_output_status = #{switchInputOutputStatus}, + alarm_status = #{alarmStatus}, + current_total_voltage_percent = #{currentTotalVoltagePercent}, + voltage_content_percent = #{voltageContentPercent}, + voltage_ac_percent = #{voltageAcPercent}, + current_total_current_percent = #{currentTotalCurrentPercent}, + current_content_percent = #{currentContentPercent}, + current_ac_percent = #{currentAcPercent}, + current_total_power_percent = #{currentTotalPowerPercent}, + power_content_percent = #{powerContentPercent}, + power_ac_percent = #{powerAcPercent}, + data_setting_year_month = #{dataSettingYearMonth}, + data_setting_day_hour = #{dataSettingDayHour}, + data_setting_minutes_seconds = #{dataSettingMinutesSeconds}, + current_rate = #{currentRate}, + version_number = #{versionNumber}, + voltage = #{voltage}, + current = #{current}, + power = #{power}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 1687a91..869d635 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -52,10 +52,24 @@ + + + + + + + + + + + + + + - select id, work_status, pcs_communication_status, ems_communication_status, operation_status, stack_voltage, stack_current, stack_soc, stack_soh, max_cell_voltage, max_voltage_group_id, max_voltage_cell_id, min_cell_voltage, min_voltage_group_id, min_voltage_cell_id, max_cell_temp, max_temp_group_id, max_temp_cell_id, min_cell_temp, min_temp_group_id, min_temp_cell_id, total_charge_capacity, total_discharge_capacity, session_charge_capacity, session_discharge_capacity, available_charge_capacity, available_discharge_capacity, remaining_discharge_time, remaining_charge_time, max_discharge_power, max_charge_power, max_discharge_current, max_charge_current, daily_discharge_cycles, daily_charge_cycles, daily_discharge_capacity, daily_charge_capacity, operating_temp, bms_status, bms_charge_status, stack_insulation_resistance, site_id, device_id, create_time, create_by, update_time, update_by from ems_battery_stack + select id, work_status, pcs_communication_status, ems_communication_status, operation_status, stack_voltage, stack_current, stack_soc, stack_soh, max_cell_voltage, max_voltage_group_id, max_voltage_cell_id, min_cell_voltage, min_voltage_group_id, min_voltage_cell_id, max_cell_temp, max_temp_group_id, max_temp_cell_id, min_cell_temp, min_temp_group_id, min_temp_cell_id, total_charge_capacity, total_discharge_capacity, session_charge_capacity, session_discharge_capacity, available_charge_capacity, available_discharge_capacity, remaining_discharge_time, remaining_charge_time, max_discharge_power, max_charge_power, max_discharge_current, max_charge_current, daily_discharge_cycles, daily_charge_cycles, daily_discharge_capacity, daily_charge_capacity, operating_temp, bms_status, bms_charge_status, stack_insulation_resistance, site_id, device_id, create_time, create_by, update_time, update_by, battery_number, battery_avg_voltage, battery_different_pressure, avg_temperature, battery_different_temperature, max_internal_resistance, min_internal_resistance, avg_internal_resistance, battery_defferent_resistance, max_resistance_cell_id, min_resistance_cell_id, environment_temperature, environment_humidity, circuit_breaker_status from ems_battery_stack @@ -160,6 +188,20 @@ create_by, update_time, update_by, + battery_number, + battery_avg_voltage, + battery_different_pressure, + avg_temperature, + battery_different_temperature, + max_internal_resistance, + min_internal_resistance, + avg_internal_resistance, + battery_defferent_resistance, + max_resistance_cell_id, + min_resistance_cell_id, + environment_temperature, + environment_humidity, + circuit_breaker_status, #{workStatus}, @@ -208,6 +250,20 @@ #{createBy}, #{updateTime}, #{updateBy}, + #{batteryNumber}, + #{batteryAvgVoltage}, + #{batteryDifferentPressure}, + #{avgTemperature}, + #{batteryDifferentTemperature}, + #{maxInternalResistance}, + #{minInternalResistance}, + #{avgInternalResistance}, + #{batteryDefferentResistance}, + #{maxResistanceCellId}, + #{minResistanceCellId}, + #{environmentTemperature}, + #{environmentHumidity}, + #{circuitBreakerStatus}, @@ -260,6 +316,20 @@ create_by = #{createBy}, update_time = #{updateTime}, update_by = #{updateBy}, + battery_number = #{batteryNumber}, + battery_avg_voltage = #{batteryAvgVoltage}, + battery_different_pressure = #{batteryDifferentPressure}, + avg_temperature = #{avgTemperature}, + battery_different_temperature = #{batteryDifferentTemperature}, + max_internal_resistance = #{maxInternalResistance}, + min_internal_resistance = #{minInternalResistance}, + avg_internal_resistance = #{avgInternalResistance}, + battery_defferent_resistance = #{batteryDefferentResistance}, + max_resistance_cell_id = #{maxResistanceCellId}, + min_resistance_cell_id = #{minResistanceCellId}, + environment_temperature = #{environmentTemperature}, + environment_humidity = #{environmentHumidity}, + circuit_breaker_status = #{circuitBreakerStatus}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 0bf766c..40036d6 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -56,10 +56,11 @@ + - select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, date_month, date_day, total_ac_charge_energy, total_ac_discharge_energy, ac_charge_active_power, ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, remote_control_status, sys_u_current, sys_v_current, sys_w_current from ems_pcs_data + select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, date_month, date_day, total_ac_charge_energy, total_ac_discharge_energy, ac_charge_active_power, ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, remote_control_status, sys_u_current, sys_v_current, sys_w_current, dw_frequency from ems_pcs_data @@ -171,6 +173,7 @@ sys_u_current, sys_v_current, sys_w_current, + dw_frequency, #{dataUpdateTime}, @@ -223,6 +226,7 @@ #{sysUCurrent}, #{sysVCurrent}, #{sysWCurrent}, + #{dwFrequency}, @@ -279,6 +283,7 @@ sys_u_current = #{sysUCurrent}, sys_v_current = #{sysVCurrent}, sys_w_current = #{sysWCurrent}, + dw_frequency = #{dwFrequency}, where id = #{id} -- 2.49.0 From 8fd2f45e18baac500611940b89654149446d3e2e Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 29 Jul 2025 15:58:26 +0800 Subject: [PATCH 111/336] =?UTF-8?q?DDS=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 10 + .../com/xzzn/ems/domain/EmsAmmeterData.java | 887 +++++++++++++++++- .../xzzn/ems/domain/EmsBatteryCluster.java | 332 +------ .../com/xzzn/ems/domain/EmsBatteryData.java | 17 +- .../com/xzzn/ems/domain/EmsBatteryGroup.java | 164 ++++ .../java/com/xzzn/ems/domain/EmsDhData.java | 104 ++ .../ems/mapper/EmsBatteryGroupMapper.java | 64 ++ .../com/xzzn/ems/mapper/EmsDhDataMapper.java | 61 ++ .../impl/DDSDataProcessServiceImpl.java | 556 +++++++---- .../mapper/ems/EmsAmmeterDataMapper.xml | 297 +++++- .../mapper/ems/EmsBatteryClusterMapper.xml | 112 +-- .../mapper/ems/EmsBatteryDataMapper.xml | 11 +- .../mapper/ems/EmsBatteryGroupMapper.xml | 148 +++ .../resources/mapper/ems/EmsDhDataMapper.xml | 91 ++ 14 files changed, 2246 insertions(+), 608 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryGroup.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsDhData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryGroupMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsDhDataMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsBatteryGroupMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsDhDataMapper.xml diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 986830b..0e3b343 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -36,4 +36,14 @@ public class RedisKeyConstants * 电表数据 redis key */ public static final String AMMETER = "AMMETER_"; + + /** + * 动环数据 redis key + */ + public static final String DH = "DH_"; + + /** + * 电池组 redis key + */ + public static final String GROUP = "GROUP_"; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java index beacd93..d62e835 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAmmeterData.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * 总数据对象 ems_ammeter_data * * @author xzzn - * @date 2025-07-27 + * @date 2025-07-29 */ public class EmsAmmeterData extends BaseEntity { @@ -418,6 +418,242 @@ public class EmsAmmeterData extends BaseEntity @Excel(name = "平均电流") private BigDecimal avgCurrent; + /** 总正向有功电能2 */ + @Excel(name = "总正向有功电能2") + private BigDecimal totalForwardActiveTwo; + + /** 总尖正向有功电能 */ + @Excel(name = "总尖正向有功电能") + private BigDecimal totalPeakForwardActive; + + /** 总峰正向有功电能 */ + @Excel(name = "总峰正向有功电能") + private BigDecimal totalHighForwardActive; + + /** 总平正向有功电能 */ + @Excel(name = "总平正向有功电能") + private BigDecimal totalFlatForwardActive; + + /** 总谷正向有功电能 */ + @Excel(name = "总谷正向有功电能") + private BigDecimal totalValleyForwardActive; + + /** 总反向有功电能2 */ + @Excel(name = "总反向有功电能2") + private BigDecimal totalReverseActiveTwo; + + /** 总尖反向有功电能 */ + @Excel(name = "总尖反向有功电能") + private BigDecimal totalPeakReverseActive; + + /** 总峰反向有功电能 */ + @Excel(name = "总峰反向有功电能") + private BigDecimal totalHighReverseActive; + + /** 总平反向有功电能 */ + @Excel(name = "总平反向有功电能") + private BigDecimal totalFlatReverseActive; + + /** 总谷反向有功电能 */ + @Excel(name = "总谷反向有功电能") + private BigDecimal totalValleyReverseActive; + + /** 断线检测指示 */ + @Excel(name = "断线检测指示") + private String disconnectDetectionIndication; + + /** 额定一次电流值 */ + @Excel(name = "额定一次电流值") + private BigDecimal ratedPrimaryCurrentValue; + + /** 开关量输入输出状态 */ + @Excel(name = "开关量输入输出状态") + private String switchInputOutputStatus; + + /** 报警状态 */ + @Excel(name = "报警状态") + private String alarmStatus; + + /** 当前总电压百分比 */ + @Excel(name = "当前总电压百分比") + private BigDecimal currentTotalVoltagePercent; + + /** 电压直流含量百分比 */ + @Excel(name = "电压直流含量百分比") + private BigDecimal voltageContentPercent; + + /** 电压交流含量百分比 */ + @Excel(name = "电压交流含量百分比") + private BigDecimal voltageAcPercent; + + /** 当前总电流百分比 */ + @Excel(name = "当前总电流百分比") + private BigDecimal currentTotalCurrentPercent; + + /** 电流直流含量百分比 */ + @Excel(name = "电流直流含量百分比") + private BigDecimal currentContentPercent; + + /** 电流交流含量百分比 */ + @Excel(name = "电流交流含量百分比") + private BigDecimal currentAcPercent; + + /** 当前总功率百分比 */ + @Excel(name = "当前总功率百分比") + private BigDecimal currentTotalPowerPercent; + + /** 功率直流含量百分比 */ + @Excel(name = "功率直流含量百分比") + private BigDecimal powerContentPercent; + + /** 功率交流含量百分比 */ + @Excel(name = "功率交流含量百分比") + private BigDecimal powerAcPercent; + + /** 日期时间设置(年月) */ + @Excel(name = "日期时间设置", readConverterExp = "年=月") + private String dataSettingYearMonth; + + /** 日期时间设置(日时) */ + @Excel(name = "日期时间设置", readConverterExp = "日=时") + private String dataSettingDayHour; + + /** 日期时间设置(分秒) */ + @Excel(name = "日期时间设置", readConverterExp = "分=秒") + private String dataSettingMinutesSeconds; + + /** 当前抄表日(高)、当前费率(低) */ + @Excel(name = "当前抄表日", readConverterExp = "高=") + private BigDecimal currentRate; + + /** 软件版本号 */ + @Excel(name = "软件版本号") + private String versionNumber; + + /** 电压 */ + @Excel(name = "电压") + private BigDecimal voltage; + + /** 电流 */ + @Excel(name = "电流") + private BigDecimal current; + + /** 功率 */ + @Excel(name = "功率") + private BigDecimal power; + + /** 内部温度 */ + @Excel(name = "内部温度") + private BigDecimal internalTemp; + + /** 总正向有功电能1 */ + @Excel(name = "总正向有功电能1") + private BigDecimal totalForwardActiveOne; + + /** 总反向有功电能1 */ + @Excel(name = "总反向有功电能1") + private BigDecimal totalReverseActiveOne; + + /** 正向无功最大需量 */ + @Excel(name = "正向无功最大需量") + private BigDecimal forwardReactiveMaxDemand; + + /** 反向无功最大需量 */ + @Excel(name = "反向无功最大需量") + private BigDecimal reverseReactiveMaxDemand; + + /** A 相正向有功电能 */ + @Excel(name = "A 相正向有功电能") + private BigDecimal aForwardActiveEnergy; + + /** B 相正向有功电能 */ + @Excel(name = "B 相正向有功电能") + private BigDecimal bForwardActiveEnergy; + + /** C 相正向有功电能 */ + @Excel(name = "C 相正向有功电能") + private BigDecimal cForwardActiveEnergy; + + /** DIDO 状态、失压状态 */ + @Excel(name = "DIDO 状态、失压状态") + private String didoStatus; + + /** 运行状态 1(高 8 位)/运行状态 2(低 8 位) */ + @Excel(name = "运行状态 1", readConverterExp = "高=,8=,位=") + private String runningStatus; + + /** 零序电流 */ + @Excel(name = "零序电流") + private BigDecimal zeroSeqCurrent; + + /** 电压不平衡度 */ + @Excel(name = "电压不平衡度") + private BigDecimal voltageUnbalanceDegree; + + /** 电流不平衡度 */ + @Excel(name = "电流不平衡度") + private BigDecimal currentUnbalanceDegree; + + /** 当日反向有功最大需量 */ + @Excel(name = "当日反向有功最大需量") + private BigDecimal dailyReverseAcMaxDemand; + + /** 当日正向无功最大需量 */ + @Excel(name = "当日正向无功最大需量") + private BigDecimal dailyForwardReacMaxDemand; + + /** 当日反向无功最大需量 */ + @Excel(name = "当日反向无功最大需量") + private BigDecimal dailyReverseReacMaxDemand; + + /** 上 1 日正向有功最大需量 */ + @Excel(name = "上 1 日正向有功最大需量") + private BigDecimal preDayForwardAcMaxDemand; + + /** 上 1 日反向有功最大需量 */ + @Excel(name = "上 1 日反向有功最大需量") + private BigDecimal preDayReverseAcMaxDemand; + + /** 上 1 日正向无功最大需量 */ + @Excel(name = "上 1 日正向无功最大需量") + private BigDecimal preDayForwardReacMaxDemand; + + /** 上 1 日反向无功最大需量 */ + @Excel(name = "上 1 日反向无功最大需量") + private BigDecimal preDayReverseReacMaxDemand; + + /** 上 2 日正向有功最大需量 */ + @Excel(name = "上 2 日正向有功最大需量") + private BigDecimal pre2dForwardAcMaxDemand; + + /** 上 2 日反向有功最大需量 */ + @Excel(name = "上 2 日反向有功最大需量") + private BigDecimal pre2dReverseAcMaxDemand; + + /** 上 2 日正向无功最大需量 */ + @Excel(name = "上 2 日正向无功最大需量") + private BigDecimal pre2dForwardReacMaxDemand; + + /** 上 2 日反向无功最大需量 */ + @Excel(name = "上 2 日反向无功最大需量") + private BigDecimal pre2dReverseReacMaxDemand; + + /** 当前正向有功需量 */ + @Excel(name = "当前正向有功需量") + private BigDecimal currentForwardAcDemand; + + /** 当前反向有功需量 */ + @Excel(name = "当前反向有功需量") + private BigDecimal currentReverseAcDemand; + + /** 当前正向无功需量 */ + @Excel(name = "当前正向无功需量") + private BigDecimal currentForwardReacDemand; + + /** 当前反向无功需量 */ + @Excel(name = "当前反向无功需量") + private BigDecimal currentReverseReacDemand; + public void setId(Long id) { this.id = id; @@ -1418,6 +1654,596 @@ public class EmsAmmeterData extends BaseEntity return avgCurrent; } + public void setTotalForwardActiveTwo(BigDecimal totalForwardActiveTwo) + { + this.totalForwardActiveTwo = totalForwardActiveTwo; + } + + public BigDecimal getTotalForwardActiveTwo() + { + return totalForwardActiveTwo; + } + + public void setTotalPeakForwardActive(BigDecimal totalPeakForwardActive) + { + this.totalPeakForwardActive = totalPeakForwardActive; + } + + public BigDecimal getTotalPeakForwardActive() + { + return totalPeakForwardActive; + } + + public void setTotalHighForwardActive(BigDecimal totalHighForwardActive) + { + this.totalHighForwardActive = totalHighForwardActive; + } + + public BigDecimal getTotalHighForwardActive() + { + return totalHighForwardActive; + } + + public void setTotalFlatForwardActive(BigDecimal totalFlatForwardActive) + { + this.totalFlatForwardActive = totalFlatForwardActive; + } + + public BigDecimal getTotalFlatForwardActive() + { + return totalFlatForwardActive; + } + + public void setTotalValleyForwardActive(BigDecimal totalValleyForwardActive) + { + this.totalValleyForwardActive = totalValleyForwardActive; + } + + public BigDecimal getTotalValleyForwardActive() + { + return totalValleyForwardActive; + } + + public void setTotalReverseActiveTwo(BigDecimal totalReverseActiveTwo) + { + this.totalReverseActiveTwo = totalReverseActiveTwo; + } + + public BigDecimal getTotalReverseActiveTwo() + { + return totalReverseActiveTwo; + } + + public void setTotalPeakReverseActive(BigDecimal totalPeakReverseActive) + { + this.totalPeakReverseActive = totalPeakReverseActive; + } + + public BigDecimal getTotalPeakReverseActive() + { + return totalPeakReverseActive; + } + + public void setTotalHighReverseActive(BigDecimal totalHighReverseActive) + { + this.totalHighReverseActive = totalHighReverseActive; + } + + public BigDecimal getTotalHighReverseActive() + { + return totalHighReverseActive; + } + + public void setTotalFlatReverseActive(BigDecimal totalFlatReverseActive) + { + this.totalFlatReverseActive = totalFlatReverseActive; + } + + public BigDecimal getTotalFlatReverseActive() + { + return totalFlatReverseActive; + } + + public void setTotalValleyReverseActive(BigDecimal totalValleyReverseActive) + { + this.totalValleyReverseActive = totalValleyReverseActive; + } + + public BigDecimal getTotalValleyReverseActive() + { + return totalValleyReverseActive; + } + + public void setDisconnectDetectionIndication(String disconnectDetectionIndication) + { + this.disconnectDetectionIndication = disconnectDetectionIndication; + } + + public String getDisconnectDetectionIndication() + { + return disconnectDetectionIndication; + } + + public void setRatedPrimaryCurrentValue(BigDecimal ratedPrimaryCurrentValue) + { + this.ratedPrimaryCurrentValue = ratedPrimaryCurrentValue; + } + + public BigDecimal getRatedPrimaryCurrentValue() + { + return ratedPrimaryCurrentValue; + } + + public void setSwitchInputOutputStatus(String switchInputOutputStatus) + { + this.switchInputOutputStatus = switchInputOutputStatus; + } + + public String getSwitchInputOutputStatus() + { + return switchInputOutputStatus; + } + + public void setAlarmStatus(String alarmStatus) + { + this.alarmStatus = alarmStatus; + } + + public String getAlarmStatus() + { + return alarmStatus; + } + + public void setCurrentTotalVoltagePercent(BigDecimal currentTotalVoltagePercent) + { + this.currentTotalVoltagePercent = currentTotalVoltagePercent; + } + + public BigDecimal getCurrentTotalVoltagePercent() + { + return currentTotalVoltagePercent; + } + + public void setVoltageContentPercent(BigDecimal voltageContentPercent) + { + this.voltageContentPercent = voltageContentPercent; + } + + public BigDecimal getVoltageContentPercent() + { + return voltageContentPercent; + } + + public void setVoltageAcPercent(BigDecimal voltageAcPercent) + { + this.voltageAcPercent = voltageAcPercent; + } + + public BigDecimal getVoltageAcPercent() + { + return voltageAcPercent; + } + + public void setCurrentTotalCurrentPercent(BigDecimal currentTotalCurrentPercent) + { + this.currentTotalCurrentPercent = currentTotalCurrentPercent; + } + + public BigDecimal getCurrentTotalCurrentPercent() + { + return currentTotalCurrentPercent; + } + + public void setCurrentContentPercent(BigDecimal currentContentPercent) + { + this.currentContentPercent = currentContentPercent; + } + + public BigDecimal getCurrentContentPercent() + { + return currentContentPercent; + } + + public void setCurrentAcPercent(BigDecimal currentAcPercent) + { + this.currentAcPercent = currentAcPercent; + } + + public BigDecimal getCurrentAcPercent() + { + return currentAcPercent; + } + + public void setCurrentTotalPowerPercent(BigDecimal currentTotalPowerPercent) + { + this.currentTotalPowerPercent = currentTotalPowerPercent; + } + + public BigDecimal getCurrentTotalPowerPercent() + { + return currentTotalPowerPercent; + } + + public void setPowerContentPercent(BigDecimal powerContentPercent) + { + this.powerContentPercent = powerContentPercent; + } + + public BigDecimal getPowerContentPercent() + { + return powerContentPercent; + } + + public void setPowerAcPercent(BigDecimal powerAcPercent) + { + this.powerAcPercent = powerAcPercent; + } + + public BigDecimal getPowerAcPercent() + { + return powerAcPercent; + } + + public void setDataSettingYearMonth(String dataSettingYearMonth) + { + this.dataSettingYearMonth = dataSettingYearMonth; + } + + public String getDataSettingYearMonth() + { + return dataSettingYearMonth; + } + + public void setDataSettingDayHour(String dataSettingDayHour) + { + this.dataSettingDayHour = dataSettingDayHour; + } + + public String getDataSettingDayHour() + { + return dataSettingDayHour; + } + + public void setDataSettingMinutesSeconds(String dataSettingMinutesSeconds) + { + this.dataSettingMinutesSeconds = dataSettingMinutesSeconds; + } + + public String getDataSettingMinutesSeconds() + { + return dataSettingMinutesSeconds; + } + + public void setCurrentRate(BigDecimal currentRate) + { + this.currentRate = currentRate; + } + + public BigDecimal getCurrentRate() + { + return currentRate; + } + + public void setVersionNumber(String versionNumber) + { + this.versionNumber = versionNumber; + } + + public String getVersionNumber() + { + return versionNumber; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setCurrent(BigDecimal current) + { + this.current = current; + } + + public BigDecimal getCurrent() + { + return current; + } + + public void setPower(BigDecimal power) + { + this.power = power; + } + + public BigDecimal getPower() + { + return power; + } + + public void setInternalTemp(BigDecimal internalTemp) + { + this.internalTemp = internalTemp; + } + + public BigDecimal getInternalTemp() + { + return internalTemp; + } + + public void setTotalForwardActiveOne(BigDecimal totalForwardActiveOne) + { + this.totalForwardActiveOne = totalForwardActiveOne; + } + + public BigDecimal getTotalForwardActiveOne() + { + return totalForwardActiveOne; + } + + public void setTotalReverseActiveOne(BigDecimal totalReverseActiveOne) + { + this.totalReverseActiveOne = totalReverseActiveOne; + } + + public BigDecimal getTotalReverseActiveOne() + { + return totalReverseActiveOne; + } + + public void setForwardReactiveMaxDemand(BigDecimal forwardReactiveMaxDemand) + { + this.forwardReactiveMaxDemand = forwardReactiveMaxDemand; + } + + public BigDecimal getForwardReactiveMaxDemand() + { + return forwardReactiveMaxDemand; + } + + public void setReverseReactiveMaxDemand(BigDecimal reverseReactiveMaxDemand) + { + this.reverseReactiveMaxDemand = reverseReactiveMaxDemand; + } + + public BigDecimal getReverseReactiveMaxDemand() + { + return reverseReactiveMaxDemand; + } + + public void setaForwardActiveEnergy(BigDecimal aForwardActiveEnergy) + { + this.aForwardActiveEnergy = aForwardActiveEnergy; + } + + public BigDecimal getaForwardActiveEnergy() + { + return aForwardActiveEnergy; + } + + public void setbForwardActiveEnergy(BigDecimal bForwardActiveEnergy) + { + this.bForwardActiveEnergy = bForwardActiveEnergy; + } + + public BigDecimal getbForwardActiveEnergy() + { + return bForwardActiveEnergy; + } + + public void setcForwardActiveEnergy(BigDecimal cForwardActiveEnergy) + { + this.cForwardActiveEnergy = cForwardActiveEnergy; + } + + public BigDecimal getcForwardActiveEnergy() + { + return cForwardActiveEnergy; + } + + public void setDidoStatus(String didoStatus) + { + this.didoStatus = didoStatus; + } + + public String getDidoStatus() + { + return didoStatus; + } + + public void setRunningStatus(String runningStatus) + { + this.runningStatus = runningStatus; + } + + public String getRunningStatus() + { + return runningStatus; + } + + public void setZeroSeqCurrent(BigDecimal zeroSeqCurrent) + { + this.zeroSeqCurrent = zeroSeqCurrent; + } + + public BigDecimal getZeroSeqCurrent() + { + return zeroSeqCurrent; + } + + public void setVoltageUnbalanceDegree(BigDecimal voltageUnbalanceDegree) + { + this.voltageUnbalanceDegree = voltageUnbalanceDegree; + } + + public BigDecimal getVoltageUnbalanceDegree() + { + return voltageUnbalanceDegree; + } + + public void setCurrentUnbalanceDegree(BigDecimal currentUnbalanceDegree) + { + this.currentUnbalanceDegree = currentUnbalanceDegree; + } + + public BigDecimal getCurrentUnbalanceDegree() + { + return currentUnbalanceDegree; + } + + public void setDailyReverseAcMaxDemand(BigDecimal dailyReverseAcMaxDemand) + { + this.dailyReverseAcMaxDemand = dailyReverseAcMaxDemand; + } + + public BigDecimal getDailyReverseAcMaxDemand() + { + return dailyReverseAcMaxDemand; + } + + public void setDailyForwardReacMaxDemand(BigDecimal dailyForwardReacMaxDemand) + { + this.dailyForwardReacMaxDemand = dailyForwardReacMaxDemand; + } + + public BigDecimal getDailyForwardReacMaxDemand() + { + return dailyForwardReacMaxDemand; + } + + public void setDailyReverseReacMaxDemand(BigDecimal dailyReverseReacMaxDemand) + { + this.dailyReverseReacMaxDemand = dailyReverseReacMaxDemand; + } + + public BigDecimal getDailyReverseReacMaxDemand() + { + return dailyReverseReacMaxDemand; + } + + public void setPreDayForwardAcMaxDemand(BigDecimal preDayForwardAcMaxDemand) + { + this.preDayForwardAcMaxDemand = preDayForwardAcMaxDemand; + } + + public BigDecimal getPreDayForwardAcMaxDemand() + { + return preDayForwardAcMaxDemand; + } + + public void setPreDayReverseAcMaxDemand(BigDecimal preDayReverseAcMaxDemand) + { + this.preDayReverseAcMaxDemand = preDayReverseAcMaxDemand; + } + + public BigDecimal getPreDayReverseAcMaxDemand() + { + return preDayReverseAcMaxDemand; + } + + public void setPreDayForwardReacMaxDemand(BigDecimal preDayForwardReacMaxDemand) + { + this.preDayForwardReacMaxDemand = preDayForwardReacMaxDemand; + } + + public BigDecimal getPreDayForwardReacMaxDemand() + { + return preDayForwardReacMaxDemand; + } + + public void setPreDayReverseReacMaxDemand(BigDecimal preDayReverseReacMaxDemand) + { + this.preDayReverseReacMaxDemand = preDayReverseReacMaxDemand; + } + + public BigDecimal getPreDayReverseReacMaxDemand() + { + return preDayReverseReacMaxDemand; + } + + public void setPre2dForwardAcMaxDemand(BigDecimal pre2dForwardAcMaxDemand) + { + this.pre2dForwardAcMaxDemand = pre2dForwardAcMaxDemand; + } + + public BigDecimal getPre2dForwardAcMaxDemand() + { + return pre2dForwardAcMaxDemand; + } + + public void setPre2dReverseAcMaxDemand(BigDecimal pre2dReverseAcMaxDemand) + { + this.pre2dReverseAcMaxDemand = pre2dReverseAcMaxDemand; + } + + public BigDecimal getPre2dReverseAcMaxDemand() + { + return pre2dReverseAcMaxDemand; + } + + public void setPre2dForwardReacMaxDemand(BigDecimal pre2dForwardReacMaxDemand) + { + this.pre2dForwardReacMaxDemand = pre2dForwardReacMaxDemand; + } + + public BigDecimal getPre2dForwardReacMaxDemand() + { + return pre2dForwardReacMaxDemand; + } + + public void setPre2dReverseReacMaxDemand(BigDecimal pre2dReverseReacMaxDemand) + { + this.pre2dReverseReacMaxDemand = pre2dReverseReacMaxDemand; + } + + public BigDecimal getPre2dReverseReacMaxDemand() + { + return pre2dReverseReacMaxDemand; + } + + public void setCurrentForwardAcDemand(BigDecimal currentForwardAcDemand) + { + this.currentForwardAcDemand = currentForwardAcDemand; + } + + public BigDecimal getCurrentForwardAcDemand() + { + return currentForwardAcDemand; + } + + public void setCurrentReverseAcDemand(BigDecimal currentReverseAcDemand) + { + this.currentReverseAcDemand = currentReverseAcDemand; + } + + public BigDecimal getCurrentReverseAcDemand() + { + return currentReverseAcDemand; + } + + public void setCurrentForwardReacDemand(BigDecimal currentForwardReacDemand) + { + this.currentForwardReacDemand = currentForwardReacDemand; + } + + public BigDecimal getCurrentForwardReacDemand() + { + return currentForwardReacDemand; + } + + public void setCurrentReverseReacDemand(BigDecimal currentReverseReacDemand) + { + this.currentReverseReacDemand = currentReverseReacDemand; + } + + public BigDecimal getCurrentReverseReacDemand() + { + return currentReverseReacDemand; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -1526,6 +2352,65 @@ public class EmsAmmeterData extends BaseEntity .append("currentPercent", getCurrentPercent()) .append("voltagePercent", getVoltagePercent()) .append("avgCurrent", getAvgCurrent()) + .append("totalForwardActiveTwo", getTotalForwardActiveTwo()) + .append("totalPeakForwardActive", getTotalPeakForwardActive()) + .append("totalHighForwardActive", getTotalHighForwardActive()) + .append("totalFlatForwardActive", getTotalFlatForwardActive()) + .append("totalValleyForwardActive", getTotalValleyForwardActive()) + .append("totalReverseActiveTwo", getTotalReverseActiveTwo()) + .append("totalPeakReverseActive", getTotalPeakReverseActive()) + .append("totalHighReverseActive", getTotalHighReverseActive()) + .append("totalFlatReverseActive", getTotalFlatReverseActive()) + .append("totalValleyReverseActive", getTotalValleyReverseActive()) + .append("disconnectDetectionIndication", getDisconnectDetectionIndication()) + .append("ratedPrimaryCurrentValue", getRatedPrimaryCurrentValue()) + .append("switchInputOutputStatus", getSwitchInputOutputStatus()) + .append("alarmStatus", getAlarmStatus()) + .append("currentTotalVoltagePercent", getCurrentTotalVoltagePercent()) + .append("voltageContentPercent", getVoltageContentPercent()) + .append("voltageAcPercent", getVoltageAcPercent()) + .append("currentTotalCurrentPercent", getCurrentTotalCurrentPercent()) + .append("currentContentPercent", getCurrentContentPercent()) + .append("currentAcPercent", getCurrentAcPercent()) + .append("currentTotalPowerPercent", getCurrentTotalPowerPercent()) + .append("powerContentPercent", getPowerContentPercent()) + .append("powerAcPercent", getPowerAcPercent()) + .append("dataSettingYearMonth", getDataSettingYearMonth()) + .append("dataSettingDayHour", getDataSettingDayHour()) + .append("dataSettingMinutesSeconds", getDataSettingMinutesSeconds()) + .append("currentRate", getCurrentRate()) + .append("versionNumber", getVersionNumber()) + .append("voltage", getVoltage()) + .append("current", getCurrent()) + .append("power", getPower()) + .append("internalTemp", getInternalTemp()) + .append("totalForwardActiveOne", getTotalForwardActiveOne()) + .append("totalReverseActiveOne", getTotalReverseActiveOne()) + .append("forwardReactiveMaxDemand", getForwardReactiveMaxDemand()) + .append("reverseReactiveMaxDemand", getReverseReactiveMaxDemand()) + .append("aForwardActiveEnergy", getaForwardActiveEnergy()) + .append("bForwardActiveEnergy", getbForwardActiveEnergy()) + .append("cForwardActiveEnergy", getcForwardActiveEnergy()) + .append("didoStatus", getDidoStatus()) + .append("runningStatus", getRunningStatus()) + .append("zeroSeqCurrent", getZeroSeqCurrent()) + .append("voltageUnbalanceDegree", getVoltageUnbalanceDegree()) + .append("currentUnbalanceDegree", getCurrentUnbalanceDegree()) + .append("dailyReverseAcMaxDemand", getDailyReverseAcMaxDemand()) + .append("dailyForwardReacMaxDemand", getDailyForwardReacMaxDemand()) + .append("dailyReverseReacMaxDemand", getDailyReverseReacMaxDemand()) + .append("preDayForwardAcMaxDemand", getPreDayForwardAcMaxDemand()) + .append("preDayReverseAcMaxDemand", getPreDayReverseAcMaxDemand()) + .append("preDayForwardReacMaxDemand", getPreDayForwardReacMaxDemand()) + .append("preDayReverseReacMaxDemand", getPreDayReverseReacMaxDemand()) + .append("pre2dForwardAcMaxDemand", getPre2dForwardAcMaxDemand()) + .append("pre2dReverseAcMaxDemand", getPre2dReverseAcMaxDemand()) + .append("pre2dForwardReacMaxDemand", getPre2dForwardReacMaxDemand()) + .append("pre2dReverseReacMaxDemand", getPre2dReverseReacMaxDemand()) + .append("currentForwardAcDemand", getCurrentForwardAcDemand()) + .append("currentReverseAcDemand", getCurrentReverseAcDemand()) + .append("currentForwardReacDemand", getCurrentForwardReacDemand()) + .append("currentReverseReacDemand", getCurrentReverseReacDemand()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java index de570e5..bc74ed7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * 电池簇数据对象 ems_battery_cluster * * @author xzzn - * @date 2025-07-27 + * @date 2025-07-29 */ public class EmsBatteryCluster extends BaseEntity { @@ -212,94 +212,6 @@ public class EmsBatteryCluster extends BaseEntity @Excel(name = "单次累计放电电量") private BigDecimal totalDischargeEnergy; - /** 断线检测指示 */ - @Excel(name = "断线检测指示") - private String disconnectDetectionIndication; - - /** 电压变比 */ - @Excel(name = "电压变比") - private BigDecimal voltageTransforRatio; - - /** 额定一次电流值 */ - @Excel(name = "额定一次电流值") - private BigDecimal ratedPrimaryCurrentValue; - - /** 开关量输入输出状态 */ - @Excel(name = "开关量输入输出状态") - private String switchInputOutputStatus; - - /** 报警状态 */ - @Excel(name = "报警状态") - private String alarmStatus; - - /** 当前总电压百分比 */ - @Excel(name = "当前总电压百分比") - private BigDecimal currentTotalVoltagePercent; - - /** 电压直流含量百分比 */ - @Excel(name = "电压直流含量百分比") - private BigDecimal voltageContentPercent; - - /** 电压交流含量百分比 */ - @Excel(name = "电压交流含量百分比") - private BigDecimal voltageAcPercent; - - /** 当前总电流百分比 */ - @Excel(name = "当前总电流百分比") - private BigDecimal currentTotalCurrentPercent; - - /** 电流直流含量百分比 */ - @Excel(name = "电流直流含量百分比") - private BigDecimal currentContentPercent; - - /** 电流交流含量百分比 */ - @Excel(name = "电流交流含量百分比") - private BigDecimal currentAcPercent; - - /** 当前总功率百分比 */ - @Excel(name = "当前总功率百分比") - private BigDecimal currentTotalPowerPercent; - - /** 功率直流含量百分比 */ - @Excel(name = "功率直流含量百分比") - private BigDecimal powerContentPercent; - - /** 功率交流含量百分比 */ - @Excel(name = "功率交流含量百分比") - private BigDecimal powerAcPercent; - - /** 日期时间设置(年月) */ - @Excel(name = "日期时间设置", readConverterExp = "年=月") - private String dataSettingYearMonth; - - /** 日期时间设置(日时) */ - @Excel(name = "日期时间设置", readConverterExp = "日=时") - private String dataSettingDayHour; - - /** 日期时间设置(分秒) */ - @Excel(name = "日期时间设置", readConverterExp = "分=秒") - private String dataSettingMinutesSeconds; - - /** 当前抄表日(高)、当前费率(低) */ - @Excel(name = "当前抄表日", readConverterExp = "高=") - private BigDecimal currentRate; - - /** 软件版本号 */ - @Excel(name = "软件版本号") - private String versionNumber; - - /** 电压 */ - @Excel(name = "电压") - private BigDecimal voltage; - - /** 电流 */ - @Excel(name = "电流") - private BigDecimal current; - - /** 功率 */ - @Excel(name = "功率") - private BigDecimal power; - public void setId(Long id) { this.id = id; @@ -790,226 +702,6 @@ public class EmsBatteryCluster extends BaseEntity return totalDischargeEnergy; } - public void setDisconnectDetectionIndication(String disconnectDetectionIndication) - { - this.disconnectDetectionIndication = disconnectDetectionIndication; - } - - public String getDisconnectDetectionIndication() - { - return disconnectDetectionIndication; - } - - public void setVoltageTransforRatio(BigDecimal voltageTransforRatio) - { - this.voltageTransforRatio = voltageTransforRatio; - } - - public BigDecimal getVoltageTransforRatio() - { - return voltageTransforRatio; - } - - public void setRatedPrimaryCurrentValue(BigDecimal ratedPrimaryCurrentValue) - { - this.ratedPrimaryCurrentValue = ratedPrimaryCurrentValue; - } - - public BigDecimal getRatedPrimaryCurrentValue() - { - return ratedPrimaryCurrentValue; - } - - public void setSwitchInputOutputStatus(String switchInputOutputStatus) - { - this.switchInputOutputStatus = switchInputOutputStatus; - } - - public String getSwitchInputOutputStatus() - { - return switchInputOutputStatus; - } - - public void setAlarmStatus(String alarmStatus) - { - this.alarmStatus = alarmStatus; - } - - public String getAlarmStatus() - { - return alarmStatus; - } - - public void setCurrentTotalVoltagePercent(BigDecimal currentTotalVoltagePercent) - { - this.currentTotalVoltagePercent = currentTotalVoltagePercent; - } - - public BigDecimal getCurrentTotalVoltagePercent() - { - return currentTotalVoltagePercent; - } - - public void setVoltageContentPercent(BigDecimal voltageContentPercent) - { - this.voltageContentPercent = voltageContentPercent; - } - - public BigDecimal getVoltageContentPercent() - { - return voltageContentPercent; - } - - public void setVoltageAcPercent(BigDecimal voltageAcPercent) - { - this.voltageAcPercent = voltageAcPercent; - } - - public BigDecimal getVoltageAcPercent() - { - return voltageAcPercent; - } - - public void setCurrentTotalCurrentPercent(BigDecimal currentTotalCurrentPercent) - { - this.currentTotalCurrentPercent = currentTotalCurrentPercent; - } - - public BigDecimal getCurrentTotalCurrentPercent() - { - return currentTotalCurrentPercent; - } - - public void setCurrentContentPercent(BigDecimal currentContentPercent) - { - this.currentContentPercent = currentContentPercent; - } - - public BigDecimal getCurrentContentPercent() - { - return currentContentPercent; - } - - public void setCurrentAcPercent(BigDecimal currentAcPercent) - { - this.currentAcPercent = currentAcPercent; - } - - public BigDecimal getCurrentAcPercent() - { - return currentAcPercent; - } - - public void setCurrentTotalPowerPercent(BigDecimal currentTotalPowerPercent) - { - this.currentTotalPowerPercent = currentTotalPowerPercent; - } - - public BigDecimal getCurrentTotalPowerPercent() - { - return currentTotalPowerPercent; - } - - public void setPowerContentPercent(BigDecimal powerContentPercent) - { - this.powerContentPercent = powerContentPercent; - } - - public BigDecimal getPowerContentPercent() - { - return powerContentPercent; - } - - public void setPowerAcPercent(BigDecimal powerAcPercent) - { - this.powerAcPercent = powerAcPercent; - } - - public BigDecimal getPowerAcPercent() - { - return powerAcPercent; - } - - public void setDataSettingYearMonth(String dataSettingYearMonth) - { - this.dataSettingYearMonth = dataSettingYearMonth; - } - - public String getDataSettingYearMonth() - { - return dataSettingYearMonth; - } - - public void setDataSettingDayHour(String dataSettingDayHour) - { - this.dataSettingDayHour = dataSettingDayHour; - } - - public String getDataSettingDayHour() - { - return dataSettingDayHour; - } - - public void setDataSettingMinutesSeconds(String dataSettingMinutesSeconds) - { - this.dataSettingMinutesSeconds = dataSettingMinutesSeconds; - } - - public String getDataSettingMinutesSeconds() - { - return dataSettingMinutesSeconds; - } - - public void setCurrentRate(BigDecimal currentRate) - { - this.currentRate = currentRate; - } - - public BigDecimal getCurrentRate() - { - return currentRate; - } - - public void setVersionNumber(String versionNumber) - { - this.versionNumber = versionNumber; - } - - public String getVersionNumber() - { - return versionNumber; - } - - public void setVoltage(BigDecimal voltage) - { - this.voltage = voltage; - } - - public BigDecimal getVoltage() - { - return voltage; - } - - public void setCurrent(BigDecimal current) - { - this.current = current; - } - - public BigDecimal getCurrent() - { - return current; - } - - public void setPower(BigDecimal power) - { - this.power = power; - } - - public BigDecimal getPower() - { - return power; - } - @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -1067,28 +759,6 @@ public class EmsBatteryCluster extends BaseEntity .append("minCellSohId", getMinCellSohId()) .append("totalChargeEnergy", getTotalChargeEnergy()) .append("totalDischargeEnergy", getTotalDischargeEnergy()) - .append("disconnectDetectionIndication", getDisconnectDetectionIndication()) - .append("voltageTransforRatio", getVoltageTransforRatio()) - .append("ratedPrimaryCurrentValue", getRatedPrimaryCurrentValue()) - .append("switchInputOutputStatus", getSwitchInputOutputStatus()) - .append("alarmStatus", getAlarmStatus()) - .append("currentTotalVoltagePercent", getCurrentTotalVoltagePercent()) - .append("voltageContentPercent", getVoltageContentPercent()) - .append("voltageAcPercent", getVoltageAcPercent()) - .append("currentTotalCurrentPercent", getCurrentTotalCurrentPercent()) - .append("currentContentPercent", getCurrentContentPercent()) - .append("currentAcPercent", getCurrentAcPercent()) - .append("currentTotalPowerPercent", getCurrentTotalPowerPercent()) - .append("powerContentPercent", getPowerContentPercent()) - .append("powerAcPercent", getPowerAcPercent()) - .append("dataSettingYearMonth", getDataSettingYearMonth()) - .append("dataSettingDayHour", getDataSettingDayHour()) - .append("dataSettingMinutesSeconds", getDataSettingMinutesSeconds()) - .append("currentRate", getCurrentRate()) - .append("versionNumber", getVersionNumber()) - .append("voltage", getVoltage()) - .append("current", getCurrent()) - .append("power", getPower()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java index 799b413..5c9f2f6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryData.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * 单体电池实时数据对象 ems_battery_data * * @author xzzn - * @date 2025-06-29 + * @date 2025-07-29 */ public class EmsBatteryData extends BaseEntity { @@ -66,6 +66,10 @@ public class EmsBatteryData extends BaseEntity @Excel(name = "簇设备id") private String clusterDeviceId; + /** 单体电池内阻 */ + @Excel(name = "单体电池内阻") + private BigDecimal interResistance; + public void setId(Long id) { this.id = id; @@ -186,6 +190,16 @@ public class EmsBatteryData extends BaseEntity return clusterDeviceId; } + public void setInterResistance(BigDecimal interResistance) + { + this.interResistance = interResistance; + } + + public BigDecimal getInterResistance() + { + return interResistance; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -206,6 +220,7 @@ public class EmsBatteryData extends BaseEntity .append("siteId", getSiteId()) .append("deviceId", getDeviceId()) .append("clusterDeviceId", getClusterDeviceId()) + .append("interResistance", getInterResistance()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryGroup.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryGroup.java new file mode 100644 index 0000000..d01792c --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryGroup.java @@ -0,0 +1,164 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; + +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_battery_group + * + * @author xzzn + * @date 2025-07-29 + */ +public class EmsBatteryGroup extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 电池组状态 */ + @Excel(name = "电池组状态") + private String status; + + /** 电压 (V) */ + @Excel(name = "电压 (V)") + private BigDecimal voltage; + + /** 电流 (A) */ + @Excel(name = "电流 (A)") + private BigDecimal current; + + /** SOC (%) */ + @Excel(name = "SOC (%)") + private BigDecimal soc; + + /** SOH (%) */ + @Excel(name = "SOH (%)") + private BigDecimal soh; + + /** 备电预估时长 */ + @Excel(name = "备电预估时长") + private BigDecimal estimatedBackupDuration; + + /** 站点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 setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setCurrent(BigDecimal current) + { + this.current = current; + } + + public BigDecimal getCurrent() + { + return current; + } + + public void setSoc(BigDecimal soc) + { + this.soc = soc; + } + + public BigDecimal getSoc() + { + return soc; + } + + public void setSoh(BigDecimal soh) + { + this.soh = soh; + } + + public BigDecimal getSoh() + { + return soh; + } + + public void setEstimatedBackupDuration(BigDecimal estimatedBackupDuration) + { + this.estimatedBackupDuration = estimatedBackupDuration; + } + + public BigDecimal getEstimatedBackupDuration() + { + return estimatedBackupDuration; + } + + 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("status", getStatus()) + .append("voltage", getVoltage()) + .append("current", getCurrent()) + .append("soc", getSoc()) + .append("soh", getSoh()) + .append("estimatedBackupDuration", getEstimatedBackupDuration()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDhData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDhData.java new file mode 100644 index 0000000..eb2d35c --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDhData.java @@ -0,0 +1,104 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; + +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_dh_data + * + * @author xzzn + * @date 2025-07-28 + */ +public class EmsDhData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 湿度 */ + @Excel(name = "湿度") + private BigDecimal humidity; + + /** 温度 */ + @Excel(name = "温度") + private BigDecimal temperature; + + /** 站点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 setHumidity(BigDecimal humidity) + { + this.humidity = humidity; + } + + public BigDecimal getHumidity() + { + return humidity; + } + + public void setTemperature(BigDecimal temperature) + { + this.temperature = temperature; + } + + public BigDecimal getTemperature() + { + return temperature; + } + + 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("humidity", getHumidity()) + .append("temperature", getTemperature()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryGroupMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryGroupMapper.java new file mode 100644 index 0000000..ee68bfe --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryGroupMapper.java @@ -0,0 +1,64 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsBatteryGroup; + +/** + * 电池组数据Mapper接口 + * + * @author xzzn + * @date 2025-07-29 + */ +public interface EmsBatteryGroupMapper +{ + /** + * 查询电池组数据 + * + * @param id 电池组数据主键 + * @return 电池组数据 + */ + public EmsBatteryGroup selectEmsBatteryGroupById(Long id); + + /** + * 查询电池组数据列表 + * + * @param emsBatteryGroup 电池组数据 + * @return 电池组数据集合 + */ + public List selectEmsBatteryGroupList(EmsBatteryGroup emsBatteryGroup); + + /** + * 新增电池组数据 + * + * @param emsBatteryGroup 电池组数据 + * @return 结果 + */ + public int insertEmsBatteryGroup(EmsBatteryGroup emsBatteryGroup); + + /** + * 修改电池组数据 + * + * @param emsBatteryGroup 电池组数据 + * @return 结果 + */ + public int updateEmsBatteryGroup(EmsBatteryGroup emsBatteryGroup); + + /** + * 删除电池组数据 + * + * @param id 电池组数据主键 + * @return 结果 + */ + public int deleteEmsBatteryGroupById(Long id); + + /** + * 批量删除电池组数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryGroupByIds(Long[] ids); + + // 批量插入 + void batchInsertGroupData(List emsBatteryGroups); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDhDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDhDataMapper.java new file mode 100644 index 0000000..d02b757 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDhDataMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsDhData; + +/** + * 动环数据Mapper接口 + * + * @author xzzn + * @date 2025-07-28 + */ +public interface EmsDhDataMapper +{ + /** + * 查询动环数据 + * + * @param id 动环数据主键 + * @return 动环数据 + */ + public EmsDhData selectEmsDhDataById(Long id); + + /** + * 查询动环数据列表 + * + * @param emsDhData 动环数据 + * @return 动环数据集合 + */ + public List selectEmsDhDataList(EmsDhData emsDhData); + + /** + * 新增动环数据 + * + * @param emsDhData 动环数据 + * @return 结果 + */ + public int insertEmsDhData(EmsDhData emsDhData); + + /** + * 修改动环数据 + * + * @param emsDhData 动环数据 + * @return 结果 + */ + public int updateEmsDhData(EmsDhData emsDhData); + + /** + * 删除动环数据 + * + * @param id 动环数据主键 + * @return 结果 + */ + public int deleteEmsDhDataById(Long id); + + /** + * 批量删除动环数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsDhDataByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index e5724d4..7aecc73 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -1,7 +1,6 @@ package com.xzzn.ems.service.impl; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; import com.xzzn.common.constant.RedisKeyConstants; @@ -17,13 +16,22 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; @Service public class DDSDataProcessServiceImpl implements IDDSDataProcessService { private static final Log log = LogFactory.getLog(DDSDataProcessServiceImpl.class); private static final String SITE_ID = "021_DDS_01"; + // 正则表达式匹配BMS设备编号和属性 + private static final Pattern PATTERN = Pattern.compile("(BMSD\\d{2})(ZT|SOC|SOH|DL|DY|BDSC)"); + // 匹配DTDC+数字格式的正则(提取序号) + private static final Pattern DTDC_PATTERN = Pattern.compile("DTDC(\\d+)([A-Za-z]*)"); + @Autowired private EmsBatteryClusterMapper emsBatteryClusterMapper; @@ -49,6 +57,10 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { private EmsAmmeterDataMapper emsAmmeterDataMapper; @Autowired private EmsBatteryDailyLatestServiceImpl emsBatteryDailyLatestServiceImpl; + @Autowired + private EmsDhDataMapper emsDhDataMapper; + @Autowired + private EmsBatteryGroupMapper emsBatteryGroupMapper; @Override public void handleDdsData(String message) { @@ -58,34 +70,74 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { String jsonData = obj.get("Data").toString(); log.info("deviceId:" + deviceId); + if (StringUtils.isEmpty(jsonData)) { + return; + } if (deviceId.contains("BMSD")) { batteryStackDataProcess(deviceId, jsonData); - - } else if (deviceId.contains("BMSC")) { - batteryClusterDataProcess(deviceId, jsonData); + batteryGroupDataProcess(deviceId, jsonData); batteryDataProcess(deviceId, jsonData); - } else if (deviceId.contains("PCS")) { pcsDataProcess(deviceId, jsonData); pcsBranchDataProcess(deviceId, jsonData); + batteryClusterDataProcess(deviceId, jsonData); } else if (deviceId.contains("LOAD")) { loadDataProcess(deviceId, jsonData); } else if (deviceId.contains("METEGF")) { - log.info("METEGF DATA PROCESS"); meteGFDataProcess(deviceId, jsonData); - } else if (deviceId.contains("METE")) { - log.info("OTHER METE DATA PROCESS"); + } else if (deviceId.equals("METE")) { meteDataProcess(deviceId, jsonData); + } else if (deviceId.contains("METE0")) { + meteBranchDataProcess(deviceId, jsonData); + } else if (deviceId.contains("XF")) { + meteXFProcess(deviceId, jsonData); + } else if (deviceId.contains("DH")) { + meteDHProcess(deviceId, jsonData); } } + private void meteDHProcess(String deviceId, String dataJson) { + //动环 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + //DH + EmsDhData dhData = new EmsDhData(); + + dhData.setHumidity(StringUtils.getBigDecimal(obj.get("SD"))); + dhData.setTemperature(StringUtils.getBigDecimal(obj.get("WD"))); + + dhData.setCreateBy("system"); + dhData.setCreateTime(DateUtils.getNowDate()); + dhData.setUpdateBy("system"); + dhData.setUpdateTime(DateUtils.getNowDate()); + dhData.setSiteId(SITE_ID); + dhData.setDeviceId(deviceId); + emsDhDataMapper.insertEmsDhData(dhData); + + redisCache.setCacheObject(RedisKeyConstants.DH + SITE_ID + "_" +deviceId, dhData); + } + + private void meteXFProcess(String deviceId, String dataJson) { + //消防 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + // 暂时只更新设备表的设备状态 ZDYBYDCZT-主电源备用电池状态 + // 状态枚举还没有提供 + EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, SITE_ID); + emsDevicesSetting.setCommunicationStatus(StringUtils.getString(obj.get("ZDYBYDCZT"))); + emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); + emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); + } + private void batteryStackDataProcess(String deviceId, String dataJson) { //电池堆 Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); - //BMS 电池簇 + //BMS 电池堆 EmsBatteryStack dataStack = new EmsBatteryStack(); // 其他非 BigDecimal 字段 @@ -133,13 +185,199 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { redisCache.setCacheObject(RedisKeyConstants.STACK + SITE_ID + "_" +deviceId, dataStack); } + private void batteryGroupDataProcess(String deviceId, String jsonData) { + //电池组 + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + Map groupMap = new HashMap<>(); + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + // 跳过空键 + if (key == null || key.trim().isEmpty()) { + continue; + } + Matcher matcher = PATTERN.matcher(key); + if (matcher.matches()) { + String groupDeviceId = matcher.group(1); + String property = matcher.group(2); + EmsBatteryGroup dataGroup = groupMap.getOrDefault(groupDeviceId, new EmsBatteryGroup()); + dataGroup.setDeviceId(groupDeviceId); + dataGroup.setSiteId(SITE_ID); + dataGroup.setCreateBy("system"); + dataGroup.setCreateTime(DateUtils.getNowDate()); + dataGroup.setUpdateBy("system"); + dataGroup.setUpdateTime(DateUtils.getNowDate()); + + setPropertyValue(dataGroup, property, entry.getValue()); + groupMap.put(groupDeviceId, dataGroup); + } + } + + // 批量插入数据库 + log.info("批量插入"); + if (!CollectionUtils.isEmpty(groupMap)) { + List batteryGroupList = new ArrayList<>(groupMap.values()); + emsBatteryGroupMapper.batchInsertGroupData(batteryGroupList); + redisCache.setCacheObject(RedisKeyConstants.GROUP + SITE_ID + "_" +deviceId, batteryGroupList); + } + + } + //根据属性名设置对应的值 + private static void setPropertyValue(EmsBatteryGroup groupData, String property, Object value) { + BigDecimal numberValue = null; + if (value instanceof Number) { + numberValue = new BigDecimal(value.toString()); + } + + switch (property) { + case "ZT": + if (numberValue != null) { + groupData.setStatus(numberValue.toString()); + } + break; + case "SOC": + groupData.setSoc(numberValue); + break; + case "SOH": + groupData.setSoh(numberValue); + break; + case "DL": + groupData.setCurrent(numberValue); + break; + case "DY": + groupData.setVoltage(numberValue); + break; + case "BDSC": + groupData.setEstimatedBackupDuration(numberValue); + break; + } + } + private void batteryDataProcess(String deviceId, String dataJson) { + //电池组 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + List dailyList = new ArrayList<>(); + Map dataMap = new HashMap<>(); + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + + if (key.startsWith("DTDC")) { + Matcher matcher = DTDC_PATTERN.matcher(key); + if (matcher.matches()) { + String batteryCellId = matcher.group(1); + String property = matcher.group(2); + + EmsBatteryData data = dataMap.getOrDefault(batteryCellId, new EmsBatteryData()); + if (StringUtils.isNotEmpty(batteryCellId)) { + data.setDataTimestamp(DateUtils.getNowDate()); + data.setBatteryPack(deviceId); + data.setBatteryCluster("BMSC01");// 写死 + data.setClusterDeviceId("BMSC01"); + data.setBatteryCellId(batteryCellId); + data.setSiteId(SITE_ID); + data.setDeviceId(batteryCellId); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + } + // 根据后缀设置对应属性 + setDTDCPropertyValue(data, property, entry.getValue()); + dataMap.put(batteryCellId, data); + + // 每日最新数据 + EmsBatteryDataDailyLatest daily = new EmsBatteryDataDailyLatest(); + BeanUtils.copyProperties(data, daily); + daily.setDateDay(DateUtils.getNowDate()); + dailyList.add(daily); + } + } + + } + if (!CollectionUtils.isEmpty(dataMap)) { + List dataList = new ArrayList<>(dataMap.values()); + emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList)); + + redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId); + redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, dataList); + } + // 批量处理每日最新数据 + if (dailyList != null && dailyList.size() > 0) { + emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList); + } + } + + private void setDTDCPropertyValue(EmsBatteryData data, String property, Object value) { + BigDecimal numberValue = null; + if (value instanceof Number) { + numberValue = new BigDecimal(value.toString()); + } + switch (property) { + case "DY": + data.setVoltage(numberValue); + break; + case "WD": + data.setTemperature(numberValue); + break; + case "NZ": + data.setInterResistance(numberValue); + break; + } + } private void batteryClusterDataProcess(String deviceId, String dataJson) { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); EmsDevicesSetting joken = new EmsDevicesSetting(); + + //BMSC 电池簇 + EmsBatteryCluster data = new EmsBatteryCluster(); + // 其他非 BigDecimal 字段 + data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + data.setSiteId(SITE_ID); + // BMSC01 电流电压功率 + deviceId = "BMSC01"; + String stackDeviceId = getDeviceParent(deviceId, SITE_ID); + if (StringUtils.isNotBlank(stackDeviceId)) { + data.setStackDeviceId(stackDeviceId); + } else { + data.setStackDeviceId("1"); + } + data.setDeviceId(deviceId); + data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC01ZLDY"))); + data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC01ZLDL"))); + data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("BMSC01ZLSCGL"))); + emsBatteryClusterMapper.insertEmsBatteryCluster(data); + redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); + + // BMSC02 电流电压功率 + deviceId = "BMSC02"; + stackDeviceId = getDeviceParent(deviceId, SITE_ID); + if (StringUtils.isNotBlank(stackDeviceId)) { + data.setStackDeviceId(stackDeviceId); + } else { + data.setStackDeviceId("1"); + } + data.setDeviceId(deviceId); + data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC02ZLDY"))); + data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC02ZLDL"))); + data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("BMSC02ZLSCGL"))); + emsBatteryClusterMapper.insertEmsBatteryCluster(data); + redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); + } + + private String getDeviceParent(String deviceId,String siteId) { + EmsDevicesSetting joken = new EmsDevicesSetting(); joken.setDeviceId(deviceId); + joken.setSiteId(siteId); List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); String stackDeviceId = ""; if (up != null && up.size() >0) { @@ -148,18 +386,44 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { stackDeviceId = "1"; } } - //BMS 电池簇 - EmsBatteryCluster data = new EmsBatteryCluster(); - // 电流电压功率 - data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZLDYZ"))); - data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZLDLZ"))); - data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("GLZ"))); - data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("ZZXYGDN1"))); - data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFXYGDN1"))); + return stackDeviceId; + } - // 特殊字段 + private void meteBranchDataProcess(String deviceId, String dataJson) { + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + //pcs电表数据 + EmsAmmeterData data = new EmsAmmeterData(); + // 更新时间 + data.setDataUpdateTime(new Date()); + + // 当月有功电能 + data.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQYZZXYGDN"))); + data.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQYJZXYGDN"))); + data.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQYFZXYGDN"))); + data.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQYPZXYGDN"))); + data.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQYGZXYGDN"))); + data.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQYZFXYGDN"))); + data.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQYJFXYGDN"))); + data.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQYFFXYGDN"))); + data.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQYPFXYGDN"))); + data.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQYGFXYGDN"))); + + // 总有功电能 + data.setTotalForwardActiveTwo(StringUtils.getBigDecimal(obj.get("ZZXYGDN2"))); + data.setTotalPeakForwardActive(StringUtils.getBigDecimal(obj.get("ZJZXYGDN"))); + data.setTotalHighForwardActive(StringUtils.getBigDecimal(obj.get("ZFZXYGDN"))); + data.setTotalFlatForwardActive(StringUtils.getBigDecimal(obj.get("ZPZXYGDN"))); + data.setTotalValleyForwardActive(StringUtils.getBigDecimal(obj.get("ZGZXYGDN"))); + data.setTotalReverseActiveTwo(StringUtils.getBigDecimal(obj.get("ZFXYGDN2"))); + data.setTotalPeakReverseActive(StringUtils.getBigDecimal(obj.get("ZJFXYGDN"))); + data.setTotalHighReverseActive(StringUtils.getBigDecimal(obj.get("ZFFXYGDN"))); + data.setTotalFlatReverseActive(StringUtils.getBigDecimal(obj.get("ZPFXYGDN"))); + data.setTotalValleyReverseActive(StringUtils.getBigDecimal(obj.get("ZGFXYGDN"))); + + // 其他字段 + data.setVoltagePercent(StringUtils.getBigDecimal(obj.get("DYBB"))); data.setDisconnectDetectionIndication(StringUtils.getString(obj.get("DXJCZS"))); - data.setVoltageTransforRatio(StringUtils.getBigDecimal(obj.get("DYBB"))); data.setRatedPrimaryCurrentValue(StringUtils.getBigDecimal(obj.get("EDYCDLZ"))); data.setSwitchInputOutputStatus(StringUtils.getString(obj.get("KGLSRSCZT"))); data.setAlarmStatus(StringUtils.getString(obj.get("BJZT"))); @@ -180,88 +444,20 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { data.setVoltage(StringUtils.getBigDecimal(obj.get("DY"))); data.setCurrent(StringUtils.getBigDecimal(obj.get("DL"))); data.setPower(StringUtils.getBigDecimal(obj.get("GL"))); + data.setInternalTemp(StringUtils.getBigDecimal(obj.get("NBWD"))); + data.setTotalForwardActiveOne(StringUtils.getBigDecimal(obj.get("ZZXYGDN1"))); + data.setTotalReverseActiveOne(StringUtils.getBigDecimal(obj.get("ZFXYGDN1"))); - // 其他非 BigDecimal 字段 - data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("NBWD"))); - data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 - data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); - data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setCreateBy("system"); data.setCreateTime(DateUtils.getNowDate()); data.setUpdateBy("system"); data.setUpdateTime(DateUtils.getNowDate()); data.setSiteId(SITE_ID); data.setDeviceId(deviceId); - if (StringUtils.isNotBlank(stackDeviceId)) { - data.setStackDeviceId(stackDeviceId); - } else { - data.setStackDeviceId("1"); - } - emsBatteryClusterMapper.insertEmsBatteryCluster(data); - - redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); - + emsAmmeterDataMapper.insertEmsAmmeterData(data); + redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, data); } - private void batteryDataProcess(String deviceId, String dataJson) { - EmsDevicesSetting joken = new EmsDevicesSetting(); - joken.setDeviceId(deviceId); - List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); - String stackDeviceId = ""; - if (up != null && up.size() >0) { - stackDeviceId = up.get(0).getParentId(); - if (stackDeviceId == null || stackDeviceId.isEmpty()) { - stackDeviceId = "1"; - } - } - //单体电池 - Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() {})); - List list = new ArrayList<>(); - List dailyList = new ArrayList<>(); - //单体电池 - for (Map.Entry> record : records.entrySet()) { - String recordId = record.getKey(); - Map fields = record.getValue(); - - EmsBatteryData batteryData = new EmsBatteryData(); - batteryData.setDeviceId(recordId); - batteryData.setBatteryCellId(recordId); - batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); - batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); - batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); - batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); - - batteryData.setBatteryCluster(deviceId); - batteryData.setBatteryPack(stackDeviceId); - - // 时间戳 - batteryData.setDataTimestamp(new Date()); - - // ID字段 - batteryData.setSiteId(SITE_ID); - batteryData.setClusterDeviceId(deviceId); - - list.add(batteryData); - - // 每日最新数据 - EmsBatteryDataDailyLatest daily = new EmsBatteryDataDailyLatest(); - BeanUtils.copyProperties(batteryData, daily); - daily.setDateDay(DateUtils.getNowDate()); - dailyList.add(daily); - } - if (list.size() > 0 ) { - emsBatteryDataMapper.insertEmsBatteryDataList(list); - - redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId); - redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, list); - } - // 批量处理每日最新数据 - if (dailyList != null && dailyList.size() > 0) { - emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList); - } - } - - private void pcsDataProcess(String deviceId, String dataJson) { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); @@ -334,9 +530,6 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { EmsPcsBranchData data = new EmsPcsBranchData(); data.setDeviceId(deviceId); data.setGridStatus(GridStatus.GRID.getCode()); - data.setDcPower(StringUtils.getBigDecimal(fields.get("BMSC01ZLSCGL"))); - data.setDcVoltage(StringUtils.getBigDecimal(fields.get("BMSC01ZLDY"))); - data.setDcCurrent(StringUtils.getBigDecimal(fields.get("BMSC01ZLDL"))); data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUAB"))); data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUBC"))); @@ -494,86 +687,129 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); - EmsAmmeterData dataLoad = new EmsAmmeterData(); + EmsAmmeterData dataMete = new EmsAmmeterData(); // 更新时间 - dataLoad.setDataUpdateTime(new Date()); + dataMete.setDataUpdateTime(new Date()); // 电压+电流 - dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); - dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); - dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); - dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); - dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); - dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + dataMete.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataMete.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataMete.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataMete.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataMete.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataMete.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); - dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); - dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); - dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); + dataMete.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataMete.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); + dataMete.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); // 频率 - dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); + dataMete.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); // 功率 - dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); - dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); - dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); - dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); - dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); - dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); - dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); - dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataMete.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataMete.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataMete.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataMete.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataMete.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataMete.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataMete.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataMete.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataMete.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); + dataMete.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); + dataMete.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); + dataMete.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + dataMete.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); + dataMete.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); + dataMete.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); + dataMete.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); - dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); - dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + // 电能设置-组合有功 + dataMete.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); + dataMete.setCurrentCombActivePeak(StringUtils.getBigDecimal(obj.get("DQZHYGJDN"))); + dataMete.setCurrentCombActiveHigh(StringUtils.getBigDecimal(obj.get("DQZHYGFDN"))); + dataMete.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); + dataMete.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); + // 电能设置-正向有功 + dataMete.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); + dataMete.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); + dataMete.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); + dataMete.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); + dataMete.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); + // 电能设置-反向有功 + dataMete.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); + dataMete.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); + dataMete.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); + dataMete.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); + dataMete.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))); + // 电能设置-组合无功 + dataMete.setCurrentCombReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZHWGZDN"))); + dataMete.setCurrentCombReactivePeak(StringUtils.getBigDecimal(obj.get("DQZHWGJDN"))); + dataMete.setCurrentCombReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZHWGFDN"))); + dataMete.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); + dataMete.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); + // 电能设置-正向无功 + dataMete.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); + dataMete.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); + dataMete.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); + dataMete.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); + dataMete.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); + // 电能设置-反向无功 + dataMete.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); + dataMete.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); + dataMete.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); + dataMete.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); + dataMete.setCurrentReverseReactiveValley(StringUtils.getBigDecimal(obj.get("DQFXWGGDN"))); + // abc相 + dataMete.setaForwardActiveEnergy(StringUtils.getBigDecimal(obj.get("AXZXYGDN"))); + dataMete.setbForwardActiveEnergy(StringUtils.getBigDecimal(obj.get("BXZXYGDN"))); + dataMete.setcForwardActiveEnergy(StringUtils.getBigDecimal(obj.get("CXZXYGDN"))); - // 二次相关数据 - dataLoad.setSecondaryAbLineVoltage(StringUtils.getBigDecimal(obj.get("ECABXDY"))); - dataLoad.setSecondaryAPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECAXDL"))); - dataLoad.setSecondaryAPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECAXDY"))); - dataLoad.setSecondaryAPowerFactor(StringUtils.getBigDecimal(obj.get("ECAXGLYS"))); - dataLoad.setSecondaryAApparentPower(StringUtils.getBigDecimal(obj.get("ECAXSZGL"))); - dataLoad.setSecondaryAReactivePower(StringUtils.getBigDecimal(obj.get("ECAXWGGL"))); - dataLoad.setSecondaryAActivePower(StringUtils.getBigDecimal(obj.get("ECAXYGGL"))); - dataLoad.setSecondaryBcLineVoltage(StringUtils.getBigDecimal(obj.get("ECBCXDY"))); - dataLoad.setSecondaryBPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECBXDL"))); - dataLoad.setSecondaryBPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECBXDY"))); - dataLoad.setSecondaryBPowerFactor(StringUtils.getBigDecimal(obj.get("ECBXGLYS"))); - dataLoad.setSecondaryBApparentPower(StringUtils.getBigDecimal(obj.get("ECBXSZGL"))); - dataLoad.setSecondaryBReactivePower(StringUtils.getBigDecimal(obj.get("ECBXWGGL"))); - dataLoad.setSecondaryBActivePower(StringUtils.getBigDecimal(obj.get("ECBXYGGL"))); - dataLoad.setSecondaryCaLineVoltage(StringUtils.getBigDecimal(obj.get("ECCAXDY"))); - dataLoad.setSecondaryCPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECCXDL"))); - dataLoad.setSecondaryCPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECCXDY"))); - dataLoad.setSecondaryCPowerFactor(StringUtils.getBigDecimal(obj.get("ECCXGLYS"))); - dataLoad.setSecondaryCApparentPower(StringUtils.getBigDecimal(obj.get("ECCXSZGL"))); - dataLoad.setSecondaryCReactivePower(StringUtils.getBigDecimal(obj.get("ECCXWGGL"))); - dataLoad.setSecondaryCActivePower(StringUtils.getBigDecimal(obj.get("ECCXYGGL"))); - dataLoad.setSecondaryGridFrequency(StringUtils.getBigDecimal(obj.get("ECDWPL"))); - dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXWGDN"))); - dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXYGDN"))); - dataLoad.setSecondaryTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ECZGLYS"))); - dataLoad.setSecondaryTotalApparentPower(StringUtils.getBigDecimal(obj.get("ECZSZFL"))); - dataLoad.setSecondaryTotalReactivePower(StringUtils.getBigDecimal(obj.get("ECZWGGL"))); - dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXWGDN"))); - dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXYGDN"))); - dataLoad.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ECZYGGL"))); + // 变比 + dataMete.setCurrentPercent(StringUtils.getBigDecimal(obj.get("DLBBCT"))); + dataMete.setVoltagePercent(StringUtils.getBigDecimal(obj.get("DYBBPT"))); // 需量 - dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("FXWGDN"))); - dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("FXYGDN"))); - dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); - dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + dataMete.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); + dataMete.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); + dataMete.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); + dataMete.setForwardReactiveMaxDemand(StringUtils.getBigDecimal(obj.get("ZXWGZDXL"))); + dataMete.setReverseReactiveMaxDemand(StringUtils.getBigDecimal(obj.get("FXWGZDXL"))); + dataMete.setDailyReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("DRFXYGZDXL"))); + dataMete.setDailyForwardReacMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXWGZDXL"))); + dataMete.setDailyReverseReacMaxDemand(StringUtils.getBigDecimal(obj.get("DRFXWGZDXL"))); - dataLoad.setCreateBy("system"); - dataLoad.setCreateTime(DateUtils.getNowDate()); - dataLoad.setUpdateBy("system"); - dataLoad.setUpdateTime(DateUtils.getNowDate()); - dataLoad.setSiteId(SITE_ID); - dataLoad.setDeviceId(deviceId); + dataMete.setPreDayForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("S1RZXYGZDXL"))); + dataMete.setPreDayReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("S1RFXYGZDXL"))); + dataMete.setPreDayForwardReacMaxDemand(StringUtils.getBigDecimal(obj.get("S1RZXWGZDX"))); + dataMete.setPreDayReverseReacMaxDemand(StringUtils.getBigDecimal(obj.get("S1RFXWGZDX"))); + dataMete.setPre2dForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("S2RZXYGZDXL"))); + dataMete.setPre2dReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("S2RFXYGZDXL"))); + dataMete.setPre2dForwardReacMaxDemand(StringUtils.getBigDecimal(obj.get("S2RZXWGZDXL"))); + dataMete.setPre2dReverseReacMaxDemand(StringUtils.getBigDecimal(obj.get("S2RFXWGZDXL"))); - emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); + dataMete.setCurrentForwardAcDemand(StringUtils.getBigDecimal(obj.get("DQZXYGXL"))); + dataMete.setCurrentReverseAcDemand(StringUtils.getBigDecimal(obj.get("DQFXYGXL"))); + dataMete.setCurrentForwardReacDemand(StringUtils.getBigDecimal(obj.get("DQZXWGXL"))); + dataMete.setCurrentReverseReacDemand(StringUtils.getBigDecimal(obj.get("DQFXWGXL"))); - redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + // 其他字段 + dataMete.setDidoStatus(StringUtils.getString(obj.get("DIDOZTSYZT"))); + dataMete.setRunningStatus(StringUtils.getString(obj.get("YXZT"))); + dataMete.setZeroSeqCurrent(StringUtils.getBigDecimal(obj.get("LXDL"))); + dataMete.setVoltageUnbalanceDegree(StringUtils.getBigDecimal(obj.get("DYBPHD"))); + dataMete.setCurrentUnbalanceDegree(StringUtils.getBigDecimal(obj.get("DLBPHD"))); + + dataMete.setCreateBy("system"); + dataMete.setCreateTime(DateUtils.getNowDate()); + dataMete.setUpdateBy("system"); + dataMete.setUpdateTime(DateUtils.getNowDate()); + dataMete.setSiteId(SITE_ID); + dataMete.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataMete); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataMete); } // 数据分组处理 private static Map> processData(Map rawData) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index ec1fdfc..914c099 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -110,10 +110,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - select id, data_update_time, current_comb_active_total, current_comb_active_peak, current_comb_active_high, current_comb_active_flat, current_comb_active_valley, current_forward_active_total, current_forward_active_peak, current_forward_active_high, current_forward_active_flat, current_forward_active_valley, current_reverse_active_total, current_reverse_active_peak, current_reverse_active_high, current_reverse_active_flat, current_reverse_active_valley, current_comb_reactive_total, current_comb_reactive_peak, current_comb_reactive_high, current_comb_reactive_flat, current_comb_reactive_valley, current_forward_reactive_total, current_forward_reactive_peak, current_forward_reactive_high, current_forward_reactive_flat, current_forward_reactive_valley, current_reverse_reactive_total, current_reverse_reactive_peak, current_reverse_reactive_high, current_reverse_reactive_flat, current_reverse_reactive_valley, phase_a_voltage, phase_b_voltage, phase_c_voltage, phase_a_current, phase_b_current, phase_c_current, frequency, ab_line_voltage, cb_line_voltage, ac_line_voltage, forward_ac_max_demand, reverse_ac_max_demand, phase_a_active_power, phase_b_active_power, phase_c_active_power, total_active_power, phase_a_reactive_power, phase_b_reactive_power, phase_c_reactive_power, total_reactive_power, phase_a_apparent_power, phase_b_apparent_power, phase_c_apparent_power, total_apparent_power, phase_a_power_factor, phase_b_power_factor, phase_c_power_factor, total_power_factor, daily_forward_max_demand, site_id, device_id, create_by, create_time, update_by, update_time, remark, secondary_ab_line_voltage, secondary_a_phase_current, secondary_a_phase_voltage, secondary_a_power_factor, secondary_a_apparent_power, secondary_a_reactive_power, secondary_a_active_power, secondary_bc_line_voltage, secondary_b_phase_current, secondary_b_phase_voltage, secondary_b_power_factor, secondary_b_apparent_power, secondary_b_reactive_power, secondary_b_active_power, secondary_ca_line_voltage, secondary_c_phase_current, secondary_c_phase_voltage, secondary_c_power_factor, secondary_c_apparent_power, secondary_c_reactive_power, secondary_c_active_power, secondary_grid_frequency, secondary_reverse_reactive_energy, secondary_negative_active_energy, secondary_total_power_factor, secondary_total_apparent_power, secondary_total_reactive_power, secondary_positive_reactive_energy, secondary_positive_active_energy, secondary_total_active_power, reverse_reactive_energy_eq_minus, reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus, current_percent, voltage_percent, avg_current from ems_ammeter_data + select id, data_update_time, current_comb_active_total, current_comb_active_peak, current_comb_active_high, current_comb_active_flat, current_comb_active_valley, current_forward_active_total, current_forward_active_peak, current_forward_active_high, current_forward_active_flat, current_forward_active_valley, current_reverse_active_total, current_reverse_active_peak, current_reverse_active_high, current_reverse_active_flat, current_reverse_active_valley, current_comb_reactive_total, current_comb_reactive_peak, current_comb_reactive_high, current_comb_reactive_flat, current_comb_reactive_valley, current_forward_reactive_total, current_forward_reactive_peak, current_forward_reactive_high, current_forward_reactive_flat, current_forward_reactive_valley, current_reverse_reactive_total, current_reverse_reactive_peak, current_reverse_reactive_high, current_reverse_reactive_flat, current_reverse_reactive_valley, phase_a_voltage, phase_b_voltage, phase_c_voltage, phase_a_current, phase_b_current, phase_c_current, frequency, ab_line_voltage, cb_line_voltage, ac_line_voltage, forward_ac_max_demand, reverse_ac_max_demand, phase_a_active_power, phase_b_active_power, phase_c_active_power, total_active_power, phase_a_reactive_power, phase_b_reactive_power, phase_c_reactive_power, total_reactive_power, phase_a_apparent_power, phase_b_apparent_power, phase_c_apparent_power, total_apparent_power, phase_a_power_factor, phase_b_power_factor, phase_c_power_factor, total_power_factor, daily_forward_max_demand, site_id, device_id, create_by, create_time, update_by, update_time, remark, secondary_ab_line_voltage, secondary_a_phase_current, secondary_a_phase_voltage, secondary_a_power_factor, secondary_a_apparent_power, secondary_a_reactive_power, secondary_a_active_power, secondary_bc_line_voltage, secondary_b_phase_current, secondary_b_phase_voltage, secondary_b_power_factor, secondary_b_apparent_power, secondary_b_reactive_power, secondary_b_active_power, secondary_ca_line_voltage, secondary_c_phase_current, secondary_c_phase_voltage, secondary_c_power_factor, secondary_c_apparent_power, secondary_c_reactive_power, secondary_c_active_power, secondary_grid_frequency, secondary_reverse_reactive_energy, secondary_negative_active_energy, secondary_total_power_factor, secondary_total_apparent_power, secondary_total_reactive_power, secondary_positive_reactive_energy, secondary_positive_active_energy, secondary_total_active_power, reverse_reactive_energy_eq_minus, reverse_active_energy_ep_minus, positive_reactive_energy_eq_plus, positive_active_energy_ep_plus, current_percent, voltage_percent, avg_current, total_forward_active_two, total_peak_forward_active, total_high_forward_active, total_flat_forward_active, total_valley_forward_active, total_reverse_active_two, total_peak_reverse_active, total_high_reverse_active, total_flat_reverse_active, total_valley_reverse_active, disconnect_detection_indication, rated_primary_current_value, switch_input_output_status, alarm_status, current_total_voltage_percent, voltage_content_percent, voltage_ac_percent, current_total_current_percent, current_content_percent, current_ac_percent, current_total_power_percent, power_content_percent, power_ac_percent, data_setting_year_month, data_setting_day_hour, data_setting_minutes_seconds, current_rate, version_number, voltage, current, power, internal_temp, total_forward_active_one, total_reverse_active_one, forward_reactive_max_demand, reverse_reactive_max_demand, a_forward_active_energy, b_forward_active_energy, c_forward_active_energy, dido_status, running_status, zero_seq_current, voltage_unbalance_degree, current_unbalance_degree, daily_reverse_ac_max_demand, daily_forward_reac_max_demand, daily_reverse_reac_max_demand, pre_day_forward_ac_max_demand, pre_day_reverse_ac_max_demand, pre_day_forward_reac_max_demand, pre_day_reverse_reac_max_demand, pre_2d_forward_ac_max_demand, pre_2d_reverse_ac_max_demand, pre_2d_forward_reac_max_demand, pre_2d_reverse_reac_max_demand, current_forward_ac_demand, current_reverse_ac_demand, current_forward_reac_demand, current_reverse_reac_demand from ems_ammeter_data @@ -333,6 +451,65 @@ current_percent, voltage_percent, avg_current, + total_forward_active_two, + total_peak_forward_active, + total_high_forward_active, + total_flat_forward_active, + total_valley_forward_active, + total_reverse_active_two, + total_peak_reverse_active, + total_high_reverse_active, + total_flat_reverse_active, + total_valley_reverse_active, + disconnect_detection_indication, + rated_primary_current_value, + switch_input_output_status, + alarm_status, + current_total_voltage_percent, + voltage_content_percent, + voltage_ac_percent, + current_total_current_percent, + current_content_percent, + current_ac_percent, + current_total_power_percent, + power_content_percent, + power_ac_percent, + data_setting_year_month, + data_setting_day_hour, + data_setting_minutes_seconds, + current_rate, + version_number, + voltage, + current, + power, + internal_temp, + total_forward_active_one, + total_reverse_active_one, + forward_reactive_max_demand, + reverse_reactive_max_demand, + a_forward_active_energy, + b_forward_active_energy, + c_forward_active_energy, + dido_status, + running_status, + zero_seq_current, + voltage_unbalance_degree, + current_unbalance_degree, + daily_reverse_ac_max_demand, + daily_forward_reac_max_demand, + daily_reverse_reac_max_demand, + pre_day_forward_ac_max_demand, + pre_day_reverse_ac_max_demand, + pre_day_forward_reac_max_demand, + pre_day_reverse_reac_max_demand, + pre_2d_forward_ac_max_demand, + pre_2d_reverse_ac_max_demand, + pre_2d_forward_reac_max_demand, + pre_2d_reverse_reac_max_demand, + current_forward_ac_demand, + current_reverse_ac_demand, + current_forward_reac_demand, + current_reverse_reac_demand, #{dataUpdateTime}, @@ -439,6 +616,65 @@ #{currentPercent}, #{voltagePercent}, #{avgCurrent}, + #{totalForwardActiveTwo}, + #{totalPeakForwardActive}, + #{totalHighForwardActive}, + #{totalFlatForwardActive}, + #{totalValleyForwardActive}, + #{totalReverseActiveTwo}, + #{totalPeakReverseActive}, + #{totalHighReverseActive}, + #{totalFlatReverseActive}, + #{totalValleyReverseActive}, + #{disconnectDetectionIndication}, + #{ratedPrimaryCurrentValue}, + #{switchInputOutputStatus}, + #{alarmStatus}, + #{currentTotalVoltagePercent}, + #{voltageContentPercent}, + #{voltageAcPercent}, + #{currentTotalCurrentPercent}, + #{currentContentPercent}, + #{currentAcPercent}, + #{currentTotalPowerPercent}, + #{powerContentPercent}, + #{powerAcPercent}, + #{dataSettingYearMonth}, + #{dataSettingDayHour}, + #{dataSettingMinutesSeconds}, + #{currentRate}, + #{versionNumber}, + #{voltage}, + #{current}, + #{power}, + #{internalTemp}, + #{totalForwardActiveOne}, + #{totalReverseActiveOne}, + #{forwardReactiveMaxDemand}, + #{reverseReactiveMaxDemand}, + #{aForwardActiveEnergy}, + #{bForwardActiveEnergy}, + #{cForwardActiveEnergy}, + #{didoStatus}, + #{runningStatus}, + #{zeroSeqCurrent}, + #{voltageUnbalanceDegree}, + #{currentUnbalanceDegree}, + #{dailyReverseAcMaxDemand}, + #{dailyForwardReacMaxDemand}, + #{dailyReverseReacMaxDemand}, + #{preDayForwardAcMaxDemand}, + #{preDayReverseAcMaxDemand}, + #{preDayForwardReacMaxDemand}, + #{preDayReverseReacMaxDemand}, + #{pre2dForwardAcMaxDemand}, + #{pre2dReverseAcMaxDemand}, + #{pre2dForwardReacMaxDemand}, + #{pre2dReverseReacMaxDemand}, + #{currentForwardAcDemand}, + #{currentReverseAcDemand}, + #{currentForwardReacDemand}, + #{currentReverseReacDemand}, @@ -549,6 +785,65 @@ current_percent = #{currentPercent}, voltage_percent = #{voltagePercent}, avg_current = #{avgCurrent}, + total_forward_active_two = #{totalForwardActiveTwo}, + total_peak_forward_active = #{totalPeakForwardActive}, + total_high_forward_active = #{totalHighForwardActive}, + total_flat_forward_active = #{totalFlatForwardActive}, + total_valley_forward_active = #{totalValleyForwardActive}, + total_reverse_active_two = #{totalReverseActiveTwo}, + total_peak_reverse_active = #{totalPeakReverseActive}, + total_high_reverse_active = #{totalHighReverseActive}, + total_flat_reverse_active = #{totalFlatReverseActive}, + total_valley_reverse_active = #{totalValleyReverseActive}, + disconnect_detection_indication = #{disconnectDetectionIndication}, + rated_primary_current_value = #{ratedPrimaryCurrentValue}, + switch_input_output_status = #{switchInputOutputStatus}, + alarm_status = #{alarmStatus}, + current_total_voltage_percent = #{currentTotalVoltagePercent}, + voltage_content_percent = #{voltageContentPercent}, + voltage_ac_percent = #{voltageAcPercent}, + current_total_current_percent = #{currentTotalCurrentPercent}, + current_content_percent = #{currentContentPercent}, + current_ac_percent = #{currentAcPercent}, + current_total_power_percent = #{currentTotalPowerPercent}, + power_content_percent = #{powerContentPercent}, + power_ac_percent = #{powerAcPercent}, + data_setting_year_month = #{dataSettingYearMonth}, + data_setting_day_hour = #{dataSettingDayHour}, + data_setting_minutes_seconds = #{dataSettingMinutesSeconds}, + current_rate = #{currentRate}, + version_number = #{versionNumber}, + voltage = #{voltage}, + current = #{current}, + power = #{power}, + internal_temp = #{internalTemp}, + total_forward_active_one = #{totalForwardActiveOne}, + total_reverse_active_one = #{totalReverseActiveOne}, + forward_reactive_max_demand = #{forwardReactiveMaxDemand}, + reverse_reactive_max_demand = #{reverseReactiveMaxDemand}, + a_forward_active_energy = #{aForwardActiveEnergy}, + b_forward_active_energy = #{bForwardActiveEnergy}, + c_forward_active_energy = #{cForwardActiveEnergy}, + dido_status = #{didoStatus}, + running_status = #{runningStatus}, + zero_seq_current = #{zeroSeqCurrent}, + voltage_unbalance_degree = #{voltageUnbalanceDegree}, + current_unbalance_degree = #{currentUnbalanceDegree}, + daily_reverse_ac_max_demand = #{dailyReverseAcMaxDemand}, + daily_forward_reac_max_demand = #{dailyForwardReacMaxDemand}, + daily_reverse_reac_max_demand = #{dailyReverseReacMaxDemand}, + pre_day_forward_ac_max_demand = #{preDayForwardAcMaxDemand}, + pre_day_reverse_ac_max_demand = #{preDayReverseAcMaxDemand}, + pre_day_forward_reac_max_demand = #{preDayForwardReacMaxDemand}, + pre_day_reverse_reac_max_demand = #{preDayReverseReacMaxDemand}, + pre_2d_forward_ac_max_demand = #{pre2dForwardAcMaxDemand}, + pre_2d_reverse_ac_max_demand = #{pre2dReverseAcMaxDemand}, + pre_2d_forward_reac_max_demand = #{pre2dForwardReacMaxDemand}, + pre_2d_reverse_reac_max_demand = #{pre2dReverseReacMaxDemand}, + current_forward_ac_demand = #{currentForwardAcDemand}, + current_reverse_ac_demand = #{currentReverseAcDemand}, + current_forward_reac_demand = #{currentForwardReacDemand}, + current_reverse_reac_demand = #{currentReverseReacDemand}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 3522724..55be7aa 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -59,32 +59,10 @@ - - - - - - - - - - - - - - - - - - - - - - - select id, work_status, pcs_communication_status, ems_communication_status, cluster_voltage, chargeable_capacity, total_charged_capacity, cluster_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id, stack_device_id, max_allowed_charge_power, max_allowed_discharge_power, max_allowed_charge_voltage, max_allowed_discharge_voltage, max_allowed_charge_current, max_allowed_discharge_current, battery_pack_voltage, battery_pack_current, battery_pack_temp, battery_pack_soc, battery_pack_soh, battery_pack_insulation_resistance, avg_cell_voltage, avg_cell_temp, max_cell_voltage, max_cell_voltage_id, min_cell_voltage, min_cell_voltage_id, max_cell_temp, max_cell_temp_id, min_cell_temp, min_cell_temp_id, max_cell_soc, max_cell_soc_id, min_cell_soc, min_cell_soc_id, max_cell_soh, max_cell_soh_id, min_cell_soh, min_cell_soh_id, total_charge_energy, total_discharge_energy, disconnect_detection_indication, voltage_transfor_ratio, rated_primary_current_value, switch_input_output_status, alarm_status, current_total_voltage_percent, voltage_content_percent, voltage_ac_percent, current_total_current_percent, current_content_percent, current_ac_percent, current_total_power_percent, power_content_percent, power_ac_percent, data_setting_year_month, data_setting_day_hour, data_setting_minutes_seconds, current_rate, version_number, voltage, current, power from ems_battery_cluster + select id, work_status, pcs_communication_status, ems_communication_status, cluster_voltage, chargeable_capacity, total_charged_capacity, cluster_current, dischargeable_capacity, total_discharged_capacity, soh, average_temperature, insulation_resistance, current_soc, create_by, create_time, update_by, update_time, remark, site_id, device_id, stack_device_id, max_allowed_charge_power, max_allowed_discharge_power, max_allowed_charge_voltage, max_allowed_discharge_voltage, max_allowed_charge_current, max_allowed_discharge_current, battery_pack_voltage, battery_pack_current, battery_pack_temp, battery_pack_soc, battery_pack_soh, battery_pack_insulation_resistance, avg_cell_voltage, avg_cell_temp, max_cell_voltage, max_cell_voltage_id, min_cell_voltage, min_cell_voltage_id, max_cell_temp, max_cell_temp_id, min_cell_temp, min_cell_temp_id, max_cell_soc, max_cell_soc_id, min_cell_soc, min_cell_soc_id, max_cell_soh, max_cell_soh_id, min_cell_soh, min_cell_soh_id, total_charge_energy, total_discharge_energy from ems_battery_cluster @@ -224,28 +180,6 @@ min_cell_soh_id, total_charge_energy, total_discharge_energy, - disconnect_detection_indication, - voltage_transfor_ratio, - rated_primary_current_value, - switch_input_output_status, - alarm_status, - current_total_voltage_percent, - voltage_content_percent, - voltage_ac_percent, - current_total_current_percent, - current_content_percent, - current_ac_percent, - current_total_power_percent, - power_content_percent, - power_ac_percent, - data_setting_year_month, - data_setting_day_hour, - data_setting_minutes_seconds, - current_rate, - version_number, - voltage, - current, - power, #{workStatus}, @@ -301,28 +235,6 @@ #{minCellSohId}, #{totalChargeEnergy}, #{totalDischargeEnergy}, - #{disconnectDetectionIndication}, - #{voltageTransforRatio}, - #{ratedPrimaryCurrentValue}, - #{switchInputOutputStatus}, - #{alarmStatus}, - #{currentTotalVoltagePercent}, - #{voltageContentPercent}, - #{voltageAcPercent}, - #{currentTotalCurrentPercent}, - #{currentContentPercent}, - #{currentAcPercent}, - #{currentTotalPowerPercent}, - #{powerContentPercent}, - #{powerAcPercent}, - #{dataSettingYearMonth}, - #{dataSettingDayHour}, - #{dataSettingMinutesSeconds}, - #{currentRate}, - #{versionNumber}, - #{voltage}, - #{current}, - #{power}, @@ -382,28 +294,6 @@ min_cell_soh_id = #{minCellSohId}, total_charge_energy = #{totalChargeEnergy}, total_discharge_energy = #{totalDischargeEnergy}, - disconnect_detection_indication = #{disconnectDetectionIndication}, - voltage_transfor_ratio = #{voltageTransforRatio}, - rated_primary_current_value = #{ratedPrimaryCurrentValue}, - switch_input_output_status = #{switchInputOutputStatus}, - alarm_status = #{alarmStatus}, - current_total_voltage_percent = #{currentTotalVoltagePercent}, - voltage_content_percent = #{voltageContentPercent}, - voltage_ac_percent = #{voltageAcPercent}, - current_total_current_percent = #{currentTotalCurrentPercent}, - current_content_percent = #{currentContentPercent}, - current_ac_percent = #{currentAcPercent}, - current_total_power_percent = #{currentTotalPowerPercent}, - power_content_percent = #{powerContentPercent}, - power_ac_percent = #{powerAcPercent}, - data_setting_year_month = #{dataSettingYearMonth}, - data_setting_day_hour = #{dataSettingDayHour}, - data_setting_minutes_seconds = #{dataSettingMinutesSeconds}, - current_rate = #{currentRate}, - version_number = #{versionNumber}, - voltage = #{voltage}, - current = #{current}, - power = #{power}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index 3760a95..5776165 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -22,10 +22,11 @@ + - select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id from ems_battery_data + select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance from ems_battery_data @@ -69,6 +71,7 @@ site_id, device_id, cluster_device_id, + inter_resistance, #{batteryPack}, @@ -87,6 +90,7 @@ #{siteId}, #{deviceId}, #{clusterDeviceId}, + #{interResistance}, @@ -109,6 +113,7 @@ site_id = #{siteId}, device_id = #{deviceId}, cluster_device_id = #{clusterDeviceId}, + inter_resistance = #{interResistance}, where id = #{id} @@ -202,14 +207,14 @@ battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, - remark, site_id, device_id, cluster_device_id + remark, site_id, device_id, cluster_device_id, inter_resistance ) VALUES ( #{item.batteryPack}, #{item.batteryCluster}, #{item.batteryCellId}, #{item.voltage}, #{item.temperature}, #{item.soc}, #{item.soh}, #{item.dataTimestamp}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, - #{item.remark}, #{item.siteId}, #{item.deviceId}, #{item.clusterDeviceId} + #{item.remark}, #{item.siteId}, #{item.deviceId}, #{item.clusterDeviceId},#{item.interResistance} ) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryGroupMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryGroupMapper.xml new file mode 100644 index 0000000..2a18355 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryGroupMapper.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, status, voltage, current, soc, soh, estimated_backup_duration, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_battery_group + + + + + + + + insert into ems_battery_group + + status, + voltage, + current, + soc, + soh, + estimated_backup_duration, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + + + #{status}, + #{voltage}, + #{current}, + #{soc}, + #{soh}, + #{estimatedBackupDuration}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + + + + + update ems_battery_group + + status = #{status}, + voltage = #{voltage}, + current = #{current}, + soc = #{soc}, + soh = #{soh}, + estimated_backup_duration = #{estimatedBackupDuration}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + + where id = #{id} + + + + delete from ems_battery_group where id = #{id} + + + + delete from ems_battery_group where id in + + #{id} + + + + + INSERT INTO ems_battery_group ( + status, + voltage, + current, + soc, + soh, + estimated_backup_duration, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id + ) VALUES + + + ( + #{item.status}, + #{item.voltage}, + #{item.current}, + #{item.soc}, + #{item.soh}, + #{item.estimatedBackupDuration}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.remark}, + #{item.siteId}, + #{item.deviceId} + ) + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsDhDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDhDataMapper.xml new file mode 100644 index 0000000..8844d1c --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsDhDataMapper.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + select id, humidity, temperature, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_dh_data + + + + + + + + insert into ems_dh_data + + humidity, + temperature, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + + + #{humidity}, + #{temperature}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + + + + + update ems_dh_data + + humidity = #{humidity}, + temperature = #{temperature}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + + where id = #{id} + + + + delete from ems_dh_data where id = #{id} + + + + delete from ems_dh_data where id in + + #{id} + + + \ No newline at end of file -- 2.49.0 From a12f7820cfb5a8b5fc8d9a71b2466f1e2ac8ce78 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 29 Jul 2025 18:28:17 +0800 Subject: [PATCH 112/336] =?UTF-8?q?DDS=E7=9B=91=E6=8E=A7=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/mapper/EmsDevicesSettingMapper.java | 2 +- .../impl/DDSDataProcessServiceImpl.java | 46 ++++++++----------- .../ems/service/impl/EmsSiteServiceImpl.java | 2 +- .../service/impl/SingleSiteServiceImpl.java | 14 +++--- .../mapper/ems/EmsDevicesSettingMapper.xml | 5 +- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 66f78af..80fa7cc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -66,7 +66,7 @@ public interface EmsDevicesSettingMapper * @param parentId * @return */ - public List> getDeviceInfoByParentId(String parentId); + public List> getDeviceInfoByParentId(@Param("siteId")String siteId, @Param("parentId")String parentId); /** * 根据site_id和device_category获取指定设备信息 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 7aecc73..8e6d4e9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -299,8 +299,8 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { List dataList = new ArrayList<>(dataMap.values()); emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList)); - redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId); - redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, dataList); + redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01"); + redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01" , dataList); } // 批量处理每日最新数据 if (dailyList != null && dailyList.size() > 0) { @@ -522,32 +522,26 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { Map> records = processDataPrefix(JSON.parseObject(dataJson, new TypeReference>() {})); List list = new ArrayList<>(); - //PCS支路 - for (Map.Entry> record : records.entrySet()) { - String recordId = record.getKey(); - Map fields = record.getValue(); + EmsPcsBranchData data = new EmsPcsBranchData(); + data.setDeviceId(deviceId); + data.setSiteId(SITE_ID); + data.setGridStatus(GridStatus.GRID.getCode()); - EmsPcsBranchData data = new EmsPcsBranchData(); - data.setDeviceId(deviceId); - data.setGridStatus(GridStatus.GRID.getCode()); - - data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUAB"))); - data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUBC"))); - data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWXDYUCA"))); - data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("PCSJLDLIA"))); - data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("PCSJLDLIB"))); - data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("PCSJLDLIC"))); - - data.setBranchId(recordId); - list.add(data); - } - if (list.size() > 0 ) { - emsPcsBranchDataMapper.insertPcsBranchDataList(list); - - redisCache.setCacheObject(RedisKeyConstants.BRANCH + SITE_ID + "_" +deviceId, list); - - } + data.setGridUVoltage(StringUtils.getBigDecimal(records.get("DWXDYUAB"))); + data.setGridVVoltage(StringUtils.getBigDecimal(records.get("DWXDYUBC"))); + data.setGridWVoltage(StringUtils.getBigDecimal(records.get("DWXDYUCA"))); + data.setOutputUCurrent(StringUtils.getBigDecimal(records.get("PCSJLDLIA"))); + data.setOutputVCurrent(StringUtils.getBigDecimal(records.get("PCSJLDLIB"))); + data.setOutputWCurrent(StringUtils.getBigDecimal(records.get("PCSJLDLIC"))); + data.setBranchId("DY1"); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + list.add(data); + emsPcsBranchDataMapper.insertPcsBranchDataList(list); + redisCache.setCacheObject(RedisKeyConstants.BRANCH + SITE_ID + "_" +deviceId, list); } private void meteGFDataProcess(String deviceId, String dataJson) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index c73f716..1aee491 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -53,7 +53,7 @@ public class EmsSiteServiceImpl implements IEmsSiteService */ @Override public List> getAllClusterInfo(String parentId) { - return emsDevicesMapper.getDeviceInfoByParentId(parentId); + return emsDevicesMapper.getDeviceInfoByParentId(null,parentId); } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 398a063..4e0d25b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -260,7 +260,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private void getBMSClusterListInfo(String siteId, String stackId, BMSOverViewVo bmsOverViewVo) { List batteryDataList = new ArrayList(); - List> clusterIds = emsDevicesSettingMapper.getDeviceInfoByParentId(stackId); + List> clusterIds = emsDevicesSettingMapper.getDeviceInfoByParentId(siteId, stackId); for (Map clusterDevice : clusterIds) { BMSBatteryDataList bmsBatteryDataList= new BMSBatteryDataList(); // 从redis取单个簇的详细数据 @@ -313,21 +313,21 @@ public class SingleSiteServiceImpl implements ISingleSiteService { voltageData.setDataName(CLUSTER_DATA_VOLTAGE); voltageData.setAvgData(clusterData.getAvgCellVoltage()); voltageData.setMaxData(clusterData.getMaxCellVoltage()); - voltageData.setMaxDataID(clusterData.getMaxCellVoltageId().toString()); + voltageData.setMaxDataID(clusterData.getMaxCellVoltageId() == null ? null : clusterData.getMaxCellVoltageId().toString()); voltageData.setMinData(clusterData.getMinCellVoltage()); - voltageData.setMinDataID(clusterData.getMinCellVoltageId().toString()); + voltageData.setMinDataID(clusterData.getMinCellVoltageId() == null ? null : clusterData.getMinCellVoltageId().toString()); tempData.setDataName(CLUSTER_DATA_TEP); tempData.setAvgData(clusterData.getAvgCellTemp()); tempData.setMaxData(clusterData.getMaxCellTemp()); - tempData.setMaxDataID(clusterData.getMaxCellTempId().toString()); + tempData.setMaxDataID(clusterData.getMaxCellTempId() == null ? null : clusterData.getMaxCellTempId().toString()); tempData.setMinData(clusterData.getMinCellTemp()); - tempData.setMinDataID(clusterData.getMinCellTempId().toString()); + tempData.setMinDataID(clusterData.getMinCellTempId() == null ? null : clusterData.getMinCellTempId().toString()); socData.setDataName(CLUSTER_DATA_SOC); socData.setAvgData(clusterData.getCurrentSoc()); socData.setMaxData(clusterData.getMaxCellSoc()); - socData.setMaxDataID(clusterData.getMaxCellSocId().toString()); + socData.setMaxDataID(clusterData.getMaxCellSocId() == null ? null : clusterData.getMaxCellSocId().toString()); socData.setMinData(clusterData.getMinCellSoc()); - socData.setMinDataID(clusterData.getMinCellSocId().toString()); + socData.setMinDataID(clusterData.getMinCellSocId() == null ? null : clusterData.getMinCellSocId().toString()); clusterDataList.add(voltageData); clusterDataList.add(tempData); diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index df9a946..750d7db 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -161,7 +161,10 @@ + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 869d635..4c1c4d9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -348,7 +348,7 @@ + + where site_id = #{siteId} and strategy_id = #{strategyId} + + \ No newline at end of file -- 2.49.0 From ff058dceaff2f30f73b99104113a7e4a869d44b6 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 13 Aug 2025 23:41:34 +0800 Subject: [PATCH 120/336] =?UTF-8?q?20250808=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E4=BD=93=E7=94=B5=E6=B1=A0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 24 +++++++++++-- .../core/controller/BaseController.java | 23 ++++++++++++ .../ems/domain/vo/SiteBatteryDataList.java | 36 +++++++++++++++++++ .../ems/mapper/EmsDevicesSettingMapper.java | 3 ++ .../xzzn/ems/service/ISingleSiteService.java | 4 ++- .../service/impl/SingleSiteServiceImpl.java | 28 +++++++++++---- .../mapper/ems/EmsDevicesSettingMapper.xml | 12 +++++++ 7 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryDataList.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 700677c..8964915 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -3,14 +3,17 @@ 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.vo.BMSBatteryDataList; import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import com.xzzn.ems.domain.vo.DateSearchRequest; +import com.xzzn.ems.domain.vo.SiteBatteryDataList; import com.xzzn.ems.service.IEmsSiteService; import com.xzzn.ems.service.IEmsStatsReportService; import com.xzzn.ems.service.ISingleSiteService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Arrays; import java.util.List; /** @@ -141,11 +144,26 @@ public class EmsSiteMonitorController extends BaseController{ * 获取电池簇下面的单体电池数据 */ @GetMapping("/getClusterDataInfoList") - public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId) + public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId,@RequestParam String stackDeviceId) { startPage(); - List list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId); - return getDataTable2(list); + SiteBatteryDataList siteBatteryDataList = new SiteBatteryDataList(); + // 簇最大最小单体id数据 + List clusterBatteryDataList = iSingleSiteService.getClusterBatteryList(siteId,stackDeviceId,clusterDeviceId); + siteBatteryDataList.setClusterList(clusterBatteryDataList); + // 单体电池数据 + List List = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId,stackDeviceId); + // 对batteryList进行分页处理 + List batteryList = paginateList(List); + siteBatteryDataList.setBatteryList(batteryList); + + // 封装分页信息 + TableDataInfo pageInfo = new TableDataInfo(); + pageInfo.setTotal(List.size()); + pageInfo.setRows(Arrays.asList(siteBatteryDataList)); + pageInfo.setCode(0); + pageInfo.setMsg("查询成功"); + return pageInfo; } /** diff --git a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java index 2eb7f8f..dd96aa1 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java +++ b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java @@ -232,4 +232,27 @@ public class BaseController rspData.setTotal(list.size()); return rspData; } + + /** + * 通用分页工具方法 + */ + protected List paginateList(List sourceList) { + if (sourceList == null || sourceList.isEmpty()) { + return new ArrayList<>(); + } + // 分页梳理 + PageDomain pageDomain = TableSupport.buildPageRequest(); + int pageNum = pageDomain.getPageNum(); + int pageSize = pageDomain.getPageSize(); + int startIndex = 0; + int endIndex = sourceList.size(); + if (pageNum > 0 && pageSize > 0) { + // 计算起始索引(处理页码小于1的情况) + startIndex = Math.max((pageNum - 1) * pageSize, 0); + // 计算结束索引(处理超出列表长度的情况) + endIndex = Math.min(startIndex + pageSize, sourceList.size()); + } + // 截取分页数据 + return sourceList.subList(startIndex, endIndex); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryDataList.java new file mode 100644 index 0000000..aed6e02 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryDataList.java @@ -0,0 +1,36 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +import java.util.List; + +/** + * 单站监控-单体电池返回数据 + * + */ +public class SiteBatteryDataList { + + // 簇相关单体最大最小值list + @Excel(name = "簇单体最大最小值list") + List clusterList; + + // 单体电池list + @Excel(name = "单体电池list") + List batteryList; + + public List getClusterList() { + return clusterList; + } + + public void setClusterList(List clusterList) { + this.clusterList = clusterList; + } + + public List getBatteryList() { + return batteryList; + } + + public void setBatteryList(List batteryList) { + this.batteryList = batteryList; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 80fa7cc..1f451de 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -84,4 +84,7 @@ public interface EmsDevicesSettingMapper public List> getLoadNameList(String siteId); public EmsDevicesSetting getDeviceBySiteAndDeviceId(@Param("deviceId")String deviceId, @Param("siteId")String siteId); + + public List> getClusterIdsByFuzzyQuery(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, + @Param("parentId")String parentId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 398e12b..acfb411 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -27,7 +27,7 @@ public interface ISingleSiteService public List getCoolingDataList(String siteId); - public List getClusterDataInfoList(String clusterDeviceId,String siteId); + public List getClusterDataInfoList(String clusterDeviceId,String siteId,String stackDeviceId); public AmmeterDataResponse getAmmeterDataList(String siteId); @@ -36,4 +36,6 @@ public interface ISingleSiteService public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId); public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId); + + public List getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 43d4d80..22e76ca 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -270,8 +270,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { BeanUtils.copyProperties(stackData, bmsOverViewVo); } // 下面簇列表数据 + List batteryDataLists = new ArrayList<>(); if (!StringUtils.isEmpty(stackId)) { - getBMSClusterListInfo(siteId,stackId,bmsOverViewVo); + batteryDataLists = getBMSClusterListInfo(siteId,stackId,null); + bmsOverViewVo.setBatteryDataList(batteryDataLists); } bmsOverViewVoList.add(bmsOverViewVo); } @@ -279,10 +281,18 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return bmsOverViewVoList; } - private void getBMSClusterListInfo(String siteId, String stackId, BMSOverViewVo bmsOverViewVo) { + private List getBMSClusterListInfo(String siteId, String stackId, String clusterDeviceId) { List batteryDataList = new ArrayList(); - List> clusterIds = emsDevicesSettingMapper.getDeviceInfoByParentId(siteId, stackId); + List> clusterIds = new ArrayList<>(); + if (StringUtils.isEmpty(clusterDeviceId)) { + clusterIds = emsDevicesSettingMapper.getClusterIdsByFuzzyQuery(siteId, DeviceCategory.CLUSTER.getCode(),stackId); + } else { + Map map = new HashMap<>(); + map.put("id", clusterDeviceId); + clusterIds.add(map); + } + for (Map clusterDevice : clusterIds) { BMSBatteryDataList bmsBatteryDataList= new BMSBatteryDataList(); // 从redis取单个簇的详细数据 @@ -295,7 +305,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { batteryDataList.add(bmsBatteryDataList); } - bmsOverViewVo.setBatteryDataList(batteryDataList); + return batteryDataList; } // 获取BMS电池簇数据 @@ -373,11 +383,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public List getClusterDataInfoList(String clusterDeviceId,String siteId) { + public List getClusterDataInfoList(String clusterDeviceId,String siteId,String stackDeviceId) { List batteryDataStatsListVo = new ArrayList<>(); List> clusterIds = new ArrayList<>(); if (StringUtils.isEmpty(clusterDeviceId)) { - clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode()); + clusterIds = emsDevicesSettingMapper.getClusterIdsByFuzzyQuery(siteId, DeviceCategory.CLUSTER.getCode(),stackDeviceId); } else { Map map = new HashMap<>(); map.put("id", clusterDeviceId); @@ -402,6 +412,12 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return sortedList; } + // 获取单站的最大最小温度和电压单体数据id + @Override + public List getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId) { + return getBMSClusterListInfo(siteId, stackDeviceId,clusterDeviceId); + } + /** * 电表数据信息 * @param siteId diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 750d7db..fd7bb73 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -198,4 +198,16 @@ + + \ No newline at end of file -- 2.49.0 From b2527507e48a1e5a51042644a35a937055b07351 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 16 Aug 2025 10:28:06 +0800 Subject: [PATCH 121/336] =?UTF-8?q?20250808=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E4=BD=93=E7=94=B5=E6=B1=A0=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 5 +- .../core/controller/BaseController.java | 4 ++ .../com/xzzn/common/utils/StringUtils.java | 13 ++++ .../xzzn/ems/domain/EmsBatteryCluster.java | 65 ++++++++++--------- .../ems/domain/vo/BMSBatteryDataList.java | 24 +++---- .../xzzn/ems/service/ISingleSiteService.java | 3 +- .../impl/DDSDataProcessServiceImpl.java | 8 +-- .../impl/FXXDataProcessServiceImpl.java | 16 ++--- .../service/impl/SingleSiteServiceImpl.java | 25 +++++-- 9 files changed, 99 insertions(+), 64 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 8964915..98ab612 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -144,7 +144,8 @@ public class EmsSiteMonitorController extends BaseController{ * 获取电池簇下面的单体电池数据 */ @GetMapping("/getClusterDataInfoList") - public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId,@RequestParam String stackDeviceId) + public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId, + @RequestParam String stackDeviceId,@RequestParam String batteryId) { startPage(); SiteBatteryDataList siteBatteryDataList = new SiteBatteryDataList(); @@ -152,7 +153,7 @@ public class EmsSiteMonitorController extends BaseController{ List clusterBatteryDataList = iSingleSiteService.getClusterBatteryList(siteId,stackDeviceId,clusterDeviceId); siteBatteryDataList.setClusterList(clusterBatteryDataList); // 单体电池数据 - List List = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId,stackDeviceId); + List List = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId,stackDeviceId,batteryId); // 对batteryList进行分页处理 List batteryList = paginateList(List); siteBatteryDataList.setBatteryList(batteryList); diff --git a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java index dd96aa1..a05a357 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java +++ b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java @@ -252,6 +252,10 @@ public class BaseController // 计算结束索引(处理超出列表长度的情况) endIndex = Math.min(startIndex + pageSize, sourceList.size()); } + // 防止越界 + if (startIndex >= sourceList.size()) { + return Collections.emptyList(); + } // 截取分页数据 return sourceList.subList(startIndex, endIndex); } diff --git a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java index 555f8a4..5fc29b9 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/StringUtils.java @@ -751,4 +751,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils } return result; } + + // 补全三位数字(返回字符串) + public static String fillThreeDigits(String value) { + if (value == null || value.trim().isEmpty()) { + return "000"; + } + try { + int num = Integer.parseInt(value.trim()); + return String.format("%03d", num); + } catch (NumberFormatException e) { + return value; + } + } } \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java index bc74ed7..e1a00c3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java @@ -3,6 +3,7 @@ package com.xzzn.ems.domain; import java.math.BigDecimal; import com.xzzn.common.core.domain.BaseEntity; +import com.xzzn.common.utils.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.xzzn.common.annotation.Excel; @@ -146,7 +147,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最高单体电压对应点号 */ @Excel(name = "最高单体电压对应点号") - private Long maxCellVoltageId; + private String maxCellVoltageId; /** 最低单体电压 */ @Excel(name = "最低单体电压") @@ -154,7 +155,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最低单体电压对应点号 */ @Excel(name = "最低单体电压对应点号") - private Long minCellVoltageId; + private String minCellVoltageId; /** 最高单体温度 */ @Excel(name = "最高单体温度") @@ -162,7 +163,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最高单体温度对应点号 */ @Excel(name = "最高单体温度对应点号") - private Long maxCellTempId; + private String maxCellTempId; /** 最低单体温度 */ @Excel(name = "最低单体温度") @@ -170,7 +171,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最低单体温度对应点号 */ @Excel(name = "最低单体温度对应点号") - private Long minCellTempId; + private String minCellTempId; /** 最高单体SOC */ @Excel(name = "最高单体SOC") @@ -178,7 +179,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最高单体SOC对应点号 */ @Excel(name = "最高单体SOC对应点号") - private Long maxCellSocId; + private String maxCellSocId; /** 最低单体SOC */ @Excel(name = "最低单体SOC") @@ -186,7 +187,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最低单体SOC对应点号 */ @Excel(name = "最低单体SOC对应点号") - private Long minCellSocId; + private String minCellSocId; /** 最高单体SOH */ @Excel(name = "最高单体SOH") @@ -194,7 +195,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最高单体SOH对应点号 */ @Excel(name = "最高单体SOH对应点号") - private Long maxCellSohId; + private String maxCellSohId; /** 最低单体SOH */ @Excel(name = "最低单体SOH") @@ -202,7 +203,7 @@ public class EmsBatteryCluster extends BaseEntity /** 最低单体SOH对应点号 */ @Excel(name = "最低单体SOH对应点号") - private Long minCellSohId; + private String minCellSohId; /** 单次累计充电电量 */ @Excel(name = "单次累计充电电量") @@ -532,12 +533,12 @@ public class EmsBatteryCluster extends BaseEntity return maxCellVoltage; } - public void setMaxCellVoltageId(Long maxCellVoltageId) + public void setMaxCellVoltageId(String maxCellVoltageId) { - this.maxCellVoltageId = maxCellVoltageId; + this.maxCellVoltageId = StringUtils.fillThreeDigits(maxCellVoltageId); } - public Long getMaxCellVoltageId() + public String getMaxCellVoltageId() { return maxCellVoltageId; } @@ -552,12 +553,12 @@ public class EmsBatteryCluster extends BaseEntity return minCellVoltage; } - public void setMinCellVoltageId(Long minCellVoltageId) + public void setMinCellVoltageId(String minCellVoltageId) { - this.minCellVoltageId = minCellVoltageId; + this.minCellVoltageId = StringUtils.fillThreeDigits(minCellVoltageId); } - public Long getMinCellVoltageId() + public String getMinCellVoltageId() { return minCellVoltageId; } @@ -572,12 +573,12 @@ public class EmsBatteryCluster extends BaseEntity return maxCellTemp; } - public void setMaxCellTempId(Long maxCellTempId) + public void setMaxCellTempId(String maxCellTempId) { - this.maxCellTempId = maxCellTempId; + this.maxCellTempId = StringUtils.fillThreeDigits(maxCellTempId); } - public Long getMaxCellTempId() + public String getMaxCellTempId() { return maxCellTempId; } @@ -592,12 +593,12 @@ public class EmsBatteryCluster extends BaseEntity return minCellTemp; } - public void setMinCellTempId(Long minCellTempId) + public void setMinCellTempId(String minCellTempId) { - this.minCellTempId = minCellTempId; + this.minCellTempId = StringUtils.fillThreeDigits(minCellTempId); } - public Long getMinCellTempId() + public String getMinCellTempId() { return minCellTempId; } @@ -612,12 +613,12 @@ public class EmsBatteryCluster extends BaseEntity return maxCellSoc; } - public void setMaxCellSocId(Long maxCellSocId) + public void setMaxCellSocId(String maxCellSocId) { - this.maxCellSocId = maxCellSocId; + this.maxCellSocId = StringUtils.fillThreeDigits(maxCellSocId); } - public Long getMaxCellSocId() + public String getMaxCellSocId() { return maxCellSocId; } @@ -632,12 +633,12 @@ public class EmsBatteryCluster extends BaseEntity return minCellSoc; } - public void setMinCellSocId(Long minCellSocId) + public void setMinCellSocId(String minCellSocId) { - this.minCellSocId = minCellSocId; + this.minCellSocId = StringUtils.fillThreeDigits(minCellSocId); } - public Long getMinCellSocId() + public String getMinCellSocId() { return minCellSocId; } @@ -652,12 +653,12 @@ public class EmsBatteryCluster extends BaseEntity return maxCellSoh; } - public void setMaxCellSohId(Long maxCellSohId) + public void setMaxCellSohId(String maxCellSohId) { - this.maxCellSohId = maxCellSohId; + this.maxCellSohId = StringUtils.fillThreeDigits(maxCellSohId); } - public Long getMaxCellSohId() + public String getMaxCellSohId() { return maxCellSohId; } @@ -672,12 +673,12 @@ public class EmsBatteryCluster extends BaseEntity return minCellSoh; } - public void setMinCellSohId(Long minCellSohId) + public void setMinCellSohId(String minCellSohId) { - this.minCellSohId = minCellSohId; + this.minCellSohId = StringUtils.fillThreeDigits(minCellSohId); } - public Long getMinCellSohId() + public String getMinCellSohId() { return minCellSohId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java index 6629543..b43ec4a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryDataList.java @@ -24,25 +24,25 @@ public class BMSBatteryDataList { private BigDecimal maxCellVoltage; /** 最高单体电压对应点号 */ - private Long maxCellVoltageId; + private String maxCellVoltageId; /** 单体最低电压 (V) */ private BigDecimal minCellVoltage; /** 最低单体电压对应点号 */ - private Long minCellVoltageId; + private String minCellVoltageId; /** 单体最高温度 (℃) */ private BigDecimal maxCellTemp; /** 最高单体温度对应点号 */ - private Long maxCellTempId; + private String maxCellTempId; /** 单体最低温度 (℃) */ private BigDecimal minCellTemp; /** 最低单体温度对应点号 */ - private Long minCellTempId; + private String minCellTempId; /** 换电站id */ private String siteId; @@ -130,35 +130,35 @@ public class BMSBatteryDataList { this.clusterVoltage = clusterVoltage; } - public Long getMaxCellVoltageId() { + public String getMaxCellVoltageId() { return maxCellVoltageId; } - public void setMaxCellVoltageId(Long maxCellVoltageId) { + public void setMaxCellVoltageId(String maxCellVoltageId) { this.maxCellVoltageId = maxCellVoltageId; } - public Long getMinCellTempId() { + public String getMinCellTempId() { return minCellTempId; } - public void setMinCellTempId(Long minCellTempId) { + public void setMinCellTempId(String minCellTempId) { this.minCellTempId = minCellTempId; } - public Long getMaxCellTempId() { + public String getMaxCellTempId() { return maxCellTempId; } - public void setMaxCellTempId(Long maxCellTempId) { + public void setMaxCellTempId(String maxCellTempId) { this.maxCellTempId = maxCellTempId; } - public Long getMinCellVoltageId() { + public String getMinCellVoltageId() { return minCellVoltageId; } - public void setMinCellVoltageId(Long minCellVoltageId) { + public void setMinCellVoltageId(String minCellVoltageId) { this.minCellVoltageId = minCellVoltageId; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index acfb411..9c9d5a3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -27,7 +27,8 @@ public interface ISingleSiteService public List getCoolingDataList(String siteId); - public List getClusterDataInfoList(String clusterDeviceId,String siteId,String stackDeviceId); + public List getClusterDataInfoList(String clusterDeviceId,String siteId, + String stackDeviceId, String batteryId); public AmmeterDataResponse getAmmeterDataList(String siteId); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index ae9d5fe..69c251f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -405,13 +405,13 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { data.setBatteryPackSoh(StringUtils.getBigDecimal(stackObj.get("BMSD01SOH"))); data.setAvgCellTemp(StringUtils.getBigDecimal(stackObj.get("DTPJWD"))); data.setMaxCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZDDY"))); - data.setMaxCellVoltageId(StringUtils.getLong(stackObj.get("DTZDDYXH"))); + data.setMaxCellVoltageId(StringUtils.getString(stackObj.get("DTZDDYXH"))); data.setMinCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZXDY"))); - data.setMinCellVoltageId(StringUtils.getLong(stackObj.get("DTZXDYXH"))); + data.setMinCellVoltageId(StringUtils.getString(stackObj.get("DTZXDYXH"))); data.setMaxCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZGWD"))); - data.setMaxCellTempId(StringUtils.getLong(stackObj.get("DTZGWDXH"))); + data.setMaxCellTempId(StringUtils.getString(stackObj.get("DTZGWDXH"))); data.setMinCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZDWD"))); - data.setMinCellTempId(StringUtils.getLong(stackObj.get("DTZDWDXH"))); + data.setMinCellTempId(StringUtils.getString(stackObj.get("DTZDWDXH"))); emsBatteryClusterMapper.insertEmsBatteryCluster(data); redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index f14fe26..ada3dd4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -234,14 +234,14 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { data.setUpdateTime(DateUtils.getNowDate()); data.setSiteId(SITE_ID); data.setDeviceId(deviceId); - data.setMaxCellVoltageId(StringUtils.getLong(obj.get("ZGDTDYDYD"))); - data.setMinCellVoltageId(StringUtils.getLong(obj.get("ZDDTDYDYD"))); - data.setMaxCellTempId(StringUtils.getLong(obj.get("ZGDTWDDYD"))); - data.setMinCellTempId(StringUtils.getLong(obj.get("ZDDTWDDYD"))); - data.setMaxCellSocId(StringUtils.getLong(obj.get("ZGDTSOCDYD"))); - data.setMinCellSocId(StringUtils.getLong(obj.get("ZDDTSOCDYD"))); - data.setMaxCellSohId(StringUtils.getLong(obj.get("ZGDTSOHDYD"))); - data.setMinCellSohId(StringUtils.getLong(obj.get("ZDDTSOHDYD"))); + data.setMaxCellVoltageId(StringUtils.getString(obj.get("ZGDTDYDYD"))); + data.setMinCellVoltageId(StringUtils.getString(obj.get("ZDDTDYDYD"))); + data.setMaxCellTempId(StringUtils.getString(obj.get("ZGDTWDDYD"))); + data.setMinCellTempId(StringUtils.getString(obj.get("ZDDTWDDYD"))); + data.setMaxCellSocId(StringUtils.getString(obj.get("ZGDTSOCDYD"))); + data.setMinCellSocId(StringUtils.getString(obj.get("ZDDTSOCDYD"))); + data.setMaxCellSohId(StringUtils.getString(obj.get("ZGDTSOHDYD"))); + data.setMinCellSohId(StringUtils.getString(obj.get("ZDDTSOHDYD"))); if (StringUtils.isNotBlank(stackDeviceId)) { data.setStackDeviceId(stackDeviceId); } else { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 22e76ca..e4b982e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -134,7 +134,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (!StringUtils.isEmpty(siteId)) { // 实时有功功率/实时无功功率/今日充电量/今日放电量 - siteMonitorRunningHeadInfoVo = emsPcsDataMapper.getSiteRunningHeadInfo(siteId); + SiteMonitorRunningHeadInfoVo tempVo = emsPcsDataMapper.getSiteRunningHeadInfo(siteId); + siteMonitorRunningHeadInfoVo = tempVo != null ? tempVo : siteMonitorRunningHeadInfoVo; // 电池堆SOC + 电池堆SOH EmsBatteryStack emsBatteryStack = emsBatteryStackMapper.getSiteSumStackInfo(siteId); if (emsBatteryStack != null) { @@ -383,7 +384,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public List getClusterDataInfoList(String clusterDeviceId,String siteId,String stackDeviceId) { + public List getClusterDataInfoList(String clusterDeviceId,String siteId, + String stackDeviceId, String batteryId) { List batteryDataStatsListVo = new ArrayList<>(); List> clusterIds = new ArrayList<>(); if (StringUtils.isEmpty(clusterDeviceId)) { @@ -399,9 +401,22 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); if (batteryDataList != null) { for (EmsBatteryData batteryData : batteryDataList) { - BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo(); - BeanUtils.copyProperties(batteryData, batteryDataStatsVo); - batteryDataStatsListVo.add(batteryDataStatsVo); + // 判断是否需要筛选:batteryId不为空时才进行匹配 + if (batteryId == null || batteryId.trim().isEmpty()) { + // 空值情况:直接添加所有数据 + BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo(); + BeanUtils.copyProperties(batteryData, batteryDataStatsVo); + batteryDataStatsListVo.add(batteryDataStatsVo); + } else { + // 有值情况:只添加匹配的数据 + if (batteryId.equals(batteryData.getDeviceId())) { + BatteryDataStatsListVo batteryDataStatsVo = new BatteryDataStatsListVo(); + BeanUtils.copyProperties(batteryData, batteryDataStatsVo); + batteryDataStatsListVo.add(batteryDataStatsVo); + // 找到匹配项后可提前退出当前簇的循环 + break; + } + } } } } -- 2.49.0 From 725ae14548fc59bd653a7f279f0c3a5c6d00a093 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 23 Aug 2025 00:09:02 +0800 Subject: [PATCH 122/336] =?UTF-8?q?20250808=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E4=BD=93=E7=94=B5=E6=B1=A0=E8=A1=A8=E6=8B=86=E5=88=86=E4=B8=BA?= =?UTF-8?q?=E5=88=86=E9=92=9F=EF=BC=8C=E6=97=B6=EF=BC=8C=E5=A4=A9=EF=BC=8C?= =?UTF-8?q?=E6=9C=88=E7=BA=A7=E5=9B=9B=E4=B8=AA=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 2 +- .../common/constant/RedisKeyConstants.java | 5 + .../xzzn/common/core/redis/RedisCache.java | 11 + .../java/com/xzzn/common/utils/DateUtils.java | 6 + .../xzzn/ems/domain/EmsBatteryDataDay.java | 242 +++++++ .../xzzn/ems/domain/EmsBatteryDataHour.java | 242 +++++++ .../ems/domain/EmsBatteryDataMinutes.java | 226 ++++++ .../xzzn/ems/domain/EmsBatteryDataMonth.java | 242 +++++++ .../ems/mapper/EmsBatteryDataDayMapper.java | 72 ++ .../ems/mapper/EmsBatteryDataHourMapper.java | 72 ++ .../mapper/EmsBatteryDataMinutesMapper.java | 68 ++ .../ems/mapper/EmsBatteryDataMonthMapper.java | 72 ++ .../impl/DDSDataProcessServiceImpl.java | 85 ++- .../impl/FXXDataProcessServiceImpl.java | 49 +- .../utils/AbstractBatteryDataProcessor.java | 681 ++++++++++++++++++ .../mapper/ems/EmsBatteryDataDayMapper.xml | 201 ++++++ .../mapper/ems/EmsBatteryDataHourMapper.xml | 202 ++++++ .../ems/EmsBatteryDataMinutesMapper.xml | 152 ++++ .../mapper/ems/EmsBatteryDataMonthMapper.xml | 202 ++++++ 19 files changed, 2785 insertions(+), 47 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDay.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataHour.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMinutes.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMonth.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataHourMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml diff --git a/ems-admin/src/main/resources/application-druid.yml b/ems-admin/src/main/resources/application-druid.yml index 3c7fe20..c7ce773 100644 --- a/ems-admin/src/main/resources/application-druid.yml +++ b/ems-admin/src/main/resources/application-druid.yml @@ -6,7 +6,7 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://122.51.194.184:13306/setri_ems?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://122.51.194.184:13306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: ems password: 12345678 # 从库数据源 diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index e16229c..58df29b 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -51,4 +51,9 @@ public class RedisKeyConstants * BMSD原始数据 redis key */ public static final String ORIGINAL_BMSD = "BMSD_"; + + /** + * mqtt监听的原始报文 + */ + public static final String MQTT_ORIGINAL = "mqtt_"; } diff --git a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java index eb9dfdf..a8af534 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java +++ b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java @@ -276,4 +276,15 @@ public class RedisCache { return redisTemplate.delete(key); } + + /** + * 批量缓存 + * @param cacheMap + */ + public void multiSet(final Map cacheMap) + { + + redisTemplate.opsForValue().multiSet(cacheMap); + } + } diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 786575b..a49d234 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -200,4 +200,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils long date = calendar.get(Calendar.DAY_OF_MONTH); // 月份从0开始,所以要加1 return date; } + + // LocalDateTime 转 Date(带时区) + public static Date convertToDate(LocalDateTime localDateTime) { + ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault()); + return Date.from(zonedDateTime.toInstant()); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDay.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDay.java new file mode 100644 index 0000000..6db06fd --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataDay.java @@ -0,0 +1,242 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_battery_data_day + * + * @author xzzn + * @date 2025-08-20 + */ +public class EmsBatteryDataDay extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 电池堆 */ + @Excel(name = "电池堆") + private String batteryPack; + + /** 电池簇 */ + @Excel(name = "电池簇") + private String batteryCluster; + + /** 单体编号 */ + @Excel(name = "单体编号") + private String batteryCellId; + + /** 电压 (V) */ + @Excel(name = "电压 (V)") + private BigDecimal voltage; + + /** 温度 (℃) */ + @Excel(name = "温度 (℃)") + private BigDecimal temperature; + + /** SOC (%) */ + @Excel(name = "SOC (%)") + private BigDecimal soc; + + /** SOH (%) */ + @Excel(name = "SOH (%)") + private BigDecimal soh; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataTimestamp; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 簇设备id */ + @Excel(name = "簇设备id") + private String clusterDeviceId; + + /** 单体电池内阻 */ + @Excel(name = "单体电池内阻") + private BigDecimal interResistance; + + /** 天级时间维度 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "天级时间维度", width = 30, dateFormat = "yyyy-MM-dd") + private Date dayTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setBatteryPack(String batteryPack) + { + this.batteryPack = batteryPack; + } + + public String getBatteryPack() + { + return batteryPack; + } + + public void setBatteryCluster(String batteryCluster) + { + this.batteryCluster = batteryCluster; + } + + public String getBatteryCluster() + { + return batteryCluster; + } + + public void setBatteryCellId(String batteryCellId) + { + this.batteryCellId = batteryCellId; + } + + public String getBatteryCellId() + { + return batteryCellId; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setTemperature(BigDecimal temperature) + { + this.temperature = temperature; + } + + public BigDecimal getTemperature() + { + return temperature; + } + + public void setSoc(BigDecimal soc) + { + this.soc = soc; + } + + public BigDecimal getSoc() + { + return soc; + } + + public void setSoh(BigDecimal soh) + { + this.soh = soh; + } + + public BigDecimal getSoh() + { + return soh; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setClusterDeviceId(String clusterDeviceId) + { + this.clusterDeviceId = clusterDeviceId; + } + + public String getClusterDeviceId() + { + return clusterDeviceId; + } + + public void setInterResistance(BigDecimal interResistance) + { + this.interResistance = interResistance; + } + + public BigDecimal getInterResistance() + { + return interResistance; + } + + public void setDayTime(Date dayTime) + { + this.dayTime = dayTime; + } + + public Date getDayTime() + { + return dayTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("batteryPack", getBatteryPack()) + .append("batteryCluster", getBatteryCluster()) + .append("batteryCellId", getBatteryCellId()) + .append("voltage", getVoltage()) + .append("temperature", getTemperature()) + .append("soc", getSoc()) + .append("soh", getSoh()) + .append("dataTimestamp", getDataTimestamp()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("clusterDeviceId", getClusterDeviceId()) + .append("interResistance", getInterResistance()) + .append("dayTime", getDayTime()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataHour.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataHour.java new file mode 100644 index 0000000..859504b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataHour.java @@ -0,0 +1,242 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_battery_data_hour + * + * @author xzzn + * @date 2025-08-19 + */ +public class EmsBatteryDataHour extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 电池堆 */ + @Excel(name = "电池堆") + private String batteryPack; + + /** 电池簇 */ + @Excel(name = "电池簇") + private String batteryCluster; + + /** 单体编号 */ + @Excel(name = "单体编号") + private String batteryCellId; + + /** 电压 (V) */ + @Excel(name = "电压 (V)") + private BigDecimal voltage; + + /** 温度 (℃) */ + @Excel(name = "温度 (℃)") + private BigDecimal temperature; + + /** SOC (%) */ + @Excel(name = "SOC (%)") + private BigDecimal soc; + + /** SOH (%) */ + @Excel(name = "SOH (%)") + private BigDecimal soh; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataTimestamp; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 簇设备id */ + @Excel(name = "簇设备id") + private String clusterDeviceId; + + /** 单体电池内阻 */ + @Excel(name = "单体电池内阻") + private BigDecimal interResistance; + + /** 小时级时间维度 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "小时级时间维度", width = 30, dateFormat = "yyyy-MM-dd") + private Date hourTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setBatteryPack(String batteryPack) + { + this.batteryPack = batteryPack; + } + + public String getBatteryPack() + { + return batteryPack; + } + + public void setBatteryCluster(String batteryCluster) + { + this.batteryCluster = batteryCluster; + } + + public String getBatteryCluster() + { + return batteryCluster; + } + + public void setBatteryCellId(String batteryCellId) + { + this.batteryCellId = batteryCellId; + } + + public String getBatteryCellId() + { + return batteryCellId; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setTemperature(BigDecimal temperature) + { + this.temperature = temperature; + } + + public BigDecimal getTemperature() + { + return temperature; + } + + public void setSoc(BigDecimal soc) + { + this.soc = soc; + } + + public BigDecimal getSoc() + { + return soc; + } + + public void setSoh(BigDecimal soh) + { + this.soh = soh; + } + + public BigDecimal getSoh() + { + return soh; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setClusterDeviceId(String clusterDeviceId) + { + this.clusterDeviceId = clusterDeviceId; + } + + public String getClusterDeviceId() + { + return clusterDeviceId; + } + + public void setInterResistance(BigDecimal interResistance) + { + this.interResistance = interResistance; + } + + public BigDecimal getInterResistance() + { + return interResistance; + } + + public void setHourTime(Date hourTime) + { + this.hourTime = hourTime; + } + + public Date getHourTime() + { + return hourTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("batteryPack", getBatteryPack()) + .append("batteryCluster", getBatteryCluster()) + .append("batteryCellId", getBatteryCellId()) + .append("voltage", getVoltage()) + .append("temperature", getTemperature()) + .append("soc", getSoc()) + .append("soh", getSoh()) + .append("dataTimestamp", getDataTimestamp()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("clusterDeviceId", getClusterDeviceId()) + .append("interResistance", getInterResistance()) + .append("hourTime", getHourTime()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMinutes.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMinutes.java new file mode 100644 index 0000000..24ed5fe --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMinutes.java @@ -0,0 +1,226 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_battery_data_minutes + * + * @author xzzn + * @date 2025-08-18 + */ +public class EmsBatteryDataMinutes extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 电池堆 */ + @Excel(name = "电池堆") + private String batteryPack; + + /** 电池簇 */ + @Excel(name = "电池簇") + private String batteryCluster; + + /** 单体编号 */ + @Excel(name = "单体编号") + private String batteryCellId; + + /** 电压 (V) */ + @Excel(name = "电压 (V)") + private BigDecimal voltage; + + /** 温度 (℃) */ + @Excel(name = "温度 (℃)") + private BigDecimal temperature; + + /** SOC (%) */ + @Excel(name = "SOC (%)") + private BigDecimal soc; + + /** SOH (%) */ + @Excel(name = "SOH (%)") + private BigDecimal soh; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataTimestamp; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 簇设备id */ + @Excel(name = "簇设备id") + private String clusterDeviceId; + + /** 单体电池内阻 */ + @Excel(name = "单体电池内阻") + private BigDecimal interResistance; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setBatteryPack(String batteryPack) + { + this.batteryPack = batteryPack; + } + + public String getBatteryPack() + { + return batteryPack; + } + + public void setBatteryCluster(String batteryCluster) + { + this.batteryCluster = batteryCluster; + } + + public String getBatteryCluster() + { + return batteryCluster; + } + + public void setBatteryCellId(String batteryCellId) + { + this.batteryCellId = batteryCellId; + } + + public String getBatteryCellId() + { + return batteryCellId; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setTemperature(BigDecimal temperature) + { + this.temperature = temperature; + } + + public BigDecimal getTemperature() + { + return temperature; + } + + public void setSoc(BigDecimal soc) + { + this.soc = soc; + } + + public BigDecimal getSoc() + { + return soc; + } + + public void setSoh(BigDecimal soh) + { + this.soh = soh; + } + + public BigDecimal getSoh() + { + return soh; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setClusterDeviceId(String clusterDeviceId) + { + this.clusterDeviceId = clusterDeviceId; + } + + public String getClusterDeviceId() + { + return clusterDeviceId; + } + + public void setInterResistance(BigDecimal interResistance) + { + this.interResistance = interResistance; + } + + public BigDecimal getInterResistance() + { + return interResistance; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("batteryPack", getBatteryPack()) + .append("batteryCluster", getBatteryCluster()) + .append("batteryCellId", getBatteryCellId()) + .append("voltage", getVoltage()) + .append("temperature", getTemperature()) + .append("soc", getSoc()) + .append("soh", getSoh()) + .append("dataTimestamp", getDataTimestamp()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("clusterDeviceId", getClusterDeviceId()) + .append("interResistance", getInterResistance()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMonth.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMonth.java new file mode 100644 index 0000000..1828042 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryDataMonth.java @@ -0,0 +1,242 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_battery_data_month + * + * @author xzzn + * @date 2025-08-22 + */ +public class EmsBatteryDataMonth extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 电池堆 */ + @Excel(name = "电池堆") + private String batteryPack; + + /** 电池簇 */ + @Excel(name = "电池簇") + private String batteryCluster; + + /** 单体编号 */ + @Excel(name = "单体编号") + private String batteryCellId; + + /** 电压 (V) */ + @Excel(name = "电压 (V)") + private BigDecimal voltage; + + /** 温度 (℃) */ + @Excel(name = "温度 (℃)") + private BigDecimal temperature; + + /** SOC (%) */ + @Excel(name = "SOC (%)") + private BigDecimal soc; + + /** SOH (%) */ + @Excel(name = "SOH (%)") + private BigDecimal soh; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataTimestamp; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 簇设备id */ + @Excel(name = "簇设备id") + private String clusterDeviceId; + + /** 单体电池内阻 */ + @Excel(name = "单体电池内阻") + private BigDecimal interResistance; + + /** 月级时间维度 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "月级时间维度", width = 30, dateFormat = "yyyy-MM-dd") + private Date monthTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setBatteryPack(String batteryPack) + { + this.batteryPack = batteryPack; + } + + public String getBatteryPack() + { + return batteryPack; + } + + public void setBatteryCluster(String batteryCluster) + { + this.batteryCluster = batteryCluster; + } + + public String getBatteryCluster() + { + return batteryCluster; + } + + public void setBatteryCellId(String batteryCellId) + { + this.batteryCellId = batteryCellId; + } + + public String getBatteryCellId() + { + return batteryCellId; + } + + public void setVoltage(BigDecimal voltage) + { + this.voltage = voltage; + } + + public BigDecimal getVoltage() + { + return voltage; + } + + public void setTemperature(BigDecimal temperature) + { + this.temperature = temperature; + } + + public BigDecimal getTemperature() + { + return temperature; + } + + public void setSoc(BigDecimal soc) + { + this.soc = soc; + } + + public BigDecimal getSoc() + { + return soc; + } + + public void setSoh(BigDecimal soh) + { + this.soh = soh; + } + + public BigDecimal getSoh() + { + return soh; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setClusterDeviceId(String clusterDeviceId) + { + this.clusterDeviceId = clusterDeviceId; + } + + public String getClusterDeviceId() + { + return clusterDeviceId; + } + + public void setInterResistance(BigDecimal interResistance) + { + this.interResistance = interResistance; + } + + public BigDecimal getInterResistance() + { + return interResistance; + } + + public void setMonthTime(Date monthTime) + { + this.monthTime = monthTime; + } + + public Date getMonthTime() + { + return monthTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("batteryPack", getBatteryPack()) + .append("batteryCluster", getBatteryCluster()) + .append("batteryCellId", getBatteryCellId()) + .append("voltage", getVoltage()) + .append("temperature", getTemperature()) + .append("soc", getSoc()) + .append("soh", getSoh()) + .append("dataTimestamp", getDataTimestamp()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("clusterDeviceId", getClusterDeviceId()) + .append("interResistance", getInterResistance()) + .append("monthTime", getMonthTime()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java new file mode 100644 index 0000000..45f7da2 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java @@ -0,0 +1,72 @@ +package com.xzzn.ems.mapper; + +import java.time.LocalDateTime; +import java.util.List; +import com.xzzn.ems.domain.EmsBatteryDataDay; +import com.xzzn.ems.domain.EmsBatteryDataHour; +import org.apache.ibatis.annotations.Param; + +/** + * 单体电池天级数据Mapper接口 + * + * @author xzzn + * @date 2025-08-20 + */ +public interface EmsBatteryDataDayMapper +{ + /** + * 查询单体电池天级数据 + * + * @param id 单体电池天级数据主键 + * @return 单体电池天级数据 + */ + public EmsBatteryDataDay selectEmsBatteryDataDayById(Long id); + + /** + * 查询单体电池天级数据列表 + * + * @param emsBatteryDataDay 单体电池天级数据 + * @return 单体电池天级数据集合 + */ + public List selectEmsBatteryDataDayList(EmsBatteryDataDay emsBatteryDataDay); + + /** + * 新增单体电池天级数据 + * + * @param emsBatteryDataDay 单体电池天级数据 + * @return 结果 + */ + public int insertEmsBatteryDataDay(EmsBatteryDataDay emsBatteryDataDay); + + /** + * 修改单体电池天级数据 + * + * @param emsBatteryDataDay 单体电池天级数据 + * @return 结果 + */ + public int updateEmsBatteryDataDay(EmsBatteryDataDay emsBatteryDataDay); + + /** + * 删除单体电池天级数据 + * + * @param id 单体电池天级数据主键 + * @return 结果 + */ + public int deleteEmsBatteryDataDayById(Long id); + + /** + * 批量删除单体电池天级数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryDataDayByIds(Long[] ids); + + EmsBatteryDataDay findDayMaxTemp(@Param("siteId") String siteId, @Param("stackId") String stackId, + @Param("clusterId") String clusterId, @Param("batteryId") String batteryId, @Param("dayStart") LocalDateTime dayStart); + + /** + * 批量插入或更新天级数据(存在则更新,不存在则插入) + */ + void batchInsertOrUpdate(@Param("list") List dayDataList); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataHourMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataHourMapper.java new file mode 100644 index 0000000..f7713fe --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataHourMapper.java @@ -0,0 +1,72 @@ +package com.xzzn.ems.mapper; + +import java.time.LocalDateTime; +import java.util.List; +import com.xzzn.ems.domain.EmsBatteryDataHour; +import org.apache.ibatis.annotations.Param; + +/** + * 单体电池小时级数据Mapper接口 + * + * @author xzzn + * @date 2025-08-19 + */ +public interface EmsBatteryDataHourMapper +{ + /** + * 查询单体电池小时级数据 + * + * @param id 单体电池小时级数据主键 + * @return 单体电池小时级数据 + */ + public EmsBatteryDataHour selectEmsBatteryDataHourById(Long id); + + /** + * 查询单体电池小时级数据列表 + * + * @param emsBatteryDataHour 单体电池小时级数据 + * @return 单体电池小时级数据集合 + */ + public List selectEmsBatteryDataHourList(EmsBatteryDataHour emsBatteryDataHour); + + /** + * 新增单体电池小时级数据 + * + * @param emsBatteryDataHour 单体电池小时级数据 + * @return 结果 + */ + public int insertEmsBatteryDataHour(EmsBatteryDataHour emsBatteryDataHour); + + /** + * 修改单体电池小时级数据 + * + * @param emsBatteryDataHour 单体电池小时级数据 + * @return 结果 + */ + public int updateEmsBatteryDataHour(EmsBatteryDataHour emsBatteryDataHour); + + /** + * 删除单体电池小时级数据 + * + * @param id 单体电池小时级数据主键 + * @return 结果 + */ + public int deleteEmsBatteryDataHourById(Long id); + + /** + * 批量删除单体电池小时级数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryDataHourByIds(Long[] ids); + + EmsBatteryDataHour findHourMaxTemp(@Param("siteId") String siteId, @Param("stackId") String stackId, + @Param("clusterId") String clusterId, @Param("batteryId") String batteryId, @Param("hourStart") LocalDateTime hourStart); + + /** + * 批量插入或更新小时级数据(存在则更新,不存在则插入) + */ + void batchInsertOrUpdate(@Param("list") List hourDataList); + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java new file mode 100644 index 0000000..b001591 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java @@ -0,0 +1,68 @@ +package com.xzzn.ems.mapper; + +import java.util.Date; +import java.util.List; + +import com.xzzn.ems.domain.EmsBatteryData; +import com.xzzn.ems.domain.EmsBatteryDataMinutes; + +/** + * 单体电池分钟级数据Mapper接口 + * + * @author xzzn + * @date 2025-08-17 + */ +public interface EmsBatteryDataMinutesMapper +{ + /** + * 查询单体电池分钟级数据 + * + * @param dateDay 单体电池分钟级数据主键 + * @return 单体电池分钟级数据 + */ + public EmsBatteryDataMinutes selectEmsBatteryDataMinutesByDateDay(Date dateDay); + + /** + * 查询单体电池分钟级数据列表 + * + * @param emsBatteryDataMinutes 单体电池分钟级数据 + * @return 单体电池分钟级数据集合 + */ + public List selectEmsBatteryDataMinutesList(EmsBatteryDataMinutes emsBatteryDataMinutes); + + /** + * 新增单体电池分钟级数据 + * + * @param emsBatteryDataMinutes 单体电池分钟级数据 + * @return 结果 + */ + public int insertEmsBatteryDataMinutes(EmsBatteryDataMinutes emsBatteryDataMinutes); + + /** + * 修改单体电池分钟级数据 + * + * @param emsBatteryDataMinutes 单体电池分钟级数据 + * @return 结果 + */ + public int updateEmsBatteryDataMinutes(EmsBatteryDataMinutes emsBatteryDataMinutes); + + /** + * 删除单体电池分钟级数据 + * + * @param dateDay 单体电池分钟级数据主键 + * @return 结果 + */ + public int deleteEmsBatteryDataMinutesByDateDay(Date dateDay); + + /** + * 批量删除单体电池分钟级数据 + * + * @param dateDays 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryDataMinutesByDateDays(Date[] dateDays); + + int insertMinutesBatteryDataList(List emsBatteryDataList); + + public void deleteByTimeBeforeOneHour(String oneHourAgoStr); +} \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java new file mode 100644 index 0000000..cc5784e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java @@ -0,0 +1,72 @@ +package com.xzzn.ems.mapper; + +import java.time.LocalDateTime; +import java.util.List; + +import com.xzzn.ems.domain.EmsBatteryDataMonth; +import org.apache.ibatis.annotations.Param; + +/** + * 单体电池月级数据Mapper接口 + * + * @author xzzn + * @date 2025-08-22 + */ +public interface EmsBatteryDataMonthMapper +{ + /** + * 查询单体电池月级数据 + * + * @param id 单体电池月级数据主键 + * @return 单体电池月级数据 + */ + public EmsBatteryDataMonth selectEmsBatteryDataMonthById(Long id); + + /** + * 查询单体电池月级数据列表 + * + * @param emsBatteryDataMonth 单体电池月级数据 + * @return 单体电池月级数据集合 + */ + public List selectEmsBatteryDataMonthList(EmsBatteryDataMonth emsBatteryDataMonth); + + /** + * 新增单体电池月级数据 + * + * @param emsBatteryDataMonth 单体电池月级数据 + * @return 结果 + */ + public int insertEmsBatteryDataMonth(EmsBatteryDataMonth emsBatteryDataMonth); + + /** + * 修改单体电池月级数据 + * + * @param emsBatteryDataMonth 单体电池月级数据 + * @return 结果 + */ + public int updateEmsBatteryDataMonth(EmsBatteryDataMonth emsBatteryDataMonth); + + /** + * 删除单体电池月级数据 + * + * @param id 单体电池月级数据主键 + * @return 结果 + */ + public int deleteEmsBatteryDataMonthById(Long id); + + /** + * 批量删除单体电池月级数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsBatteryDataMonthByIds(Long[] ids); + + EmsBatteryDataMonth findMonthMaxTemp(@Param("siteId") String siteId, @Param("stackId") String stackId, + @Param("clusterId") String clusterId, @Param("batteryId") String batteryId, @Param("monthStart") LocalDateTime monthStart); + + /** + * 批量插入或更新月级数据(存在则更新,不存在则插入) + */ + void batchInsertOrUpdate(@Param("list") List monthDataList); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 69c251f..cec9755 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -14,6 +14,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IDDSDataProcessService; +import com.xzzn.ems.utils.AbstractBatteryDataProcessor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanUtils; @@ -22,20 +23,22 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @Service -public class DDSDataProcessServiceImpl implements IDDSDataProcessService { +public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IDDSDataProcessService { private static final Log log = LogFactory.getLog(DDSDataProcessServiceImpl.class); private static final String SITE_ID = "021_DDS_01"; // 正则表达式匹配BMS设备编号和属性 private static final Pattern PATTERN = Pattern.compile("(BMSD\\d{2})(ZT|SOC|SOH|DL|DY|BDSC)"); // 匹配DTDC+数字格式的正则(提取序号) private static final Pattern DTDC_PATTERN = Pattern.compile("DTDC(\\d+)([A-Za-z]*)"); - // 初始化ObjectMapper(可以作为全局变量) - private static final ObjectMapper objectMapper = new ObjectMapper(); + @Autowired private EmsBatteryClusterMapper emsBatteryClusterMapper; @@ -65,6 +68,12 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { private EmsDhDataMapper emsDhDataMapper; @Autowired private EmsBatteryGroupMapper emsBatteryGroupMapper; + @Autowired + private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; + + public DDSDataProcessServiceImpl(ObjectMapper objectMapper) { + super(objectMapper); + } @Override public void handleDdsData(String message) { @@ -231,7 +240,6 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { } // 批量插入数据库 - log.info("批量插入"); if (!CollectionUtils.isEmpty(groupMap)) { List batteryGroupList = new ArrayList<>(groupMap.values()); emsBatteryGroupMapper.batchInsertGroupData(batteryGroupList); @@ -273,8 +281,17 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { //电池组 Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); - List dailyList = new ArrayList<>(); + List dataList = new ArrayList<>(); + + // 前一个小时 + LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String oneHourAgoStr = oneHourAgo.format(formatter); + Map dataMap = new HashMap<>(); + Map dailyMap = new HashMap<>(); + Map minutesMap = new HashMap<>(); + for (Map.Entry entry : obj.entrySet()) { String key = entry.getKey(); @@ -302,26 +319,45 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { setDTDCPropertyValue(data, property, entry.getValue()); dataMap.put(batteryCellId, data); - // 每日最新数据 - EmsBatteryDataDailyLatest daily = new EmsBatteryDataDailyLatest(); + // 每日最新数据:按batteryCellId去重 + EmsBatteryDataDailyLatest daily = dailyMap.getOrDefault(batteryCellId, new EmsBatteryDataDailyLatest()); BeanUtils.copyProperties(data, daily); daily.setDateDay(DateUtils.getNowDate()); - dailyList.add(daily); + dailyMap.put(batteryCellId, daily); + + // 分钟级的表,上报的数据直接存入,数据上限是 1 个小时 + EmsBatteryDataMinutes minutes = minutesMap.getOrDefault(batteryCellId, new EmsBatteryDataMinutes()); + BeanUtils.copyProperties(data, minutes); + minutesMap.put(batteryCellId, minutes); } } - } if (!CollectionUtils.isEmpty(dataMap)) { - List dataList = new ArrayList<>(dataMap.values()); + dataList = new ArrayList<>(dataMap.values()); emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList)); redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01"); redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01" , dataList); } // 批量处理每日最新数据 - if (dailyList != null && dailyList.size() > 0) { + List dailyList = new ArrayList<>(dailyMap.values()); + if (!dailyList.isEmpty()) { + dailyList = new ArrayList<>(dailyMap.values()); emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList); } + + // 实时插入每分钟数据 + List minutesList = new ArrayList<>(minutesMap.values()); + if (!minutesList.isEmpty()) { + emsBatteryDataMinutesMapper.insertMinutesBatteryDataList(minutesList); + } + // 清理分钟级表里一小时前数据 + emsBatteryDataMinutesMapper.deleteByTimeBeforeOneHour(oneHourAgoStr); + + // 分片处理时级,天级,月级数据 + if (dataList.size() > 0) { + super.processBatch(dataList); + } } private void setDTDCPropertyValue(EmsBatteryData data, String property, Object value) { @@ -884,33 +920,6 @@ public class DDSDataProcessServiceImpl implements IDDSDataProcessService { return records; } - private static Map> processDataPrefix(Map rawData) { - Map> records = new HashMap<>(); - - for (Map.Entry entry : rawData.entrySet()) { - String key = entry.getKey(); - // 确保键长度足够 - if (key.length() < 3) { - continue; - } - - // 提取记录ID(前3位) - String recordId = key.substring(0, 3); - if (!recordId.startsWith("DY")) { - continue; - } - - // 提取字段类型(剩余部分) - String fieldType = key.substring(3); - - // 初始化记录 - records.putIfAbsent(recordId, new HashMap<>()); - // 存入字段值 - records.get(recordId).put(fieldType, entry.getValue()); - } - return records; - } - // 空数据不处理 private boolean checkJsonDataEmpty(String jsonData) { boolean flag = false; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index ada3dd4..a740418 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -15,20 +15,22 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IFXXDataProcessService; +import com.xzzn.ems.utils.AbstractBatteryDataProcessor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.*; @Service -public class FXXDataProcessServiceImpl implements IFXXDataProcessService { +public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXDataProcessService { private static final Log log = LogFactory.getLog(FXXDataProcessServiceImpl.class); private static final String SITE_ID = "021_FXX_01"; - // 初始化ObjectMapper(可以作为全局变量) - private static final ObjectMapper objectMapper = new ObjectMapper(); @Autowired private EmsBatteryClusterMapper emsBatteryClusterMapper; @@ -55,6 +57,13 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { private EmsAmmeterDataMapper emsAmmeterDataMapper; @Autowired private EmsBatteryDailyLatestServiceImpl emsBatteryDailyLatestServiceImpl; + @Autowired + private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; + + // 构造方法(调用父类构造) + public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { + super(objectMapper); + } @Override public void handleFxData(String message) { @@ -268,6 +277,11 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() {})); List list = new ArrayList<>(); List dailyList = new ArrayList<>(); + List minutesList = new ArrayList<>(); + // 前一个小时 + LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String oneHourAgoStr = oneHourAgo.format(formatter); //单体电池 for (Map.Entry> record : records.entrySet()) { String recordId = record.getKey(); @@ -286,11 +300,14 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { // 时间戳 batteryData.setDataTimestamp(new Date()); - + // 系统管理字段 + batteryData.setCreateBy("system"); + batteryData.setCreateTime(DateUtils.getNowDate()); + batteryData.setUpdateBy("system"); + batteryData.setUpdateTime(DateUtils.getNowDate()); // ID字段 batteryData.setSiteId(SITE_ID); batteryData.setClusterDeviceId(deviceId); - list.add(batteryData); // 每日最新数据 @@ -298,18 +315,34 @@ public class FXXDataProcessServiceImpl implements IFXXDataProcessService { BeanUtils.copyProperties(batteryData, daily); daily.setDateDay(DateUtils.getNowDate()); dailyList.add(daily); + + // 分钟级的表,上报的数据直接存入,数据上限是 1 个小时 + EmsBatteryDataMinutes minutes = new EmsBatteryDataMinutes(); + BeanUtils.copyProperties(batteryData, minutes); + minutesList.add(minutes); } - if (list.size() > 0 ) { + if (list.size() > 0) { emsBatteryDataMapper.insertEmsBatteryDataList(list); - redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId); - redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" +deviceId, list); + redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId); + redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId, list); } // 批量处理每日最新数据 if (dailyList != null && dailyList.size() > 0) { emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList); } + // 实时插入每分钟数据 + if (minutesList != null && minutesList.size() > 0) { + emsBatteryDataMinutesMapper.insertMinutesBatteryDataList(minutesList); + } + // 清理分钟级表里一小时前数据 + emsBatteryDataMinutesMapper.deleteByTimeBeforeOneHour(oneHourAgoStr); + + // 分片处理时级,天级,月级数据 + if (list.size() > 0) { + super.processBatch(list); + } } private void pcsDataProcess(String deviceId, String dataJson) { diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java new file mode 100644 index 0000000..2dcc4a1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java @@ -0,0 +1,681 @@ +package com.xzzn.ems.utils; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.EmsBatteryData; +import com.xzzn.ems.domain.EmsBatteryDataDay; +import com.xzzn.ems.domain.EmsBatteryDataHour; +import com.xzzn.ems.domain.EmsBatteryDataMonth; +import com.xzzn.ems.mapper.EmsBatteryDataDayMapper; +import com.xzzn.ems.mapper.EmsBatteryDataHourMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMonthMapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.locks.ReentrantLock; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public abstract class AbstractBatteryDataProcessor { + + private static final Log log = LogFactory.getLog(AbstractBatteryDataProcessor.class); + + protected static final DateTimeFormatter HOUR_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH"); + protected static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + protected static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM"); + // 公共缓存: + protected final Map tempCache = new ConcurrentHashMap<>(); + // 公共锁缓存: + protected final Map lockCache = new ConcurrentHashMap<>(); + protected final ObjectMapper objectMapper; + + @Autowired + private EmsBatteryDataHourMapper emsBatteryDataHourMapper; + @Autowired + private EmsBatteryDataDayMapper emsBatteryDataDayMapper; + @Autowired + private EmsBatteryDataMonthMapper emsBatteryDataMonthMapper; + @Autowired + private RedisCache redisCache; + + // 公共线程池(IO密集型,子类共享) + protected ThreadPoolTaskExecutor ioExecutor; + // 批量缓冲区(线程安全队列,按级别区分) + protected ConcurrentLinkedQueue hourBatchQueue = new ConcurrentLinkedQueue<>(); + protected ConcurrentLinkedQueue dayBatchQueue = new ConcurrentLinkedQueue<>(); + protected ConcurrentLinkedQueue monthBatchQueue = new ConcurrentLinkedQueue<>(); + // 批量提交阈值(满100条触发数据库操作) + protected static final int BATCH_THRESHOLD = 50; + // 死锁重试等待时间基数(毫秒) + private static final int RETRY_BASE_DELAY = 100; + // 随机数生成器,用于重试退避 + private static final Random random = new Random(); + + // 初始化方法(构造时初始化线程池) + public AbstractBatteryDataProcessor(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + ioExecutor = new ThreadPoolTaskExecutor(); + int coreThreads = Runtime.getRuntime().availableProcessors() * 2; + ioExecutor.setCorePoolSize(coreThreads); + ioExecutor.setMaxPoolSize(coreThreads * 2); + ioExecutor.setQueueCapacity(10000); + ioExecutor.setThreadNamePrefix("battery-io-"); + // 线程池饱和策略:使用调用者线程执行,避免任务丢失 + ioExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + ioExecutor.initialize(); + } + + // 模板方法:定义数据处理主流程(子类无需重写) + public void processBatch(List batchData) { + // 1. 数据分片(实现通用分片逻辑) + List> shards = splitIntoShards(batchData, 50); + int totalShards = shards.size(); + + // 2. 并行处理每个分片(使用父类线程池) + for (int i = 0; i < totalShards; i++) { + List shard = shards.get(i); + boolean isLastShard = (i == totalShards - 1); // 判断是否为最后一个分片 + + // 传递分片索引和是否最后一个分片的标记 + ioExecutor.execute(() -> processShard(shard, isLastShard)); + } + //shards.forEach(shard -> ioExecutor.execute(() -> processShard(shard))); + } + + /** + * 将大批量数据拆分为多个小分片 + * @param dataList 原始数据列表 + * @param shardSize 每个分片的最大大小(如100条/片) + * @return 分片后的列表(每个元素是一个子列表) + */ + protected List> splitIntoShards(List dataList, int shardSize) { + // 1. 校验参数:避免空列表或无效分片大小 + if (dataList == null || dataList.isEmpty()) { + return new ArrayList<>(); + } + if (shardSize <= 0) { + throw new IllegalArgumentException("分片大小必须大于0"); + } + + // 2. 计算总分片数:向上取整(如150条数据,分片大小100 → 2片) + int totalSize = dataList.size(); + int shardCount = (totalSize + shardSize - 1) / shardSize; + + // 3. 拆分数据为分片(使用IntStream生成分片索引) + return IntStream.range(0, shardCount) + .mapToObj(shardIndex -> { + // 计算当前分片的起始索引和结束索引 + int startIndex = shardIndex * shardSize; + int endIndex = Math.min(startIndex + shardSize, totalSize); + // 截取子列表作为一个分片 + return dataList.subList(startIndex, endIndex); + }) + .collect(Collectors.toList()); + } + + // 处理单个分片(父类定义流程,调用子类实现的具体判断和更新逻辑) + private void processShard(List shard, boolean isLastShard) { + int shardSize = shard.size(); + log.info("分片校验:" + shardSize + ""); + for (int i = 0; i < shardSize; i++) { + EmsBatteryData data = shard.get(i); + if (!isValidData(data)) continue; + + // 判断当前数据是否为最后一个分片的最后一条数据 + boolean isLastData = isLastShard && (i == shardSize - 1); + // shouldUpdate判断是否需要更新 + if (shouldUpdate(data, "hour")) { + addToHourBatch(data, isLastData); // 加入小时级批量队列 + } + if (shouldUpdate(data, "day")) { + addToDayBatch(data, isLastData); // 加入天级批量队列 + } + if (shouldUpdate(data, "month")) { + addToMonthBatch(data, isLastData); + } + } + } + + // 加入小时级批量队列,达到阈值时触发批量更新 + protected void addToHourBatch(EmsBatteryData data, boolean isLastData) { + hourBatchQueue.add(data); + if (hourBatchQueue.size() >= BATCH_THRESHOLD || isLastData) { + List batch = drainQueue(hourBatchQueue); + ioExecutor.execute(() -> batchUpdateHour(batch)); // 异步批量更新 + } + } + + // 加入天级批量队列,达到阈值时触发批量更新 + protected void addToDayBatch(EmsBatteryData data, boolean isLastData) { + dayBatchQueue.add(data); + if (dayBatchQueue.size() >= BATCH_THRESHOLD || isLastData) { + List batch = drainQueue(dayBatchQueue); + ioExecutor.execute(() -> batchUpdateDay(batch)); // 异步批量更新 + } + } + + // 加入月级批量队列,达到阈值时触发批量更新 + protected void addToMonthBatch(EmsBatteryData data, boolean isLastData) { + monthBatchQueue.add(data); + if (monthBatchQueue.size() >= BATCH_THRESHOLD || isLastData) { + List batch = drainQueue(monthBatchQueue); + ioExecutor.execute(() -> batchUpdateMonth(batch)); // 异步批量更新 + } + } + + // 实现父类的抽象方法:批量更新小时级数据 + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void batchUpdateHour(List batch) { + if (batch.isEmpty()) return; + + int maxRetry = 3; // 最多重试3次 + int retryCount = 0; + while (retryCount < maxRetry) { + try { + // 关键优化:按唯一键排序,保证所有线程处理相同记录时顺序一致 + List sortedBatch = batch.stream() + .sorted(Comparator.comparing(data -> generateCacheKey(data, "hour"))) // 用唯一键排序 + .collect(Collectors.toList()); + + // 1. 转换原始数据为小时级统计对象(分组取最高温) + List hourDataList = sortedBatch.stream() + .collect(Collectors.groupingBy( + data -> generateCacheKey(data, "hour"), // 分组键 + Collectors.collectingAndThen( + Collectors.maxBy((d1, d2) -> d1.getTemperature().compareTo(d2.getTemperature())), + maxData -> convertToHourData(maxData.get()) // 取每组最高温转换为HourData + ) + )) + .values() + .stream() + .sorted(Comparator.comparing(this::getHourDataUniqueKey)) + .collect(Collectors.toList()); + + // 2. 批量插入或更新数据库(依赖数据库唯一索引) + emsBatteryDataHourMapper.batchInsertOrUpdate(hourDataList); + + // 3. 同步更新Redis缓存(批量操作) + batchUpdateHourCache(hourDataList); + log.info("小时级批量更新成功,批次大小:" + batch.size() + ",重试次数:" + retryCount); + return; + } catch (Exception e) { + log.error("小时级批量更新失败", e); + // 使用改进的死锁判断方法,直接传入异常对象 + if (isDeadlockException(e) && retryCount < maxRetry - 1) { + retryCount++; + long sleepTime = calculateBackoffTime(retryCount); + log.info("检测到死锁,第" + retryCount + "次重试(当前批次大小:" + batch.size() + ")", e); + try { + // 指数退避策略:100ms, 200ms, 300ms... + Thread.sleep(sleepTime); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); // 保留中断状态 + break; + } + } else { + log.error("小时级批量更新失败(已达最大重试次数)", e); + //retryQueue.addAll(batch); // 加入重试队列 + return; + } + } + } + } + // 辅助方法:获取小时级数据的唯一键(用于排序) + private String getHourDataUniqueKey(EmsBatteryDataHour data) { + return data.getSiteId() + "_" + data.getBatteryPack() + "_" + data.getClusterDeviceId() + + "_" + data.getDeviceId() + "_" + data.getHourTime(); + } + // 批量更新小时级数据缓存-小时级统计数据列表(已按唯一键分组并取最高温) + public void batchUpdateHourCache(List hourDataList) { + if (hourDataList.isEmpty()) return; + + // 1. 构建缓存键值对(批量操作提升效率) + Map tempCacheMap = new HashMap<>(hourDataList.size()); + for (EmsBatteryDataHour data : hourDataList) { + EmsBatteryData cacheData = new EmsBatteryData(); + BeanUtils.copyProperties(data, cacheData); + // 2. 生成唯一缓存键(与数据库唯一键一致) + String cacheKey = generateCacheKey(cacheData, "hour"); + // 3. 存储最高温度和最后更新时间(两个独立缓存项) + tempCacheMap.put(cacheKey, data.getTemperature().toString()); + } + + try { + // 4. 批量设置缓存(Redis批量操作减少网络交互) + redisCache.multiSet(tempCacheMap); + } catch (Exception e) { + log.error("批量更新小时级缓存失败", e); + // 缓存更新失败不影响主流程,但需记录日志便于排查 + } + } + // 转换为小时级数据对象 + private EmsBatteryDataHour convertToHourData(EmsBatteryData data) { + LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai")) + .toLocalDateTime(); + LocalDateTime hourStart = localDateTime.truncatedTo(ChronoUnit.HOURS); + + EmsBatteryDataHour hourData = new EmsBatteryDataHour(); + BeanUtils.copyProperties(data, hourData); + hourData.setUpdateTime(new Date()); + hourData.setHourTime(DateUtils.convertToDate(hourStart)); + return hourData; + } + + // 实现父类的抽象方法:批量更新天级数据 + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void batchUpdateDay(List batch) { + if (batch.isEmpty()) return; + + int maxRetry = 3; // 最多重试3次 + int retryCount = 0; + while (retryCount < maxRetry) { + try { + // 关键优化:按唯一键排序,保证所有线程处理相同记录时顺序一致 + List sortedBatch = batch.stream() + .sorted(Comparator.comparing(data -> generateCacheKey(data, "day"))) // 用唯一键排序 + .collect(Collectors.toList()); + + // 1. 转换原始数据为天级统计对象(分组取最高温) + List dayDataList = sortedBatch.stream() + .collect(Collectors.groupingBy( + data -> generateCacheKey(data, "day"), // 分组键 + Collectors.collectingAndThen( + Collectors.maxBy((d1, d2) -> d1.getTemperature().compareTo(d2.getTemperature())), + maxData -> convertToDayData(maxData.get()) // 取每组最高温转换为HourData + ) + )) + .values() + .stream() + .sorted(Comparator.comparing(this::getDayDataUniqueKey)) + .collect(Collectors.toList()); + + // 2. 批量插入或更新数据库(依赖数据库唯一索引) + emsBatteryDataDayMapper.batchInsertOrUpdate(dayDataList); + + // 3. 同步更新Redis缓存(批量操作) + batchUpdateDayCache(dayDataList); + log.info("天级批量更新成功,批次大小:" + batch.size() + ",重试次数:" + retryCount); + return; + } catch (Exception e) { + log.error("天级批量更新失败", e); + // 使用改进的死锁判断方法,直接传入异常对象 + if (isDeadlockException(e) && retryCount < maxRetry - 1) { + retryCount++; + long sleepTime = calculateBackoffTime(retryCount); + log.info("检测到死锁,第" + retryCount + "次重试(当前批次大小:" + batch.size() + ")", e); + try { + // 指数退避策略:100ms, 200ms, 300ms... + Thread.sleep(sleepTime); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); // 保留中断状态 + break; + } + } else { + log.error("天级批量更新失败(已达最大重试次数)", e); + //retryQueue.addAll(batch); // 加入重试队列 + return; + } + } + } + } + // 辅助方法:获取天级数据的唯一键(用于排序) + private String getDayDataUniqueKey(EmsBatteryDataDay data) { + return data.getSiteId() + "_" + data.getBatteryPack() + "_" + data.getClusterDeviceId() + + "_" + data.getDeviceId() + "_" + data.getDayTime(); + } + // 批量更新天级数据缓存-天级统计数据列表(已按唯一键分组并取最高温) + public void batchUpdateDayCache(List dayDataList) { + if (dayDataList.isEmpty()) return; + + // 1. 构建缓存键值对(批量操作提升效率) + Map tempCacheMap = new HashMap<>(dayDataList.size()); + for (EmsBatteryDataDay data : dayDataList) { + EmsBatteryData cacheData = new EmsBatteryData(); + BeanUtils.copyProperties(data, cacheData); + // 2. 生成唯一缓存键(与数据库唯一键一致) + String cacheKey = generateCacheKey(cacheData, "day"); + // 3. 存储最高温度和最后更新时间(两个独立缓存项) + tempCacheMap.put(cacheKey, data.getTemperature().toString()); + } + + try { + // 4. 批量设置缓存(Redis批量操作减少网络交互) + redisCache.multiSet(tempCacheMap); + } catch (Exception e) { + log.error("批量更新小时级缓存失败", e); + // 缓存更新失败不影响主流程,但需记录日志便于排查 + } + } + // 转换为天级数据对象 + private EmsBatteryDataDay convertToDayData(EmsBatteryData data) { + LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai")) + .toLocalDateTime(); + LocalDateTime dayStart = localDateTime.truncatedTo(ChronoUnit.DAYS); + + EmsBatteryDataDay dayData = new EmsBatteryDataDay(); + BeanUtils.copyProperties(data, dayData); + dayData.setUpdateTime(new Date()); + dayData.setDayTime(DateUtils.convertToDate(dayStart)); + return dayData; + } + + // 实现父类的抽象方法:批量更新月级数据 + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void batchUpdateMonth(List batch) { + if (batch.isEmpty()) return; + + int maxRetry = 3; // 最多重试3次 + int retryCount = 0; + while (retryCount < maxRetry) { + try { + // 关键优化:按唯一键排序,保证所有线程处理相同记录时顺序一致 + List sortedBatch = batch.stream() + .sorted(Comparator.comparing(data -> generateCacheKey(data, "month"))) // 用唯一键排序 + .collect(Collectors.toList()); + + // 1. 转换原始数据为小时级统计对象(分组取最高温) + List monthDataList = sortedBatch.stream() + .collect(Collectors.groupingBy( + data -> generateCacheKey(data, "month"), // 分组键 + Collectors.collectingAndThen( + Collectors.maxBy((d1, d2) -> d1.getTemperature().compareTo(d2.getTemperature())), + maxData -> convertToMonthData(maxData.get()) // 取每组最高温转换为HourData + ) + )) + .values() + .stream() + .sorted(Comparator.comparing(this::getMonthDataUniqueKey)) + .collect(Collectors.toList()); + + // 2. 批量插入或更新数据库(依赖数据库唯一索引) + emsBatteryDataMonthMapper.batchInsertOrUpdate(monthDataList); + + // 3. 同步更新Redis缓存(批量操作) + batchUpdateMonthCache(monthDataList); + log.info("月级批量更新成功,批次大小:" + batch.size() + ",重试次数:" + retryCount); + return; + } catch (Exception e) { + log.error("月级批量更新失败", e); + // 使用改进的死锁判断方法,直接传入异常对象 + if (isDeadlockException(e) && retryCount < maxRetry - 1) { + retryCount++; + long sleepTime = calculateBackoffTime(retryCount); + log.info("检测到死锁,第" + retryCount + "次重试(当前批次大小:" + batch.size() + ")", e); + try { + // 指数退避策略:100ms, 200ms, 300ms... + Thread.sleep(sleepTime); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); // 保留中断状态 + break; + } + } else { + log.error("月级批量更新失败(已达最大重试次数)", e); + //retryQueue.addAll(batch); // 加入重试队列 + return; + } + } + } + } + // 辅助方法:获取月级数据的唯一键(用于排序) + private String getMonthDataUniqueKey(EmsBatteryDataMonth data) { + return data.getSiteId() + "_" + data.getBatteryPack() + "_" + data.getClusterDeviceId() + + "_" + data.getDeviceId() + "_" + data.getMonthTime(); + } + // 转换为月级数据对象 + private EmsBatteryDataMonth convertToMonthData(EmsBatteryData data) { + LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai")) + .toLocalDateTime(); + LocalDateTime monthStart = localDateTime.withDayOfMonth(1).withHour(0).withMinute(0) + .withSecond(0).withNano(0); + + EmsBatteryDataMonth monthData = new EmsBatteryDataMonth(); + BeanUtils.copyProperties(data, monthData); + monthData.setUpdateTime(new Date()); + monthData.setMonthTime(DateUtils.convertToDate(monthStart)); + return monthData; + } + // 批量更新月级数据缓存-月级统计数据列表(已按唯一键分组并取最高温) + public void batchUpdateMonthCache(List monthDataList) { + if (monthDataList.isEmpty()) return; + + // 1. 构建缓存键值对(批量操作提升效率) + Map tempCacheMap = new HashMap<>(monthDataList.size()); + for (EmsBatteryDataMonth data : monthDataList) { + EmsBatteryData cacheData = new EmsBatteryData(); + BeanUtils.copyProperties(data, cacheData); + // 2. 生成唯一缓存键(与数据库唯一键一致) + String cacheKey = generateCacheKey(cacheData, "month"); + // 3. 存储最高温度和最后更新时间(两个独立缓存项) + tempCacheMap.put(cacheKey, data.getTemperature().toString()); + } + + try { + // 4. 批量设置缓存(Redis批量操作减少网络交互) + redisCache.multiSet(tempCacheMap); + } catch (Exception e) { + log.error("批量更新月级缓存失败", e); + // 缓存更新失败不影响主流程,但需记录日志便于排查 + } + } + + + /** + * 校验数据有效性(公共逻辑:检查核心字段) + */ + protected boolean isValidData(EmsBatteryData data) { + return data.getDeviceId() != null + && data.getTemperature() != null + && data.getDataTimestamp() != null; + } + + /** + * 判断是否需要更新(公共缓存逻辑) + */ + protected boolean shouldUpdate(EmsBatteryData data, String granularity) { + String cacheKey = generateCacheKey(data, granularity); + if (cacheKey == null) return true; + + BigDecimal newTemp = data.getTemperature(); + CacheValue localCache = tempCache.get(cacheKey); + if (localCache != null) { + return newTemp.compareTo(localCache.maxTemp) > 0; + } + + // 本地缓存未命中:查Redis + try { + String redisValue = redisCache.getCacheObject(cacheKey); + if (redisValue != null) { + // Redis有值:转换为BigDecimal比较 + BigDecimal redisMaxTemp = new BigDecimal(redisValue); + // 同时更新本地缓存(减少下次查询Redis的开销) + tempCache.put(cacheKey, new CacheValue(redisMaxTemp, LocalDateTime.now())); + return newTemp.compareTo(redisMaxTemp) > 0; + } + } catch (Exception e) { + log.error("查询Redis缓存失败(key: " + cacheKey + ")", e); + } + + + // 数据库校验(缓存都未命中或新温度更高时) + BigDecimal dbMaxTemp = queryDbMaxTemp(data, granularity); + if (dbMaxTemp != null && newTemp.compareTo(dbMaxTemp) <= 0) { + // 数据库已有更高温度,更新缓存后返回 + CacheValue dbCache = new CacheValue(dbMaxTemp, LocalDateTime.now()); + tempCache.put(cacheKey, dbCache); + redisCache.setCacheObject(cacheKey, dbMaxTemp.toString()); // 同步到Redis + return false; + } + + return true; + } + + /** + * 查询数据库中该设备在指定时间粒度下的最大温度 + */ + private BigDecimal queryDbMaxTemp(EmsBatteryData data, String granularity) { + try { + LocalDateTime dataTime = data.getDataTimestamp().toInstant() + .atZone(ZoneId.of("Asia/Shanghai")).toLocalDateTime(); + + String siteId = data.getSiteId(); + String batteryPack = data.getBatteryPack(); + String clusterId = data.getClusterDeviceId(); + String deviceId = data.getDeviceId(); + + // 根据粒度查询对应的数据表 + switch (granularity) { + case "hour": + LocalDateTime hourStart = dataTime.truncatedTo(ChronoUnit.HOURS); + // 调用Mapper查询该小时的最大温度(需确保Mapper方法存在) + EmsBatteryDataHour hourMax = emsBatteryDataHourMapper.findHourMaxTemp( + siteId, batteryPack, clusterId, deviceId, hourStart + ); + return hourMax != null ? hourMax.getTemperature() : null; + + case "day": + LocalDateTime dayStart = dataTime.truncatedTo(ChronoUnit.DAYS); + EmsBatteryDataDay dayMax = emsBatteryDataDayMapper.findDayMaxTemp( + siteId, batteryPack, clusterId, deviceId, dayStart + ); + return dayMax != null ? dayMax.getTemperature() : null; + + case "month": + // 设为当月1号 与其他表统一格式 + LocalDateTime monthStart = dataTime.withDayOfMonth(1).withHour(0).withMinute(0) + .withSecond(0).withNano(0); + EmsBatteryDataMonth monthMax = emsBatteryDataMonthMapper.findMonthMaxTemp( + siteId, batteryPack, clusterId, deviceId, monthStart + ); + return monthMax != null ? monthMax.getTemperature() : null; + + default: + log.error("不支持的查询粒度:" + granularity); + return null; + } + } catch (Exception e) { + log.error("查询数据库最大温度失败", e); + return null; // 数据库查询失败时,暂不阻止更新(避免业务中断) + } + } + + // 生成缓存键(不同级别格式不同) + private String generateCacheKey(EmsBatteryData data, String granularity) { + String siteId = data.getSiteId(); + String stackId = data.getBatteryPack(); + String clusterId = data.getClusterDeviceId(); + String batteryId = data.getDeviceId(); + try { + LocalDateTime localDateTime = data.getDataTimestamp().toInstant().atZone(ZoneId.of("Asia/Shanghai")) + .toLocalDateTime(); + String timeStr; + // 根据级别格式化时间(小时/天/月) + switch (granularity) { + case "hour": + timeStr = localDateTime.format(HOUR_FORMATTER); + break; + case "day": + timeStr = localDateTime.format(DAY_FORMATTER); + break; + case "month": + timeStr = localDateTime.format(MONTH_FORMATTER); + break; + default: + log.info("不支持的级别:" + granularity); + return null; + } + // 缓存键格式 + return siteId + "_" + stackId + "_" + clusterId + "_" + batteryId + "_" +timeStr; + } catch (Exception e) { + log.error("生成缓存键失败", e); + return null; + } + } + + // 工具方法:从队列中取出所有元素 + protected List drainQueue(ConcurrentLinkedQueue queue) { + List result = new ArrayList<>(); + T element; + while ((element = queue.poll()) != null) { + result.add(element); + } + return result; + } + + /** + * 获取电池+粒度的专属锁(公共锁逻辑) + */ + protected ReentrantLock getLock(String siteId, String stackId, String clusterId, + String batteryId, String granularity) { + String lockKey = siteId + "_" + stackId + "_" + clusterId + "_" + batteryId + "_" + granularity; + return lockCache.computeIfAbsent(lockKey, k -> new ReentrantLock()); + } + + // 计算退避时间:指数退避 + 随机抖动,避免重试风暴 + private long calculateBackoffTime(int retryCount) { + // 100ms * 2^retry + 随机0-100ms + return (long)(RETRY_BASE_DELAY * Math.pow(2, retryCount)) + random.nextInt(100); + } + + // 判断是否为死锁异常 + private boolean isDeadlockException(Throwable e) { + // 遍历所有异常链(包括cause的cause...) + while (e != null) { + // 检查异常消息是否包含死锁关键字 + if (e.getMessage() != null && e.getMessage().contains("Deadlock found when trying to get lock")) { + return true; + } + // 深入下一层异常 + e = e.getCause(); + } + return false; + } + + /** + * 公共缓存实体(所有站点通用) + */ + protected static class CacheValue { + BigDecimal maxTemp; + LocalDateTime lastUpdateTime; + + public CacheValue(BigDecimal maxTemp, LocalDateTime lastUpdateTime) { + this.maxTemp = maxTemp; + this.lastUpdateTime = lastUpdateTime; + } + } + + // 新增定时任务,每1分钟强制刷新一次队列(防止数据长期积压) + @Scheduled(fixedRate = 60000) // 1分钟 = 60000毫秒 + protected void scheduledFlushBatch() { + if (!hourBatchQueue.isEmpty()) { + List remaining = drainQueue(hourBatchQueue); + ioExecutor.execute(() -> batchUpdateHour(remaining)); + log.info("定时任务触发,处理小时级剩余数据,数量: " + remaining.size()); + } + if (!dayBatchQueue.isEmpty()) { + List remaining = drainQueue(dayBatchQueue); + ioExecutor.execute(() -> batchUpdateDay(remaining)); + log.info("定时任务触发,处理天级剩余数据,数量: " + remaining.size()); + } + if (!monthBatchQueue.isEmpty()) { + List remaining = drainQueue(monthBatchQueue); + ioExecutor.execute(() -> batchUpdateMonth(remaining)); + log.info("定时任务触发,处理月级剩余数据,数量: " + remaining.size()); + } + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml new file mode 100644 index 0000000..d1c9bc5 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance, day_time from ems_battery_data_day + + + + + + + + insert into ems_battery_data_day + + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + inter_resistance, + day_time, + + + #{batteryPack}, + #{batteryCluster}, + #{batteryCellId}, + #{voltage}, + #{temperature}, + #{soc}, + #{soh}, + #{dataTimestamp}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + #{clusterDeviceId}, + #{interResistance}, + #{dayTime}, + + + + + update ems_battery_data_day + + battery_pack = #{batteryPack}, + battery_cluster = #{batteryCluster}, + battery_cell_id = #{batteryCellId}, + voltage = #{voltage}, + temperature = #{temperature}, + soc = #{soc}, + soh = #{soh}, + data_timestamp = #{dataTimestamp}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + cluster_device_id = #{clusterDeviceId}, + inter_resistance = #{interResistance}, + day_time = #{dayTime}, + + where id = #{id} + + + + delete from ems_battery_data_day where id = #{id} + + + + delete from ems_battery_data_day where id in + + #{id} + + + + + + + + INSERT INTO ems_battery_data_day ( + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + inter_resistance, + day_time + ) VALUES + + ( + #{item.batteryPack}, + #{item.batteryCluster}, + #{item.batteryCellId}, + #{item.voltage}, + #{item.temperature}, + #{item.soc}, + #{item.soh}, + #{item.dataTimestamp}, + #{item.createBy}, + #{item.createTime}, #{item.updateBy}, + #{item.updateTime}, + #{item.remark}, + #{item.siteId}, + #{item.deviceId}, + #{item.clusterDeviceId}, + #{item.interResistance}, + #{item.dayTime} + ) + + ON DUPLICATE KEY UPDATE + -- 仅当新温度高于现有温度时,才更新温度和相关字段 + update_time = IF(VALUES(temperature) > temperature, NOW(), update_time), + data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp), + voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage), + soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc), + soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh), + inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance), + update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by) + temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) + + diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml new file mode 100644 index 0000000..aff9a5c --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance, hour_time from ems_battery_data_hour + + + + + + + + insert into ems_battery_data_hour + + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + inter_resistance, + hour_time, + + + #{batteryPack}, + #{batteryCluster}, + #{batteryCellId}, + #{voltage}, + #{temperature}, + #{soc}, + #{soh}, + #{dataTimestamp}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + #{clusterDeviceId}, + #{interResistance}, + #{hourTime}, + + + + + update ems_battery_data_hour + + battery_pack = #{batteryPack}, + battery_cluster = #{batteryCluster}, + battery_cell_id = #{batteryCellId}, + voltage = #{voltage}, + temperature = #{temperature}, + soc = #{soc}, + soh = #{soh}, + data_timestamp = #{dataTimestamp}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + cluster_device_id = #{clusterDeviceId}, + inter_resistance = #{interResistance}, + hour_time = #{hourTime}, + + where id = #{id} + + + + delete from ems_battery_data_hour where id = #{id} + + + + delete from ems_battery_data_hour where id in + + #{id} + + + + + + + + INSERT INTO ems_battery_data_hour ( + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + inter_resistance, + hour_time + ) VALUES + + ( + #{item.batteryPack}, + #{item.batteryCluster}, + #{item.batteryCellId}, + #{item.voltage}, + #{item.temperature}, + #{item.soc}, + #{item.soh}, + #{item.dataTimestamp}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.remark}, + #{item.siteId}, + #{item.deviceId}, + #{item.clusterDeviceId}, + #{item.interResistance}, + #{item.hourTime} + ) + + ON DUPLICATE KEY UPDATE + -- 仅当新温度高于现有温度时,才更新温度和相关字段 + update_time = IF(VALUES(temperature) > temperature, NOW(), update_time), + data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp), + voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage), + soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc), + soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh), + inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance), + update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by) + temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml new file mode 100644 index 0000000..3781843 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance from ems_battery_data_minutes + + + + + + + + insert into ems_battery_data_minutes + + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + inter_resistance, + + + #{batteryPack}, + #{batteryCluster}, + #{batteryCellId}, + #{voltage}, + #{temperature}, + #{soc}, + #{soh}, + #{dataTimestamp}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + #{clusterDeviceId}, + #{interResistance}, + + + + + update ems_battery_data_minutes + + battery_pack = #{batteryPack}, + battery_cluster = #{batteryCluster}, + battery_cell_id = #{batteryCellId}, + voltage = #{voltage}, + temperature = #{temperature}, + soc = #{soc}, + soh = #{soh}, + data_timestamp = #{dataTimestamp}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + cluster_device_id = #{clusterDeviceId}, + inter_resistance = #{interResistance}, + + where id = #{id} + + + + delete from ems_battery_data_minutes where date_day = #{dateDay} + + + + delete from ems_battery_data_minutes where date_day in + + #{dateDay} + + + + + INSERT INTO ems_battery_data_minutes ( + battery_pack, battery_cluster, battery_cell_id, + voltage, temperature, soc, soh, data_timestamp, + create_by, create_time, update_by, update_time, + remark, site_id, device_id, cluster_device_id, inter_resistance + ) VALUES + + ( + #{item.batteryPack}, #{item.batteryCluster}, #{item.batteryCellId}, + #{item.voltage}, #{item.temperature}, #{item.soc}, #{item.soh}, #{item.dataTimestamp}, + #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, + #{item.remark}, #{item.siteId}, #{item.deviceId}, #{item.clusterDeviceId},#{item.interResistance} + ) + + + + + delete from ems_battery_data_minutes where data_timestamp < #{oneHourAgoStr} + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml new file mode 100644 index 0000000..87f6b2b --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, remark, site_id, device_id, cluster_device_id, inter_resistance, month_time from ems_battery_data_month + + + + + + + + insert into ems_battery_data_month + + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + inter_resistance, + month_time, + + + #{batteryPack}, + #{batteryCluster}, + #{batteryCellId}, + #{voltage}, + #{temperature}, + #{soc}, + #{soh}, + #{dataTimestamp}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + #{clusterDeviceId}, + #{interResistance}, + #{monthTime}, + + + + + update ems_battery_data_month + + battery_pack = #{batteryPack}, + battery_cluster = #{batteryCluster}, + battery_cell_id = #{batteryCellId}, + voltage = #{voltage}, + temperature = #{temperature}, + soc = #{soc}, + soh = #{soh}, + data_timestamp = #{dataTimestamp}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + cluster_device_id = #{clusterDeviceId}, + inter_resistance = #{interResistance}, + month_time = #{monthTime}, + + where id = #{id} + + + + delete from ems_battery_data_month where id = #{id} + + + + delete from ems_battery_data_month where id in + + #{id} + + + + + + + + INSERT INTO ems_battery_data_month ( + battery_pack, + battery_cluster, + battery_cell_id, + voltage, + temperature, + soc, + soh, + data_timestamp, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + cluster_device_id, + inter_resistance, + month_time + ) VALUES + + ( + #{item.batteryPack}, + #{item.batteryCluster}, + #{item.batteryCellId}, + #{item.voltage}, + #{item.temperature}, + #{item.soc}, + #{item.soh}, + #{item.dataTimestamp}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.remark}, + #{item.siteId}, + #{item.deviceId}, + #{item.clusterDeviceId}, + #{item.interResistance}, + #{item.monthTime} + ) + + ON DUPLICATE KEY UPDATE + -- 仅当新温度高于现有温度时,才更新温度和相关字段 + update_time = IF(VALUES(temperature) > temperature, NOW(), update_time), + data_timestamp = IF(VALUES(temperature) > temperature, VALUES(data_timestamp), data_timestamp), + voltage = IF(VALUES(temperature) > temperature, VALUES(voltage), voltage), + soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc), + soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh), + inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance), + update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by) + temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) + + \ No newline at end of file -- 2.49.0 From d6276dc21f4a84670fcbcda1d1a8ed49c54a5b19 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 24 Aug 2025 17:12:42 +0800 Subject: [PATCH 123/336] =?UTF-8?q?20250808=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E4=BD=93=E7=94=B5=E6=B1=A0=E8=A1=A8=E6=8B=86=E5=88=86=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/common/core/redis/RedisCache.java | 69 ++++++++++++++++-- .../utils/AbstractBatteryDataProcessor.java | 71 +++++++++---------- .../mapper/ems/EmsBatteryDataDayMapper.xml | 2 +- .../mapper/ems/EmsBatteryDataHourMapper.xml | 2 +- .../mapper/ems/EmsBatteryDataMonthMapper.xml | 2 +- 5 files changed, 102 insertions(+), 44 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java index a8af534..99829d4 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java +++ b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java @@ -7,10 +7,8 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.BoundSetOperations; -import org.springframework.data.redis.core.HashOperations; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; +import org.springframework.dao.DataAccessException; +import org.springframework.data.redis.core.*; import org.springframework.stereotype.Component; /** @@ -287,4 +285,67 @@ public class RedisCache redisTemplate.opsForValue().multiSet(cacheMap); } + /** + * 批量设置键值对,并为每个键设置相同的过期时间 + * @param keyValueMap 键值对集合 + * @param timeout 过期时间 + * @param unit 时间单位 + */ + public void multiSetWithExpire(Map keyValueMap, long timeout, TimeUnit unit) { + if (keyValueMap.isEmpty()) { + return; // 空集合直接返回 + } + + // 使用Redis管道批量执行命令 + redisTemplate.executePipelined(new SessionCallback() { + @Override + public Object execute(RedisOperations operations) throws DataAccessException { + // 循环处理每个键值对 + for (Map.Entry entry : keyValueMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + + // 1. 设置键值对 + operations.opsForValue().set(key, value); + // 2. 设置过期时间 + operations.expire(key, timeout, unit); + } + return null; // 管道操作无需返回值 + } + }); + } + + /** + * 删除指定站点的所有历史测试数据缓存(最精准) + * @param testSiteId 测试数据所属的站点ID(如"test-site-001") + */ + public void deleteTestCacheBySite(String testSiteId) { + System.out.println("开删除缓存redis:" + testSiteId + ""); + if (testSiteId == null || testSiteId.isEmpty()) { + return; + } + + // 构造键前缀:测试站点ID开头的所有缓存键(无论粒度和时间) + String pattern = testSiteId + "_*"; + deleteCacheByPattern(pattern); + } + + /** + * 根据键前缀批量删除缓存(核心方法) + * @param pattern 键匹配模式(支持Redis的通配符:*表示任意字符,?表示单个字符) + */ + public void deleteCacheByPattern(String pattern) { + try { + // 1. 查找所有匹配的键(注意:keys命令在大数据量时可能阻塞Redis,建议生产环境用scan) + Set keys = redisTemplate.keys(pattern); + if (keys == null || keys.isEmpty()) { + return; + } + + // 2. 批量删除匹配的键 + long deleteCount = redisTemplate.delete(keys); + System.out.println("删除缓存数据:" + deleteCount + ""); + } catch (Exception e) { + } + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java index 2dcc4a1..ba0ec22 100644 --- a/ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java +++ b/ems-system/src/main/java/com/xzzn/ems/utils/AbstractBatteryDataProcessor.java @@ -28,6 +28,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -95,7 +96,6 @@ public abstract class AbstractBatteryDataProcessor { // 传递分片索引和是否最后一个分片的标记 ioExecutor.execute(() -> processShard(shard, isLastShard)); } - //shards.forEach(shard -> ioExecutor.execute(() -> processShard(shard))); } /** @@ -245,20 +245,11 @@ public abstract class AbstractBatteryDataProcessor { public void batchUpdateHourCache(List hourDataList) { if (hourDataList.isEmpty()) return; - // 1. 构建缓存键值对(批量操作提升效率) - Map tempCacheMap = new HashMap<>(hourDataList.size()); - for (EmsBatteryDataHour data : hourDataList) { - EmsBatteryData cacheData = new EmsBatteryData(); - BeanUtils.copyProperties(data, cacheData); - // 2. 生成唯一缓存键(与数据库唯一键一致) - String cacheKey = generateCacheKey(cacheData, "hour"); - // 3. 存储最高温度和最后更新时间(两个独立缓存项) - tempCacheMap.put(cacheKey, data.getTemperature().toString()); - } + Map tempCacheMap = buildCacheMap(hourDataList, "hour"); try { - // 4. 批量设置缓存(Redis批量操作减少网络交互) - redisCache.multiSet(tempCacheMap); + // 批量设置缓存 + redisCache.multiSetWithExpire(tempCacheMap, 1, TimeUnit.HOURS); } catch (Exception e) { log.error("批量更新小时级缓存失败", e); // 缓存更新失败不影响主流程,但需记录日志便于排查 @@ -343,20 +334,11 @@ public abstract class AbstractBatteryDataProcessor { public void batchUpdateDayCache(List dayDataList) { if (dayDataList.isEmpty()) return; - // 1. 构建缓存键值对(批量操作提升效率) - Map tempCacheMap = new HashMap<>(dayDataList.size()); - for (EmsBatteryDataDay data : dayDataList) { - EmsBatteryData cacheData = new EmsBatteryData(); - BeanUtils.copyProperties(data, cacheData); - // 2. 生成唯一缓存键(与数据库唯一键一致) - String cacheKey = generateCacheKey(cacheData, "day"); - // 3. 存储最高温度和最后更新时间(两个独立缓存项) - tempCacheMap.put(cacheKey, data.getTemperature().toString()); - } + Map tempCacheMap = buildCacheMap(dayDataList, "hour"); try { - // 4. 批量设置缓存(Redis批量操作减少网络交互) - redisCache.multiSet(tempCacheMap); + // 批量设置缓存 + redisCache.multiSetWithExpire(tempCacheMap, 24, TimeUnit.HOURS); } catch (Exception e) { log.error("批量更新小时级缓存失败", e); // 缓存更新失败不影响主流程,但需记录日志便于排查 @@ -454,20 +436,11 @@ public abstract class AbstractBatteryDataProcessor { public void batchUpdateMonthCache(List monthDataList) { if (monthDataList.isEmpty()) return; - // 1. 构建缓存键值对(批量操作提升效率) - Map tempCacheMap = new HashMap<>(monthDataList.size()); - for (EmsBatteryDataMonth data : monthDataList) { - EmsBatteryData cacheData = new EmsBatteryData(); - BeanUtils.copyProperties(data, cacheData); - // 2. 生成唯一缓存键(与数据库唯一键一致) - String cacheKey = generateCacheKey(cacheData, "month"); - // 3. 存储最高温度和最后更新时间(两个独立缓存项) - tempCacheMap.put(cacheKey, data.getTemperature().toString()); - } + Map tempCacheMap = buildCacheMap(monthDataList, "hour"); try { - // 4. 批量设置缓存(Redis批量操作减少网络交互) - redisCache.multiSet(tempCacheMap); + // 批量设置缓存 + redisCache.multiSetWithExpire(tempCacheMap, 24*30, TimeUnit.HOURS); } catch (Exception e) { log.error("批量更新月级缓存失败", e); // 缓存更新失败不影响主流程,但需记录日志便于排查 @@ -659,6 +632,30 @@ public abstract class AbstractBatteryDataProcessor { } } + // 通用构建缓存键值对的方法(根据不同数据类型适配) + private Map buildCacheMap(List dataList, String granularity) { + Map cacheMap = new HashMap<>(dataList.size()); + for (T data : dataList) { + EmsBatteryData cacheData = new EmsBatteryData(); + BeanUtils.copyProperties(data, cacheData); + String cacheKey = generateCacheKey(cacheData, granularity); + + // 根据数据类型获取温度值(实际项目中可通过接口或反射统一处理) + String temperature; + if (data instanceof EmsBatteryDataHour) { + temperature = ((EmsBatteryDataHour) data).getTemperature().toString(); + } else if (data instanceof EmsBatteryDataDay) { + temperature = ((EmsBatteryDataDay) data).getTemperature().toString(); + } else if (data instanceof EmsBatteryDataMonth) { + temperature = ((EmsBatteryDataMonth) data).getTemperature().toString(); + } else { + throw new IllegalArgumentException("不支持的数据类型"); + } + cacheMap.put(cacheKey, temperature); + } + return cacheMap; + } + // 新增定时任务,每1分钟强制刷新一次队列(防止数据长期积压) @Scheduled(fixedRate = 60000) // 1分钟 = 60000毫秒 protected void scheduledFlushBatch() { diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml index d1c9bc5..be2f7b8 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml @@ -195,7 +195,7 @@ soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc), soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh), inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance), - update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by) + update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by), temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml index aff9a5c..2f2f886 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataHourMapper.xml @@ -196,7 +196,7 @@ soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc), soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh), inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance), - update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by) + update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by), temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml index 87f6b2b..4d066dd 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml @@ -196,7 +196,7 @@ soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc), soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh), inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance), - update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by) + update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by), temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) \ No newline at end of file -- 2.49.0 From 1a1558f8cd56743a072bc4a8331082b44f65d74a Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 27 Aug 2025 01:32:05 +0800 Subject: [PATCH 124/336] =?UTF-8?q?20250808=E4=BC=98=E5=8C=96-=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E4=BC=98=E5=8C=96&=E4=B8=BB=E8=B7=AF=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/vo/AlarmRecordListRequestVo.java | 11 ++++++++++ .../xzzn/ems/domain/vo/SiteDeviceListVo.java | 10 ++++++++++ .../ems/mapper/EmsBatteryDataDayMapper.java | 4 ++++ .../impl/DDSDataProcessServiceImpl.java | 4 ++-- .../ems/service/impl/EmsSiteServiceImpl.java | 20 ++++++++++++++++++- .../impl/EmsStatsReportServiceImpl.java | 4 +++- .../mapper/ems/EmsAlarmRecordsMapper.xml | 7 +++++++ .../mapper/ems/EmsBatteryDataDayMapper.xml | 15 ++++++++++++++ 8 files changed, 71 insertions(+), 4 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java index a6179f3..b334c00 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AlarmRecordListRequestVo.java @@ -26,6 +26,9 @@ public class AlarmRecordListRequestVo { /** 设备id */ private String deviceId; + /** 告警状态 */ + private String status; + public String getSiteId() { return siteId; } @@ -73,4 +76,12 @@ public class AlarmRecordListRequestVo { public void setDeviceId(String deviceId) { this.deviceId = deviceId; } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java index dab2423..5ddddf8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -25,6 +25,8 @@ public class SiteDeviceListVo { private String id; /** 父类id */ private String parentId; + /** 单体电池个数-仅stack设备下有 */ + private int batteryNum; public String getSiteId() { return siteId; @@ -105,4 +107,12 @@ public class SiteDeviceListVo { public void setParentId(String parentId) { this.parentId = parentId; } + + public int getBatteryNum() { + return batteryNum; + } + + public void setBatteryNum(int batteryNum) { + this.batteryNum = batteryNum; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java index 45f7da2..1928e99 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataDayMapper.java @@ -4,6 +4,8 @@ import java.time.LocalDateTime; import java.util.List; import com.xzzn.ems.domain.EmsBatteryDataDay; import com.xzzn.ems.domain.EmsBatteryDataHour; +import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; +import com.xzzn.ems.domain.vo.DateSearchRequest; import org.apache.ibatis.annotations.Param; /** @@ -69,4 +71,6 @@ public interface EmsBatteryDataDayMapper * 批量插入或更新天级数据(存在则更新,不存在则插入) */ void batchInsertOrUpdate(@Param("list") List dayDataList); + + public List getBatteryDayData(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index cec9755..04d81d3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -815,13 +815,13 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataMete.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); dataMete.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); // 电能设置-正向有功 - dataMete.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); + dataMete.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXZYGDN"))); dataMete.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); dataMete.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); dataMete.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); dataMete.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); // 电能设置-反向有功 - dataMete.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); + dataMete.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXZYGDN"))); dataMete.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); dataMete.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); dataMete.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index d88adfe..cadf8d7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -1,6 +1,9 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsSiteSetting; import com.xzzn.ems.domain.vo.SiteDeviceListVo; import com.xzzn.ems.domain.vo.SiteTotalInfoVo; @@ -25,6 +28,8 @@ public class EmsSiteServiceImpl implements IEmsSiteService private EmsSiteSettingMapper emsSiteMapper; @Autowired private EmsDevicesSettingMapper emsDevicesMapper; + @Autowired + private RedisCache redisCache; @Override public List getAllSites() { @@ -76,7 +81,20 @@ public class EmsSiteServiceImpl implements IEmsSiteService */ @Override public List getAllDeviceList(String siteId) { - return emsSiteMapper.getAllSiteDeviceList(siteId); + List resultData = emsSiteMapper.getAllSiteDeviceList(siteId); + if(resultData == null || resultData.size() == 0){ + return resultData; + } + for (SiteDeviceListVo siteDeviceListVo : resultData) { + String clusterId = siteDeviceListVo.getDeviceId(); + String deviceCategory = siteDeviceListVo.getDeviceCategory(); + if(DeviceCategory.CLUSTER.getCode().equals(deviceCategory)){ + // 获取该stack下面有多少单体电池 + List batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); + siteDeviceListVo.setBatteryNum(batteryDataList == null ? 0 : batteryDataList.size()); + } + } + return resultData; } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 2cdb178..c1a10d7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -39,6 +39,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService private EmsBatteryDataMapper emsBatteryDataMapper; @Autowired private EmsBatteryDailyLatestMapper emsBatteryDailyLatestMapper; + @Autowired + private EmsBatteryDataDayMapper emsBatteryDataDayMapper; // 电量指标 @Override @@ -295,6 +297,6 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService public List getSingleBatteryData(DateSearchRequest requestVo) { // 默认时间-7天 dealRequestTime(requestVo); - return emsBatteryDailyLatestMapper.getBatteryDailyLatest(requestVo); + return emsBatteryDataDayMapper.getBatteryDayData(requestVo); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index 9e8ed76..e47c236 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -162,6 +162,13 @@ AND t.device_id = #{deviceId} + + AND t.status IN ( + + #{item} + + ) + AND (date_format(t.alarm_start_time,'%Y%m%d') BETWEEN date_format(#{alarmStartTime},'%Y%m%d') and date_format(#{alarmEndTime},'%Y%m%d') or date_format(t.alarm_end_time,'%Y%m%d') BETWEEN date_format(#{alarmStartTime},'%Y%m%d') and date_format(#{alarmEndTime},'%Y%m%d') ) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml index be2f7b8..96e21ca 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataDayMapper.xml @@ -198,4 +198,19 @@ update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by), temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) + + + -- 2.49.0 From 26bbe6deeee9614925de2f3b8c17272e33c59719 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 28 Aug 2025 14:15:19 +0800 Subject: [PATCH 125/336] =?UTF-8?q?20250808=E4=BC=98=E5=8C=96-=E5=85=85?= =?UTF-8?q?=E6=94=BE=E7=94=B5=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/common/constant/Constants.java | 5 ++ .../java/com/xzzn/common/utils/DateUtils.java | 38 ++++++++++++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 4 ++ .../impl/DDSDataProcessServiceImpl.java | 54 +++++++++++++++++ .../impl/EmsStatsReportServiceImpl.java | 5 +- .../impl/FXXDataProcessServiceImpl.java | 60 +++++++++++++++++-- .../ems/service/impl/HomePageServiceImpl.java | 48 ++++++--------- .../service/impl/SingleSiteServiceImpl.java | 32 ++++------ .../mapper/ems/EmsAmmeterDataMapper.xml | 8 +++ .../mapper/ems/EmsBatteryClusterMapper.xml | 2 +- 10 files changed, 199 insertions(+), 57 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/constant/Constants.java b/ems-common/src/main/java/com/xzzn/common/constant/Constants.java index c594319..9757912 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/Constants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/Constants.java @@ -170,4 +170,9 @@ public class Constants */ public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml", "org.springframework", "org.apache", "com.xzzn.common.utils.file", "com.xzzn.common.config", "com.xzzn.generator" }; + + /** + * 昨日充放电最晚数据有效期 + */ + public static final Integer DATE_VALID_TIME = 1; } diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index a49d234..9111374 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -8,6 +8,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; import org.apache.commons.lang3.time.DateFormatUtils; @@ -29,6 +30,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; + public static String YYYYMMDD = "yyyyMMdd"; + private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", @@ -206,4 +209,39 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.systemDefault()); return Date.from(zonedDateTime.toInstant()); } + + /** + * 获取昨天的日期,格式为yyyy-MM-dd + * @return 昨天的日期字符串 + */ + public static String getYesterdayDate() { + // 获取今天的日期 + LocalDate today = LocalDate.now(); + // 减去一天得到昨天 + LocalDate yesterday = today.minusDays(1); + // 定义日期格式化器 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYYMMDD); + // 格式化并返回 + return yesterday.format(formatter); + } + + /** + * 校验传入日期是否今天 + * @param dataDate + * @return + */ + public static boolean checkIsToday(String dataDate) { + boolean flag = false; + Calendar calendar = Calendar.getInstance(); + int todayMonth = calendar.get(Calendar.MONTH) + 1; + int todayDay = calendar.get(Calendar.DAY_OF_MONTH); + if (StringUtils.isNotEmpty(dataDate)){ + String[] pcsDateArray = dataDate.split("-"); + if (todayMonth == Integer.parseInt(pcsDateArray[1]) && + todayDay == Integer.parseInt(pcsDateArray[2])) { + flag = true; + } + } + return flag; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index 5ffe8de..34996a9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -4,6 +4,7 @@ import java.util.List; import com.xzzn.ems.domain.EmsAmmeterData; import com.xzzn.ems.domain.vo.AmmeterStatisListVo; import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest; +import org.apache.ibatis.annotations.Param; /** * 总数据Mapper接口 @@ -67,4 +68,7 @@ public interface EmsAmmeterDataMapper * @return */ public List getLoadDataByHour(StatisAmmeterDateRequest requestVo); + + // 获取昨天最晚数据 + public EmsAmmeterData getYestLatestDate(@Param("siteId")String siteId, @Param("deviceId")String deviceId, @Param("yestData")String yestData); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 04d81d3..9dadac0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson2.TypeReference; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.constant.Constants; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.*; @@ -27,6 +28,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -70,6 +72,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsBatteryGroupMapper emsBatteryGroupMapper; @Autowired private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; + @Autowired + private EmsDailyChargeDataMapper emsDailyChargeDataMapper; public DDSDataProcessServiceImpl(ObjectMapper objectMapper) { super(objectMapper); @@ -894,7 +898,57 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsAmmeterDataMapper.insertEmsAmmeterData(dataMete); redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataMete); + + // 处理每日充放电数据 + dealDDSDailyChargeDate(obj,deviceId); } + + private void dealDDSDailyChargeDate(Map obj, String deviceId) { + log.info("start dealDDSDailyChargeDate"); + // 初始化今日充放电 + BigDecimal dailyDisChargeDate = new BigDecimal(0); + BigDecimal dailyChargeDate = new BigDecimal(0); + + BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN")); + BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN")); + // 初始化当日数据 + EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); + emsDailyChargeData.setSiteId(SITE_ID); + emsDailyChargeData.setDeviceId(deviceId); + emsDailyChargeData.setDateTime(DateUtils.getNowDate()); + emsDailyChargeData.setTotalChargeData(nowTotalChargeDate); + emsDailyChargeData.setTotalDischargeData(nowTotalDisChargeDate); + emsDailyChargeData.setCreateBy("system"); + emsDailyChargeData.setCreateTime(DateUtils.getNowDate()); + emsDailyChargeData.setUpdateBy("system"); + emsDailyChargeData.setUpdateTime(DateUtils.getNowDate()); + // 获取redis存放昨日最晚数据 + String yestData = DateUtils.getYesterdayDate(); + String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestData; + EmsAmmeterData yestDate = redisCache.getCacheObject(yestDateRedisKey); + if (yestDate == null) { + // redis没有这查电表总数据表 + yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData); + } + if (yestDate != null) { + // 今日总数据-昨日总数据=今日充放电 + BigDecimal yestTotalDisChargeDate = yestDate.getCurrentForwardActiveTotal(); + BigDecimal yestTotalChargeDate = yestDate.getCurrentReverseActiveTotal(); + + dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); + dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); + emsDailyChargeData.setChargeData(dailyChargeDate); + emsDailyChargeData.setDischargeData(dailyDisChargeDate); + + // 最新数据存redis + redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); + } + + // 插入或更新每日充放电数据表 + emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); + log.info("end dealDDSDailyChargeDate"); + } + // 数据分组处理 private static Map> processData(Map rawData) { Map> records = new HashMap<>(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index c1a10d7..deefda8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -41,6 +41,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService private EmsBatteryDailyLatestMapper emsBatteryDailyLatestMapper; @Autowired private EmsBatteryDataDayMapper emsBatteryDataDayMapper; + @Autowired + private EmsDailyChargeDataMapper emsDailyChargeDataMapper; // 电量指标 @Override @@ -53,7 +55,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService Date endDate = requestVo.getEndDate(); // 总充总放 - Map totalMap = emsPcsDataMapper.getPcsTotalChargeData(requestVo.getSiteId()); + String nowData = DateUtils.getDate(); + Map totalMap = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,requestVo.getSiteId()); BigDecimal totalDischarge = totalMap.get("totalDischargedCap") != null ? totalMap.get("totalDischargedCap") : BigDecimal.ZERO; BigDecimal totalCharge = totalMap.get("totalChargedCap") != null ? totalMap.get("totalChargedCap") : BigDecimal.ZERO; BigDecimal efficiency = new BigDecimal(0); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index a740418..fac9e34 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson2.TypeReference; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.constant.Constants; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.*; @@ -22,10 +23,12 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.concurrent.TimeUnit; @Service public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXDataProcessService { @@ -59,6 +62,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsBatteryDailyLatestServiceImpl emsBatteryDailyLatestServiceImpl; @Autowired private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; + @Autowired + private EmsDailyChargeDataMapper emsDailyChargeDataMapper; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -81,7 +86,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return; } - if (deviceId.contains("BMSD")) { + /*if (deviceId.contains("BMSD")) { batteryStackDataProcess(deviceId, jsonData); } else if (deviceId.contains("BMSC")) { @@ -92,11 +97,11 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else if (deviceId.contains("PCS")) { pcsDataProcess(deviceId, jsonData); pcsBranchDataProcess(deviceId, jsonData); - } else if (deviceId.contains("LOAD")) { + } else*/ if (deviceId.contains("LOAD")) { loadDataProcess(deviceId, jsonData); - } else if (deviceId.contains("METE")) { + } /*else if (deviceId.contains("METE")) { meteDataProcess(deviceId, jsonData); - } + }*/ } } @@ -560,6 +565,53 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + + // 处理每日充放电数据 + dealFXXDailyChargeDate(obj,deviceId); + } + + private void dealFXXDailyChargeDate(Map obj, String deviceId) { + log.info("start dealFXXDailyChargeDate"); + // 初始化今日充放电 + BigDecimal dailyChargeDate = new BigDecimal(0); + BigDecimal dailyDisChargeDate = new BigDecimal(0); + + BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQZXYGZDN")); + BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQFXYGZDN")); + // 初始化当日数据 + EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); + emsDailyChargeData.setSiteId(SITE_ID); + emsDailyChargeData.setDeviceId(deviceId); + emsDailyChargeData.setDateTime(DateUtils.getNowDate()); + emsDailyChargeData.setTotalChargeData(nowTotalChargeDate); + emsDailyChargeData.setTotalDischargeData(nowTotalDisChargeDate); + emsDailyChargeData.setCreateBy("system"); + emsDailyChargeData.setCreateTime(DateUtils.getNowDate()); + emsDailyChargeData.setUpdateBy("system"); + emsDailyChargeData.setUpdateTime(DateUtils.getNowDate()); + // 获取redis存放昨日最晚数据 + String yestData = DateUtils.getYesterdayDate(); + String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestData; + EmsAmmeterData yestDate = redisCache.getCacheObject(yestDateRedisKey); + if (yestDate == null) { + // redis没有这查电表总数据表 + yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData); + } + if (yestDate != null) { + // 今日总数据-昨日总数据=今日充放电 + BigDecimal yestTotalDisChargeDate = yestDate.getCurrentForwardActiveTotal(); + BigDecimal yestTotalChargeDate = yestDate.getCurrentReverseActiveTotal(); + + dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); + dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); + emsDailyChargeData.setChargeData(dailyChargeDate); + emsDailyChargeData.setDischargeData(dailyDisChargeDate); + // 存下redis-有效期1天 + redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); + } + // 插入或更新每日充放电数据表 + emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); + log.info("end dealFXXDailyChargeDate"); } private void meteDataProcess(String deviceId, String dataJson) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index 7c36cb5..984aaa0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -5,6 +5,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsSiteSetting; import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; +import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; import com.xzzn.ems.mapper.EmsPcsDataMapper; import com.xzzn.ems.mapper.EmsSiteSettingMapper; import com.xzzn.ems.service.IEmsSiteService; @@ -34,16 +35,19 @@ public class HomePageServiceImpl implements IHomePageService private EmsSiteSettingMapper emsSiteMapper; @Autowired private EmsAlarmRecordsMapper alarmRecordsMapper; + @Autowired + private EmsDailyChargeDataMapper emsDailyChargeDataMapper; @Override public SiteTotalInfoVo getSiteTotalInfo() { SiteTotalInfoVo siteTotalInfoVo = new SiteTotalInfoVo(); siteTotalInfoVo = emsSiteService.getSiteTotalInfo(); // 获取总充+总放 - Map pcsMap = emsPcsDataMapper.getPcsTotalChargeData(null); - if(pcsMap != null){ - siteTotalInfoVo.setTotalChargedCap(pcsMap.get("totalChargedCap")); - siteTotalInfoVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap")); + String nowData = DateUtils.getDate(); + Map data = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,null); + if(data != null){ + siteTotalInfoVo.setTotalChargedCap(data.get("totalChargedCap")); + siteTotalInfoVo.setTotalDischargedCap(data.get("totalDischargedCap")); } return siteTotalInfoVo; } @@ -69,31 +73,32 @@ public class HomePageServiceImpl implements IHomePageService singleSiteBaseInfo.setRunningTime(emsSite.getRunningTime() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd",emsSite.getRunningTime()));//投运时间 // 获取单站点的总充+总放 - Map pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId); - if (pcsMap != null) { - singleSiteBaseInfo.setTotalChargedCap(pcsMap.get("totalChargedCap")); - singleSiteBaseInfo.setTotalDisChargedCap(pcsMap.get("totalDischargedCap")); + String nowData = DateUtils.getDate(); + Map data = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,siteId); + if (data != null) { + singleSiteBaseInfo.setTotalChargedCap(data.get("totalChargedCap")); + singleSiteBaseInfo.setTotalDisChargedCap(data.get("totalDischargedCap")); } // 七天放电数据统计 默认从今天往前7天 LocalDate sevenDaysAgo = LocalDate.now().minusDays(LIMIT_TIME); Date startDate = DateUtils.toDate(sevenDaysAgo); Date endDate = new Date(); - List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,startDate,endDate); + List siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate); singleSiteBaseInfo.setSevenDayDisChargeStats(siteMonitorDataVoList); // 充放电基本数据处理 - dealSitePCSDate(singleSiteBaseInfo,siteMonitorDataVoList); + dealSiteChargeDate(singleSiteBaseInfo,siteMonitorDataVoList); } } return singleSiteBaseInfo; } - private void dealSitePCSDate(SingleSiteBaseInfo singleSiteBaseInfo, List siteMonitorDataVoList) { + private void dealSiteChargeDate(SingleSiteBaseInfo singleSiteBaseInfo, List siteMonitorDataVoList) { if (siteMonitorDataVoList != null && !siteMonitorDataVoList.isEmpty()) { for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) { // 获取当天的充电量+放电量 - String pcsDate = sitePcsData.getAmmeterDate(); - boolean isToday= checkIsToday(pcsDate); + String dayDate = sitePcsData.getAmmeterDate(); + boolean isToday= DateUtils.checkIsToday(dayDate); if(isToday){ singleSiteBaseInfo.setDayChargedCap(sitePcsData.getChargedCap()); singleSiteBaseInfo.setDayDisChargedCap(sitePcsData.getDisChargedCap()); @@ -102,21 +107,6 @@ public class HomePageServiceImpl implements IHomePageService } } - private boolean checkIsToday(String pcsDate) { - boolean flag = false; - Calendar calendar = Calendar.getInstance(); - int todayMonth = calendar.get(Calendar.MONTH) + 1; - int todayDay = calendar.get(Calendar.DAY_OF_MONTH); - if (StringUtils.isNotEmpty(pcsDate)){ - String[] pcsDateArray = pcsDate.split("-"); - if (todayMonth == Integer.parseInt(pcsDateArray[0]) && - todayDay == Integer.parseInt(pcsDateArray[1])) { - flag = true; - } - } - return flag; - } - /** * 首页看板-数据概览 */ @@ -179,7 +169,7 @@ public class HomePageServiceImpl implements IHomePageService Date startDate = requestVo.getStartDate(); Date endDate = requestVo.getEndDate(); // 七天放电数据统计 - List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,startDate,endDate); + List siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate); return siteMonitorDataVoList; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index e4b982e..e518c70 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -61,6 +61,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private EmsStrategyRunningMapper emsStrategyRunningMapper; @Autowired private EmsStrategyTempMapper emsStrategyTempMapper; + @Autowired + private EmsDailyChargeDataMapper emsDailyChargeDataMapper; @Override public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { @@ -68,11 +70,12 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (!StringUtils.isEmpty(siteId)) { // 获取单站点的总充+总放+电网实时功率 - Map pcsMap = emsPcsDataMapper.getPcsTotalChargeData(siteId); - if (pcsMap != null) { - siteMonitorHomeVo.setTotalChargedCap(pcsMap.get("totalChargedCap")); - siteMonitorHomeVo.setTotalDischargedCap(pcsMap.get("totalDischargedCap")); - siteMonitorHomeVo.setGridNrtPower(pcsMap.get("gridNrtPower")); + String nowData = DateUtils.getDate(); + Map dataMap = emsDailyChargeDataMapper.getAllSiteChargeData(nowData,siteId); + if (dataMap != null) { + siteMonitorHomeVo.setTotalChargedCap(dataMap.get("totalChargedCap")); + siteMonitorHomeVo.setTotalDischargedCap(dataMap.get("totalDischargedCap")); + siteMonitorHomeVo.setGridNrtPower(dataMap.get("gridNrtPower")); } // 实时告警数据 名称+状态+告警内容 List siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId); @@ -91,12 +94,12 @@ public class SingleSiteServiceImpl implements ISingleSiteService { LocalDate sevenDaysAgo = LocalDate.now().minusDays(6); Date startDate = DateUtils.toDate(sevenDaysAgo); Date endDate = new Date(); - List siteMonitorDataVoList = emsPcsDataMapper.getPcsDataBySiteId(siteId,startDate,endDate); + List siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate); if (!CollectionUtils.isEmpty(siteMonitorDataVoList)) { for (SiteMonitorDataVo sitePcsData : siteMonitorDataVoList) { // 获取当天的充电量+放电量 String pcsDate = sitePcsData.getAmmeterDate(); - boolean isToday= checkIsToday(pcsDate); + boolean isToday= DateUtils.checkIsToday(pcsDate); if(isToday){ siteMonitorHomeVo.setDayChargedCap(sitePcsData.getChargedCap()); siteMonitorHomeVo.setDayDisChargedCap(sitePcsData.getDisChargedCap()); @@ -112,21 +115,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return siteMonitorHomeVo; } - private boolean checkIsToday(String pcsDate) { - boolean flag = false; - Calendar calendar = Calendar.getInstance(); - int todayMonth = calendar.get(Calendar.MONTH) + 1; - int todayDay = calendar.get(Calendar.DAY_OF_MONTH); - if (StringUtils.isNotEmpty(pcsDate)){ - String[] pcsDateArray = pcsDate.split("-"); - if (todayMonth == Integer.parseInt(pcsDateArray[0]) && - todayDay == Integer.parseInt(pcsDateArray[1])) { - flag = true; - } - } - return flag; - } - // 获取单站监控实时运行头部数据 @Override public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 914c099..cb665e4 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -883,4 +883,12 @@ and t.data_update_time = latest.max_update_time order by dataTime + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 55be7aa..ef46217 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -343,7 +343,7 @@ avg(t.avg_cell_temp) as batteryTemp, DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') AS createDate from ems_battery_cluster t - where t.site_id = '021_FXX_01' + where t.site_id = #{siteId} AND t.create_time >= Date(#{startDate}) AND t.create_time <= #{endDate} GROUP BY t.site_id,DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') -- 2.49.0 From 7374d7708bb597ecc29b2e95275cf0245c06ec9d Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 1 Sep 2025 16:10:17 +0800 Subject: [PATCH 126/336] =?UTF-8?q?20250808=E4=BC=98=E5=8C=96-=E5=85=85?= =?UTF-8?q?=E6=94=BE=E7=94=B5=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 5 - .../java/com/xzzn/common/utils/DateUtils.java | 8 + .../xzzn/ems/domain/EmsDailyChargeData.java | 151 +++++++++++++++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 17 +- .../ems/mapper/EmsDailyChargeDataMapper.java | 79 ++++++++ .../impl/DDSDataProcessServiceImpl.java | 13 +- .../impl/EmsStatsReportServiceImpl.java | 19 +- .../impl/FXXDataProcessServiceImpl.java | 20 +- .../ems/service/impl/HomePageServiceImpl.java | 105 ++++++++++- .../mapper/ems/EmsAmmeterDataMapper.xml | 71 +++++++ .../mapper/ems/EmsDailyChageDataMapper.xml | 177 ++++++++++++++++++ 11 files changed, 627 insertions(+), 38 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyChargeData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 58df29b..e16229c 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -51,9 +51,4 @@ public class RedisKeyConstants * BMSD原始数据 redis key */ public static final String ORIGINAL_BMSD = "BMSD_"; - - /** - * mqtt监听的原始报文 - */ - public static final String MQTT_ORIGINAL = "mqtt_"; } diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 9111374..61d94a2 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -244,4 +244,12 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils } return flag; } + + /** + * 将时间转换为月份(YYYY-MM) + */ + public static String formatMonth(LocalDateTime time) { + return time.format(DateTimeFormatter.ofPattern("yyyy-MM")); + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyChargeData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyChargeData.java new file mode 100644 index 0000000..05e5898 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyChargeData.java @@ -0,0 +1,151 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_daily_charge_data + * + * @author xzzn + * @date 2025-08-27 + */ +public class EmsDailyChargeData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 数据日期:yyyy-MM-dd */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据日期:yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd") + private Date dateTime; + + /** 总充电量 */ + @Excel(name = "总充电量") + private BigDecimal totalChargeData; + + /** 总放电量 */ + @Excel(name = "总放电量") + private BigDecimal totalDischargeData; + + /** 当日充电量 */ + @Excel(name = "当日充电量") + private BigDecimal chargeData; + + /** 当日放电量 */ + @Excel(name = "当日放电量") + private BigDecimal dischargeData; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + 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 void setDateTime(Date dateTime) + { + this.dateTime = dateTime; + } + + public Date getDateTime() + { + return dateTime; + } + + public void setTotalChargeData(BigDecimal totalChargeData) + { + this.totalChargeData = totalChargeData; + } + + public BigDecimal getTotalChargeData() + { + return totalChargeData; + } + + public void setTotalDischargeData(BigDecimal totalDischargeData) + { + this.totalDischargeData = totalDischargeData; + } + + public BigDecimal getTotalDischargeData() + { + return totalDischargeData; + } + + public void setChargeData(BigDecimal chargeData) + { + this.chargeData = chargeData; + } + + public BigDecimal getChargeData() + { + return chargeData; + } + + public void setDischargeData(BigDecimal dischargeData) + { + this.dischargeData = dischargeData; + } + + public BigDecimal getDischargeData() + { + return dischargeData; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("dateTime", getDateTime()) + .append("totalChargeData", getTotalChargeData()) + .append("totalDischargeData", getTotalDischargeData()) + .append("chargeData", getChargeData()) + .append("dischargeData", getDischargeData()) + .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/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index 34996a9..4b1b554 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -1,9 +1,9 @@ package com.xzzn.ems.mapper; +import java.util.Date; import java.util.List; import com.xzzn.ems.domain.EmsAmmeterData; -import com.xzzn.ems.domain.vo.AmmeterStatisListVo; -import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest; +import com.xzzn.ems.domain.vo.*; import org.apache.ibatis.annotations.Param; /** @@ -71,4 +71,17 @@ public interface EmsAmmeterDataMapper // 获取昨天最晚数据 public EmsAmmeterData getYestLatestDate(@Param("siteId")String siteId, @Param("deviceId")String deviceId, @Param("yestData")String yestData); + + // 获取可统计站点每个月的时间范围 + public List getMonthlyTimeRanges(); + + // 批量获取站点时间节点的充放电数据 + public List batchGetTimePointValues(List timePointQueries); + + // 概率统计-电量指标(按小时) + public List getChargeDataByHour(@Param("siteId")String siteId, @Param("deviceId")String deviceId,@Param("startDate")Date startDate); + + // 概率统计-电量指标(按月) + public List getChargeDataByMonth(@Param("siteId")String siteId, @Param("deviceId")String deviceId,@Param("startDate")Date startDate,@Param("endDate")Date endDate); + } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java new file mode 100644 index 0000000..2d88493 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java @@ -0,0 +1,79 @@ +package com.xzzn.ems.mapper; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.xzzn.ems.domain.EmsDailyChargeData; +import com.xzzn.ems.domain.vo.SiteMonitorDataVo; +import org.apache.ibatis.annotations.Param; + +/** + * 站点每日充放电数据Mapper接口 + * + * @author xzzn + * @date 2025-08-27 + */ +public interface EmsDailyChargeDataMapper +{ + /** + * 查询站点每日充放电数据 + * + * @param id 站点每日充放电数据主键 + * @return 站点每日充放电数据 + */ + public EmsDailyChargeData selectEmsDailyChargeDataById(Long id); + + /** + * 查询站点每日充放电数据列表 + * + * @param emsDailyChargeData 站点每日充放电数据 + * @return 站点每日充放电数据集合 + */ + public List selectEmsDailyChargeDataList(EmsDailyChargeData emsDailyChargeData); + + /** + * 新增站点每日充放电数据 + * + * @param emsDailyChargeData 站点每日充放电数据 + * @return 结果 + */ + public int insertEmsDailyChargeData(EmsDailyChargeData emsDailyChargeData); + + /** + * 修改站点每日充放电数据 + * + * @param emsDailyChargeData 站点每日充放电数据 + * @return 结果 + */ + public int updateEmsDailyChargeData(EmsDailyChargeData emsDailyChargeData); + + /** + * 删除站点每日充放电数据 + * + * @param id 站点每日充放电数据主键 + * @return 结果 + */ + public int deleteEmsDailyChargeDataById(Long id); + + /** + * 批量删除站点每日充放电数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsDailyChargeDataByIds(Long[] ids); + + // 插入或更新站点每日充放电数据 + public void insertOrUpdateData(EmsDailyChargeData emsDailyChargeData); + + // 获取所有站点总充总放 + public Map getAllSiteChargeData(@Param("nowData")String nowData, @Param("siteId")String siteId); + + // 获取单站点时间范围内每日充放电数据 + public List getSingleSiteChargeData(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + + // 按天获取站点每日总充总放 + public List getTotalChargeDataByDay(@Param("siteId")String siteId,@Param("startDate")Date startDate, @Param("endDate")Date endDate); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 9dadac0..97c31cd 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -909,8 +909,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl BigDecimal dailyDisChargeDate = new BigDecimal(0); BigDecimal dailyChargeDate = new BigDecimal(0); - BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN")); - BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN")); + BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN")); + BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN")); // 初始化当日数据 EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); emsDailyChargeData.setSiteId(SITE_ID); @@ -929,19 +929,18 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl if (yestDate == null) { // redis没有这查电表总数据表 yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData); + // 数据存redis-有效期1天 + redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); } if (yestDate != null) { // 今日总数据-昨日总数据=今日充放电 - BigDecimal yestTotalDisChargeDate = yestDate.getCurrentForwardActiveTotal(); - BigDecimal yestTotalChargeDate = yestDate.getCurrentReverseActiveTotal(); + BigDecimal yestTotalDisChargeDate = yestDate.getCurrentReverseActiveTotal(); + BigDecimal yestTotalChargeDate = yestDate.getCurrentForwardActiveTotal(); dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); emsDailyChargeData.setChargeData(dailyChargeDate); emsDailyChargeData.setDischargeData(dailyDisChargeDate); - - // 最新数据存redis - redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); } // 插入或更新每日充放电数据表 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index deefda8..32a9ec8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -68,24 +68,31 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService electricDataInfoVo.setTotalChargedCap(totalCharge); electricDataInfoVo.setEfficiency(efficiency); + String siteId = requestVo.getSiteId(); + String deviceId = requestVo.getDeviceId(); + if ("021_DDS_01".equals(siteId)){ + deviceId = "METE"; + } else if ("021_FXX_01".equals(siteId)){ + deviceId = "LOAD"; + } // 日期筛选 List dataList = new ArrayList(); // 开始日期和结束日期同一天,展示 0-24 小时数据 if (DateUtils.isSameDay(startDate, endDate)){ electricDataInfoVo.setUnit("时"); - endDate = DateUtils.addDays(endDate, 1); - dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate); + //endDate = DateUtils.addDays(endDate, 1); + //dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate); + dataList = emsAmmeterDataMapper.getChargeDataByHour(siteId,deviceId,startDate); } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ electricDataInfoVo.setUnit("日"); - endDate = DateUtils.addDays(endDate, 1); // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 - dataList = emsPcsDataMapper.getPcsDataByDay(requestVo.getSiteId(), startDate, endDate); + //dataList = emsPcsDataMapper.getPcsDataByDay(requestVo.getSiteId(), startDate, endDate); + dataList = emsDailyChargeDataMapper.getTotalChargeDataByDay(siteId,startDate,endDate); } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ electricDataInfoVo.setUnit("月"); - endDate = DateUtils.addDays(endDate, 1); // 开始日期-结束日期大于 1 个月,按月展示数据 - dataList = emsPcsDataMapper.getPcsDataByMonth(requestVo.getSiteId(), startDate, endDate); + dataList = emsAmmeterDataMapper.getChargeDataByMonth(requestVo.getSiteId(),deviceId, startDate, endDate); } // 根据时间获取每天的充放电量 if (!CollectionUtils.isEmpty(dataList)){ diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index fac9e34..12aad12 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -86,7 +86,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return; } - /*if (deviceId.contains("BMSD")) { + if (deviceId.contains("BMSD")) { batteryStackDataProcess(deviceId, jsonData); } else if (deviceId.contains("BMSC")) { @@ -97,11 +97,11 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else if (deviceId.contains("PCS")) { pcsDataProcess(deviceId, jsonData); pcsBranchDataProcess(deviceId, jsonData); - } else*/ if (deviceId.contains("LOAD")) { + } else if (deviceId.contains("LOAD")) { loadDataProcess(deviceId, jsonData); - } /*else if (deviceId.contains("METE")) { + } else if (deviceId.contains("METE")) { meteDataProcess(deviceId, jsonData); - }*/ + } } } @@ -576,8 +576,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl BigDecimal dailyChargeDate = new BigDecimal(0); BigDecimal dailyDisChargeDate = new BigDecimal(0); - BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQZXYGZDN")); - BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQFXYGZDN")); + BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXYGZDN")); + BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXYGZDN")); // 初始化当日数据 EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); emsDailyChargeData.setSiteId(SITE_ID); @@ -596,18 +596,18 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl if (yestDate == null) { // redis没有这查电表总数据表 yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData); + // 数据redis-有效期1天 + redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); } if (yestDate != null) { // 今日总数据-昨日总数据=今日充放电 - BigDecimal yestTotalDisChargeDate = yestDate.getCurrentForwardActiveTotal(); - BigDecimal yestTotalChargeDate = yestDate.getCurrentReverseActiveTotal(); + BigDecimal yestTotalDisChargeDate = yestDate.getCurrentReverseActiveTotal(); + BigDecimal yestTotalChargeDate = yestDate.getCurrentForwardActiveTotal(); dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); emsDailyChargeData.setChargeData(dailyChargeDate); emsDailyChargeData.setDischargeData(dailyDisChargeDate); - // 存下redis-有效期1天 - redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); } // 插入或更新每日充放电数据表 emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index 984aaa0..26e039b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -4,10 +4,7 @@ import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsSiteSetting; import com.xzzn.ems.domain.vo.*; -import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; -import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; -import com.xzzn.ems.mapper.EmsPcsDataMapper; -import com.xzzn.ems.mapper.EmsSiteSettingMapper; +import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsSiteService; import com.xzzn.ems.service.IHomePageService; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +14,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.util.*; +import java.util.stream.Collectors; /** * 首页看板+站点地图 服务层实现 @@ -37,6 +35,8 @@ public class HomePageServiceImpl implements IHomePageService private EmsAlarmRecordsMapper alarmRecordsMapper; @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; + @Autowired + private EmsAmmeterDataMapper emsAmmeterDataMapper; @Override public SiteTotalInfoVo getSiteTotalInfo() { @@ -114,7 +114,8 @@ public class HomePageServiceImpl implements IHomePageService public HomePageDataViewVo getHomePageDataList() { HomePageDataViewVo homePageDataViewVo = new HomePageDataViewVo(); // 电量指标 - List electricDataList = emsPcsDataMapper.getElectDataList(); + //List electricDataList = emsPcsDataMapper.getElectDataList(); + List electricDataList = getElectricDataList(); homePageDataViewVo.setElecDataList(electricDataList); // 系统效率 List systemEfficiencyLists = new ArrayList<>(); @@ -160,6 +161,97 @@ public class HomePageServiceImpl implements IHomePageService return homePageDataViewVo; } + private List getElectricDataList() { + List electricDataList = new ArrayList<>(); + // 获取每个月最早和最晚的时间 + List timeRanges = emsAmmeterDataMapper.getMonthlyTimeRanges(); + if (timeRanges.isEmpty()) { + return Collections.emptyList(); + } + // 遍历收集所有需要查询的时间点(最早+最晚) + List timePointQueries = new ArrayList<>(); + for (MonthlyTimeRange range : timeRanges) { + timePointQueries.add(new TimePointQuery(range.getSiteId(),range.getFirstDataTime())); + timePointQueries.add(new TimePointQuery(range.getSiteId(),range.getLastDataTime())); + } + // 批量获取所有时间点对应的数据值转化为map + List timePointValues = emsAmmeterDataMapper.batchGetTimePointValues(timePointQueries); + Map valueMap = timePointValues.stream() + .collect(Collectors.toMap( + v -> v.getSiteId() + "_" + v.getDataUpdateTime().toString(), + v -> v + )); + // 缓存每个站点的上月最晚电量 key=siteId, value=上月最晚时间对应数据 + Map lastMonthMap = new HashMap<>(); + + // 组装结果-key=统计月,value=统计月的数据 + Map elecDataMap = new HashMap<>(); + for (MonthlyTimeRange timeRange : timeRanges) { + String dataMonth = timeRange.getMonth(); + String siteId = timeRange.getSiteId(); + + BigDecimal totalChargeData = new BigDecimal(0); + BigDecimal totalDisChargeData = new BigDecimal(0); + // 获取本月最晚数据 + TimePointValue monthLastValue = valueMap.get(siteId +"_"+timeRange.getLastDataTime()); + BigDecimal lastChargeValue = new BigDecimal(0); + BigDecimal lastDisChargeValue = new BigDecimal(0); + if (monthLastValue != null) { + lastChargeValue = monthLastValue.getTotalChargeData() == null ? BigDecimal.ZERO : monthLastValue.getTotalChargeData(); + lastDisChargeValue = monthLastValue.getTotalDischargeData() == null ? BigDecimal.ZERO : monthLastValue.getTotalDischargeData(); + + }// 看是否有缓存上个月最晚电量,没有则是首月 + if (!lastMonthMap.containsKey(siteId)) { + // 首月充放电 = 本月最晚数据 - 本月最早数据 + TimePointValue monthFirstValue = valueMap.get(siteId +"_"+timeRange.getFirstDataTime()); + BigDecimal firstChargeValue = new BigDecimal(0); + BigDecimal firstDisChargeValue = new BigDecimal(0); + if (monthLastValue != null) { + firstChargeValue = monthFirstValue.getTotalChargeData() == null ? BigDecimal.ZERO : monthFirstValue.getTotalChargeData(); + firstDisChargeValue = monthFirstValue.getTotalDischargeData() == null ? BigDecimal.ZERO : monthFirstValue.getTotalDischargeData(); + } + totalChargeData = lastChargeValue.subtract(firstChargeValue); + totalDisChargeData = lastDisChargeValue.subtract(firstDisChargeValue); + } else {// 非本月充放电 = 本月最晚数据 - 上月最晚数据 + TimePointValue lastValue = lastMonthMap.get(siteId); + if (lastValue == null) {// 缓存找不到上月数据,则取本月最早数据 + lastValue = valueMap.get(siteId +"_"+timeRange.getFirstDataTime()); + } + BigDecimal lastMonthChargeValue = new BigDecimal(0); + BigDecimal lastMonthDisChargeValue = new BigDecimal(0); + if (lastValue != null) { + lastMonthChargeValue = lastValue.getTotalChargeData() == null ? BigDecimal.ZERO : lastValue.getTotalChargeData(); + lastMonthDisChargeValue = lastValue.getTotalDischargeData() == null ? BigDecimal.ZERO : lastValue.getTotalDischargeData(); + }totalChargeData = lastChargeValue.subtract(lastMonthChargeValue); + totalDisChargeData = lastDisChargeValue.subtract(lastMonthDisChargeValue); + } + // 缓存最晚数据 + lastMonthMap.put(siteId,monthLastValue); + + ElectricIndexList electricIndexList = new ElectricIndexList(); + // 判断map里面是否已经有排序月份 + if (elecDataMap.containsKey(dataMonth)) { + electricIndexList = elecDataMap.get(dataMonth); + totalChargeData = totalChargeData.add(electricIndexList.getChargeEnergy()); + totalDisChargeData = totalDisChargeData.add(electricIndexList.getDisChargeEnergy()); + } + electricIndexList.setDateMonth(dataMonth); + electricIndexList.setChargeEnergy(totalChargeData); + electricIndexList.setDisChargeEnergy(totalDisChargeData); + elecDataMap.put(dataMonth,electricIndexList); + } + + electricDataList = elecDataMap.values().stream().collect(Collectors.toList()); + return electricDataList; + } + // 从timeRangeList中获取指定站点+月份的时间范围 + private MonthlyTimeRange getSiteRangeByMonth(List rangeList, String siteId, String month) { + return rangeList.stream() + .filter(r -> siteId.equals(r.getSiteId()) && month.equals(r.getMonth())) + .findFirst() .orElse(null); + } + + @Override public List getSevenChargeData(DateSearchRequest requestVo) { String siteId = requestVo.getSiteId(); @@ -185,9 +277,6 @@ public class HomePageServiceImpl implements IHomePageService endDate = new Date(); requestVo.setStartDate(startDate); requestVo.setEndDate(endDate); - } else if (endDate != null) { - endDate = DateUtils.addDays(endDate, 1); - requestVo.setEndDate(endDate); } } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index cb665e4..ff90c79 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -891,4 +891,75 @@ and DATE(data_update_time) = #{yestData} order by data_update_time desc limit 1 + + + + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml new file mode 100644 index 0000000..547a525 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + select id, site_id, device_id, date_time, total_charge_Data, total_discharge_Data, charge_data, discharge_data, create_by, create_time, update_by, update_time, remark from ems_daily_charge_data + + + + + + + + insert into ems_daily_charge_data + + site_id, + device_id, + date_time, + total_charge_Data, + total_discharge_Data, + charge_data, + discharge_data, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{siteId}, + #{deviceId}, + #{dateTime}, + #{totalChargeData}, + #{totalDischargeData}, + #{chargeData}, + #{dischargeData}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_daily_charge_data + + site_id = #{siteId}, + device_id = #{deviceId}, + date_time = #{dateTime}, + total_charge_Data = #{totalChargeData}, + total_discharge_Data = #{totalDischargeData}, + charge_data = #{chargeData}, + discharge_data = #{dischargeData}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_daily_charge_data where id = #{id} + + + + delete from ems_daily_charge_data where id in + + #{id} + + + + + INSERT into ems_daily_charge_data ( + id, + site_id, + device_id, + date_time, + total_charge_Data, + total_discharge_Data, + charge_data, + discharge_data, + create_by, + create_time, + update_by, + update_time, + remark + ) values ( + #{id}, + #{siteId}, + #{deviceId}, + #{dateTime}, + #{totalChargeData}, + #{totalDischargeData}, + #{chargeData}, + #{dischargeData}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark} + ) + on duplicate key update + total_charge_Data = #{totalChargeData}, + total_discharge_Data = #{totalDischargeData}, + charge_data = #{chargeData}, + discharge_data = #{dischargeData}, + update_time = NOW() + + + + + + + + \ No newline at end of file -- 2.49.0 From 15e230babb6c945971fcd7ccde1ef7a6c99e6a24 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 1 Sep 2025 16:17:36 +0800 Subject: [PATCH 127/336] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/HomePageServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index 26e039b..03a8a62 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -28,8 +28,6 @@ public class HomePageServiceImpl implements IHomePageService @Autowired private IEmsSiteService emsSiteService; @Autowired - private EmsPcsDataMapper emsPcsDataMapper; - @Autowired private EmsSiteSettingMapper emsSiteMapper; @Autowired private EmsAlarmRecordsMapper alarmRecordsMapper; @@ -240,8 +238,10 @@ public class HomePageServiceImpl implements IHomePageService electricIndexList.setDisChargeEnergy(totalDisChargeData); elecDataMap.put(dataMonth,electricIndexList); } - - electricDataList = elecDataMap.values().stream().collect(Collectors.toList()); + // 按月份升序排序后返回 + electricDataList = elecDataMap.values().stream() + .sorted(Comparator.comparing(ElectricIndexList::getDateMonth)) + .collect(Collectors.toList()); return electricDataList; } // 从timeRangeList中获取指定站点+月份的时间范围 -- 2.49.0 From aa37e2a8816b8ebcf597808b2bb02a408a08db16 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 5 Sep 2025 13:45:39 +0800 Subject: [PATCH 128/336] =?UTF-8?q?=E7=BB=BC=E5=90=88=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsGeneralQueryController.java | 72 +++++ .../com/xzzn/common/enums/DeviceCategory.java | 23 +- .../java/com/xzzn/common/utils/DateUtils.java | 37 +++ .../com/xzzn/ems/domain/EmsPointMatch.java | 117 ++++++++ .../ems/domain/vo/DevicePointDataList.java | 36 +++ .../ems/domain/vo/GeneralQueryDataVo.java | 47 +++ .../ems/domain/vo/GeneralQueryResponse.java | 37 +++ .../xzzn/ems/domain/vo/MonthlyTimeRange.java | 49 +++ .../xzzn/ems/domain/vo/PointNameRequest.java | 82 +++++ .../xzzn/ems/domain/vo/SiteBatteryListVo.java | 27 ++ .../xzzn/ems/domain/vo/TimePointQuery.java | 33 ++ .../xzzn/ems/domain/vo/TimePointValue.java | 48 +++ .../ems/mapper/EmsBatteryDataMonthMapper.java | 4 + .../ems/mapper/EmsDevicesSettingMapper.java | 2 + .../xzzn/ems/mapper/EmsPointMatchMapper.java | 97 ++++++ .../ems/service/IGeneralQueryService.java | 23 ++ .../impl/DDSDataProcessServiceImpl.java | 4 +- .../impl/FXXDataProcessServiceImpl.java | 33 +- .../service/impl/GeneralQueryServiceImpl.java | 284 ++++++++++++++++++ .../service/impl/SingleSiteServiceImpl.java | 19 +- .../mapper/ems/EmsBatteryDataMonthMapper.xml | 9 + .../mapper/ems/EmsDevicesSettingMapper.xml | 4 + .../mapper/ems/EmsPointMatchMapper.xml | 220 ++++++++++++++ 23 files changed, 1300 insertions(+), 7 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/MonthlyTimeRange.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryListVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointQuery.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointValue.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IGeneralQueryService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java new file mode 100644 index 0000000..a0f7a76 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java @@ -0,0 +1,72 @@ +package com.xzzn.web.controller.ems; + +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.ems.domain.vo.*; +import com.xzzn.ems.service.IGeneralQueryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * 综合查询 + * + */ +@RestController +@RequestMapping("/ems/generalQuery") +public class EmsGeneralQueryController extends BaseController{ + + @Autowired + private IGeneralQueryService iGeneralQueryService; + + /** + * 获取设备枚举 + */ + @GetMapping("/getAllDeviceCategory") + public AjaxResult getDeviceCategory() + { + // 获取所有枚举的中文信息 + List deviceCategoryName = new ArrayList<>(); + for (DeviceCategory category : DeviceCategory.values()) { + deviceCategoryName.add(category.getInfo()); + } + return success(deviceCategoryName); + } + + /** + * 点位模糊查询 + */ + @PostMapping("/pointFuzzyQuery") + public AjaxResult pointFuzzyQuery(@RequestBody PointNameRequest request) + { + return success(iGeneralQueryService.getPointNameList(request)); + } + + /** + * 根据点位查询点位数据变化 + */ + @PostMapping("/getPointValueList") + public AjaxResult getPointValueList(@RequestBody PointNameRequest request) + { + List result = new ArrayList<>(); + try { + result = iGeneralQueryService.getPointValueList(request); + } catch (Exception e) { + return error("报错请重试!"); + } + return success(result); + } + + /** + * 获取设备枚举 + */ + @GetMapping("/getAllBatteryIdsBySites/{siteIds}") + public AjaxResult getAllBatteryIdsBySites(@PathVariable String[] siteIds) + { + return success(iGeneralQueryService.getAllBatteryIdsBySites(siteIds)); + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java index 3b48820..6a23611 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java @@ -1,5 +1,8 @@ package com.xzzn.common.enums; +import java.util.HashMap; +import java.util.Map; + /** * device-设备类别 * @@ -13,7 +16,10 @@ public enum DeviceCategory CLUSTER("CLUSTER", "电池簇"), BATTERY("BATTERY", "单体电池"), AMMETER("AMMETER", "电表"), - COOLING("COOLING", "冷液体"); + COOLING("COOLING", "冷却"), + DH("DH", "动环"), + XF("XF", "消防"), + BATTERY_GROUP("BATTERY_GROUP", "电池组"); private final String code; private final String info; @@ -33,4 +39,19 @@ public enum DeviceCategory { return info; } + + // 缓存info与code的映射(优化查询效率) + private static final Map INFO_CODE_MAP = new HashMap<>(); + + // 静态块初始化缓存 + static { + for (DeviceCategory category : DeviceCategory.values()) { + INFO_CODE_MAP.put(category.info, category.code); + } + } + + // 通过info获取code的方法 + public static String getCodeByInfo(String info) { + return INFO_CODE_MAP.get(info); // 从缓存中直接获取,效率高 + } } diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 61d94a2..12c8167 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -32,6 +32,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils public static String YYYYMMDD = "yyyyMMdd"; + public static String YYYY_MM_DD_HH_MM_00 = "yyyy-MM-dd HH:mm:00"; + private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", @@ -252,4 +254,39 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils return time.format(DateTimeFormatter.ofPattern("yyyy-MM")); } + /** + * 增加 LocalDateTime ==> String + */ + public static String convertToString(LocalDateTime time) { + return time.format(DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM_SS)); + } + + /** + * 将输入时间调整到下一分钟的整点(秒数强制为00) + * 例如:2026-09-03 18:34:49 -> 2026-09-03 18:35:00 + * @param timeStr 输入时间字符串(支持yyyy-MM-dd HH:mm:ss格式) + * @return 调整后的时间字符串(yyyy-MM-dd HH:mm:00) + * @throws ParseException 时间格式错误时抛出 + */ + public static String adjustToNextMinute(String timeStr) throws ParseException { + // 1. 解析原始时间(使用包含秒数的格式) + SimpleDateFormat fullFormat = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS); + Date originalDate = fullFormat.parse(timeStr); + + // 2. 使用Calendar调整时间 + Calendar cal = Calendar.getInstance(); + cal.setTime(originalDate); + + // 3. 如果当前秒数大于0,自动进1分钟(否则保持当前分钟) + if (cal.get(Calendar.SECOND) > 0) { + cal.add(Calendar.MINUTE, 1); // 分钟+1 + } + + // 4. 强制设置秒数和毫秒为0 + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + + // 5. 格式化为目标字符串 + return new SimpleDateFormat(YYYY_MM_DD_HH_MM_00).format(cal.getTime()); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java new file mode 100644 index 0000000..afe534b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -0,0 +1,117 @@ +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_point_match + * + * @author xzzn + * @date 2025-09-02 + */ +public class EmsPointMatch extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 设备ID,主键自增长 */ + private Long id; + + /** 点位名称 */ + @Excel(name = "点位名称") + private String pointName; + + /** 点位所在表 */ + @Excel(name = "点位所在表") + private String matchTable; + + /** 点位匹配字段 */ + @Excel(name = "点位匹配字段") + private String matchField; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备类别,例如“STACK/CLUSTER/PCS等” */ + @Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”") + private String deviceCategory; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setPointName(String pointName) + { + this.pointName = pointName; + } + + public String getPointName() + { + return pointName; + } + + public void setMatchTable(String matchTable) + { + this.matchTable = matchTable; + } + + public String getMatchTable() + { + return matchTable; + } + + public void setMatchField(String matchField) + { + this.matchField = matchField; + } + + public String getMatchField() + { + return matchField; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public void setDeviceCategory(String deviceCategory) + { + this.deviceCategory = deviceCategory; + } + + public String getDeviceCategory() + { + return deviceCategory; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("pointName", getPointName()) + .append("matchTable", getMatchTable()) + .append("matchField", getMatchField()) + .append("siteId", getSiteId()) + .append("deviceCategory", getDeviceCategory()) + .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/DevicePointDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java new file mode 100644 index 0000000..d5230b1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java @@ -0,0 +1,36 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; + +/** + * 综合查询返回-设备数据list + */ +public class DevicePointDataList +{ + // 设备id + private String deviceId; + + // 该设备点位数据list + private List pointValueList; + + public DevicePointDataList(String deviceId, List pointValueList) { + this.deviceId = deviceId; + this.pointValueList = pointValueList; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public List getPointValueList() { + return pointValueList; + } + + public void setPointValueList(List pointValueList) { + this.pointValueList = pointValueList; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java new file mode 100644 index 0000000..50c0468 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java @@ -0,0 +1,47 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 综合查询-数据库返回结果 + */ +public class GeneralQueryDataVo { + + // 站点 + private String siteId; + private String deviceId; + private String valueDate; + private Object pointValue; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getValueDate() { + return valueDate; + } + + public void setValueDate(String valueDate) { + this.valueDate = valueDate; + } + + public Object getPointValue() { + return pointValue; + } + + public void setPointValue(Object pointValue) { + this.pointValue = pointValue; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java new file mode 100644 index 0000000..0569696 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java @@ -0,0 +1,37 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; + +/** + * 综合查询结果 + * + */ +public class GeneralQueryResponse { + + // 站点 + private String siteId; + + // 设备数据 + private List deviceList; + + public GeneralQueryResponse(String siteId, List deviceList) { + this.siteId = siteId; + this.deviceList = deviceList; + } + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public List getDeviceList() { + return deviceList; + } + + public void setDeviceList(List deviceList) { + this.deviceList = deviceList; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/MonthlyTimeRange.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/MonthlyTimeRange.java new file mode 100644 index 0000000..675b410 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/MonthlyTimeRange.java @@ -0,0 +1,49 @@ +package com.xzzn.ems.domain.vo; + +import java.time.LocalDateTime; + +/** + * 每月时间范围实体 + */ +public class MonthlyTimeRange { + // 站点ID + private String siteId; + // 月份(YYYY-MM) + private String month; + // 当月最早时间 + private LocalDateTime firstDataTime; + // 当月最晚时间 + private LocalDateTime lastDataTime; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public LocalDateTime getFirstDataTime() { + return firstDataTime; + } + + public void setFirstDataTime(LocalDateTime firstDataTime) { + this.firstDataTime = firstDataTime; + } + + public LocalDateTime getLastDataTime() { + return lastDataTime; + } + + public void setLastDataTime(LocalDateTime lastDataTime) { + this.lastDataTime = lastDataTime; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java new file mode 100644 index 0000000..f7b7470 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java @@ -0,0 +1,82 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; +import java.util.Map; + +/** + * 点位模糊查询入参 + * + */ +public class PointNameRequest { + + private List siteIds; + + private String categoryName; + + private String pointName; + + /** 数据分组 1-分钟 2-小时 3-天 */ + private int dataUnit; + + private String startDate; + + private String endDate; + + private Map> siteDeviceMap; + + public List getSiteIds() { + return siteIds; + } + + public void setSiteIds(List siteIds) { + this.siteIds = siteIds; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public String getPointName() { + return pointName; + } + + public void setPointName(String pointName) { + this.pointName = pointName; + } + + public int getDataUnit() { + return dataUnit; + } + + public void setDataUnit(int dataUnit) { + this.dataUnit = dataUnit; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getEndDate() { + return endDate; + } + + public void setEndDate(String endDate) { + this.endDate = endDate; + } + + public Map> getSiteDeviceMap() { + return siteDeviceMap; + } + + public void setSiteDeviceMap(Map> siteDeviceMap) { + this.siteDeviceMap = siteDeviceMap; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryListVo.java new file mode 100644 index 0000000..94eb5dc --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteBatteryListVo.java @@ -0,0 +1,27 @@ +package com.xzzn.ems.domain.vo; + +/** + * 综合查询-站点下单体电池实际数据 + * + */ +public class SiteBatteryListVo { + /** 站点id */ + private String siteId; + private String deviceId; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointQuery.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointQuery.java new file mode 100644 index 0000000..207d291 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointQuery.java @@ -0,0 +1,33 @@ +package com.xzzn.ems.domain.vo; + +import java.time.LocalDateTime; + +/** + * 时间点参数实体 + */ +public class TimePointQuery { + private String siteId; + // 要查询的时间点 + private LocalDateTime dataTime; + + public TimePointQuery(String siteId, LocalDateTime dataTime) { + this.siteId = siteId; + this.dataTime = dataTime; + } + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public LocalDateTime getDataTime() { + return dataTime; + } + + public void setDataTime(LocalDateTime dataTime) { + this.dataTime = dataTime; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointValue.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointValue.java new file mode 100644 index 0000000..95c75f5 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/TimePointValue.java @@ -0,0 +1,48 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 时间点-总充放电数据 + */ +public class TimePointValue { + private String siteId; + private LocalDateTime dataUpdateTime; + // 总充电量 + private BigDecimal totalChargeData; + // 总放电量 + private BigDecimal totalDischargeData; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public LocalDateTime getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(LocalDateTime dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + + public BigDecimal getTotalChargeData() { + return totalChargeData; + } + + public void setTotalChargeData(BigDecimal totalChargeData) { + this.totalChargeData = totalChargeData; + } + + public BigDecimal getTotalDischargeData() { + return totalDischargeData; + } + + public void setTotalDischargeData(BigDecimal totalDischargeData) { + this.totalDischargeData = totalDischargeData; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java index cc5784e..56cf737 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMonthMapper.java @@ -4,6 +4,7 @@ import java.time.LocalDateTime; import java.util.List; import com.xzzn.ems.domain.EmsBatteryDataMonth; +import com.xzzn.ems.domain.vo.SiteBatteryListVo; import org.apache.ibatis.annotations.Param; /** @@ -69,4 +70,7 @@ public interface EmsBatteryDataMonthMapper * 批量插入或更新月级数据(存在则更新,不存在则插入) */ void batchInsertOrUpdate(@Param("list") List monthDataList); + + // 查找siteId下面所有的单体电池编码 + public List getAllBatteryIdsBySites(@Param("siteIds")String[] siteIds); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 1f451de..29e851e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -87,4 +87,6 @@ public interface EmsDevicesSettingMapper public List> getClusterIdsByFuzzyQuery(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("parentId")String parentId); + + public List getDeviceIdsBySiteIdAndCategory(@Param("siteId")String siteId,@Param("deviceCategory")String deviceCategory); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java new file mode 100644 index 0000000..01ee073 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -0,0 +1,97 @@ +package com.xzzn.ems.mapper; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.GeneralQueryDataVo; +import org.apache.ibatis.annotations.Param; + +/** + * 点位匹配Mapper接口 + * + * @author xzzn + * @date 2025-09-02 + */ +public interface EmsPointMatchMapper +{ + /** + * 查询点位匹配 + * + * @param id 点位匹配主键 + * @return 点位匹配 + */ + public EmsPointMatch selectEmsPointMatchById(Long id); + + /** + * 查询点位匹配列表 + * + * @param emsPointMatch 点位匹配 + * @return 点位匹配集合 + */ + public List selectEmsPointMatchList(EmsPointMatch emsPointMatch); + + /** + * 新增点位匹配 + * + * @param emsPointMatch 点位匹配 + * @return 结果 + */ + public int insertEmsPointMatch(EmsPointMatch emsPointMatch); + + /** + * 修改点位匹配 + * + * @param emsPointMatch 点位匹配 + * @return 结果 + */ + public int updateEmsPointMatch(EmsPointMatch emsPointMatch); + + /** + * 删除点位匹配 + * + * @param id 点位匹配主键 + * @return 结果 + */ + public int deleteEmsPointMatchById(Long id); + + /** + * 批量删除点位匹配 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsPointMatchByIds(Long[] ids); + + // 模糊查询所有点位 + public List getPointNameList(@Param("siteIds") List siteIds, + @Param("deviceCategory")String deviceCategory, + @Param("pointName") String pointName); + + // 获取匹配信息 + public List getMatchInfo(@Param("siteIds") List siteIds, + @Param("deviceCategory")String deviceCategory, + @Param("pointName") String pointName); + // 根据条件查询数据-按分钟 + public List getPointDataListByMinutes(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate")Date startDate, + @Param("endDate")Date endDate, + @Param("params") Map> params); + // 根据条件查询数据-按小时 + public List getPointDataListByHours(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate") Date startDate, + @Param("endDate")Date endDate, + @Param("params") Map> params); + // 根据条件查询数据-按天 + public List getPointDataListByDays(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate")Date startDate, + @Param("endDate")Date endDate, + @Param("params") Map> params); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IGeneralQueryService.java b/ems-system/src/main/java/com/xzzn/ems/service/IGeneralQueryService.java new file mode 100644 index 0000000..325993f --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IGeneralQueryService.java @@ -0,0 +1,23 @@ +package com.xzzn.ems.service; + +import com.xzzn.ems.domain.vo.*; + +import java.util.List; +import java.util.Map; + +/** + * 综合查询 服务层 + * + */ +public interface IGeneralQueryService +{ + + // 模糊查询获取点位名称List + public List getPointNameList(PointNameRequest request); + + // 根据条件获取点位数据变化 + public List getPointValueList(PointNameRequest request); + + // 根据siteId获取下面对应的单体电池编号 + public Map> getAllBatteryIdsBySites(String[] siteIds); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 97c31cd..05cf43a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -112,11 +112,11 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else if (deviceId.contains("XF")) { meteXFProcess(deviceId, jsonData); } else if (deviceId.contains("DH")) { - meteDHProcess(deviceId, jsonData); + dhDataProcess(deviceId, jsonData); } } - private void meteDHProcess(String deviceId, String dataJson) { + private void dhDataProcess(String deviceId, String dataJson) { //动环 Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 12aad12..e988941 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -64,6 +64,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; + @Autowired + private EmsDhDataMapper emsDhDataMapper; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -99,12 +101,36 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl pcsBranchDataProcess(deviceId, jsonData); } else if (deviceId.contains("LOAD")) { loadDataProcess(deviceId, jsonData); - } else if (deviceId.contains("METE")) { + } else if (deviceId.contains("METE")) { meteDataProcess(deviceId, jsonData); + } else if (deviceId.contains("donghuan")) { + dhDataProcess(deviceId, jsonData); } } } + private void dhDataProcess(String deviceId, String dataJson) { + //动环 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + //DH + EmsDhData dhData = new EmsDhData(); + + dhData.setHumidity(StringUtils.getBigDecimal(obj.get("SD3"))); + dhData.setTemperature(StringUtils.getBigDecimal(obj.get("WD3"))); + + dhData.setCreateBy("system"); + dhData.setCreateTime(DateUtils.getNowDate()); + dhData.setUpdateBy("system"); + dhData.setUpdateTime(DateUtils.getNowDate()); + dhData.setSiteId(SITE_ID); + dhData.setDeviceId(deviceId); + emsDhDataMapper.insertEmsDhData(dhData); + + redisCache.setCacheObject(RedisKeyConstants.DH + SITE_ID + "_" +deviceId, dhData); + } + private void batteryStackDataProcess(String deviceId, String dataJson) { //电池堆 @@ -433,6 +459,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsPcsBranchData data = new EmsPcsBranchData(); data.setDeviceId(deviceId); + data.setSiteId(SITE_ID); data.setGridStatus(GridStatus.GRID.getCode()); data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); @@ -457,6 +484,10 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); data.setBranchId(recordId); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); list.add(data); } if (list.size() > 0 ) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java new file mode 100644 index 0000000..5d4d46d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -0,0 +1,284 @@ +package com.xzzn.ems.service.impl; + +import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.*; +import com.xzzn.ems.mapper.EmsBatteryDataMonthMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsPointMatchMapper; +import com.xzzn.ems.service.IGeneralQueryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.temporal.TemporalAdjusters; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 综合查询 服务层实现 + * + */ +@Service +public class GeneralQueryServiceImpl implements IGeneralQueryService +{ + private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:00"); + + @Autowired + private EmsPointMatchMapper emsPointMatchMapper; + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; + @Autowired + private EmsBatteryDataMonthMapper emsBatteryDataMonthMapper; + + @Override + public List getPointNameList(PointNameRequest request) { + List siteIds = request.getSiteIds(); + if (siteIds == null || siteIds.isEmpty()) { + return Collections.emptyList(); + } + + String categoryName = request.getCategoryName(); + String deviceCategory = DeviceCategory.getCodeByInfo(categoryName); + if (deviceCategory == null) { + return Collections.emptyList(); + } + + return emsPointMatchMapper.getPointNameList(siteIds,deviceCategory,request.getPointName()); + } + + @Override + public Map> getAllBatteryIdsBySites(String[] siteIds) { + Map> resultMap = new HashMap<>(); + if (siteIds == null || siteIds.length == 0) { + return resultMap; + } + List siteBatteryListVos = emsBatteryDataMonthMapper.getAllBatteryIdsBySites(siteIds); + resultMap = convertToMap(siteBatteryListVos); + return resultMap; + } + + public static Map> convertToMap(List siteDeviceList) { + Map> resultMap = new HashMap<>(); + + for (SiteBatteryListVo item : siteDeviceList) { + String siteId = item.getSiteId (); + String deviceId = item.getDeviceId (); + if (!resultMap.containsKey (siteId)) { + resultMap.put (siteId, new ArrayList<>()); + } + resultMap.get (siteId).add (deviceId); + } + + return resultMap; + } + + @Override + public List getPointValueList(PointNameRequest request){ + List result = new ArrayList<>(); + List querySiteIds = new ArrayList<>(); + + List siteIds = request.getSiteIds(); + String categoryName = request.getCategoryName(); + String deviceCategory = DeviceCategory.getCodeByInfo(categoryName); + // 根据入参获取点位对应的表和字段 + List matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceCategory,request.getPointName()); + if (matchInfo == null || matchInfo.size() == 0) { + return result; + } else { + for (EmsPointMatch emsPointMatch : matchInfo) { + querySiteIds.add(emsPointMatch.getSiteId()); + } + } + + Map> siteDeviceMap = request.getSiteDeviceMap(); + if (DeviceCategory.BATTERY.getCode().equals(deviceCategory) && (siteDeviceMap == null || siteDeviceMap.size() == 0)) { + return result; + } + + // 处理时间范围,如果未传根据单位设默认值 + dealDataTime(request); + + int dataUnit = request.getDataUnit(); + Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate()); + Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate()); + try { + // 不同的site_id根据设备类型和字段,默认取第一个匹配到的表和表字段只会有一个, + String tableName = matchInfo.get(0).getMatchTable(); + String tableField = matchInfo.get(0).getMatchField(); + List dataVoList = new ArrayList<>(); + if (dataUnit == 1) { // 分钟 + dataVoList = emsPointMatchMapper.getPointDataListByMinutes(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + if (dataVoList != null && dataVoList.size() > 0) { + dataVoList = dealWithMinutesData(querySiteIds,dataVoList,deviceCategory, + request.getStartDate(),request.getEndDate(),siteDeviceMap); + } + } else if (dataUnit == 2) { // 小时 + if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { + // 单体电池特殊处理,已经提前按小时分表 + tableName = "ems_battery_data_hour"; + } + dataVoList = emsPointMatchMapper.getPointDataListByHours(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + } else if (dataUnit == 3) { // 天 + if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { + tableName = "ems_battery_data_day"; + } + dataVoList = emsPointMatchMapper.getPointDataListByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + } + + // 数据转换: 先按siteId分组,再按deviceId分组 + result = dataVoList.stream() + // 第一层分组:按siteId分组,得到 + .collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId)) + .entrySet().stream() + .map(siteEntry -> { + String siteId = siteEntry.getKey(); + List siteAllData = siteEntry.getValue(); + + // 第二层分组:在当前站点下,按deviceId分组,得到 + List deviceList = siteAllData.stream() + .collect(Collectors.groupingBy(GeneralQueryDataVo::getDeviceId)) + .entrySet().stream() + .map(deviceEntry -> new DevicePointDataList( + deviceEntry.getKey(), + deviceEntry.getValue() + )) + .collect(Collectors.toList()); + + return new GeneralQueryResponse(siteId, deviceList); + }) + .collect(Collectors.toList()); + } catch (ParseException e) { + throw new RuntimeException(e); + } + return result; + } + + private void dealDataTime(PointNameRequest request) { + String startDate = request.getStartDate(); + String endDate = request.getEndDate(); + int dataUnit = request.getDataUnit(); + if (startDate == null || endDate == null) { + // 前端未传递时,根据dataunit设置默认时间范围 + LocalDateTime now = LocalDateTime.now(); + LocalDateTime start; + LocalDateTime end; + switch (dataUnit) { + case 1: // 按分钟 - 前一小时 + end = now; + start = now.minusHours(1); + break; + case 2: // 按小时 - 当天 + end = now.with(LocalTime.MAX); + start = now.with(LocalTime.MIN); + break; + case 3: // 按天 - 当月 + end = now.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX); + start = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN); + break; + default: + throw new IllegalArgumentException("无效的dataunit值: " + dataUnit); + } + // 格式化为字符串(与前端传递的格式一致) + startDate = DateUtils.convertToString(start); + endDate = DateUtils.convertToString(end); + } + request.setStartDate(startDate); + request.setEndDate(endDate); + } + + private List dealWithMinutesData(List querySiteIds, List dataVoList, + String deviceCategory, String startDate, String endDate, Map> siteDeviceMap) throws ParseException { + List fullData = new ArrayList<>(); + Map dataMap = new HashMap<>(); + for (GeneralQueryDataVo data : dataVoList) { + String key = data.getSiteId() + "_" + data.getDeviceId() + "_" + data.getValueDate(); + dataMap.put(key, data); + } + // 生成分钟序列 + Set minuteSeries = generateMinuteSeries(startDate, endDate); + // 遍历每个站点,动态获取该站点下的所有设备 + for (String siteId : querySiteIds) { + List deviceIds = new ArrayList<>(); + // 单体电池deviceId特殊处理 + if (DeviceCategory.BATTERY.getCode().equals(deviceCategory) && (siteDeviceMap != null || siteDeviceMap.size() > 0)) { + deviceIds = siteDeviceMap.get(siteId); + } else { + deviceIds = emsDevicesSettingMapper.getDeviceIdsBySiteIdAndCategory(siteId,deviceCategory); + } + if (deviceIds.isEmpty()) { + continue; // 跳过无设备的站点 + } + + // 处理该站点下的所有设备 + for (String deviceId : deviceIds) { + Object lastValue = null; + + for (String minute : minuteSeries) { + String dataKey = siteId + "_" + deviceId + "_" + minute; + GeneralQueryDataVo data = dataMap.get(dataKey); + + // 空值填充逻辑 + if (data == null) { + data = new GeneralQueryDataVo(); + data.setValueDate(minute); + data.setSiteId(siteId); + data.setDeviceId(deviceId); + data.setPointValue(lastValue); // 用上一分钟值填充 + } else { + lastValue = data.getPointValue(); // 更新最新值 + } + + fullData.add(data); + } + } + } + + fullData.sort(Comparator.comparing(GeneralQueryDataVo::getValueDate) + .thenComparing(GeneralQueryDataVo::getSiteId) + .thenComparing(GeneralQueryDataVo::getDeviceId)); + + return fullData; + } + + /** + * 根据前端传递的startDate和endDate生成所有分钟点的序列 + * @param startDate 起始时间(格式:yyyy-MM-dd HH:mm:00) + * @param endDate 结束时间(格式:yyyy-MM-dd HH:mm:00) + * @return 包含所有分钟点的有序集合 + * @throws ParseException 时间格式解析失败时抛出 + */ + private Set generateMinuteSeries(String startDate, String endDate) throws ParseException { + Set minutes = new TreeSet<>(); // TreeSet保证时间有序 + + // 解析起止时间 + startDate = DateUtils.adjustToNextMinute(startDate); + Date startTime = TIME_FORMAT.parse(startDate.substring(0, 16) + ":00"); + Date endTime = TIME_FORMAT.parse(endDate.substring(0, 16) + ":00"); + + // 验证时间有效性 + if (startTime.after(endTime)) { + throw new IllegalArgumentException("起始时间不能晚于结束时间"); + } + + // 初始化日历对象,从起始时间开始 + Calendar cal = Calendar.getInstance(); + cal.setTime(startTime); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + + // 循环生成从startDate到endDate的所有分钟点 + while (!cal.getTime().after(endTime)) { + // 添加当前分钟(格式:yyyy-MM-dd HH:mm:00) + minutes.add(TIME_FORMAT.format(cal.getTime())); + // 递增1分钟 + cal.add(Calendar.MINUTE, 1); + } + + return minutes; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index e518c70..3084a11 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -17,6 +17,8 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.*; import java.util.stream.Collectors; @@ -75,7 +77,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (dataMap != null) { siteMonitorHomeVo.setTotalChargedCap(dataMap.get("totalChargedCap")); siteMonitorHomeVo.setTotalDischargedCap(dataMap.get("totalDischargedCap")); - siteMonitorHomeVo.setGridNrtPower(dataMap.get("gridNrtPower")); + //siteMonitorHomeVo.setGridNrtPower(dataMap.get("gridNrtPower")); } // 实时告警数据 名称+状态+告警内容 List siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId); @@ -121,9 +123,20 @@ public class SingleSiteServiceImpl implements ISingleSiteService { SiteMonitorRunningHeadInfoVo siteMonitorRunningHeadInfoVo = new SiteMonitorRunningHeadInfoVo(); if (!StringUtils.isEmpty(siteId)) { - // 实时有功功率/实时无功功率/今日充电量/今日放电量 + // 实时有功功率/实时无功功率 SiteMonitorRunningHeadInfoVo tempVo = emsPcsDataMapper.getSiteRunningHeadInfo(siteId); - siteMonitorRunningHeadInfoVo = tempVo != null ? tempVo : siteMonitorRunningHeadInfoVo; + siteMonitorRunningHeadInfoVo.setTotalActivePower(tempVo.getTotalActivePower()); + siteMonitorRunningHeadInfoVo.setTotalReactivePower(tempVo.getTotalReactivePower()); + // 今日充放电 + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startOfDay = now.with(LocalTime.MIN); + Date startDate = DateUtils.toDate(startOfDay); + Date endDate = new Date(); + List siteMonitorDataVoList = emsDailyChargeDataMapper.getSingleSiteChargeData(siteId,startDate,endDate); + if (siteMonitorDataVoList != null && siteMonitorDataVoList.size() > 0) { + siteMonitorRunningHeadInfoVo.setDayChargedCap(siteMonitorDataVoList.get(0).getChargedCap()); + siteMonitorRunningHeadInfoVo.setDayDisChargedCap(siteMonitorDataVoList.get(0).getDisChargedCap()); + } // 电池堆SOC + 电池堆SOH EmsBatteryStack emsBatteryStack = emsBatteryStackMapper.getSiteSumStackInfo(siteId); if (emsBatteryStack != null) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml index 4d066dd..0ef37df 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMonthMapper.xml @@ -199,4 +199,13 @@ update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by), temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index fd7bb73..38cb326 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -210,4 +210,8 @@ and device_category = #{deviceCategory} + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml new file mode 100644 index 0000000..2f21263 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + select id, point_name, match_table, match_field, site_id, device_category, create_by, create_time, update_by, update_time, remark from ems_point_match + + + + + + + + insert into ems_point_match + + point_name, + match_table, + match_field, + site_id, + device_category, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{pointName}, + #{matchTable}, + #{matchField}, + #{siteId}, + #{deviceCategory}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_point_match + + point_name = #{pointName}, + match_table = #{matchTable}, + match_field = #{matchField}, + site_id = #{siteId}, + device_category = #{deviceCategory}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_point_match where id = #{id} + + + + delete from ems_point_match where id in + + #{id} + + + + + + + + + + + AND ( + + ( site_id = #{siteId} + AND device_id IN + + #{deviceId} + + ) + + + ) + + + AND site_id IN + + #{siteId} + + + + + + + + + + + \ No newline at end of file -- 2.49.0 From 2344cc458c15c5653174563246fc56927f248a2b Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 5 Sep 2025 20:31:30 +0800 Subject: [PATCH 129/336] =?UTF-8?q?=E7=BB=BC=E5=90=88=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/utils/DateUtils.java | 59 ++++ .../ems/domain/vo/DevicePointDataList.java | 15 +- .../ems/domain/vo/GeneralQueryDataVo.java | 9 + .../ems/domain/vo/GeneralQueryResponse.java | 4 + .../xzzn/ems/mapper/EmsPointMatchMapper.java | 33 ++- .../service/impl/GeneralQueryServiceImpl.java | 278 ++++++++++++++---- .../mapper/ems/EmsPointMatchMapper.xml | 110 +++++-- 7 files changed, 423 insertions(+), 85 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 12c8167..cfc07e2 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -11,6 +11,8 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; +import java.util.TimeZone; + import org.apache.commons.lang3.time.DateFormatUtils; /** @@ -34,6 +36,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils public static String YYYY_MM_DD_HH_MM_00 = "yyyy-MM-dd HH:mm:00"; + private static final DateTimeFormatter DAY_INPUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private static final DateTimeFormatter MIN_HOUR_INPUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", @@ -289,4 +294,58 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils // 5. 格式化为目标字符串 return new SimpleDateFormat(YYYY_MM_DD_HH_MM_00).format(cal.getTime()); } + + /** + * 将"yyyy-MM-dd"字符串转换为Date类型的"yyyy-MM-dd 23:59:59" + */ + public static Date adjustToEndOfDay(String dateStr) { + // 1. 解析字符串为LocalDate(仅日期) + LocalDate localDate = LocalDate.parse(dateStr, DAY_INPUT_FORMATTER); + + // 2. 补充时间为23:59:59,转换为LocalDateTime + LocalDateTime localDateTime = localDate.atTime(23, 59, 59); + + // 3. 转换为Date类型(兼容旧API) + return Date.from( + localDateTime.atZone(TimeZone.getDefault().toZoneId()) // 适配系统时区 + .toInstant() + ); + } + + /** + * 将 "yyyy-MM-dd HH:mm:ss" 字符串转换为Date类型的"yyyy-MM-dd HH:00:00" + */ + public static Date adjustToStartOfHour(String inputTime) { + // 1. 解析输入字符串为LocalDateTime(包含日期和小时、分钟) + LocalDateTime inputLdt = LocalDateTime.parse(inputTime, MIN_HOUR_INPUT_FORMATTER); + + // 2. 调整分钟为00,秒为00(保留日期和小时不变) + LocalDateTime adjustedLdt = inputLdt + .withMinute(00) // 强制设为00分 + .withSecond(00); // 强制设为00秒 + + // 3. 转换为Date类型(适配旧API) + return Date.from( + adjustedLdt.atZone(TimeZone.getDefault().toZoneId()) // 适配系统时区 + .toInstant() + ); + } + + /** + * 将 "yyyy-MM-dd HH:mm:ss" 字符串转换为Date类型的"yyyy-MM-dd HH:mm:00" + */ + public static Date adjustToStartOfMinutes(String inputTime) { + // 1. 解析输入字符串为LocalDateTime(包含日期和小时、分钟) + LocalDateTime inputLdt = LocalDateTime.parse(inputTime, MIN_HOUR_INPUT_FORMATTER); + + // 2. 调整分钟为00,秒为00(保留日期和小时不变) + LocalDateTime adjustedLdt = inputLdt + .withSecond(00); // 强制设为00秒 + + // 3. 转换为Date类型(适配旧API) + return Date.from( + adjustedLdt.atZone(TimeZone.getDefault().toZoneId()) // 适配系统时区 + .toInstant() + ); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java index d5230b1..90526b5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java @@ -9,7 +9,8 @@ public class DevicePointDataList { // 设备id private String deviceId; - + // 父类设备id + private String parentDeviceId; // 该设备点位数据list private List pointValueList; @@ -18,6 +19,10 @@ public class DevicePointDataList this.pointValueList = pointValueList; } + public DevicePointDataList() { + + } + public String getDeviceId() { return deviceId; } @@ -33,4 +38,12 @@ public class DevicePointDataList public void setPointValueList(List pointValueList) { this.pointValueList = pointValueList; } + + public String getParentDeviceId() { + return parentDeviceId; + } + + public void setParentDeviceId(String parentDeviceId) { + this.parentDeviceId = parentDeviceId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java index 50c0468..81d67ff 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java @@ -12,6 +12,7 @@ public class GeneralQueryDataVo { private String deviceId; private String valueDate; private Object pointValue; + private String parentDeviceId; public String getSiteId() { return siteId; @@ -44,4 +45,12 @@ public class GeneralQueryDataVo { public void setPointValue(Object pointValue) { this.pointValue = pointValue; } + + public String getParentDeviceId() { + return parentDeviceId; + } + + public void setParentDeviceId(String parentDeviceId) { + this.parentDeviceId = parentDeviceId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java index 0569696..a4e8248 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java @@ -19,6 +19,10 @@ public class GeneralQueryResponse { this.deviceList = deviceList; } + public GeneralQueryResponse() { + + } + public String getSiteId() { return siteId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 01ee073..818acb3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -73,25 +73,44 @@ public interface EmsPointMatchMapper public List getMatchInfo(@Param("siteIds") List siteIds, @Param("deviceCategory")String deviceCategory, @Param("pointName") String pointName); - // 根据条件查询数据-按分钟 - public List getPointDataListByMinutes(@Param("siteIds")List siteIds, + // 根据条件查询数据-按分钟-单体电池特殊处理 + public List getBatteryPointDataByMinutes(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate")Date startDate, @Param("endDate")Date endDate, @Param("params") Map> params); - // 根据条件查询数据-按小时 - public List getPointDataListByHours(@Param("siteIds")List siteIds, + // 根据条件查询数据-按小时-单体电池特殊处理 + public List getBatteryPointDataByHours(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate") Date startDate, @Param("endDate")Date endDate, @Param("params") Map> params); - // 根据条件查询数据-按天 - public List getPointDataListByDays(@Param("siteIds")List siteIds, + // 根据条件查询数据-按天-单体电池特殊处理 + public List getBatteryPointDataByDays(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate")Date startDate, @Param("endDate")Date endDate, - @Param("params") Map> params); + @Param("params") Map> params); + + // 根据条件查询数据-按分钟-其他设备 + public List getCommonPointDataByMinutes(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate")Date startDate, + @Param("endDate")Date endDate); + // 根据条件查询数据-按小时-其他设备 + public List getCommonPointDataByHours(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate") Date startDate, + @Param("endDate")Date endDate); + // 根据条件查询数据-按天-其他设备 + public List getCommonPointDataByDays(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate")Date startDate, + @Param("endDate")Date endDate); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index 5d4d46d..78bf576 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -95,69 +95,175 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService } } + // 单体电池特殊校验 Map> siteDeviceMap = request.getSiteDeviceMap(); if (DeviceCategory.BATTERY.getCode().equals(deviceCategory) && (siteDeviceMap == null || siteDeviceMap.size() == 0)) { return result; } - // 处理时间范围,如果未传根据单位设默认值 + // 处理时间范围,如果未传根据数据单位设默认值 dealDataTime(request); - int dataUnit = request.getDataUnit(); - Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate()); - Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate()); try { // 不同的site_id根据设备类型和字段,默认取第一个匹配到的表和表字段只会有一个, String tableName = matchInfo.get(0).getMatchTable(); String tableField = matchInfo.get(0).getMatchField(); - List dataVoList = new ArrayList<>(); - if (dataUnit == 1) { // 分钟 - dataVoList = emsPointMatchMapper.getPointDataListByMinutes(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); - if (dataVoList != null && dataVoList.size() > 0) { - dataVoList = dealWithMinutesData(querySiteIds,dataVoList,deviceCategory, - request.getStartDate(),request.getEndDate(),siteDeviceMap); - } - } else if (dataUnit == 2) { // 小时 - if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { - // 单体电池特殊处理,已经提前按小时分表 - tableName = "ems_battery_data_hour"; - } - dataVoList = emsPointMatchMapper.getPointDataListByHours(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); - } else if (dataUnit == 3) { // 天 - if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { - tableName = "ems_battery_data_day"; - } - dataVoList = emsPointMatchMapper.getPointDataListByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + + if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { + // 单体电池数据特殊处理 + result = generalQueryBatteryData(querySiteIds,tableName,tableField,request,deviceCategory); + } else { + // 其他设备数据 + result = generalQueryCommonData(querySiteIds,tableName,tableField,request,deviceCategory); } - - // 数据转换: 先按siteId分组,再按deviceId分组 - result = dataVoList.stream() - // 第一层分组:按siteId分组,得到 - .collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId)) - .entrySet().stream() - .map(siteEntry -> { - String siteId = siteEntry.getKey(); - List siteAllData = siteEntry.getValue(); - - // 第二层分组:在当前站点下,按deviceId分组,得到 - List deviceList = siteAllData.stream() - .collect(Collectors.groupingBy(GeneralQueryDataVo::getDeviceId)) - .entrySet().stream() - .map(deviceEntry -> new DevicePointDataList( - deviceEntry.getKey(), - deviceEntry.getValue() - )) - .collect(Collectors.toList()); - - return new GeneralQueryResponse(siteId, deviceList); - }) - .collect(Collectors.toList()); } catch (ParseException e) { throw new RuntimeException(e); } return result; } + private List generalQueryCommonData(List querySiteIds,String tableName, + String tableField, PointNameRequest request, + String deviceCategory) throws ParseException { + List result = new ArrayList<>(); + List dataVoList = new ArrayList<>(); + + int dataUnit = request.getDataUnit(); + Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate()); + Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate()); + if (dataUnit == 1) { // 分钟:yyyy-MM-dd HH:mm:ss + startDate = DateUtils.adjustToStartOfMinutes(request.getStartDate()); + dataVoList = emsPointMatchMapper.getCommonPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate); + if (dataVoList != null && dataVoList.size() > 0) { + dataVoList = dealWithMinutesData(querySiteIds,dataVoList,deviceCategory, + request.getStartDate(),request.getEndDate()); + } + } else if (dataUnit == 2) { // 小时:yyyy-MM-dd HH:mm:ss + dataVoList = emsPointMatchMapper.getCommonPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate); + } else if (dataUnit == 3) { // 天:yyyy-MM-dd 00:00:00 + endDate = DateUtils.adjustToEndOfDay(request.getEndDate()); + dataVoList = emsPointMatchMapper.getCommonPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate); + } + + // 数据转换 + result = convertCommonToResultList(dataVoList); + return result; + } + + private List generalQueryBatteryData(List querySiteIds,String tableName, + String tableField, PointNameRequest request, + String deviceCategory) throws ParseException { + List result = new ArrayList<>(); + List dataVoList = new ArrayList<>(); + + int dataUnit = request.getDataUnit(); + Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate()); + Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate()); + Map> siteDeviceMap = request.getSiteDeviceMap(); + if (dataUnit == 1) { // 分钟 + startDate = DateUtils.adjustToStartOfMinutes(request.getStartDate()); + dataVoList = emsPointMatchMapper.getBatteryPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + if (dataVoList != null && dataVoList.size() > 0) { + dataVoList = dealWithBatteryMinutesData(querySiteIds,dataVoList,deviceCategory, + request.getStartDate(),request.getEndDate(),siteDeviceMap); + } + } else if (dataUnit == 2) { // 小时 + startDate = DateUtils.adjustToStartOfHour(request.getStartDate()); + tableName = "ems_battery_data_hour"; + dataVoList = emsPointMatchMapper.getBatteryPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + } else if (dataUnit == 3) { // 天 + endDate = DateUtils.adjustToEndOfDay(request.getEndDate()); + tableName = "ems_battery_data_day"; + dataVoList = emsPointMatchMapper.getBatteryPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + } + // 数据转换 + result = convertBatteryToResultList(dataVoList); + return result; + } + + private List convertBatteryToResultList(List dataVoList) { + // 先按siteId分组 + return dataVoList.stream() + .collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId)) + .entrySet().stream() + .map(siteEntry -> { + String siteId = siteEntry.getKey(); + List siteData = siteEntry.getValue(); + + // 2. 按(deviceId + parentDeviceId)组合分组,生成deviceList + List deviceList = siteData.stream() + // 分组键:deviceId + parentDeviceId(确保唯一设备) + .collect(Collectors.groupingBy(data -> + data.getDeviceId() + "_" + data.getParentDeviceId() + )) + .entrySet().stream() + .map(deviceEntry -> { + // 解析分组键,获取deviceId和parentDeviceId + String[] keyParts = deviceEntry.getKey().split("_"); + String deviceId = keyParts[0]; + String parentDeviceId = keyParts[1]; + + // 3. 转换为PointValue列表 + List pointValueList = deviceEntry.getValue().stream() + .map(data -> { + GeneralQueryDataVo pv = new GeneralQueryDataVo(); + pv.setSiteId(siteId); + pv.setDeviceId(deviceId); + pv.setValueDate(data.getValueDate()); + pv.setPointValue(data.getPointValue()); + pv.setParentDeviceId(parentDeviceId); + return pv; + }) + .collect(Collectors.toList()); + + // 4. 构建DeviceItem + DevicePointDataList deviceItem = new DevicePointDataList(); + deviceItem.setDeviceId(deviceId); + deviceItem.setParentDeviceId(parentDeviceId); + deviceItem.setPointValueList(pointValueList); + return deviceItem; + })// 关键排序步骤:先按deviceId升序,再按parentDeviceId升序 + .sorted( + Comparator.comparing(DevicePointDataList::getDeviceId) // 第一排序键:deviceId + .thenComparing(DevicePointDataList::getParentDeviceId) // 第二排序键:parentDeviceId + ) + .collect(Collectors.toList()); + + // 5. 构建SiteData + GeneralQueryResponse site = new GeneralQueryResponse(); + site.setSiteId(siteId); + site.setDeviceList(deviceList); + return site; + }) + .collect(Collectors.toList()); + } + + private List convertCommonToResultList(List dataVoList) { + // 数据转换: 先按siteId分组,再按deviceId分组 + return dataVoList.stream() + // 第一层分组:按siteId分组,得到 + .collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId)) + .entrySet().stream() + .map(siteEntry -> { + String siteId = siteEntry.getKey(); + List siteAllData = siteEntry.getValue(); + + // 第二层分组:在当前站点下,按deviceId分组,得到 + List deviceList = siteAllData.stream() + .collect(Collectors.groupingBy(GeneralQueryDataVo::getDeviceId)) + .entrySet().stream() + .map(deviceEntry -> new DevicePointDataList( + deviceEntry.getKey(), + deviceEntry.getValue() + )) + .collect(Collectors.toList()); + + return new GeneralQueryResponse(siteId, deviceList); + }) + .collect(Collectors.toList()); + + } + private void dealDataTime(PointNameRequest request) { String startDate = request.getStartDate(); String endDate = request.getEndDate(); @@ -192,28 +298,22 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService } private List dealWithMinutesData(List querySiteIds, List dataVoList, - String deviceCategory, String startDate, String endDate, Map> siteDeviceMap) throws ParseException { + String deviceCategory, String startDate, String endDate) throws ParseException { List fullData = new ArrayList<>(); Map dataMap = new HashMap<>(); + List deviceIds = new ArrayList<>(); for (GeneralQueryDataVo data : dataVoList) { String key = data.getSiteId() + "_" + data.getDeviceId() + "_" + data.getValueDate(); dataMap.put(key, data); + + if (!deviceIds.contains(data.getDeviceId())) { + deviceIds.add(data.getDeviceId()); + } } // 生成分钟序列 Set minuteSeries = generateMinuteSeries(startDate, endDate); - // 遍历每个站点,动态获取该站点下的所有设备 + // 遍历每个站点,查看设备 for (String siteId : querySiteIds) { - List deviceIds = new ArrayList<>(); - // 单体电池deviceId特殊处理 - if (DeviceCategory.BATTERY.getCode().equals(deviceCategory) && (siteDeviceMap != null || siteDeviceMap.size() > 0)) { - deviceIds = siteDeviceMap.get(siteId); - } else { - deviceIds = emsDevicesSettingMapper.getDeviceIdsBySiteIdAndCategory(siteId,deviceCategory); - } - if (deviceIds.isEmpty()) { - continue; // 跳过无设备的站点 - } - // 处理该站点下的所有设备 for (String deviceId : deviceIds) { Object lastValue = null; @@ -228,7 +328,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService data.setValueDate(minute); data.setSiteId(siteId); data.setDeviceId(deviceId); - data.setPointValue(lastValue); // 用上一分钟值填充 + data.setPointValue(lastValue==null? 0 : lastValue); // 用上一分钟值填充 } else { lastValue = data.getPointValue(); // 更新最新值 } @@ -245,6 +345,64 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService return fullData; } + private List dealWithBatteryMinutesData(List querySiteIds, List dataVoList, + String deviceCategory, String startDate, String endDate, + Map> siteDeviceMap) throws ParseException { + List fullData = new ArrayList<>(); + Map dataMap = new HashMap<>(); + List clusterIds = new ArrayList<>(); + for (GeneralQueryDataVo data : dataVoList) { + String key = data.getParentDeviceId() + "_" + data.getDeviceId() + "_" + data.getValueDate(); + dataMap.put(key, data); + + if (!clusterIds.contains(data.getParentDeviceId())) { + clusterIds.add(data.getParentDeviceId()); + } + } + // 生成分钟序列 + Set minuteSeries = generateMinuteSeries(startDate, endDate); + + Map lastValueMap = new HashMap<>(); + String siteId = querySiteIds.get(0); + // 单站-先处理站点下的簇id + for (String clusterId : clusterIds) { + List deviceIds = siteDeviceMap.get(siteId); + if (deviceIds.isEmpty()) { + continue; + } + for (String deviceId : deviceIds) { + String deviceKey = clusterId + "_" + deviceId; + + for (String minute : minuteSeries) { + Object lastValue = lastValueMap.get(deviceKey); + String dataKey = clusterId + "_" + deviceId + "_" + minute; + GeneralQueryDataVo data = dataMap.get(dataKey); + + // 空值填充逻辑 + if (data == null) { + data = new GeneralQueryDataVo(); + data.setValueDate(minute); + data.setSiteId(siteId); + data.setDeviceId(deviceId); + data.setParentDeviceId(clusterId); + data.setPointValue(lastValue == null ? 0 : lastValue); // 上一分钟数据不存在默认0 + } else { + lastValueMap.put(deviceKey,data.getPointValue());// 更新最新值 + } + + fullData.add(data); + } + } + + } + + fullData.sort(Comparator.comparing(GeneralQueryDataVo::getValueDate) + .thenComparing(GeneralQueryDataVo::getSiteId) + .thenComparing(GeneralQueryDataVo::getDeviceId)); + + return fullData; + } + /** * 根据前端传递的startDate和endDate生成所有分钟点的序列 * @param startDate 起始时间(格式:yyyy-MM-dd HH:mm:00) @@ -256,7 +414,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService Set minutes = new TreeSet<>(); // TreeSet保证时间有序 // 解析起止时间 - startDate = DateUtils.adjustToNextMinute(startDate); + //startDate = DateUtils.adjustToNextMinute(startDate); Date startTime = TIME_FORMAT.parse(startDate.substring(0, 16) + ":00"); Date endTime = TIME_FORMAT.parse(endDate.substring(0, 16) + ":00"); diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 2f21263..5064b7d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -158,7 +158,74 @@ - + SELECT DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:00') AS valueDate, + site_id as siteId, + device_id as deviceId, + cluster_device_id as parentDeviceId, + ${tableField} as pointValue + FROM ${tableName} + WHERE create_time >= #{startDate} + AND create_time <= #{endDate} + AND ${tableField} is not null + + GROUP BY valueDate, site_id, device_id,cluster_device_id,pointValue + ORDER BY site_id,device_id,cluster_device_id, valueDate ASC + + + + + + + - SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') AS valueDate, t.site_id as siteId, t.device_id as deviceId, @@ -181,12 +251,15 @@ FROM ${tableName} t INNER JOIN ( SELECT site_id, device_id, DATE_FORMAT(create_time, '%Y-%m-%d %H:00') AS hour_group, MAX(create_time) AS max_time - FROM ${tableName} - WHERE create_time >= #{startDate} - AND create_time < #{endDate} + FROM ${tableName} + WHERE create_time >= #{startDate} + AND create_time <= #{endDate} AND ${tableField} is not null - - GROUP BY site_id, device_id, hour_group + AND site_id IN + + #{siteId} + + GROUP BY site_id, device_id, hour_group ) tmp ON t.site_id = tmp.site_id AND t.device_id = tmp.device_id AND DATE_FORMAT(t.create_time, '%Y-%m-%d %H:00') = tmp.hour_group @@ -195,7 +268,7 @@ ORDER BY t.site_id, t.device_id, valueDate ASC - SELECT DATE_FORMAT(t.create_time, '%Y-%m-%d') AS valueDate, t.site_id as siteId, t.device_id as deviceId, @@ -203,12 +276,15 @@ t.create_time AS last_update_time FROM ${tableName} t INNER JOIN ( SELECT site_id, device_id, DATE_FORMAT(create_time, '%Y-%m-%d') AS day_group, - MAX(create_time) AS max_time - FROM ${tableName} - WHERE create_time >= #{startDate} - AND create_time <= #{endDate} - AND ${tableField} is not null - + MAX(create_time) AS max_time + FROM ${tableName} + WHERE create_time >= #{startDate} + AND create_time <= #{endDate} + AND ${tableField} is not null + AND site_id IN + + #{siteId} + GROUP BY site_id, device_id, day_group ) tmp ON t.site_id = tmp.site_id AND t.device_id = tmp.device_id -- 2.49.0 From ab6771d33d9cd38befa0f77b3b89e2f88e261055 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 7 Sep 2025 21:23:24 +0800 Subject: [PATCH 130/336] =?UTF-8?q?20250905-=E5=A5=89=E8=B4=A4=E5=85=85?= =?UTF-8?q?=E6=94=BE=E7=94=B5=E5=8F=96=E5=80=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/FXXDataProcessServiceImpl.java | 40 +++++-------------- .../mapper/ems/EmsDailyChageDataMapper.xml | 7 ++-- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index e988941..550a488 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -99,6 +99,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else if (deviceId.contains("PCS")) { pcsDataProcess(deviceId, jsonData); pcsBranchDataProcess(deviceId, jsonData); + dealFXXDailyChargeDate(deviceId, jsonData); } else if (deviceId.contains("LOAD")) { loadDataProcess(deviceId, jsonData); } else if (deviceId.contains("METE")) { @@ -596,50 +597,27 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); - - // 处理每日充放电数据 - dealFXXDailyChargeDate(obj,deviceId); } - private void dealFXXDailyChargeDate(Map obj, String deviceId) { + private void dealFXXDailyChargeDate(String deviceId, String dataJson) { log.info("start dealFXXDailyChargeDate"); - // 初始化今日充放电 - BigDecimal dailyChargeDate = new BigDecimal(0); - BigDecimal dailyDisChargeDate = new BigDecimal(0); + //日充放电数据 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); - BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXYGZDN")); - BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXYGZDN")); // 初始化当日数据 EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); emsDailyChargeData.setSiteId(SITE_ID); emsDailyChargeData.setDeviceId(deviceId); emsDailyChargeData.setDateTime(DateUtils.getNowDate()); - emsDailyChargeData.setTotalChargeData(nowTotalChargeDate); - emsDailyChargeData.setTotalDischargeData(nowTotalDisChargeDate); + emsDailyChargeData.setTotalChargeData(StringUtils.getBigDecimal(obj.get("ZCDL"))); + emsDailyChargeData.setTotalDischargeData(StringUtils.getBigDecimal(obj.get("ZFDL"))); + emsDailyChargeData.setChargeData(StringUtils.getBigDecimal(obj.get("RCDL"))); + emsDailyChargeData.setDischargeData(StringUtils.getBigDecimal(obj.get("RFDL"))); emsDailyChargeData.setCreateBy("system"); emsDailyChargeData.setCreateTime(DateUtils.getNowDate()); emsDailyChargeData.setUpdateBy("system"); emsDailyChargeData.setUpdateTime(DateUtils.getNowDate()); - // 获取redis存放昨日最晚数据 - String yestData = DateUtils.getYesterdayDate(); - String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestData; - EmsAmmeterData yestDate = redisCache.getCacheObject(yestDateRedisKey); - if (yestDate == null) { - // redis没有这查电表总数据表 - yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData); - // 数据redis-有效期1天 - redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); - } - if (yestDate != null) { - // 今日总数据-昨日总数据=今日充放电 - BigDecimal yestTotalDisChargeDate = yestDate.getCurrentReverseActiveTotal(); - BigDecimal yestTotalChargeDate = yestDate.getCurrentForwardActiveTotal(); - - dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); - dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); - emsDailyChargeData.setChargeData(dailyChargeDate); - emsDailyChargeData.setDischargeData(dailyDisChargeDate); - } // 插入或更新每日充放电数据表 emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); log.info("end dealFXXDailyChargeDate"); diff --git a/ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml index 547a525..cf98727 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDailyChageDataMapper.xml @@ -156,12 +156,13 @@ -- 2.49.0 From bfdbc4f42c4f4eeaac4bfcb5fa0ef8bf1e70446a Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 12 Sep 2025 04:40:47 +0800 Subject: [PATCH 131/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 2 +- .../ems/domain/vo/BMSBatteryClusterVo.java | 11 ++++ .../xzzn/ems/domain/vo/SiteMonitorDataVo.java | 20 ++++++++ .../ems/mapper/EmsDailyChargeDataMapper.java | 6 +++ .../ems/mapper/EmsDevicesSettingMapper.java | 4 +- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 15 +----- .../impl/EmsStatsReportServiceImpl.java | 51 ++++++++++++++----- .../ems/service/impl/HomePageServiceImpl.java | 8 ++- .../service/impl/SingleSiteServiceImpl.java | 3 +- .../mapper/ems/EmsAmmeterDataMapper.xml | 35 ++++++------- .../mapper/ems/EmsBatteryStackMapper.xml | 4 +- .../mapper/ems/EmsDailyChageDataMapper.xml | 50 ++++++++++++++---- .../mapper/ems/EmsDevicesSettingMapper.xml | 17 ++++--- .../resources/mapper/ems/EmsPcsDataMapper.xml | 4 +- 14 files changed, 162 insertions(+), 68 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index 1f557f5..4d43ef1 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -100,7 +100,7 @@ public class EmsStatisticalReportController extends BaseController } /** - * 概率统计-获取总表 + * 概率统计-获取站点下所有电表 */ @GetMapping("/getLoadNameList") public AjaxResult getLoadNameList(String siteId) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java index 8de0dda..dfae301 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java @@ -57,6 +57,9 @@ public class BMSBatteryClusterVo { /** 设备唯一标识符 */ private String deviceId; + /** 父类设备名称 */ + private String parentDeviceName; + private List batteryDataList; public String getDeviceName() { @@ -194,4 +197,12 @@ public class BMSBatteryClusterVo { public void setBatteryDataList(List batteryDataList) { this.batteryDataList = batteryDataList; } + + public String getParentDeviceName() { + return parentDeviceName; + } + + public void setParentDeviceName(String parentDeviceName) { + this.parentDeviceName = parentDeviceName; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorDataVo.java index 58c0291..a2aaf1f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorDataVo.java @@ -24,6 +24,10 @@ public class SiteMonitorDataVo { private BigDecimal dailyEfficiency; + private BigDecimal totalChargedCap; + + private BigDecimal totalDisChargedCap; + public String getAmmeterDate() { return ammeterDate; } @@ -55,4 +59,20 @@ public class SiteMonitorDataVo { public void setDailyEfficiency(BigDecimal dailyEfficiency) { this.dailyEfficiency = dailyEfficiency; } + + public BigDecimal getTotalChargedCap() { + return totalChargedCap; + } + + public void setTotalChargedCap(BigDecimal totalChargedCap) { + this.totalChargedCap = totalChargedCap; + } + + public BigDecimal getTotalDisChargedCap() { + return totalDisChargedCap; + } + + public void setTotalDisChargedCap(BigDecimal totalDisChargedCap) { + this.totalDisChargedCap = totalDisChargedCap; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java index 2d88493..27c3864 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyChargeDataMapper.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import com.xzzn.ems.domain.EmsDailyChargeData; +import com.xzzn.ems.domain.vo.ElectricIndexList; import com.xzzn.ems.domain.vo.SiteMonitorDataVo; import org.apache.ibatis.annotations.Param; @@ -76,4 +77,9 @@ public interface EmsDailyChargeDataMapper // 按天获取站点每日总充总放 public List getTotalChargeDataByDay(@Param("siteId")String siteId,@Param("startDate")Date startDate, @Param("endDate")Date endDate); + + // 按月获取站点每日总充总放 + public List getTotalChargeDataByMonth(@Param("siteId")String siteId,@Param("startDate")Date startDate, @Param("endDate")Date endDate); + + public List getAllSiteChargeDataByMonth(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index 29e851e..d46d6b0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -77,11 +77,11 @@ public interface EmsDevicesSettingMapper public List> getDeviceInfosBySiteIdAndCategory(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); /** - * 获取该设备下的总表 + * 获取该设备下所有的电表 * @param siteId * @return */ - public List> getLoadNameList(String siteId); + public List> getAmmeterNameList(String siteId); public EmsDevicesSetting getDeviceBySiteAndDeviceId(@Param("deviceId")String deviceId, @Param("siteId")String siteId); diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index 9a5a7f2..ce7a868 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -92,12 +92,6 @@ public interface EmsPcsDataMapper */ public List getPcsDetailInfoBySiteId(String siteId); - /** - * 获取总充+总放 - * @return - */ - public Map getPcsTotalChargeData(String siteId); - /** * 根据时间按天获取充放电量 * @param siteId @@ -106,14 +100,7 @@ public interface EmsPcsDataMapper * @return */ public List getPcsDataByDay(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); - /** - * 根据时间按月获取充放电量 - * @param siteId - * @param startDate - * @param endDate - * @return - */ - public List getPcsDataByMonth(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + /** * 根据时间按小时获取充放电量 * @param siteId diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 32a9ec8..7040e73 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -1,6 +1,7 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.EmsAmmeterData; import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsStatsReportService; @@ -70,37 +71,38 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService String siteId = requestVo.getSiteId(); String deviceId = requestVo.getDeviceId(); - if ("021_DDS_01".equals(siteId)){ - deviceId = "METE"; - } else if ("021_FXX_01".equals(siteId)){ - deviceId = "LOAD"; - } // 日期筛选 List dataList = new ArrayList(); // 开始日期和结束日期同一天,展示 0-24 小时数据 if (DateUtils.isSameDay(startDate, endDate)){ electricDataInfoVo.setUnit("时"); - //endDate = DateUtils.addDays(endDate, 1); - //dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate); - dataList = emsAmmeterDataMapper.getChargeDataByHour(siteId,deviceId,startDate); + if ("021_DDS_01".equals(siteId)) { + deviceId = "METE"; + dataList = emsAmmeterDataMapper.getChargeDataByHour(siteId,deviceId,startDate); + } else if ("021_FXX_01".equals(siteId)) { + endDate = DateUtils.addDays(endDate, 1); + dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate); + } } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ electricDataInfoVo.setUnit("日"); // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 - //dataList = emsPcsDataMapper.getPcsDataByDay(requestVo.getSiteId(), startDate, endDate); dataList = emsDailyChargeDataMapper.getTotalChargeDataByDay(siteId,startDate,endDate); } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ electricDataInfoVo.setUnit("月"); // 开始日期-结束日期大于 1 个月,按月展示数据 - dataList = emsAmmeterDataMapper.getChargeDataByMonth(requestVo.getSiteId(),deviceId, startDate, endDate); + dataList = emsDailyChargeDataMapper.getTotalChargeDataByMonth(siteId,startDate, endDate); } - // 根据时间获取每天的充放电量 + // 获取昨天昨晚一条数据,计算第一个小时的差值 + //setFirstDataDiff(dataList,siteId,deviceId); + // 计算充放电效率 if (!CollectionUtils.isEmpty(dataList)){ for (SiteMonitorDataVo siteMonitorDataVo : dataList) { // 计算单天的效率 BigDecimal dailyEfficiency = new BigDecimal(0); - if ( siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){ + if ( siteMonitorDataVo.getChargedCap() != null && + siteMonitorDataVo.getChargedCap().compareTo(BigDecimal.ZERO)>0){ dailyEfficiency = siteMonitorDataVo.getDisChargedCap().divide(siteMonitorDataVo.getChargedCap(), 2, RoundingMode.HALF_UP); dailyEfficiency = dailyEfficiency.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); } @@ -112,6 +114,29 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return electricDataInfoVo; } + private void setFirstDataDiff(List dataList, String siteId, String deviceId) { + BigDecimal yestTotalDisChargeDate = new BigDecimal(0); + BigDecimal yestTotalChargeDate = new BigDecimal(0); + + String yestDate = DateUtils.getYesterdayDate(); + if (dataList != null && dataList.size()>0){ + SiteMonitorDataVo firstData = dataList.get(0); + if ("021_DDS_01".equals(siteId)){ + EmsAmmeterData yestData = emsAmmeterDataMapper.getYestLatestDate(siteId,deviceId,yestDate); + if (yestData != null) { + yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal(); + yestTotalChargeDate = yestData.getCurrentForwardActiveTotal(); + } + } else if ("021_FXX_01".equals(siteId)) { + + } + firstData.setChargedCap(firstData.getTotalChargedCap() == null ? BigDecimal.ZERO + : firstData.getTotalChargedCap().subtract(yestTotalChargeDate)); + firstData.setDisChargedCap(firstData.getTotalDisChargedCap() == null ? BigDecimal.ZERO + : firstData.getTotalDisChargedCap().subtract(yestTotalDisChargeDate)); + } + } + // pcs曲线数据 @Override public List getPCSDataResult(DateSearchRequest requestVo) { @@ -188,7 +213,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Override public List> getLoadNameList(String siteId) { - return emsDevicesSettingMapper.getLoadNameList(siteId); + return emsDevicesSettingMapper.getAmmeterNameList(siteId); } // 电表报表 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java index 03a8a62..948b85f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/HomePageServiceImpl.java @@ -113,7 +113,7 @@ public class HomePageServiceImpl implements IHomePageService HomePageDataViewVo homePageDataViewVo = new HomePageDataViewVo(); // 电量指标 //List electricDataList = emsPcsDataMapper.getElectDataList(); - List electricDataList = getElectricDataList(); + List electricDataList = getElectricDataList2(); homePageDataViewVo.setElecDataList(electricDataList); // 系统效率 List systemEfficiencyLists = new ArrayList<>(); @@ -159,6 +159,12 @@ public class HomePageServiceImpl implements IHomePageService return homePageDataViewVo; } + private List getElectricDataList2() { + List electricDataList = new ArrayList<>(); + electricDataList = emsDailyChargeDataMapper.getAllSiteChargeDataByMonth(); + return electricDataList; + } + private List getElectricDataList() { List electricDataList = new ArrayList<>(); // 获取每个月最早和最晚的时间 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 3084a11..3915c6e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -321,9 +321,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService { for (Map clusterDevice : clusterIds) { BMSBatteryClusterVo bmsBatteryClusterVo = new BMSBatteryClusterVo(); bmsBatteryClusterVo.setDeviceName(clusterDevice.get("deviceName").toString()); + bmsBatteryClusterVo.setParentDeviceName(clusterDevice.get("parentDeviceName").toString()); // 从redis取单个簇详细数据 String clusterId = clusterDevice.get("id").toString(); EmsBatteryCluster clusterData = redisCache.getCacheObject(RedisKeyConstants.CLUSTER +siteId+"_"+clusterId); + String parentDeviceId = ""; if (clusterData != null) { BeanUtils.copyProperties(clusterData, bmsBatteryClusterVo); // 处理单体电池数据-平均/最大/最小 @@ -331,7 +333,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { dealWithBatteryClusterData(clusterData,clusterDataList); bmsBatteryClusterVo.setBatteryDataList(clusterDataList); } - bmsBatteryClusterVoList.add(bmsBatteryClusterVo); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index ff90c79..fc045db 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -918,24 +918,25 @@ diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 4c1c4d9..7058b1b 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -428,8 +428,8 @@ - SELECT SUM(t.total_charge_data) AS totalChargedCap, - SUM(t.total_discharge_data) AS totalDischargedCap + SELECT + SUM(t.total_charge_data) AS totalChargedCap, + SUM(t.total_discharge_data) AS totalDischargedCap FROM ems_daily_charge_data t - LEFT JOIN ems_site_setting ss ON t.site_id = ss.site_id - WHERE t.date_time = #{nowData} + LEFT JOIN ems_site_setting ss ON t.site_id = ss.site_id + INNER JOIN ( + SELECT site_id,MAX(date_time) AS latest_date FROM ems_daily_charge_data + WHERE date_time <= #{nowData} - and t.site_id = #{siteId} + and site_id = #{siteId} - AND t.total_charge_data IS NOT NULL - AND t.total_discharge_data IS NOT NULL + AND total_charge_data IS NOT NULL + AND total_discharge_data IS NOT NULL + GROUP BY site_id + ) AS latest ON t.date_time = latest.latest_date + and t.site_id = latest.site_id + + where t.site_id = #{siteId} + SELECT t.date_time AS ammeterDate, - t.total_charge_Data as chargedCap, - t.total_discharge_Data as disChargedCap + SUM(t.charge_data) as chargedCap, + SUM(t.discharge_data) as disChargedCap FROM ems_daily_charge_data t WHERE t.site_id = #{siteId} AND t.date_time BETWEEN #{startDate} AND #{endDate} + group BY ammeterDate order by ammeterDate + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 38cb326..af5eb4f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -182,10 +182,15 @@ - + select distinct device_id as id,device_name as deviceName from ems_devices_setting where site_id = #{siteId} and device_category = 'AMMETER' select latest.dateHour as ammeterDate, - sum(t.total_ac_charge_energy) as chargedCap, - sum(t.total_ac_discharge_energy) as disChargedCap + sum(t.daily_ac_charge_energy) as chargedCap, + sum(t.daily_ac_discharge_energy) as disChargedCap from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p -- 2.49.0 From ecbe55cdbf97eb3e7ce06730b952cd9858624d70 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 13 Sep 2025 19:25:58 +0800 Subject: [PATCH 132/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E7=82=B9=E4=BD=8D=E6=95=B0=E6=8D=AE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=A2=9E=E5=8A=A0=E5=85=A5=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/domain/vo/PointNameRequest.java | 10 ++++++++++ .../java/com/xzzn/ems/mapper/EmsPointMatchMapper.java | 9 ++++++--- .../xzzn/ems/service/impl/GeneralQueryServiceImpl.java | 7 ++++--- .../main/resources/mapper/ems/EmsPointMatchMapper.xml | 9 +++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java index f7b7470..f2eaa6f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java @@ -22,6 +22,8 @@ public class PointNameRequest { private String endDate; + private String deviceId; + private Map> siteDeviceMap; public List getSiteIds() { @@ -79,4 +81,12 @@ public class PointNameRequest { public void setSiteDeviceMap(Map> siteDeviceMap) { this.siteDeviceMap = siteDeviceMap; } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 818acb3..78aabdc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -100,17 +100,20 @@ public interface EmsPointMatchMapper @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate")Date startDate, - @Param("endDate")Date endDate); + @Param("endDate")Date endDate, + @Param("deviceId")String deviceId); // 根据条件查询数据-按小时-其他设备 public List getCommonPointDataByHours(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate") Date startDate, - @Param("endDate")Date endDate); + @Param("endDate")Date endDate, + @Param("deviceId")String deviceId); // 根据条件查询数据-按天-其他设备 public List getCommonPointDataByDays(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate")Date startDate, - @Param("endDate")Date endDate); + @Param("endDate")Date endDate, + @Param("deviceId")String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index 78bf576..0fadf9b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -129,20 +129,21 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService List dataVoList = new ArrayList<>(); int dataUnit = request.getDataUnit(); + String deviceId = request.getDeviceId(); Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate()); Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate()); if (dataUnit == 1) { // 分钟:yyyy-MM-dd HH:mm:ss startDate = DateUtils.adjustToStartOfMinutes(request.getStartDate()); - dataVoList = emsPointMatchMapper.getCommonPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate); + dataVoList = emsPointMatchMapper.getCommonPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate,deviceId); if (dataVoList != null && dataVoList.size() > 0) { dataVoList = dealWithMinutesData(querySiteIds,dataVoList,deviceCategory, request.getStartDate(),request.getEndDate()); } } else if (dataUnit == 2) { // 小时:yyyy-MM-dd HH:mm:ss - dataVoList = emsPointMatchMapper.getCommonPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate); + dataVoList = emsPointMatchMapper.getCommonPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate,deviceId); } else if (dataUnit == 3) { // 天:yyyy-MM-dd 00:00:00 endDate = DateUtils.adjustToEndOfDay(request.getEndDate()); - dataVoList = emsPointMatchMapper.getCommonPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate); + dataVoList = emsPointMatchMapper.getCommonPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,deviceId); } // 数据转换 diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 5064b7d..853e524 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -238,6 +238,9 @@ #{siteId} + + and device_id = #{deviceId} + GROUP BY valueDate, site_id, device_id,pointValue ORDER BY site_id,device_id, valueDate ASC @@ -259,6 +262,9 @@ #{siteId} + + and device_id = #{deviceId} + GROUP BY site_id, device_id, hour_group ) tmp ON t.site_id = tmp.site_id AND t.device_id = tmp.device_id @@ -285,6 +291,9 @@ #{siteId} + + and device_id = #{deviceId} + GROUP BY site_id, device_id, day_group ) tmp ON t.site_id = tmp.site_id AND t.device_id = tmp.device_id -- 2.49.0 From 8a4cff0a6cd86b2c8debbf07ada50a9432fa0ca0 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 13 Sep 2025 21:49:33 +0800 Subject: [PATCH 133/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E7=82=B9=E4=BD=8D=E5=88=97=E8=A1=A8=E5=88=86?= =?UTF-8?q?=E9=A1=B5&=E7=82=B9=E4=BD=8D=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 15 ++++++ .../com/xzzn/ems/domain/EmsPointMatch.java | 47 ++++++++++++++++++- .../xzzn/ems/domain/vo/AmmeterLoadDataVo.java | 11 +++++ .../xzzn/ems/domain/vo/AmmeterMeteDataVo.java | 11 ++++- .../xzzn/ems/mapper/EmsPointMatchMapper.java | 3 ++ .../service/impl/SingleSiteServiceImpl.java | 2 + .../resources/mapper/ems/EmsPcsDataMapper.xml | 2 +- .../mapper/ems/EmsPointMatchMapper.xml | 28 ++++++++++- 8 files changed, 115 insertions(+), 4 deletions(-) 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 50d2276..5951959 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 @@ -7,8 +7,10 @@ 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.EmsPointMatch; import com.xzzn.ems.domain.EmsSiteSetting; 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; @@ -31,6 +33,8 @@ public class EmsSiteConfigController extends BaseController{ @Autowired private IEmsDeviceSettingService iEmsDeviceSettingService; + @Autowired + private EmsPointMatchMapper emsPointMatchMapper; /** * 获取站点列表 @@ -136,4 +140,15 @@ public class EmsSiteConfigController extends BaseController{ { return toAjax(iEmsDeviceSettingService.deleteEmsDevicesSettingById(id)); } + + /** + * 单个站点单个设备点位查询 + */ + @GetMapping("/getDevicePointList") + public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceCategory) + { + startPage(); + List pointList = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory); + return getDataTable(pointList); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java index afe534b..0bc2052 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -9,7 +9,7 @@ import com.xzzn.common.annotation.Excel; * 点位匹配对象 ems_point_match * * @author xzzn - * @date 2025-09-02 + * @date 2025-09-13 */ public class EmsPointMatch extends BaseEntity { @@ -38,6 +38,18 @@ public class EmsPointMatch extends BaseEntity @Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”") private String deviceCategory; + /** 数据点位 */ + @Excel(name = "数据点位") + private String dataPoint; + + /** 数据点位名称 */ + @Excel(name = "数据点位名称") + private String dataPointName; + + /** 数据点位来源设备 */ + @Excel(name = "数据点位来源设备") + private String dataDevice; + public void setId(Long id) { this.id = id; @@ -98,6 +110,36 @@ public class EmsPointMatch extends BaseEntity return deviceCategory; } + public void setDataPoint(String dataPoint) + { + this.dataPoint = dataPoint; + } + + public String getDataPoint() + { + return dataPoint; + } + + public void setDataPointName(String dataPointName) + { + this.dataPointName = dataPointName; + } + + public String getDataPointName() + { + return dataPointName; + } + + public void setDataDevice(String dataDevice) + { + this.dataDevice = dataDevice; + } + + public String getDataDevice() + { + return dataDevice; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -107,6 +149,9 @@ public class EmsPointMatch extends BaseEntity .append("matchField", getMatchField()) .append("siteId", getSiteId()) .append("deviceCategory", getDeviceCategory()) + .append("dataPoint", getDataPoint()) + .append("dataPointName", getDataPointName()) + .append("dataDevice", getDataDevice()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java index f443390..103eebc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java @@ -13,6 +13,9 @@ public class AmmeterLoadDataVo { /** 电表名称 */ private String deviceName; + /** 设备id */ + private String deviceId; + /** 通信状态 */ private String emsCommunicationStatus; @@ -54,4 +57,12 @@ public class AmmeterLoadDataVo { public void setLoadDataDetailInfo(List loadDataDetailInfo) { this.loadDataDetailInfo = loadDataDetailInfo; } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java index a9a941d..6d29576 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterMeteDataVo.java @@ -12,7 +12,8 @@ public class AmmeterMeteDataVo { /** 电表名称 */ private String deviceName; - + /** 设备id */ + private String deviceId; /** 通信状态 */ private String emsCommunicationStatus; @@ -54,4 +55,12 @@ public class AmmeterMeteDataVo { public void setMeteDataDetailInfo(List meteDataDetailInfo) { this.meteDataDetailInfo = meteDataDetailInfo; } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 78aabdc..d402fba 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -116,4 +116,7 @@ public interface EmsPointMatchMapper @Param("startDate")Date startDate, @Param("endDate")Date endDate, @Param("deviceId")String deviceId); + + // 单个站点单个设备点位查询 + public List getSingleSiteDevicePoints(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 3915c6e..583b73d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -456,6 +456,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (AMMETER_DEVICE_LOAD.equals(ammeterId)) { AmmeterLoadDataVo ammeterLoadDataVo = new AmmeterLoadDataVo(); ammeterLoadDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); + ammeterLoadDataVo.setDeviceId(ammeterDevice.get("id").toString()); ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : ammeterDevice.get("communicationStatus").toString()); // 处理总表数据 @@ -464,6 +465,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } else if (AMMETER_DEVICE_METE.equals(ammeterId)) { AmmeterMeteDataVo ammeterMeteDataVo = new AmmeterMeteDataVo(); ammeterMeteDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); + ammeterMeteDataVo.setDeviceId(ammeterDevice.get("id").toString()); ammeterMeteDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : ammeterDevice.get("communicationStatus").toString()); // 处理储能表数据 diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 85e0a9c..307a44f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -348,7 +348,7 @@ SELECT p.device_id, MAX(p.data_update_time) AS max_update_time FROM ems_pcs_data p where p.site_id = #{siteId} - and p.data_update_time >= CURDATE() + and p.data_update_time <= CURDATE() GROUP BY p.device_id ) latest inner join ems_pcs_data t ON latest.device_id = t.device_id AND latest.max_update_time = t.data_update_time diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 853e524..753e95e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -11,6 +11,9 @@ + + + @@ -19,7 +22,7 @@ - select id, point_name, match_table, match_field, site_id, device_category, create_by, create_time, update_by, update_time, remark from ems_point_match + select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, create_by, create_time, update_by, update_time, remark from ems_point_match @@ -46,6 +52,9 @@ match_field, site_id, device_category, + data_point, + data_point_name, + data_device, create_by, create_time, update_by, @@ -58,6 +67,9 @@ #{matchField}, #{siteId}, #{deviceCategory}, + #{dataPoint}, + #{dataPointName}, + #{dataDevice}, #{createBy}, #{createTime}, #{updateBy}, @@ -74,6 +86,9 @@ match_field = #{matchField}, site_id = #{siteId}, device_category = #{deviceCategory}, + data_point = #{dataPoint}, + data_point_name = #{dataPointName}, + data_device = #{dataDevice}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, @@ -302,4 +317,15 @@ WHERE t.${tableField} is not null ORDER BY t.site_id, t.device_id, valueDate ASC + + \ No newline at end of file -- 2.49.0 From d807b9117d303343dba328aa9d7d6eb9178bd987 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 14 Sep 2025 22:44:10 +0800 Subject: [PATCH 134/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96-PCS=E6=9B=B2=E7=BA=BF=E5=92=8C=E7=94=B5=E6=B1=A0?= =?UTF-8?q?=E5=A0=86=E6=9B=B2=E7=BA=BF=E8=BF=94=E5=9B=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 8 +--- .../xzzn/ems/domain/vo/PCSCurveResponse.java | 30 +++++++++++++ .../xzzn/ems/domain/vo/PcsStatisListVo.java | 13 +++++- .../ems/domain/vo/StackCurveResponse.java | 30 +++++++++++++ .../xzzn/ems/domain/vo/StackStatisListVo.java | 13 +++++- .../ems/service/IEmsStatsReportService.java | 4 +- .../impl/EmsStatsReportServiceImpl.java | 45 +++++++++++++++++-- .../mapper/ems/EmsBatteryStackMapper.xml | 4 +- .../resources/mapper/ems/EmsPcsDataMapper.xml | 4 +- 9 files changed, 135 insertions(+), 16 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSCurveResponse.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StackCurveResponse.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index 4d43ef1..906c261 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -58,8 +58,7 @@ public class EmsStatisticalReportController extends BaseController @GetMapping("/getPCSData") public AjaxResult getPCSData(DateSearchRequest requestVo) { - if (!StringUtils.isEmpty(requestVo.getSiteId()) && - !StringUtils.isEmpty(requestVo.getDeviceId()) && + if (!StringUtils.isEmpty(requestVo.getSiteId())&& !StringUtils.isEmpty(requestVo.getDataType())) { return success(ieEmsStatsReportService.getPCSDataResult(requestVo)); } else { @@ -74,7 +73,6 @@ public class EmsStatisticalReportController extends BaseController public AjaxResult getStackData(DateSearchRequest requestVo) { if (!StringUtils.isEmpty(requestVo.getSiteId()) && - !StringUtils.isEmpty(requestVo.getDeviceId()) && !StringUtils.isEmpty(requestVo.getDataType())) { return success(ieEmsStatsReportService.getStackDataResult(requestVo)); } else { @@ -131,9 +129,7 @@ public class EmsStatisticalReportController extends BaseController @GetMapping("/getPowerData") public AjaxResult getPowerData(DateSearchRequest requestVo) { - if (!StringUtils.isEmpty(requestVo.getSiteId()) - && !StringUtils.isEmpty(requestVo.getDeviceId()) - && !StringUtils.isEmpty(requestVo.getDataType())) { + if (!StringUtils.isEmpty(requestVo.getSiteId())) { return success(ieEmsStatsReportService.getPowerDataList(requestVo)); } else { return error("缺少必传项"); diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSCurveResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSCurveResponse.java new file mode 100644 index 0000000..cfa956b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PCSCurveResponse.java @@ -0,0 +1,30 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; + +/** + * 单数据统计-pcs曲线-返回对象 + * + */ +public class PCSCurveResponse { + /** pcs设备id */ + private String deviceId; + /** 数据对象 */ + private List dataList; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public List getDataList() { + return dataList; + } + + public void setDataList(List dataList) { + this.dataList = dataList; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java index e22fa71..c5f9384 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsStatisListVo.java @@ -3,7 +3,7 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; /** - * 数据统计-pcs曲线-通用对象 + * 数据统计-pcs曲线-数据list对象 */ public class PcsStatisListVo { /** @@ -36,6 +36,9 @@ public class PcsStatisListVo { */ private BigDecimal wCurrent; + /** pcs设备id */ + private String deviceId; + public String getStatisDate() { return statisDate; } @@ -83,4 +86,12 @@ public class PcsStatisListVo { public void setwCurrent(BigDecimal wCurrent) { this.wCurrent = wCurrent; } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackCurveResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackCurveResponse.java new file mode 100644 index 0000000..e267d42 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackCurveResponse.java @@ -0,0 +1,30 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; + +/** + * 数据统计-堆曲线-返回对象 + * + */ +public class StackCurveResponse { + /** pcs设备id */ + private String deviceId; + /** 数据对象 */ + private List dataList; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public List getDataList() { + return dataList; + } + + public void setDataList(List dataList) { + this.dataList = dataList; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java index 3038d51..0c9c6d9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java @@ -3,7 +3,7 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; /** - * 数据统计-堆曲线-通用对象 + * 数据统计-堆曲线-数据list对象 */ public class StackStatisListVo { /** @@ -31,6 +31,9 @@ public class StackStatisListVo { */ private BigDecimal soc; + /** pcs设备id */ + private String deviceId; + public String getStatisDate() { return statisDate; } @@ -70,4 +73,12 @@ public class StackStatisListVo { public void setSoc(BigDecimal soc) { this.soc = soc; } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java index 1b1c7ce..bb5bc8e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java @@ -16,9 +16,9 @@ public interface IEmsStatsReportService public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo); - public List getPCSDataResult(DateSearchRequest requestVo); + public List getPCSDataResult(DateSearchRequest requestVo); - public List getStackDataResult(DateSearchRequest requestVo); + public List getStackDataResult(DateSearchRequest requestVo); public List getClusterDataResult(StatisClusterDateRequest requestVo); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 7040e73..34e291d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 统计报表数据Service业务层处理 @@ -139,7 +140,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // pcs曲线数据 @Override - public List getPCSDataResult(DateSearchRequest requestVo) { + public List getPCSDataResult(DateSearchRequest requestVo) { + List responseList = new ArrayList<>(); List dataList = new ArrayList(); // 默认时间-7天 @@ -164,12 +166,30 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // 开始日期-结束日期大于 1 个月,按月展示数据 dataList = emsPcsDataMapper.getPcsActivePowerByMonth(requestVo); } - return dataList; + + // 数据格式转换 按deviceId分组 + if (dataList != null && dataList.size()>0){ + responseList = dataList.stream() + .collect(Collectors.groupingBy(PcsStatisListVo::getDeviceId)) + // 将Map转换为Set后流转 + .entrySet().stream() + // 映射为PCSCurveResponse对象 + .map(entry -> { + PCSCurveResponse response = new PCSCurveResponse(); + response.setDeviceId(entry.getKey()); + response.setDataList(entry.getValue()); + return response; + }) + // 收集为List + .collect(Collectors.toList()); + } + return responseList; } // 电池堆曲线 @Override - public List getStackDataResult(DateSearchRequest requestVo) { + public List getStackDataResult(DateSearchRequest requestVo) { + List responseList = new ArrayList<>(); List dataList = new ArrayList(); // 默认时间-7天 dealRequestTime(requestVo); @@ -193,7 +213,24 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // 开始日期-结束日期大于 1 个月,按月展示数据 dataList = emsBatteryStackMapper.getStackDataByMonth(requestVo); } - return dataList; + + // 数据格式转换 按deviceId分组 + if (dataList != null && dataList.size()>0){ + responseList = dataList.stream() + .collect(Collectors.groupingBy(StackStatisListVo::getDeviceId)) + // 将Map转换为Set后流转 + .entrySet().stream() + // 映射为PCSCurveResponse对象 + .map(entry -> { + StackCurveResponse response = new StackCurveResponse(); + response.setDeviceId(entry.getKey()); + response.setDataList(entry.getValue()); + return response; + }) + // 收集为List + .collect(Collectors.toList()); + } + return responseList; } // 电池温度 diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 7058b1b..11a905c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -359,7 +359,6 @@ WHERE p.site_id = #{siteId} - and p.device_id = #{deviceId} AND p.update_time >= #{startDate} @@ -390,6 +389,7 @@ select latest.dateDay as statisDate, + t.device_id as deviceId, from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%Y-%m-%d') AS dateDay,MAX(p.update_time) as max_update_time FROM ems_battery_stack p @@ -416,6 +417,7 @@ select latest.dateDay as statisDate, + t.device_id as deviceId, from ( SELECT p.site_id, p.device_id,DATE(p.data_update_time ) AS dateDay,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p @@ -513,6 +513,7 @@ select latest.dateHour as statisDate, + t.device_id as deviceId, from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p -- 2.49.0 From 2bb78dc02066244d97124409ee9438620c7ecd86 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 15 Sep 2025 14:21:27 +0800 Subject: [PATCH 135/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E5=8A=9F=E7=8E=87=E6=9B=B2=E7=BA=BF=E5=8F=96?= =?UTF-8?q?=E5=80=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/enums/SiteEnum.java | 31 ++++++++++ .../xzzn/ems/domain/vo/PowerStatisListVo.java | 8 +-- .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 4 ++ .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 13 ---- .../impl/DDSDataProcessServiceImpl.java | 3 + .../impl/EmsStatsReportServiceImpl.java | 40 ++++++++++++- .../mapper/ems/EmsAmmeterDataMapper.xml | 59 ++++++++++++++++++ .../resources/mapper/ems/EmsPcsDataMapper.xml | 60 ------------------- 8 files changed, 138 insertions(+), 80 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/SiteEnum.java diff --git a/ems-common/src/main/java/com/xzzn/common/enums/SiteEnum.java b/ems-common/src/main/java/com/xzzn/common/enums/SiteEnum.java new file mode 100644 index 0000000..78b0b90 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/SiteEnum.java @@ -0,0 +1,31 @@ +package com.xzzn.common.enums; + +/** + * device-设备类型 + * + * @author xzzn + */ + +public enum SiteEnum +{ + DDS("021_DDS_01", "电动所内部"), FX("021_FXX_01", "奉贤西部污水处理厂"); + + private final String code; + private final String info; + + SiteEnum(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java index 5159437..330f05f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java @@ -12,22 +12,22 @@ public class PowerStatisListVo { private String statisDate; /** - * 电网功率-total_apparent_power总交流视在功率 + * 电网功率-total_active_power(LOAD) */ private BigDecimal gridPower; /** - * 负载功率-total_active_power总交流有功电率 + * 负载功率 */ private BigDecimal loadPower; /** - * 储能功率-max_discharge_power_capacity最大可放功率 + * 储能功率-secondary_total_active_power(METE) */ private BigDecimal storagePower; /** - * 光伏功率-ac_capacitive_reactive_power交流侧容性无功功率 + * 光伏功率-total_active_power(METEGT) */ private BigDecimal pvPower; diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index 4b1b554..5049e76 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -84,4 +84,8 @@ public interface EmsAmmeterDataMapper // 概率统计-电量指标(按月) public List getChargeDataByMonth(@Param("siteId")String siteId, @Param("deviceId")String deviceId,@Param("startDate")Date startDate,@Param("endDate")Date endDate); + // 报表统计-功率曲线 + public List getPowerDataByHour(DateSearchRequest requestVo); + public List getPowerDataByDay(DateSearchRequest requestVo); + public List getPowerDataByMonth(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index ce7a868..a3d1bc1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -1,9 +1,7 @@ package com.xzzn.ems.mapper; -import java.math.BigDecimal; import java.util.Date; import java.util.List; -import java.util.Map; import com.xzzn.ems.domain.EmsPcsData; import com.xzzn.ems.domain.vo.*; @@ -129,15 +127,4 @@ public interface EmsPcsDataMapper public List getPcsActivePowerByHour(DateSearchRequest requestVo); public List getPcsActivePowerByMonth(DateSearchRequest requestVo); - - /** - * 获取pcs功率曲线数据 - * @param requestVo - * @return - */ - public List getPowerDataByHour(DateSearchRequest requestVo); - - public List getPowerDataByDay(DateSearchRequest requestVo); - - public List getPowerDataByMonth(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 05cf43a..e527c2f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -888,6 +888,9 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataMete.setVoltageUnbalanceDegree(StringUtils.getBigDecimal(obj.get("DYBPHD"))); dataMete.setCurrentUnbalanceDegree(StringUtils.getBigDecimal(obj.get("DLBPHD"))); + // 储能功率 + dataMete.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataMete.setCreateBy("system"); dataMete.setCreateTime(DateUtils.getNowDate()); dataMete.setUpdateBy("system"); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 34e291d..94335b4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -1,5 +1,6 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsAmmeterData; import com.xzzn.ems.domain.vo.*; @@ -11,6 +12,7 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.DecimalFormat; import java.time.LocalDate; import java.util.ArrayList; import java.util.Date; @@ -46,6 +48,9 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; + private static final BigDecimal DDS_STORAGE_FACTOR = new BigDecimal("0.1"); + private static final BigDecimal DDS_PV_FACTOR = new BigDecimal("-0.001"); + // 电量指标 @Override public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { @@ -328,23 +333,52 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService if (DateUtils.isSameDay(startDate, endDate)){ endDate = DateUtils.addDays(endDate, 1); requestVo.setEndDate(endDate); - dataList = emsPcsDataMapper.getPowerDataByHour(requestVo); + dataList = emsAmmeterDataMapper.getPowerDataByHour(requestVo); } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ endDate = DateUtils.addDays(endDate, 1); requestVo.setEndDate(endDate); // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 - dataList = emsPcsDataMapper.getPowerDataByDay(requestVo); + dataList = emsAmmeterDataMapper.getPowerDataByDay(requestVo); } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ endDate = DateUtils.addDays(endDate, 1); requestVo.setEndDate(endDate); // 开始日期-结束日期大于 1 个月,按月展示数据 - dataList = emsPcsDataMapper.getPowerDataByMonth(requestVo); + dataList = emsAmmeterDataMapper.getPowerDataByMonth(requestVo); } + // 处理数据设置 负荷功率 + dealDataPower(requestVo.getSiteId(),dataList); return dataList; } + private void dealDataPower(String siteId, List dataList) { + DecimalFormat df = new DecimalFormat("0.####"); + + if (dataList == null || dataList.size() == 0){ + return; + } + + for (PowerStatisListVo powerStatisListVo : dataList) { + BigDecimal gridPower = powerStatisListVo.getGridPower() == null ? BigDecimal.ZERO : powerStatisListVo.getGridPower(); + BigDecimal storagePower = powerStatisListVo.getStoragePower() == null ? BigDecimal.ZERO : powerStatisListVo.getStoragePower(); + BigDecimal pvPower = powerStatisListVo.getPvPower() == null ? BigDecimal.ZERO : powerStatisListVo.getPvPower(); + BigDecimal loadPower = new BigDecimal(0); + + // 电动所:储能功率=储能功率乘0.1;光伏功率=光伏功率*乘-0.001;负荷功率=电网功率+光伏功率-储能功率 + if (SiteEnum.DDS.getCode().equals(siteId)){ + powerStatisListVo.setStoragePower(storagePower.multiply(DDS_STORAGE_FACTOR).stripTrailingZeros()); + powerStatisListVo.setPvPower(pvPower.multiply(DDS_PV_FACTOR).stripTrailingZeros()); + loadPower = gridPower.add(powerStatisListVo.getPvPower()).subtract(powerStatisListVo.getStoragePower()); + powerStatisListVo.setLoadPower(loadPower); + } else if (SiteEnum.FX.getCode().equals(siteId)){ + // 奉贤:负荷功率=电网功率-储能功率; + loadPower = gridPower.subtract(storagePower); + powerStatisListVo.setLoadPower(loadPower); + } + } + } + // 统计入参时间处理 public void dealRequestTime(DateSearchRequest requestVo){ diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index fc045db..3b1308a 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -963,4 +963,63 @@ WHERE rn = 1 ORDER BY ammeterDate + + + MAX(CASE WHEN t.device_id = 'METE' THEN t.secondary_total_active_power END) AS gridPower, + MAX(CASE WHEN t.device_id = 'LOAD' THEN t.total_active_power END) AS storagePower, + MAX(CASE WHEN t.device_id = 'METEGF' THEN t.total_active_power END) AS pvPower + + + + WHERE p.device_id in ('METE','LOAD','METEGF') + and p.site_id = #{siteId} + + AND p.data_update_time >= #{startDate} + + + AND p.data_update_time < #{endDate} + + + + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 667765c..7b08a6c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -539,64 +539,4 @@ AND latest.max_update_time = t.data_update_time order by statisDate desc - - - - - t.total_apparent_power as gridPower - - - t.total_active_power as loadPower - - - t.max_discharge_power_capacity as storagePower - - - t.ac_capacitive_reactive_power as pvPower - - - 0 as gridPower - - - - - - - - - \ No newline at end of file -- 2.49.0 From cb39131871de3d67997f1e9a4f5e99648c8feecc Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 16 Sep 2025 00:31:58 +0800 Subject: [PATCH 136/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E5=8D=95=E7=AB=99=E7=9B=91=E6=8E=A7=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=82=B9=E4=BD=8D=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .../ems/EmsSiteMonitorController.java | 16 ++ .../xzzn/ems/domain/vo/PointDataResponse.java | 103 +++++++++++ .../com/xzzn/ems/domain/vo/StackPointVo.java | 50 +++++ .../xzzn/ems/domain/vo/StackStatisListVo.java | 4 +- .../ems/mapper/EmsBatteryClusterMapper.java | 8 + .../ems/mapper/EmsBatteryStackMapper.java | 6 + .../xzzn/ems/service/ISingleSiteService.java | 2 + .../impl/EmsStatsReportServiceImpl.java | 6 - .../impl/FXXDataProcessServiceImpl.java | 3 - .../service/impl/SingleSiteServiceImpl.java | 172 +++++++++++++++++- .../mapper/ems/EmsAmmeterDataMapper.xml | 2 +- .../mapper/ems/EmsBatteryClusterMapper.xml | 49 +++++ .../mapper/ems/EmsBatteryStackMapper.xml | 50 ++++- .../resources/mapper/ems/EmsPcsDataMapper.xml | 4 +- 15 files changed, 457 insertions(+), 20 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/StackPointVo.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 9533805..90fdf05 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,5 +8,5 @@ - + \ No newline at end of file diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 98ab612..578397e 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -3,6 +3,7 @@ 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.common.utils.StringUtils; import com.xzzn.ems.domain.vo.BMSBatteryDataList; import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import com.xzzn.ems.domain.vo.DateSearchRequest; @@ -184,4 +185,19 @@ public class EmsSiteMonitorController extends BaseController{ { return success(iSingleSiteService.getAmmeterDataList(siteId)); } + + /** + * 单站监控-首页-点位展示 + * 储能功率、电网功率、负荷功率、光伏功率 + * SOC、SOH、电池平均温度 + */ + @GetMapping("/getPointData") + public AjaxResult getPointData(DateSearchRequest requestVo) + { + if (!StringUtils.isEmpty(requestVo.getSiteId())) { + return success(iSingleSiteService.getPointData(requestVo)); + } else { + return error("缺少必传项"); + } + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java new file mode 100644 index 0000000..d8ca59d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java @@ -0,0 +1,103 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 单站监控-首页-点位重点数据展示 + */ +public class PointDataResponse{ + /** 数据日期 */ + private String statisDate; + /** 电网功率-total_active_power(LOAD) */ + private BigDecimal gridPower; + /** 负载功率 */ + private BigDecimal loadPower; + /** 储能功率-secondary_total_active_power(METE) */ + private BigDecimal storagePower; + /** 光伏功率-total_active_power(METEGT) */ + private BigDecimal pvPower; + /** SOC */ + private BigDecimal avgSoc; + /** SOH */ + private BigDecimal avgSoh; + /** 电池平均温度 */ + private BigDecimal avgTemp; + + public PointDataResponse(String statisDate, + BigDecimal pvPower, BigDecimal storagePower, BigDecimal loadPower, BigDecimal gridPower, + BigDecimal avgSoh, BigDecimal avgSoc,BigDecimal avgTemp + ) { + this.avgTemp = avgTemp; + this.avgSoh = avgSoh; + this.avgSoc = avgSoc; + this.pvPower = pvPower; + this.storagePower = storagePower; + this.loadPower = loadPower; + this.gridPower = gridPower; + this.statisDate = statisDate; + } + + public BigDecimal getAvgTemp() { + return avgTemp; + } + + public void setAvgTemp(BigDecimal avgTemp) { + this.avgTemp = avgTemp; + } + + public BigDecimal getAvgSoc() { + return avgSoc; + } + + public void setAvgSoc(BigDecimal avgSoc) { + this.avgSoc = avgSoc; + } + + public BigDecimal getAvgSoh() { + return avgSoh; + } + + public void setAvgSoh(BigDecimal avgSoh) { + this.avgSoh = avgSoh; + } + + public String getStatisDate() { + return statisDate; + } + + public void setStatisDate(String statisDate) { + this.statisDate = statisDate; + } + + public BigDecimal getGridPower() { + return gridPower; + } + + public void setGridPower(BigDecimal gridPower) { + this.gridPower = gridPower; + } + + public BigDecimal getLoadPower() { + return loadPower; + } + + public void setLoadPower(BigDecimal loadPower) { + this.loadPower = loadPower; + } + + public BigDecimal getStoragePower() { + return storagePower; + } + + public void setStoragePower(BigDecimal storagePower) { + this.storagePower = storagePower; + } + + public BigDecimal getPvPower() { + return pvPower; + } + + public void setPvPower(BigDecimal pvPower) { + this.pvPower = pvPower; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackPointVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackPointVo.java new file mode 100644 index 0000000..d0aa382 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackPointVo.java @@ -0,0 +1,50 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 单站监控-首页-电池堆点位数据 + */ +public class StackPointVo{ + private String statisDate; + /** SOC */ + private BigDecimal avgSoc; + + /** SOH */ + private BigDecimal avgSoh; + + /** 电池平均温度 */ + private BigDecimal avgTemp; + + public String getStatisDate() { + return statisDate; + } + + public void setStatisDate(String statisDate) { + this.statisDate = statisDate; + } + + public BigDecimal getAvgTemp() { + return avgTemp; + } + + public void setAvgTemp(BigDecimal avgTemp) { + this.avgTemp = avgTemp; + } + + public BigDecimal getAvgSoc() { + return avgSoc; + } + + public void setAvgSoc(BigDecimal avgSoc) { + this.avgSoc = avgSoc; + } + + public BigDecimal getAvgSoh() { + return avgSoh; + } + + public void setAvgSoh(BigDecimal avgSoh) { + this.avgSoh = avgSoh; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java index 0c9c6d9..58fe490 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackStatisListVo.java @@ -12,12 +12,12 @@ public class StackStatisListVo { private String statisDate; /** - * 有功 + * 温度 */ private BigDecimal temp; /** - * 无功 + * 电压 */ private BigDecimal voltage; diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java index fe0e99a..8cf29f2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java @@ -1,7 +1,10 @@ package com.xzzn.ems.mapper; +import java.math.BigDecimal; import java.util.Date; import java.util.List; +import java.util.Map; + import com.xzzn.ems.domain.EmsBatteryCluster; import com.xzzn.ems.domain.vo.*; import org.apache.ibatis.annotations.Param; @@ -83,4 +86,9 @@ public interface EmsBatteryClusterMapper /** 堆电池温度数据-获取当天每小时簇 */ public List getClusterDataByHour(StatisClusterDateRequest requestVo); + + // 奉贤-电池平均温度 + public List> getAvgTempByHour(DateSearchRequest requestVo); + public List> getAvgTempByDay(DateSearchRequest requestVo); + public List> getAvgTempByMonth(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java index ea78caf..dad1e38 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java @@ -5,6 +5,7 @@ import java.util.List; import com.xzzn.ems.domain.EmsBatteryStack; import com.xzzn.ems.domain.vo.DateSearchRequest; import com.xzzn.ems.domain.vo.StackAveTempVo; +import com.xzzn.ems.domain.vo.StackPointVo; import com.xzzn.ems.domain.vo.StackStatisListVo; import org.apache.ibatis.annotations.Param; @@ -85,4 +86,9 @@ public interface EmsBatteryStackMapper public List getStackDataByMonth(DateSearchRequest requestVo); public EmsBatteryStack getSiteSumStackInfo(String siteId); + + // 点位数据 - soc/soh/temp + public List getStackPointByHour(DateSearchRequest requestVo); + public List getStackPointByDay(DateSearchRequest requestVo); + public List getStackPointByMonth(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 9c9d5a3..88358e1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -39,4 +39,6 @@ public interface ISingleSiteService public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId); public List getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId); + + public List getPointData(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 94335b4..f9c2897 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -40,10 +40,6 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Autowired private EmsDevicesSettingMapper emsDevicesSettingMapper; @Autowired - private EmsBatteryDataMapper emsBatteryDataMapper; - @Autowired - private EmsBatteryDailyLatestMapper emsBatteryDailyLatestMapper; - @Autowired private EmsBatteryDataDayMapper emsBatteryDataDayMapper; @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; @@ -353,8 +349,6 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService } private void dealDataPower(String siteId, List dataList) { - DecimalFormat df = new DecimalFormat("0.####"); - if (dataList == null || dataList.size() == 0){ return; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 550a488..01f7427 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -7,7 +7,6 @@ import com.alibaba.fastjson2.TypeReference; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.xzzn.common.constant.Constants; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.*; @@ -23,12 +22,10 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; -import java.util.concurrent.TimeUnit; @Service public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXDataProcessService { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 583b73d..e31a9dc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -4,6 +4,7 @@ import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.AmmeterCategory; import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; @@ -38,19 +39,26 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private static final String AMMETER_DEVICE_METE = "METE"; + private static Map storageFactor = new HashMap<>(); + static { + storageFactor.put("021_DDS_01", new BigDecimal("0.1")); + storageFactor.put("default", BigDecimal.ONE); // 默认1 + } + + private static Map pvFactor = new HashMap<>(); + static { + pvFactor.put("021_DDS_01", new BigDecimal("-0.001")); + pvFactor.put("default", BigDecimal.ONE); // Convert to Basic Latin + } @Autowired private EmsPcsDataMapper emsPcsDataMapper; @Autowired private EmsAlarmRecordsMapper emsAlarmRecordsMapper; @Autowired - private EmsBatteryDataMapper emsBatteryDataMapper; - @Autowired private EmsBatteryStackMapper emsBatteryStackMapper; @Autowired private EmsBatteryClusterMapper emsBatteryClusterMapper; @Autowired - private EmsPcsBranchDataMapper emsPcsBranchDataMapper; - @Autowired private EmsCoolingDataMapper emsCoolingDataMapper; @Autowired private EmsAmmeterDataMapper emsAmmeterDataMapper; @@ -537,4 +545,160 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } + /** + * 单站监控-首页-获取重点数据 + * @param requestVo + * @return + */ + @Override + public List getPointData(DateSearchRequest requestVo) { + List responseList = new ArrayList<>(); + List powerList = new ArrayList<>();//功率数据 + List stackList = new ArrayList<>();//电池堆数据 + List> fxAvgTempList = new ArrayList<>(); + + // 默认时间-7天 + dealRequestTime(requestVo); + Date startDate = requestVo.getStartDate(); + Date endDate = requestVo.getEndDate(); + List timeList = new ArrayList<>(); + + // 开始日期和结束日期同一天,展示 0-24 小时数据 + if (DateUtils.isSameDay(startDate, endDate)){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + powerList = emsAmmeterDataMapper.getPowerDataByHour(requestVo);//功率数据 + stackList = emsBatteryStackMapper.getStackPointByHour(requestVo);//电池堆数据 + if (SiteEnum.FX.getCode().equals(requestVo.getSiteId())){ + fxAvgTempList = emsBatteryClusterMapper.getAvgTempByHour(requestVo); + } + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 + && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 天,小于30 天,按天展示数据 + powerList = emsAmmeterDataMapper.getPowerDataByDay(requestVo);//功率数据 + stackList = emsBatteryStackMapper.getStackPointByDay(requestVo);//电池堆数据 + if (SiteEnum.FX.getCode().equals(requestVo.getSiteId())){ + fxAvgTempList = emsBatteryClusterMapper.getAvgTempByDay(requestVo); + } + } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 30){ + endDate = DateUtils.addDays(endDate, 1); + requestVo.setEndDate(endDate); + // 开始日期-结束日期大于 1 个月,按月展示数据 + powerList = emsAmmeterDataMapper.getPowerDataByMonth(requestVo);//功率数据 + stackList = emsBatteryStackMapper.getStackPointByMonth(requestVo);//电池堆数据 + if (SiteEnum.FX.getCode().equals(requestVo.getSiteId())){ + fxAvgTempList = emsBatteryClusterMapper.getAvgTempByMonth(requestVo); + } + } + + // 如果奉贤数据:电池平均温度单独取值。将其塞入stackList里面 + if (SiteEnum.FX.getCode().equals(requestVo.getSiteId())){ + processFXXTempData(stackList,fxAvgTempList); + } + + // 数据转换为Map + Map powerMap = powerList.stream() + .collect(Collectors.toMap(PowerStatisListVo::getStatisDate, stat -> stat)); + Map stackMap = stackList.stream() + .collect(Collectors.toMap(StackPointVo::getStatisDate, stat -> stat)); + // 收集所有日期 + Set allDates = new HashSet<>(); + allDates.addAll(powerMap.keySet()); + allDates.addAll(stackMap.keySet()); + + // 按日期合并数据 + responseList = allDates.stream() + .map(date -> { + PowerStatisListVo powerStat = powerMap.get(date); + StackPointVo stackStat = stackMap.get(date); + + // null时取0 + BigDecimal pvPower = powerStat != null ? powerStat.getPvPower() : BigDecimal.ZERO; + BigDecimal storagePower = powerStat != null ? powerStat.getStoragePower() : BigDecimal.ZERO; + BigDecimal gridPower = powerStat != null ? powerStat.getGridPower() : BigDecimal.ZERO; + BigDecimal avgSoh = stackStat != null ? stackStat.getAvgSoh() : BigDecimal.ZERO; + BigDecimal avgSoc = stackStat != null ? stackStat.getAvgSoc() : BigDecimal.ZERO; + BigDecimal avgTemp = stackStat != null ? stackStat.getAvgTemp() : BigDecimal.ZERO; + + // 假设完整构造参数(补充原代码中缺失的部分) + return new PointDataResponse(date, pvPower, storagePower, BigDecimal.ZERO, gridPower, avgSoh, avgSoc, avgTemp); + }) + // 按日期排序 + .sorted(Comparator.comparing(PointDataResponse::getStatisDate)) + .collect(Collectors.toList()); + + // 处理数据系数 &负荷功率 + dealDataPower(requestVo.getSiteId(),responseList); + + return responseList; + } + + private void dealDataPower(String siteId, List dataList) { + if (dataList == null || dataList.size() == 0){ + return; + } + + for (PointDataResponse pointDataResponse : dataList) { + BigDecimal gridPower = pointDataResponse.getGridPower() == null ? BigDecimal.ZERO : pointDataResponse.getGridPower(); + BigDecimal storagePower = pointDataResponse.getStoragePower() == null ? BigDecimal.ZERO : pointDataResponse.getStoragePower(); + BigDecimal pvPower = pointDataResponse.getPvPower() == null ? BigDecimal.ZERO : pointDataResponse.getPvPower(); + BigDecimal loadPower = new BigDecimal(0); + + // 电动所:储能功率=储能功率乘0.1;光伏功率=光伏功率*乘-0.001;负荷功率=电网功率+光伏功率-储能功率 + // 奉贤:负荷功率=电网功率-储能功率; + // 电动所:储能功率=储能功率乘0.1;光伏功率=光伏功率*乘-0.001;负荷功率=电网功率+光伏功率-储能功率 + if (SiteEnum.DDS.getCode().equals(siteId)){ + pointDataResponse.setStoragePower(storagePower.multiply(storageFactor.get(siteId)).stripTrailingZeros()); + pointDataResponse.setPvPower(pvPower.multiply(pvFactor.get(siteId)).stripTrailingZeros()); + loadPower = gridPower.add(pointDataResponse.getPvPower()).subtract(pointDataResponse.getStoragePower()); + pointDataResponse.setLoadPower(loadPower); + } else if (SiteEnum.FX.getCode().equals(siteId)){ + // 奉贤:负荷功率=电网功率-储能功率; + loadPower = gridPower.subtract(storagePower); + pointDataResponse.setLoadPower(loadPower); + } + } + } + + private void processFXXTempData(List stackList, List> fxAvgTempList) { + if (stackList == null || fxAvgTempList == null) { + return; + } + + Map fxAvgTempMap = fxAvgTempList.stream() + .filter(subMap -> subMap != null && !subMap.isEmpty()) + .filter(subMap -> subMap.containsKey("statisDate") && subMap.containsKey("avgTemp")) + .collect(Collectors.toMap( + subMap -> String.valueOf(subMap.get("statisDate")), + subMap -> (BigDecimal)subMap.get("avgTemp"), + (existingValue, newValue) -> newValue, + HashMap::new + )); + + for (StackPointVo stackPointVo : stackList) { + // 从map中获取temp + BigDecimal mapTemp = (fxAvgTempMap != null) ? fxAvgTempMap.get(stackPointVo.getStatisDate()) : null; + if (mapTemp != null) { + stackPointVo.setAvgTemp(mapTemp); + } + } + + } + + // 统计入参时间处理 + public void dealRequestTime(DateSearchRequest requestVo){ + Date startDate = requestVo.getStartDate(); + Date endDate = requestVo.getEndDate(); + if (startDate == null && endDate == null) { + // 如果没有传时间,默认从今天往前7天 + LocalDate sevenDaysAgo = LocalDate.now().minusDays(6); + startDate = DateUtils.toDate(sevenDaysAgo); + endDate = new Date(); + requestVo.setStartDate(startDate); + requestVo.setEndDate(endDate); + } + } + } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 3b1308a..1c69618 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -984,7 +984,7 @@ + + + WHERE p.site_id = #{siteId} + + AND p.update_time >= #{startDate} + + + AND p.update_time < #{endDate} + + + + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 11a905c..2467e79 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -391,7 +391,7 @@ select latest.dateHour as statisDate, t.device_id as deviceId, - from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%H')+1 AS dateHour,MAX(p.update_time) as max_update_time + from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.update_time, '%H:00') AS dateHour,MAX(p.update_time) as max_update_time FROM ems_battery_stack p GROUP BY p.site_id,p.device_id,dateHour @@ -443,4 +443,52 @@ and t.create_time = latest.max_time where t.site_id = #{siteId} + + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 7b08a6c..90014fe 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -456,7 +456,7 @@ select latest.dateHour as ammeterDate, sum(t.daily_ac_charge_energy) as chargedCap, sum(t.daily_ac_discharge_energy) as disChargedCap - from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time + from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H:00') AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p GROUP BY p.site_id,p.device_id,dateHour @@ -530,7 +530,7 @@ select latest.dateHour as statisDate, t.device_id as deviceId, - from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H')+1 AS dateHour,MAX(p.data_update_time) as max_update_time + from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%H:00') AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p GROUP BY p.site_id,p.device_id,dateHour -- 2.49.0 From 2451e000221b7d906016ae0f8472fc1e1384545e Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 16 Sep 2025 00:34:14 +0800 Subject: [PATCH 137/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E5=8D=95=E7=AB=99=E7=9B=91=E6=8E=A7=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=82=B9=E4=BD=8D=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 90fdf05..9533805 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,5 +8,5 @@ - + \ No newline at end of file -- 2.49.0 From b8d3643ba9fa91f7959e1029a0c534e4b7ad16b8 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 16 Sep 2025 10:53:41 +0800 Subject: [PATCH 138/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250904=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E5=8A=9F=E7=8E=87=E6=95=B0=E6=8D=AE=E4=B8=8D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/EmsStatsReportServiceImpl.java | 12 +++--------- .../ems/service/impl/SingleSiteServiceImpl.java | 16 +++++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index f9c2897..03f2ee8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -12,7 +12,6 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; -import java.text.DecimalFormat; import java.time.LocalDate; import java.util.ArrayList; import java.util.Date; @@ -44,9 +43,6 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; - private static final BigDecimal DDS_STORAGE_FACTOR = new BigDecimal("0.1"); - private static final BigDecimal DDS_PV_FACTOR = new BigDecimal("-0.001"); - // 电量指标 @Override public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) { @@ -343,7 +339,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService dataList = emsAmmeterDataMapper.getPowerDataByMonth(requestVo); } - // 处理数据设置 负荷功率 + // 负荷功率 dealDataPower(requestVo.getSiteId(),dataList); return dataList; } @@ -359,11 +355,9 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService BigDecimal pvPower = powerStatisListVo.getPvPower() == null ? BigDecimal.ZERO : powerStatisListVo.getPvPower(); BigDecimal loadPower = new BigDecimal(0); - // 电动所:储能功率=储能功率乘0.1;光伏功率=光伏功率*乘-0.001;负荷功率=电网功率+光伏功率-储能功率 + // 电动所:负荷功率=电网功率+光伏功率-储能功率 if (SiteEnum.DDS.getCode().equals(siteId)){ - powerStatisListVo.setStoragePower(storagePower.multiply(DDS_STORAGE_FACTOR).stripTrailingZeros()); - powerStatisListVo.setPvPower(pvPower.multiply(DDS_PV_FACTOR).stripTrailingZeros()); - loadPower = gridPower.add(powerStatisListVo.getPvPower()).subtract(powerStatisListVo.getStoragePower()); + loadPower = gridPower.add(pvPower).subtract(storagePower); powerStatisListVo.setLoadPower(loadPower); } else if (SiteEnum.FX.getCode().equals(siteId)){ // 奉贤:负荷功率=电网功率-储能功率; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index e31a9dc..f0866e7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -17,6 +17,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; @@ -618,9 +619,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { BigDecimal pvPower = powerStat != null ? powerStat.getPvPower() : BigDecimal.ZERO; BigDecimal storagePower = powerStat != null ? powerStat.getStoragePower() : BigDecimal.ZERO; BigDecimal gridPower = powerStat != null ? powerStat.getGridPower() : BigDecimal.ZERO; - BigDecimal avgSoh = stackStat != null ? stackStat.getAvgSoh() : BigDecimal.ZERO; - BigDecimal avgSoc = stackStat != null ? stackStat.getAvgSoc() : BigDecimal.ZERO; - BigDecimal avgTemp = stackStat != null ? stackStat.getAvgTemp() : BigDecimal.ZERO; + BigDecimal avgSoh = stackStat != null ? stackStat.getAvgSoh().setScale(2,RoundingMode.HALF_UP) : BigDecimal.ZERO; + BigDecimal avgSoc = stackStat != null ? stackStat.getAvgSoc().setScale(2,RoundingMode.HALF_UP) : BigDecimal.ZERO; + BigDecimal avgTemp = stackStat != null ? stackStat.getAvgTemp().setScale(2,RoundingMode.HALF_UP) : BigDecimal.ZERO; // 假设完整构造参数(补充原代码中缺失的部分) return new PointDataResponse(date, pvPower, storagePower, BigDecimal.ZERO, gridPower, avgSoh, avgSoc, avgTemp); @@ -629,7 +630,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { .sorted(Comparator.comparing(PointDataResponse::getStatisDate)) .collect(Collectors.toList()); - // 处理数据系数 &负荷功率 + // 负荷功率 dealDataPower(requestVo.getSiteId(),responseList); return responseList; @@ -646,13 +647,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { BigDecimal pvPower = pointDataResponse.getPvPower() == null ? BigDecimal.ZERO : pointDataResponse.getPvPower(); BigDecimal loadPower = new BigDecimal(0); - // 电动所:储能功率=储能功率乘0.1;光伏功率=光伏功率*乘-0.001;负荷功率=电网功率+光伏功率-储能功率 + // 电动所:负荷功率=电网功率+光伏功率-储能功率 // 奉贤:负荷功率=电网功率-储能功率; - // 电动所:储能功率=储能功率乘0.1;光伏功率=光伏功率*乘-0.001;负荷功率=电网功率+光伏功率-储能功率 if (SiteEnum.DDS.getCode().equals(siteId)){ - pointDataResponse.setStoragePower(storagePower.multiply(storageFactor.get(siteId)).stripTrailingZeros()); - pointDataResponse.setPvPower(pvPower.multiply(pvFactor.get(siteId)).stripTrailingZeros()); - loadPower = gridPower.add(pointDataResponse.getPvPower()).subtract(pointDataResponse.getStoragePower()); + loadPower = gridPower.add(pvPower).subtract(storagePower); pointDataResponse.setLoadPower(loadPower); } else if (SiteEnum.FX.getCode().equals(siteId)){ // 奉贤:负荷功率=电网功率-储能功率; -- 2.49.0 From 8954329ccc8bf38a2fe509c222a870cf8d8b7dd7 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 18 Sep 2025 05:17:57 +0800 Subject: [PATCH 139/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250916=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E7=82=B9=E4=BD=8D=E6=9C=80=E6=96=B0=E5=80=BC+?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 8 +- .../common/constant/RedisKeyConstants.java | 5 + .../core/controller/BaseController.java | 36 ++++-- .../ems/domain/vo/PointQueryResponse.java | 96 +++++++++++++++ .../xzzn/ems/mapper/EmsPointMatchMapper.java | 3 +- .../ems/service/IEmsDeviceSettingService.java | 4 + .../impl/DDSDataProcessServiceImpl.java | 3 + .../impl/EmsDeviceSettingServiceImpl.java | 113 +++++++++++++++++- .../impl/FXXDataProcessServiceImpl.java | 3 + .../mapper/ems/EmsPointMatchMapper.xml | 9 +- 10 files changed, 259 insertions(+), 21 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java 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 5951959..3f152b8 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 @@ -9,6 +9,7 @@ import com.xzzn.common.utils.file.MimeTypeUtils; import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.domain.EmsSiteSetting; +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; @@ -145,10 +146,9 @@ public class EmsSiteConfigController extends BaseController{ * 单个站点单个设备点位查询 */ @GetMapping("/getDevicePointList") - public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceCategory) + public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceId,@RequestParam String deviceCategory) { - startPage(); - List pointList = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory); - return getDataTable(pointList); + List result = iEmsDeviceSettingService.getSingleSiteDevicePoints(siteId,deviceId,deviceCategory); + return getDataTable2(result); } } diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index e16229c..408dc42 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -51,4 +51,9 @@ public class RedisKeyConstants * BMSD原始数据 redis key */ public static final String ORIGINAL_BMSD = "BMSD_"; + + /** + * 存放单个设备同步过来的原始数据 + */ + public static final String ORIGINAL_MQTT_DATA = "MQTT_"; } diff --git a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java index a05a357..6d1fb1b 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java +++ b/ems-common/src/main/java/com/xzzn/common/core/controller/BaseController.java @@ -208,28 +208,42 @@ public class BaseController @SuppressWarnings({ "rawtypes", "unchecked" }) protected TableDataInfo getDataTable2(List list) { - List subList = new ArrayList<>(); - // 分页梳理 + // 1. 处理原列表为null的情况,避免空指针 + List targetList = (list == null) ? Collections.emptyList() : list; + List subList; + + // 2. 获取分页参数 PageDomain pageDomain = TableSupport.buildPageRequest(); int pageNum = pageDomain.getPageNum(); int pageSize = pageDomain.getPageSize(); + + // 3. 判断分页参数是否有效(pageNum和pageSize均为正数时才分页) if (pageNum > 0 && pageSize > 0) { - // 计算分页起始和结束索引 - int startIndex = (pageNum - 1) * pageSize; - int endIndex = Math.min(startIndex + pageSize, list.size()); - // 防止越界 - if (startIndex >= list.size()) { - subList = Collections.emptyList(); + // 计算起始索引(确保不小于0) + int startIndex = Math.max((pageNum - 1) * pageSize, 0); + + // 关键修复:若起始索引已超出列表大小,直接返回空列表 + if (startIndex >= targetList.size()) { + subList = Collections.emptyList(); + } else { + // 计算结束索引(不超过列表大小,且不小于起始索引) + int endIndex = Math.min(startIndex + pageSize, targetList.size()); + endIndex = Math.max(endIndex, startIndex); // 防止endIndex < startIndex + + // 截取子列表(转换为新ArrayList,避免视图依赖) + subList = new ArrayList<>(targetList.subList(startIndex, endIndex)); } - // 截取当前页数据 - subList = list.subList(startIndex, endIndex); + } else { + // 分页参数无效时,返回全部数据 + subList = new ArrayList<>(targetList); } + // 4. 封装返回结果 TableDataInfo rspData = new TableDataInfo(); rspData.setCode(HttpStatus.SUCCESS); rspData.setMsg("查询成功"); rspData.setRows(subList); - rspData.setTotal(list.size()); + rspData.setTotal(targetList.size()); return rspData; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java new file mode 100644 index 0000000..e03cff5 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xzzn.common.annotation.Excel; + +import java.util.Date; + +/** + * 设备列表-点位详情返回 + */ +public class PointQueryResponse +{ + /** 点位名称 */ + @Excel(name = "点位名称") + private String pointName; + + /** 数据点位 */ + @Excel(name = "数据点位") + private String dataPoint; + + /** 数据点位名称 */ + @Excel(name = "数据点位名称") + private String dataPointName; + + /** 数据点位来源设备 */ + @Excel(name = "数据点位来源设备") + private String dataDevice; + + /** 数据点位来源设备 */ + @Excel(name = "点位最新数据") + private Object pointValue; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** 点位是否需要匹配多设备 */ + @Excel(name = "点位最新数据") + private int isNeedDeviceId; + + public int getIsNeedDeviceId() { + return isNeedDeviceId; + } + + public void setIsNeedDeviceId(int isNeedDeviceId) { + this.isNeedDeviceId = isNeedDeviceId; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Object getPointValue() { + return pointValue; + } + + public void setPointValue(Object pointValue) { + this.pointValue = pointValue; + } + + public String getDataDevice() { + return dataDevice; + } + + public void setDataDevice(String dataDevice) { + this.dataDevice = dataDevice; + } + + public String getDataPointName() { + return dataPointName; + } + + public void setDataPointName(String dataPointName) { + this.dataPointName = dataPointName; + } + + public String getDataPoint() { + return dataPoint; + } + + public void setDataPoint(String dataPoint) { + this.dataPoint = dataPoint; + } + + public String getPointName() { + return pointName; + } + + public void setPointName(String pointName) { + this.pointName = pointName; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index d402fba..fd1c646 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -6,6 +6,7 @@ import java.util.Map; import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.domain.vo.GeneralQueryDataVo; +import com.xzzn.ems.domain.vo.PointQueryResponse; import org.apache.ibatis.annotations.Param; /** @@ -118,5 +119,5 @@ public interface EmsPointMatchMapper @Param("deviceId")String deviceId); // 单个站点单个设备点位查询 - public List getSingleSiteDevicePoints(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); + public List getSingleSiteDevicePoints(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); } 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 3340e50..dcecb19 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,6 +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.PointQueryResponse; import java.util.List; @@ -21,4 +23,6 @@ public interface IEmsDeviceSettingService public int deleteEmsDevicesSettingById(Long id); public List getDeviceCategory(); + + public List getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index e527c2f..3689c55 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -92,6 +92,9 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return; } + // 存放mqtt原始每个设备数据,便于后面点位获取数据 + redisCache.setCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + SITE_ID + "_" + deviceId, obj); + // 处理相关数据 if (deviceId.contains("BMSD")) { batteryStackDataProcess(deviceId, jsonData); 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 1837a49..ee537ee 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 @@ -1,16 +1,22 @@ package com.xzzn.ems.service.impl; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.alibaba.fastjson2.TypeReference; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.vo.PointQueryResponse; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsPointMatchMapper; import com.xzzn.ems.service.IEmsDeviceSettingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Arrays; -import java.util.List; +import java.util.*; /** * 站点信息 服务层实现 @@ -19,9 +25,14 @@ import java.util.List; @Service public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService { + private static final String DDS_SITE_ID = "021_DDS_01"; + @Autowired private EmsDevicesSettingMapper emsDevicesMapper; - + @Autowired + private EmsPointMatchMapper emsPointMatchMapper; + @Autowired + private RedisCache redisCache; /** * 获取设备详细信息 * @param id @@ -106,4 +117,100 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService List deviceList = Arrays.asList(DeviceCategory.values()); return deviceList; } + + @Override + public List getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory) { + List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory); + + // 电动所的电池簇特殊处理-来源pcs+bmsd + if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { + response = specialDealWithDDSCluster(response,siteId,deviceId); + return response; + } + + // 从redis取最新数据 + //String test = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); + JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); + if(mqttJson == null){ + return response; + } + String deviceFromMqtt = mqttJson.get("Device").toString(); + String jsonData = mqttJson.get("Data").toString(); + if (StringUtils.isEmpty(jsonData) || !deviceId.equals(deviceFromMqtt)) { + return response; + } + + Map obj = JSON.parseObject(jsonData, new TypeReference>() {}); + for (PointQueryResponse pointInfo : response) { + String dataKey = pointInfo.getDataPoint(); + int isNeedDeviceId = pointInfo.getIsNeedDeviceId(); + if (isNeedDeviceId == 1) {// 需要根据deviceId拼接point + dataKey = deviceId + dataKey; + pointInfo.setDataPoint(dataKey); + } + pointInfo.setPointValue(obj.get(dataKey)); + Long updateTime = Long.valueOf(mqttJson.get("timestamp").toString()); + Date latestUpdateTime = convertUpdateTime(updateTime); + pointInfo.setUpdateTime(latestUpdateTime); + } + + return response; + } + + // 对于dds的电池簇点位最新数据获取特殊处理 + private List specialDealWithDDSCluster(List response, String siteId, String deviceId) { + JSONObject mergedData = new JSONObject(); + + // 数据来源pcs + JSONObject pcsJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_PCS"); + if (pcsJson != null) { + JSONObject data = pcsJson.getJSONObject("Data"); + mergedData.putAll(data); + } + // 根据deviceId获取父类bmsd + String bmsdDeviceId = deviceId.replace("BMSC","BMSD"); + JSONObject bmsdJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + bmsdDeviceId); + if (bmsdJson != null) { + JSONObject data = bmsdJson.getJSONObject("Data"); + mergedData.putAll(data); + } + + String jsonData = mergedData.toString(); + Map obj = JSON.parseObject(jsonData, new TypeReference>() {}); + for (PointQueryResponse pointInfo : response) { + String dataKey = pointInfo.getDataPoint(); + Long updateTime = Long.valueOf(bmsdJson.get("timestamp").toString()); + int isNeedDeviceId = pointInfo.getIsNeedDeviceId(); + if (isNeedDeviceId == 1 && "PCS".equals(pointInfo.getDataDevice())) {// 需要根据deviceId拼接point + dataKey = deviceId + dataKey; + updateTime = Long.valueOf(pcsJson.get("timestamp").toString()); + } else if (isNeedDeviceId == 1 && "BMSD".equals(pointInfo.getDataDevice())){ + dataKey = bmsdDeviceId + dataKey; + } + pointInfo.setDataPoint(dataKey); + pointInfo.setPointValue(obj.get(dataKey)); + Date latestUpdateTime = convertUpdateTime(updateTime); + pointInfo.setUpdateTime(latestUpdateTime); + } + return response; + } + + private Date convertUpdateTime(Long updateTime) { + if (updateTime == null) { + return null; + } + + // 兼容10位(秒级)和13位(毫秒级) + int length = String.valueOf(updateTime).length(); + if (length == 10) { // 10位秒级 -> 转换为毫秒级 + updateTime *= 1000; + } else if (length != 13) { // 既不是10位也不是13位,视为非法 + System.err.println("时间戳格式错误,必须是10位(秒)或13位(毫秒)"); + return null; + } + + // 3. 转换为Date + return new Date(updateTime); + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 01f7427..fe2d5ac 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -85,6 +85,9 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return; } + // 存放mqtt原始每个设备数据,便于后面点位获取数据 + redisCache.setCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + SITE_ID + "_" + deviceId, obj); + if (deviceId.contains("BMSD")) { batteryStackDataProcess(deviceId, jsonData); diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 753e95e..7b6b290 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -318,8 +318,13 @@ ORDER BY t.site_id, t.device_id, valueDate ASC - + select t.point_name as pointName, + t.data_point as dataPoint, + t.data_point_name as dataPointName, + t.data_device as dataDevice, + t.need_diff_device_id as isNeedDeviceId + from ems_point_match t where 1=1 and site_id = #{siteId} -- 2.49.0 From e93f9cc6b8310fa3aad449de7f4e031a21b99ea8 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 18 Sep 2025 18:04:59 +0800 Subject: [PATCH 140/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250916=E4=BC=98?= =?UTF-8?q?=E5=8C=96-=E7=82=B9=E4=BD=8D=E5=90=8D=E7=A7=B0=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/web/controller/ems/EmsSiteConfigController.java | 5 +++-- .../main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java | 4 +++- .../com/xzzn/ems/service/IEmsDeviceSettingService.java | 2 +- .../xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java | 5 +++-- .../src/main/resources/mapper/ems/EmsPointMatchMapper.xml | 7 +++++-- 5 files changed, 15 insertions(+), 8 deletions(-) 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 3f152b8..f03eb13 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 @@ -146,9 +146,10 @@ public class EmsSiteConfigController extends BaseController{ * 单个站点单个设备点位查询 */ @GetMapping("/getDevicePointList") - public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceId,@RequestParam String deviceCategory) + public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceId, + @RequestParam String deviceCategory, String dataPointName) { - List result = iEmsDeviceSettingService.getSingleSiteDevicePoints(siteId,deviceId,deviceCategory); + List result = iEmsDeviceSettingService.getSingleSiteDevicePoints(siteId,deviceId,deviceCategory,dataPointName); return getDataTable2(result); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index fd1c646..7dd6e15 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -119,5 +119,7 @@ public interface EmsPointMatchMapper @Param("deviceId")String deviceId); // 单个站点单个设备点位查询 - public List getSingleSiteDevicePoints(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory); + public List getSingleSiteDevicePoints(@Param("siteId")String siteId, + @Param("deviceCategory")String deviceCategory, + @Param("dataPointName")String dataPointName); } 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 dcecb19..bbd4d6a 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 @@ -24,5 +24,5 @@ public interface IEmsDeviceSettingService public List getDeviceCategory(); - public List getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory); + public List getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory, String dataPointName); } 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 ee537ee..7d6ebe6 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 @@ -119,8 +119,9 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService } @Override - public List getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory) { - List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory); + public List getSingleSiteDevicePoints(String siteId, String deviceId, + String deviceCategory, String dataPointName) { + List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory,dataPointName); // 电动所的电池簇特殊处理-来源pcs+bmsd if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 7b6b290..ed73fe0 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -327,10 +327,13 @@ from ems_point_match t where 1=1 - and site_id = #{siteId} + and t.site_id = #{siteId} - and device_category = #{deviceCategory} + and t.device_category = #{deviceCategory} + + + and t.data_point_name like CONCAT('%', #{dataPointName}, '%') \ No newline at end of file -- 2.49.0 From a5f1444984756cc7c4174309e4d0dbd10564db4b Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 22 Sep 2025 00:40:38 +0800 Subject: [PATCH 141/336] =?UTF-8?q?=E6=95=B0=E6=8D=AE20250916=E4=BC=98?= =?UTF-8?q?=E5=8C=96-topic=E8=AE=A2=E9=98=85=E5=A4=B1=E8=B4=A5&=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=A9=BA=E6=8A=A5=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 5 + .../manager/MqttLifecycleManager.java | 9 +- .../com/xzzn/ems/domain/EmsAlarmRecords.java | 15 --- .../ems/mapper/EmsAlarmRecordsMapper.java | 4 + .../ems/service/IEmsAlarmRecordsService.java | 7 ++ .../impl/DDSDataProcessServiceImpl.java | 5 + .../impl/EmsAlarmRecordsServiceImpl.java | 94 ++++++++++++++++++- .../impl/FXXDataProcessServiceImpl.java | 5 + .../mapper/ems/EmsAlarmRecordsMapper.xml | 43 +++++---- 9 files changed, 151 insertions(+), 36 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 408dc42..eaab5be 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -56,4 +56,9 @@ public class RedisKeyConstants * 存放单个设备同步过来的原始数据 */ public static final String ORIGINAL_MQTT_DATA = "MQTT_"; + + /** 存放订阅失败告警信息 */ + public static final String TOPIC_FAILED_ALRAM_RECORD = "topic_failed_"; + /** topic 内没有数据设备维度告警 */ + public static final String TOPIC_EMPTY_ALARM_RECORD = "topic_empty_"; } diff --git a/ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java b/ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java index 234382a..b4c05ce 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java +++ b/ems-framework/src/main/java/com/xzzn/framework/manager/MqttLifecycleManager.java @@ -1,5 +1,6 @@ package com.xzzn.framework.manager; +import com.xzzn.ems.service.IEmsAlarmRecordsService; import org.eclipse.paho.client.mqttv3.*; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; import org.springframework.beans.factory.annotation.Autowired; @@ -16,6 +17,7 @@ import java.util.concurrent.ConcurrentHashMap; public class MqttLifecycleManager implements ApplicationRunner, SmartLifecycle, MqttCallback { private final MqttConnectOptions connectOptions; + private final IEmsAlarmRecordsService iEmsAlarmRecordsService; private MqttClient mqttClient; private volatile boolean running = false; @@ -23,8 +25,9 @@ public class MqttLifecycleManager implements ApplicationRunner, SmartLifecycle, private final ConcurrentHashMap subscriptions = new ConcurrentHashMap<>(); @Autowired - public MqttLifecycleManager(MqttConnectOptions connectOptions) { + public MqttLifecycleManager(MqttConnectOptions connectOptions, IEmsAlarmRecordsService iEmsAlarmRecordsService) { this.connectOptions = connectOptions; + this.iEmsAlarmRecordsService = iEmsAlarmRecordsService; } // Spring Boot 启动完成后执行 @@ -107,7 +110,11 @@ public class MqttLifecycleManager implements ApplicationRunner, SmartLifecycle, subscriptions.put(topic, new SubscriptionInfo(listener, qos)); } catch (MqttException e) { System.err.println("Subscribe failed: " + e.getMessage()); + // 订阅失败-增加告警 + iEmsAlarmRecordsService.addSubFailedAlarmRecord(topic); } + // 订阅成功了-校验是否存在未处理或者处理中的订阅失败信息 + iEmsAlarmRecordsService.checkFailedRecord(topic); } // 发布方法 diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java index 258d3b5..72ec48a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java @@ -54,10 +54,6 @@ public class EmsAlarmRecords extends BaseEntity @Excel(name = "设备唯一标识符") private String deviceId; - /** 设备名称,用于标识设备 */ - @Excel(name = "设备名称,用于标识设备") - private String deviceName; - /** 工单号(规则:T+日期+6位随机) */ @Excel(name = "工单号", readConverterExp = "规=则:T+日期+6位随机") private String ticketNo; @@ -152,16 +148,6 @@ public class EmsAlarmRecords extends BaseEntity return deviceId; } - public void setDeviceName(String deviceName) - { - this.deviceName = deviceName; - } - - public String getDeviceName() - { - return deviceName; - } - public String getTicketNo() { return ticketNo; } @@ -187,7 +173,6 @@ public class EmsAlarmRecords extends BaseEntity .append("remark", getRemark()) .append("siteId", getSiteId()) .append("deviceId", getDeviceId()) - .append("deviceName", getDeviceName()) .append("ticketNo", getTicketNo()) .toString(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java index ca0ba7b..09cdcd4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java @@ -90,4 +90,8 @@ public interface EmsAlarmRecordsMapper // 获取站点设备告警数量 public int getDeviceAlarmNum(@Param("siteId") String siteId, @Param("deviceId") String deviceId); + + //获取未处理的订阅失败告警 + public EmsAlarmRecords getFailedRecord(@Param("siteId")String siteId, @Param("deviceId")String deviceId, + @Param("content") String content,@Param("status")String status); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java index 2a29700..94c7743 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -76,4 +76,11 @@ public interface IEmsAlarmRecordsService * @return */ public String createTicketNo(Long id, Long userId); + // 订阅失败-增加告警 + public void addSubFailedAlarmRecord(String topic); + // 订阅成功-处理告警 + public void checkFailedRecord(String topic); + + // topic 内没有数据,按照设备维度告警 + public void addEmptyDataAlarmRecord(String siteId, String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 3689c55..8efb366 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -15,6 +15,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IDDSDataProcessService; +import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -74,6 +75,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; + @Autowired + private IEmsAlarmRecordsService iEmsAlarmRecordsService; public DDSDataProcessServiceImpl(ObjectMapper objectMapper) { super(objectMapper); @@ -89,6 +92,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl log.info("deviceId:" + deviceId); boolean isEmpty = checkJsonDataEmpty(jsonData); if (isEmpty) { + // 添加设备告警 + iEmsAlarmRecordsService.addEmptyDataAlarmRecord(SITE_ID,deviceId); return; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index 6e38d64..f5ecb3b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -1,10 +1,14 @@ package com.xzzn.ems.service.impl; -import java.util.List; -import java.util.Random; +import java.util.*; +import java.util.concurrent.TimeUnit; +import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.domain.entity.SysUser; import com.xzzn.common.core.domain.model.LoginUser; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.AlarmLevelStatus; +import com.xzzn.common.enums.AlarmStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsTicket; @@ -36,6 +40,13 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService private EmsTicketMapper emsTicketMapper; @Autowired private SysUserMapper sysUserMapper; + @Autowired + private RedisCache redisCache; + + private Map alarmMap = new HashMap() {{ + put("021_DDS_01", "PCS"); + put("021_FXX_01", "PCS01"); + }}; /** * 查询告警记录 @@ -153,6 +164,85 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService return ticketNo; } + // 订阅失败-增加告警 + @Override + public void addSubFailedAlarmRecord(String topic) { + EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); + String siteId = ""; + String deviceId = ""; + String content = "topic订阅失败"; + String status = AlarmLevelStatus.EMERGENCY.getCode(); + + if (topic.startsWith("021_DDS")) { + siteId = "021_DDS_01"; + deviceId = alarmMap.get("021_DDS_01"); + } else if (topic.startsWith("021_FXX")) { + siteId = "021_FXX_01"; + deviceId = alarmMap.get("021_FXX_01"); + } + // 先判断是否存在未处理的订阅失败告警 + emsAlarmRecords = redisCache.getCacheObject(RedisKeyConstants.TOPIC_FAILED_ALRAM_RECORD + siteId + "_" + deviceId); + if (emsAlarmRecords != null) { + return; + } + emsAlarmRecords = createAlarmAtPcs(siteId,deviceId,content,status); + emsAlarmRecordsMapper.insertEmsAlarmRecords(emsAlarmRecords); + + // 存redis便于订阅成功后处理 + redisCache.setCacheObject(RedisKeyConstants.TOPIC_FAILED_ALRAM_RECORD + siteId + "_" + deviceId, emsAlarmRecords); + } + + @Override + public void checkFailedRecord(String topic) { + String siteId = ""; + String deviceId = ""; + + if (topic.startsWith("021_DDS")) { + siteId = "021_DDS_01"; + deviceId = alarmMap.get("021_DDS_01"); + } else if (topic.startsWith("021_FXX")) { + siteId = "021_FXX_01"; + deviceId = alarmMap.get("021_FXX_01"); + } + EmsAlarmRecords emsAlarmRecords = redisCache.getCacheObject(RedisKeyConstants.TOPIC_FAILED_ALRAM_RECORD + siteId + "_" + deviceId); + if (emsAlarmRecords != null) { + // 存在更新为已处理,并清除redis + emsAlarmRecords.setStatus(AlarmStatus.DONE.getCode()); + emsAlarmRecords.setAlarmEndTime(new Date()); + emsAlarmRecords.setUpdateTime(DateUtils.getNowDate()); + emsAlarmRecords.setUpdateBy("system"); + emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords); + } + } + + @Override + public void addEmptyDataAlarmRecord(String siteId, String topicDevice) { + EmsAlarmRecords emsAlarmRecords = redisCache.getCacheObject(RedisKeyConstants.TOPIC_EMPTY_ALARM_RECORD + siteId + "_" + topicDevice); + if (emsAlarmRecords != null) { + return; + } + emsAlarmRecords = createAlarmAtPcs(siteId,topicDevice,"topic内没有数据",AlarmLevelStatus.EMERGENCY.getCode()); + emsAlarmRecordsMapper.insertEmsAlarmRecords(emsAlarmRecords); + + // 存redis-防止重复插入-有效期一天 + redisCache.setCacheObject(RedisKeyConstants.TOPIC_EMPTY_ALARM_RECORD + siteId + "_" + topicDevice, emsAlarmRecords,1, TimeUnit.DAYS); + } + + + private EmsAlarmRecords createAlarmAtPcs(String siteId, String deviceId,String content,String level) { + EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); + emsAlarmRecords.setSiteId(siteId); + emsAlarmRecords.setDeviceId(deviceId); + emsAlarmRecords.setAlarmContent(content); + emsAlarmRecords.setAlarmLevel(level); + emsAlarmRecords.setAlarmStartTime(new Date()); + emsAlarmRecords.setStatus(AlarmStatus.WAITING.getCode()); + emsAlarmRecords.setDeviceType("TCP"); + emsAlarmRecords.setCreateBy("system"); + emsAlarmRecords.setCreateTime(new Date()); + return emsAlarmRecords; + } + private String createRandomTicketNo() { String ticketNo = ""; String nowDate = DateUtils.dateTime(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index fe2d5ac..625d0cc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -14,6 +14,7 @@ import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.mapper.*; +import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; import org.apache.commons.logging.Log; @@ -63,6 +64,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsDailyChargeDataMapper emsDailyChargeDataMapper; @Autowired private EmsDhDataMapper emsDhDataMapper; + @Autowired + private IEmsAlarmRecordsService iEmsAlarmRecordsService; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -82,6 +85,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl log.info("deviceId:" + deviceId); boolean isEmpty = checkJsonDataEmpty(jsonData); if (isEmpty) { + // 添加设备告警 + iEmsAlarmRecordsService.addEmptyDataAlarmRecord(SITE_ID,deviceId); return; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index e47c236..f2d5952 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -19,12 +19,11 @@ - - select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, device_name, ticket_no from ems_alarm_records + select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, ticket_no from ems_alarm_records @@ -64,7 +62,6 @@ remark, site_id, device_id, - device_name, ticket_no, @@ -81,7 +78,6 @@ #{remark}, #{siteId}, #{deviceId}, - #{deviceName}, #{ticketNo}, @@ -102,7 +98,6 @@ remark = #{remark}, site_id = #{siteId}, device_id = #{deviceId}, - device_name = #{deviceName}, ticket_no = #{ticketNo}, where id = #{id} @@ -120,13 +115,13 @@ select COUNT(*) as alarmNum from ems_alarm_records where site_id = #{siteId} and device_id = #{deviceId} + and status 1 + + + \ No newline at end of file -- 2.49.0 From 8e8c57cb648b2588f75b86d93b80fc8d3e4a4c8b Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 23 Sep 2025 13:59:45 +0800 Subject: [PATCH 142/336] =?UTF-8?q?=E5=A5=89=E8=B4=A4=20alarm=20topic?= =?UTF-8?q?=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 6 + .../xzzn/common/core/redis/RedisCache.java | 24 +++ .../manager/ModbusConnectionManager.java | 10 ++ .../xzzn/ems/domain/EmsAlarmMatchData.java | 117 +++++++++++++++ .../com/xzzn/ems/domain/EmsAlarmRecords.java | 35 +++-- .../ems/mapper/EmsAlarmMatchDataMapper.java | 63 ++++++++ .../ems/mapper/EmsAlarmRecordsMapper.java | 6 + .../ems/service/IEmsAlarmRecordsService.java | 9 ++ .../ems/service/IFXXDataProcessService.java | 1 + .../impl/EmsAlarmRecordsServiceImpl.java | 33 ++++- .../impl/FXXDataProcessServiceImpl.java | 140 ++++++++++++++++++ .../mapper/ems/EmsAlarmMatchDataMapper.xml | 100 +++++++++++++ .../mapper/ems/EmsAlarmRecordsMapper.xml | 62 +++++++- .../mapper/ems/EmsAmmeterDataMapper.xml | 2 +- 14 files changed, 593 insertions(+), 15 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmMatchData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmMatchDataMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsAlarmMatchDataMapper.xml diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index eaab5be..5edda60 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -61,4 +61,10 @@ public class RedisKeyConstants public static final String TOPIC_FAILED_ALRAM_RECORD = "topic_failed_"; /** topic 内没有数据设备维度告警 */ public static final String TOPIC_EMPTY_ALARM_RECORD = "topic_empty_"; + + /** 告警匹配信息 */ + public static final String ALARM_MATCH_INFO = "alarm_message_info"; + + /** 现有的告警数据 */ + public static final String LATEST_ALARM_RECORD = "LATEST_ALARM_RECORD"; } diff --git a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java index 99829d4..b234b47 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java +++ b/ems-common/src/main/java/com/xzzn/common/core/redis/RedisCache.java @@ -241,6 +241,18 @@ public class RedisCache return redisTemplate.opsForHash().multiGet(key, hKeys); } + /** + * 删除Hash中的多条数据 + * + * @param key Redis键 + * @param hKey Hash键 + * @return 是否成功 + */ + public boolean deleteAllCacheMapValue(final String key, final Object[] hKey) + { + return redisTemplate.opsForHash().delete(key, hKey) > 0; + } + /** * 删除Hash中的某条数据 * @@ -253,6 +265,18 @@ public class RedisCache return redisTemplate.opsForHash().delete(key, hKey) > 0; } + + /** + * 批量往Hash中存入数据 + * + * @param key Redis键 + * @param value 值 + */ + public void setAllCacheMapValue(final String key, final Map value) + { + redisTemplate.opsForHash().putAll(key, value); + } + /** * 获得缓存的基本对象列表 * diff --git a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java index 9529d6d..98e83a2 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java +++ b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java @@ -3,6 +3,7 @@ package com.xzzn.framework.manager; import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.service.IEmsAlarmRecordsService; import org.apache.commons.pool2.impl.GenericObjectPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +36,8 @@ public class ModbusConnectionManager implements ApplicationRunner { private ScheduledExecutorService scheduler; @Autowired private EmsDevicesSettingMapper deviceRepo; + @Autowired + private IEmsAlarmRecordsService iEmsAlarmRecordsService; @Override public void run(ApplicationArguments args) throws Exception { @@ -46,8 +49,15 @@ public class ModbusConnectionManager implements ApplicationRunner { scheduler = Executors.newSingleThreadScheduledExecutor(); scheduler.scheduleAtFixedRate(this::heartbeatCheck, 1, 5, TimeUnit.MINUTES); logger.info("Modbus连接管理器已初始化"); + + // 初始数据工作 + initData(); } + private void initData() { + // 初始化-告警数据 + iEmsAlarmRecordsService.initAlarmMatchInfo(); + } /** * 获取连接(带自动创建和缓存) */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmMatchData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmMatchData.java new file mode 100644 index 0000000..e6f03c9 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmMatchData.java @@ -0,0 +1,117 @@ +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_alarm_match_data + * + * @author xzzn + * @date 2025-09-22 + */ +public class EmsAlarmMatchData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 告警点位 */ + @Excel(name = "告警点位") + private String point; + + /** 告警值 */ + @Excel(name = "告警值") + private Long alarmData; + + /** 告警描述 */ + @Excel(name = "告警描述") + private String alarmDescription; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备类型 */ + @Excel(name = "设备类型") + private String deviceCategory; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setPoint(String point) + { + this.point = point; + } + + public String getPoint() + { + return point; + } + + public void setAlarmData(Long alarmData) + { + this.alarmData = alarmData; + } + + public Long getAlarmData() + { + return alarmData; + } + + public void setAlarmDescription(String alarmDescription) + { + this.alarmDescription = alarmDescription; + } + + public String getAlarmDescription() + { + return alarmDescription; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public void setDeviceCategory(String deviceCategory) + { + this.deviceCategory = deviceCategory; + } + + public String getDeviceCategory() + { + return deviceCategory; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("point", getPoint()) + .append("alarmData", getAlarmData()) + .append("alarmDescription", getAlarmDescription()) + .append("siteId", getSiteId()) + .append("deviceCategory", getDeviceCategory()) + .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/EmsAlarmRecords.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java index 72ec48a..7bd68ac 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsAlarmRecords.java @@ -24,8 +24,8 @@ public class EmsAlarmRecords extends BaseEntity @Excel(name = "设备类型") private String deviceType; - /** 告警等级 */ - @Excel(name = "告警等级") + /** 告警等级:A-提示 B-一般 C-严重 D紧急 */ + @Excel(name = "告警等级:A-提示 B-一般 C-严重 D紧急") private String alarmLevel; /** 告警内容 */ @@ -42,8 +42,12 @@ public class EmsAlarmRecords extends BaseEntity @Excel(name = "告警结束时间", width = 30, dateFormat = "yyyy-MM-dd") private Date alarmEndTime; - /** 状态 */ - @Excel(name = "状态") + /** 告警点位 */ + @Excel(name = "告警点位") + private String alarmPoint; + + /** 状态:0-待处理 1-已处理 2-处理中 */ + @Excel(name = "状态:0-待处理 1-已处理 2-处理中") private String status; /** 站点id */ @@ -118,6 +122,16 @@ public class EmsAlarmRecords extends BaseEntity return alarmEndTime; } + public void setAlarmPoint(String alarmPoint) + { + this.alarmPoint = alarmPoint; + } + + public String getAlarmPoint() + { + return alarmPoint; + } + public void setStatus(String status) { this.status = status; @@ -148,12 +162,14 @@ public class EmsAlarmRecords extends BaseEntity return deviceId; } - public String getTicketNo() { - return ticketNo; + public void setTicketNo(String ticketNo) + { + this.ticketNo = ticketNo; } - public void setTicketNo(String ticketNo) { - this.ticketNo = ticketNo; + public String getTicketNo() + { + return ticketNo; } @Override @@ -165,6 +181,7 @@ public class EmsAlarmRecords extends BaseEntity .append("alarmContent", getAlarmContent()) .append("alarmStartTime", getAlarmStartTime()) .append("alarmEndTime", getAlarmEndTime()) + .append("alarmPoint", getAlarmPoint()) .append("status", getStatus()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) @@ -176,4 +193,4 @@ public class EmsAlarmRecords extends BaseEntity .append("ticketNo", getTicketNo()) .toString(); } -} +} \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmMatchDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmMatchDataMapper.java new file mode 100644 index 0000000..c4cbe65 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmMatchDataMapper.java @@ -0,0 +1,63 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import java.util.Map; + +import com.xzzn.ems.domain.EmsAlarmMatchData; + +/** + * 告警点位匹配数据Mapper接口 + * + * @author xzzn + * @date 2025-09-22 + */ +public interface EmsAlarmMatchDataMapper +{ + /** + * 查询告警点位匹配数据 + * + * @param id 告警点位匹配数据主键 + * @return 告警点位匹配数据 + */ + public EmsAlarmMatchData selectEmsAlarmMatchDataById(Long id); + + /** + * 查询告警点位匹配数据列表 + * + * @param emsAlarmMatchData 告警点位匹配数据 + * @return 告警点位匹配数据集合 + */ + public List selectEmsAlarmMatchDataList(EmsAlarmMatchData emsAlarmMatchData); + + /** + * 新增告警点位匹配数据 + * + * @param emsAlarmMatchData 告警点位匹配数据 + * @return 结果 + */ + public int insertEmsAlarmMatchData(EmsAlarmMatchData emsAlarmMatchData); + + /** + * 修改告警点位匹配数据 + * + * @param emsAlarmMatchData 告警点位匹配数据 + * @return 结果 + */ + public int updateEmsAlarmMatchData(EmsAlarmMatchData emsAlarmMatchData); + + /** + * 删除告警点位匹配数据 + * + * @param id 告警点位匹配数据主键 + * @return 结果 + */ + public int deleteEmsAlarmMatchDataById(Long id); + + /** + * 批量删除告警点位匹配数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsAlarmMatchDataByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java index 09cdcd4..41751b6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java @@ -94,4 +94,10 @@ public interface EmsAlarmRecordsMapper //获取未处理的订阅失败告警 public EmsAlarmRecords getFailedRecord(@Param("siteId")String siteId, @Param("deviceId")String deviceId, @Param("content") String content,@Param("status")String status); + + // 批量处理告警数据 + public void batchUpsert(@Param("recordsList")List recordsList); + + // 获取所有没有处理完成的告警记录 + public List getAllUnfinishedRecords(@Param("needUpdateKeys")List needUpdateKeys,@Param("siteId") String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java index 94c7743..ece699c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -83,4 +83,13 @@ public interface IEmsAlarmRecordsService // topic 内没有数据,按照设备维度告警 public void addEmptyDataAlarmRecord(String siteId, String deviceId); + + // 告警字段和告警信息 + public void initAlarmMatchInfo(); + + // 获取所有没有处理完成的告警记录 + public List getAllUnfinishedRecords(List needUpdateKeys, String siteId); + + // 批量处理告警数据 + public void batchProcessAlarmRecords(List recordsList); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java b/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java index 1c8219d..bdf80fb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java @@ -4,4 +4,5 @@ public interface IFXXDataProcessService { public void handleFxData(String message); + public void handleFxAlarmData(String message); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index f5ecb3b..e6aa6dc 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -2,18 +2,20 @@ package com.xzzn.ems.service.impl; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.domain.entity.SysUser; -import com.xzzn.common.core.domain.model.LoginUser; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.AlarmLevelStatus; import com.xzzn.common.enums.AlarmStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsAlarmMatchData; import com.xzzn.ems.domain.EmsTicket; import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; +import com.xzzn.ems.mapper.EmsAlarmMatchDataMapper; import com.xzzn.ems.mapper.EmsTicketMapper; import com.xzzn.ems.service.IEmsTicketService; import com.xzzn.system.mapper.SysUserMapper; @@ -35,8 +37,6 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService @Autowired private EmsAlarmRecordsMapper emsAlarmRecordsMapper; @Autowired - private IEmsTicketService emsTicketService; - @Autowired private EmsTicketMapper emsTicketMapper; @Autowired private SysUserMapper sysUserMapper; @@ -47,6 +47,8 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService put("021_DDS_01", "PCS"); put("021_FXX_01", "PCS01"); }}; + @Autowired + private EmsAlarmMatchDataMapper emsAlarmMatchDataMapper; /** * 查询告警记录 @@ -228,7 +230,6 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService redisCache.setCacheObject(RedisKeyConstants.TOPIC_EMPTY_ALARM_RECORD + siteId + "_" + topicDevice, emsAlarmRecords,1, TimeUnit.DAYS); } - private EmsAlarmRecords createAlarmAtPcs(String siteId, String deviceId,String content,String level) { EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); emsAlarmRecords.setSiteId(siteId); @@ -251,4 +252,28 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService } + @Override + public void initAlarmMatchInfo() { + List alarmPointList = emsAlarmMatchDataMapper.selectEmsAlarmMatchDataList(null); + Map resultMap = alarmPointList.stream() + .collect(Collectors.toMap( + data->data.getDeviceCategory()+"_"+data.getPoint(), + data->data, + (existing, replacement) -> replacement + )); + // 存redis + redisCache.setCacheObject(RedisKeyConstants.ALARM_MATCH_INFO,resultMap, 1, TimeUnit.DAYS); + } + + @Override + public List getAllUnfinishedRecords(List needUpdateKeys, String siteId) { + return emsAlarmRecordsMapper.getAllUnfinishedRecords(needUpdateKeys,siteId); + } + + @Override + public void batchProcessAlarmRecords(List recordsList) { + emsAlarmRecordsMapper.batchUpsert(recordsList); + } + + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 625d0cc..5da9227 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -27,6 +27,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.stream.Collectors; @Service public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXDataProcessService { @@ -767,6 +768,145 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return records; } + @Override + public void handleFxAlarmData(String message) { + JSONArray arraylist = JSONArray.parseArray(message); + + // 获取redis缓存-告警信息 + Map alarmMatchInfo= redisCache.getCacheObject(RedisKeyConstants.ALARM_MATCH_INFO); + + for (int i = 0; i < arraylist.size(); i++) { + JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); + + String deviceId = obj.get("Device").toString(); + String jsonData = obj.get("Data").toString(); + + log.info("deviceId:" + deviceId); + + if (deviceId.contains("BMSD")) { + alarmDataProcess(deviceId, jsonData, alarmMatchInfo, DeviceCategory.STACK.getCode()); + } else if (deviceId.contains("BMSC")) { + alarmDataProcess(deviceId, jsonData, alarmMatchInfo, DeviceCategory.CLUSTER.getCode()); + } else if (deviceId.contains("PCS")) { + alarmDataProcess(deviceId, jsonData, alarmMatchInfo, DeviceCategory.PCS.getCode()); + } + } + } + + private void alarmDataProcess(String deviceId, String jsonData, + Map alarmInfoData, String category) { + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + String redisKey = RedisKeyConstants.LATEST_ALARM_RECORD + "_" + SITE_ID +"_" + deviceId; + // 获取redis里面的当前有效告警遍历添加到已存在告警key里面 + Map currentAlarm = redisCache.getCacheMap(redisKey); + final Set currentAlarmKeys = new HashSet<>(); + if (currentAlarm != null && !currentAlarm.isEmpty()) { + currentAlarm.keySet().stream() + .filter(Objects::nonNull) + .map(Object::toString) + .forEach(currentAlarmKeys::add); + } + + // 结合同步数据,筛选簇需要更新的告警信息 + List needUpdateKeys = obj.entrySet().stream() + .filter(entry -> { + Object valueObj = entry.getValue(); + if (valueObj == null) { + return false; + } + int value = Integer.parseInt(valueObj.toString()); + return value == 0 && currentAlarmKeys.contains(entry.getKey()); + }) + .map(Map.Entry::getKey) + .collect(Collectors.toList()); + + // 批量查询数据库-需要更新的数据 + Map needUpdateMap = new HashMap<>(); + if (!needUpdateKeys.isEmpty()) { + List records = iEmsAlarmRecordsService.getAllUnfinishedRecords(needUpdateKeys,SITE_ID); + // 转为Map便于快速获取 + needUpdateMap = records.stream() + .collect(Collectors.toMap( + EmsAlarmRecords::getAlarmPoint, + record -> record + )); + } + + + List saveOrUpdateList = new ArrayList<>(); + List newAddRecordList = new ArrayList<>(); + List toRemoveFromRedis = new ArrayList<>(); + + // 遍历数据map + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + Integer value = (Integer) entry.getValue(); + Boolean isCurrentAlarm = currentAlarmKeys.contains(key); + + // 值为 1且不在当前告警里面 - 新增告警 + if (value == 1 && !isCurrentAlarm) { + String matchRedisKey = category + "_" + key; + Object cacheObj = alarmInfoData.get(matchRedisKey); + if (cacheObj == null) { + // 处理空数据逻辑 + return; + } + EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class); + EmsAlarmRecords emsAlarmRecord = convertAlarmRecord(deviceId,matchInfo); + saveOrUpdateList.add(emsAlarmRecord); + newAddRecordList.add(emsAlarmRecord); + } else if (value == 0 && isCurrentAlarm) {// 值为 0且在当前告警里面 - 更新告警已处理 + EmsAlarmRecords existingAlarm = needUpdateMap.get(key); + if (existingAlarm != null) { + existingAlarm.setStatus(AlarmStatus.DONE.getCode()); + existingAlarm.setUpdateTime(new Date()); + existingAlarm.setAlarmEndTime(new Date()); + saveOrUpdateList.add(existingAlarm); + toRemoveFromRedis.add(key); + } + } + } + + // 批量处理插入和更新操作 + if (saveOrUpdateList != null && saveOrUpdateList.size() > 0) { + iEmsAlarmRecordsService.batchProcessAlarmRecords(saveOrUpdateList); + } + // 已处理的从redis里面删除 + if (!toRemoveFromRedis.isEmpty()) { + redisCache.deleteAllCacheMapValue(RedisKeyConstants.LATEST_ALARM_RECORD + SITE_ID,toRemoveFromRedis.toArray()); + } + // 批量添加新增的告警到Redis + Map newAlarms = newAddRecordList.stream() + .filter(a -> !AlarmStatus.DONE.getCode().equals(a.getStatus())) + .collect(Collectors.toMap(EmsAlarmRecords::getAlarmPoint, a -> a)); + if (!newAlarms.isEmpty()) { + // 本次新增的放入redis + redisCache.setAllCacheMapValue(redisKey, newAlarms); + } + } + + private EmsAlarmRecords convertAlarmRecord(String deviceId, EmsAlarmMatchData matchInfo) { + EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); + emsAlarmRecords.setSiteId(SITE_ID); + emsAlarmRecords.setDeviceId(deviceId); + emsAlarmRecords.setDeviceType(DeviceType.TCP.toString()); + emsAlarmRecords.setAlarmLevel(AlarmLevelStatus.GENERAL.getCode()); + emsAlarmRecords.setStatus(AlarmStatus.WAITING.getCode()); + emsAlarmRecords.setAlarmStartTime(DateUtils.getNowDate()); + emsAlarmRecords.setCreateTime(DateUtils.getNowDate()); + emsAlarmRecords.setCreateBy("system"); + emsAlarmRecords.setUpdateTime(DateUtils.getNowDate()); + emsAlarmRecords.setUpdateBy("system"); + + if (matchInfo != null) { + emsAlarmRecords.setAlarmPoint(matchInfo.getPoint()); + emsAlarmRecords.setAlarmContent(matchInfo.getAlarmDescription()); + } + return emsAlarmRecords; + } + // 空数据不处理 private boolean checkJsonDataEmpty(String jsonData) { boolean flag = false; diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmMatchDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmMatchDataMapper.xml new file mode 100644 index 0000000..7f1bd02 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmMatchDataMapper.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + select id, point, alarm_data, alarm_description, site_id, device_category, create_by, create_time, update_by, update_time, remark from ems_alarm_match_data + + + + + + + + insert into ems_alarm_match_data + + point, + alarm_data, + alarm_description, + site_id, + device_category, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{point}, + #{alarmData}, + #{alarmDescription}, + #{siteId}, + #{deviceCategory}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_alarm_match_data + + point = #{point}, + alarm_data = #{alarmData}, + alarm_description = #{alarmDescription}, + site_id = #{siteId}, + device_category = #{deviceCategory}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_alarm_match_data where id = #{id} + + + + delete from ems_alarm_match_data where id in + + #{id} + + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index f2d5952..8b1dcd0 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -11,6 +11,7 @@ + @@ -23,7 +24,7 @@ - select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, ticket_no from ems_alarm_records + select id, device_type, alarm_level, alarm_content, alarm_start_time, alarm_end_time, alarm_point, status, create_by, create_time, update_by, update_time, remark, site_id, device_id, ticket_no from ems_alarm_records + + + + + INSERT into ems_alarm_records ( + id, + device_type, + alarm_level, + alarm_content, + alarm_start_time, + alarm_end_time, + alarm_point, + status, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + ticket_no + ) values + + ( + #{item.id}, + #{item.deviceType}, + #{item.alarmLevel}, + #{item.alarmContent}, + #{item.alarmStartTime}, + #{item.alarmEndTime}, + #{item.alarmPoint}, + #{item.status}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.remark}, + #{item.siteId}, + #{item.deviceId}, + #{item.ticketNo} + ) + + on duplicate key update + alarm_end_time = values(alarm_end_time), + status = values(status), + device_id = values(device_id) + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 1c69618..13bfcb9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -984,7 +984,7 @@ SELECT latest.statisDate, avg(t.avg_cell_temp) as avgTemp - FROM ( SELECT p.site_id, p.device_id, DATE_FORMAT( p.update_time, '%H:00') AS statisDate, MAX(p.update_time) AS max_update_time + FROM ( SELECT p.site_id, p.device_id, DATE_FORMAT( p.update_time, '%Y-%m-%d %H:00') AS statisDate, MAX(p.update_time) AS max_update_time FROM ems_battery_cluster p GROUP BY p.site_id, p.device_id, statisDate diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 2467e79..c2520e3 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -449,7 +449,7 @@ avg(t.stack_soc) as avgSoc, avg(t.stack_soh) as avgSoh, avg(t.avg_temperature) as avgTemp - from ( SELECT p.site_id, p.device_id, DATE_FORMAT(p.update_time, '%H:00') AS dateHour,MAX(p.update_time) as max_update_time + from ( SELECT p.site_id, p.device_id, DATE_FORMAT(p.update_time, '%Y-%m-%d %H:00') AS dateHour,MAX(p.update_time) as max_update_time FROM ems_battery_stack p GROUP BY p.site_id,p.device_id,dateHour diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index ed73fe0..1bf9b03 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -335,5 +335,8 @@ and t.data_point_name like CONCAT('%', #{dataPointName}, '%') + + and t.data_point like CONCAT('%', #{dataPoint}, '%') + \ No newline at end of file -- 2.49.0 From 7cd5a9b1315d6d652b45b76d595ceb1e1c268193 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 23 Sep 2025 15:04:02 +0800 Subject: [PATCH 145/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=8D=87=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 7 ++- .../ems/service/IEmsDeviceSettingService.java | 2 +- .../impl/EmsDeviceSettingServiceImpl.java | 63 +++++++++++-------- 3 files changed, 41 insertions(+), 31 deletions(-) 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 7727c48..0d91534 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 @@ -147,10 +147,11 @@ public class EmsSiteConfigController extends BaseController{ */ @GetMapping("/getDevicePointList") public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceId, - @RequestParam String deviceCategory, String dataPointName, - String dataPoint) + @RequestParam String deviceCategory, String sortMethod, + String dataPointName, String dataPoint) { - List result = iEmsDeviceSettingService.getSingleSiteDevicePoints(siteId,deviceId,deviceCategory,dataPointName,dataPoint); + List result = iEmsDeviceSettingService.getSingleSiteDevicePoints( + siteId,deviceId,deviceCategory,dataPointName,dataPoint,sortMethod); return getDataTable2(result); } } 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 70e3aca..a578449 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 @@ -25,5 +25,5 @@ public interface IEmsDeviceSettingService public List getDeviceCategory(); public List getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory, - String dataPointName, String dataPoint); + String dataPointName, String dataPoint, String sortMethod); } 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 755d35c..069d4ab 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,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; /** * 站点信息 服务层实现 @@ -120,41 +121,49 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService @Override public List getSingleSiteDevicePoints(String siteId, String deviceId, - String deviceCategory, String dataPointName,String dataPoint) { + String deviceCategory, String dataPointName, + String dataPoint, String sortMethod) { List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory,dataPointName,dataPoint); // 电动所的电池簇特殊处理-来源pcs+bmsd if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { response = specialDealWithDDSCluster(response,siteId,deviceId); - return response; - } - - // 从redis取最新数据 - //String test = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); - JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); - if(mqttJson == null){ - return response; - } - String deviceFromMqtt = mqttJson.get("Device").toString(); - String jsonData = mqttJson.get("Data").toString(); - if (StringUtils.isEmpty(jsonData) || !deviceId.equals(deviceFromMqtt)) { - return response; - } - - Map obj = JSON.parseObject(jsonData, new TypeReference>() {}); - for (PointQueryResponse pointInfo : response) { - String dataKey = pointInfo.getDataPoint(); - int isNeedDeviceId = pointInfo.getIsNeedDeviceId(); - if (isNeedDeviceId == 1) {// 需要根据deviceId拼接point - dataKey = deviceId + dataKey; - pointInfo.setDataPoint(dataKey); + } else { + // 从redis取最新数据 + JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); + if(mqttJson == null){ + return response; + } + String deviceFromMqtt = mqttJson.get("Device").toString(); + String jsonData = mqttJson.get("Data").toString(); + if (StringUtils.isEmpty(jsonData) || !deviceId.equals(deviceFromMqtt)) { + return response; + } + + Map obj = JSON.parseObject(jsonData, new TypeReference>() {}); + for (PointQueryResponse pointInfo : response) { + String dataKey = pointInfo.getDataPoint(); + int isNeedDeviceId = pointInfo.getIsNeedDeviceId(); + if (isNeedDeviceId == 1) {// 需要根据deviceId拼接point + dataKey = deviceId + dataKey; + pointInfo.setDataPoint(dataKey); + } + pointInfo.setPointValue(obj.get(dataKey)); + Long updateTime = Long.valueOf(mqttJson.get("timestamp").toString()); + Date latestUpdateTime = convertUpdateTime(updateTime); + pointInfo.setUpdateTime(latestUpdateTime); } - pointInfo.setPointValue(obj.get(dataKey)); - Long updateTime = Long.valueOf(mqttJson.get("timestamp").toString()); - Date latestUpdateTime = convertUpdateTime(updateTime); - pointInfo.setUpdateTime(latestUpdateTime); } + if (response == null || response.isEmpty()) { + return response; + } + // 结果排序 + if (sortMethod==null || sortMethod.isEmpty() || "asc".equals(sortMethod)) {// 升序 + response = response.stream().sorted(Comparator.comparing(PointQueryResponse::getUpdateTime)).collect(Collectors.toList()); + } else if ("desc".equals(sortMethod)) {//降序 + response = response.stream().sorted(Comparator.comparing(PointQueryResponse::getUpdateTime).reversed()).collect(Collectors.toList()); + } return response; } -- 2.49.0 From 2810f5e20414cb788dfe2aa260d630e1f8029d8f Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 24 Sep 2025 14:07:54 +0800 Subject: [PATCH 146/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=80=BC=E5=8F=8D?= =?UTF-8?q?=E5=90=91=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/ems/EmsSiteConfigController.java | 10 ++++------ .../com/xzzn/ems/service/IEmsDeviceSettingService.java | 4 ++-- .../java/com/xzzn/ems/service/ISingleSiteService.java | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) 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 0d91534..cc3c17a 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 @@ -7,14 +7,15 @@ 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.EmsPointMatch; import com.xzzn.ems.domain.EmsSiteSetting; +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; @@ -146,12 +147,9 @@ public class EmsSiteConfigController extends BaseController{ * 单个站点单个设备点位查询 */ @GetMapping("/getDevicePointList") - public TableDataInfo getDevicePointList(@RequestParam String siteId,@RequestParam String deviceId, - @RequestParam String deviceCategory, String sortMethod, - String dataPointName, String dataPoint) + public TableDataInfo getDevicePointList(@Validated PointDataRequest request) { - List result = iEmsDeviceSettingService.getSingleSiteDevicePoints( - siteId,deviceId,deviceCategory,dataPointName,dataPoint,sortMethod); + List result = iEmsDeviceSettingService.getSingleSiteDevicePoints(request); return getDataTable2(result); } } 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 a578449..87cf5d9 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 @@ -3,6 +3,7 @@ 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.PointDataRequest; import com.xzzn.ems.domain.vo.PointQueryResponse; import java.util.List; @@ -24,6 +25,5 @@ public interface IEmsDeviceSettingService public List getDeviceCategory(); - public List getSingleSiteDevicePoints(String siteId, String deviceId, String deviceCategory, - String dataPointName, String dataPoint, String sortMethod); + public List getSingleSiteDevicePoints(PointDataRequest request); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 88358e1..9a0fe0a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -30,7 +30,7 @@ public interface ISingleSiteService public List getClusterDataInfoList(String clusterDeviceId,String siteId, String stackDeviceId, String batteryId); - public AmmeterDataResponse getAmmeterDataList(String siteId); + public List getAmmeterDataList(String siteId); public SiteMonitorRuningInfoVo getRunningGraphStackTemp(String siteId); -- 2.49.0 From f3b34e7fb5799f7d2cc97089a3ee0190935d7a66 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 24 Sep 2025 14:09:29 +0800 Subject: [PATCH 147/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=80=BC=E5=8F=8D?= =?UTF-8?q?=E5=90=91=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/EmsDeviceSettingServiceImpl.java | 53 +++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) 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 069d4ab..ac45ec4 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 @@ -9,6 +9,7 @@ import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.vo.PointDataRequest; import com.xzzn.ems.domain.vo.PointQueryResponse; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsPointMatchMapper; @@ -16,6 +17,7 @@ import com.xzzn.ems.service.IEmsDeviceSettingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -120,10 +122,13 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService } @Override - public List getSingleSiteDevicePoints(String siteId, String deviceId, - String deviceCategory, String dataPointName, - String dataPoint, String sortMethod) { - List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory,dataPointName,dataPoint); + public List getSingleSiteDevicePoints(PointDataRequest request) { + String siteId = request.getSiteId(); + String deviceId = request.getDeviceId(); + String deviceCategory = request.getDeviceCategory(); + + List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory, + request.getDataPointName(),request.getDataPoint()); // 电动所的电池簇特殊处理-来源pcs+bmsd if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { @@ -158,7 +163,30 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService if (response == null || response.isEmpty()) { return response; } + BigDecimal lowerBound = request.getLower(); + BigDecimal upperBound = request.getUpper(); + // 数据反向筛选 + if (lowerBound == null && upperBound == null) { + return response; + } + response = response.stream() .filter(point -> { + Object dataValue = point.getPointValue(); + if (dataValue == null) { + return false; + } + // 转换为BigDecimal进行精确比较(避免double精度损失) + BigDecimal value = parseToBigDecimal(dataValue); + if (value == null) { + return false; + } + // 比较:使用BigDecimal的compareTo方法 + boolean meetLower = (lowerBound == null) || (value.compareTo(lowerBound) >= 0); + boolean meetUpper = (upperBound == null) || (value.compareTo(upperBound) <= 0); + return meetLower && meetUpper; + }).collect(Collectors.toList()); + // 结果排序 + String sortMethod = request.getSortMethod(); if (sortMethod==null || sortMethod.isEmpty() || "asc".equals(sortMethod)) {// 升序 response = response.stream().sorted(Comparator.comparing(PointQueryResponse::getUpdateTime)).collect(Collectors.toList()); } else if ("desc".equals(sortMethod)) {//降序 @@ -167,6 +195,23 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService return response; } + // Object转BigDecimal(支持多种类型) + private BigDecimal parseToBigDecimal(Object dataValue) { + if (dataValue instanceof BigDecimal) { + return (BigDecimal) dataValue; + } else if (dataValue instanceof Number) { + return new BigDecimal(((Number) dataValue).toString()); + } else if (dataValue instanceof String) { + try { + return new BigDecimal((String) dataValue); + } catch (NumberFormatException e) { + return null; + } + } else { + return null; + } + } + // 对于dds的电池簇点位最新数据获取特殊处理 private List specialDealWithDDSCluster(List response, String siteId, String deviceId) { JSONObject mergedData = new JSONObject(); -- 2.49.0 From f7515b221be160d9afbf51e7680db496d34ce96b Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 24 Sep 2025 14:10:10 +0800 Subject: [PATCH 148/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=80=BC=E5=8F=8D?= =?UTF-8?q?=E5=90=91=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/vo/PointDataRequest.java | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java new file mode 100644 index 0000000..cdbe913 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java @@ -0,0 +1,94 @@ +package com.xzzn.ems.domain.vo; + + +import javax.validation.constraints.NotBlank; +import java.math.BigDecimal; + +/** + * 设备列表-点位详情-入参 + * + */ +public class PointDataRequest { + /** 站点id */ + @NotBlank(message = "站点ID不能为空") + private String siteId; + /** 设备id */ + @NotBlank(message = "设备ID不能为空") + private String deviceId; + /** 设备类型 */ + @NotBlank(message = "设备类型不能为空") + private String deviceCategory; + /** 排序方式 */ + private String sortMethod; + /** 点位名称-模糊查询 */ + private String dataPointName; + /** 点位-模糊查询 */ + private String dataPoint; + /** 点位数据-范围上下限 */ + private BigDecimal lower; + private BigDecimal upper; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceCategory() { + return deviceCategory; + } + + public void setDeviceCategory(String deviceCategory) { + this.deviceCategory = deviceCategory; + } + + public String getSortMethod() { + return sortMethod; + } + + public void setSortMethod(String sortMethod) { + this.sortMethod = sortMethod; + } + + public String getDataPointName() { + return dataPointName; + } + + public void setDataPointName(String dataPointName) { + this.dataPointName = dataPointName; + } + + public String getDataPoint() { + return dataPoint; + } + + public void setDataPoint(String dataPoint) { + this.dataPoint = dataPoint; + } + + public BigDecimal getLower() { + return lower; + } + + public void setLower(BigDecimal lower) { + this.lower = lower; + } + + public BigDecimal getUpper() { + return upper; + } + + public void setUpper(BigDecimal upper) { + this.upper = upper; + } +} -- 2.49.0 From 9874d6b1ea502663cec2dd69f08172862990187f Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 24 Sep 2025 14:12:37 +0800 Subject: [PATCH 149/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E7=AB=99=E7=9B=91=E6=8E=A7-=E7=94=B5=E8=A1=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/common/enums/AmmeterCategory.java | 6 +- .../ems/domain/vo/AmmeterDataResponse.java | 8 +- ...eterLoadDataVo.java => AmmeterDataVo.java} | 6 +- .../impl/DDSDataProcessServiceImpl.java | 4 +- .../service/impl/SingleSiteServiceImpl.java | 102 ++++++++++-------- 5 files changed, 69 insertions(+), 57 deletions(-) rename ems-system/src/main/java/com/xzzn/ems/domain/vo/{AmmeterLoadDataVo.java => AmmeterDataVo.java} (94%) diff --git a/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java index 406c628..47c8bd6 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/AmmeterCategory.java @@ -7,8 +7,10 @@ package com.xzzn.common.enums; */ public enum AmmeterCategory { - CURRENT_COMB_ACTIVE("1", "当前组合有功电能"), - CURRENT_COMB_REACTIVE("2", "当前组合无功电能"), + CURRENT_FORWARD_ACTIVE("1", "当前正向有功电能"), + CURRENT_FORWARD_REACTIVE("2", "当前正向无功电能"), + CURRENT_REVERSE_ACTIVE("3", "当前反向有功电能"), + CURRENT_REVERSE_REACTIVE("4", "当前反向无功电能"), A_POWER("3", "A相功率"), B_POWER("4", "B相功率"), C_POWER("5", "C相功率"); diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java index b5f0994..7c1eb87 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataResponse.java @@ -1,23 +1,21 @@ package com.xzzn.ems.domain.vo; -import java.util.List; - /** * 电表数据 */ public class AmmeterDataResponse { /** 总表信息 */ - private AmmeterLoadDataVo ammeterLoadData; + private AmmeterDataVo ammeterLoadData; /** 储能表信息 */ private AmmeterMeteDataVo ammeterMeteData; - public AmmeterLoadDataVo getAmmeterLoadData() { + public AmmeterDataVo getAmmeterLoadData() { return ammeterLoadData; } - public void setAmmeterLoadDataVoList(AmmeterLoadDataVo ammeterLoadData) { + public void setAmmeterLoadDataVoList(AmmeterDataVo ammeterLoadData) { this.ammeterLoadData = ammeterLoadData; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java similarity index 94% rename from ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java rename to ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java index 103eebc..54f4b7f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterLoadDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java @@ -6,9 +6,9 @@ import java.util.Date; import java.util.List; /** - * 电表-总表数据 + * 电表数据 */ -public class AmmeterLoadDataVo { +public class AmmeterDataVo { /** 电表名称 */ private String deviceName; @@ -23,7 +23,7 @@ public class AmmeterLoadDataVo { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date dataUpdateTime; - /** 总表数据信息 */ + /** 表数据信息 */ private List loadDataDetailInfo; public String getDeviceName() { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 8efb366..ed70cb8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -845,13 +845,13 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataMete.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); dataMete.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); // 电能设置-正向无功 - dataMete.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); + dataMete.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXZWGDN"))); dataMete.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); dataMete.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); dataMete.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); dataMete.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); // 电能设置-反向无功 - dataMete.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); + dataMete.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXZWGDN"))); dataMete.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); dataMete.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); dataMete.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index f0866e7..bdec05a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -450,38 +450,32 @@ public class SingleSiteServiceImpl implements ISingleSiteService { * @return */ @Override - public AmmeterDataResponse getAmmeterDataList(String siteId) { - AmmeterDataResponse ammeterResponse = new AmmeterDataResponse(); + public List getAmmeterDataList(String siteId) { + List ammeterResponse = new ArrayList<>(); - if (!StringUtils.isEmpty(siteId)) { - // 先获取电表设备 - List> ammeterIdList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.AMMETER.getCode()); + if (StringUtils.isEmpty(siteId)) { + return ammeterResponse; + } - for (Map ammeterDevice : ammeterIdList) { - String ammeterId = ammeterDevice.get("id").toString(); - // 从redis取总表详细数据 - EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); - // 判断电表类型 - if (AMMETER_DEVICE_LOAD.equals(ammeterId)) { - AmmeterLoadDataVo ammeterLoadDataVo = new AmmeterLoadDataVo(); - ammeterLoadDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); - ammeterLoadDataVo.setDeviceId(ammeterDevice.get("id").toString()); - ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : - ammeterDevice.get("communicationStatus").toString()); - // 处理总表数据 - dealAmmeterLoadData(ammeterData,ammeterLoadDataVo); - ammeterResponse.setAmmeterLoadDataVoList(ammeterLoadDataVo); - } else if (AMMETER_DEVICE_METE.equals(ammeterId)) { - AmmeterMeteDataVo ammeterMeteDataVo = new AmmeterMeteDataVo(); - ammeterMeteDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); - ammeterMeteDataVo.setDeviceId(ammeterDevice.get("id").toString()); - ammeterMeteDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : - ammeterDevice.get("communicationStatus").toString()); - // 处理储能表数据 - dealAmmeterMeteData(ammeterData,ammeterMeteDataVo); - ammeterResponse.setAmmeterMeteDataVoList(ammeterMeteDataVo); - } - } + // 先获取电表设备 + List> ammeterIdList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.AMMETER.getCode()); + if (ammeterIdList == null || ammeterIdList.isEmpty()) { + return ammeterResponse; + } + + for (Map ammeterDevice : ammeterIdList) { + String ammeterId = ammeterDevice.get("id").toString(); + // 从redis取总表详细数据 + EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); + + AmmeterDataVo ammeterLoadDataVo = new AmmeterDataVo(); + ammeterLoadDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); + ammeterLoadDataVo.setDeviceId(ammeterDevice.get("id").toString()); + ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : + ammeterDevice.get("communicationStatus").toString()); + // 设置表数据 + dealAmmeterLoadData(ammeterData,ammeterLoadDataVo); + ammeterResponse.add(ammeterLoadDataVo); } return ammeterResponse; } @@ -515,31 +509,49 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } } - private void dealAmmeterLoadData(EmsAmmeterData ammeterData, AmmeterLoadDataVo ammeterDataVo) { + private void dealAmmeterLoadData(EmsAmmeterData ammeterData, AmmeterDataVo ammeterDataVo) { if (ammeterData != null) { // 数据更新时间 ammeterDataVo.setDataUpdateTime(ammeterData.getDataUpdateTime()); List loadDataDetailInfos = new ArrayList<>(); // 拼接数据 - // 组合有功 + // 当前正向有功 LoadDataDetailInfo ammeterDataDetailInfo1 = new LoadDataDetailInfo(); - ammeterDataDetailInfo1.setCategory(AmmeterCategory.CURRENT_COMB_ACTIVE.getInfo()); - ammeterDataDetailInfo1.setTotalKwh(ammeterData.getCurrentCombActiveTotal()); - ammeterDataDetailInfo1.setPeakKwh(ammeterData.getCurrentCombActivePeak()); - ammeterDataDetailInfo1.setHighKwh(ammeterData.getCurrentCombActiveHigh()); - ammeterDataDetailInfo1.setFlatKwh(ammeterData.getCurrentCombActiveFlat()); - ammeterDataDetailInfo1.setValleyKwh(ammeterData.getCurrentCombActiveValley()); + ammeterDataDetailInfo1.setCategory(AmmeterCategory.CURRENT_FORWARD_ACTIVE.getInfo()); + ammeterDataDetailInfo1.setTotalKwh(ammeterData.getCurrentForwardActiveTotal()); + ammeterDataDetailInfo1.setPeakKwh(ammeterData.getCurrentForwardActivePeak()); + ammeterDataDetailInfo1.setHighKwh(ammeterData.getCurrentForwardActiveHigh()); + ammeterDataDetailInfo1.setFlatKwh(ammeterData.getCurrentForwardActiveFlat()); + ammeterDataDetailInfo1.setValleyKwh(ammeterData.getCurrentForwardActiveValley()); loadDataDetailInfos.add(ammeterDataDetailInfo1); - // 组合无功 + // 当前正向无功 LoadDataDetailInfo ammeterDataDetailInfo2 = new LoadDataDetailInfo(); - ammeterDataDetailInfo2.setCategory(AmmeterCategory.CURRENT_COMB_REACTIVE.getInfo()); - ammeterDataDetailInfo2.setTotalKwh(ammeterData.getCurrentCombReactiveTotal()); - ammeterDataDetailInfo2.setPeakKwh(ammeterData.getCurrentCombReactivePeak()); - ammeterDataDetailInfo2.setHighKwh(ammeterData.getCurrentCombReactiveHigh()); - ammeterDataDetailInfo2.setFlatKwh(ammeterData.getCurrentCombReactiveFlat()); - ammeterDataDetailInfo2.setValleyKwh(ammeterData.getCurrentCombReactiveValley()); + ammeterDataDetailInfo2.setCategory(AmmeterCategory.CURRENT_FORWARD_REACTIVE.getInfo()); + ammeterDataDetailInfo2.setTotalKwh(ammeterData.getCurrentForwardReactiveTotal()); + ammeterDataDetailInfo2.setPeakKwh(ammeterData.getCurrentForwardReactivePeak()); + ammeterDataDetailInfo2.setHighKwh(ammeterData.getCurrentForwardReactiveHigh()); + ammeterDataDetailInfo2.setFlatKwh(ammeterData.getCurrentForwardReactiveFlat()); + ammeterDataDetailInfo2.setValleyKwh(ammeterData.getCurrentForwardReactiveValley()); loadDataDetailInfos.add(ammeterDataDetailInfo2); + // 当前反向有功 + LoadDataDetailInfo ammeterDataDetailInfo3 = new LoadDataDetailInfo(); + ammeterDataDetailInfo3.setCategory(AmmeterCategory.CURRENT_REVERSE_ACTIVE.getInfo()); + ammeterDataDetailInfo3.setTotalKwh(ammeterData.getCurrentReverseActiveTotal()); + ammeterDataDetailInfo3.setPeakKwh(ammeterData.getCurrentReverseActivePeak()); + ammeterDataDetailInfo3.setHighKwh(ammeterData.getCurrentReverseActiveHigh()); + ammeterDataDetailInfo3.setFlatKwh(ammeterData.getCurrentReverseActiveFlat()); + ammeterDataDetailInfo3.setValleyKwh(ammeterData.getCurrentReverseActiveValley()); + loadDataDetailInfos.add(ammeterDataDetailInfo3); + // 当前反向无功 + LoadDataDetailInfo ammeterDataDetailInfo4 = new LoadDataDetailInfo(); + ammeterDataDetailInfo4.setCategory(AmmeterCategory.CURRENT_REVERSE_REACTIVE.getInfo()); + ammeterDataDetailInfo4.setTotalKwh(ammeterData.getCurrentReverseReactiveTotal()); + ammeterDataDetailInfo4.setPeakKwh(ammeterData.getCurrentReverseReactivePeak()); + ammeterDataDetailInfo4.setHighKwh(ammeterData.getCurrentReverseReactiveHigh()); + ammeterDataDetailInfo4.setFlatKwh(ammeterData.getCurrentReverseReactiveFlat()); + ammeterDataDetailInfo4.setValleyKwh(ammeterData.getCurrentReverseReactiveValley()); + loadDataDetailInfos.add(ammeterDataDetailInfo4); ammeterDataVo.setLoadDataDetailInfo(loadDataDetailInfos); } -- 2.49.0 From 46135aa2ec1795473c63ee145011679accfba67f Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 24 Sep 2025 22:47:09 +0800 Subject: [PATCH 150/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E7=AB=99=E7=9B=91=E6=8E=A7-=E5=8A=9F=E7=8E=87=E6=9B=B2?= =?UTF-8?q?=E7=BA=BF=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA=E5=89=8D=E4=B8=80?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E6=95=B0=E6=8D=AE=E6=8C=89=E5=88=86=E9=92=9F?= =?UTF-8?q?=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/utils/DateUtils.java | 8 ++ .../xzzn/ems/domain/vo/PowerStatisListVo.java | 7 ++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 1 + .../impl/EmsStatsReportServiceImpl.java | 73 +++++++++++++++++-- .../mapper/ems/EmsAmmeterDataMapper.xml | 14 ++++ 5 files changed, 95 insertions(+), 8 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index cfc07e2..069e852 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -348,4 +348,12 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils .toInstant() ); } + + /** + * 将时间转换为月份(YYYY-MM-DD HH:mm:00) + */ + public static Date timeConvertToDate(LocalDateTime time) { + String dateStr = convertToString(time); + return dateTime(YYYY_MM_DD_HH_MM_SS,dateStr); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java index 330f05f..5bd7671 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java @@ -31,6 +31,13 @@ public class PowerStatisListVo { */ private BigDecimal pvPower; + public PowerStatisListVo(String statisDate, BigDecimal gridPower, BigDecimal storagePower, BigDecimal pvPower) { + this.statisDate = statisDate; + this.gridPower = gridPower; + this.storagePower = storagePower; + this.pvPower = pvPower; + } + public String getStatisDate() { return statisDate; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index 5049e76..b63d33a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -88,4 +88,5 @@ public interface EmsAmmeterDataMapper public List getPowerDataByHour(DateSearchRequest requestVo); public List getPowerDataByDay(DateSearchRequest requestVo); public List getPowerDataByMonth(DateSearchRequest requestVo); + public List getPowerDataByMinutes(DateSearchRequest requestVo); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 03f2ee8..9e75504 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -13,10 +13,9 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.*; import java.util.stream.Collectors; /** @@ -316,13 +315,31 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService public List getPowerDataList(DateSearchRequest requestVo) { List dataList = new ArrayList<>(); - // 默认时间-7天 - dealRequestTime(requestVo); Date startDate = requestVo.getStartDate(); Date endDate = requestVo.getEndDate(); + if (startDate == null || endDate == null) { + // 默认按分钟展示-前一个小时数据 + LocalDateTime oneHourAgo = LocalDateTime.now().minusHours(1).truncatedTo(ChronoUnit.MINUTES);; + startDate = DateUtils.toDate(oneHourAgo); + requestVo.setStartDate(startDate); + requestVo.setEndDate(DateUtils.getNowDate()); + dataList = emsAmmeterDataMapper.getPowerDataByMinutes(requestVo); + // 生成目标时间点列表(每分钟一个) + List targetMinutes = new ArrayList<>(60); + LocalDateTime current = oneHourAgo; + for (int i = 0; i < 60; i++) { + targetMinutes.add(current); // 添加当前分钟 + current = current.plusMinutes(1); // 递增1分钟 + } + + // 填充数据 + if (dataList != null && dataList.size() >= 0){ + dataList = fillEveryMinutesData(dataList,targetMinutes); + } + } // 开始日期和结束日期同一天,展示 0-24 小时数据 - if (DateUtils.isSameDay(startDate, endDate)){ + else if (DateUtils.isSameDay(startDate, endDate)){ endDate = DateUtils.addDays(endDate, 1); requestVo.setEndDate(endDate); dataList = emsAmmeterDataMapper.getPowerDataByHour(requestVo); @@ -341,7 +358,47 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // 负荷功率 dealDataPower(requestVo.getSiteId(),dataList); - return dataList; + return dataList.stream().sorted(Comparator.comparing(PowerStatisListVo::getStatisDate)).collect(Collectors.toList()); + } + + private List fillEveryMinutesData(List dataList, List targetMinutes) { + + List powerStatisListVoList = new ArrayList<>(); + if (targetMinutes == null || targetMinutes.isEmpty()) { + return dataList; + } + + // 数组转化成Map便于后续获取数据 + Map dataMap = dataList.stream() + .map(data -> new PowerStatisListVo( + data.getStatisDate(), + data.getGridPower(), + data.getStoragePower(), + data.getPvPower() + )).collect(Collectors.toMap( + PowerStatisListVo::getStatisDate, + data -> data, + (existing, replacement) -> replacement + )); + + PowerStatisListVo lastData = null; + // 遍历时间数组 + for (LocalDateTime targetMinute : targetMinutes) { + String tarteDate = DateUtils.convertToString(targetMinute); + PowerStatisListVo currentData = dataMap.get(tarteDate); + if (currentData == null && lastData != null) { + BigDecimal pvPower = lastData.getPvPower(); + BigDecimal storagePower = lastData.getStoragePower(); + BigDecimal gridPower = lastData.getGridPower(); + currentData = new PowerStatisListVo(tarteDate.toString(),gridPower,storagePower,pvPower); + } else if (currentData == null && lastData == null){ + // 开头无数据,所有字段设为null + currentData = new PowerStatisListVo(tarteDate.toString(), null, null, null); + } + lastData = currentData; + powerStatisListVoList.add(currentData); + } + return powerStatisListVoList; } private void dealDataPower(String siteId, List dataList) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 13bfcb9..862074f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -1022,4 +1022,18 @@ GROUP BY statisDate order by statisDate desc + + \ No newline at end of file -- 2.49.0 From d47d9150e6c4970f4a686ed412564820bba29f75 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 25 Sep 2025 14:53:17 +0800 Subject: [PATCH 151/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E7=AB=99=E7=9B=91=E6=8E=A7-=E5=AE=9E=E6=97=B6=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=9B=B2=E7=BA=BF=E5=9B=BE=E5=8F=96=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/utils/DateUtils.java | 16 +++ .../ems/domain/vo/EnergyStoragePowVo.java | 17 ++- .../com/xzzn/ems/domain/vo/PcsPowerList.java | 32 ++++++ .../domain/vo/SiteMonitorRuningInfoVo.java | 16 +-- .../ems/mapper/EmsBatteryClusterMapper.java | 10 +- .../ems/mapper/EmsBatteryStackMapper.java | 11 +- .../service/impl/SingleSiteServiceImpl.java | 102 ++++++++++++++++-- .../mapper/ems/EmsBatteryClusterMapper.xml | 13 --- .../mapper/ems/EmsBatteryStackMapper.xml | 18 +++- .../resources/mapper/ems/EmsPcsDataMapper.xml | 8 +- 10 files changed, 188 insertions(+), 55 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsPowerList.java diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 069e852..c7a0e57 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -356,4 +356,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils String dateStr = convertToString(time); return dateTime(YYYY_MM_DD_HH_MM_SS,dateStr); } + + /** + * 增加 Date ==> LocalDateTime + */ + public static LocalDateTime toLocalDateTime(Date date) + { + if (date == null) { + return null; + } + + // 1. Date → LocalDateTime(保留原始时间) + LocalDateTime dateTime = date.toInstant() + .atZone(TimeZone.getDefault().toZoneId()) // 关联时区 + .toLocalDateTime(); + return dateTime; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java index 85ae376..713c34d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java @@ -4,7 +4,7 @@ import java.math.BigDecimal; import java.util.Date; /** - * 实时运行-储能功率数据 + * 实时运行-有功无功功率数据 * */ public class EnergyStoragePowVo { @@ -12,7 +12,7 @@ public class EnergyStoragePowVo { * 显示日期 */ - private Date createDate; + private String createDate; /** * pcs实时有功功率 @@ -24,12 +24,21 @@ public class EnergyStoragePowVo { */ private BigDecimal pcsTotalReactivePower; + private String deviceId; - public Date getCreateDate() { + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getCreateDate() { return createDate; } - public void setCreateDate(Date createDate) { + public void setCreateDate(String createDate) { this.createDate = createDate; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsPowerList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsPowerList.java new file mode 100644 index 0000000..88d3190 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsPowerList.java @@ -0,0 +1,32 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 实时运行-PCS数据list + * + */ +public class PcsPowerList { + + private String deviceId; + // 有功和无功功率数据 + private List energyStoragePowList; + + public List getEnergyStoragePowList() { + return energyStoragePowList; + } + + public void setEnergyStoragePowList(List energyStoragePowList) { + this.energyStoragePowList = energyStoragePowList; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java index fd2dcd1..e80825b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java @@ -8,17 +8,17 @@ import java.util.List; */ public class SiteMonitorRuningInfoVo { /** - * 储能功率list + * PCS有功和无功功率 */ - private List energyStoragePowList; + private List pcsPowerList; /** - * pcs平均温度list + * PCS最高温度 */ private List stackAveTempList; /** - * 电池平均soclist + * 平均soclist */ private List batteryAveSOCList; @@ -27,12 +27,12 @@ public class SiteMonitorRuningInfoVo { */ private List batteryAveTempList; - public List getEnergyStoragePowList() { - return energyStoragePowList; + public List getPcsPowerList() { + return pcsPowerList; } - public void setEnergyStoragePowList(List energyStoragePowList) { - this.energyStoragePowList = energyStoragePowList; + public void setPcsPowerList(List pcsPowerList) { + this.pcsPowerList = pcsPowerList; } public List getStackAveTempList() { diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java index 8cf29f2..a658c40 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryClusterMapper.java @@ -73,15 +73,7 @@ public interface EmsBatteryClusterMapper */ public List getBmsBatteryData(@Param("siteId")String siteId, @Param("stackDeviceId")String stackDeviceId); - /** - * 实时运行-平均soc+平均温度 - * @param siteId - * @param startDate - * @param endDate - * @return - */ - public List getAveSocList(@Param("siteId")String siteId, @Param("startDate") Date startDate, @Param("endDate")Date endDate); - + // 实时运行-FX平均温度 public List getBatteryAveTempList(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); /** 堆电池温度数据-获取当天每小时簇 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java index dad1e38..b8d5f8c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java @@ -3,10 +3,7 @@ package com.xzzn.ems.mapper; import java.util.Date; import java.util.List; import com.xzzn.ems.domain.EmsBatteryStack; -import com.xzzn.ems.domain.vo.DateSearchRequest; -import com.xzzn.ems.domain.vo.StackAveTempVo; -import com.xzzn.ems.domain.vo.StackPointVo; -import com.xzzn.ems.domain.vo.StackStatisListVo; +import com.xzzn.ems.domain.vo.*; import org.apache.ibatis.annotations.Param; /** @@ -91,4 +88,10 @@ public interface EmsBatteryStackMapper public List getStackPointByHour(DateSearchRequest requestVo); public List getStackPointByDay(DateSearchRequest requestVo); public List getStackPointByMonth(DateSearchRequest requestVo); + + + // 实时运行-平均soc + public List getAveSocList(@Param("siteId") String siteId, @Param("startDate") Date startDate, @Param("endDate") Date endDate); + // 实时运行-DDS平均温度 + public List getBatteryAveTempList(@Param("siteId")String siteId, @Param("startDate")Date yesterday, @Param("endDate") Date today); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index bdec05a..7254a49 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -21,6 +21,7 @@ import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; @@ -36,10 +37,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private static final String CLUSTER_DATA_SOC = "SOC"; - private static final String AMMETER_DEVICE_LOAD = "LOAD"; - - private static final String AMMETER_DEVICE_METE = "METE"; - private static Map storageFactor = new HashMap<>(); static { storageFactor.put("021_DDS_01", new BigDecimal("0.1")); @@ -157,7 +154,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return siteMonitorRunningHeadInfoVo; } - // 获取单站监控实时运行-储能功率数据 + // 获取单站监控实时运行-PCS有功无功功率 @Override public SiteMonitorRuningInfoVo getRunningGraphStorage(String siteId) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); @@ -166,12 +163,92 @@ public class SingleSiteServiceImpl implements ISingleSiteService { Date today = DateUtils.getNowDate(); Date yesterday = DateUtils.addDays(today, -1); - //储能功率list + //pcs有功无功 + List pcsPowerList = new ArrayList<>(); List energyStoragePowList = emsPcsDataMapper.getStoragePowerList(siteId, yesterday, today); - siteMonitorRuningInfoVo.setEnergyStoragePowList(energyStoragePowList); + + // 生成时间列表(每分钟一个) + List targetMinutes = new ArrayList<>(60); + LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); + LocalDateTime endDate = DateUtils.toLocalDateTime(today); + while (startDate.isBefore(endDate)) { + targetMinutes.add(startDate); + startDate = startDate.plusMinutes(1); // 递增1分钟 + } + + // 数据格式转换 + if (!CollectionUtils.isEmpty(energyStoragePowList) && !CollectionUtils.isEmpty(targetMinutes)) { + Map> dataMap = energyStoragePowList.stream() + .collect(Collectors.groupingBy( + EnergyStoragePowVo::getDeviceId, + Collectors.toList())); + + pcsPowerList = dataMap.entrySet().stream() + .map(entry -> { + PcsPowerList pcdData = new PcsPowerList(); + pcdData.setDeviceId(entry.getKey()); + pcdData.setEnergyStoragePowList(entry.getValue()); + return pcdData; + }).collect(Collectors.toList()); + + // 根据时间列表填充数据 + pcsPowerList = fullFillData(pcsPowerList,targetMinutes); + } + + siteMonitorRuningInfoVo.setPcsPowerList(pcsPowerList); } return siteMonitorRuningInfoVo; } + private List fullFillData(List pcsPowerList, List targetMinutes) { + List resultList = new ArrayList<>(); + + for (PcsPowerList pcsPower : pcsPowerList) { + Map dataMap = new HashMap<>(); + PcsPowerList pcsResultPower = new PcsPowerList(); + String deviceId = pcsPower.getDeviceId(); + List powerList = pcsPower.getEnergyStoragePowList(); + + if (CollectionUtils.isEmpty(powerList)) { + continue; + } + // 将数据转Map便于后续根据时间获取 + dataMap = powerList.stream().collect( + Collectors.toMap( + data -> data.getCreateDate(), + data -> data, + (existing, replacement) -> replacement + )); + + // 按时间列表遍历 + List resultPowerList = new ArrayList<>(); + EnergyStoragePowVo lastData = null; + for(LocalDateTime targetMinute : targetMinutes) { + String currentDate = DateUtils.convertToString(targetMinute); + EnergyStoragePowVo currentData = dataMap.get(currentDate); + if (currentData == null && lastData != null) { + BigDecimal pcsTotalActPower = lastData.getPcsTotalActPower(); + BigDecimal pcsTotalReactivePower = lastData.getPcsTotalReactivePower(); + currentData = new EnergyStoragePowVo(); + currentData.setPcsTotalActPower(pcsTotalActPower); + currentData.setPcsTotalReactivePower(pcsTotalReactivePower); + currentData.setDeviceId(deviceId); + } else if (currentData == null && lastData == null){ + // 开头无数据,所有字段设为null + currentData = new EnergyStoragePowVo(); + currentData.setDeviceId(deviceId); + } + lastData = currentData; + currentData.setCreateDate(currentDate.substring(11)); + resultPowerList.add(currentData); + } + pcsResultPower.setDeviceId(deviceId); + pcsResultPower.setEnergyStoragePowList(resultPowerList); + resultList.add(pcsResultPower); + } + + return resultList; + } + // 获取单站监控实时运行-stack平均温度 // 20250811 按小时 @Override @@ -187,7 +264,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } return siteMonitorRuningInfoVo; } - // 获取单站监控实时运行-电池平均soc + // 获取单站监控实时运行-平均soc @Override public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); @@ -196,7 +273,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { Date today = new Date(); Date yesterday = DateUtils.addDays(today, -1); //电池平均soclist - List batteryAveSOCList = emsBatteryClusterMapper.getAveSocList(siteId, yesterday, today); + List batteryAveSOCList = emsBatteryStackMapper.getAveSocList(siteId, yesterday, today); siteMonitorRuningInfoVo.setBatteryAveSOCList(batteryAveSOCList); } return siteMonitorRuningInfoVo; @@ -210,7 +287,12 @@ public class SingleSiteServiceImpl implements ISingleSiteService { Date today = new Date(); Date yesterday = DateUtils.addDays(today, -1); //电池平均温度list - List batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, yesterday, today); + List batteryAveTempList = new ArrayList<>(); + if (SiteEnum.FX.getCode().equals(siteId)) { + batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, yesterday, today); + } else if (SiteEnum.DDS.getCode().equals(siteId)) { + batteryAveTempList = emsBatteryStackMapper.getBatteryAveTempList(siteId, yesterday, today); + } siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); } return siteMonitorRuningInfoVo; diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index ec3eceb..829e227 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -325,19 +325,6 @@ t.max_cell_temp,t.min_cell_temp - - - + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 90014fe..bd8419b 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -424,15 +424,15 @@ -- 2.49.0 From 102ecbd41cbb60e30a96b5358e4e48cb3230b7d5 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 25 Sep 2025 19:44:00 +0800 Subject: [PATCH 152/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E5=8D=95?= =?UTF-8?q?=E7=AB=99=E7=9B=91=E6=8E=A7-=E5=AE=9E=E6=97=B6=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=9B=B2=E7=BA=BF=E5=9B=BEpcs=E5=88=86=E5=BC=80?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 6 +- .../java/com/xzzn/ems/domain/EmsPcsData.java | 107 ++++++++++++++- .../xzzn/ems/domain/vo/PcsMaxTempList.java | 30 +++++ ...{StackAveTempVo.java => PcsMaxTempVo.java} | 20 ++- .../domain/vo/SiteMonitorRuningInfoVo.java | 10 +- .../ems/mapper/EmsBatteryStackMapper.java | 9 -- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 5 + .../xzzn/ems/service/ISingleSiteService.java | 2 +- .../impl/DDSDataProcessServiceImpl.java | 6 + .../impl/FXXDataProcessServiceImpl.java | 5 + .../service/impl/SingleSiteServiceImpl.java | 122 +++++++++++++++--- .../resources/mapper/ems/EmsPcsDataMapper.xml | 76 ++++++++++- 12 files changed, 351 insertions(+), 47 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempList.java rename ems-system/src/main/java/com/xzzn/ems/domain/vo/{StackAveTempVo.java => PcsMaxTempVo.java} (52%) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 578397e..3134973 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -60,10 +60,10 @@ public class EmsSiteMonitorController extends BaseController{ return success(iSingleSiteService.getRunningGraphStorage(siteId)); } - @GetMapping("/runningGraph/stackAveTemp") - public AjaxResult getRunningGraphStackTemp(@RequestParam String siteId) + @GetMapping("/runningGraph/pcsMaxTemp") + public AjaxResult getRunningGraphPcsMaxTemp(@RequestParam String siteId) { - return success(iSingleSiteService.getRunningGraphStackTemp(siteId)); + return success(iSingleSiteService.getRunningGraphPcsMaxTemp(siteId)); } @GetMapping("/runningGraph/batteryAveSoc") diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index 98c642f..b505401 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -12,7 +12,7 @@ import com.xzzn.common.annotation.Excel; * PCS数据对象 ems_pcs_data * * @author xzzn - * @date 2025-07-07 + * @date 2025-09-25 */ public class EmsPcsData extends BaseEntity { @@ -206,6 +206,34 @@ public class EmsPcsData extends BaseEntity @Excel(name = "电网频率") private BigDecimal dwFrequency; + /** 单元1U相IGBT温度 */ + @Excel(name = "单元1U相IGBT温度") + private BigDecimal uTemperature; + + /** 单元1V相IGBT温度 */ + @Excel(name = "单元1V相IGBT温度") + private BigDecimal vTemperature; + + /** 单元1W相IGBT温度 */ + @Excel(name = "单元1W相IGBT温度") + private BigDecimal wTemperature; + + /** 1#模块IGBT最高温 */ + @Excel(name = "1#模块IGBT最高温") + private BigDecimal module1Temp; + + /** 2#模块IGBT最高温 */ + @Excel(name = "2#模块IGBT最高温") + private BigDecimal module2Temp; + + /** 3#模块IGBT最高温 */ + @Excel(name = "3#模块IGBT最高温") + private BigDecimal module3Temp; + + /** 4#模块IGBT最高温 */ + @Excel(name = "4#模块IGBT最高温") + private BigDecimal module4Temp; + public void setId(Long id) { this.id = id; @@ -676,6 +704,76 @@ public class EmsPcsData extends BaseEntity return dwFrequency; } + public void setuTemperature(BigDecimal uTemperature) + { + this.uTemperature = uTemperature; + } + + public BigDecimal getuTemperature() + { + return uTemperature; + } + + public void setvTemperature(BigDecimal vTemperature) + { + this.vTemperature = vTemperature; + } + + public BigDecimal getvTemperature() + { + return vTemperature; + } + + public void setwTemperature(BigDecimal wTemperature) + { + this.wTemperature = wTemperature; + } + + public BigDecimal getwTemperature() + { + return wTemperature; + } + + public void setModule1Temp(BigDecimal module1Temp) + { + this.module1Temp = module1Temp; + } + + public BigDecimal getModule1Temp() + { + return module1Temp; + } + + public void setModule2Temp(BigDecimal module2Temp) + { + this.module2Temp = module2Temp; + } + + public BigDecimal getModule2Temp() + { + return module2Temp; + } + + public void setModule3Temp(BigDecimal module3Temp) + { + this.module3Temp = module3Temp; + } + + public BigDecimal getModule3Temp() + { + return module3Temp; + } + + public void setModule4Temp(BigDecimal module4Temp) + { + this.module4Temp = module4Temp; + } + + public BigDecimal getModule4Temp() + { + return module4Temp; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -731,6 +829,13 @@ public class EmsPcsData extends BaseEntity .append("sysVCurrent", getSysVCurrent()) .append("sysWCurrent", getSysWCurrent()) .append("dwFrequency", getDwFrequency()) + .append("uTemperature", getuTemperature()) + .append("vTemperature", getvTemperature()) + .append("wTemperature", getwTemperature()) + .append("module1Temp", getModule1Temp()) + .append("module2Temp", getModule2Temp()) + .append("module3Temp", getModule3Temp()) + .append("module4Temp", getModule4Temp()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempList.java new file mode 100644 index 0000000..57838fd --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempList.java @@ -0,0 +1,30 @@ +package com.xzzn.ems.domain.vo; + +import java.util.List; + +/** + * 实时运行-PCS最高温度list + * + */ +public class PcsMaxTempList { + + private String deviceId; + // 最高温度数据 + private List maxTempVoList; + + public List getMaxTempVoList() { + return maxTempVoList; + } + + public void setMaxTempVoList(List maxTempVoList) { + this.maxTempVoList = maxTempVoList; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackAveTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempVo.java similarity index 52% rename from ems-system/src/main/java/com/xzzn/ems/domain/vo/StackAveTempVo.java rename to ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempVo.java index 1fe2c2d..04d6978 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StackAveTempVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempVo.java @@ -1,29 +1,37 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; -import java.util.Date; /** - * 实时运行-堆平均温度数据 + * 实时运行-PCS最高温度 * */ -public class StackAveTempVo { +public class PcsMaxTempVo { /** * 数据时间 */ - private Date createDate; + private String createDate; /** * 实时温度 */ private BigDecimal temp; + private String deviceId; - public Date getCreateDate() { + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getCreateDate() { return createDate; } - public void setCreateDate(Date createDate) { + public void setCreateDate(String createDate) { this.createDate = createDate; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java index e80825b..1063752 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorRuningInfoVo.java @@ -15,7 +15,7 @@ public class SiteMonitorRuningInfoVo { /** * PCS最高温度 */ - private List stackAveTempList; + private List pcsMaxTempList; /** * 平均soclist @@ -35,12 +35,12 @@ public class SiteMonitorRuningInfoVo { this.pcsPowerList = pcsPowerList; } - public List getStackAveTempList() { - return stackAveTempList; + public List getPcsMaxTempList() { + return pcsMaxTempList; } - public void setStackAveTempList(List stackAveTempList) { - this.stackAveTempList = stackAveTempList; + public void setPcsMaxTempList(List pcsMaxTempList) { + this.pcsMaxTempList = pcsMaxTempList; } public List getBatteryAveSOCList() { diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java index b8d5f8c..81b048a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryStackMapper.java @@ -62,15 +62,6 @@ public interface EmsBatteryStackMapper */ public int deleteEmsBatteryStackByIds(Long[] ids); - /** - * 获取实时运行-堆平均温度 - * @param siteId - * @param startDate - * @param endDate - * @return - */ - public List getStackAveTempList(@Param("siteId")String siteId, @Param("startDate") Date startDate, @Param("endDate")Date endDate); - /** * 堆曲线数据-按小时区分 * @param requestVo diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index a3d1bc1..8a76ae6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -127,4 +127,9 @@ public interface EmsPcsDataMapper public List getPcsActivePowerByHour(DateSearchRequest requestVo); public List getPcsActivePowerByMonth(DateSearchRequest requestVo); + + // 实时运行-fx-pcs最高温度 + public List getFXMaxTemp(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + // 实时运行-dds-pcs最高温度 + public List getDDSMaxTemp(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 9a0fe0a..e24eba0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -32,7 +32,7 @@ public interface ISingleSiteService public List getAmmeterDataList(String siteId); - public SiteMonitorRuningInfoVo getRunningGraphStackTemp(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphPcsMaxTemp(String siteId); public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index ed70cb8..e67d042 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -598,6 +598,12 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZLZGL"))); pcsData.setTotalPowerFactor(new BigDecimal(0)); + // 模块温度 + pcsData.setModule1Temp(StringUtils.getBigDecimal(obj.get("IGBYZGWD1"))); + pcsData.setModule2Temp(StringUtils.getBigDecimal(obj.get("IGBYZGWD2"))); + pcsData.setModule3Temp(StringUtils.getBigDecimal(obj.get("IGBYZGWD3"))); + pcsData.setModule4Temp(StringUtils.getBigDecimal(obj.get("IGBYZGWD4"))); + // 系统管理字段 pcsData.setCreateBy("system"); pcsData.setCreateTime(DateUtils.getNowDate()); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 5da9227..d7a7f56 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -439,6 +439,11 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); // pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + // 三相温度 + pcsData.setuTemperature(StringUtils.getBigDecimal(obj.get("DY1UXIGBTWD"))); + pcsData.setvTemperature(StringUtils.getBigDecimal(obj.get("DY1VXIGBTWD"))); + pcsData.setwTemperature(StringUtils.getBigDecimal(obj.get("DY1WXIGBTWD"))); + // 系统管理字段 pcsData.setCreateBy("system"); pcsData.setCreateTime(DateUtils.getNowDate()); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 7254a49..7b23cee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -167,17 +167,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List pcsPowerList = new ArrayList<>(); List energyStoragePowList = emsPcsDataMapper.getStoragePowerList(siteId, yesterday, today); - // 生成时间列表(每分钟一个) - List targetMinutes = new ArrayList<>(60); - LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); - LocalDateTime endDate = DateUtils.toLocalDateTime(today); - while (startDate.isBefore(endDate)) { - targetMinutes.add(startDate); - startDate = startDate.plusMinutes(1); // 递增1分钟 - } - - // 数据格式转换 - if (!CollectionUtils.isEmpty(energyStoragePowList) && !CollectionUtils.isEmpty(targetMinutes)) { + // List -> 按pcs的deviceId分组转成List + if (!CollectionUtils.isEmpty(energyStoragePowList)) { Map> dataMap = energyStoragePowList.stream() .collect(Collectors.groupingBy( EnergyStoragePowVo::getDeviceId, @@ -191,6 +182,14 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return pcdData; }).collect(Collectors.toList()); + // 生成时间列表(每分钟一个) + List targetMinutes = new ArrayList<>(60); + LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); + LocalDateTime endDate = DateUtils.toLocalDateTime(today); + while (startDate.isBefore(endDate)) { + targetMinutes.add(startDate); + startDate = startDate.plusMinutes(1); // 递增1分钟 + } // 根据时间列表填充数据 pcsPowerList = fullFillData(pcsPowerList,targetMinutes); } @@ -249,21 +248,102 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return resultList; } - // 获取单站监控实时运行-stack平均温度 - // 20250811 按小时 + // 获取单站监控实时运行-pcs最高温度 @Override - public SiteMonitorRuningInfoVo getRunningGraphStackTemp(String siteId) { + public SiteMonitorRuningInfoVo getRunningGraphPcsMaxTemp(String siteId) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); - if (!StringUtils.isEmpty(siteId)) { - // 时间暂定今日+昨日 - Date today = new Date(); - Date yesterday = DateUtils.addDays(today, -1); - //pcs平均温度list - List stackAveTempVos = emsBatteryStackMapper.getStackAveTempList(siteId, yesterday, today); - siteMonitorRuningInfoVo.setStackAveTempList(stackAveTempVos); + List pcsMaxTempList = new ArrayList<>(); + // 时间暂定今日+昨日 + Date today = new Date(); + Date yesterday = DateUtils.addDays(today, -1); + //PCS最高温度list + List pcsMaxTempVos = new ArrayList<>(); + if (SiteEnum.FX.getCode().equals(siteId)) { + pcsMaxTempVos = emsPcsDataMapper.getFXMaxTemp(siteId, yesterday, today); + } else if (SiteEnum.DDS.getCode().equals(siteId)) { + pcsMaxTempVos = emsPcsDataMapper.getDDSMaxTemp(siteId, yesterday, today); } + + // List -> 按pcs的deviceId分组转成List + if (!CollectionUtils.isEmpty(pcsMaxTempVos)) { + Map> dataMap = pcsMaxTempVos.stream() + .collect(Collectors.groupingBy( + PcsMaxTempVo::getDeviceId, + Collectors.toList())); + + pcsMaxTempList = dataMap.entrySet().stream() + .map(entry -> { + PcsMaxTempList pcdData = new PcsMaxTempList(); + pcdData.setDeviceId(entry.getKey()); + pcdData.setMaxTempVoList(entry.getValue()); + return pcdData; + }).collect(Collectors.toList()); + + // 生成时间列表(每小时一个) + List targetHours = new ArrayList<>(60); + LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); + LocalDateTime endDate = DateUtils.toLocalDateTime(today); + while (startDate.isBefore(endDate)) { + targetHours.add(startDate); + startDate = startDate.plusHours(1); // 递增1小时 + } + // 根据时间列表填充数据 + pcsMaxTempList = fullFillMaxTempData(pcsMaxTempList,targetHours); + } + + siteMonitorRuningInfoVo.setPcsMaxTempList(pcsMaxTempList); return siteMonitorRuningInfoVo; } + private List fullFillMaxTempData(List pcsMaxTempList, List targetHours) { + List resultList = new ArrayList<>(); + + for (PcsMaxTempList pcsMaxTemp : pcsMaxTempList) { + PcsMaxTempList pcsTemp = new PcsMaxTempList(); + List resultVos = new ArrayList<>(); + Map dataMap = new HashMap<>(); + + String deviceId = pcsMaxTemp.getDeviceId(); + List pcsMaxTempVos = pcsMaxTemp.getMaxTempVoList(); + if (CollectionUtils.isEmpty(pcsMaxTempVos)) { + continue; + } + + // 将数据转Map便于后续根据时间获取 + dataMap = pcsMaxTempVos.stream().collect( + Collectors.toMap( + data -> data.getCreateDate(), + data -> data, + (existing, replacement) -> replacement + )); + + PcsMaxTempVo lastData = null; + List resultTempList = new ArrayList<>(); + // 遍历时间填充数据 + for (LocalDateTime targetHour : targetHours) { + String currentDate = DateUtils.convertToString(targetHour); + PcsMaxTempVo currentData = dataMap.get(currentDate); + if (currentData == null && lastData != null) { + BigDecimal temp = lastData.getTemp(); + currentData = new PcsMaxTempVo(); + currentData.setTemp(temp); + currentData.setDeviceId(deviceId); + } else if (currentData == null && lastData == null){ + // 开头无数据,所有字段设为null + currentData = new PcsMaxTempVo(); + currentData.setDeviceId(deviceId); + } + lastData = currentData; + currentData.setCreateDate(currentDate.substring(11)); + resultTempList.add(currentData); + + } + pcsTemp.setDeviceId(deviceId); + pcsTemp.setMaxTempVoList(resultTempList); + resultList.add(pcsTemp); + } + return resultList; + } + // 获取单站监控实时运行-平均soc @Override public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index bd8419b..560f619 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -57,10 +57,17 @@ + + + + + + + - select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, date_month, date_day, total_ac_charge_energy, total_ac_discharge_energy, ac_charge_active_power, ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, remote_control_status, sys_u_current, sys_v_current, sys_w_current, dw_frequency from ems_pcs_data + select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, date_month, date_day, total_ac_charge_energy, total_ac_discharge_energy, ac_charge_active_power, ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, remote_control_status, sys_u_current, sys_v_current, sys_w_current, dw_frequency, u_temperature, v_temperature, w_temperature, module1_temp, module2_temp, module3_temp, module4_temp from ems_pcs_data @@ -174,6 +188,13 @@ sys_v_current, sys_w_current, dw_frequency, + u_temperature, + v_temperature, + w_temperature, + module1_temp, + module2_temp, + module3_temp, + module4_temp, #{dataUpdateTime}, @@ -227,6 +248,13 @@ #{sysVCurrent}, #{sysWCurrent}, #{dwFrequency}, + #{uTemperature}, + #{vTemperature}, + #{wTemperature}, + #{module1Temp}, + #{module2Temp}, + #{module3Temp}, + #{module4Temp}, @@ -284,6 +312,13 @@ sys_v_current = #{sysVCurrent}, sys_w_current = #{sysWCurrent}, dw_frequency = #{dwFrequency}, + u_temperature = #{uTemperature}, + v_temperature = #{vTemperature}, + w_temperature = #{wTemperature}, + module1_temp = #{module1Temp}, + module2_temp = #{module2Temp}, + module3_temp = #{module3Temp}, + module4_temp = #{module4Temp}, where id = #{id} @@ -539,4 +574,43 @@ AND latest.max_update_time = t.data_update_time order by statisDate desc + + + + \ No newline at end of file -- 2.49.0 From 553e30c6ef119d0c96fe7bc886d04423510a881d Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 26 Sep 2025 13:55:16 +0800 Subject: [PATCH 153/336] =?UTF-8?q?0926-=E5=A5=89=E8=B4=A4=E6=B6=B2?= =?UTF-8?q?=E5=86=B7=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 5 + .../com/xzzn/ems/domain/EmsCoolingData.java | 111 +++++++++++++++- .../xzzn/ems/domain/vo/CoolingDataViewVo.java | 118 ++++++++++++++++++ .../ems/service/IEmsAlarmRecordsService.java | 2 +- .../xzzn/ems/service/ISingleSiteService.java | 2 +- .../impl/EmsAlarmRecordsServiceImpl.java | 1 + .../impl/FXXDataProcessServiceImpl.java | 30 +++++ .../service/impl/SingleSiteServiceImpl.java | 19 ++- .../mapper/ems/EmsCoolingDataMapper.xml | 37 +++++- 9 files changed, 315 insertions(+), 10 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 5edda60..30231c4 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -52,6 +52,11 @@ public class RedisKeyConstants */ public static final String ORIGINAL_BMSD = "BMSD_"; + /** + * 冷却数据 redis key + */ + public static final String COOLING = "COOLING_"; + /** * 存放单个设备同步过来的原始数据 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java index a469528..2e85dc8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java @@ -11,7 +11,7 @@ import com.xzzn.common.annotation.Excel; * 冷却系统参数对象 ems_cooling_data * * @author xzzn - * @date 2025-06-29 + * @date 2025-09-26 */ public class EmsCoolingData extends BaseEntity { @@ -24,8 +24,8 @@ public class EmsCoolingData extends BaseEntity @Excel(name = "系统名称,如1#液冷") private String systemName; - /** 工作模式 */ - @Excel(name = "工作模式") + /** 工作模式:0-正常 1-停止 */ + @Excel(name = "工作模式:0-正常 1-停止") private String workMode; /** 当前温度 (℃) */ @@ -56,6 +56,34 @@ public class EmsCoolingData extends BaseEntity @Excel(name = "低温告警点 (℃)") private BigDecimal lowTempAlarmPoint; + /** 供水温度 */ + @Excel(name = "供水温度") + private BigDecimal gsTemp; + + /** 回水温度 */ + @Excel(name = "回水温度") + private BigDecimal hsTemp; + + /** 供水压力 */ + @Excel(name = "供水压力") + private BigDecimal gsPressure; + + /** 回水压力 */ + @Excel(name = "回水压力") + private BigDecimal hsPressure; + + /** 冷源水温度 */ + @Excel(name = "冷源水温度") + private BigDecimal lysTemp; + + /** VB01开度 */ + @Excel(name = "VB01开度") + private BigDecimal vb01Kd; + + /** VB02开度 */ + @Excel(name = "VB02开度") + private BigDecimal vb02Kd; + /** 站点id */ @Excel(name = "站点id") private String siteId; @@ -164,6 +192,76 @@ public class EmsCoolingData extends BaseEntity return lowTempAlarmPoint; } + public void setGsTemp(BigDecimal gsTemp) + { + this.gsTemp = gsTemp; + } + + public BigDecimal getGsTemp() + { + return gsTemp; + } + + public void setHsTemp(BigDecimal hsTemp) + { + this.hsTemp = hsTemp; + } + + public BigDecimal getHsTemp() + { + return hsTemp; + } + + public void setGsPressure(BigDecimal gsPressure) + { + this.gsPressure = gsPressure; + } + + public BigDecimal getGsPressure() + { + return gsPressure; + } + + public void setHsPressure(BigDecimal hsPressure) + { + this.hsPressure = hsPressure; + } + + public BigDecimal getHsPressure() + { + return hsPressure; + } + + public void setLysTemp(BigDecimal lysTemp) + { + this.lysTemp = lysTemp; + } + + public BigDecimal getLysTemp() + { + return lysTemp; + } + + public void setVb01Kd(BigDecimal vb01Kd) + { + this.vb01Kd = vb01Kd; + } + + public BigDecimal getVb01Kd() + { + return vb01Kd; + } + + public void setVb02Kd(BigDecimal vb02Kd) + { + this.vb02Kd = vb02Kd; + } + + public BigDecimal getVb02Kd() + { + return vb02Kd; + } + public void setSiteId(String siteId) { this.siteId = siteId; @@ -197,6 +295,13 @@ public class EmsCoolingData extends BaseEntity .append("heatingStopPoint", getHeatingStopPoint()) .append("coolingStopPoint", getCoolingStopPoint()) .append("lowTempAlarmPoint", getLowTempAlarmPoint()) + .append("gsTemp", getGsTemp()) + .append("hsTemp", getHsTemp()) + .append("gsPressure", getGsPressure()) + .append("hsPressure", getHsPressure()) + .append("lysTemp", getLysTemp()) + .append("vb01Kd", getVb01Kd()) + .append("vb02Kd", getVb02Kd()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java new file mode 100644 index 0000000..9f19015 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java @@ -0,0 +1,118 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +import java.math.BigDecimal; + +/** + * 单站监控-液冷 + * + */ +public class CoolingDataViewVo { + + /** 设备名称 */ + private String deviceName; + + /** 供水温度 */ + @Excel(name = "供水温度") + private BigDecimal gsTemp; + + /** 回水温度 */ + @Excel(name = "回水温度") + private BigDecimal hsTemp; + + /** 供水压力 */ + @Excel(name = "供水压力") + private BigDecimal gsPressure; + + /** 回水压力 */ + @Excel(name = "回水压力") + private BigDecimal hsPressure; + + /** 冷源水温度 */ + @Excel(name = "冷源水温度") + private BigDecimal lysTemp; + + /** VB01开度 */ + @Excel(name = "VB01开度") + private BigDecimal vb01Kd; + + /** VB02开度 */ + @Excel(name = "VB02开度") + private BigDecimal vb02Kd; + + /** 设备唯一标识符 */ + private String deviceId; + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public BigDecimal getGsTemp() { + return gsTemp; + } + + public void setGsTemp(BigDecimal gsTemp) { + this.gsTemp = gsTemp; + } + + public BigDecimal getHsTemp() { + return hsTemp; + } + + public void setHsTemp(BigDecimal hsTemp) { + this.hsTemp = hsTemp; + } + + public BigDecimal getGsPressure() { + return gsPressure; + } + + public void setGsPressure(BigDecimal gsPressure) { + this.gsPressure = gsPressure; + } + + public BigDecimal getHsPressure() { + return hsPressure; + } + + public void setHsPressure(BigDecimal hsPressure) { + this.hsPressure = hsPressure; + } + + public BigDecimal getLysTemp() { + return lysTemp; + } + + public void setLysTemp(BigDecimal lysTemp) { + this.lysTemp = lysTemp; + } + + public BigDecimal getVb01Kd() { + return vb01Kd; + } + + public void setVb01Kd(BigDecimal vb01Kd) { + this.vb01Kd = vb01Kd; + } + + public BigDecimal getVb02Kd() { + return vb02Kd; + } + + public void setVb02Kd(BigDecimal vb02Kd) { + this.vb02Kd = vb02Kd; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java index ece699c..9fc29d1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -69,7 +69,7 @@ public interface IEmsAlarmRecordsService public List getAlarmRecordDetailList(AlarmRecordListRequestVo requestVo); /** - * 生产工单号 + * 生产工单号并设置告警处理中 * * @param id * @param userId diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index e24eba0..fa88d06 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -25,7 +25,7 @@ public interface ISingleSiteService public List getBMSBatteryCluster(String siteId); - public List getCoolingDataList(String siteId); + public List getCoolingDataList(String siteId); public List getClusterDataInfoList(String clusterDeviceId,String siteId, String stackDeviceId, String batteryId); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index e6aa6dc..146c54e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -145,6 +145,7 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService ticketNo = createRandomTicketNo(); // 更新告警表 emsAlarmRecords.setTicketNo(ticketNo); + emsAlarmRecords.setStatus(AlarmStatus.PROCESSING.getCode()); emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords); // 不存在-默认userId if (userId == null) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index d7a7f56..05f54f0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -67,6 +67,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsDhDataMapper emsDhDataMapper; @Autowired private IEmsAlarmRecordsService iEmsAlarmRecordsService; + @Autowired + private EmsCoolingDataMapper emsCoolingDataMapper; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -112,10 +114,38 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl meteDataProcess(deviceId, jsonData); } else if (deviceId.contains("donghuan")) { dhDataProcess(deviceId, jsonData); + } else if (deviceId.contains("ZSLQ")) { + coolingDataProcess(deviceId, jsonData); } } } + private void coolingDataProcess(String deviceId, String jsonData) { + //中水冷却 + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + EmsCoolingData coolingData = new EmsCoolingData(); + coolingData.setGsTemp(StringUtils.getBigDecimal(obj.get("GSWD"))); + coolingData.setHsTemp(StringUtils.getBigDecimal(obj.get("HSWD"))); + coolingData.setGsPressure(StringUtils.getBigDecimal(obj.get("GSYL"))); + coolingData.setHsPressure(StringUtils.getBigDecimal(obj.get("HSYL"))); + coolingData.setLysTemp(StringUtils.getBigDecimal(obj.get("LYSWD"))); + coolingData.setVb01Kd(StringUtils.getBigDecimal(obj.get("VB1KD"))); + coolingData.setVb02Kd(StringUtils.getBigDecimal(obj.get("VB2KD"))); + + coolingData.setCreateBy("system"); + coolingData.setCreateTime(DateUtils.getNowDate()); + coolingData.setUpdateBy("system"); + coolingData.setUpdateTime(DateUtils.getNowDate()); + coolingData.setSiteId(SITE_ID); + coolingData.setDeviceId(deviceId); + + emsCoolingDataMapper.insertEmsCoolingData(coolingData); + + redisCache.setCacheObject(RedisKeyConstants.COOLING + SITE_ID + "_" +deviceId, coolingData); + } + private void dhDataProcess(String deviceId, String dataJson) { //动环 Map obj = JSON.parseObject(dataJson, new TypeReference>() { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 7b23cee..e5bf9b4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -542,10 +542,21 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取液冷设备参数 @Override - public List getCoolingDataList(String siteId) { - List emsCoolingDataList = new ArrayList<>(); - if (!StringUtils.isEmpty(siteId)) { - emsCoolingDataList = emsCoolingDataMapper.getCoolingDataList(siteId); + public List getCoolingDataList(String siteId) { + List emsCoolingDataList = new ArrayList<>(); + + List> deviceIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.COOLING.getCode()); + for (Map deviceId : deviceIds) { + CoolingDataViewVo dataViewVo = new CoolingDataViewVo(); + dataViewVo.setDeviceName(deviceId.get("deviceName").toString()); + // 从redis取堆单个详细数据 + String coolingId = deviceId.get("id").toString(); + EmsCoolingData coolingData = redisCache.getCacheObject(RedisKeyConstants.COOLING + siteId + "_" + coolingId); + if (coolingData != null) { + BeanUtils.copyProperties(coolingData, dataViewVo); + } + + emsCoolingDataList.add(dataViewVo); } return emsCoolingDataList; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml index 99e6067..ed058c2 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml @@ -15,6 +15,13 @@ + + + + + + + @@ -25,7 +32,7 @@ - select id, system_name, work_mode, current_temperature, heating_start_point, cooling_start_point, high_temp_alarm_point, heating_stop_point, cooling_stop_point, low_temp_alarm_point, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_cooling_data + select id, system_name, work_mode, current_temperature, heating_start_point, cooling_start_point, high_temp_alarm_point, heating_stop_point, cooling_stop_point, low_temp_alarm_point, gs_temp, hs_temp, gs_pressure, hs_pressure, lys_temp, vb01_kd, vb02_kd, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_cooling_data + + \ No newline at end of file -- 2.49.0 From ee53ab137bcd388b21e2940480173fa7aa98860b Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 26 Sep 2025 16:43:40 +0800 Subject: [PATCH 155/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E5=88=97=E8=A1=A8=E7=94=B5=E6=B1=A0=E7=B0=87=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 f64cb44..66d006f 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 @@ -244,12 +244,8 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService for (PointQueryResponse pointInfo : response) { String dataKey = pointInfo.getDataPoint(); Long updateTime = Long.valueOf(bmsdJson.get("timestamp").toString()); - int isNeedDeviceId = pointInfo.getIsNeedDeviceId(); - if (isNeedDeviceId == 1 && "PCS".equals(pointInfo.getDataDevice())) {// 需要根据deviceId拼接point - dataKey = deviceId + dataKey; + if ("PCS".equals(pointInfo.getDataDevice())) { updateTime = Long.valueOf(pcsJson.get("timestamp").toString()); - } else if (isNeedDeviceId == 1 && "BMSD".equals(pointInfo.getDataDevice())){ - dataKey = bmsdDeviceId + dataKey; } pointInfo.setDataPoint(dataKey); pointInfo.setPointValue(obj.get(dataKey)); -- 2.49.0 From 33534cc50083d2bd6775425a08eb49af79e89776 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 27 Sep 2025 15:11:57 +0800 Subject: [PATCH 156/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E8=BF=90=E8=A1=8C=E6=9B=B2=E7=BA=BF=E5=9B=BE=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/vo/BatteryAveSOCVo.java | 6 +++--- .../com/xzzn/ems/domain/vo/BatteryAveTempVo.java | 6 +++--- .../mapper/ems/EmsBatteryClusterMapper.xml | 7 ++++--- .../resources/mapper/ems/EmsBatteryStackMapper.xml | 14 ++++++++------ 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java index 806491d..d85a12c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java @@ -11,18 +11,18 @@ public class BatteryAveSOCVo { /** * 数据时间 */ - private Date createDate; + private String createDate; /** * 实时SOC */ private BigDecimal batterySOC; - public Date getCreateDate() { + public String getCreateDate() { return createDate; } - public void setCreateDate(Date createDate) { + public void setCreateDate(String createDate) { this.createDate = createDate; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java index bcab5d4..b79e0de 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java @@ -11,18 +11,18 @@ public class BatteryAveTempVo { /** * 数据时间 */ - private Date createDate; + private String createDate; /** * 实时温度 */ private BigDecimal batteryTemp; - public Date getCreateDate() { + public String getCreateDate() { return createDate; } - public void setCreateDate(Date createDate) { + public void setCreateDate(String createDate) { this.createDate = createDate; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 829e227..0c693ce 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -328,13 +328,14 @@ select t.site_id, avg(t.avg_temperature) as batteryTemp, - DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i:00') AS createDate + DATE_FORMAT(t.create_time, '%Y-%m-%d') AS dateDay, + DATE_FORMAT(t.create_time, '%H:%i:00') AS createDate from ems_battery_stack t where t.site_id = #{siteId} AND t.create_time >= Date(#{startDate}) AND t.create_time <= #{endDate} - GROUP BY t.site_id,createDate - order by createDate + GROUP BY t.site_id,dateDay,createDate + order by dateDay,createDate @@ -495,12 +496,13 @@ \ No newline at end of file -- 2.49.0 From 097709d403df7715075e877b750d588e37d038b5 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 27 Sep 2025 20:01:31 +0800 Subject: [PATCH 157/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E8=BF=90=E8=A1=8CPCS=E6=9C=80=E9=AB=98=E6=B8=A9?= =?UTF-8?q?=E5=BA=A6=E6=95=B0=E6=8D=AE=E7=BC=BA=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ems/EmsPcsDataMapper.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 560f619..791fab4 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -585,7 +585,9 @@ latest.dateHour as createDate from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%Y-%m-%d %H:00:00') AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p - + WHERE p.site_id = #{siteId} + AND p.data_update_time >= Date(#{startDate}) + AND p.data_update_time <= #{endDate} GROUP BY p.site_id, p.device_id,dateHour ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id AND latest.device_id = t.device_id @@ -605,7 +607,9 @@ latest.dateHour as createDate from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%Y-%m-%d %H:00:00') AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p - + WHERE p.site_id = #{siteId} + AND p.data_update_time >= Date(#{startDate}) + AND p.data_update_time <= #{endDate} GROUP BY p.site_id, p.device_id,dateHour ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id AND latest.device_id = t.device_id -- 2.49.0 From f2b2741b1cb579a0540b2270524ba5e1f9d9d2b8 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 28 Sep 2025 10:32:02 +0800 Subject: [PATCH 158/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=94=B5?= =?UTF-8?q?=E8=A1=A8=E5=8F=96=E5=80=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DDSDataProcessServiceImpl.java | 8 ++- .../impl/FXXDataProcessServiceImpl.java | 6 ++ .../service/impl/SingleSiteServiceImpl.java | 55 ++++++++----------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index e67d042..ebf1617 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -699,7 +699,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 其他字段 dataGF.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("WGDN"))); - dataGF.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("WGDN"))); + dataGF.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("YGDN"))); dataGF.setCurrentPercent(StringUtils.getBigDecimal(obj.get("DLBB"))); dataGF.setVoltagePercent(StringUtils.getBigDecimal(obj.get("DYBB"))); dataGF.setAvgCurrent(StringUtils.getBigDecimal(obj.get("PJDL"))); @@ -771,6 +771,12 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("GXWGDDYCC"))); dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("XSYGDDYCC"))); + // 正向反向有功无功电能 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("XSYGDDYCC"))); + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("SFYGDDYCC"))); + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("GXWGDDYCC"))); + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("RXWGDDYCC"))); + dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); dataLoad.setUpdateBy("system"); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 05f54f0..5c2f718 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -740,6 +740,12 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + // 正反向有功无功电能 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("FXYGDN"))); + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); dataLoad.setUpdateBy("system"); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index e5bf9b4..7ee278d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -48,6 +48,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService { pvFactor.put("021_DDS_01", new BigDecimal("-0.001")); pvFactor.put("default", BigDecimal.ONE); // Convert to Basic Latin } + + // 初始化List,存储指定的电表deviceId + List ammeterDeviceIds = Arrays.asList( + "LOAD", "METE", "METEGF" + ); @Autowired private EmsPcsDataMapper emsPcsDataMapper; @Autowired @@ -638,47 +643,35 @@ public class SingleSiteServiceImpl implements ISingleSiteService { for (Map ammeterDevice : ammeterIdList) { String ammeterId = ammeterDevice.get("id").toString(); + if (!ammeterDeviceIds.contains(ammeterId)) { + continue; + } // 从redis取总表详细数据 EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); - AmmeterDataVo ammeterLoadDataVo = new AmmeterDataVo(); - ammeterLoadDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); - ammeterLoadDataVo.setDeviceId(ammeterDevice.get("id").toString()); - ammeterLoadDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : + AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); + ammeterDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); + ammeterDataVo.setDeviceId(ammeterDevice.get("id").toString()); + ammeterDataVo.setEmsCommunicationStatus(ammeterDevice.get("communicationStatus") == null? "" : ammeterDevice.get("communicationStatus").toString()); // 设置表数据 - dealAmmeterLoadData(ammeterData,ammeterLoadDataVo); - ammeterResponse.add(ammeterLoadDataVo); + dealAmmeterData(ammeterData,ammeterDataVo); + ammeterResponse.add(ammeterDataVo); } return ammeterResponse; } - private void dealAmmeterMeteData(EmsAmmeterData ammeterData, AmmeterMeteDataVo ammeterMeteDataVo) { + private void dealAmmeterData(EmsAmmeterData ammeterData, AmmeterDataVo ammeterDataVo) { if (ammeterData != null) { - // 数据更新时间 - ammeterMeteDataVo.setDataUpdateTime(ammeterData.getDataUpdateTime()); - - List meteDataDetailInfos = new ArrayList<>(); - // 拼接数据 - // a相 - MeteDataDetailInfo meteDataDetailInfo1 = new MeteDataDetailInfo(); - meteDataDetailInfo1.setCategory(AmmeterCategory.A_POWER.getInfo()); - meteDataDetailInfo1.setActivePower(ammeterData.getPhaseAActivePower()); - meteDataDetailInfo1.setReactivePower(ammeterData.getPhaseAReactivePower()); - meteDataDetailInfos.add(meteDataDetailInfo1); - // b相 - MeteDataDetailInfo meteDataDetailInfo2 = new MeteDataDetailInfo(); - meteDataDetailInfo2.setCategory(AmmeterCategory.B_POWER.getInfo()); - meteDataDetailInfo2.setActivePower(ammeterData.getPhaseBActivePower()); - meteDataDetailInfo2.setReactivePower(ammeterData.getPhaseBReactivePower()); - meteDataDetailInfos.add(meteDataDetailInfo2); - // c相 - MeteDataDetailInfo meteDataDetailInfo3 = new MeteDataDetailInfo(); - meteDataDetailInfo3.setCategory(AmmeterCategory.C_POWER.getInfo()); - meteDataDetailInfo3.setActivePower(ammeterData.getPhaseCActivePower()); - meteDataDetailInfo3.setReactivePower(ammeterData.getPhaseCReactivePower()); - meteDataDetailInfos.add(meteDataDetailInfo3); - ammeterMeteDataVo.setMeteDataDetailInfo(meteDataDetailInfos); + ammeterDataVo.setActivePower(ammeterData.getTotalActivePower()); + ammeterDataVo.setReactivePower(ammeterData.getTotalReactivePower()); + ammeterDataVo.setForwardActive(ammeterData.getCurrentForwardActiveTotal()); + ammeterDataVo.setForwardReactive(ammeterData.getCurrentForwardReactiveTotal()); + ammeterDataVo.setReverseActive(ammeterData.getCurrentReverseActiveTotal()); + ammeterDataVo.setReverseReactive(ammeterData.getCurrentReverseReactiveTotal()); + ammeterDataVo.setActiveEnergy(ammeterData.getPositiveActiveEnergyEpPlus()); + ammeterDataVo.setReactiveEnergy(ammeterData.getPositiveReactiveEnergyEqPlus()); + ammeterDataVo.setDataUpdateTime(ammeterData.getDataUpdateTime()); } } -- 2.49.0 From e5a2ce4c8de96a5781ae0c43260e2af5cb684055 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 28 Sep 2025 14:44:02 +0800 Subject: [PATCH 159/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=94=B5?= =?UTF-8?q?=E8=A1=A8=E7=82=B9=E4=BD=8D=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/vo/AmmeterDataVo.java | 82 +++++++++++++++++++ .../xzzn/ems/mapper/EmsPointMatchMapper.java | 4 +- .../impl/EmsDeviceSettingServiceImpl.java | 8 +- .../mapper/ems/EmsPointMatchMapper.xml | 8 +- 4 files changed, 94 insertions(+), 8 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java index 54f4b7f..ff85c61 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterDataVo.java @@ -2,6 +2,7 @@ package com.xzzn.ems.domain.vo; import com.fasterxml.jackson.annotation.JsonFormat; +import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -26,6 +27,87 @@ public class AmmeterDataVo { /** 表数据信息 */ private List loadDataDetailInfo; + // 正向有功电能 + private BigDecimal forwardActive; + // 反向有功电能 + private BigDecimal reverseActive; + // 正向无功电能 + private BigDecimal forwardReactive; + // 反向无功电能 + private BigDecimal reverseReactive; + // 有功功率 + private BigDecimal activePower; + // 无功功率 + private BigDecimal reactivePower; + // 有功电能 + private BigDecimal activeEnergy; + // 无功电能 + private BigDecimal reactiveEnergy; + + public BigDecimal getActiveEnergy() { + return activeEnergy; + } + + public void setActiveEnergy(BigDecimal activeEnergy) { + this.activeEnergy = activeEnergy; + } + + public BigDecimal getReactiveEnergy() { + return reactiveEnergy; + } + + public void setReactiveEnergy(BigDecimal reactiveEnergy) { + this.reactiveEnergy = reactiveEnergy; + } + + public BigDecimal getForwardActive() { + return forwardActive; + } + + public void setForwardActive(BigDecimal forwardActive) { + this.forwardActive = forwardActive; + } + + public BigDecimal getReverseActive() { + return reverseActive; + } + + public void setReverseActive(BigDecimal reverseActive) { + this.reverseActive = reverseActive; + } + + public BigDecimal getForwardReactive() { + return forwardReactive; + } + + public void setForwardReactive(BigDecimal forwardReactive) { + this.forwardReactive = forwardReactive; + } + + public BigDecimal getReverseReactive() { + return reverseReactive; + } + + public void setReverseReactive(BigDecimal reverseReactive) { + this.reverseReactive = reverseReactive; + } + + public BigDecimal getActivePower() { + return activePower; + } + + public void setActivePower(BigDecimal activePower) { + this.activePower = activePower; + } + + public BigDecimal getReactivePower() { + return reactivePower; + } + + public void setReactivePower(BigDecimal reactivePower) { + this.reactivePower = reactivePower; + } + public String getDeviceName() { return deviceName; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 6bd17d6..2807b09 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -121,13 +121,13 @@ public interface EmsPointMatchMapper // 单个站点单个设备点位查询-除了电池簇其他设备使用 public List getSingleSiteDevicePoints(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, - @Param("dataPointName")String dataPointName, + @Param("pointName")String pointName, @Param("dataPoint")String dataPoint); // 单个站点单个设备点位查询-电池簇使用 public List getClusterDevicePoints(@Param("siteId")String siteId, @Param("deviceId")String deviceId, @Param("parentDeviceId")String parentDeviceId, @Param("deviceCategory")String deviceCategory, - @Param("dataPointName")String dataPointName, + @Param("pointName")String pointName, @Param("dataPoint")String dataPoint); } 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 66d006f..af9ef50 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 @@ -190,9 +190,13 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService // 结果排序 String sortMethod = request.getSortMethod(); if (sortMethod==null || sortMethod.isEmpty() || "asc".equals(sortMethod)) {// 升序 - response = response.stream().sorted(Comparator.comparing(PointQueryResponse::getUpdateTime)).collect(Collectors.toList()); + response = response.stream() + .filter(p -> p.getPointValue() != null) + .sorted(Comparator.comparing(PointQueryResponse::getUpdateTime)).collect(Collectors.toList()); } else if ("desc".equals(sortMethod)) {//降序 - response = response.stream().sorted(Comparator.comparing(PointQueryResponse::getUpdateTime).reversed()).collect(Collectors.toList()); + response = response.stream() + .filter(p -> p.getPointValue() != null) + .sorted(Comparator.comparing(PointQueryResponse::getUpdateTime).reversed()).collect(Collectors.toList()); } return response; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 4126698..870d722 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -332,8 +332,8 @@ and t.device_category = #{deviceCategory} - - and t.data_point_name like CONCAT('%', #{dataPointName}, '%') + + and t.point_name like CONCAT('%', #{pointName}, '%') and t.data_point like CONCAT('%', #{dataPoint}, '%') @@ -362,8 +362,8 @@ ) as tmp where 1=1 - - and tmp.dataPointName like CONCAT('%', #{dataPointName}, '%') + + and tmp.point_name like CONCAT('%', #{pointName}, '%') and tmp.dataPoint like CONCAT('%', #{dataPoint}, '%') -- 2.49.0 From 2bbc0abc0819744c880173489f88a159dab74f7b Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 29 Sep 2025 10:14:46 +0800 Subject: [PATCH 160/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E5=B7=A5=E5=8D=95=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/mapper/EmsAlarmRecordsMapper.java | 8 ++++++- .../ems/service/IEmsAlarmRecordsService.java | 5 +++- .../impl/EmsAlarmRecordsServiceImpl.java | 20 ++++++++++++++-- .../service/impl/EmsTicketServiceImpl.java | 24 +++++++++++++++++++ .../impl/FXXDataProcessServiceImpl.java | 2 +- .../mapper/ems/EmsAlarmRecordsMapper.xml | 17 ++++++++++++- 6 files changed, 70 insertions(+), 6 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java index 41751b6..d7eeb52 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java @@ -99,5 +99,11 @@ public interface EmsAlarmRecordsMapper public void batchUpsert(@Param("recordsList")List recordsList); // 获取所有没有处理完成的告警记录 - public List getAllUnfinishedRecords(@Param("needUpdateKeys")List needUpdateKeys,@Param("siteId") String siteId); + public List getAllUnfinishedRecords(@Param("needUpdateKeys")List needUpdateKeys,@Param("siteId") String siteId, + @Param("deviceId") String deviceId); + + // 根据ticketNo更新告警状态 + public EmsAlarmRecords getAlarmByTicketNo(@Param("ticketNo")String ticketNo); + //获取指定设备未处理和处理中的告警 + public List getNeedPutRedisAlarm(@Param("siteId")String siteId, @Param("deviceId")String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java index 9fc29d1..139d857 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -88,8 +88,11 @@ public interface IEmsAlarmRecordsService public void initAlarmMatchInfo(); // 获取所有没有处理完成的告警记录 - public List getAllUnfinishedRecords(List needUpdateKeys, String siteId); + public List getAllUnfinishedRecords(List needUpdateKeys, String siteId, String deviceId); // 批量处理告警数据 public void batchProcessAlarmRecords(List recordsList); + + // 根据site_id和deviceId更新对应的redis + public void updateRedisAlarmRecords(String siteId, String deviceId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index 146c54e..08fcc62 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -9,6 +9,7 @@ import com.xzzn.common.core.domain.entity.SysUser; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.AlarmLevelStatus; import com.xzzn.common.enums.AlarmStatus; +import com.xzzn.common.enums.TicketStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsAlarmMatchData; @@ -159,6 +160,7 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService emsTicket.setContent(emsAlarmRecords.getAlarmContent()); emsTicket.setUserId(userId); emsTicket.setWorkUserId(userId); + emsTicket.setStatus(Long.valueOf(TicketStatus.WAITING.getCode())); emsTicket.setCreateTime(DateUtils.getNowDate()); emsTicket.setCreateBy(user.getUserName()); emsTicket.setUpdateTime(DateUtils.getNowDate()); @@ -267,8 +269,8 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService } @Override - public List getAllUnfinishedRecords(List needUpdateKeys, String siteId) { - return emsAlarmRecordsMapper.getAllUnfinishedRecords(needUpdateKeys,siteId); + public List getAllUnfinishedRecords(List needUpdateKeys, String siteId, String deviceId) { + return emsAlarmRecordsMapper.getAllUnfinishedRecords(needUpdateKeys,siteId,deviceId); } @Override @@ -276,5 +278,19 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService emsAlarmRecordsMapper.batchUpsert(recordsList); } + @Override + public void updateRedisAlarmRecords(String siteId, String deviceId) { + if (StringUtils.isEmpty(siteId) || StringUtils.isEmpty(deviceId)) { + return; + } + String redisKey = RedisKeyConstants.LATEST_ALARM_RECORD + "_" + siteId +"_" + deviceId; + List allDeviceRecords = emsAlarmRecordsMapper.getNeedPutRedisAlarm(siteId,deviceId); + // 转Map + Map newAlarms = allDeviceRecords.stream() + .filter(a -> !AlarmStatus.DONE.getCode().equals(a.getStatus())) + .collect(Collectors.toMap(EmsAlarmRecords::getAlarmPoint, a -> a)); + redisCache.setAllCacheMapValue(redisKey, newAlarms); + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java index 588cc1a..8e41617 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java @@ -3,10 +3,15 @@ package com.xzzn.ems.service.impl; import java.util.List; import java.util.Random; +import com.xzzn.common.enums.AlarmStatus; import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsAlarmRecords; import com.xzzn.ems.domain.EmsTicket; import com.xzzn.ems.domain.vo.TicketListVo; +import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; import com.xzzn.ems.mapper.EmsTicketMapper; +import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IEmsTicketService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -23,6 +28,10 @@ public class EmsTicketServiceImpl implements IEmsTicketService { @Autowired private EmsTicketMapper emsTicketMapper; + @Autowired + private EmsAlarmRecordsMapper emsAlarmRecordsMapper; + @Autowired + private IEmsAlarmRecordsService iEmsAlarmRecordsService; /** * 查询工单主-工单详情 @@ -76,6 +85,21 @@ public class EmsTicketServiceImpl implements IEmsTicketService @Override public int updateEmsTicket(EmsTicket emsTicket) { + String status = emsTicket.getStatus().toString(); + String ticketNo = emsTicket.getTicketNo(); + // 判断工单状态为:3-已完成 + if ("3".equals(status) && !StringUtils.isEmpty(ticketNo)) { + // 处理告警数据状态-已处理 + EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.getAlarmByTicketNo(ticketNo); + if (emsAlarmRecords != null) { + emsAlarmRecords.setStatus(AlarmStatus.DONE.getCode()); + emsAlarmRecords.setUpdateTime(DateUtils.getNowDate()); + emsAlarmRecords.setAlarmEndTime(DateUtils.getNowDate()); + emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords); + // 更新告警redis + iEmsAlarmRecordsService.updateRedisAlarmRecords(emsAlarmRecords.getSiteId(),emsAlarmRecords.getDeviceId()); + } + } emsTicket.setUpdateTime(DateUtils.getNowDate()); return emsTicketMapper.updateEmsTicket(emsTicket); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 5c2f718..4fa57ea 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -866,7 +866,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 批量查询数据库-需要更新的数据 Map needUpdateMap = new HashMap<>(); if (!needUpdateKeys.isEmpty()) { - List records = iEmsAlarmRecordsService.getAllUnfinishedRecords(needUpdateKeys,SITE_ID); + List records = iEmsAlarmRecordsService.getAllUnfinishedRecords(needUpdateKeys,SITE_ID, deviceId); // 转为Map便于快速获取 needUpdateMap = records.stream() .collect(Collectors.toMap( diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index 8b1dcd0..fa7a31d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -192,10 +192,11 @@ limit 1 - WHERE status 1 and site_id = #{siteId} + and device_id = #{deviceId} and alarm_point IN #{key} @@ -246,4 +247,18 @@ status = values(status), device_id = values(device_id) + + + + \ No newline at end of file -- 2.49.0 From 7121fdecfa95a920b02505aaafb5a96a76aadcd1 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 29 Sep 2025 20:05:16 +0800 Subject: [PATCH 161/336] =?UTF-8?q?0929-=E9=83=A8=E5=88=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/common/enums/TicketStatus.java | 30 +++++++++++++++++++ .../impl/EmsStatsReportServiceImpl.java | 8 ++--- .../mapper/ems/EmsAmmeterDataMapper.xml | 4 +-- .../resources/mapper/ems/EmsPcsDataMapper.xml | 1 - 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/TicketStatus.java diff --git a/ems-common/src/main/java/com/xzzn/common/enums/TicketStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/TicketStatus.java new file mode 100644 index 0000000..caad78d --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/TicketStatus.java @@ -0,0 +1,30 @@ +package com.xzzn.common.enums; + +/** + * ticket - 工单状态 + * + * @author xzzn + */ +public enum TicketStatus +{ + WAITING("1", "待处理"), PROCESSING("2", "处理中"),DONE("3", "已处理"); + + private final String code; + private final String info; + + TicketStatus(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 9e75504..4acb413 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -387,13 +387,13 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService String tarteDate = DateUtils.convertToString(targetMinute); PowerStatisListVo currentData = dataMap.get(tarteDate); if (currentData == null && lastData != null) { - BigDecimal pvPower = lastData.getPvPower(); - BigDecimal storagePower = lastData.getStoragePower(); - BigDecimal gridPower = lastData.getGridPower(); + BigDecimal pvPower = lastData.getPvPower()==null?new BigDecimal(0) :lastData.getGridPower(); + BigDecimal storagePower = lastData.getStoragePower()==null?new BigDecimal(0) :lastData.getGridPower(); + BigDecimal gridPower = lastData.getGridPower()==null?new BigDecimal(0) :lastData.getGridPower(); currentData = new PowerStatisListVo(tarteDate.toString(),gridPower,storagePower,pvPower); } else if (currentData == null && lastData == null){ // 开头无数据,所有字段设为null - currentData = new PowerStatisListVo(tarteDate.toString(), null, null, null); + currentData = new PowerStatisListVo(tarteDate.toString(), new BigDecimal(0), new BigDecimal(0), new BigDecimal(0)); } lastData = currentData; powerStatisListVoList.add(currentData); diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 862074f..eb67bf4 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -965,8 +965,8 @@ - MAX(CASE WHEN t.device_id = 'METE' THEN t.secondary_total_active_power END) AS gridPower, - MAX(CASE WHEN t.device_id = 'LOAD' THEN t.total_active_power END) AS storagePower, + MAX(CASE WHEN t.device_id = 'METE' THEN t.secondary_total_active_power END) AS storagePower, + MAX(CASE WHEN t.device_id = 'LOAD' THEN t.total_active_power END) AS gridPower, MAX(CASE WHEN t.device_id = 'METEGF' THEN t.total_active_power END) AS pvPower diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 791fab4..302d1a0 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -383,7 +383,6 @@ SELECT p.device_id, MAX(p.data_update_time) AS max_update_time FROM ems_pcs_data p where p.site_id = #{siteId} - and p.data_update_time <= CURDATE() GROUP BY p.device_id ) latest inner join ems_pcs_data t ON latest.device_id = t.device_id AND latest.max_update_time = t.data_update_time -- 2.49.0 From d8d0a83c87f038b2695055cd487adb68cf9bf853 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 9 Oct 2025 19:58:50 +0800 Subject: [PATCH 162/336] =?UTF-8?q?=E7=94=B5=E4=BB=B7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsEnergyPriceConfigController.java | 89 ++++++++ .../xzzn/ems/domain/EmsEnergyPriceConfig.java | 134 ++++++++++++ .../xzzn/ems/domain/EmsPriceTimeConfig.java | 102 +++++++++ .../ems/domain/vo/EnergyPriceTimeRange.java | 45 ++++ .../com/xzzn/ems/domain/vo/EnergyPriceVo.java | 99 +++++++++ .../mapper/EmsEnergyPriceConfigMapper.java | 69 ++++++ .../ems/mapper/EmsPriceTimeConfigMapper.java | 70 +++++++ .../service/IEmsEnergyPriceConfigService.java | 61 ++++++ .../impl/EmsEnergyPriceConfigServiceImpl.java | 198 ++++++++++++++++++ .../mapper/ems/EmsEnergyPriceConfigMapper.xml | 151 +++++++++++++ .../mapper/ems/EmsPriceTimeConfigMapper.xml | 127 +++++++++++ 11 files changed, 1145 insertions(+) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsPriceTimeConfig.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceTimeRange.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsPriceTimeConfigMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsPriceTimeConfigMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java new file mode 100644 index 0000000..e8818d2 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java @@ -0,0 +1,89 @@ +package com.xzzn.web.controller.ems; + +import java.util.List; + +import com.xzzn.ems.domain.vo.EnergyPriceVo; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.xzzn.common.annotation.Log; +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.BusinessType; +import com.xzzn.ems.service.IEmsEnergyPriceConfigService; +import com.xzzn.common.core.page.TableDataInfo; + +/** + * 电价配置Controller + * + * @author xzzn + * @date 2025-09-28 + */ +@RestController +@RequestMapping("/ems/energyPriceConfig") +public class EmsEnergyPriceConfigController extends BaseController +{ + @Autowired + private IEmsEnergyPriceConfigService emsEnergyPriceConfigService; + + /** + * 查询电价配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:config:list')") + @GetMapping("/list") + public TableDataInfo list() + { + List list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList(); + return getDataTable2(list); + } + + /** + * 获取电价配置详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:config:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(emsEnergyPriceConfigService.selectEmsEnergyPriceConfigById(id)); + } + + /** + * 新增电价配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:add')") + @Log(title = "电价配置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EnergyPriceVo priceVo) + { + return toAjax(emsEnergyPriceConfigService.insertEmsEnergyPriceConfig(priceVo)); + } + + /** + * 修改电价配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:edit')") + @Log(title = "电价配置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EnergyPriceVo priceVo) + { + return toAjax(emsEnergyPriceConfigService.updateEmsEnergyPriceConfig(priceVo)); + } + + /** + * 删除电价配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:remove')") + @Log(title = "电价配置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(emsEnergyPriceConfigService.deleteEmsEnergyPriceConfigByIds(ids)); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java new file mode 100644 index 0000000..c4c45c1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java @@ -0,0 +1,134 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; + +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_energy_price_config + * + * @author xzzn + * @date 2025-10-09 + */ +public class EmsEnergyPriceConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** 年份,如2025 */ + @Excel(name = "年份,如2025") + private String year; + + /** 月份,如"9"表示9月 */ + @Excel(name = "月份,如\"9\"表示9月") + private String month; + + /** 尖-peak电价(元/kWh) */ + @Excel(name = "尖-peak电价(元/kWh)") + private BigDecimal peak; + + /** 峰-high电价(元/kWh) */ + @Excel(name = "峰-high电价(元/kWh)") + private BigDecimal high; + + /** 平-flat电价(元/kWh) */ + @Excel(name = "平-flat电价(元/kWh)") + private BigDecimal flat; + + /** 谷-valley电价(元/kWh) */ + @Excel(name = "谷-valley电价(元/kWh)") + private BigDecimal valley; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setYear(String year) + { + this.year = year; + } + + public String getYear() + { + return year; + } + + public void setMonth(String month) + { + this.month = month; + } + + public String getMonth() + { + return month; + } + + public void setPeak(BigDecimal peak) + { + this.peak = peak; + } + + public BigDecimal getPeak() + { + return peak; + } + + public void setHigh(BigDecimal high) + { + this.high = high; + } + + public BigDecimal getHigh() + { + return high; + } + + public void setFlat(BigDecimal flat) + { + this.flat = flat; + } + + public BigDecimal getFlat() + { + return flat; + } + + public void setValley(BigDecimal valley) + { + this.valley = valley; + } + + public BigDecimal getValley() + { + return valley; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("year", getYear()) + .append("month", getMonth()) + .append("peak", getPeak()) + .append("high", getHigh()) + .append("flat", getFlat()) + .append("valley", getValley()) + .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/EmsPriceTimeConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPriceTimeConfig.java new file mode 100644 index 0000000..2bdc7ab --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPriceTimeConfig.java @@ -0,0 +1,102 @@ +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_price_time_config + * + * @author xzzn + * @date 2025-10-09 + */ +public class EmsPriceTimeConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** 时段开始时间 */ + @Excel(name = "时段开始时间") + private String startTime; + + /** 时段结束时间 */ + @Excel(name = "时段结束时间") + private String endTime; + + /** 电价类型: 尖-peak,峰-high,平-flat,谷-valley */ + @Excel(name = "电价类型: 尖-peak,峰-high,平-flat,谷-valley") + private String costType; + + /** 电价配置id */ + @Excel(name = "电价配置id") + private Long priceId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setStartTime(String startTime) + { + this.startTime = startTime; + } + + public String getStartTime() + { + return startTime; + } + + public void setEndTime(String endTime) + { + this.endTime = endTime; + } + + public String getEndTime() + { + return endTime; + } + + public void setCostType(String costType) + { + this.costType = costType; + } + + public String getCostType() + { + return costType; + } + + public void setPriceId(Long priceId) + { + this.priceId = priceId; + } + + public Long getPriceId() + { + return priceId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("costType", getCostType()) + .append("priceId", getPriceId()) + .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/EnergyPriceTimeRange.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceTimeRange.java new file mode 100644 index 0000000..eff9d04 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceTimeRange.java @@ -0,0 +1,45 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +/** + * 电价配置-电价列表-电价范围 + * + */ +public class EnergyPriceTimeRange { + /** 时段开始时间 */ + @Excel(name = "时段开始时间") + private String startTime; + + /** 时段结束时间 */ + @Excel(name = "时段结束时间") + private String endTime; + + /** 电价类型: 尖-peak,峰-high,平-flat,谷=valley */ + @Excel(name = "电价类型: 尖-peak,峰-high,平-flat,谷=valley") + private String costType; + + public String getCostType() { + return costType; + } + + public void setCostType(String costType) { + this.costType = costType; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java new file mode 100644 index 0000000..4614dca --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java @@ -0,0 +1,99 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 电价配置-电价列表-对象 + * + */ +public class EnergyPriceVo { + /** */ + private Long id; + /** 年份 */ + @Excel(name = "年份") + private String year; + /** 月份,如"9"表示9月 */ + @Excel(name = "月份,如\"9\"表示9月") + private String month; + /** 尖电价(元/kWh) */ + @Excel(name = "尖电价(元/kWh)") + private BigDecimal peak; + /** 峰电价(元/kWh) */ + @Excel(name = "峰电价(元/kWh)") + private BigDecimal high; + /** 平电价(元/kWh) */ + @Excel(name = "平电价(元/kWh)") + private BigDecimal flat; + /** 谷电价(元/kWh) */ + @Excel(name = "谷电价(元/kWh)") + private BigDecimal valley; + /** 电价时间范围对象 */ + private List range; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + + public BigDecimal getPeak() { + return peak; + } + + public void setPeak(BigDecimal peak) { + this.peak = peak; + } + + public BigDecimal getHigh() { + return high; + } + + public void setHigh(BigDecimal high) { + this.high = high; + } + + public BigDecimal getFlat() { + return flat; + } + + public void setFlat(BigDecimal flat) { + this.flat = flat; + } + + public BigDecimal getValley() { + return valley; + } + + public void setValley(BigDecimal valley) { + this.valley = valley; + } + + public List getRange() { + return range; + } + + public void setRange(List range) { + this.range = range; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java new file mode 100644 index 0000000..8609ff3 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java @@ -0,0 +1,69 @@ +package com.xzzn.ems.mapper; + +import java.util.List; + +import com.xzzn.ems.domain.EmsEnergyPriceConfig; +import org.apache.ibatis.annotations.Param; + +/** + * 电价配置Mapper接口 + * + * @author xzzn + * @date 2025-09-28 + */ +public interface EmsEnergyPriceConfigMapper +{ + /** + * 查询电价配置 + * + * @param id 电价配置主键 + * @return 电价配置 + */ + public EmsEnergyPriceConfig selectEmsEnergyPriceConfigById(Long id); + + /** + * 查询当年电价配置列表 + * + * @return 电价配置集合 + */ + public List selectEmsEnergyPriceConfigList(int currentYear); + + /** + * 新增电价配置 + * + * @param emsEnergyPriceConfig 电价配置 + * @return 结果 + */ + public int insertEmsEnergyPriceConfig(EmsEnergyPriceConfig emsEnergyPriceConfig); + + /** + * 修改电价配置 + * + * @param emsEnergyPriceConfig 电价配置 + * @return 结果 + */ + public int updateEmsEnergyPriceConfig(EmsEnergyPriceConfig emsEnergyPriceConfig); + + /** + * 删除电价配置 + * + * @param id 电价配置主键 + * @return 结果 + */ + public int deleteEmsEnergyPriceConfigById(Long id); + + /** + * 批量删除电价配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsEnergyPriceConfigByIds(Long[] ids); + + // 查询当年电价配置列表 + public List getCurrentYearConfigList(int currentYear); + // 根据指定年月获取电价配置 + public EmsEnergyPriceConfig getConfigListByYearAndMonth(@Param("currentYear") String currentYear, @Param("month")String month); + // 插入或更新 + public void insertOrUpdateEmsEnergyPriceConfig(EmsEnergyPriceConfig priceConfig); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPriceTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPriceTimeConfigMapper.java new file mode 100644 index 0000000..a4ef73d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPriceTimeConfigMapper.java @@ -0,0 +1,70 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsPriceTimeConfig; +import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; +import org.apache.ibatis.annotations.Param; + +/** + * 电价时间配置Mapper接口 + * + * @author xzzn + * @date 2025-10-09 + */ +public interface EmsPriceTimeConfigMapper +{ + /** + * 查询电价时间配置 + * + * @param id 电价时间配置主键 + * @return 电价时间配置 + */ + public EmsPriceTimeConfig selectEmsPriceTimeConfigById(Long id); + + /** + * 查询电价时间配置列表 + * + * @param emsPriceTimeConfig 电价时间配置 + * @return 电价时间配置集合 + */ + public List selectEmsPriceTimeConfigList(EmsPriceTimeConfig emsPriceTimeConfig); + + /** + * 新增电价时间配置 + * + * @param emsPriceTimeConfig 电价时间配置 + * @return 结果 + */ + public int insertEmsPriceTimeConfig(EmsPriceTimeConfig emsPriceTimeConfig); + + /** + * 修改电价时间配置 + * + * @param emsPriceTimeConfig 电价时间配置 + * @return 结果 + */ + public int updateEmsPriceTimeConfig(EmsPriceTimeConfig emsPriceTimeConfig); + + /** + * 删除电价时间配置 + * + * @param id 电价时间配置主键 + * @return 结果 + */ + public int deleteEmsPriceTimeConfigById(Long id); + + /** + * 批量删除电价时间配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsPriceTimeConfigByIds(Long[] ids); + + // 获取年月的电价时间范围 + public List getTimeRangeByPriceId(Long priceId); + // 批量插入 + public int batchInsert(List timeConfigs); + // 删除priceId对应的时间范围配置 + public void deleteTimeRangeByPriceId(Long[] priceIds); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java new file mode 100644 index 0000000..ae44a2e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsEnergyPriceConfig; +import com.xzzn.ems.domain.vo.EnergyPriceVo; + +/** + * 电价配置Service接口 + * + * @author xzzn + * @date 2025-09-28 + */ +public interface IEmsEnergyPriceConfigService +{ + /** + * 查询电价配置 + * + * @param id 电价配置主键 + * @return 电价配置 + */ + public EnergyPriceVo selectEmsEnergyPriceConfigById(Long id); + + /** + * 查询电价配置列表 + * + * @return 电价配置集合 + */ + public List selectEmsEnergyPriceConfigList(); + + /** + * 新增电价配置-按月 + * + * @param priceVo 电价配置 + * @return 结果 + */ + public int insertEmsEnergyPriceConfig(EnergyPriceVo priceVo); + + /** + * 修改电价配置 + * + * @param priceVo 电价配置 + * @return 结果 + */ + public int updateEmsEnergyPriceConfig(EnergyPriceVo priceVo); + + /** + * 批量删除电价配置 + * + * @param ids 需要删除的电价配置主键集合 + * @return 结果 + */ + public int deleteEmsEnergyPriceConfigByIds(Long[] ids); + + /** + * 删除电价配置信息 + * + * @param id 电价配置主键 + * @return 结果 + */ + public int deleteEmsEnergyPriceConfigById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java new file mode 100644 index 0000000..d288835 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -0,0 +1,198 @@ +package com.xzzn.ems.service.impl; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsPriceTimeConfig; +import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; +import com.xzzn.ems.domain.vo.EnergyPriceVo; +import com.xzzn.ems.mapper.EmsPriceTimeConfigMapper; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper; +import com.xzzn.ems.domain.EmsEnergyPriceConfig; +import com.xzzn.ems.service.IEmsEnergyPriceConfigService; + +/** + * 电价配置Service业务层处理 + * + * @author xzzn + * @date 2025-09-28 + */ +@Service +public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigService +{ + @Autowired + private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; + @Autowired + private EmsPriceTimeConfigMapper emsPriceTimeConfigMapper; + + /** + * 查询电价配置 + * + * @param id 电价配置主键 + * @return 电价配置 + */ + @Override + public EnergyPriceVo selectEmsEnergyPriceConfigById(Long id) + { + EnergyPriceVo vo = new EnergyPriceVo(); + EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.selectEmsEnergyPriceConfigById(id); + if(priceConfig != null) { + BeanUtils.copyProperties(priceConfig,vo); + // 时间范围 + if (priceConfig.getId() != null) { + List priceVos = emsPriceTimeConfigMapper.getTimeRangeByPriceId(priceConfig.getId()); + vo.setRange(priceVos); + } + } else { + return null; + } + return vo; + } + + /** + * 查询电价配置列表 + * + * @return 电价配置 + */ + @Override + public List selectEmsEnergyPriceConfigList() + { + List responses = new ArrayList<>(); + // 仅查询当年配置 + LocalDate currentDate = LocalDate.now(); + int currentYear = currentDate.getYear(); + + List priceConfigs = emsEnergyPriceConfigMapper.getCurrentYearConfigList(currentYear); + + if (priceConfigs != null && priceConfigs.size() > 0) { + for (EmsEnergyPriceConfig priceConfig : priceConfigs) { + EnergyPriceVo vo = new EnergyPriceVo(); + BeanUtils.copyProperties(priceConfig, vo); + // 时间范围 + if (priceConfig.getId() != null) { + List priceVos = emsPriceTimeConfigMapper.getTimeRangeByPriceId(priceConfig.getId()); + vo.setRange(priceVos); + } + responses.add(vo); + } + } + + return responses; + } + + /** + * 新增电价配置 + * + * @param priceVo 电价配置 + * @return 结果 + */ + @Override + public int insertEmsEnergyPriceConfig(EnergyPriceVo priceVo) + { + String year = priceVo.getYear(); + String month = priceVo.getMonth(); + + // 判断入参 + if(StringUtils.isEmpty(year) || StringUtils.isEmpty(month)){ + return 0; + } + + // 校验当前月电价设置是否已存在,不存在则新增,存在则更新 + EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(year,month); + if (priceConfig != null){ + return 0; + } else { + priceConfig = new EmsEnergyPriceConfig(); + } + BeanUtils.copyProperties(priceVo,priceConfig); + priceConfig.setCreateTime(DateUtils.getNowDate()); + priceConfig.setUpdateTime(DateUtils.getNowDate()); + priceConfig.setCreateBy("system"); + priceConfig.setUpdateBy("system"); + emsEnergyPriceConfigMapper.insertOrUpdateEmsEnergyPriceConfig(priceConfig); + + return batchInsetPriceTimeRange(priceVo,priceConfig.getId()); + } + + private int batchInsetPriceTimeRange(EnergyPriceVo priceVo, Long priceId) { + List timeConfigs = new ArrayList<>(); + List rangeVos = priceVo.getRange(); + if (rangeVos != null && rangeVos.size() > 0) { + for (EnergyPriceTimeRange rangeVo : rangeVos) { + EmsPriceTimeConfig timeConfig = new EmsPriceTimeConfig(); + BeanUtils.copyProperties(rangeVo,timeConfig); + timeConfig.setCreateTime(DateUtils.getNowDate()); + timeConfig.setUpdateTime(DateUtils.getNowDate()); + timeConfig.setCreateBy("system"); + timeConfig.setUpdateBy("system"); + timeConfig.setPriceId(priceId); + timeConfigs.add(timeConfig); + } + } + // 批量插入 + return emsPriceTimeConfigMapper.batchInsert(timeConfigs); + } + + /** + * 修改电价配置 + * + * @param priceVo 电价配置 + * @return 结果 + */ + @Override + public int updateEmsEnergyPriceConfig(EnergyPriceVo priceVo) + { + if (priceVo == null || priceVo.getId() == null) { + return 0; + } + // 不存在 + EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.selectEmsEnergyPriceConfigById(priceVo.getId()); + if (priceConfig == null) { + return 0; + } + + // 存在更新 + BeanUtils.copyProperties(priceVo, priceConfig); + priceConfig.setUpdateTime(DateUtils.getNowDate()); + priceConfig.setUpdateBy("system"); + emsEnergyPriceConfigMapper.updateEmsEnergyPriceConfig(priceConfig); + + // 时间配置,全删,全插入 + Long[] priceIds = {priceVo.getId()}; + emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(priceIds); + return batchInsetPriceTimeRange(priceVo,priceConfig.getId()); + } + + /** + * 批量删除电价配置 + * + * @param ids 需要删除的电价配置主键 + * @return 结果 + */ + @Override + public int deleteEmsEnergyPriceConfigByIds(Long[] ids) + { + // 先删时间配置 + emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(ids); + // 再删月电价 + return emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigByIds(ids); + } + + /** + * 删除电价配置信息 + * + * @param id 电价配置主键 + * @return 结果 + */ + @Override + public int deleteEmsEnergyPriceConfigById(Long id) + { + return emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigById(id); + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml new file mode 100644 index 0000000..8be7131 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + select id, year, month, peak, high, flat, valley, create_by, create_time, update_by, update_time, remark from ems_energy_price_config + + + + + + + + insert into ems_energy_price_config + + year, + month, + peak, + high, + flat, + valley, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{year}, + #{month}, + #{peak}, + #{high}, + #{flat}, + #{valley}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_energy_price_config + + year = #{year}, + month = #{month}, + peak = #{peak}, + high = #{high}, + flat = #{flat}, + valley = #{valley}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_energy_price_config where id = #{id} + + + + delete from ems_energy_price_config where id in + + #{id} + + + + + + + INSERT INTO ems_energy_price_config ( + id, + year, + month, + peak, + high, + flat, + valley, + create_by, + create_time, + update_by, + update_time, + remark + ) VALUES ( + #{id}, + #{year}, + #{month}, + #{peak}, + #{high}, + #{flat}, + #{valley}, + 'system', + NOW(), + 'system', + NOW(), + #{remark} + ) ON DUPLICATE KEY UPDATE + peak = #{peak}, + high = #{high}, + flat = #{flat}, + valley = #{valley}, + update_time = NOW(); + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPriceTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPriceTimeConfigMapper.xml new file mode 100644 index 0000000..887441a --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsPriceTimeConfigMapper.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + select id, start_time, end_time, cost_type, price_id, create_by, create_time, update_by, update_time, remark from ems_price_time_config + + + + + + + + insert into ems_price_time_config + + start_time, + end_time, + cost_type, + price_id, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{startTime}, + #{endTime}, + #{costType}, + #{priceId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_price_time_config + + start_time = #{startTime}, + end_time = #{endTime}, + cost_type = #{costType}, + price_id = #{priceId}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_price_time_config where id = #{id} + + + + delete from ems_price_time_config where id in + + #{id} + + + + + + + + INSERT INTO ems_price_time_config ( + start_time, end_time, cost_type, price_id, create_by, create_time, update_by, update_time, remark + ) VALUES + + + ( + #{item.startTime}, + #{item.endTime}, + #{item.costType}, + #{item.priceId}, + #{item.createBy}, + #{item.createTime}, + #{item.updateBy}, + #{item.updateTime}, + #{item.remark} + ) + + + + + delete from ems_price_time_config where price_id in + + #{priceId} + + + \ No newline at end of file -- 2.49.0 From 636a2ab73b851047e5f9e5bf1a7c0df1de76ebea Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 10 Oct 2025 11:21:33 +0800 Subject: [PATCH 163/336] =?UTF-8?q?=E7=94=B5=E4=BB=B7=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8A=A0=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4?= =?UTF-8?q?-=E6=9A=82=E6=97=B6=E5=8F=AA=E5=8F=96=E5=B9=B4=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsEnergyPriceConfigController.java | 13 +++---------- .../ems/service/IEmsEnergyPriceConfigService.java | 2 +- .../impl/EmsEnergyPriceConfigServiceImpl.java | 8 ++++---- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java index e8818d2..b6c8e6a 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java @@ -5,14 +5,7 @@ import java.util.List; import com.xzzn.ems.domain.vo.EnergyPriceVo; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.xzzn.common.annotation.Log; import com.xzzn.common.core.controller.BaseController; import com.xzzn.common.core.domain.AjaxResult; @@ -38,9 +31,9 @@ public class EmsEnergyPriceConfigController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:config:list')") @GetMapping("/list") - public TableDataInfo list() + public TableDataInfo list(String startTime,String endTime) { - List list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList(); + List list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList(startTime,endTime); return getDataTable2(list); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java index ae44a2e..1be7b8d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java @@ -25,7 +25,7 @@ public interface IEmsEnergyPriceConfigService * * @return 电价配置集合 */ - public List selectEmsEnergyPriceConfigList(); + public List selectEmsEnergyPriceConfigList(String startTime,String endTime); /** * 新增电价配置-按月 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java index d288835..187662b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -61,12 +61,12 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer * @return 电价配置 */ @Override - public List selectEmsEnergyPriceConfigList() + public List selectEmsEnergyPriceConfigList(String startTime,String endTime) { List responses = new ArrayList<>(); - // 仅查询当年配置 - LocalDate currentDate = LocalDate.now(); - int currentYear = currentDate.getYear(); + // 根据时间截取年份 + String[] startTimeArr = startTime.split("-"); + int currentYear = Integer.valueOf(startTimeArr[0]); List priceConfigs = emsEnergyPriceConfigMapper.getCurrentYearConfigList(currentYear); -- 2.49.0 From b861ad7593e5db2a1f7a3e738e617ad13d93fd97 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 10 Oct 2025 16:10:37 +0800 Subject: [PATCH 164/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=94=B5?= =?UTF-8?q?=E8=A1=A8=E6=8A=A5=E8=A1=A8-=E5=B0=96=E5=B3=B0=E5=B9=B3?= =?UTF-8?q?=E8=B0=B7=E6=97=A5=E5=B7=AE=E5=80=BC=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 4 +- .../common/constant/RedisKeyConstants.java | 6 + .../java/com/xzzn/common/utils/DateUtils.java | 25 ++- .../manager/ModbusConnectionManager.java | 5 + .../xzzn/ems/domain/EmsDailyEnergyData.java | 211 ++++++++++++++++++ .../ems/mapper/EmsDailyEnergyDataMapper.java | 67 ++++++ .../mapper/EmsEnergyPriceConfigMapper.java | 3 + .../service/IEmsEnergyPriceConfigService.java | 3 + .../impl/DDSDataProcessServiceImpl.java | 68 ++++-- .../impl/EmsEnergyPriceConfigServiceImpl.java | 20 ++ .../impl/FXXDataProcessServiceImpl.java | 177 ++++++++++++++- .../mapper/ems/EmsAmmeterDataMapper.xml | 20 +- .../mapper/ems/EmsDailyEnergyDataMapper.xml | 181 +++++++++++++++ .../mapper/ems/EmsEnergyPriceConfigMapper.xml | 10 + 14 files changed, 766 insertions(+), 34 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index c72c44d..6fac929 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -133,11 +133,11 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } - private static final long FORCE_INTERVAL = 60 * 1000; // 1分钟(毫秒) + /*private static final long FORCE_INTERVAL = 60 * 1000; // 1分钟(毫秒) @Scheduled(fixedRate = FORCE_INTERVAL) // 每分钟执行一次 public void scheduledForceSave() { System.out.println("执行定时强制存储任务:" + new Date()); - } + }*/ } \ No newline at end of file diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 30231c4..2df12f2 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -72,4 +72,10 @@ public class RedisKeyConstants /** 现有的告警数据 */ public static final String LATEST_ALARM_RECORD = "LATEST_ALARM_RECORD"; + + /** fx-电表电量差值起始数据 */ + public static final String DIFF_CHARGE_START = "diff_charge_start_"; + + /** 预存电价时间配置 */ + public static final String ENERGY_PRICE_TIME = "energy_price_time_"; } diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index c7a0e57..951bb4d 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -218,7 +218,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils } /** - * 获取昨天的日期,格式为yyyy-MM-dd + * 获取昨天的日期,格式为yyyy-MM-dd 23:59:59 * @return 昨天的日期字符串 */ public static String getYesterdayDate() { @@ -226,8 +226,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils LocalDate today = LocalDate.now(); // 减去一天得到昨天 LocalDate yesterday = today.minusDays(1); + // 将日期转换为LocalDateTime,并设置时间为23:59:59 + LocalDateTime yesterdayEndTime = yesterday.atTime(23, 59, 59); // 定义日期格式化器 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYYMMDD); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM_SS); // 格式化并返回 return yesterday.format(formatter); } @@ -372,4 +374,23 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils .toLocalDateTime(); return dateTime; } + + // 时间戳转时间 + public static Date convertUpdateTime(Long updateTime) { + if (updateTime == null) { + return null; + } + + // 兼容10位(秒级)和13位(毫秒级) + int length = String.valueOf(updateTime).length(); + if (length == 10) { // 10位秒级 -> 转换为毫秒级 + updateTime *= 1000; + } else if (length != 13) { // 既不是10位也不是13位,视为非法 + System.err.println("时间戳格式错误,必须是10位(秒)或13位(毫秒)"); + return null; + } + + // 3. 转换为Date + return new Date(updateTime); + } } diff --git a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java index 98e83a2..901dec7 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java +++ b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java @@ -4,6 +4,7 @@ import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.service.IEmsAlarmRecordsService; +import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import org.apache.commons.pool2.impl.GenericObjectPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +39,8 @@ public class ModbusConnectionManager implements ApplicationRunner { private EmsDevicesSettingMapper deviceRepo; @Autowired private IEmsAlarmRecordsService iEmsAlarmRecordsService; + @Autowired + private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; @Override public void run(ApplicationArguments args) throws Exception { @@ -57,6 +60,8 @@ public class ModbusConnectionManager implements ApplicationRunner { private void initData() { // 初始化-告警数据 iEmsAlarmRecordsService.initAlarmMatchInfo(); + // 初始化当月电价 + iEmsEnergyPriceConfigService.initCurrentMonthPrice(); } /** * 获取连接(带自动创建和缓存) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java new file mode 100644 index 0000000..e7ea25e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java @@ -0,0 +1,211 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_daily_energy_data + * + * @author xzzn + * @date 2025-10-09 + */ +public class EmsDailyEnergyData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 数据日期:yyyy-MM-dd */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据日期:yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataDate; + + /** 尖峰时段充电差值 */ + @Excel(name = "尖峰时段充电差值") + private BigDecimal peakChargeDiff; + + /** 尖峰时段放电差值 */ + @Excel(name = "尖峰时段放电差值") + private BigDecimal peakDischargeDiff; + + /** 峰时时段充电差值 */ + @Excel(name = "峰时时段充电差值") + private BigDecimal highChargeDiff; + + /** 峰时时段放电差值 */ + @Excel(name = "峰时时段放电差值") + private BigDecimal highDischargeDiff; + + /** 平时时段充电差值 */ + @Excel(name = "平时时段充电差值") + private BigDecimal flatChargeDiff; + + /** 平时时段放电差值 */ + @Excel(name = "平时时段放电差值") + private BigDecimal flatDischargeDiff; + + /** 谷时时段充电差值 */ + @Excel(name = "谷时时段充电差值") + private BigDecimal valleyChargeDiff; + + /** 谷时时段放电差值 */ + @Excel(name = "谷时时段放电差值") + private BigDecimal valleyDischargeDiff; + + /** 差值计算时间(如2025-10-10 23:59:00) */ + @Excel(name = "差值计算时间", readConverterExp = "如=2025-10-10,2=3:59:00") + private Date calcTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public void setDataDate(Date dataDate) + { + this.dataDate = dataDate; + } + + public Date getDataDate() + { + return dataDate; + } + + public void setPeakChargeDiff(BigDecimal peakChargeDiff) + { + this.peakChargeDiff = peakChargeDiff; + } + + public BigDecimal getPeakChargeDiff() + { + return peakChargeDiff; + } + + public void setPeakDischargeDiff(BigDecimal peakDischargeDiff) + { + this.peakDischargeDiff = peakDischargeDiff; + } + + public BigDecimal getPeakDischargeDiff() + { + return peakDischargeDiff; + } + + public void setHighChargeDiff(BigDecimal highChargeDiff) + { + this.highChargeDiff = highChargeDiff; + } + + public BigDecimal getHighChargeDiff() + { + return highChargeDiff; + } + + public void setHighDischargeDiff(BigDecimal highDischargeDiff) + { + this.highDischargeDiff = highDischargeDiff; + } + + public BigDecimal getHighDischargeDiff() + { + return highDischargeDiff; + } + + public void setFlatChargeDiff(BigDecimal flatChargeDiff) + { + this.flatChargeDiff = flatChargeDiff; + } + + public BigDecimal getFlatChargeDiff() + { + return flatChargeDiff; + } + + public void setFlatDischargeDiff(BigDecimal flatDischargeDiff) + { + this.flatDischargeDiff = flatDischargeDiff; + } + + public BigDecimal getFlatDischargeDiff() + { + return flatDischargeDiff; + } + + public void setValleyChargeDiff(BigDecimal valleyChargeDiff) + { + this.valleyChargeDiff = valleyChargeDiff; + } + + public BigDecimal getValleyChargeDiff() + { + return valleyChargeDiff; + } + + public void setValleyDischargeDiff(BigDecimal valleyDischargeDiff) + { + this.valleyDischargeDiff = valleyDischargeDiff; + } + + public BigDecimal getValleyDischargeDiff() + { + return valleyDischargeDiff; + } + + public void setCalcTime(Date calcTime) + { + this.calcTime = calcTime; + } + + public Date getCalcTime() + { + return calcTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("siteId", getSiteId()) + .append("dataDate", getDataDate()) + .append("peakChargeDiff", getPeakChargeDiff()) + .append("peakDischargeDiff", getPeakDischargeDiff()) + .append("highChargeDiff", getHighChargeDiff()) + .append("highDischargeDiff", getHighDischargeDiff()) + .append("flatChargeDiff", getFlatChargeDiff()) + .append("flatDischargeDiff", getFlatDischargeDiff()) + .append("valleyChargeDiff", getValleyChargeDiff()) + .append("valleyDischargeDiff", getValleyDischargeDiff()) + .append("calcTime", getCalcTime()) + .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/mapper/EmsDailyEnergyDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java new file mode 100644 index 0000000..2316e16 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java @@ -0,0 +1,67 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsDailyEnergyData; +import org.apache.ibatis.annotations.Param; + +/** + * 站点电每日数据Mapper接口 + * + * @author xzzn + * @date 2025-10-09 + */ +public interface EmsDailyEnergyDataMapper +{ + /** + * 查询站点电每日数据 + * + * @param id 站点电每日数据主键 + * @return 站点电每日数据 + */ + public EmsDailyEnergyData selectEmsDailyEnergyDataById(Long id); + + /** + * 查询站点电每日数据列表 + * + * @param emsDailyEnergyData 站点电每日数据 + * @return 站点电每日数据集合 + */ + public List selectEmsDailyEnergyDataList(EmsDailyEnergyData emsDailyEnergyData); + + /** + * 新增站点电每日数据 + * + * @param emsDailyEnergyData 站点电每日数据 + * @return 结果 + */ + public int insertEmsDailyEnergyData(EmsDailyEnergyData emsDailyEnergyData); + + /** + * 修改站点电每日数据 + * + * @param emsDailyEnergyData 站点电每日数据 + * @return 结果 + */ + public int updateEmsDailyEnergyData(EmsDailyEnergyData emsDailyEnergyData); + + /** + * 删除站点电每日数据 + * + * @param id 站点电每日数据主键 + * @return 结果 + */ + public int deleteEmsDailyEnergyDataById(Long id); + + /** + * 批量删除站点电每日数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsDailyEnergyDataByIds(Long[] ids); + + // 获取站点某日电表数据 + public EmsDailyEnergyData getDataByDate(@Param("siteId")String siteId,@Param("today") String today); + // 插入或更新每日尖峰平谷差值 + public void insertOrUpdateData(EmsDailyEnergyData energyData); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java index 8609ff3..f6b3d2e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java @@ -3,6 +3,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsEnergyPriceConfig; +import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import org.apache.ibatis.annotations.Param; /** @@ -66,4 +67,6 @@ public interface EmsEnergyPriceConfigMapper public EmsEnergyPriceConfig getConfigListByYearAndMonth(@Param("currentYear") String currentYear, @Param("month")String month); // 插入或更新 public void insertOrUpdateEmsEnergyPriceConfig(EmsEnergyPriceConfig priceConfig); + // 获取指定年月的电价时间配置 + public List getTimeRangeByDate(@Param("currentYear")int currentYear, @Param("currentMonth")int currentMonth); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java index 1be7b8d..c0ee58f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java @@ -58,4 +58,7 @@ public interface IEmsEnergyPriceConfigService * @return 结果 */ public int deleteEmsEnergyPriceConfigById(Long id); + + // 初始化当月电价 + public void initCurrentMonthPrice(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index ebf1617..2104c13 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -77,6 +77,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsDailyChargeDataMapper emsDailyChargeDataMapper; @Autowired private IEmsAlarmRecordsService iEmsAlarmRecordsService; + @Autowired + private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; public DDSDataProcessServiceImpl(ObjectMapper objectMapper) { super(objectMapper); @@ -926,31 +928,32 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dealDDSDailyChargeDate(obj,deviceId); } + private EmsDailyEnergyData initEnergyData() { + EmsDailyEnergyData energyData = new EmsDailyEnergyData(); + energyData.setSiteId(SITE_ID); + energyData.setDataDate(DateUtils.getNowDate()); + energyData.setCreateBy("system"); + energyData.setCreateTime(DateUtils.getNowDate()); + energyData.setUpdateBy("system"); + energyData.setUpdateTime(DateUtils.getNowDate()); + return energyData; + } + private void dealDDSDailyChargeDate(Map obj, String deviceId) { - log.info("start dealDDSDailyChargeDate"); // 初始化今日充放电 BigDecimal dailyDisChargeDate = new BigDecimal(0); BigDecimal dailyChargeDate = new BigDecimal(0); BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN")); BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN")); - // 初始化当日数据 - EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); - emsDailyChargeData.setSiteId(SITE_ID); - emsDailyChargeData.setDeviceId(deviceId); - emsDailyChargeData.setDateTime(DateUtils.getNowDate()); - emsDailyChargeData.setTotalChargeData(nowTotalChargeDate); - emsDailyChargeData.setTotalDischargeData(nowTotalDisChargeDate); - emsDailyChargeData.setCreateBy("system"); - emsDailyChargeData.setCreateTime(DateUtils.getNowDate()); - emsDailyChargeData.setUpdateBy("system"); - emsDailyChargeData.setUpdateTime(DateUtils.getNowDate()); + // 初始化当日数据-总的 + EmsDailyChargeData emsDailyChargeData = initDailyChargeData(deviceId,nowTotalChargeDate,nowTotalDisChargeDate); // 获取redis存放昨日最晚数据 String yestData = DateUtils.getYesterdayDate(); String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestData; EmsAmmeterData yestDate = redisCache.getCacheObject(yestDateRedisKey); if (yestDate == null) { - // redis没有这查电表总数据表 + // redis没有这查电表总数据表取截止到昨日最新第一条数据 yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData); // 数据存redis-有效期1天 redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); @@ -968,7 +971,44 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 插入或更新每日充放电数据表 emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); - log.info("end dealDDSDailyChargeDate"); + + // 初始化数据-尖峰平谷 + EmsDailyEnergyData energyData = initEnergyData(); + // 计算尖峰平谷差值 + energyData.setPeakChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGJDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActivePeak()));// 正向-尖 + energyData.setHighChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGFDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveHigh()));// 正向-峰 + energyData.setFlatChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGPDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveFlat()));// 正向-平 + energyData.setValleyChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGGDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveValley()));// 正向-谷 + energyData.setPeakDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGJDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActivePeak()));// 反向-尖 + energyData.setHighDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGFDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveHigh()));// 反向-峰 + energyData.setFlatDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGPDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveFlat()));// 反向-平 + energyData.setValleyDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGGDN")) + .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveValley()));// 反向-谷 + energyData.setCalcTime(DateUtils.getNowDate()); + // 插入或更新电表每日差值数据表 + emsDailyEnergyDataMapper.insertOrUpdateData(energyData); + } + + private EmsDailyChargeData initDailyChargeData(String deviceId, BigDecimal nowTotalChargeDate, + BigDecimal nowTotalDisChargeDate) { + EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); + emsDailyChargeData.setSiteId(SITE_ID); + emsDailyChargeData.setDeviceId(deviceId); + emsDailyChargeData.setDateTime(DateUtils.getNowDate()); + emsDailyChargeData.setTotalChargeData(nowTotalChargeDate); + emsDailyChargeData.setTotalDischargeData(nowTotalDisChargeDate); + emsDailyChargeData.setCreateBy("system"); + emsDailyChargeData.setCreateTime(DateUtils.getNowDate()); + emsDailyChargeData.setUpdateBy("system"); + emsDailyChargeData.setUpdateTime(DateUtils.getNowDate()); + return emsDailyChargeData; } // 数据分组处理 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java index 187662b..d9623da 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -3,7 +3,10 @@ package com.xzzn.ems.service.impl; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsPriceTimeConfig; @@ -30,6 +33,8 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; @Autowired private EmsPriceTimeConfigMapper emsPriceTimeConfigMapper; + @Autowired + private RedisCache redisCache; /** * 查询电价配置 @@ -195,4 +200,19 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer { return emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigById(id); } + + /** + * 初始化当月的电价 + */ + @Override + public void initCurrentMonthPrice() { + // 获取当年和当月的电价 + int currentMonth = LocalDate.now().getMonthValue(); + int currentYear = LocalDate.now().getYear(); + + List timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(currentYear,currentMonth); + + String key = RedisKeyConstants.ENERGY_PRICE_TIME + currentYear + currentMonth; + redisCache.setCacheObject(key,timeRanges, 31, TimeUnit.DAYS); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 4fa57ea..1a310be 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -13,20 +13,26 @@ import com.xzzn.common.enums.*; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @Service @@ -69,6 +75,10 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private IEmsAlarmRecordsService iEmsAlarmRecordsService; @Autowired private EmsCoolingDataMapper emsCoolingDataMapper; + @Autowired + private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; + @Autowired + private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -84,6 +94,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl String deviceId = obj.get("Device").toString(); String jsonData = obj.get("Data").toString(); + Long timestamp = Long.valueOf(obj.get("timestamp").toString()); + Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); log.info("deviceId:" + deviceId); boolean isEmpty = checkJsonDataEmpty(jsonData); @@ -102,16 +114,16 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else if (deviceId.contains("BMSC")) { log.info("BMSC data:"+ jsonData); batteryClusterDataProcess(deviceId, jsonData); - batteryDataProcess(deviceId, jsonData); + batteryDataProcess(deviceId, jsonData,dataUpdateTime); } else if (deviceId.contains("PCS")) { - pcsDataProcess(deviceId, jsonData); + pcsDataProcess(deviceId, jsonData,dataUpdateTime); pcsBranchDataProcess(deviceId, jsonData); dealFXXDailyChargeDate(deviceId, jsonData); } else if (deviceId.contains("LOAD")) { - loadDataProcess(deviceId, jsonData); + loadDataProcess(deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains("METE")) { - meteDataProcess(deviceId, jsonData); + meteDataProcess(deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains("donghuan")) { dhDataProcess(deviceId, jsonData); } else if (deviceId.contains("ZSLQ")) { @@ -330,7 +342,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } - private void batteryDataProcess(String deviceId, String dataJson) { + private void batteryDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { EmsDevicesSetting joken = new EmsDevicesSetting(); joken.setDeviceId(deviceId); List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); @@ -367,7 +379,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl batteryData.setBatteryPack(stackDeviceId); // 时间戳 - batteryData.setDataTimestamp(new Date()); + batteryData.setDataTimestamp(dataUpdateTime); // 系统管理字段 batteryData.setCreateBy("system"); batteryData.setCreateTime(DateUtils.getNowDate()); @@ -413,13 +425,13 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } } - private void pcsDataProcess(String deviceId, String dataJson) { + private void pcsDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); //pcs EmsPcsData pcsData = new EmsPcsData(); // 时间与状态类字段 - pcsData.setDataUpdateTime(new Date()); + pcsData.setDataUpdateTime(dataUpdateTime); pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); pcsData.setGridStatus(GridStatus.GRID.getCode()); pcsData.setDeviceStatus(DeviceStatus.ONLINE.getCode()); @@ -541,7 +553,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } - private void loadDataProcess(String deviceId, String dataJson) { + private void loadDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { //总表 Map obj = JSON.parseObject(dataJson, new TypeReference>() { @@ -549,7 +561,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsAmmeterData dataLoad = new EmsAmmeterData(); // 更新时间 - dataLoad.setDataUpdateTime(new Date()); + dataLoad.setDataUpdateTime(dataUpdateTime); // 电能设置-组合有功 dataLoad.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); @@ -664,7 +676,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl log.info("end dealFXXDailyChargeDate"); } - private void meteDataProcess(String deviceId, String dataJson) { + private void meteDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { //总表 Map obj = JSON.parseObject(dataJson, new TypeReference>() { @@ -672,7 +684,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsAmmeterData dataLoad = new EmsAmmeterData(); // 更新时间 - dataLoad.setDataUpdateTime(new Date()); + dataLoad.setDataUpdateTime(dataUpdateTime); // 电压+电流 dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); @@ -756,7 +768,148 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + + // 处理电表每日充放电数据 + dealAmmeterDailyDate(obj, deviceId, dataUpdateTime); } + + private void dealAmmeterDailyDate(Map obj, String deviceId, Date dataUpdateTime) { + // 先获取当月电价配置,redis没有这查数据库,都没有则返回 + String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); + List timeRanges = redisCache.getCacheObject(priceKey); + if (timeRanges == null) { + timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(LocalDate.now().getYear(),LocalDate.now().getMonthValue()); + if (timeRanges == null) { + return; + } + redisCache.setCacheObject(priceKey,timeRanges, 31, TimeUnit.DAYS); + } + + // 根据时间范围判断数据类型(尖峰平谷),无法确定数据类型则不处理 + String costType = ""; + String startTime = ""; + for (EnergyPriceTimeRange timeRange : timeRanges) { + startTime = timeRange.getStartTime(); + if (isInPriceTimeRange(startTime,timeRange.getEndTime(),dataUpdateTime)) { + costType = timeRange.getCostType(); + break; + } + } + if (StringUtils.isEmpty(costType)) { + return; + } + + // 确定数据类型,获取小于等于开始时刻的最新数据。 + startTime = concateCurrentDayTime(startTime); + String startTimeDataKey = RedisKeyConstants.DIFF_CHARGE_START + SITE_ID +"_" + startTime; + Map redisHash = redisCache.getCacheObject(startTimeDataKey); + // redis无,就取数据库 + if (redisHash == null) { + // 查询数据库-电表表数据取截止到昨日最新一条数据,均无默认初始值0 + EmsAmmeterData ammeterData = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,startTime); + redisHash = new HashMap<>(); + redisHash.put("charge", ammeterData == null ? + new BigDecimal(0) : ammeterData.getCurrentForwardActiveTotal()); + redisHash.put("discharge", ammeterData == null ? + new BigDecimal(0) : ammeterData.getCurrentReverseActiveTotal()); + redisCache.setCacheObject(startTimeDataKey, redisHash, 24, TimeUnit.HOURS); + } + + //初始化电表每日差值对象 + EmsDailyEnergyData energyData = initEnergyData(); + + // 根据 costType 计算差值 + setDiffByCostType(costType,energyData,redisHash,obj); + + // 插入或更新电表每日差值数据表 + emsDailyEnergyDataMapper.insertOrUpdateData(energyData); + } + + private void setDiffByCostType(String costType, EmsDailyEnergyData energyData, Map redisHash, Map obj) { + BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN")); + BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN")); + currentChargeData = currentChargeData != null ? currentChargeData : BigDecimal.ZERO; + currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO; + + // 计算差值,根据类型累加 + BigDecimal chargeDiffData = currentChargeData.subtract(redisHash.getOrDefault("charge", BigDecimal.ZERO)); + BigDecimal disChargeDiffData = currentDischargeData.subtract(redisHash.getOrDefault("discharge", BigDecimal.ZERO)); + switch (costType) { + case "peak": + BigDecimal peakCharge = energyData.getPeakChargeDiff(); + energyData.setPeakChargeDiff((peakCharge == null ? BigDecimal.ZERO : peakCharge) + .add(chargeDiffData)); + BigDecimal peakDischarge = energyData.getPeakDischargeDiff(); + energyData.setPeakDischargeDiff((peakDischarge == null ? BigDecimal.ZERO : peakDischarge) + .add(disChargeDiffData)); + break; + case "high": + BigDecimal highCharge = energyData.getHighChargeDiff(); + energyData.setHighChargeDiff((highCharge == null ? BigDecimal.ZERO : highCharge) + .add(chargeDiffData)); + BigDecimal highDischarge = energyData.getHighDischargeDiff(); + energyData.setHighDischargeDiff((highDischarge == null ? BigDecimal.ZERO : highDischarge) + .add(disChargeDiffData)); + break; + case "flat": + BigDecimal flatCharge = energyData.getFlatChargeDiff(); + energyData.setFlatChargeDiff((flatCharge == null ? BigDecimal.ZERO : flatCharge) + .add(chargeDiffData)); + BigDecimal flatDischarge = energyData.getFlatDischargeDiff(); + energyData.setFlatDischargeDiff((flatDischarge == null ? BigDecimal.ZERO : flatDischarge) + .add(disChargeDiffData)); + break; + case "valley": + BigDecimal valleyCharge = energyData.getValleyChargeDiff(); + energyData.setValleyChargeDiff((valleyCharge == null ? BigDecimal.ZERO : valleyCharge) + .add(chargeDiffData)); + BigDecimal valleyDischarge = energyData.getValleyDischargeDiff(); + energyData.setValleyDischargeDiff((valleyDischarge == null ? BigDecimal.ZERO : valleyDischarge) + .add(disChargeDiffData)); + break; + default: + return; + } + } + + private boolean isInPriceTimeRange(String startTime, String endTime, Date dataUpdateTime) { + if (startTime == null || endTime == null || dataUpdateTime == null) { + return false; + } + LocalDateTime time = DateUtils.toLocalDateTime(dataUpdateTime); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + String dataTimeStr = time.format(formatter); + // 比较时间范围 + return dataTimeStr.compareTo(startTime) >= 0 + && dataTimeStr.compareTo(endTime) < 0; + } + + private String concateCurrentDayTime(String startTime) { + DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime time = LocalTime.parse(startTime, timeFormatter); + + LocalDate today = LocalDate.now(); + LocalDateTime targetDateTime = LocalDateTime.of(today, time); + + DateTimeFormatter resultFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); + return targetDateTime.format(resultFormatter); + } + + private EmsDailyEnergyData initEnergyData() { + // 先获取数据库当天数据,存在则更新时间,不存在则初始化 + EmsDailyEnergyData energyData = emsDailyEnergyDataMapper.getDataByDate(SITE_ID,DateUtils.getDate()); + if (energyData == null) { + energyData = new EmsDailyEnergyData(); + energyData.setSiteId(SITE_ID); + energyData.setDataDate(DateUtils.getNowDate()); + energyData.setCreateBy("system"); + energyData.setCreateTime(DateUtils.getNowDate()); + } + energyData.setUpdateBy("system"); + energyData.setCalcTime(DateUtils.getNowDate()); + return energyData; + } + // 数据分组处理 private static Map> processData(Map rawData) { Map> records = new HashMap<>(); diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index eb67bf4..53fc6d4 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -885,11 +885,23 @@ + + + and site_id = #{siteId} + and data_date = #{dataDate} + and peak_charge_diff = #{peakChargeDiff} + and peak_discharge_diff = #{peakDischargeDiff} + and high_charge_diff = #{highChargeDiff} + and high_discharge_diff = #{highDischargeDiff} + and flat_charge_diff = #{flatChargeDiff} + and flat_discharge_diff = #{flatDischargeDiff} + and valley_charge_diff = #{valleyChargeDiff} + and valley_discharge_diff = #{valleyDischargeDiff} + and calc_time = #{calcTime} + + + + + + + insert into ems_daily_energy_data + + site_id, + data_date, + peak_charge_diff, + peak_discharge_diff, + high_charge_diff, + high_discharge_diff, + flat_charge_diff, + flat_discharge_diff, + valley_charge_diff, + valley_discharge_diff, + calc_time, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{siteId}, + #{dataDate}, + #{peakChargeDiff}, + #{peakDischargeDiff}, + #{highChargeDiff}, + #{highDischargeDiff}, + #{flatChargeDiff}, + #{flatDischargeDiff}, + #{valleyChargeDiff}, + #{valleyDischargeDiff}, + #{calcTime}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_daily_energy_data + + site_id = #{siteId}, + data_date = #{dataDate}, + peak_charge_diff = #{peakChargeDiff}, + peak_discharge_diff = #{peakDischargeDiff}, + high_charge_diff = #{highChargeDiff}, + high_discharge_diff = #{highDischargeDiff}, + flat_charge_diff = #{flatChargeDiff}, + flat_discharge_diff = #{flatDischargeDiff}, + valley_charge_diff = #{valleyChargeDiff}, + valley_discharge_diff = #{valleyDischargeDiff}, + calc_time = #{calcTime}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_daily_energy_data where id = #{id} + + + + delete from ems_daily_energy_data where id in + + #{id} + + + + + + + INSERT INTO ems_daily_energy_data ( + id, site_id, data_date, + peak_charge_diff, + peak_discharge_diff, + high_charge_diff, + high_discharge_diff, + flat_charge_diff, + flat_discharge_diff, + valley_charge_diff, + valley_discharge_diff, + calc_time, + create_by, + create_time, + update_by, + update_time, + remark + ) VALUES ( + #{id}, + #{siteId}, + #{dataDate}, + #{peakChargeDiff}, + #{peakDischargeDiff}, + #{highChargeDiff}, + #{highDischargeDiff}, + #{flatChargeDiff}, + #{flatDischargeDiff}, + #{valleyChargeDiff}, + #{valleyDischargeDiff}, + #{calcTime}, + 'system', + NOW(), + 'system', + NOW(), + #{remark} + ) ON DUPLICATE KEY UPDATE + peak_charge_diff = #{peakChargeDiff}, + peak_discharge_diff = #{peakDischargeDiff}, + high_charge_diff = #{highChargeDiff}, + high_discharge_diff = #{highDischargeDiff}, + flat_charge_diff = #{flatChargeDiff}, + flat_discharge_diff = #{flatDischargeDiff}, + valley_charge_diff = #{valleyChargeDiff}, + valley_discharge_diff = #{valleyDischargeDiff}, + calc_time = #{calcTime}, + update_time = NOW(); + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml index 8be7131..e27b431 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml @@ -148,4 +148,14 @@ where year = #{currentYear} and month = #{month} + + \ No newline at end of file -- 2.49.0 From 158bc1a51d1ff5f548636c72e062a9032e96083d Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 10 Oct 2025 17:32:15 +0800 Subject: [PATCH 165/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=94=B5?= =?UTF-8?q?=E8=A1=A8=E6=8A=A5=E8=A1=A8-=E5=B0=96=E5=B3=B0=E5=B9=B3?= =?UTF-8?q?=E8=B0=B7=E6=97=A5=E5=B7=AE=E5=80=BC=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 15 ++--- .../domain/vo/StatisAmmeterDateRequest.java | 38 ++++------- .../ems/mapper/EmsDailyEnergyDataMapper.java | 3 + .../impl/EmsStatsReportServiceImpl.java | 64 +++++++++++-------- .../mapper/ems/EmsDailyEnergyDataMapper.xml | 23 +++++++ 5 files changed, 82 insertions(+), 61 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index 906c261..230b980 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -4,10 +4,7 @@ import com.xzzn.common.core.controller.BaseController; import com.xzzn.common.core.domain.AjaxResult; import com.xzzn.common.core.page.TableDataInfo; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.vo.ClusterStatisListVo; -import com.xzzn.ems.domain.vo.DateSearchRequest; -import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest; -import com.xzzn.ems.domain.vo.StatisClusterDateRequest; +import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.service.IEmsStatsReportService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -114,13 +111,11 @@ public class EmsStatisticalReportController extends BaseController * 概率统计-电表报表 */ @GetMapping("/getAmmeterData") - public AjaxResult getAmmeterData(StatisAmmeterDateRequest requestVo) + public TableDataInfo getAmmeterData(StatisAmmeterDateRequest requestVo) { - if (!StringUtils.isEmpty(requestVo.getDeviceId())) { - return success(ieEmsStatsReportService.getAmmeterDataResult(requestVo)); - } else { - return error("缺少必传项"); - } + startPage(); + List dataList = ieEmsStatsReportService.getAmmeterDataResult(requestVo); + return getDataTable(dataList); } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java index 6ff5897..9b83def 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/StatisAmmeterDateRequest.java @@ -1,32 +1,30 @@ package com.xzzn.ems.domain.vo; -import com.fasterxml.jackson.annotation.JsonFormat; - -import java.util.Date; - /** * 报表统计-电表报表入参 * */ public class StatisAmmeterDateRequest { - /** - * 筛选时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd") - private Date dateTime; - + private String startTime; + private String endTime; private String siteId; - private String deviceId; - - public Date getDateTime() { - return dateTime; + public String getStartTime() { + return startTime; } - public void setDateTime(Date dateTime) { - this.dateTime = dateTime; + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; } public String getSiteId() { @@ -36,12 +34,4 @@ public class StatisAmmeterDateRequest { public void setSiteId(String siteId) { this.siteId = siteId; } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java index 2316e16..047ac45 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java @@ -2,6 +2,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsDailyEnergyData; +import com.xzzn.ems.domain.vo.AmmeterStatisListVo; import org.apache.ibatis.annotations.Param; /** @@ -64,4 +65,6 @@ public interface EmsDailyEnergyDataMapper public EmsDailyEnergyData getDataByDate(@Param("siteId")String siteId,@Param("today") String today); // 插入或更新每日尖峰平谷差值 public void insertOrUpdateData(EmsDailyEnergyData energyData); + // 电表报表 + public List getDataBySiteId(@Param("siteId")String siteId, @Param("startTime")String startTime, @Param("endTime")String endTime); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 4acb413..03dd35d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -41,6 +41,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService private EmsBatteryDataDayMapper emsBatteryDataDayMapper; @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; + @Autowired + private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; // 电量指标 @Override @@ -252,35 +254,43 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // 电表报表 @Override public List getAmmeterDataResult(StatisAmmeterDateRequest requestVo){ - List dataList = new ArrayList(); - // 时间不传默认当天 - if (requestVo.getDateTime() == null) { - String now = DateUtils.getDate(); - requestVo.setDateTime(DateUtils.dateTime(DateUtils.YYYY_MM_DD, now)); + List dataList = emsDailyEnergyDataMapper.getDataBySiteId(requestVo.getSiteId(),requestVo.getStartTime(),requestVo.getEndTime()); + if (dataList == null || dataList.size()==0){ + return null; } - dataList = emsAmmeterDataMapper.getLoadDataByHour(requestVo); - if (dataList.size()>0){ - AmmeterStatisListVo totalVo = new AmmeterStatisListVo(); - totalVo.setDataTime("汇总"); - for (AmmeterStatisListVo ammeterStatisListVo : dataList) { - BigDecimal effect = new BigDecimal(0); - BigDecimal activePower = ammeterStatisListVo.getActiveTotalKwh(); - BigDecimal reactivePower = ammeterStatisListVo.getReActiveTotalKwh(); - if ( activePower != null && reactivePower !=null - && activePower.compareTo(BigDecimal.ZERO) > 0 - && reactivePower.compareTo(BigDecimal.ZERO) > 0){ - effect = reactivePower.divide(activePower, 2, RoundingMode.HALF_UP) - .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); - } - // 每小时的效率 - ammeterStatisListVo.setEffect(effect); - // 处理汇总数据 - dealWithAmmeterTotalDate(ammeterStatisListVo,totalVo); + BigDecimal activePower = new BigDecimal(0); + BigDecimal reactivePower = new BigDecimal(0); + /*AmmeterStatisListVo totalVo = new AmmeterStatisListVo(); + totalVo.setDataTime("汇总");*/ + for (AmmeterStatisListVo ammeterStatisListVo : dataList) { + BigDecimal effect = new BigDecimal(0); + activePower = (ammeterStatisListVo.getActivePeakKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getActivePeakKwh()) + .add((ammeterStatisListVo.getActiveHighKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getActiveHighKwh())) + .add((ammeterStatisListVo.getActiveFlatKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getActiveFlatKwh())) + .add((ammeterStatisListVo.getActiveValleyKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getActiveValleyKwh())); + reactivePower = (ammeterStatisListVo.getReActivePeakKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getReActivePeakKwh()) + .add((ammeterStatisListVo.getReActiveHighKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getReActiveHighKwh())) + .add((ammeterStatisListVo.getReActiveFlatKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getReActiveFlatKwh())) + .add((ammeterStatisListVo.getReActiveValleyKwh() == null ? BigDecimal.ZERO : ammeterStatisListVo.getReActiveValleyKwh())); + + ammeterStatisListVo.setActiveTotalKwh(activePower); + ammeterStatisListVo.setReActiveTotalKwh(reactivePower); + if ( activePower != null && reactivePower !=null + && activePower.compareTo(BigDecimal.ZERO) > 0 + && reactivePower.compareTo(BigDecimal.ZERO) > 0){ + effect = reactivePower.divide(activePower, 2, RoundingMode.HALF_UP) + .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); } + // 每天的效率 + ammeterStatisListVo.setEffect(effect); - // 处理汇总的效率 - BigDecimal totalActive = totalVo.getActiveTotalKwh(); + // 处理汇总数据 + //dealWithAmmeterTotalDate(ammeterStatisListVo,totalVo); + } + + // 处理汇总的效率 + /*BigDecimal totalActive = totalVo.getActiveTotalKwh(); BigDecimal totalReactive = totalVo.getReActiveTotalKwh(); if ( totalActive != null && totalReactive !=null && totalActive.compareTo(BigDecimal.ZERO) > 0 @@ -290,8 +300,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService .multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); totalVo.setEffect(totalEffect); } - dataList.add(totalVo); - } + dataList.add(totalVo);*/ + return dataList; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml index 7aba570..cee2e05 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml @@ -178,4 +178,27 @@ calc_time = #{calcTime}, update_time = NOW(); + + \ No newline at end of file -- 2.49.0 From 9075878e4163e02a704cd134700ff4c73c88b0c0 Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 10 Oct 2025 18:59:47 +0800 Subject: [PATCH 166/336] =?UTF-8?q?=E7=94=B5=E4=BB=B7=E5=88=97=E8=A1=A8-?= =?UTF-8?q?=E6=8C=89=E6=9C=88=E9=99=8D=E5=BA=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/service/impl/EmsEnergyPriceConfigServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java index d9623da..82aa8c4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -2,8 +2,10 @@ package com.xzzn.ems.service.impl; import java.time.LocalDate; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; @@ -88,7 +90,9 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer } } - return responses; + return responses.stream() + .sorted(Comparator.comparingInt((EnergyPriceVo vo) -> Integer.parseInt(vo.getMonth())).reversed()) + .collect(Collectors.toList()); } /** -- 2.49.0 From e33b26fc059438b007c68e238b94a534b8d714a2 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 11 Oct 2025 10:48:45 +0800 Subject: [PATCH 167/336] =?UTF-8?q?=E6=97=A5=E6=9C=9F=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 951bb4d..cb03d6c 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -231,7 +231,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils // 定义日期格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM_SS); // 格式化并返回 - return yesterday.format(formatter); + return yesterdayEndTime.format(formatter); } /** -- 2.49.0 From b79f9caa2db388853f3fd66bfadd55ddd80f8e97 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 11 Oct 2025 16:28:50 +0800 Subject: [PATCH 168/336] =?UTF-8?q?=E7=94=B5=E4=BB=B7=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AB=99=E7=82=B9id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsEnergyPriceConfigController.java | 4 +-- .../xzzn/ems/domain/EmsEnergyPriceConfig.java | 15 ++++++++++ .../com/xzzn/ems/domain/vo/EnergyPriceVo.java | 11 +++++++ .../mapper/EmsEnergyPriceConfigMapper.java | 12 +++++--- .../xzzn/ems/mapper/EmsSiteSettingMapper.java | 2 ++ .../service/IEmsEnergyPriceConfigService.java | 2 +- .../impl/EmsEnergyPriceConfigServiceImpl.java | 29 ++++++++++++------- .../mapper/ems/EmsEnergyPriceConfigMapper.xml | 19 +++++++++--- .../mapper/ems/EmsSiteSettingMapper.xml | 4 +++ 9 files changed, 76 insertions(+), 22 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java index b6c8e6a..0117d6f 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsEnergyPriceConfigController.java @@ -31,9 +31,9 @@ public class EmsEnergyPriceConfigController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:config:list')") @GetMapping("/list") - public TableDataInfo list(String startTime,String endTime) + public TableDataInfo list(String siteId, String startTime,String endTime) { - List list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList(startTime,endTime); + List list = emsEnergyPriceConfigService.selectEmsEnergyPriceConfigList(siteId,startTime,endTime); return getDataTable2(list); } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java index c4c45c1..6887f1e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsEnergyPriceConfig.java @@ -20,6 +20,10 @@ public class EmsEnergyPriceConfig extends BaseEntity /** */ private Long id; + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + /** 年份,如2025 */ @Excel(name = "年份,如2025") private String year; @@ -54,6 +58,16 @@ public class EmsEnergyPriceConfig extends BaseEntity return id; } + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + public void setYear(String year) { this.year = year; @@ -118,6 +132,7 @@ public class EmsEnergyPriceConfig extends BaseEntity public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) + .append("siteId", getSiteId()) .append("year", getYear()) .append("month", getMonth()) .append("peak", getPeak()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java index 4614dca..1a2bf0c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceVo.java @@ -12,6 +12,9 @@ import java.util.List; public class EnergyPriceVo { /** */ private Long id; + /** 站点id */ + @Excel(name = "站点id") + private String siteId; /** 年份 */ @Excel(name = "年份") private String year; @@ -41,6 +44,14 @@ public class EnergyPriceVo { this.id = id; } + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + public String getYear() { return year; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java index f6b3d2e..816ae73 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java @@ -62,11 +62,15 @@ public interface EmsEnergyPriceConfigMapper public int deleteEmsEnergyPriceConfigByIds(Long[] ids); // 查询当年电价配置列表 - public List getCurrentYearConfigList(int currentYear); - // 根据指定年月获取电价配置 - public EmsEnergyPriceConfig getConfigListByYearAndMonth(@Param("currentYear") String currentYear, @Param("month")String month); + public List getCurrentYearConfigList(@Param("siteId")String siteId,@Param("currentYear")int currentYear); + // 站点指定年月获取电价配置 + public EmsEnergyPriceConfig getConfigListByYearAndMonth(@Param("siteId")String siteId, + @Param("currentYear") String currentYear, + @Param("month")String month); // 插入或更新 public void insertOrUpdateEmsEnergyPriceConfig(EmsEnergyPriceConfig priceConfig); // 获取指定年月的电价时间配置 - public List getTimeRangeByDate(@Param("currentYear")int currentYear, @Param("currentMonth")int currentMonth); + public List getTimeRangeByDate(@Param("siteId")String siteId, + @Param("currentYear")int currentYear, + @Param("currentMonth")int currentMonth); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java index abcc74a..f29e394 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java @@ -90,4 +90,6 @@ public interface EmsSiteSettingMapper * @return */ public List getAllSiteDeviceList(String siteId); + + public List getAllSiteId(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java index c0ee58f..3828d4a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java @@ -25,7 +25,7 @@ public interface IEmsEnergyPriceConfigService * * @return 电价配置集合 */ - public List selectEmsEnergyPriceConfigList(String startTime,String endTime); + public List selectEmsEnergyPriceConfigList(String siteId, String startTime,String endTime); /** * 新增电价配置-按月 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java index 82aa8c4..69d2fd5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -1,9 +1,7 @@ package com.xzzn.ems.service.impl; import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -15,6 +13,7 @@ import com.xzzn.ems.domain.EmsPriceTimeConfig; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import com.xzzn.ems.domain.vo.EnergyPriceVo; import com.xzzn.ems.mapper.EmsPriceTimeConfigMapper; +import com.xzzn.ems.mapper.EmsSiteSettingMapper; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -37,6 +36,8 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer private EmsPriceTimeConfigMapper emsPriceTimeConfigMapper; @Autowired private RedisCache redisCache; + @Autowired + private EmsSiteSettingMapper emsSiteSettingMapper; /** * 查询电价配置 @@ -68,14 +69,14 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer * @return 电价配置 */ @Override - public List selectEmsEnergyPriceConfigList(String startTime,String endTime) + public List selectEmsEnergyPriceConfigList(String siteId,String startTime,String endTime) { List responses = new ArrayList<>(); // 根据时间截取年份 String[] startTimeArr = startTime.split("-"); int currentYear = Integer.valueOf(startTimeArr[0]); - List priceConfigs = emsEnergyPriceConfigMapper.getCurrentYearConfigList(currentYear); + List priceConfigs = emsEnergyPriceConfigMapper.getCurrentYearConfigList(siteId,currentYear); if (priceConfigs != null && priceConfigs.size() > 0) { for (EmsEnergyPriceConfig priceConfig : priceConfigs) { @@ -106,14 +107,14 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer { String year = priceVo.getYear(); String month = priceVo.getMonth(); - + String siteId = priceVo.getSiteId(); // 判断入参 - if(StringUtils.isEmpty(year) || StringUtils.isEmpty(month)){ + if(StringUtils.isEmpty(siteId) || StringUtils.isEmpty(year) || StringUtils.isEmpty(month)){ return 0; } // 校验当前月电价设置是否已存在,不存在则新增,存在则更新 - EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(year,month); + EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId,year,month); if (priceConfig != null){ return 0; } else { @@ -214,9 +215,15 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer int currentMonth = LocalDate.now().getMonthValue(); int currentYear = LocalDate.now().getYear(); - List timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(currentYear,currentMonth); + List siteIds = emsSiteSettingMapper.getAllSiteId(); + if (siteIds == null || siteIds.size() == 0) { + return; + } + for (String siteId : siteIds) { + List timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(siteId,currentYear,currentMonth); + String key = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + currentYear + currentMonth; + redisCache.setCacheObject(key,timeRanges, 31, TimeUnit.DAYS); + } - String key = RedisKeyConstants.ENERGY_PRICE_TIME + currentYear + currentMonth; - redisCache.setCacheObject(key,timeRanges, 31, TimeUnit.DAYS); } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml index e27b431..99bb6c9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml @@ -6,6 +6,7 @@ + @@ -20,19 +21,19 @@ - select id, year, month, peak, high, flat, valley, create_by, create_time, update_by, update_time, remark from ems_energy_price_config + select id, site_id, year, month, peak, high, flat, valley, create_by, create_time, update_by, update_time, remark from ems_energy_price_config @@ -44,6 +45,7 @@ insert into ems_energy_price_config + site_id, year, month, peak, @@ -57,6 +59,7 @@ remark, + #{siteId}, #{year}, #{month}, #{peak}, @@ -74,6 +77,7 @@ update ems_energy_price_config + site_id = #{siteId}, year = #{year}, month = #{month}, peak = #{peak}, @@ -104,6 +108,9 @@ year = #{currentYear} + + and site_id = #{siteId} + @@ -111,6 +118,7 @@ useGeneratedKeys="true" keyProperty="id"> INSERT INTO ems_energy_price_config ( id, + site_id, year, month, peak, @@ -124,6 +132,7 @@ remark ) VALUES ( #{id}, + #{siteId}, #{year}, #{month}, #{peak}, @@ -145,7 +154,8 @@ @@ -155,7 +165,8 @@ t2.end_time as endTime from ems_energy_price_config t left join ems_price_time_config t2 on t.id = t2.price_id - where t.`year` = #{currentYear} + where t.site_id = #{siteId} + and t.`year` = #{currentYear} and t.`month` = #{currentMonth} \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index b7dadf6..bf2424a 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -147,4 +147,8 @@ and es.site_id = #{siteId} + + \ No newline at end of file -- 2.49.0 From 83f8f4e293cd7fdd72b8dbebcf705015072ab1e8 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 11 Oct 2025 16:31:32 +0800 Subject: [PATCH 169/336] =?UTF-8?q?=E7=94=B5=E4=BB=B7=E9=85=8D=E7=BD=AE-?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AB=99=E7=82=B9id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 1a310be..2b844a4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -775,10 +775,10 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private void dealAmmeterDailyDate(Map obj, String deviceId, Date dataUpdateTime) { // 先获取当月电价配置,redis没有这查数据库,都没有则返回 - String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); + String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + SITE_ID + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); List timeRanges = redisCache.getCacheObject(priceKey); if (timeRanges == null) { - timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(LocalDate.now().getYear(),LocalDate.now().getMonthValue()); + timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(SITE_ID, LocalDate.now().getYear(),LocalDate.now().getMonthValue()); if (timeRanges == null) { return; } -- 2.49.0 From 3454359f01e54cfb97c6512dc19fa47ab1388fa7 Mon Sep 17 00:00:00 2001 From: mashili Date: Sat, 11 Oct 2025 17:21:40 +0800 Subject: [PATCH 170/336] =?UTF-8?q?0918=E7=94=B5=E8=A1=A8=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8-=E5=A5=89=E8=B4=A4=E6=AF=8F=E6=97=A5=E5=B0=96?= =?UTF-8?q?=E5=B3=B0=E5=B9=B3=E8=B0=B7=E7=B4=AF=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 4 ++ .../impl/FXXDataProcessServiceImpl.java | 55 ++++++++++--------- .../mapper/ems/EmsAmmeterDataMapper.xml | 13 +++++ 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index b63d33a..62a1bdf 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -89,4 +89,8 @@ public interface EmsAmmeterDataMapper public List getPowerDataByDay(DateSearchRequest requestVo); public List getPowerDataByMonth(DateSearchRequest requestVo); public List getPowerDataByMinutes(DateSearchRequest requestVo); + + // 获取最新数据 + public EmsAmmeterData getLastData(@Param("siteId")String siteId, @Param("deviceId")String deviceId); + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 2b844a4..49af4ff 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -18,7 +18,6 @@ import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanUtils; @@ -682,6 +681,9 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); + // 获取上次数据,便于后面计算差值均无则默认0 + EmsAmmeterData lastAmmeterData = getLastAmmeterData(deviceId); + EmsAmmeterData dataLoad = new EmsAmmeterData(); // 更新时间 dataLoad.setDataUpdateTime(dataUpdateTime); @@ -770,10 +772,26 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); // 处理电表每日充放电数据 - dealAmmeterDailyDate(obj, deviceId, dataUpdateTime); + dealAmmeterDailyDate(obj, deviceId, dataUpdateTime, lastAmmeterData); } - private void dealAmmeterDailyDate(Map obj, String deviceId, Date dataUpdateTime) { + private EmsAmmeterData getLastAmmeterData(String deviceId) { + // 先从redis取,取不到查数据 + EmsAmmeterData lastData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId); + if (lastData == null) { + lastData = emsAmmeterDataMapper.getLastData(SITE_ID,deviceId); + if (lastData == null) { + lastData = new EmsAmmeterData(); + lastData.setSiteId(SITE_ID); + lastData.setDeviceId(deviceId); + lastData.setCurrentForwardActiveTotal(BigDecimal.ZERO); + lastData.setCurrentReverseActiveTotal(BigDecimal.ZERO); + } + } + return lastData; + } + + private void dealAmmeterDailyDate(Map obj, String deviceId, Date dataUpdateTime, EmsAmmeterData lastData) { // 先获取当月电价配置,redis没有这查数据库,都没有则返回 String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + SITE_ID + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); List timeRanges = redisCache.getCacheObject(priceKey); @@ -799,41 +817,28 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return; } - // 确定数据类型,获取小于等于开始时刻的最新数据。 - startTime = concateCurrentDayTime(startTime); - String startTimeDataKey = RedisKeyConstants.DIFF_CHARGE_START + SITE_ID +"_" + startTime; - Map redisHash = redisCache.getCacheObject(startTimeDataKey); - // redis无,就取数据库 - if (redisHash == null) { - // 查询数据库-电表表数据取截止到昨日最新一条数据,均无默认初始值0 - EmsAmmeterData ammeterData = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,startTime); - redisHash = new HashMap<>(); - redisHash.put("charge", ammeterData == null ? - new BigDecimal(0) : ammeterData.getCurrentForwardActiveTotal()); - redisHash.put("discharge", ammeterData == null ? - new BigDecimal(0) : ammeterData.getCurrentReverseActiveTotal()); - redisCache.setCacheObject(startTimeDataKey, redisHash, 24, TimeUnit.HOURS); - } - //初始化电表每日差值对象 EmsDailyEnergyData energyData = initEnergyData(); - // 根据 costType 计算差值 - setDiffByCostType(costType,energyData,redisHash,obj); + // 根据 costType,计算本次与上次数据差值,累加到对应的数据类型里面 + setDiffByCostType(costType,energyData,lastData,obj); // 插入或更新电表每日差值数据表 emsDailyEnergyDataMapper.insertOrUpdateData(energyData); } - private void setDiffByCostType(String costType, EmsDailyEnergyData energyData, Map redisHash, Map obj) { + private void setDiffByCostType(String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData, Map obj) { BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN")); BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN")); currentChargeData = currentChargeData != null ? currentChargeData : BigDecimal.ZERO; currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO; - // 计算差值,根据类型累加 - BigDecimal chargeDiffData = currentChargeData.subtract(redisHash.getOrDefault("charge", BigDecimal.ZERO)); - BigDecimal disChargeDiffData = currentDischargeData.subtract(redisHash.getOrDefault("discharge", BigDecimal.ZERO)); + // 计算时段差值,按照数据类型累加 + BigDecimal chargeDiffData = currentChargeData.subtract( + lastData.getCurrentForwardActiveTotal() == null ? BigDecimal.ZERO : lastData.getCurrentForwardActiveTotal()); + BigDecimal disChargeDiffData = currentDischargeData.subtract( + lastData.getCurrentReverseActiveTotal() == null ? BigDecimal.ZERO : lastData.getCurrentReverseActiveTotal() + ); switch (costType) { case "peak": BigDecimal peakCharge = energyData.getPeakChargeDiff(); diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index 53fc6d4..f49a05a 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -1048,4 +1048,17 @@ GROUP BY statisDate order by statisDate desc + + \ No newline at end of file -- 2.49.0 From 6ebeb48b6236549f766bc5da35d0fee05dd59862 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 12 Oct 2025 19:47:55 +0800 Subject: [PATCH 171/336] =?UTF-8?q?0918=E7=94=B5=E4=BB=B7-=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=AE=9E=E6=97=B6=E6=80=BB=E6=94=B6=E5=85=A5?= =?UTF-8?q?=E5=92=8C=E5=AE=9E=E6=97=B6=E5=BD=93=E6=97=A5=E6=94=B6=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 8 +- .../xzzn/ems/domain/EmsDailyEnergyData.java | 30 +++++ .../xzzn/ems/domain/vo/SiteMonitorHomeVo.java | 26 ++++ .../ems/mapper/EmsDailyEnergyDataMapper.java | 7 ++ .../mapper/EmsEnergyPriceConfigMapper.java | 3 + .../service/IEmsEnergyPriceConfigService.java | 2 + .../impl/DDSDataProcessServiceImpl.java | 108 ++++++++++++---- .../impl/EmsEnergyPriceConfigServiceImpl.java | 53 ++++++-- .../impl/FXXDataProcessServiceImpl.java | 117 +++++++++++++----- .../service/impl/SingleSiteServiceImpl.java | 35 +++--- .../mapper/ems/EmsDailyEnergyDataMapper.xml | 35 +++++- .../mapper/ems/EmsEnergyPriceConfigMapper.xml | 8 ++ 12 files changed, 348 insertions(+), 84 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 2df12f2..46971ca 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -73,9 +73,11 @@ public class RedisKeyConstants /** 现有的告警数据 */ public static final String LATEST_ALARM_RECORD = "LATEST_ALARM_RECORD"; - /** fx-电表电量差值起始数据 */ - public static final String DIFF_CHARGE_START = "diff_charge_start_"; - /** 预存电价时间配置 */ public static final String ENERGY_PRICE_TIME = "energy_price_time_"; + + /** dds昨日累计总收益 */ + public static final String DDS_TOTAL_REVENUE = "total_revenue_"; + /** fx实时总收益和当日实时收益 */ + public static final String FXX_REALTIME_REVENUE = "realtime_revenue_"; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java index e7ea25e..91f1630 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDailyEnergyData.java @@ -30,6 +30,14 @@ public class EmsDailyEnergyData extends BaseEntity @Excel(name = "数据日期:yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd") private Date dataDate; + /** 总收入 */ + @Excel(name = "总收入") + private BigDecimal totalRevenue; + + /** 当日实时收入 */ + @Excel(name = "当日实时收入") + private BigDecimal dayRevenue; + /** 尖峰时段充电差值 */ @Excel(name = "尖峰时段充电差值") private BigDecimal peakChargeDiff; @@ -96,6 +104,26 @@ public class EmsDailyEnergyData extends BaseEntity return dataDate; } + public void setTotalRevenue(BigDecimal totalRevenue) + { + this.totalRevenue = totalRevenue; + } + + public BigDecimal getTotalRevenue() + { + return totalRevenue; + } + + public void setDayRevenue(BigDecimal dayRevenue) + { + this.dayRevenue = dayRevenue; + } + + public BigDecimal getDayRevenue() + { + return dayRevenue; + } + public void setPeakChargeDiff(BigDecimal peakChargeDiff) { this.peakChargeDiff = peakChargeDiff; @@ -192,6 +220,8 @@ public class EmsDailyEnergyData extends BaseEntity .append("id", getId()) .append("siteId", getSiteId()) .append("dataDate", getDataDate()) + .append("totalRevenue", getTotalRevenue()) + .append("dayRevenue", getDayRevenue()) .append("peakChargeDiff", getPeakChargeDiff()) .append("peakDischargeDiff", getPeakDischargeDiff()) .append("highChargeDiff", getHighChargeDiff()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java index d0991df..d7bcc6a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java @@ -65,6 +65,32 @@ public class SiteMonitorHomeVo { */ private StrategyTempInfo strategyTempInfo; + /** + * 总收入 + */ + private BigDecimal totalRevenue; + + /** + * 当日实时收入 + */ + private BigDecimal dayRevenue; + + public BigDecimal getTotalRevenue() { + return totalRevenue; + } + + public void setTotalRevenue(BigDecimal totalRevenue) { + this.totalRevenue = totalRevenue; + } + + public BigDecimal getDayRevenue() { + return dayRevenue; + } + + public void setDayRevenue(BigDecimal dayRevenue) { + this.dayRevenue = dayRevenue; + } + public BigDecimal getDayChargedCap() { return dayChargedCap; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java index 047ac45..eeac437 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java @@ -1,6 +1,9 @@ package com.xzzn.ems.mapper; +import java.math.BigDecimal; import java.util.List; +import java.util.Map; + import com.xzzn.ems.domain.EmsDailyEnergyData; import com.xzzn.ems.domain.vo.AmmeterStatisListVo; import org.apache.ibatis.annotations.Param; @@ -67,4 +70,8 @@ public interface EmsDailyEnergyDataMapper public void insertOrUpdateData(EmsDailyEnergyData energyData); // 电表报表 public List getDataBySiteId(@Param("siteId")String siteId, @Param("startTime")String startTime, @Param("endTime")String endTime); + // dds-获取今天之前最晚的总收入 + public BigDecimal getLastTotalRevenue(String siteId); + // fx-获取实时总收益和当日实时收益 + public Map getRealTimeRevenue(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java index 816ae73..4e80ad0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java @@ -73,4 +73,7 @@ public interface EmsEnergyPriceConfigMapper public List getTimeRangeByDate(@Param("siteId")String siteId, @Param("currentYear")int currentYear, @Param("currentMonth")int currentMonth); + // 获取所有有效站点的电价配置 + public List getAllSitePriceConfig( @Param("currentYear")int currentYear, + @Param("currentMonth")int currentMonth); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java index 3828d4a..52acc2a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java @@ -61,4 +61,6 @@ public interface IEmsEnergyPriceConfigService // 初始化当月电价 public void initCurrentMonthPrice(); + // 获取指定站点的当月电价 + public EnergyPriceVo getCurrentMonthPrice(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 2104c13..bf2ac4c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -13,6 +13,7 @@ import com.xzzn.common.enums.*; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.vo.EnergyPriceVo; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IDDSDataProcessService; import com.xzzn.ems.service.IEmsAlarmRecordsService; @@ -25,6 +26,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; @@ -949,19 +951,19 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 初始化当日数据-总的 EmsDailyChargeData emsDailyChargeData = initDailyChargeData(deviceId,nowTotalChargeDate,nowTotalDisChargeDate); // 获取redis存放昨日最晚数据 - String yestData = DateUtils.getYesterdayDate(); - String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestData; - EmsAmmeterData yestDate = redisCache.getCacheObject(yestDateRedisKey); + String yestDate = DateUtils.getYesterdayDate(); + String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestDate; + EmsAmmeterData yestData = redisCache.getCacheObject(yestDateRedisKey); if (yestDate == null) { // redis没有这查电表总数据表取截止到昨日最新第一条数据 - yestDate = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestData); + yestData = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestDate); // 数据存redis-有效期1天 redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); } if (yestDate != null) { // 今日总数据-昨日总数据=今日充放电 - BigDecimal yestTotalDisChargeDate = yestDate.getCurrentReverseActiveTotal(); - BigDecimal yestTotalChargeDate = yestDate.getCurrentForwardActiveTotal(); + BigDecimal yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal(); + BigDecimal yestTotalChargeDate = yestData.getCurrentForwardActiveTotal(); dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); @@ -974,28 +976,88 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 初始化数据-尖峰平谷 EmsDailyEnergyData energyData = initEnergyData(); - // 计算尖峰平谷差值 - energyData.setPeakChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGJDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActivePeak()));// 正向-尖 - energyData.setHighChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGFDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveHigh()));// 正向-峰 - energyData.setFlatChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGPDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveFlat()));// 正向-平 - energyData.setValleyChargeDiff(StringUtils.getBigDecimal(obj.get("DQZXYGGDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentForwardActiveValley()));// 正向-谷 - energyData.setPeakDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGJDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActivePeak()));// 反向-尖 - energyData.setHighDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGFDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveHigh()));// 反向-峰 - energyData.setFlatDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGPDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveFlat()));// 反向-平 - energyData.setValleyDischargeDiff(StringUtils.getBigDecimal(obj.get("DQFXYGGDN")) - .subtract(yestDate == null ? new BigDecimal(0) : yestDate.getCurrentReverseActiveValley()));// 反向-谷 + // 计算尖峰平谷差值,更新表 + calcEnergyDiffAndRevenue(energyData,obj,yestData); energyData.setCalcTime(DateUtils.getNowDate()); // 插入或更新电表每日差值数据表 emsDailyEnergyDataMapper.insertOrUpdateData(energyData); } + private void calcEnergyDiffAndRevenue(EmsDailyEnergyData energyData, Map obj, EmsAmmeterData yestData) { + + // 获取当月电价 + String key = RedisKeyConstants.ENERGY_PRICE_TIME + SITE_ID + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); + EnergyPriceVo priceVo = redisCache.getCacheObject(key); + + // 计算尖峰平谷差值 + // 正反向-尖 + BigDecimal peakChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGJDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActivePeak()); + energyData.setPeakChargeDiff(peakChargeDiff); + BigDecimal peakDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGJDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActivePeak()); + energyData.setPeakDischargeDiff(peakDischargeDiff); + // 正反向-峰 + BigDecimal highChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGFDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveHigh()); + energyData.setHighChargeDiff(highChargeDiff); + BigDecimal highDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGFDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveHigh()); + energyData.setHighDischargeDiff(highDischargeDiff); + // 正反向-平 + BigDecimal flatChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGPDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveFlat()); + energyData.setFlatChargeDiff(flatChargeDiff); + BigDecimal flatDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGPDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveFlat()); + energyData.setFlatDischargeDiff(flatDisChargeDiff); + // 正反向-谷 + BigDecimal valleyChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGGDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveValley()); + energyData.setValleyChargeDiff(valleyChargeDiff); + BigDecimal valleyDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGGDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveValley()); + energyData.setValleyDischargeDiff(valleyDisChargeDiff); + + + BigDecimal totalRevenue = getYestLastData(SITE_ID); + BigDecimal dayRevenue = BigDecimal.ZERO; + BigDecimal price = BigDecimal.ZERO; + // 计算当日收益,尖峰平谷收益累加,(放电量-充电量)*电价 + if (priceVo != null) { + price = priceVo.getPeak() == null ? BigDecimal.ZERO : priceVo.getPeak(); + BigDecimal peakRevenue = peakDischargeDiff.subtract(peakChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(peakRevenue); + price = priceVo.getHigh() == null ? BigDecimal.ZERO : priceVo.getHigh(); + BigDecimal highRevenue = highDischargeDiff.subtract(highChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(highRevenue); + price = priceVo.getFlat() == null ? BigDecimal.ZERO : priceVo.getFlat(); + BigDecimal flatRevenue = flatDisChargeDiff.subtract(flatChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(flatRevenue); + price = priceVo.getValley() == null ? BigDecimal.ZERO : priceVo.getValley(); + BigDecimal valleyRevenue = valleyDisChargeDiff.subtract(valleyChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(valleyRevenue); + energyData.setDayRevenue(dayRevenue); + } + // 总收益 = 昨日总收益+今日实时收益 + totalRevenue = totalRevenue.add(dayRevenue); + energyData.setTotalRevenue(totalRevenue); + } + + private BigDecimal getYestLastData(String siteId) { + // dds存的是累计到昨日总收益 + String redisKey = RedisKeyConstants.DDS_TOTAL_REVENUE + siteId; + BigDecimal yestLastTotalRevenue = redisCache.getCacheObject(redisKey); + if (yestLastTotalRevenue == null) { + yestLastTotalRevenue = emsDailyEnergyDataMapper.getLastTotalRevenue(siteId); + if (yestLastTotalRevenue == null) { + yestLastTotalRevenue = BigDecimal.ZERO; + } + redisCache.setCacheObject(redisKey, yestLastTotalRevenue); + } + return yestLastTotalRevenue; + } + private EmsDailyChargeData initDailyChargeData(String deviceId, BigDecimal nowTotalChargeDate, BigDecimal nowTotalDisChargeDate) { EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java index 69d2fd5..d8f1704 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -127,7 +127,15 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer priceConfig.setUpdateBy("system"); emsEnergyPriceConfigMapper.insertOrUpdateEmsEnergyPriceConfig(priceConfig); - return batchInsetPriceTimeRange(priceVo,priceConfig.getId()); + batchInsetPriceTimeRange(priceVo,priceConfig.getId()); + + // 判断是否当月电价,是则更新当月电价缓存 + int currentMonth = LocalDate.now().getMonthValue(); + if (currentMonth == Integer.parseInt(month)) { + initCurrentMonthPrice(); + } + + return 1; } private int batchInsetPriceTimeRange(EnergyPriceVo priceVo, Long priceId) { @@ -176,7 +184,14 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer // 时间配置,全删,全插入 Long[] priceIds = {priceVo.getId()}; emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(priceIds); - return batchInsetPriceTimeRange(priceVo,priceConfig.getId()); + batchInsetPriceTimeRange(priceVo,priceConfig.getId()); + + // 判断是否当月电价,是则更新当月电价缓存 + int currentMonth = LocalDate.now().getMonthValue(); + if (currentMonth == Integer.parseInt(priceVo.getMonth())) { + initCurrentMonthPrice(); + } + return 1; } /** @@ -191,7 +206,10 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer // 先删时间配置 emsPriceTimeConfigMapper.deleteTimeRangeByPriceId(ids); // 再删月电价 - return emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigByIds(ids); + emsEnergyPriceConfigMapper.deleteEmsEnergyPriceConfigByIds(ids); + // 更新当月电价缓存 + initCurrentMonthPrice(); + return 1; } /** @@ -207,7 +225,7 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer } /** - * 初始化当月的电价 + * 初始化当月的电价存redis */ @Override public void initCurrentMonthPrice() { @@ -215,15 +233,34 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer int currentMonth = LocalDate.now().getMonthValue(); int currentYear = LocalDate.now().getYear(); - List siteIds = emsSiteSettingMapper.getAllSiteId(); - if (siteIds == null || siteIds.size() == 0) { + List siteIdConfig = emsEnergyPriceConfigMapper.getAllSitePriceConfig(currentYear,currentMonth); + if (siteIdConfig == null || siteIdConfig.size() == 0) { return; } - for (String siteId : siteIds) { + for (EmsEnergyPriceConfig priceConfig : siteIdConfig) { + EnergyPriceVo priceVo = new EnergyPriceVo(); + BeanUtils.copyProperties(priceConfig,priceVo); + String siteId = priceConfig.getSiteId(); List timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(siteId,currentYear,currentMonth); + priceVo.setRange(timeRanges); String key = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + currentYear + currentMonth; - redisCache.setCacheObject(key,timeRanges, 31, TimeUnit.DAYS); + redisCache.setCacheObject(key,priceVo, 31, TimeUnit.DAYS); } } + + public EnergyPriceVo getCurrentMonthPrice(String siteId) { + EnergyPriceVo priceVo = new EnergyPriceVo(); + // 获取当年和当月的电价 + int currentMonth = LocalDate.now().getMonthValue(); + int currentYear = LocalDate.now().getYear(); + + EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId,String.valueOf(currentYear),String.valueOf(currentMonth)); + if (priceConfig != null) { + BeanUtils.copyProperties(priceConfig,priceVo); + List timeRanges = emsPriceTimeConfigMapper.getTimeRangeByPriceId(priceConfig.getId()); + priceVo.setRange(timeRanges); + } + return priceVo; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 49af4ff..a25939c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -14,8 +14,10 @@ import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; +import com.xzzn.ems.domain.vo.EnergyPriceVo; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsAlarmRecordsService; +import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; import org.apache.commons.logging.Log; @@ -78,6 +80,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; @Autowired private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; + @Autowired + private IEmsEnergyPriceConfigService emsEnergyPriceConfigService; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -772,7 +776,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); // 处理电表每日充放电数据 - dealAmmeterDailyDate(obj, deviceId, dataUpdateTime, lastAmmeterData); + dealAmmeterDailyDate(obj, dataUpdateTime, lastAmmeterData); } private EmsAmmeterData getLastAmmeterData(String deviceId) { @@ -791,16 +795,20 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return lastData; } - private void dealAmmeterDailyDate(Map obj, String deviceId, Date dataUpdateTime, EmsAmmeterData lastData) { + private void dealAmmeterDailyDate(Map obj, Date dataUpdateTime, EmsAmmeterData lastData) { // 先获取当月电价配置,redis没有这查数据库,都没有则返回 String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + SITE_ID + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); - List timeRanges = redisCache.getCacheObject(priceKey); - if (timeRanges == null) { - timeRanges = emsEnergyPriceConfigMapper.getTimeRangeByDate(SITE_ID, LocalDate.now().getYear(),LocalDate.now().getMonthValue()); - if (timeRanges == null) { + EnergyPriceVo priceVo = redisCache.getCacheObject(priceKey); + if (priceVo == null) { + priceVo = emsEnergyPriceConfigService.getCurrentMonthPrice(SITE_ID); + redisCache.setCacheObject(priceKey, priceVo, 31, TimeUnit.DAYS); + if (priceVo == null) { return; } - redisCache.setCacheObject(priceKey,timeRanges, 31, TimeUnit.DAYS); + } + List timeRanges = priceVo.getRange(); + if (timeRanges == null) { + return; } // 根据时间范围判断数据类型(尖峰平谷),无法确定数据类型则不处理 @@ -808,7 +816,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl String startTime = ""; for (EnergyPriceTimeRange timeRange : timeRanges) { startTime = timeRange.getStartTime(); - if (isInPriceTimeRange(startTime,timeRange.getEndTime(),dataUpdateTime)) { + if (isInPriceTimeRange(startTime, timeRange.getEndTime(), dataUpdateTime)) { costType = timeRange.getCostType(); break; } @@ -821,19 +829,26 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsDailyEnergyData energyData = initEnergyData(); // 根据 costType,计算本次与上次数据差值,累加到对应的数据类型里面 - setDiffByCostType(costType,energyData,lastData,obj); + setDiffByCostType(costType,energyData,lastData,obj,priceVo); // 插入或更新电表每日差值数据表 emsDailyEnergyDataMapper.insertOrUpdateData(energyData); } - private void setDiffByCostType(String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData, Map obj) { + private void setDiffByCostType(String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData, + Map obj, EnergyPriceVo priceVo) { BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN")); BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN")); currentChargeData = currentChargeData != null ? currentChargeData : BigDecimal.ZERO; currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO; + // 获取上次实时总收益+当日实时总收益,初始化电价 + Map revenueMap = getLastData(SITE_ID); + BigDecimal totalRevenue = revenueMap.get("totalRevenue") == null ? BigDecimal.ZERO : revenueMap.get("totalRevenue"); + BigDecimal dayRevenue = revenueMap.get("dayRevenue") == null ? BigDecimal.ZERO : revenueMap.get("dayRevenue"); + BigDecimal price = BigDecimal.ZERO; // 计算时段差值,按照数据类型累加 + // 计算当日累加收益,尖峰平谷收益在当日原基础累加,(放电量-充电量)*电价 BigDecimal chargeDiffData = currentChargeData.subtract( lastData.getCurrentForwardActiveTotal() == null ? BigDecimal.ZERO : lastData.getCurrentForwardActiveTotal()); BigDecimal disChargeDiffData = currentDischargeData.subtract( @@ -841,40 +856,72 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl ); switch (costType) { case "peak": - BigDecimal peakCharge = energyData.getPeakChargeDiff(); - energyData.setPeakChargeDiff((peakCharge == null ? BigDecimal.ZERO : peakCharge) - .add(chargeDiffData)); - BigDecimal peakDischarge = energyData.getPeakDischargeDiff(); - energyData.setPeakDischargeDiff((peakDischarge == null ? BigDecimal.ZERO : peakDischarge) - .add(disChargeDiffData)); + // 增加电量 + BigDecimal peakCharge = energyData.getPeakChargeDiff() == null ? BigDecimal.ZERO : energyData.getPeakChargeDiff(); + energyData.setPeakChargeDiff(peakCharge.add(chargeDiffData)); + BigDecimal peakDischarge = energyData.getPeakDischargeDiff() == null ? BigDecimal.ZERO : energyData.getPeakDischargeDiff(); + energyData.setPeakDischargeDiff(peakDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getPeak() == null ? BigDecimal.ZERO : priceVo.getPeak(); break; case "high": - BigDecimal highCharge = energyData.getHighChargeDiff(); - energyData.setHighChargeDiff((highCharge == null ? BigDecimal.ZERO : highCharge) - .add(chargeDiffData)); - BigDecimal highDischarge = energyData.getHighDischargeDiff(); - energyData.setHighDischargeDiff((highDischarge == null ? BigDecimal.ZERO : highDischarge) - .add(disChargeDiffData)); + // 增加电量 + BigDecimal highCharge = energyData.getHighChargeDiff() == null ? BigDecimal.ZERO : energyData.getHighChargeDiff(); + energyData.setHighChargeDiff(highCharge.add(chargeDiffData)); + BigDecimal highDischarge = energyData.getHighDischargeDiff() == null ? BigDecimal.ZERO : energyData.getHighDischargeDiff(); + energyData.setHighDischargeDiff(highDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getHigh() == null ? BigDecimal.ZERO : priceVo.getHigh(); break; case "flat": - BigDecimal flatCharge = energyData.getFlatChargeDiff(); - energyData.setFlatChargeDiff((flatCharge == null ? BigDecimal.ZERO : flatCharge) - .add(chargeDiffData)); - BigDecimal flatDischarge = energyData.getFlatDischargeDiff(); - energyData.setFlatDischargeDiff((flatDischarge == null ? BigDecimal.ZERO : flatDischarge) - .add(disChargeDiffData)); + // 增加电量 + BigDecimal flatCharge = energyData.getFlatChargeDiff() == null ? BigDecimal.ZERO : energyData.getFlatChargeDiff(); + energyData.setFlatChargeDiff(flatCharge.add(chargeDiffData)); + BigDecimal flatDischarge = energyData.getFlatDischargeDiff() == null ? BigDecimal.ZERO : energyData.getFlatDischargeDiff(); + energyData.setFlatDischargeDiff(flatDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getFlat() == null ? BigDecimal.ZERO : priceVo.getFlat(); break; case "valley": - BigDecimal valleyCharge = energyData.getValleyChargeDiff(); - energyData.setValleyChargeDiff((valleyCharge == null ? BigDecimal.ZERO : valleyCharge) - .add(chargeDiffData)); - BigDecimal valleyDischarge = energyData.getValleyDischargeDiff(); - energyData.setValleyDischargeDiff((valleyDischarge == null ? BigDecimal.ZERO : valleyDischarge) - .add(disChargeDiffData)); + // 增加电量 + BigDecimal valleyCharge = energyData.getValleyChargeDiff() == null ? BigDecimal.ZERO : energyData.getValleyChargeDiff(); + energyData.setValleyChargeDiff(valleyCharge.add(chargeDiffData)); + BigDecimal valleyDischarge = energyData.getValleyDischargeDiff() == null ? BigDecimal.ZERO : energyData.getValleyDischargeDiff(); + energyData.setValleyDischargeDiff(valleyDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getValley() == null ? BigDecimal.ZERO : priceVo.getValley(); break; default: return; } + + // 计算本次累加收益 + BigDecimal addRevenue = disChargeDiffData.subtract(chargeDiffData).multiply(price); + dayRevenue = dayRevenue.add(addRevenue); + energyData.setDayRevenue(dayRevenue); + // 总收益 = 上次实时总收益+今日实时增加的收益 + totalRevenue = totalRevenue.add(addRevenue); + energyData.setTotalRevenue(totalRevenue); + } + + private Map getLastData(String siteId) { + // dds存的是累计到昨日总收益 + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId; + Map realTimeRevenue = redisCache.getCacheObject(redisKey); + if (realTimeRevenue == null) { + realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); + if (realTimeRevenue == null) { + realTimeRevenue = new HashMap<>(); + realTimeRevenue.put("totalRevenue", BigDecimal.ZERO); + realTimeRevenue.put("dayRevenue", BigDecimal.ZERO); + } + redisCache.setCacheObject(redisKey, realTimeRevenue); + } + return realTimeRevenue; } private boolean isInPriceTimeRange(String startTime, String endTime, Date dataUpdateTime) { @@ -907,6 +954,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl energyData = new EmsDailyEnergyData(); energyData.setSiteId(SITE_ID); energyData.setDataDate(DateUtils.getNowDate()); + energyData.setTotalRevenue(BigDecimal.ZERO); + energyData.setDayRevenue(BigDecimal.ZERO); energyData.setCreateBy("system"); energyData.setCreateTime(DateUtils.getNowDate()); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 7ee278d..96bd173 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -37,18 +37,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private static final String CLUSTER_DATA_SOC = "SOC"; - private static Map storageFactor = new HashMap<>(); - static { - storageFactor.put("021_DDS_01", new BigDecimal("0.1")); - storageFactor.put("default", BigDecimal.ONE); // 默认1 - } - - private static Map pvFactor = new HashMap<>(); - static { - pvFactor.put("021_DDS_01", new BigDecimal("-0.001")); - pvFactor.put("default", BigDecimal.ONE); // Convert to Basic Latin - } - // 初始化List,存储指定的电表deviceId List ammeterDeviceIds = Arrays.asList( "LOAD", "METE", "METEGF" @@ -62,8 +50,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { @Autowired private EmsBatteryClusterMapper emsBatteryClusterMapper; @Autowired - private EmsCoolingDataMapper emsCoolingDataMapper; - @Autowired private EmsAmmeterDataMapper emsAmmeterDataMapper; @Autowired private EmsDevicesSettingMapper emsDevicesSettingMapper; @@ -76,6 +62,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private EmsStrategyTempMapper emsStrategyTempMapper; @Autowired private EmsDailyChargeDataMapper emsDailyChargeDataMapper; + @Autowired + private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; @Override public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { @@ -90,9 +78,14 @@ public class SingleSiteServiceImpl implements ISingleSiteService { siteMonitorHomeVo.setTotalDischargedCap(dataMap.get("totalDischargedCap")); //siteMonitorHomeVo.setGridNrtPower(dataMap.get("gridNrtPower")); } + + // 总收入+当日实时收入 + setRevenueInfo(siteMonitorHomeVo,siteId); + // 实时告警数据 名称+状态+告警内容 List siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId); siteMonitorHomeVo.setSiteMonitorHomeAlarmVo(siteMonitorHomeAlarmVo); + // 策略运行-主策略模板数据 List runningVo = emsStrategyRunningMapper.getRunningList(siteId); if (runningVo != null && runningVo.size() > 0) { @@ -103,6 +96,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { siteTempInfo.setSiteMonitorDataVo(tempList); siteMonitorHomeVo.setStrategyTempInfo(siteTempInfo); } + // 能量数据 LocalDate sevenDaysAgo = LocalDate.now().minusDays(6); Date startDate = DateUtils.toDate(sevenDaysAgo); @@ -122,12 +116,25 @@ public class SingleSiteServiceImpl implements ISingleSiteService { BigDecimal energyStorageAvailElec = siteMonitorHomeVo.getTotalDischargedCap().subtract(siteMonitorHomeVo.getTotalChargedCap()); siteMonitorHomeVo.setEnergyStorageAvailElec(energyStorageAvailElec); } + siteMonitorHomeVo.setSiteMonitorDataVo(siteMonitorDataVoList); } return siteMonitorHomeVo; } + private void setRevenueInfo(SiteMonitorHomeVo siteMonitorHomeVo, String siteId) { + BigDecimal totalRevenue = BigDecimal.ZERO; + BigDecimal dayRevenue = BigDecimal.ZERO; + Map realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); + if (realTimeRevenue != null) { + totalRevenue = realTimeRevenue.get("totalRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("totalRevenue"); + dayRevenue = realTimeRevenue.get("dayRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("dayRevenue"); + } + siteMonitorHomeVo.setTotalRevenue(totalRevenue); + siteMonitorHomeVo.setDayRevenue(dayRevenue); + } + // 获取单站监控实时运行头部数据 @Override public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml index cee2e05..d7a1782 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml @@ -8,6 +8,8 @@ + + @@ -25,7 +27,7 @@ - select id, site_id, data_date, peak_charge_diff, peak_discharge_diff, high_charge_diff, high_discharge_diff, flat_charge_diff, flat_discharge_diff, valley_charge_diff, valley_discharge_diff, calc_time, create_by, create_time, update_by, update_time, remark from ems_daily_energy_data + select id, site_id, data_date, total_revenue, day_revenue, peak_charge_diff, peak_discharge_diff, high_charge_diff, high_discharge_diff, flat_charge_diff, flat_discharge_diff, valley_charge_diff, valley_discharge_diff, calc_time, create_by, create_time, update_by, update_time, remark from ems_daily_energy_data + + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml index 99bb6c9..a9a19ff 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml @@ -169,4 +169,12 @@ and t.`year` = #{currentYear} and t.`month` = #{currentMonth} + + \ No newline at end of file -- 2.49.0 From eed6f839f6f3ec2c686ed9d97cdb8eeac9f57e58 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 13 Oct 2025 11:37:03 +0800 Subject: [PATCH 172/336] =?UTF-8?q?0918=E7=94=B5=E4=BB=B7-=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=AE=9E=E6=97=B6=E6=80=BB=E6=94=B6=E5=85=A5?= =?UTF-8?q?=E5=92=8C=E5=AE=9E=E6=97=B6=E5=BD=93=E6=97=A5=E6=94=B6=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/utils/DateUtils.java | 15 +++++++++++++++ .../service/impl/DDSDataProcessServiceImpl.java | 11 ++++++----- .../service/impl/FXXDataProcessServiceImpl.java | 5 +++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index cb03d6c..fb0ddc2 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -393,4 +393,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils // 3. 转换为Date return new Date(updateTime); } + + /** + * 获取昨天的日期,格式为yyyy-MM-dd + * @return 昨天的日期字符串 + */ + public static String getYesterdayDayString() { + // 获取今天的日期 + LocalDate today = LocalDate.now(); + // 减去一天得到昨天 + LocalDate yesterday = today.minusDays(1); + // 定义日期格式化器 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYYMMDD); + // 格式化并返回 + return yesterday.format(formatter); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index bf2ac4c..06cf38e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -954,13 +954,13 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl String yestDate = DateUtils.getYesterdayDate(); String yestDateRedisKey = RedisKeyConstants.AMMETER + SITE_ID + "_" + deviceId + "_" + yestDate; EmsAmmeterData yestData = redisCache.getCacheObject(yestDateRedisKey); - if (yestDate == null) { + if (yestData == null) { // redis没有这查电表总数据表取截止到昨日最新第一条数据 yestData = emsAmmeterDataMapper.getYestLatestDate(SITE_ID,deviceId,yestDate); // 数据存redis-有效期1天 - redisCache.setCacheObject(yestDateRedisKey, yestDate , Constants.DATE_VALID_TIME, TimeUnit.DAYS); + redisCache.setCacheObject(yestDateRedisKey, yestData , Constants.DATE_VALID_TIME, TimeUnit.DAYS); } - if (yestDate != null) { + if (yestData != null) { // 今日总数据-昨日总数据=今日充放电 BigDecimal yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal(); BigDecimal yestTotalChargeDate = yestData.getCurrentForwardActiveTotal(); @@ -1046,14 +1046,15 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private BigDecimal getYestLastData(String siteId) { // dds存的是累计到昨日总收益 - String redisKey = RedisKeyConstants.DDS_TOTAL_REVENUE + siteId; + String yestDate = DateUtils.getYesterdayDayString(); + String redisKey = RedisKeyConstants.DDS_TOTAL_REVENUE + siteId + "_" + yestDate; BigDecimal yestLastTotalRevenue = redisCache.getCacheObject(redisKey); if (yestLastTotalRevenue == null) { yestLastTotalRevenue = emsDailyEnergyDataMapper.getLastTotalRevenue(siteId); if (yestLastTotalRevenue == null) { yestLastTotalRevenue = BigDecimal.ZERO; } - redisCache.setCacheObject(redisKey, yestLastTotalRevenue); + redisCache.setCacheObject(redisKey, yestLastTotalRevenue, 1 , TimeUnit.DAYS); } return yestLastTotalRevenue; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index a25939c..3b8491b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -910,7 +910,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private Map getLastData(String siteId) { // dds存的是累计到昨日总收益 - String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId; + String yestDate = DateUtils.getYesterdayDayString(); + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId + "_" + yestDate; Map realTimeRevenue = redisCache.getCacheObject(redisKey); if (realTimeRevenue == null) { realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); @@ -919,7 +920,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl realTimeRevenue.put("totalRevenue", BigDecimal.ZERO); realTimeRevenue.put("dayRevenue", BigDecimal.ZERO); } - redisCache.setCacheObject(redisKey, realTimeRevenue); + redisCache.setCacheObject(redisKey, realTimeRevenue, 1, TimeUnit.DAYS); } return realTimeRevenue; } -- 2.49.0 From c438f50ae1672bbf326ccfe022ef9f9ce58b63ed Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 13 Oct 2025 12:04:46 +0800 Subject: [PATCH 173/336] =?UTF-8?q?0918=E7=94=B5=E4=BB=B7-=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=AE=9E=E6=97=B6=E6=80=BB=E6=94=B6=E5=85=A5?= =?UTF-8?q?=E5=92=8C=E5=AE=9E=E6=97=B6=E5=BD=93=E6=97=A5=E6=94=B6=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FXXDataProcessServiceImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 3b8491b..ff9988e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -843,7 +843,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO; // 获取上次实时总收益+当日实时总收益,初始化电价 - Map revenueMap = getLastData(SITE_ID); + Map revenueMap = getRealTimeData(SITE_ID); BigDecimal totalRevenue = revenueMap.get("totalRevenue") == null ? BigDecimal.ZERO : revenueMap.get("totalRevenue"); BigDecimal dayRevenue = revenueMap.get("dayRevenue") == null ? BigDecimal.ZERO : revenueMap.get("dayRevenue"); BigDecimal price = BigDecimal.ZERO; @@ -906,12 +906,18 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 总收益 = 上次实时总收益+今日实时增加的收益 totalRevenue = totalRevenue.add(addRevenue); energyData.setTotalRevenue(totalRevenue); + + // 存redis便于下次取用 + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + SITE_ID; + Map realTimeRevenue = new HashMap<>(); + realTimeRevenue.put("totalRevenue", totalRevenue); + realTimeRevenue.put("dayRevenue",dayRevenue); + redisCache.setCacheObject(redisKey, realTimeRevenue, 1, TimeUnit.DAYS); } - private Map getLastData(String siteId) { - // dds存的是累计到昨日总收益 - String yestDate = DateUtils.getYesterdayDayString(); - String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId + "_" + yestDate; + private Map getRealTimeData(String siteId) { + // fx取实时总收益和当天实时收益 + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId; Map realTimeRevenue = redisCache.getCacheObject(redisKey); if (realTimeRevenue == null) { realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); -- 2.49.0 From 049eaa84b757a4a504d94311bdc87d7b19618a1e Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 13 Oct 2025 13:00:35 +0800 Subject: [PATCH 174/336] =?UTF-8?q?0918=E7=94=B5=E4=BB=B7-=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E7=9A=84=E5=AE=9E=E6=97=B6=E6=80=BB=E6=94=B6=E5=85=A5?= =?UTF-8?q?=E5=92=8C=E5=AE=9E=E6=97=B6=E5=BD=93=E6=97=A5=E6=94=B6=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index ff9988e..d5a8a01 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -961,8 +961,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl energyData = new EmsDailyEnergyData(); energyData.setSiteId(SITE_ID); energyData.setDataDate(DateUtils.getNowDate()); - energyData.setTotalRevenue(BigDecimal.ZERO); - energyData.setDayRevenue(BigDecimal.ZERO); energyData.setCreateBy("system"); energyData.setCreateTime(DateUtils.getNowDate()); } -- 2.49.0 From aadf66d5ad495fa2262c435e7c21e2cb388f3764 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 13 Oct 2025 14:24:13 +0800 Subject: [PATCH 175/336] =?UTF-8?q?=E7=82=B9=E4=BD=8D=E6=B8=85=E5=8D=95-?= =?UTF-8?q?=E6=8C=89=E6=95=B0=E5=80=BC=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/vo/PointDataRequest.java | 10 ++ .../impl/EmsDeviceSettingServiceImpl.java | 113 ++++++++++++++++-- 2 files changed, 110 insertions(+), 13 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java index cdbe913..9fbeaac 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java @@ -27,6 +27,16 @@ public class PointDataRequest { /** 点位数据-范围上下限 */ private BigDecimal lower; private BigDecimal upper; + /** 排序字段 */ + private String sortData; + + public String getSortData() { + return sortData; + } + + public void setSortData(String sortData) { + this.sortData = sortData; + } public String getSiteId() { return siteId; 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 af9ef50..94d6319 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 @@ -187,20 +187,48 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService }).collect(Collectors.toList()); } - // 结果排序 - String sortMethod = request.getSortMethod(); - if (sortMethod==null || sortMethod.isEmpty() || "asc".equals(sortMethod)) {// 升序 - response = response.stream() - .filter(p -> p.getPointValue() != null) - .sorted(Comparator.comparing(PointQueryResponse::getUpdateTime)).collect(Collectors.toList()); - } else if ("desc".equals(sortMethod)) {//降序 - response = response.stream() - .filter(p -> p.getPointValue() != null) - .sorted(Comparator.comparing(PointQueryResponse::getUpdateTime).reversed()).collect(Collectors.toList()); - } - return response; - } + // 确保赋值后不会被修改 + final List resultResponse = response; + // 根据排序字段和排序方式进行排序 + Comparator comparator; + String sortData = request.getSortData(); + if ("pointValue".equals(sortData)) {// 按pointValue排序 + comparator = Comparator.comparing( + PointQueryResponse::getPointValue, + EmsDeviceSettingServiceImpl::compareMultiType); + } else {// 默认按updateTime排序 + comparator = Comparator.comparing(PointQueryResponse::getUpdateTime); + } + // 排序方式 + String sortMethod = request.getSortMethod(); + boolean isAsc = sortMethod == null || sortMethod.isEmpty() || "asc".equals(sortMethod); + Comparator finalComparator = Comparator.comparing( + PointQueryResponse::getPointValue, // 用于判断null的字段 + (v1, v2) -> { // 核心逻辑:null值始终返回1(排在后面) + if (v1 == v2) return 0; + if (v1 == null) return 1; + if (v2 == null) return -1; + // 非null值使用基础比较器逻辑 + return isAsc ? + comparator.compare(findByValue(resultResponse, v1), findByValue(resultResponse, v2)) : + comparator.reversed().compare(findByValue(resultResponse, v1), findByValue(resultResponse, v2)); + } + ); + return resultResponse.stream() + .sorted(finalComparator) + .collect(Collectors.toList()); + } + // 辅助方法:根据值查找对应的对象(用于比较器中获取完整对象) + private PointQueryResponse findByValue(List list, Object value) { + return list.stream() + .filter(p -> { + Object val = p.getPointValue(); + return val == value || (val != null && val.equals(value)); + }) + .findFirst() + .orElse(null); + } // Object转BigDecimal(支持多种类型) private BigDecimal parseToBigDecimal(Object dataValue) { if (dataValue instanceof BigDecimal) { @@ -276,5 +304,64 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService // 3. 转换为Date return new Date(updateTime); } + /** + * 自定义多类型比较器,支持BigDecimal、Integer、String等类型比较 + */ + private static int compareMultiType(Object o1, Object o2) { + // 统一转换为Comparable进行比较 + try { + // 对于数字类型(BigDecimal、Integer等) + if (o1 instanceof Number && o2 instanceof Number) { + Number numObj1 = (Number) o1; + Number numObj2 = (Number) o2; + BigDecimal num1 = toBigDecimal(numObj1); + BigDecimal num2 = toBigDecimal(numObj2); + return num1.compareTo(num2); + } + + // 对于字符串类型 + if (o1 instanceof String && o2 instanceof String) { + String str1 = (String) o1; + String str2 = (String) o2; + + if (isNumericString(str1) && isNumericString(str2)) { + return new BigDecimal(str1).compareTo(new BigDecimal(str2)); + } + return str1.compareTo(str2); + } + + // 其他类型默认按toString比较 + return o1.toString().compareTo(o2.toString()); + + } catch (Exception e) { + // 比较失败时按toString兜底 + return o1.toString().compareTo(o2.toString()); + } + } + + /** + * 将Number类型转换为BigDecimal + */ + private static BigDecimal toBigDecimal(Number number) { + if (number instanceof BigDecimal) { + return (BigDecimal) number; + } + return new BigDecimal(number.toString()); + } + + /** + * 判断字符串是否为数字格式 + */ + private static boolean isNumericString(String str) { + if (str == null || str.isEmpty()) { + return false; + } + try { + new BigDecimal(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } } -- 2.49.0 From 609803605d9d619d52ea71c38827958e395e967a Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 14 Oct 2025 14:36:34 +0800 Subject: [PATCH 176/336] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java index 8e41617..e8843af 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsTicketServiceImpl.java @@ -85,10 +85,10 @@ public class EmsTicketServiceImpl implements IEmsTicketService @Override public int updateEmsTicket(EmsTicket emsTicket) { - String status = emsTicket.getStatus().toString(); + String status = emsTicket.getStatus() == null ? "" : emsTicket.getStatus().toString(); String ticketNo = emsTicket.getTicketNo(); // 判断工单状态为:3-已完成 - if ("3".equals(status) && !StringUtils.isEmpty(ticketNo)) { + if (!StringUtils.isEmpty(status) && "3".equals(status) && !StringUtils.isEmpty(ticketNo)) { // 处理告警数据状态-已处理 EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.getAlarmByTicketNo(ticketNo); if (emsAlarmRecords != null) { -- 2.49.0 From 3020f9f915c65f6d3e380583cf88cffbee06f58d Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 14 Oct 2025 16:50:53 +0800 Subject: [PATCH 177/336] =?UTF-8?q?task63-=E7=82=B9=E4=BD=8D=E6=B8=85?= =?UTF-8?q?=E5=8D=95=E5=A2=9E=E5=8A=A0=E5=8D=95=E4=BD=8D=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/EmsPointMatch.java | 51 +++++++++++++++++-- .../ems/domain/vo/PointQueryResponse.java | 12 +++++ .../impl/FXXDataProcessServiceImpl.java | 1 - .../mapper/ems/EmsPointMatchMapper.xml | 26 ++++++++-- 4 files changed, 82 insertions(+), 8 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java index 0bc2052..c15a3d0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -9,7 +9,7 @@ import com.xzzn.common.annotation.Excel; * 点位匹配对象 ems_point_match * * @author xzzn - * @date 2025-09-13 + * @date 2025-10-14 */ public class EmsPointMatch extends BaseEntity { @@ -18,8 +18,8 @@ public class EmsPointMatch extends BaseEntity /** 设备ID,主键自增长 */ private Long id; - /** 点位名称 */ - @Excel(name = "点位名称") + /** 存储点位名称 */ + @Excel(name = "存储点位名称") private String pointName; /** 点位所在表 */ @@ -50,6 +50,18 @@ public class EmsPointMatch extends BaseEntity @Excel(name = "数据点位来源设备") private String dataDevice; + /** 数据单位 */ + @Excel(name = "数据单位") + private String dataUnit; + + /** 数据类型:1-瞬时值 2-增量 */ + @Excel(name = "数据类型:1-瞬时值 2-增量") + private Long dataType; + + /** 点位是否需要区分多设备:0-不需要 1-需要 */ + @Excel(name = "点位是否需要区分多设备:0-不需要 1-需要") + private Long needDiffDeviceId; + public void setId(Long id) { this.id = id; @@ -140,6 +152,36 @@ public class EmsPointMatch extends BaseEntity return dataDevice; } + public void setDataUnit(String dataUnit) + { + this.dataUnit = dataUnit; + } + + public String getDataUnit() + { + return dataUnit; + } + + public void setDataType(Long dataType) + { + this.dataType = dataType; + } + + public Long getDataType() + { + return dataType; + } + + public void setNeedDiffDeviceId(Long needDiffDeviceId) + { + this.needDiffDeviceId = needDiffDeviceId; + } + + public Long getNeedDiffDeviceId() + { + return needDiffDeviceId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -152,6 +194,9 @@ public class EmsPointMatch extends BaseEntity .append("dataPoint", getDataPoint()) .append("dataPointName", getDataPointName()) .append("dataDevice", getDataDevice()) + .append("dataUnit", getDataUnit()) + .append("dataType", getDataType()) + .append("needDiffDeviceId", getNeedDiffDeviceId()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java index e03cff5..a9c24b1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java @@ -38,6 +38,18 @@ public class PointQueryResponse @Excel(name = "点位最新数据") private int isNeedDeviceId; + /** 数据单位 */ + @Excel(name = "数据单位") + private String dataUnit; + + public String getDataUnit() { + return dataUnit; + } + + public void setDataUnit(String dataUnit) { + this.dataUnit = dataUnit; + } + public int getIsNeedDeviceId() { return isNeedDeviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index d5a8a01..cb1b3d3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -115,7 +115,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl batteryStackDataProcess(deviceId, jsonData); } else if (deviceId.contains("BMSC")) { - log.info("BMSC data:"+ jsonData); batteryClusterDataProcess(deviceId, jsonData); batteryDataProcess(deviceId, jsonData,dataUpdateTime); diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 870d722..ce80d20 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -14,6 +14,9 @@ + + + @@ -22,7 +25,7 @@ - select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, create_by, create_time, update_by, update_time, remark from ems_point_match + select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark from ems_point_match @@ -55,6 +61,9 @@ data_point, data_point_name, data_device, + data_unit, + data_type, + need_diff_device_id, create_by, create_time, update_by, @@ -70,6 +79,9 @@ #{dataPoint}, #{dataPointName}, #{dataDevice}, + #{dataUnit}, + #{dataType}, + #{needDiffDeviceId}, #{createBy}, #{createTime}, #{updateBy}, @@ -89,6 +101,9 @@ data_point = #{dataPoint}, data_point_name = #{dataPointName}, data_device = #{dataDevice}, + data_unit = #{dataUnit}, + data_type = #{dataType}, + need_diff_device_id = #{needDiffDeviceId}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, @@ -323,7 +338,8 @@ t.data_point as dataPoint, t.data_point_name as dataPointName, t.data_device as dataDevice, - t.need_diff_device_id as isNeedDeviceId + t.need_diff_device_id as isNeedDeviceId, + t.data_unit as dataUnit from ems_point_match t where 1=1 @@ -344,14 +360,16 @@ SELECT tmp.pointName, tmp.dataPoint, tmp.dataDevice, - tmp.dataPointName + tmp.dataPointName, + tmp.dataUnit FROM ( select t.point_name as pointName, case when t.need_diff_device_id = 1 and t.data_device = 'PCS' then concat(#{deviceId}, t.data_point) when t.need_diff_device_id = 1 and t.data_device = 'BMSD' then concat(#{parentDeviceId}, t.data_point) else t.data_point end as dataPoint, t.data_point_name as dataPointName, - t.data_device as dataDevice + t.data_device as dataDevice, + t.data_unit as dataUnit from ems_point_match t where 1=1 -- 2.49.0 From 15b964b4cefc1070800aafd856311ea770d71736 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 14 Oct 2025 17:07:00 +0800 Subject: [PATCH 178/336] =?UTF-8?q?task66-=E5=8D=95=E4=BD=93=E7=94=B5?= =?UTF-8?q?=E6=B1=A0=E8=B0=83=E7=BB=BC=E5=90=88=E6=9F=A5=E8=AF=A2=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E6=9B=B2=E7=BA=BF=E6=8E=A5=E5=8F=A3-=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=B0=87id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/mapper/EmsPointMatchMapper.java | 9 ++++++--- .../xzzn/ems/service/impl/GeneralQueryServiceImpl.java | 7 ++++--- .../main/resources/mapper/ems/EmsPointMatchMapper.xml | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 2807b09..b3d4f72 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -80,21 +80,24 @@ public interface EmsPointMatchMapper @Param("tableField")String tableField, @Param("startDate")Date startDate, @Param("endDate")Date endDate, - @Param("params") Map> params); + @Param("params") Map> params, + @Param("clusterDeviceId")String clusterDeviceId); // 根据条件查询数据-按小时-单体电池特殊处理 public List getBatteryPointDataByHours(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate") Date startDate, @Param("endDate")Date endDate, - @Param("params") Map> params); + @Param("params") Map> params, + @Param("clusterDeviceId")String clusterDeviceId); // 根据条件查询数据-按天-单体电池特殊处理 public List getBatteryPointDataByDays(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @Param("tableField")String tableField, @Param("startDate")Date startDate, @Param("endDate")Date endDate, - @Param("params") Map> params); + @Param("params") Map> params, + @Param("clusterDeviceId")String clusterDeviceId); // 根据条件查询数据-按分钟-其他设备 public List getCommonPointDataByMinutes(@Param("siteIds")List siteIds, diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index 0fadf9b..cb1724e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -158,12 +158,13 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService List dataVoList = new ArrayList<>(); int dataUnit = request.getDataUnit(); + String clusterDeviceId = request.getDeviceId(); Date startDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getStartDate()); Date endDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,request.getEndDate()); Map> siteDeviceMap = request.getSiteDeviceMap(); if (dataUnit == 1) { // 分钟 startDate = DateUtils.adjustToStartOfMinutes(request.getStartDate()); - dataVoList = emsPointMatchMapper.getBatteryPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + dataVoList = emsPointMatchMapper.getBatteryPointDataByMinutes(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap,clusterDeviceId); if (dataVoList != null && dataVoList.size() > 0) { dataVoList = dealWithBatteryMinutesData(querySiteIds,dataVoList,deviceCategory, request.getStartDate(),request.getEndDate(),siteDeviceMap); @@ -171,11 +172,11 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService } else if (dataUnit == 2) { // 小时 startDate = DateUtils.adjustToStartOfHour(request.getStartDate()); tableName = "ems_battery_data_hour"; - dataVoList = emsPointMatchMapper.getBatteryPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + dataVoList = emsPointMatchMapper.getBatteryPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap,clusterDeviceId); } else if (dataUnit == 3) { // 天 endDate = DateUtils.adjustToEndOfDay(request.getEndDate()); tableName = "ems_battery_data_day"; - dataVoList = emsPointMatchMapper.getBatteryPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap); + dataVoList = emsPointMatchMapper.getBatteryPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap,clusterDeviceId); } // 数据转换 result = convertBatteryToResultList(dataVoList); diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index ce80d20..f29c14d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -165,6 +165,9 @@ + + and cluster_device_id = #{clusterDeviceId} + AND ( -- 2.49.0 From d468ef9941bd83cc768ecbdfa88878e6f32a8d17 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 14 Oct 2025 17:32:16 +0800 Subject: [PATCH 179/336] =?UTF-8?q?task65-=E5=8A=A8=E6=80=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=AB=99=E7=82=B9=E4=B8=8B=E8=AE=BE=E5=A4=87=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/web/controller/ems/EmsSiteConfigController.java | 9 +++++++++ .../com/xzzn/ems/mapper/EmsDevicesSettingMapper.java | 2 +- .../com/xzzn/ems/service/IEmsDeviceSettingService.java | 2 ++ .../ems/service/impl/EmsDeviceSettingServiceImpl.java | 6 ++++++ .../resources/mapper/ems/EmsDevicesSettingMapper.xml | 9 +++++++-- 5 files changed, 25 insertions(+), 3 deletions(-) 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 cc3c17a..d9d419e 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 @@ -152,4 +152,13 @@ public class EmsSiteConfigController extends BaseController{ List result = iEmsDeviceSettingService.getSingleSiteDevicePoints(request); return getDataTable2(result); } + + /** + * 获取指定站点下的所有设备类别 + */ + @GetMapping("/getSiteAllDeviceCategory") + public AjaxResult getSiteAllDeviceCategory(String siteId) + { + return success(iEmsDeviceSettingService.getSiteAllDeviceCategory(siteId)); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java index d46d6b0..0afbaee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDevicesSettingMapper.java @@ -88,5 +88,5 @@ public interface EmsDevicesSettingMapper public List> getClusterIdsByFuzzyQuery(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("parentId")String parentId); - public List getDeviceIdsBySiteIdAndCategory(@Param("siteId")String siteId,@Param("deviceCategory")String deviceCategory); + public List getAllDeviceCategoryBySiteId(String siteId); } 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 87cf5d9..eb21c9e 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 @@ -26,4 +26,6 @@ public interface IEmsDeviceSettingService public List getDeviceCategory(); public List getSingleSiteDevicePoints(PointDataRequest request); + + public List getSiteAllDeviceCategory(String siteId); } 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 94d6319..f558976 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 @@ -219,6 +219,12 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService .sorted(finalComparator) .collect(Collectors.toList()); } + + @Override + public List getSiteAllDeviceCategory(String siteId) { + return emsDevicesMapper.getAllDeviceCategoryBySiteId(siteId); + } + // 辅助方法:根据值查找对应的对象(用于比较器中获取完整对象) private PointQueryResponse findByValue(List list, Object value) { return list.stream() diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index af5eb4f..3c666ec 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -216,7 +216,12 @@ and device_category = #{deviceCategory} - + select DISTINCT device_category + from ems_devices_setting + where 1=1 + + and site_id = #{siteId} + \ No newline at end of file -- 2.49.0 From 250318ddef74c9f5398307bf2b7a046fd0bc55cb Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 15 Oct 2025 15:39:18 +0800 Subject: [PATCH 180/336] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E4=BF=A1=E6=81=AF=E5=AD=98=E5=85=A5redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 2 + .../manager/ModbusConnectionManager.java | 5 ++ .../ems/service/IEmsDeviceSettingService.java | 3 + .../impl/DDSDataProcessServiceImpl.java | 73 ++++++++++++++----- 4 files changed, 65 insertions(+), 18 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 46971ca..09e84e5 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -67,6 +67,8 @@ public class RedisKeyConstants /** topic 内没有数据设备维度告警 */ public static final String TOPIC_EMPTY_ALARM_RECORD = "topic_empty_"; + /** 设备信息初始化 */ + public static final String INIT_DEVICE_INFO = "init_device_info"; /** 告警匹配信息 */ public static final String ALARM_MATCH_INFO = "alarm_message_info"; diff --git a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java index 901dec7..6ca81fc 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java +++ b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java @@ -4,6 +4,7 @@ import com.ghgande.j2mod.modbus.net.TCPMasterConnection; import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.service.IEmsAlarmRecordsService; +import com.xzzn.ems.service.IEmsDeviceSettingService; import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import org.apache.commons.pool2.impl.GenericObjectPool; import org.slf4j.Logger; @@ -41,6 +42,8 @@ public class ModbusConnectionManager implements ApplicationRunner { private IEmsAlarmRecordsService iEmsAlarmRecordsService; @Autowired private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; + @Autowired + private IEmsDeviceSettingService iEmsDeviceSettingService; @Override public void run(ApplicationArguments args) throws Exception { @@ -58,6 +61,8 @@ public class ModbusConnectionManager implements ApplicationRunner { } private void initData() { + // 初始化-设备信息 + iEmsDeviceSettingService.initDeviceInfo(); // 初始化-告警数据 iEmsAlarmRecordsService.initAlarmMatchInfo(); // 初始化当月电价 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 eb21c9e..9540a9b 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 @@ -7,6 +7,7 @@ import com.xzzn.ems.domain.vo.PointDataRequest; import com.xzzn.ems.domain.vo.PointQueryResponse; import java.util.List; +import java.util.Map; /** * 设备信息 服务层 @@ -28,4 +29,6 @@ public interface IEmsDeviceSettingService public List getSingleSiteDevicePoints(PointDataRequest request); public List getSiteAllDeviceCategory(String siteId); + // 初始化设备信息 + public Map> initDeviceInfo(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 06cf38e..f066353 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -17,6 +17,7 @@ import com.xzzn.ems.domain.vo.EnergyPriceVo; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IDDSDataProcessService; import com.xzzn.ems.service.IEmsAlarmRecordsService; +import com.xzzn.ems.service.IEmsDeviceSettingService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -81,6 +82,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private IEmsAlarmRecordsService iEmsAlarmRecordsService; @Autowired private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; + @Autowired + private IEmsDeviceSettingService iEmsDeviceSettingService; public DDSDataProcessServiceImpl(ObjectMapper objectMapper) { super(objectMapper); @@ -92,6 +95,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl String deviceId = obj.get("Device").toString(); String jsonData = obj.get("Data").toString(); + Long timestamp = Long.valueOf(obj.get("timestamp").toString()); + Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); log.info("deviceId:" + deviceId); boolean isEmpty = checkJsonDataEmpty(jsonData); @@ -108,7 +113,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl if (deviceId.contains("BMSD")) { batteryStackDataProcess(deviceId, jsonData); batteryGroupDataProcess(deviceId, jsonData); - batteryDataProcess(deviceId, jsonData); + batteryDataProcess(deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains("PCS")) { pcsDataProcess(deviceId, jsonData); pcsBranchDataProcess(deviceId, jsonData); @@ -293,7 +298,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl break; } } - private void batteryDataProcess(String deviceId, String dataJson) { + private void batteryDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { //电池组 Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); @@ -308,6 +313,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl Map dailyMap = new HashMap<>(); Map minutesMap = new HashMap<>(); + String clusterId = getClusterDeviceIdByParentDeviceId(deviceId); for (Map.Entry entry : obj.entrySet()) { String key = entry.getKey(); @@ -319,10 +325,10 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsBatteryData data = dataMap.getOrDefault(batteryCellId, new EmsBatteryData()); if (StringUtils.isNotEmpty(batteryCellId)) { - data.setDataTimestamp(DateUtils.getNowDate()); + data.setDataTimestamp(dataUpdateTime); data.setBatteryPack(deviceId); - data.setBatteryCluster("BMSC01");// 写死 - data.setClusterDeviceId("BMSC01"); + data.setBatteryCluster(clusterId); + data.setClusterDeviceId(clusterId); data.setBatteryCellId(batteryCellId); data.setSiteId(SITE_ID); data.setDeviceId(batteryCellId); @@ -352,8 +358,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataList = new ArrayList<>(dataMap.values()); emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList)); - redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01"); - redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + "BMSC01" , dataList); + redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + clusterId); + redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + clusterId , dataList); } // 批量处理每日最新数据 List dailyList = new ArrayList<>(dailyMap.values()); @@ -376,6 +382,26 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } } + private String getClusterDeviceIdByParentDeviceId(String deviceId) { + String clusterId = "BMSC01"; + Map> map = redisCache.getCacheObject(RedisKeyConstants.INIT_DEVICE_INFO); + if (map == null || map.isEmpty()) { + map = iEmsDeviceSettingService.initDeviceInfo(); + } + // 不为空,则查找子类的簇id + if (map != null && !map.isEmpty()) { + List list = map.get(SITE_ID); + if (list != null && list.size() > 0) { + for (EmsDevicesSetting emsDevicesSetting : list) { + if (deviceId.equals(emsDevicesSetting.getParentId())) { + clusterId = emsDevicesSetting.getDeviceId(); + } + } + } + } + return clusterId; + } + private void setDTDCPropertyValue(EmsBatteryData data, String property, Object value) { BigDecimal numberValue = null; if (value instanceof Number) { @@ -416,7 +442,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl data.setSiteId(SITE_ID); // BMSC02 电流电压功率 deviceId = "BMSC02"; - String stackDeviceId = getDeviceParent(deviceId, SITE_ID); + String stackDeviceId = getDeviceParent(deviceId); if (StringUtils.isNotBlank(stackDeviceId)) { data.setStackDeviceId(stackDeviceId); } else { @@ -438,7 +464,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // BMSC01 电流电压功率 deviceId = "BMSC01"; - stackDeviceId = getDeviceParent(deviceId, SITE_ID); + stackDeviceId = getDeviceParent(deviceId); if (StringUtils.isNotBlank(stackDeviceId)) { data.setStackDeviceId(stackDeviceId); } else { @@ -469,16 +495,27 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); } - private String getDeviceParent(String deviceId,String siteId) { - EmsDevicesSetting joken = new EmsDevicesSetting(); - joken.setDeviceId(deviceId); - joken.setSiteId(siteId); - List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); - String stackDeviceId = ""; - if (up != null && up.size() >0) { - stackDeviceId = up.get(0).getParentId(); + private String getDeviceParent(String deviceId) { + Map> map = redisCache.getCacheObject(RedisKeyConstants.INIT_DEVICE_INFO); + if (map == null || map.isEmpty()) { + map = iEmsDeviceSettingService.initDeviceInfo(); + } + // 不为空,则查找父类 + String stackDeviceId = "1"; + if (map != null && !map.isEmpty()) { + List list = map.get(SITE_ID); + if (list == null || list.isEmpty()) { + EmsDevicesSetting deviceInfo = new EmsDevicesSetting(); + deviceInfo.setDeviceId(deviceId); + deviceInfo.setSiteId(SITE_ID); + list = emsDevicesSettingMapper.selectEmsDevicesSettingList(deviceInfo); + if (list == null || list.isEmpty()) { + return stackDeviceId; + } + } + stackDeviceId = list.get(0).getParentId(); if (stackDeviceId == null || stackDeviceId.isEmpty()) { - stackDeviceId = "1"; + return stackDeviceId; } } return stackDeviceId; -- 2.49.0 From 451b2f676697bffc2c3ccef4e56e2978b60abe8c Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 15 Oct 2025 16:26:21 +0800 Subject: [PATCH 181/336] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=88=B6=E7=B1=BB=E7=B1=BB=E5=88=AB=E7=9A=84?= =?UTF-8?q?id=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 11 ++++- .../com/xzzn/common/enums/DeviceCategory.java | 41 ++++++++++++++----- .../com/xzzn/ems/service/IEmsSiteService.java | 2 + .../ems/service/impl/EmsSiteServiceImpl.java | 12 ++++++ 4 files changed, 53 insertions(+), 13 deletions(-) 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 d9d419e..33beaa9 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 @@ -35,8 +35,6 @@ public class EmsSiteConfigController extends BaseController{ @Autowired private IEmsDeviceSettingService iEmsDeviceSettingService; - @Autowired - private EmsPointMatchMapper emsPointMatchMapper; /** * 获取站点列表 @@ -161,4 +159,13 @@ public class EmsSiteConfigController extends BaseController{ { return success(iEmsDeviceSettingService.getSiteAllDeviceCategory(siteId)); } + + /** + * 根据设备类别获取父类的设备id + */ + @GetMapping("/getParentDeviceId") + public AjaxResult getParentDeviceId(@RequestParam String siteId, @RequestParam String deviceCategory) + { + return success(iEmsSiteService.getParentCategoryDeviceId(siteId, deviceCategory)); + } } diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java index 6a23611..4be8b3e 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java @@ -1,5 +1,7 @@ package com.xzzn.common.enums; +import org.apache.xmlbeans.impl.common.NameUtil; + import java.util.HashMap; import java.util.Map; @@ -10,24 +12,26 @@ import java.util.Map; */ public enum DeviceCategory { - PCS("PCS", "PCS设备"), - BRANCH("BRANCH", "PCS分支设备"), - STACK("STACK", "电池堆"), - CLUSTER("CLUSTER", "电池簇"), - BATTERY("BATTERY", "单体电池"), - AMMETER("AMMETER", "电表"), - COOLING("COOLING", "冷却"), - DH("DH", "动环"), - XF("XF", "消防"), - BATTERY_GROUP("BATTERY_GROUP", "电池组"); + PCS("PCS", "PCS设备", null), + BRANCH("BRANCH", "PCS分支设备", PCS), + STACK("STACK", "电池堆", null), + CLUSTER("CLUSTER", "电池簇", STACK), + BATTERY("BATTERY", "单体电池", CLUSTER), + AMMETER("AMMETER", "电表", null), + COOLING("COOLING", "冷却", null), + DH("DH", "动环", null), + XF("XF", "消防", null), + BATTERY_GROUP("BATTERY_GROUP", "电池组", null),; private final String code; private final String info; + private final DeviceCategory parentCategory; - DeviceCategory(String code, String info) + DeviceCategory(String code, String info, DeviceCategory parentCategory) { this.code = code; this.info = info; + this.parentCategory = parentCategory; } public String getCode() @@ -40,6 +44,10 @@ public enum DeviceCategory return info; } + public DeviceCategory getParentCategory() + { + return parentCategory; + } // 缓存info与code的映射(优化查询效率) private static final Map INFO_CODE_MAP = new HashMap<>(); @@ -54,4 +62,15 @@ public enum DeviceCategory public static String getCodeByInfo(String info) { return INFO_CODE_MAP.get(info); // 从缓存中直接获取,效率高 } + + // 通过code获取父类code + // 根据字符串编码查找对应的枚举 + public static DeviceCategory fromCode(String code) { + for (DeviceCategory category : values()) { + if (category.code.equalsIgnoreCase(code)) { // 忽略大小写,增强兼容性 + return category; + } + } + return null; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index c2acc64..11c8cda 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -28,4 +28,6 @@ public interface IEmsSiteService public List getAllDeviceList(String siteId); public List> getAllPcsInfo(String siteId); + + public List> getParentCategoryDeviceId(String siteId, String deviceCategory); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index cadf8d7..23844e0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -106,4 +106,16 @@ public class EmsSiteServiceImpl implements IEmsSiteService public List> getAllPcsInfo(String siteId) { return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode()); } + + // 根据设备类别获取父类的设备id + @Override + public List> getParentCategoryDeviceId(String siteId, String deviceCategory) { + DeviceCategory category = DeviceCategory.fromCode(deviceCategory); + if(category == null || category.getParentCategory() == null){ + return null; + } + String parentCategory = category.getParentCategory().getCode(); + List> deviceIdList = emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, parentCategory); + return deviceIdList; + } } -- 2.49.0 From 67168524356d2e5eba89ac7ec8dc3a9363b93039 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 15 Oct 2025 16:27:22 +0800 Subject: [PATCH 182/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8-?= =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0=E7=9A=84=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/vo/PointDataRequest.java | 10 +++ .../xzzn/ems/mapper/EmsBatteryDataMapper.java | 22 ----- .../mapper/EmsBatteryDataMinutesMapper.java | 6 ++ .../impl/EmsDeviceSettingServiceImpl.java | 85 +++++++++++++++++-- .../ems/EmsBatteryDataMinutesMapper.xml | 12 +++ 5 files changed, 108 insertions(+), 27 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java index 9fbeaac..cddf9f5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java @@ -29,6 +29,16 @@ public class PointDataRequest { private BigDecimal upper; /** 排序字段 */ private String sortData; + /** 父类deviceId */ + private String parentId; + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } public String getSortData() { return sortData; diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java index 1bd9546..2a222b4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMapper.java @@ -65,28 +65,6 @@ public interface EmsBatteryDataMapper */ public int deleteEmsBatteryDataByIds(Long[] ids); - /** - * 根据siteId查询站点电池实时数据 - * @param siteId - * @return - */ - public EmsBatteryData getBatteryDataBySiteId(String siteId); - - /** - * 根据siteId和簇id获取单体数据 - * @param siteId - * @param clusterDeviceId - * @return - */ - public BatteryClusterDataDetailVo getBatteryDataByClusterId(@Param("siteId")String siteId, @Param("clusterDeviceId")String clusterDeviceId); - - /** - * 获取最大最小的单体id - * @param dataVo - * @return - */ - public List> getDataIdsMap(BatteryClusterDataDetailVo dataVo); - /** * 根据电池簇设备id获取下面所有单体电池 * @param clusterDeviceId diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java index b001591..f2b76d7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsBatteryDataMinutesMapper.java @@ -5,6 +5,7 @@ import java.util.List; import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsBatteryDataMinutes; +import org.apache.ibatis.annotations.Param; /** * 单体电池分钟级数据Mapper接口 @@ -65,4 +66,9 @@ public interface EmsBatteryDataMinutesMapper int insertMinutesBatteryDataList(List emsBatteryDataList); public void deleteByTimeBeforeOneHour(String oneHourAgoStr); + + // 获取指定站点指定电池簇下面的单体电池最新数据 + public EmsBatteryData getLastBatteryData(@Param("siteId") String siteId, + @Param("clusterDeviceId") String clusterDeviceId, + @Param("deviceId") String deviceId); } \ No newline at end of file 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 f558976..dc02593 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 @@ -6,11 +6,13 @@ import com.alibaba.fastjson2.TypeReference; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDevicesSetting; 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.EmsPointMatchMapper; import com.xzzn.ems.service.IEmsDeviceSettingService; @@ -19,6 +21,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -36,6 +39,11 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService private EmsPointMatchMapper emsPointMatchMapper; @Autowired private RedisCache redisCache; + @Autowired + private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; + @Autowired + private EmsBatteryClusterServiceImpl emsBatteryClusterServiceImpl; + /** * 获取设备详细信息 * @param id @@ -129,14 +137,18 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService List response = new ArrayList<>(); - + String dataPointName = request.getDataPointName(); + String dataPoint = request.getDataPoint(); + String parentDeviceId = request.getParentId(); // 电动所的电池簇特殊处理-来源pcs+bmsd if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { - response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory, - request.getDataPointName(),request.getDataPoint()); + response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory,dataPointName,dataPoint); + } else if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { + response = specialDealWithBattery(siteId,deviceId,deviceCategory, + dataPointName,dataPoint,parentDeviceId); } else { - response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory, - request.getDataPointName(),request.getDataPoint()); + response = emsPointMatchMapper.getSingleSiteDevicePoints( + siteId,deviceCategory,dataPointName,dataPoint); // 从redis取最新数据 JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); if(mqttJson == null){ @@ -220,6 +232,54 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService .collect(Collectors.toList()); } + private List specialDealWithBattery(String siteId, String deviceId, String deviceCategory, + String dataPointName, String dataPoint, String parentDeviceId) { + List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory, + dataPointName,dataPoint); + + // 获取redis同步最新数据 + JSONObject jsonObject = new JSONObject(); + if (SiteEnum.DDS.getCode().equals(siteId)) { + // dds单体电池数据来源于BMSD + EmsDevicesSetting clusterDevice = emsDevicesMapper.getDeviceBySiteAndDeviceId(parentDeviceId,siteId); + String bmsdDeviceId = clusterDevice == null ? "" :clusterDevice.getParentId(); + if (StringUtils.isEmpty(bmsdDeviceId)) { + return response; + } + jsonObject = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + bmsdDeviceId); + } else if (SiteEnum.FX.getCode().equals(siteId)) { + // fx单体电池数据来源于父类簇BMSC + jsonObject = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + parentDeviceId); + } + if (jsonObject != null) { + // 填充数据 + fillBatteryData(jsonObject,siteId, deviceId, response); + } + return response; + } + + private void fillBatteryData(JSONObject jsonObject, String siteId, String deviceId, List response) { + String jsonData = jsonObject.get("Data").toString(); + if (StringUtils.isEmpty(jsonData)) { + return; + } + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + Long updateTime = Long.valueOf(jsonObject.get("timestamp").toString()); + Date dataUpdateTime = DateUtils.convertUpdateTime(updateTime); + // 遍历点位数据,设最新值 + for (PointQueryResponse pointInfo : response) { + String dataKey = ""; + if (SiteEnum.DDS.getCode().equals(siteId)) { + dataKey = "DTDC" + deviceId + pointInfo.getDataPoint(); + } else if (SiteEnum.FX.getCode().equals(siteId)) { + dataKey = pointInfo.getDataPoint() + deviceId; + } + pointInfo.setPointValue(obj.get(dataKey)); + pointInfo.setUpdateTime(dataUpdateTime); + } + } + @Override public List getSiteAllDeviceCategory(String siteId) { return emsDevicesMapper.getAllDeviceCategoryBySiteId(siteId); @@ -370,4 +430,19 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService return false; } } + + @Override + public Map> initDeviceInfo() { + List settingList = emsDevicesMapper.selectEmsDevicesSettingList(null); + // 按siteId分组 + Map> map = settingList.stream() + .collect(Collectors.groupingBy( + EmsDevicesSetting::getSiteId, + HashMap::new, + Collectors.toList() + )); + // 存redis + redisCache.setCacheObject(RedisKeyConstants.INIT_DEVICE_INFO, map, 30, TimeUnit.DAYS); + return map; + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml index 3781843..070cf44 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMinutesMapper.xml @@ -149,4 +149,16 @@ delete from ems_battery_data_minutes where data_timestamp < #{oneHourAgoStr} + + \ No newline at end of file -- 2.49.0 From 391ed354f8b3b806f6d5d2db6d2a3f640329c87b Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 15 Oct 2025 17:53:12 +0800 Subject: [PATCH 183/336] =?UTF-8?q?dds-=E7=94=B5=E6=B1=A0=E7=B0=87?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E7=88=B6?= =?UTF-8?q?=E7=B1=BBstackId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/service/impl/DDSDataProcessServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index f066353..7cf76e3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -513,9 +513,10 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return stackDeviceId; } } - stackDeviceId = list.get(0).getParentId(); - if (stackDeviceId == null || stackDeviceId.isEmpty()) { - return stackDeviceId; + for (EmsDevicesSetting emsDevicesSetting : list) { + if (deviceId.equals(emsDevicesSetting.getDeviceId())) { + stackDeviceId = emsDevicesSetting.getParentId(); + } } } return stackDeviceId; -- 2.49.0 From 94e18c029c7a057cecd4355b171519b260e3ceb8 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 16 Oct 2025 14:04:13 +0800 Subject: [PATCH 184/336] =?UTF-8?q?=E7=94=B5=E4=BB=B7-=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E6=94=B6=E5=85=A5=E5=AE=9E=E6=97=B6=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DDSDataProcessServiceImpl.java | 16 +++++++-- .../service/impl/SingleSiteServiceImpl.java | 34 ++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 7cf76e3..181368e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -426,8 +426,6 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl }); EmsDevicesSetting joken = new EmsDevicesSetting(); - // 获取redis获取最新的BMSD01数据 - Map stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD +SITE_ID+"_BMSD01"); //BMSC 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); @@ -448,6 +446,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else { data.setStackDeviceId("1"); } + // 获取redis获取最新的BMSD数据 + Map stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD +SITE_ID+"_"+stackDeviceId); data.setDeviceId(deviceId); data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC02ZLDY"))); data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC02ZLDL"))); @@ -459,6 +459,16 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl data.setBatteryPackCurrent(StringUtils.getBigDecimal(stackObj.get("BMSD02DL"))); data.setBatteryPackSoc(StringUtils.getBigDecimal(stackObj.get("BMSD02SOC"))); data.setBatteryPackSoh(StringUtils.getBigDecimal(stackObj.get("BMSD02SOH"))); + data.setAvgCellTemp(StringUtils.getBigDecimal(stackObj.get("DTPJWD"))); + data.setMaxCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZDDY"))); + data.setMaxCellVoltageId(StringUtils.getString(stackObj.get("DTZDDYXH"))); + data.setMinCellVoltage(StringUtils.getBigDecimal(stackObj.get("DTZXDY"))); + data.setMinCellVoltageId(StringUtils.getString(stackObj.get("DTZXDYXH"))); + data.setMaxCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZGWD"))); + data.setMaxCellTempId(StringUtils.getString(stackObj.get("DTZGWDXH"))); + data.setMinCellTemp(StringUtils.getBigDecimal(stackObj.get("DTZDWD"))); + data.setMinCellTempId(StringUtils.getString(stackObj.get("DTZDWDXH"))); + emsBatteryClusterMapper.insertEmsBatteryCluster(data); redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); @@ -470,6 +480,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else { data.setStackDeviceId("1"); } + // 获取redis获取最新的BMSD数据 + stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD +SITE_ID+"_"+stackDeviceId); data.setDeviceId(deviceId); data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("BMSC01ZLDY"))); data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("BMSC01ZLDL"))); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 96bd173..7e9a424 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -64,6 +64,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private EmsDailyChargeDataMapper emsDailyChargeDataMapper; @Autowired private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; + @Autowired + private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; @Override public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { @@ -124,12 +126,36 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } private void setRevenueInfo(SiteMonitorHomeVo siteMonitorHomeVo, String siteId) { + // 默认0 BigDecimal totalRevenue = BigDecimal.ZERO; BigDecimal dayRevenue = BigDecimal.ZERO; - Map realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); - if (realTimeRevenue != null) { - totalRevenue = realTimeRevenue.get("totalRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("totalRevenue"); - dayRevenue = realTimeRevenue.get("dayRevenue") == null ? BigDecimal.ZERO : realTimeRevenue.get("dayRevenue"); + // 当日实时数据 + String today = DateUtils.getDate(); + EmsDailyEnergyData todayData = emsDailyEnergyDataMapper.getDataByDate(siteId,today); + if (todayData == null) { + Map lastData = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); + if (lastData != null) { + totalRevenue = lastData.get("totalRevenue") == null ? BigDecimal.ZERO : lastData.get("totalRevenue"); + } + } else { + totalRevenue = todayData.getTotalRevenue() == null ? BigDecimal.ZERO : todayData.getTotalRevenue(); + // 获取当月电价 + int currentMonth = LocalDate.now().getMonthValue(); + int currentYear = LocalDate.now().getYear(); + EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId, String.valueOf(currentYear), String.valueOf(currentMonth)); + if (priceConfig != null) { + // 计算各个时段单独收益=(放电量-充电量)*电价,累加即当日实时收益 + BigDecimal peakRevenue = todayData.getPeakDischargeDiff().subtract(todayData.getPeakChargeDiff()) + .multiply(priceConfig.getPeak() == null ? BigDecimal.ZERO : priceConfig.getPeak()); + BigDecimal highRevenue = todayData.getHighDischargeDiff().subtract(todayData.getHighChargeDiff()) + .multiply(priceConfig.getHigh() == null ? BigDecimal.ZERO : priceConfig.getHigh()); + BigDecimal flatRevenue = todayData.getFlatDischargeDiff().subtract(todayData.getFlatChargeDiff()) + .multiply(priceConfig.getFlat() == null ? BigDecimal.ZERO : priceConfig.getFlat()); + BigDecimal valleyRevenue = todayData.getValleyDischargeDiff().subtract(todayData.getValleyChargeDiff()) + .multiply(priceConfig.getValley() == null ? BigDecimal.ZERO : priceConfig.getValley()); + dayRevenue = dayRevenue.add(peakRevenue).add(highRevenue).add(flatRevenue).add(valleyRevenue) + .setScale(4, RoundingMode.HALF_UP); + } } siteMonitorHomeVo.setTotalRevenue(totalRevenue); siteMonitorHomeVo.setDayRevenue(dayRevenue); -- 2.49.0 From d0275e62e0c323c25c910e3696143dc770a83eea Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 16 Oct 2025 14:57:18 +0800 Subject: [PATCH 185/336] =?UTF-8?q?=E7=94=B5=E4=BB=B7-=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E6=94=B6=E5=85=A5=E5=AE=9E=E6=97=B6=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IEmsEnergyPriceConfigService.java | 5 +++ .../impl/EmsEnergyPriceConfigServiceImpl.java | 45 ++++++++++++++++++- .../impl/FXXDataProcessServiceImpl.java | 11 +++-- .../service/impl/SingleSiteServiceImpl.java | 45 ++++--------------- 4 files changed, 65 insertions(+), 41 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java index 52acc2a..b5eed5a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsEnergyPriceConfigService.java @@ -1,6 +1,9 @@ package com.xzzn.ems.service; +import java.math.BigDecimal; import java.util.List; +import java.util.Map; + import com.xzzn.ems.domain.EmsEnergyPriceConfig; import com.xzzn.ems.domain.vo.EnergyPriceVo; @@ -63,4 +66,6 @@ public interface IEmsEnergyPriceConfigService public void initCurrentMonthPrice(); // 获取指定站点的当月电价 public EnergyPriceVo getCurrentMonthPrice(String siteId); + // 获取指定站点的总收益和当日实时收益 + public Map getDayRevenueMap(String siteId); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java index d8f1704..f6b179c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -1,5 +1,7 @@ package com.xzzn.ems.service.impl; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDate; import java.util.*; import java.util.concurrent.TimeUnit; @@ -9,9 +11,11 @@ import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsDailyEnergyData; import com.xzzn.ems.domain.EmsPriceTimeConfig; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import com.xzzn.ems.domain.vo.EnergyPriceVo; +import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; import com.xzzn.ems.mapper.EmsPriceTimeConfigMapper; import com.xzzn.ems.mapper.EmsSiteSettingMapper; import org.springframework.beans.BeanUtils; @@ -37,7 +41,7 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer @Autowired private RedisCache redisCache; @Autowired - private EmsSiteSettingMapper emsSiteSettingMapper; + private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; /** * 查询电价配置 @@ -263,4 +267,43 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer } return priceVo; } + + @Override + public Map getDayRevenueMap(String siteId) { + Map currentDayRevenue = new HashMap<>(); + // 默认0 + BigDecimal totalRevenue = BigDecimal.ZERO; + BigDecimal dayRevenue = BigDecimal.ZERO; + // 当日实时数据 + String today = DateUtils.getDate(); + EmsDailyEnergyData todayData = emsDailyEnergyDataMapper.getDataByDate(siteId,today); + if (todayData == null) { + Map lastData = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); + if (lastData != null) { + totalRevenue = lastData.get("totalRevenue") == null ? BigDecimal.ZERO : lastData.get("totalRevenue"); + } + } else { + totalRevenue = todayData.getTotalRevenue() == null ? BigDecimal.ZERO : todayData.getTotalRevenue(); + // 获取当月电价 + int currentMonth = LocalDate.now().getMonthValue(); + int currentYear = LocalDate.now().getYear(); + EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId, String.valueOf(currentYear), String.valueOf(currentMonth)); + if (priceConfig != null) { + // 计算各个时段单独收益=(放电量-充电量)*电价,累加即当日实时收益 + BigDecimal peakRevenue = todayData.getPeakDischargeDiff().subtract(todayData.getPeakChargeDiff()) + .multiply(priceConfig.getPeak() == null ? BigDecimal.ZERO : priceConfig.getPeak()); + BigDecimal highRevenue = todayData.getHighDischargeDiff().subtract(todayData.getHighChargeDiff()) + .multiply(priceConfig.getHigh() == null ? BigDecimal.ZERO : priceConfig.getHigh()); + BigDecimal flatRevenue = todayData.getFlatDischargeDiff().subtract(todayData.getFlatChargeDiff()) + .multiply(priceConfig.getFlat() == null ? BigDecimal.ZERO : priceConfig.getFlat()); + BigDecimal valleyRevenue = todayData.getValleyDischargeDiff().subtract(todayData.getValleyChargeDiff()) + .multiply(priceConfig.getValley() == null ? BigDecimal.ZERO : priceConfig.getValley()); + dayRevenue = dayRevenue.add(peakRevenue).add(highRevenue).add(flatRevenue).add(valleyRevenue) + .setScale(4, RoundingMode.HALF_UP); + } + } + currentDayRevenue.put("totalRevenue", totalRevenue); + currentDayRevenue.put("dayRevenue", dayRevenue); + return currentDayRevenue; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index cb1b3d3..a808968 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -82,6 +82,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; @Autowired private IEmsEnergyPriceConfigService emsEnergyPriceConfigService; + @Autowired + private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -907,7 +909,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl energyData.setTotalRevenue(totalRevenue); // 存redis便于下次取用 - String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + SITE_ID; + String today = DateUtils.getDate(); + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + SITE_ID + "_" + today; Map realTimeRevenue = new HashMap<>(); realTimeRevenue.put("totalRevenue", totalRevenue); realTimeRevenue.put("dayRevenue",dayRevenue); @@ -916,10 +919,12 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private Map getRealTimeData(String siteId) { // fx取实时总收益和当天实时收益 - String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId; + String today = DateUtils.getDate(); + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId + "_" + today; Map realTimeRevenue = redisCache.getCacheObject(redisKey); if (realTimeRevenue == null) { - realTimeRevenue = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); + // 查数据库 + realTimeRevenue = iEmsEnergyPriceConfigService.getDayRevenueMap(SITE_ID); if (realTimeRevenue == null) { realTimeRevenue = new HashMap<>(); realTimeRevenue.put("totalRevenue", BigDecimal.ZERO); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 7e9a424..6f09eeb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -10,6 +10,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.mapper.*; +import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import com.xzzn.ems.service.ISingleSiteService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -66,6 +67,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; @Autowired private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; + @Autowired + private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; @Override public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { @@ -82,7 +85,11 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } // 总收入+当日实时收入 - setRevenueInfo(siteMonitorHomeVo,siteId); + Map dayRevenueMap = iEmsEnergyPriceConfigService.getDayRevenueMap(siteId); + siteMonitorHomeVo.setTotalRevenue( + dayRevenueMap.get("totalRevenue") == null ? BigDecimal.ZERO : dayRevenueMap.get("totalRevenue")); + siteMonitorHomeVo.setDayRevenue( + dayRevenueMap.get("dayRevenue") == null ? BigDecimal.ZERO :dayRevenueMap.get("dayRevenue")); // 实时告警数据 名称+状态+告警内容 List siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId); @@ -125,42 +132,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return siteMonitorHomeVo; } - private void setRevenueInfo(SiteMonitorHomeVo siteMonitorHomeVo, String siteId) { - // 默认0 - BigDecimal totalRevenue = BigDecimal.ZERO; - BigDecimal dayRevenue = BigDecimal.ZERO; - // 当日实时数据 - String today = DateUtils.getDate(); - EmsDailyEnergyData todayData = emsDailyEnergyDataMapper.getDataByDate(siteId,today); - if (todayData == null) { - Map lastData = emsDailyEnergyDataMapper.getRealTimeRevenue(siteId); - if (lastData != null) { - totalRevenue = lastData.get("totalRevenue") == null ? BigDecimal.ZERO : lastData.get("totalRevenue"); - } - } else { - totalRevenue = todayData.getTotalRevenue() == null ? BigDecimal.ZERO : todayData.getTotalRevenue(); - // 获取当月电价 - int currentMonth = LocalDate.now().getMonthValue(); - int currentYear = LocalDate.now().getYear(); - EmsEnergyPriceConfig priceConfig = emsEnergyPriceConfigMapper.getConfigListByYearAndMonth(siteId, String.valueOf(currentYear), String.valueOf(currentMonth)); - if (priceConfig != null) { - // 计算各个时段单独收益=(放电量-充电量)*电价,累加即当日实时收益 - BigDecimal peakRevenue = todayData.getPeakDischargeDiff().subtract(todayData.getPeakChargeDiff()) - .multiply(priceConfig.getPeak() == null ? BigDecimal.ZERO : priceConfig.getPeak()); - BigDecimal highRevenue = todayData.getHighDischargeDiff().subtract(todayData.getHighChargeDiff()) - .multiply(priceConfig.getHigh() == null ? BigDecimal.ZERO : priceConfig.getHigh()); - BigDecimal flatRevenue = todayData.getFlatDischargeDiff().subtract(todayData.getFlatChargeDiff()) - .multiply(priceConfig.getFlat() == null ? BigDecimal.ZERO : priceConfig.getFlat()); - BigDecimal valleyRevenue = todayData.getValleyDischargeDiff().subtract(todayData.getValleyChargeDiff()) - .multiply(priceConfig.getValley() == null ? BigDecimal.ZERO : priceConfig.getValley()); - dayRevenue = dayRevenue.add(peakRevenue).add(highRevenue).add(flatRevenue).add(valleyRevenue) - .setScale(4, RoundingMode.HALF_UP); - } - } - siteMonitorHomeVo.setTotalRevenue(totalRevenue); - siteMonitorHomeVo.setDayRevenue(dayRevenue); - } - // 获取单站监控实时运行头部数据 @Override public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId) { -- 2.49.0 From 4ad2cafc5dd079e5ac8efa01f447a52e44862199 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 16 Oct 2025 17:01:35 +0800 Subject: [PATCH 186/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=BB=BC?= =?UTF-8?q?=E5=90=88=E6=9F=A5=E8=AF=A2=E6=98=BE=E7=A4=BA=E6=9B=B2=E7=BA=BF?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E6=9C=80=E5=B0=8F=E5=B9=B3=E5=9D=87=E5=80=BC?= =?UTF-8?q?=E5=92=8C=E5=B7=AE=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsGeneralQueryController.java | 14 ++- .../ems/EmsSiteConfigController.java | 2 +- .../com/xzzn/common/enums/DeviceCategory.java | 2 +- .../ems/domain/vo/DevicePointDataList.java | 50 ++++++++- .../ems/domain/vo/GeneralQueryResponse.java | 14 ++- .../xzzn/ems/domain/vo/PointNameRequest.java | 10 +- .../service/impl/GeneralQueryServiceImpl.java | 101 ++++++++++++------ .../mapper/ems/EmsPointMatchMapper.xml | 3 +- 8 files changed, 152 insertions(+), 44 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java index a0f7a76..107e835 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsGeneralQueryController.java @@ -9,7 +9,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @@ -29,12 +31,15 @@ public class EmsGeneralQueryController extends BaseController{ @GetMapping("/getAllDeviceCategory") public AjaxResult getDeviceCategory() { - // 获取所有枚举的中文信息 - List deviceCategoryName = new ArrayList<>(); + // 获取所有枚举的信息 + List> deviceCategoryList = new ArrayList<>(); for (DeviceCategory category : DeviceCategory.values()) { - deviceCategoryName.add(category.getInfo()); + Map categoryMap = new HashMap<>(); + categoryMap.put("name", category.getInfo()); + categoryMap.put("code", category.getCode()); + deviceCategoryList.add(categoryMap); } - return success(deviceCategoryName); + return success(deviceCategoryList); } /** @@ -56,6 +61,7 @@ public class EmsGeneralQueryController extends BaseController{ try { result = iGeneralQueryService.getPointValueList(request); } catch (Exception e) { + logger.error("",e); return error("报错请重试!"); } return success(result); 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 33beaa9..fc37793 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 @@ -142,7 +142,7 @@ public class EmsSiteConfigController extends BaseController{ } /** - * 单个站点单个设备点位查询 + * 单个站点单个设备点位查询-点位清单 */ @GetMapping("/getDevicePointList") public TableDataInfo getDevicePointList(@Validated PointDataRequest request) diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java index 4be8b3e..1b7c55f 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java @@ -21,7 +21,7 @@ public enum DeviceCategory COOLING("COOLING", "冷却", null), DH("DH", "动环", null), XF("XF", "消防", null), - BATTERY_GROUP("BATTERY_GROUP", "电池组", null),; + BATTERY_GROUP("BATTERY_GROUP", "电池组", null); private final String code; private final String info; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java index 90526b5..3f768f2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java @@ -1,5 +1,6 @@ package com.xzzn.ems.domain.vo; +import java.math.BigDecimal; import java.util.List; /** @@ -13,10 +14,25 @@ public class DevicePointDataList private String parentDeviceId; // 该设备点位数据list private List pointValueList; + // 最大值 + private BigDecimal maxValue; + // 最小值 + private BigDecimal minValue; + // 平均值(保留4位小数) + private BigDecimal avgValue; + // 差值(max - min) + private BigDecimal diffValue; - public DevicePointDataList(String deviceId, List pointValueList) { + public DevicePointDataList(String deviceId, List pointValueList,String parentDeviceId, + BigDecimal maxValue, BigDecimal minValue, + BigDecimal avgValue, BigDecimal diffValue) { this.deviceId = deviceId; this.pointValueList = pointValueList; + this.parentDeviceId = parentDeviceId; + this.maxValue = maxValue; + this.minValue = minValue; + this.avgValue = avgValue; + this.diffValue = diffValue; } public DevicePointDataList() { @@ -46,4 +62,36 @@ public class DevicePointDataList public void setParentDeviceId(String parentDeviceId) { this.parentDeviceId = parentDeviceId; } + + public BigDecimal getMaxValue() { + return maxValue; + } + + public void setMaxValue(BigDecimal maxValue) { + this.maxValue = maxValue; + } + + public BigDecimal getMinValue() { + return minValue; + } + + public void setMinValue(BigDecimal minValue) { + this.minValue = minValue; + } + + public BigDecimal getAvgValue() { + return avgValue; + } + + public void setAvgValue(BigDecimal avgValue) { + this.avgValue = avgValue; + } + + public BigDecimal getDiffValue() { + return diffValue; + } + + public void setDiffValue(BigDecimal diffValue) { + this.diffValue = diffValue; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java index a4e8248..1571ac8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java @@ -14,9 +14,13 @@ public class GeneralQueryResponse { // 设备数据 private List deviceList; - public GeneralQueryResponse(String siteId, List deviceList) { + // 点位数据类型,1-瞬时值,2-累计值 + private Long dataType; + + public GeneralQueryResponse(String siteId, List deviceList, Long dataType) { this.siteId = siteId; this.deviceList = deviceList; + this.dataType = dataType; } public GeneralQueryResponse() { @@ -38,4 +42,12 @@ public class GeneralQueryResponse { public void setDeviceList(List deviceList) { this.deviceList = deviceList; } + + public Long getDataType() { + return dataType; + } + + public void setDataType(Long dataType) { + this.dataType = dataType; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java index f2eaa6f..8552c37 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointNameRequest.java @@ -11,7 +11,7 @@ public class PointNameRequest { private List siteIds; - private String categoryName; + private String deviceCategory; private String pointName; @@ -34,12 +34,12 @@ public class PointNameRequest { this.siteIds = siteIds; } - public String getCategoryName() { - return categoryName; + public String getDeviceCategory() { + return deviceCategory; } - public void setCategoryName(String categoryName) { - this.categoryName = categoryName; + public void setDeviceCategory(String deviceCategory) { + this.deviceCategory = deviceCategory; } public String getPointName() { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index cb1724e..d424da4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -11,6 +11,7 @@ import com.xzzn.ems.service.IGeneralQueryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -42,8 +43,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService return Collections.emptyList(); } - String categoryName = request.getCategoryName(); - String deviceCategory = DeviceCategory.getCodeByInfo(categoryName); + String deviceCategory = request.getDeviceCategory(); if (deviceCategory == null) { return Collections.emptyList(); } @@ -83,8 +83,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService List querySiteIds = new ArrayList<>(); List siteIds = request.getSiteIds(); - String categoryName = request.getCategoryName(); - String deviceCategory = DeviceCategory.getCodeByInfo(categoryName); + String deviceCategory = request.getDeviceCategory(); // 根据入参获取点位对应的表和字段 List matchInfo = emsPointMatchMapper.getMatchInfo(siteIds,deviceCategory,request.getPointName()); if (matchInfo == null || matchInfo.size() == 0) { @@ -108,13 +107,13 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService // 不同的site_id根据设备类型和字段,默认取第一个匹配到的表和表字段只会有一个, String tableName = matchInfo.get(0).getMatchTable(); String tableField = matchInfo.get(0).getMatchField(); - + Long dataType = matchInfo.get(0).getDataType(); if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { // 单体电池数据特殊处理 - result = generalQueryBatteryData(querySiteIds,tableName,tableField,request,deviceCategory); + result = generalQueryBatteryData(querySiteIds,tableName,tableField,request,deviceCategory,dataType); } else { // 其他设备数据 - result = generalQueryCommonData(querySiteIds,tableName,tableField,request,deviceCategory); + result = generalQueryCommonData(querySiteIds,tableName,tableField,request,deviceCategory,dataType); } } catch (ParseException e) { throw new RuntimeException(e); @@ -122,9 +121,9 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService return result; } - private List generalQueryCommonData(List querySiteIds,String tableName, + private List generalQueryCommonData(List querySiteIds, String tableName, String tableField, PointNameRequest request, - String deviceCategory) throws ParseException { + String deviceCategory, Long dataType) throws ParseException { List result = new ArrayList<>(); List dataVoList = new ArrayList<>(); @@ -146,14 +145,14 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService dataVoList = emsPointMatchMapper.getCommonPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,deviceId); } - // 数据转换 - result = convertCommonToResultList(dataVoList); + // 数据转换+计算曲线数据最大最小平均和差值 + result = convertCommonToResultList(dataVoList, dataType); return result; } - private List generalQueryBatteryData(List querySiteIds,String tableName, + private List generalQueryBatteryData(List querySiteIds, String tableName, String tableField, PointNameRequest request, - String deviceCategory) throws ParseException { + String deviceCategory, Long dataType) throws ParseException { List result = new ArrayList<>(); List dataVoList = new ArrayList<>(); @@ -179,11 +178,11 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService dataVoList = emsPointMatchMapper.getBatteryPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap,clusterDeviceId); } // 数据转换 - result = convertBatteryToResultList(dataVoList); + result = convertBatteryToResultList(dataVoList,dataType); return result; } - private List convertBatteryToResultList(List dataVoList) { + private List convertBatteryToResultList(List dataVoList, Long dataType) { // 先按siteId分组 return dataVoList.stream() .collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId)) @@ -218,12 +217,12 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService }) .collect(Collectors.toList()); + // 4. 计算最大最小平均值 + Stats stats = clacStats(pointValueList); + // 4. 构建DeviceItem - DevicePointDataList deviceItem = new DevicePointDataList(); - deviceItem.setDeviceId(deviceId); - deviceItem.setParentDeviceId(parentDeviceId); - deviceItem.setPointValueList(pointValueList); - return deviceItem; + return new DevicePointDataList(deviceId, pointValueList,parentDeviceId, + stats.max, stats.min,stats.avg,stats.diff); })// 关键排序步骤:先按deviceId升序,再按parentDeviceId升序 .sorted( Comparator.comparing(DevicePointDataList::getDeviceId) // 第一排序键:deviceId @@ -232,15 +231,12 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService .collect(Collectors.toList()); // 5. 构建SiteData - GeneralQueryResponse site = new GeneralQueryResponse(); - site.setSiteId(siteId); - site.setDeviceList(deviceList); - return site; + return new GeneralQueryResponse(siteId, deviceList, dataType); }) .collect(Collectors.toList()); } - private List convertCommonToResultList(List dataVoList) { + private List convertCommonToResultList(List dataVoList, Long dataType) { // 数据转换: 先按siteId分组,再按deviceId分组 return dataVoList.stream() // 第一层分组:按siteId分组,得到 @@ -254,18 +250,46 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService List deviceList = siteAllData.stream() .collect(Collectors.groupingBy(GeneralQueryDataVo::getDeviceId)) .entrySet().stream() - .map(deviceEntry -> new DevicePointDataList( - deviceEntry.getKey(), - deviceEntry.getValue() - )) + .map(deviceEntry -> { + String deviceId = deviceEntry.getKey(); + List deviceDataList = deviceEntry.getValue(); + + // 计算当前设备数据的统计值(最大,最小,平均,差值) + Stats stats = clacStats(deviceDataList); + + return new DevicePointDataList(deviceId, deviceDataList,null, + stats.max, stats.min,stats.avg,stats.diff); + }) .collect(Collectors.toList()); - return new GeneralQueryResponse(siteId, deviceList); + return new GeneralQueryResponse(siteId, deviceList, dataType); }) .collect(Collectors.toList()); } + private Stats clacStats(List deviceDataList) { + // 提取有效数值(过滤null) + List values = deviceDataList.stream() + .map(vo -> (BigDecimal) vo.getPointValue()) + .filter(value -> value != null) // 过滤null值 + .collect(Collectors.toList()); + if (values.isEmpty()) { + return new Stats(null, null, null, null); + } + + // 计算最大最小值 + BigDecimal maxValue = values.stream().max(BigDecimal::compareTo).get(); + BigDecimal minValue = values.stream().min(BigDecimal::compareTo).get(); + // 计算平均值,四舍五入保留4为小数 + BigDecimal sum = values.stream().reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal avgValue = sum.divide(BigDecimal.valueOf(values.size()), 4, BigDecimal.ROUND_HALF_UP); + // 增量数据,计算差值 + BigDecimal diff = maxValue.subtract(minValue); + + return new Stats(maxValue,minValue,avgValue,diff); + } + private void dealDataTime(PointNameRequest request) { String startDate = request.getStartDate(); String endDate = request.getEndDate(); @@ -441,4 +465,21 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService return minutes; } + + /** + * 内部辅助类:存储统计结果 + */ + private static class Stats { + private final BigDecimal max; + private final BigDecimal min; + private final BigDecimal avg; + private final BigDecimal diff; + + public Stats(BigDecimal max, BigDecimal min, BigDecimal avg, BigDecimal diff) { + this.max = max; + this.min = min; + this.avg = avg; + this.diff = diff; + } + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index f29c14d..4a0f96e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -147,7 +147,8 @@ t.match_table as matchTable, t.match_field as matchField, t.device_category as deviceCategory, - t.point_name as pointName + t.point_name as pointName, + t.data_type as dataType from ems_point_match t where 1=1 -- 2.49.0 From a338c921d339ca7c873974e5db5d24cb88c6a5e3 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 21 Oct 2025 12:39:14 +0800 Subject: [PATCH 187/336] =?UTF-8?q?=E7=BB=BC=E5=90=88=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/GeneralQueryServiceImpl.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index d424da4..c8b53ab 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -271,7 +271,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService private Stats clacStats(List deviceDataList) { // 提取有效数值(过滤null) List values = deviceDataList.stream() - .map(vo -> (BigDecimal) vo.getPointValue()) + .map(vo -> convertToBigDecimal(vo.getPointValue())) .filter(value -> value != null) // 过滤null值 .collect(Collectors.toList()); if (values.isEmpty()) { @@ -290,6 +290,27 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService return new Stats(maxValue,minValue,avgValue,diff); } + private BigDecimal convertToBigDecimal(Object pointValue) { + if (pointValue == null) { + return null; + } + // 根据实际存储的数值类型,依次判断并转换 + if (pointValue instanceof BigDecimal) { + return (BigDecimal) pointValue; + } else if (pointValue instanceof Integer) { + return new BigDecimal ((Integer) pointValue); + } else if (pointValue instanceof Long) { + return new BigDecimal ((Long) pointValue); + } else if (pointValue instanceof Double) { + return BigDecimal.valueOf ((Double) pointValue); // 避免 Double 精度丢失 + } else if (pointValue instanceof Float) { + return BigDecimal.valueOf ((Float) pointValue); + } else { + // 非数值类型(如 String),可根据业务需求处理(此处返回 null) + return null; + } + } + private void dealDataTime(PointNameRequest request) { String startDate = request.getStartDate(); String endDate = request.getEndDate(); @@ -354,7 +375,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService data.setValueDate(minute); data.setSiteId(siteId); data.setDeviceId(deviceId); - data.setPointValue(lastValue==null? 0 : lastValue); // 用上一分钟值填充 + data.setPointValue(lastValue==null? BigDecimal.ZERO : lastValue); // 用上一分钟值填充 } else { lastValue = data.getPointValue(); // 更新最新值 } -- 2.49.0 From e1fb6e30acfe1e64c9e877645e19d490ce76f472 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 21 Oct 2025 13:55:06 +0800 Subject: [PATCH 188/336] =?UTF-8?q?=E6=B6=88=E9=98=B2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AD=98=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 5 + .../xzzn/ems/domain/EmsMqttTopicConfig.java | 71 ++++++++ .../java/com/xzzn/ems/domain/EmsXfData.java | 151 ++++++++++++++++++ .../com/xzzn/ems/mapper/EmsXfDataMapper.java | 61 +++++++ .../impl/DDSDataProcessServiceImpl.java | 23 ++- .../resources/mapper/ems/EmsXfDataMapper.xml | 106 ++++++++++++ 6 files changed, 415 insertions(+), 2 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsXfData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsXfDataMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsXfDataMapper.xml diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 09e84e5..37d7394 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -42,6 +42,11 @@ public class RedisKeyConstants */ public static final String DH = "DH_"; + /** + * 消防数据 redis key + */ + public static final String XF = "XF_"; + /** * 电池组 redis key */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java new file mode 100644 index 0000000..ec16a32 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java @@ -0,0 +1,71 @@ +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; + +/** + * 站点topic配置对象 ems_mqtt_topic_config + * + * @author xzzn + * @date 2025-10-21 + */ +public class EmsMqttTopicConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 订阅topic */ + @Excel(name = "订阅topic") + private String mqttTopic; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public void setMqttTopic(String mqttTopic) + { + this.mqttTopic = mqttTopic; + } + + public String getMqttTopic() + { + return mqttTopic; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("siteId", getSiteId()) + .append("mqttTopic", getMqttTopic()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsXfData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsXfData.java new file mode 100644 index 0000000..0d784aa --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsXfData.java @@ -0,0 +1,151 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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_xf_data + * + * @author xzzn + * @date 2025-10-21 + */ +public class EmsXfData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataTimestamp; + + /** 主电源备用电池状态 */ + @Excel(name = "主电源备用电池状态") + private BigDecimal dczt; + + /** 手自动状态延时状态 */ + @Excel(name = "手自动状态延时状态") + private BigDecimal yszt; + + /** 启动喷洒气体喷洒状态 */ + @Excel(name = "启动喷洒气体喷洒状态") + private BigDecimal pszt; + + /** 压力开关状态电磁阀状态 */ + @Excel(name = "压力开关状态电磁阀状态") + private BigDecimal dcfzt; + + /** 站点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 setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + public void setDczt(BigDecimal dczt) + { + this.dczt = dczt; + } + + public BigDecimal getDczt() + { + return dczt; + } + + public void setYszt(BigDecimal yszt) + { + this.yszt = yszt; + } + + public BigDecimal getYszt() + { + return yszt; + } + + public void setPszt(BigDecimal pszt) + { + this.pszt = pszt; + } + + public BigDecimal getPszt() + { + return pszt; + } + + public void setDcfzt(BigDecimal dcfzt) + { + this.dcfzt = dcfzt; + } + + public BigDecimal getDcfzt() + { + return dcfzt; + } + + 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("dataTimestamp", getDataTimestamp()) + .append("dczt", getDczt()) + .append("yszt", getYszt()) + .append("pszt", getPszt()) + .append("dcfzt", getDcfzt()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsXfDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsXfDataMapper.java new file mode 100644 index 0000000..2771b2e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsXfDataMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsXfData; + +/** + * 消防数据Mapper接口 + * + * @author xzzn + * @date 2025-10-21 + */ +public interface EmsXfDataMapper +{ + /** + * 查询消防数据 + * + * @param id 消防数据主键 + * @return 消防数据 + */ + public EmsXfData selectEmsXfDataById(Long id); + + /** + * 查询消防数据列表 + * + * @param emsXfData 消防数据 + * @return 消防数据集合 + */ + public List selectEmsXfDataList(EmsXfData emsXfData); + + /** + * 新增消防数据 + * + * @param emsXfData 消防数据 + * @return 结果 + */ + public int insertEmsXfData(EmsXfData emsXfData); + + /** + * 修改消防数据 + * + * @param emsXfData 消防数据 + * @return 结果 + */ + public int updateEmsXfData(EmsXfData emsXfData); + + /** + * 删除消防数据 + * + * @param id 消防数据主键 + * @return 结果 + */ + public int deleteEmsXfDataById(Long id); + + /** + * 批量删除消防数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsXfDataByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 181368e..80744ee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -84,6 +84,8 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; @Autowired private IEmsDeviceSettingService iEmsDeviceSettingService; + @Autowired + private EmsXfDataMapper emsXfDataMapper; public DDSDataProcessServiceImpl(ObjectMapper objectMapper) { super(objectMapper); @@ -127,7 +129,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } else if (deviceId.contains("METE0")) { meteBranchDataProcess(deviceId, jsonData); } else if (deviceId.contains("XF")) { - meteXFProcess(deviceId, jsonData); + meteXFProcess(deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains("DH")) { dhDataProcess(deviceId, jsonData); } @@ -155,12 +157,29 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.DH + SITE_ID + "_" +deviceId, dhData); } - private void meteXFProcess(String deviceId, String dataJson) { + private void meteXFProcess(String deviceId, String dataJson, Date dataUpdateTime) { //消防 Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); // 暂时只更新设备表的设备状态 ZDYBYDCZT-主电源备用电池状态 + // 数据存表 + EmsXfData xfData = new EmsXfData(); + xfData.setDataTimestamp(dataUpdateTime); + xfData.setDcfzt(StringUtils.getBigDecimal(obj.get("YLKGDCFZT"))); + xfData.setDczt(StringUtils.getBigDecimal(obj.get("ZDYBYDCZT"))); + xfData.setPszt(StringUtils.getBigDecimal(obj.get("QDQTPSZT"))); + xfData.setYszt(StringUtils.getBigDecimal(obj.get("SZDYSZT"))); + + xfData.setCreateBy("system"); + xfData.setCreateTime(DateUtils.getNowDate()); + xfData.setUpdateBy("system"); + xfData.setUpdateTime(DateUtils.getNowDate()); + xfData.setSiteId(SITE_ID); + xfData.setDeviceId(deviceId); + emsXfDataMapper.insertEmsXfData(xfData); + + redisCache.setCacheObject(RedisKeyConstants.XF + SITE_ID + "_" +deviceId, xfData); // 状态枚举还没有提供 EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, SITE_ID); emsDevicesSetting.setCommunicationStatus(StringUtils.getString(obj.get("ZDYBYDCZT"))); diff --git a/ems-system/src/main/resources/mapper/ems/EmsXfDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsXfDataMapper.xml new file mode 100644 index 0000000..45bcf36 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsXfDataMapper.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + select id, data_timestamp, dczt, yszt, pszt, dcfzt, create_by, create_time, update_by, update_time, remark, site_id, device_id from ems_xf_data + + + + + + + + insert into ems_xf_data + + data_timestamp, + dczt, + yszt, + pszt, + dcfzt, + create_by, + create_time, + update_by, + update_time, + remark, + site_id, + device_id, + + + #{dataTimestamp}, + #{dczt}, + #{yszt}, + #{pszt}, + #{dcfzt}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{siteId}, + #{deviceId}, + + + + + update ems_xf_data + + data_timestamp = #{dataTimestamp}, + dczt = #{dczt}, + yszt = #{yszt}, + pszt = #{pszt}, + dcfzt = #{dcfzt}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + site_id = #{siteId}, + device_id = #{deviceId}, + + where id = #{id} + + + + delete from ems_xf_data where id = #{id} + + + + delete from ems_xf_data where id in + + #{id} + + + \ No newline at end of file -- 2.49.0 From 76b30c715c9e83dc9cb08ecfe21299a4e30602a6 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 21 Oct 2025 15:12:14 +0800 Subject: [PATCH 189/336] =?UTF-8?q?0918=E4=BC=98=E5=8C=96-=E7=BB=BC?= =?UTF-8?q?=E5=90=88=E6=9F=A5=E8=AF=A2=E6=9C=80=E5=A4=A7=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/DevicePointDataList.java | 27 ++++++++- .../service/impl/GeneralQueryServiceImpl.java | 56 +++++++++++++------ 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java index 3f768f2..ac2f356 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java @@ -14,10 +14,12 @@ public class DevicePointDataList private String parentDeviceId; // 该设备点位数据list private List pointValueList; - // 最大值 + // 最大值&时间 private BigDecimal maxValue; - // 最小值 + private String maxDate; + // 最小值&时间 private BigDecimal minValue; + private String minDate; // 平均值(保留4位小数) private BigDecimal avgValue; // 差值(max - min) @@ -25,7 +27,8 @@ public class DevicePointDataList public DevicePointDataList(String deviceId, List pointValueList,String parentDeviceId, BigDecimal maxValue, BigDecimal minValue, - BigDecimal avgValue, BigDecimal diffValue) { + BigDecimal avgValue, BigDecimal diffValue, + String maxDate, String minDate) { this.deviceId = deviceId; this.pointValueList = pointValueList; this.parentDeviceId = parentDeviceId; @@ -33,12 +36,30 @@ public class DevicePointDataList this.minValue = minValue; this.avgValue = avgValue; this.diffValue = diffValue; + this.maxDate = maxDate; + this.minDate = minDate; } public DevicePointDataList() { } + public String getMaxDate() { + return maxDate; + } + + public void setMaxDate(String maxDate) { + this.maxDate = maxDate; + } + + public String getMinDate() { + return minDate; + } + + public void setMinDate(String minDate) { + this.minDate = minDate; + } + public String getDeviceId() { return deviceId; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index c8b53ab..6d99ba0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -222,7 +222,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService // 4. 构建DeviceItem return new DevicePointDataList(deviceId, pointValueList,parentDeviceId, - stats.max, stats.min,stats.avg,stats.diff); + stats.max, stats.min,stats.avg,stats.diff,stats.maxDate,stats.minDate); })// 关键排序步骤:先按deviceId升序,再按parentDeviceId升序 .sorted( Comparator.comparing(DevicePointDataList::getDeviceId) // 第一排序键:deviceId @@ -258,7 +258,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService Stats stats = clacStats(deviceDataList); return new DevicePointDataList(deviceId, deviceDataList,null, - stats.max, stats.min,stats.avg,stats.diff); + stats.max, stats.min,stats.avg,stats.diff,stats.maxDate,stats.minDate); }) .collect(Collectors.toList()); @@ -269,25 +269,30 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService } private Stats clacStats(List deviceDataList) { - // 提取有效数值(过滤null) - List values = deviceDataList.stream() - .map(vo -> convertToBigDecimal(vo.getPointValue())) - .filter(value -> value != null) // 过滤null值 + // 转换并过滤数据,封装数值和对应的时间 + List validPairs = deviceDataList.stream() + .map(vo -> { + BigDecimal value = convertToBigDecimal(vo.getPointValue()); + return value != null ? + new ValueTimePair(value, vo.getValueDate()) : + null; + }) + .filter(pair -> pair != null) // 过滤无效数据 .collect(Collectors.toList()); - if (values.isEmpty()) { - return new Stats(null, null, null, null); + + if (validPairs.isEmpty()) { + return new Stats(null, null, null, null, null, null); } - // 计算最大最小值 - BigDecimal maxValue = values.stream().max(BigDecimal::compareTo).get(); - BigDecimal minValue = values.stream().min(BigDecimal::compareTo).get(); + Optional maxPair = validPairs.stream().max((p1, p2) -> p1.value.compareTo(p2.value)); + Optional minPair = validPairs.stream().min((p1, p2) -> p1.value.compareTo(p2.value)); // 计算平均值,四舍五入保留4为小数 - BigDecimal sum = values.stream().reduce(BigDecimal.ZERO, BigDecimal::add); - BigDecimal avgValue = sum.divide(BigDecimal.valueOf(values.size()), 4, BigDecimal.ROUND_HALF_UP); + BigDecimal sum = validPairs.stream() .map(pair -> pair.value).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal avgValue = sum.divide(BigDecimal.valueOf(validPairs.size()), 4, BigDecimal.ROUND_HALF_UP); // 增量数据,计算差值 - BigDecimal diff = maxValue.subtract(minValue); + BigDecimal diff = maxPair.get().value.subtract(minPair.get().value); - return new Stats(maxValue,minValue,avgValue,diff); + return new Stats(maxPair.get().value,minPair.get().value,avgValue,diff,maxPair.get().time,minPair.get().time); } private BigDecimal convertToBigDecimal(Object pointValue) { @@ -492,15 +497,34 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService */ private static class Stats { private final BigDecimal max; + private final String maxDate; private final BigDecimal min; + private final String minDate; private final BigDecimal avg; private final BigDecimal diff; - public Stats(BigDecimal max, BigDecimal min, BigDecimal avg, BigDecimal diff) { + public Stats(BigDecimal max, BigDecimal min, BigDecimal avg, BigDecimal diff, + String maxDate, String minDate) { this.max = max; + this.maxDate = maxDate; this.min = min; + this.minDate = minDate; this.avg = avg; this.diff = diff; } } + + /** + * 辅助类:关联数值和对应的时间 + */ + private static class ValueTimePair { + final BigDecimal value; + final String time; + + ValueTimePair(BigDecimal value, String time) { + this.value = value; + this.time = time; + } + } + } -- 2.49.0 From b776f6ff7664e6f5db6d88e2a737f8dd0d796c7a Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 21 Oct 2025 15:25:23 +0800 Subject: [PATCH 190/336] =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E9=87=8C=E9=9D=A2=E7=9A=84=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=88=97=E6=94=B9=E6=88=90=E6=98=BE=E7=A4=BA=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=B1=BB=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/enums/DeviceCategory.java | 9 +++++++++ .../java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java | 10 ++++++++++ .../com/xzzn/ems/service/impl/EmsSiteServiceImpl.java | 2 ++ 3 files changed, 21 insertions(+) diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java index 1b7c55f..c90aca1 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceCategory.java @@ -73,4 +73,13 @@ public enum DeviceCategory } return null; } + + public static String getInfoByCode(String code) { + for (DeviceCategory category : DeviceCategory.values()) { + if (category.code.equals(code)) { + return category.info; + } + } + return null; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java index 5ddddf8..ba37363 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -27,6 +27,16 @@ public class SiteDeviceListVo { private String parentId; /** 单体电池个数-仅stack设备下有 */ private int batteryNum; + /** 设备类型名称 */ + private String categoryName; + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } public String getSiteId() { return siteId; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index 23844e0..9819c8c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -93,6 +93,8 @@ public class EmsSiteServiceImpl implements IEmsSiteService List batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); siteDeviceListVo.setBatteryNum(batteryDataList == null ? 0 : batteryDataList.size()); } + String categoryName = DeviceCategory.getInfoByCode(deviceCategory); + siteDeviceListVo.setCategoryName(categoryName); } return resultData; } -- 2.49.0 From 4a0075b60681abb95b6600586c11a5f08b2957a4 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 22 Oct 2025 17:21:43 +0800 Subject: [PATCH 191/336] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8C=89=E8=AE=BE=E5=A4=87=E5=AD=98=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 6 +- .../xzzn/ems/domain/EmsClusterAlarmData.java | 1410 +++++++++++++++ .../xzzn/ems/domain/EmsCoolingAlarmData.java | 795 +++++++++ .../com/xzzn/ems/domain/EmsPcsAlarmData.java | 1545 +++++++++++++++++ .../xzzn/ems/domain/EmsStackAlarmData.java | 1545 +++++++++++++++++ .../ems/mapper/EmsClusterAlarmDataMapper.java | 61 + .../ems/mapper/EmsCoolingAlarmDataMapper.java | 61 + .../ems/mapper/EmsPcsAlarmDataMapper.java | 61 + .../ems/mapper/EmsStackAlarmDataMapper.java | 61 + .../service/IFXXAlarmDataProcessService.java | 6 + .../ems/service/IFXXDataProcessService.java | 2 - .../impl/FXXAlarmDataProcessServiceImpl.java | 634 +++++++ .../impl/FXXDataProcessServiceImpl.java | 149 +- .../mapper/ems/EmsClusterAlarmDataMapper.xml | 526 ++++++ .../mapper/ems/EmsCoolingAlarmDataMapper.xml | 321 ++++ .../mapper/ems/EmsPcsAlarmDataMapper.xml | 571 ++++++ .../mapper/ems/EmsStackAlarmDataMapper.xml | 571 ++++++ 17 files changed, 8175 insertions(+), 150 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsClusterAlarmData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingAlarmData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsAlarmData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsStackAlarmData.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsClusterAlarmDataMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingAlarmDataMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsAlarmDataMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsStackAlarmDataMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IFXXAlarmDataProcessService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/FXXAlarmDataProcessServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsClusterAlarmDataMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsCoolingAlarmDataMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsPcsAlarmDataMapper.xml create mode 100644 ems-system/src/main/resources/mapper/ems/EmsStackAlarmDataMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 6fac929..a68f394 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -2,6 +2,7 @@ package com.xzzn.web.controller.ems; import com.xzzn.ems.service.IDDSDataProcessService; import com.xzzn.ems.service.IEmsMqttMessageService; +import com.xzzn.ems.service.IFXXAlarmDataProcessService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; @@ -35,6 +36,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IDDSDataProcessService dDSDataProcessService; + + @Autowired + private IFXXAlarmDataProcessService fXXAlarmDataProcessService; @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { this.mqttLifecycleManager = mqttLifecycleManager; @@ -96,7 +100,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { try { // 业务处理逻辑 if (topic.startsWith("021_FXX")) { - fXXDataProcessService.handleFxAlarmData(payload); + fXXAlarmDataProcessService.handleFxAlarmData(payload); } emsMqttMessageService.insertMqttOriginalMessage(topic,payload); diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsClusterAlarmData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsClusterAlarmData.java new file mode 100644 index 0000000..d550741 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsClusterAlarmData.java @@ -0,0 +1,1410 @@ +package com.xzzn.ems.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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; + +/** + * bmsc告警数据对象 ems_cluster_alarm_data + * + * @author xzzn + * @date 2025-10-22 + */ +public class EmsClusterAlarmData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 记录唯一ID */ + private Long id; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date dataTimestamp; + + /** 站点ID */ + @Excel(name = "站点ID") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 簇1主控通讯失联(0=正常,1=异常) */ + @Excel(name = "簇1主控通讯失联", readConverterExp = "0==正常,1=异常") + private Integer c1zktxsl; + + /** 簇1端电压欠压轻度告警 */ + @Excel(name = "簇1端电压欠压轻度告警") + private Integer c1ddyqyqdgj; + + /** 簇1端电压欠压中度告警 */ + @Excel(name = "簇1端电压欠压中度告警") + private Integer c1ddyqyzdgj; + + /** 簇1端电压欠压重度告警 */ + @Excel(name = "簇1端电压欠压重度告警") + private Integer c1ddyqyzzdgj; + + /** 簇1端电压过压轻度告警 */ + @Excel(name = "簇1端电压过压轻度告警") + private Integer c1ddygyqdgj; + + /** 簇1端电压过压中度告警 */ + @Excel(name = "簇1端电压过压中度告警") + private Integer c1ddygyzdgj; + + /** 簇1端电压过压重度告警 */ + @Excel(name = "簇1端电压过压重度告警") + private Integer c1ddygyzzdgj; + + /** 簇1端电流轻度告警 */ + @Excel(name = "簇1端电流轻度告警") + private Integer c1ddlqdgj; + + /** 簇1端电流中度告警 */ + @Excel(name = "簇1端电流中度告警") + private Integer c1ddlzdgj; + + /** 簇1端电流重度告警 */ + @Excel(name = "簇1端电流重度告警") + private Integer c1ddlzzdgj; + + /** 簇1单体欠压轻度告警 */ + @Excel(name = "簇1单体欠压轻度告警") + private Integer c1dtqyqdgj; + + /** 簇1单体欠压中度告警 */ + @Excel(name = "簇1单体欠压中度告警") + private Integer c1dtqyzdgj; + + /** 簇1单体欠压重度告警 */ + @Excel(name = "簇1单体欠压重度告警") + private Integer c1dtqyzzdgj; + + /** 簇1单体过压轻度告警 */ + @Excel(name = "簇1单体过压轻度告警") + private Integer c1dtgyqdgj; + + /** 簇1单体过压中度告警 */ + @Excel(name = "簇1单体过压中度告警") + private Integer c1dtgyzdgj; + + /** 簇1单体过压重度告警 */ + @Excel(name = "簇1单体过压重度告警") + private Integer c1dtgyzzdgj; + + /** 簇1单体欠温轻度告警 */ + @Excel(name = "簇1单体欠温轻度告警") + private Integer c1dtqwqdgj; + + /** 簇1单体欠温中度告警 */ + @Excel(name = "簇1单体欠温中度告警") + private Integer c1dtqwzdgj; + + /** 簇1单体欠温重度告警 */ + @Excel(name = "簇1单体欠温重度告警") + private Integer c1dtqwzzdgj; + + /** 簇1单体过温轻度告警 */ + @Excel(name = "簇1单体过温轻度告警") + private Integer c1dtgwqdgj; + + /** 簇1单体过温中度告警 */ + @Excel(name = "簇1单体过温中度告警") + private Integer c1dtgwzdgj; + + /** 簇1单体过温重度告警 */ + @Excel(name = "簇1单体过温重度告警") + private Integer c1dtgwzzdgj; + + /** 簇1单体SOC低轻度告警 */ + @Excel(name = "簇1单体SOC低轻度告警") + private Integer c1socdqdgj; + + /** 簇1单体SOC低中度告警 */ + @Excel(name = "簇1单体SOC低中度告警") + private Integer c1socdzdgj; + + /** 簇1单体SOC低重度告警 */ + @Excel(name = "簇1单体SOC低重度告警") + private Integer c1socdzzdgj; + + /** 簇1单体SOC高轻度告警 */ + @Excel(name = "簇1单体SOC高轻度告警") + private Integer c1socgqdgj; + + /** 簇1单体SOC高中度告警 */ + @Excel(name = "簇1单体SOC高中度告警") + private Integer c1socgzdgj; + + /** 簇1单体SOC高重度告警 */ + @Excel(name = "簇1单体SOC高重度告警") + private Integer c1socgzzdgj; + + /** 簇1单体SOH低轻度告警 */ + @Excel(name = "簇1单体SOH低轻度告警") + private Integer c1sohdqdgj; + + /** 簇1单体SOH低中度告警 */ + @Excel(name = "簇1单体SOH低中度告警") + private Integer c1sohdzdgj; + + /** 簇1单体SOH低重度告警 */ + @Excel(name = "簇1单体SOH低重度告警") + private Integer c1sohdzzdgj; + + /** 簇1单体压差轻度告警 */ + @Excel(name = "簇1单体压差轻度告警") + private Integer c1dtycqdgj; + + /** 簇1单体压差中度告警 */ + @Excel(name = "簇1单体压差中度告警") + private Integer c1dtyczdgj; + + /** 簇1单体压差重度告警 */ + @Excel(name = "簇1单体压差重度告警") + private Integer c1dtyczzdgj; + + /** 簇1单体温差轻度告警 */ + @Excel(name = "簇1单体温差轻度告警") + private Integer c1dtwcqdgj; + + /** 簇1单体温差中度告警 */ + @Excel(name = "簇1单体温差中度告警") + private Integer c1dtwczdgj; + + /** 簇1单体温差重度告警 */ + @Excel(name = "簇1单体温差重度告警") + private Integer c1dtwczzdgj; + + /** 簇1从控1通讯失联 */ + @Excel(name = "簇1从控1通讯失联") + private Integer c1ck1txsl; + + /** 簇1从控2通讯失联 */ + @Excel(name = "簇1从控2通讯失联") + private Integer c1ck2txsl; + + /** 簇1从控3通讯失联 */ + @Excel(name = "簇1从控3通讯失联") + private Integer c1ck3txsl; + + /** 簇1从控4通讯失联 */ + @Excel(name = "簇1从控4通讯失联") + private Integer c1ck4txsl; + + /** 簇1从控5通讯失联 */ + @Excel(name = "簇1从控5通讯失联") + private Integer c1ck5txsl; + + /** 簇1从控6通讯失联 */ + @Excel(name = "簇1从控6通讯失联") + private Integer c1ck6txsl; + + /** 簇1从控7通讯失联 */ + @Excel(name = "簇1从控7通讯失联") + private Integer c1ck7txsl; + + /** 簇1从控8通讯失联 */ + @Excel(name = "簇1从控8通讯失联") + private Integer c1ck8txsl; + + /** 簇1从控9通讯失联 */ + @Excel(name = "簇1从控9通讯失联") + private Integer c1ck9txsl; + + /** 簇1从控10通讯失联 */ + @Excel(name = "簇1从控10通讯失联") + private Integer c1ck10txsl; + + /** 簇1从控11通讯失联 */ + @Excel(name = "簇1从控11通讯失联") + private Integer c1ck11txsl; + + /** 簇1从控12通讯失联 */ + @Excel(name = "簇1从控12通讯失联") + private Integer c1ck12txsl; + + /** 簇1从控13通讯失联 */ + @Excel(name = "簇1从控13通讯失联") + private Integer c1ck13txsl; + + /** 簇1从控14通讯失联 */ + @Excel(name = "簇1从控14通讯失联") + private Integer c1ck14txsl; + + /** 簇1从控15通讯失联 */ + @Excel(name = "簇1从控15通讯失联") + private Integer c1ck15txsl; + + /** 簇1从控16通讯失联 */ + @Excel(name = "簇1从控16通讯失联") + private Integer c1ck16txsl; + + /** 簇1从控17通讯失联 */ + @Excel(name = "簇1从控17通讯失联") + private Integer c1ck17txsl; + + /** 簇1从控18通讯失联 */ + @Excel(name = "簇1从控18通讯失联") + private Integer c1ck18txsl; + + /** 簇1从控19通讯失联 */ + @Excel(name = "簇1从控19通讯失联") + private Integer c1ck19txsl; + + /** 簇1从控20通讯失联 */ + @Excel(name = "簇1从控20通讯失联") + private Integer c1ck20txsl; + + /** 簇1从控21通讯失联 */ + @Excel(name = "簇1从控21通讯失联") + private Integer c1ck21txsl; + + /** 簇1从控22通讯失联 */ + @Excel(name = "簇1从控22通讯失联") + private Integer c1ck22txsl; + + /** 簇1从控23通讯失联 */ + @Excel(name = "簇1从控23通讯失联") + private Integer c1ck23txsl; + + /** 簇1从控24通讯失联 */ + @Excel(name = "簇1从控24通讯失联") + private Integer c1ck24txsl; + + /** 簇1从控25通讯失联 */ + @Excel(name = "簇1从控25通讯失联") + private Integer c1ck25txsl; + + /** 簇1从控26通讯失联 */ + @Excel(name = "簇1从控26通讯失联") + private Integer c1ck26txsl; + + /** 簇1从控27通讯失联 */ + @Excel(name = "簇1从控27通讯失联") + private Integer c1ck27txsl; + + /** 簇1从控28通讯失联 */ + @Excel(name = "簇1从控28通讯失联") + private Integer c1ck28txsl; + + /** 簇1从控29通讯失联 */ + @Excel(name = "簇1从控29通讯失联") + private Integer c1ck29txsl; + + /** 簇1从控30通讯失联 */ + @Excel(name = "簇1从控30通讯失联") + private Integer c1ck30txsl; + + /** 簇1从控31通讯失联 */ + @Excel(name = "簇1从控31通讯失联") + private Integer c1ck31txsl; + + /** 簇1从控32通讯失联 */ + @Excel(name = "簇1从控32通讯失联") + private Integer c1ck32txsl; + + /** 簇1从控33通讯失联 */ + @Excel(name = "簇1从控33通讯失联") + private Integer c1ck33txsl; + + /** 簇1从控34通讯失联 */ + @Excel(name = "簇1从控34通讯失联") + private Integer c1ck34txsl; + + /** 簇1从控35通讯失联 */ + @Excel(name = "簇1从控35通讯失联") + private Integer c1ck35txsl; + + /** 簇1从控36通讯失联 */ + @Excel(name = "簇1从控36通讯失联") + private Integer c1ck36txsl; + + /** 簇1从控37通讯失联 */ + @Excel(name = "簇1从控37通讯失联") + private Integer c1ck37txsl; + + /** 簇1从控38通讯失联 */ + @Excel(name = "簇1从控38通讯失联") + private Integer c1ck38txsl; + + /** 簇1从控39通讯失联 */ + @Excel(name = "簇1从控39通讯失联") + private Integer c1ck39txsl; + + /** 簇1从控40通讯失联 */ + @Excel(name = "簇1从控40通讯失联") + private Integer c1ck40txsl; + + /** 簇1端子温度过高轻度告警 */ + @Excel(name = "簇1端子温度过高轻度告警") + private Integer c1dzwdggqdgj; + + /** 簇1端子温度过高中度告警 */ + @Excel(name = "簇1端子温度过高中度告警") + private Integer c1dzwdggzdgj; + + /** 簇1端子温度过高重度告警 */ + @Excel(name = "簇1端子温度过高重度告警") + private Integer c1dzwdggzzdgj; + + /** 簇1模块电压过高轻度告警 */ + @Excel(name = "簇1模块电压过高轻度告警") + private Integer c1mkdyggqdgj; + + /** 簇1模块电压过高中度告警 */ + @Excel(name = "簇1模块电压过高中度告警") + private Integer c1mkdyggzdgj; + + /** 簇1模块电压过高重度告警 */ + @Excel(name = "簇1模块电压过高重度告警") + private Integer c1mkdyggzzdgj; + + /** 簇1模块电压过低轻度告警 */ + @Excel(name = "簇1模块电压过低轻度告警") + private Integer c1mkdygdqdgj; + + /** 簇1模块电压过低中度告警 */ + @Excel(name = "簇1模块电压过低中度告警") + private Integer c1mkdygdzdgj; + + /** 簇1模块电压过低重度告警 */ + @Excel(name = "簇1模块电压过低重度告警") + private Integer c1mkdygdzzdgj; + + /** 簇1电压采集故障 */ + @Excel(name = "簇1电压采集故障") + private Integer c1dycjgz; + + /** 簇1温度采集故障 */ + @Excel(name = "簇1温度采集故障") + private Integer c1wdcjgz; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setC1zktxsl(Integer c1zktxsl) + { + this.c1zktxsl = c1zktxsl; + } + + public Integer getC1zktxsl() + { + return c1zktxsl; + } + + public void setC1ddyqyqdgj(Integer c1ddyqyqdgj) + { + this.c1ddyqyqdgj = c1ddyqyqdgj; + } + + public Integer getC1ddyqyqdgj() + { + return c1ddyqyqdgj; + } + + public void setC1ddyqyzdgj(Integer c1ddyqyzdgj) + { + this.c1ddyqyzdgj = c1ddyqyzdgj; + } + + public Integer getC1ddyqyzdgj() + { + return c1ddyqyzdgj; + } + + public void setC1ddyqyzzdgj(Integer c1ddyqyzzdgj) + { + this.c1ddyqyzzdgj = c1ddyqyzzdgj; + } + + public Integer getC1ddyqyzzdgj() + { + return c1ddyqyzzdgj; + } + + public void setC1ddygyqdgj(Integer c1ddygyqdgj) + { + this.c1ddygyqdgj = c1ddygyqdgj; + } + + public Integer getC1ddygyqdgj() + { + return c1ddygyqdgj; + } + + public void setC1ddygyzdgj(Integer c1ddygyzdgj) + { + this.c1ddygyzdgj = c1ddygyzdgj; + } + + public Integer getC1ddygyzdgj() + { + return c1ddygyzdgj; + } + + public void setC1ddygyzzdgj(Integer c1ddygyzzdgj) + { + this.c1ddygyzzdgj = c1ddygyzzdgj; + } + + public Integer getC1ddygyzzdgj() + { + return c1ddygyzzdgj; + } + + public void setC1ddlqdgj(Integer c1ddlqdgj) + { + this.c1ddlqdgj = c1ddlqdgj; + } + + public Integer getC1ddlqdgj() + { + return c1ddlqdgj; + } + + public void setC1ddlzdgj(Integer c1ddlzdgj) + { + this.c1ddlzdgj = c1ddlzdgj; + } + + public Integer getC1ddlzdgj() + { + return c1ddlzdgj; + } + + public void setC1ddlzzdgj(Integer c1ddlzzdgj) + { + this.c1ddlzzdgj = c1ddlzzdgj; + } + + public Integer getC1ddlzzdgj() + { + return c1ddlzzdgj; + } + + public void setC1dtqyqdgj(Integer c1dtqyqdgj) + { + this.c1dtqyqdgj = c1dtqyqdgj; + } + + public Integer getC1dtqyqdgj() + { + return c1dtqyqdgj; + } + + public void setC1dtqyzdgj(Integer c1dtqyzdgj) + { + this.c1dtqyzdgj = c1dtqyzdgj; + } + + public Integer getC1dtqyzdgj() + { + return c1dtqyzdgj; + } + + public void setC1dtqyzzdgj(Integer c1dtqyzzdgj) + { + this.c1dtqyzzdgj = c1dtqyzzdgj; + } + + public Integer getC1dtqyzzdgj() + { + return c1dtqyzzdgj; + } + + public void setC1dtgyqdgj(Integer c1dtgyqdgj) + { + this.c1dtgyqdgj = c1dtgyqdgj; + } + + public Integer getC1dtgyqdgj() + { + return c1dtgyqdgj; + } + + public void setC1dtgyzdgj(Integer c1dtgyzdgj) + { + this.c1dtgyzdgj = c1dtgyzdgj; + } + + public Integer getC1dtgyzdgj() + { + return c1dtgyzdgj; + } + + public void setC1dtgyzzdgj(Integer c1dtgyzzdgj) + { + this.c1dtgyzzdgj = c1dtgyzzdgj; + } + + public Integer getC1dtgyzzdgj() + { + return c1dtgyzzdgj; + } + + public void setC1dtqwqdgj(Integer c1dtqwqdgj) + { + this.c1dtqwqdgj = c1dtqwqdgj; + } + + public Integer getC1dtqwqdgj() + { + return c1dtqwqdgj; + } + + public void setC1dtqwzdgj(Integer c1dtqwzdgj) + { + this.c1dtqwzdgj = c1dtqwzdgj; + } + + public Integer getC1dtqwzdgj() + { + return c1dtqwzdgj; + } + + public void setC1dtqwzzdgj(Integer c1dtqwzzdgj) + { + this.c1dtqwzzdgj = c1dtqwzzdgj; + } + + public Integer getC1dtqwzzdgj() + { + return c1dtqwzzdgj; + } + + public void setC1dtgwqdgj(Integer c1dtgwqdgj) + { + this.c1dtgwqdgj = c1dtgwqdgj; + } + + public Integer getC1dtgwqdgj() + { + return c1dtgwqdgj; + } + + public void setC1dtgwzdgj(Integer c1dtgwzdgj) + { + this.c1dtgwzdgj = c1dtgwzdgj; + } + + public Integer getC1dtgwzdgj() + { + return c1dtgwzdgj; + } + + public void setC1dtgwzzdgj(Integer c1dtgwzzdgj) + { + this.c1dtgwzzdgj = c1dtgwzzdgj; + } + + public Integer getC1dtgwzzdgj() + { + return c1dtgwzzdgj; + } + + public void setC1socdqdgj(Integer c1socdqdgj) + { + this.c1socdqdgj = c1socdqdgj; + } + + public Integer getC1socdqdgj() + { + return c1socdqdgj; + } + + public void setC1socdzdgj(Integer c1socdzdgj) + { + this.c1socdzdgj = c1socdzdgj; + } + + public Integer getC1socdzdgj() + { + return c1socdzdgj; + } + + public void setC1socdzzdgj(Integer c1socdzzdgj) + { + this.c1socdzzdgj = c1socdzzdgj; + } + + public Integer getC1socdzzdgj() + { + return c1socdzzdgj; + } + + public void setC1socgqdgj(Integer c1socgqdgj) + { + this.c1socgqdgj = c1socgqdgj; + } + + public Integer getC1socgqdgj() + { + return c1socgqdgj; + } + + public void setC1socgzdgj(Integer c1socgzdgj) + { + this.c1socgzdgj = c1socgzdgj; + } + + public Integer getC1socgzdgj() + { + return c1socgzdgj; + } + + public void setC1socgzzdgj(Integer c1socgzzdgj) + { + this.c1socgzzdgj = c1socgzzdgj; + } + + public Integer getC1socgzzdgj() + { + return c1socgzzdgj; + } + + public void setC1sohdqdgj(Integer c1sohdqdgj) + { + this.c1sohdqdgj = c1sohdqdgj; + } + + public Integer getC1sohdqdgj() + { + return c1sohdqdgj; + } + + public void setC1sohdzdgj(Integer c1sohdzdgj) + { + this.c1sohdzdgj = c1sohdzdgj; + } + + public Integer getC1sohdzdgj() + { + return c1sohdzdgj; + } + + public void setC1sohdzzdgj(Integer c1sohdzzdgj) + { + this.c1sohdzzdgj = c1sohdzzdgj; + } + + public Integer getC1sohdzzdgj() + { + return c1sohdzzdgj; + } + + public void setC1dtycqdgj(Integer c1dtycqdgj) + { + this.c1dtycqdgj = c1dtycqdgj; + } + + public Integer getC1dtycqdgj() + { + return c1dtycqdgj; + } + + public void setC1dtyczdgj(Integer c1dtyczdgj) + { + this.c1dtyczdgj = c1dtyczdgj; + } + + public Integer getC1dtyczdgj() + { + return c1dtyczdgj; + } + + public void setC1dtyczzdgj(Integer c1dtyczzdgj) + { + this.c1dtyczzdgj = c1dtyczzdgj; + } + + public Integer getC1dtyczzdgj() + { + return c1dtyczzdgj; + } + + public void setC1dtwcqdgj(Integer c1dtwcqdgj) + { + this.c1dtwcqdgj = c1dtwcqdgj; + } + + public Integer getC1dtwcqdgj() + { + return c1dtwcqdgj; + } + + public void setC1dtwczdgj(Integer c1dtwczdgj) + { + this.c1dtwczdgj = c1dtwczdgj; + } + + public Integer getC1dtwczdgj() + { + return c1dtwczdgj; + } + + public void setC1dtwczzdgj(Integer c1dtwczzdgj) + { + this.c1dtwczzdgj = c1dtwczzdgj; + } + + public Integer getC1dtwczzdgj() + { + return c1dtwczzdgj; + } + + public void setC1ck1txsl(Integer c1ck1txsl) + { + this.c1ck1txsl = c1ck1txsl; + } + + public Integer getC1ck1txsl() + { + return c1ck1txsl; + } + + public void setC1ck2txsl(Integer c1ck2txsl) + { + this.c1ck2txsl = c1ck2txsl; + } + + public Integer getC1ck2txsl() + { + return c1ck2txsl; + } + + public void setC1ck3txsl(Integer c1ck3txsl) + { + this.c1ck3txsl = c1ck3txsl; + } + + public Integer getC1ck3txsl() + { + return c1ck3txsl; + } + + public void setC1ck4txsl(Integer c1ck4txsl) + { + this.c1ck4txsl = c1ck4txsl; + } + + public Integer getC1ck4txsl() + { + return c1ck4txsl; + } + + public void setC1ck5txsl(Integer c1ck5txsl) + { + this.c1ck5txsl = c1ck5txsl; + } + + public Integer getC1ck5txsl() + { + return c1ck5txsl; + } + + public void setC1ck6txsl(Integer c1ck6txsl) + { + this.c1ck6txsl = c1ck6txsl; + } + + public Integer getC1ck6txsl() + { + return c1ck6txsl; + } + + public void setC1ck7txsl(Integer c1ck7txsl) + { + this.c1ck7txsl = c1ck7txsl; + } + + public Integer getC1ck7txsl() + { + return c1ck7txsl; + } + + public void setC1ck8txsl(Integer c1ck8txsl) + { + this.c1ck8txsl = c1ck8txsl; + } + + public Integer getC1ck8txsl() + { + return c1ck8txsl; + } + + public void setC1ck9txsl(Integer c1ck9txsl) + { + this.c1ck9txsl = c1ck9txsl; + } + + public Integer getC1ck9txsl() + { + return c1ck9txsl; + } + + public void setC1ck10txsl(Integer c1ck10txsl) + { + this.c1ck10txsl = c1ck10txsl; + } + + public Integer getC1ck10txsl() + { + return c1ck10txsl; + } + + public void setC1ck11txsl(Integer c1ck11txsl) + { + this.c1ck11txsl = c1ck11txsl; + } + + public Integer getC1ck11txsl() + { + return c1ck11txsl; + } + + public void setC1ck12txsl(Integer c1ck12txsl) + { + this.c1ck12txsl = c1ck12txsl; + } + + public Integer getC1ck12txsl() + { + return c1ck12txsl; + } + + public void setC1ck13txsl(Integer c1ck13txsl) + { + this.c1ck13txsl = c1ck13txsl; + } + + public Integer getC1ck13txsl() + { + return c1ck13txsl; + } + + public void setC1ck14txsl(Integer c1ck14txsl) + { + this.c1ck14txsl = c1ck14txsl; + } + + public Integer getC1ck14txsl() + { + return c1ck14txsl; + } + + public void setC1ck15txsl(Integer c1ck15txsl) + { + this.c1ck15txsl = c1ck15txsl; + } + + public Integer getC1ck15txsl() + { + return c1ck15txsl; + } + + public void setC1ck16txsl(Integer c1ck16txsl) + { + this.c1ck16txsl = c1ck16txsl; + } + + public Integer getC1ck16txsl() + { + return c1ck16txsl; + } + + public void setC1ck17txsl(Integer c1ck17txsl) + { + this.c1ck17txsl = c1ck17txsl; + } + + public Integer getC1ck17txsl() + { + return c1ck17txsl; + } + + public void setC1ck18txsl(Integer c1ck18txsl) + { + this.c1ck18txsl = c1ck18txsl; + } + + public Integer getC1ck18txsl() + { + return c1ck18txsl; + } + + public void setC1ck19txsl(Integer c1ck19txsl) + { + this.c1ck19txsl = c1ck19txsl; + } + + public Integer getC1ck19txsl() + { + return c1ck19txsl; + } + + public void setC1ck20txsl(Integer c1ck20txsl) + { + this.c1ck20txsl = c1ck20txsl; + } + + public Integer getC1ck20txsl() + { + return c1ck20txsl; + } + + public void setC1ck21txsl(Integer c1ck21txsl) + { + this.c1ck21txsl = c1ck21txsl; + } + + public Integer getC1ck21txsl() + { + return c1ck21txsl; + } + + public void setC1ck22txsl(Integer c1ck22txsl) + { + this.c1ck22txsl = c1ck22txsl; + } + + public Integer getC1ck22txsl() + { + return c1ck22txsl; + } + + public void setC1ck23txsl(Integer c1ck23txsl) + { + this.c1ck23txsl = c1ck23txsl; + } + + public Integer getC1ck23txsl() + { + return c1ck23txsl; + } + + public void setC1ck24txsl(Integer c1ck24txsl) + { + this.c1ck24txsl = c1ck24txsl; + } + + public Integer getC1ck24txsl() + { + return c1ck24txsl; + } + + public void setC1ck25txsl(Integer c1ck25txsl) + { + this.c1ck25txsl = c1ck25txsl; + } + + public Integer getC1ck25txsl() + { + return c1ck25txsl; + } + + public void setC1ck26txsl(Integer c1ck26txsl) + { + this.c1ck26txsl = c1ck26txsl; + } + + public Integer getC1ck26txsl() + { + return c1ck26txsl; + } + + public void setC1ck27txsl(Integer c1ck27txsl) + { + this.c1ck27txsl = c1ck27txsl; + } + + public Integer getC1ck27txsl() + { + return c1ck27txsl; + } + + public void setC1ck28txsl(Integer c1ck28txsl) + { + this.c1ck28txsl = c1ck28txsl; + } + + public Integer getC1ck28txsl() + { + return c1ck28txsl; + } + + public void setC1ck29txsl(Integer c1ck29txsl) + { + this.c1ck29txsl = c1ck29txsl; + } + + public Integer getC1ck29txsl() + { + return c1ck29txsl; + } + + public void setC1ck30txsl(Integer c1ck30txsl) + { + this.c1ck30txsl = c1ck30txsl; + } + + public Integer getC1ck30txsl() + { + return c1ck30txsl; + } + + public void setC1ck31txsl(Integer c1ck31txsl) + { + this.c1ck31txsl = c1ck31txsl; + } + + public Integer getC1ck31txsl() + { + return c1ck31txsl; + } + + public void setC1ck32txsl(Integer c1ck32txsl) + { + this.c1ck32txsl = c1ck32txsl; + } + + public Integer getC1ck32txsl() + { + return c1ck32txsl; + } + + public void setC1ck33txsl(Integer c1ck33txsl) + { + this.c1ck33txsl = c1ck33txsl; + } + + public Integer getC1ck33txsl() + { + return c1ck33txsl; + } + + public void setC1ck34txsl(Integer c1ck34txsl) + { + this.c1ck34txsl = c1ck34txsl; + } + + public Integer getC1ck34txsl() + { + return c1ck34txsl; + } + + public void setC1ck35txsl(Integer c1ck35txsl) + { + this.c1ck35txsl = c1ck35txsl; + } + + public Integer getC1ck35txsl() + { + return c1ck35txsl; + } + + public void setC1ck36txsl(Integer c1ck36txsl) + { + this.c1ck36txsl = c1ck36txsl; + } + + public Integer getC1ck36txsl() + { + return c1ck36txsl; + } + + public void setC1ck37txsl(Integer c1ck37txsl) + { + this.c1ck37txsl = c1ck37txsl; + } + + public Integer getC1ck37txsl() + { + return c1ck37txsl; + } + + public void setC1ck38txsl(Integer c1ck38txsl) + { + this.c1ck38txsl = c1ck38txsl; + } + + public Integer getC1ck38txsl() + { + return c1ck38txsl; + } + + public void setC1ck39txsl(Integer c1ck39txsl) + { + this.c1ck39txsl = c1ck39txsl; + } + + public Integer getC1ck39txsl() + { + return c1ck39txsl; + } + + public void setC1ck40txsl(Integer c1ck40txsl) + { + this.c1ck40txsl = c1ck40txsl; + } + + public Integer getC1ck40txsl() + { + return c1ck40txsl; + } + + public void setC1dzwdggqdgj(Integer c1dzwdggqdgj) + { + this.c1dzwdggqdgj = c1dzwdggqdgj; + } + + public Integer getC1dzwdggqdgj() + { + return c1dzwdggqdgj; + } + + public void setC1dzwdggzdgj(Integer c1dzwdggzdgj) + { + this.c1dzwdggzdgj = c1dzwdggzdgj; + } + + public Integer getC1dzwdggzdgj() + { + return c1dzwdggzdgj; + } + + public void setC1dzwdggzzdgj(Integer c1dzwdggzzdgj) + { + this.c1dzwdggzzdgj = c1dzwdggzzdgj; + } + + public Integer getC1dzwdggzzdgj() + { + return c1dzwdggzzdgj; + } + + public void setC1mkdyggqdgj(Integer c1mkdyggqdgj) + { + this.c1mkdyggqdgj = c1mkdyggqdgj; + } + + public Integer getC1mkdyggqdgj() + { + return c1mkdyggqdgj; + } + + public void setC1mkdyggzdgj(Integer c1mkdyggzdgj) + { + this.c1mkdyggzdgj = c1mkdyggzdgj; + } + + public Integer getC1mkdyggzdgj() + { + return c1mkdyggzdgj; + } + + public void setC1mkdyggzzdgj(Integer c1mkdyggzzdgj) + { + this.c1mkdyggzzdgj = c1mkdyggzzdgj; + } + + public Integer getC1mkdyggzzdgj() + { + return c1mkdyggzzdgj; + } + + public void setC1mkdygdqdgj(Integer c1mkdygdqdgj) + { + this.c1mkdygdqdgj = c1mkdygdqdgj; + } + + public Integer getC1mkdygdqdgj() + { + return c1mkdygdqdgj; + } + + public void setC1mkdygdzdgj(Integer c1mkdygdzdgj) + { + this.c1mkdygdzdgj = c1mkdygdzdgj; + } + + public Integer getC1mkdygdzdgj() + { + return c1mkdygdzdgj; + } + + public void setC1mkdygdzzdgj(Integer c1mkdygdzzdgj) + { + this.c1mkdygdzzdgj = c1mkdygdzzdgj; + } + + public Integer getC1mkdygdzzdgj() + { + return c1mkdygdzzdgj; + } + + public void setC1dycjgz(Integer c1dycjgz) + { + this.c1dycjgz = c1dycjgz; + } + + public Integer getC1dycjgz() + { + return c1dycjgz; + } + + public void setC1wdcjgz(Integer c1wdcjgz) + { + this.c1wdcjgz = c1wdcjgz; + } + + public Integer getC1wdcjgz() + { + return c1wdcjgz; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dataTimestamp", getDataTimestamp()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("c1zktxsl", getC1zktxsl()) + .append("c1ddyqyqdgj", getC1ddyqyqdgj()) + .append("c1ddyqyzdgj", getC1ddyqyzdgj()) + .append("c1ddyqyzzdgj", getC1ddyqyzzdgj()) + .append("c1ddygyqdgj", getC1ddygyqdgj()) + .append("c1ddygyzdgj", getC1ddygyzdgj()) + .append("c1ddygyzzdgj", getC1ddygyzzdgj()) + .append("c1ddlqdgj", getC1ddlqdgj()) + .append("c1ddlzdgj", getC1ddlzdgj()) + .append("c1ddlzzdgj", getC1ddlzzdgj()) + .append("c1dtqyqdgj", getC1dtqyqdgj()) + .append("c1dtqyzdgj", getC1dtqyzdgj()) + .append("c1dtqyzzdgj", getC1dtqyzzdgj()) + .append("c1dtgyqdgj", getC1dtgyqdgj()) + .append("c1dtgyzdgj", getC1dtgyzdgj()) + .append("c1dtgyzzdgj", getC1dtgyzzdgj()) + .append("c1dtqwqdgj", getC1dtqwqdgj()) + .append("c1dtqwzdgj", getC1dtqwzdgj()) + .append("c1dtqwzzdgj", getC1dtqwzzdgj()) + .append("c1dtgwqdgj", getC1dtgwqdgj()) + .append("c1dtgwzdgj", getC1dtgwzdgj()) + .append("c1dtgwzzdgj", getC1dtgwzzdgj()) + .append("c1socdqdgj", getC1socdqdgj()) + .append("c1socdzdgj", getC1socdzdgj()) + .append("c1socdzzdgj", getC1socdzzdgj()) + .append("c1socgqdgj", getC1socgqdgj()) + .append("c1socgzdgj", getC1socgzdgj()) + .append("c1socgzzdgj", getC1socgzzdgj()) + .append("c1sohdqdgj", getC1sohdqdgj()) + .append("c1sohdzdgj", getC1sohdzdgj()) + .append("c1sohdzzdgj", getC1sohdzzdgj()) + .append("c1dtycqdgj", getC1dtycqdgj()) + .append("c1dtyczdgj", getC1dtyczdgj()) + .append("c1dtyczzdgj", getC1dtyczzdgj()) + .append("c1dtwcqdgj", getC1dtwcqdgj()) + .append("c1dtwczdgj", getC1dtwczdgj()) + .append("c1dtwczzdgj", getC1dtwczzdgj()) + .append("c1ck1txsl", getC1ck1txsl()) + .append("c1ck2txsl", getC1ck2txsl()) + .append("c1ck3txsl", getC1ck3txsl()) + .append("c1ck4txsl", getC1ck4txsl()) + .append("c1ck5txsl", getC1ck5txsl()) + .append("c1ck6txsl", getC1ck6txsl()) + .append("c1ck7txsl", getC1ck7txsl()) + .append("c1ck8txsl", getC1ck8txsl()) + .append("c1ck9txsl", getC1ck9txsl()) + .append("c1ck10txsl", getC1ck10txsl()) + .append("c1ck11txsl", getC1ck11txsl()) + .append("c1ck12txsl", getC1ck12txsl()) + .append("c1ck13txsl", getC1ck13txsl()) + .append("c1ck14txsl", getC1ck14txsl()) + .append("c1ck15txsl", getC1ck15txsl()) + .append("c1ck16txsl", getC1ck16txsl()) + .append("c1ck17txsl", getC1ck17txsl()) + .append("c1ck18txsl", getC1ck18txsl()) + .append("c1ck19txsl", getC1ck19txsl()) + .append("c1ck20txsl", getC1ck20txsl()) + .append("c1ck21txsl", getC1ck21txsl()) + .append("c1ck22txsl", getC1ck22txsl()) + .append("c1ck23txsl", getC1ck23txsl()) + .append("c1ck24txsl", getC1ck24txsl()) + .append("c1ck25txsl", getC1ck25txsl()) + .append("c1ck26txsl", getC1ck26txsl()) + .append("c1ck27txsl", getC1ck27txsl()) + .append("c1ck28txsl", getC1ck28txsl()) + .append("c1ck29txsl", getC1ck29txsl()) + .append("c1ck30txsl", getC1ck30txsl()) + .append("c1ck31txsl", getC1ck31txsl()) + .append("c1ck32txsl", getC1ck32txsl()) + .append("c1ck33txsl", getC1ck33txsl()) + .append("c1ck34txsl", getC1ck34txsl()) + .append("c1ck35txsl", getC1ck35txsl()) + .append("c1ck36txsl", getC1ck36txsl()) + .append("c1ck37txsl", getC1ck37txsl()) + .append("c1ck38txsl", getC1ck38txsl()) + .append("c1ck39txsl", getC1ck39txsl()) + .append("c1ck40txsl", getC1ck40txsl()) + .append("c1dzwdggqdgj", getC1dzwdggqdgj()) + .append("c1dzwdggzdgj", getC1dzwdggzdgj()) + .append("c1dzwdggzzdgj", getC1dzwdggzzdgj()) + .append("c1mkdyggqdgj", getC1mkdyggqdgj()) + .append("c1mkdyggzdgj", getC1mkdyggzdgj()) + .append("c1mkdyggzzdgj", getC1mkdyggzzdgj()) + .append("c1mkdygdqdgj", getC1mkdygdqdgj()) + .append("c1mkdygdzdgj", getC1mkdygdzdgj()) + .append("c1mkdygdzzdgj", getC1mkdygdzzdgj()) + .append("c1dycjgz", getC1dycjgz()) + .append("c1wdcjgz", getC1wdcjgz()) + .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/EmsCoolingAlarmData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingAlarmData.java new file mode 100644 index 0000000..9ae72ef --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingAlarmData.java @@ -0,0 +1,795 @@ +package com.xzzn.ems.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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; + +/** + * ZSLQ告警故障数据对象 ems_cooling_alarm_data + * + * @author xzzn + * @date 2025-10-22 + */ +public class EmsCoolingAlarmData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 记录唯一ID */ + private Long id; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date dataTimestamp; + + /** 站点ID */ + @Excel(name = "站点ID") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** */ + @Excel(name = "") + private Integer lsjyx; + + /** */ + @Excel(name = "") + private Integer pqdcfyx; + + /** */ + @Excel(name = "") + private Integer djrq2yx; + + /** */ + @Excel(name = "") + private Integer djrq1yx; + + /** */ + @Excel(name = "") + private Integer bqbyx; + + /** */ + @Excel(name = "") + private Integer bsbyx; + + /** */ + @Excel(name = "") + private Integer zxhbyx; + + /** */ + @Excel(name = "") + private Integer sltzgz; + + /** */ + @Excel(name = "") + private Integer slzhyj; + + /** */ + @Excel(name = "") + private Integer slxtyctzxh; + + /** */ + @Excel(name = "") + private Integer slxtycqdxh; + + /** */ + @Excel(name = "") + private Integer slxtyckz; + + /** */ + @Excel(name = "") + private Integer slxtbdkz; + + /** */ + @Excel(name = "") + private Integer slxtzdms; + + /** */ + @Excel(name = "") + private Integer slxtsdms; + + /** */ + @Excel(name = "") + private Integer hsylcdyj; + + /** */ + @Excel(name = "") + private Integer hsyldyj; + + /** */ + @Excel(name = "") + private Integer gsylcgyj; + + /** */ + @Excel(name = "") + private Integer gsylgyj; + + /** */ + @Excel(name = "") + private Integer gsylcdyj; + + /** */ + @Excel(name = "") + private Integer gsyldyj; + + /** */ + @Excel(name = "") + private Integer hcgywg; + + /** */ + @Excel(name = "") + private Integer hcgywcdtz; + + /** */ + @Excel(name = "") + private Integer hcgywd; + + /** */ + @Excel(name = "") + private Integer hcgylg; + + /** */ + @Excel(name = "") + private Integer hcgyld; + + /** */ + @Excel(name = "") + private Integer lysylgyj; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private Integer lysyldyj; + + /** */ + @Excel(name = "") + private Integer hswdcgyj; + + /** */ + @Excel(name = "") + private Integer hswdgyj; + + /** */ + @Excel(name = "") + private Integer gswdcgtz; + + /** */ + @Excel(name = "") + private Integer gswdgyj; + + /** */ + @Excel(name = "") + private Integer gswddyj; + + /** */ + @Excel(name = "") + private Integer ddf2gz; + + /** */ + @Excel(name = "") + private Integer ddf1gz; + + /** */ + @Excel(name = "") + private Integer lyswdbsqyJ; + + /** */ + @Excel(name = "") + private Integer hsylbsqyJ; + + /** */ + @Excel(name = "") + private Integer gsylbsqyJ; + + /** */ + @Excel(name = "") + private Integer hswdbsqyJ; + + /** */ + @Excel(name = "") + private Integer gswdbsqgztz; + + /** */ + @Excel(name = "") + private Integer lsjgz; + + /** */ + @Excel(name = "") + private Integer djrq2gz; + + /** */ + @Excel(name = "") + private Integer djrq1gz; + + /** */ + @Excel(name = "") + private Integer bqbgz; + + /** */ + @Excel(name = "") + private Integer bsbgz; + + /** */ + @Excel(name = "") + private Integer xhbgz; + + /** */ + @Excel(name = "") + private Integer zdygz; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setLsjyx(Integer lsjyx) + { + this.lsjyx = lsjyx; + } + + public Integer getLsjyx() + { + return lsjyx; + } + + public void setPqdcfyx(Integer pqdcfyx) + { + this.pqdcfyx = pqdcfyx; + } + + public Integer getPqdcfyx() + { + return pqdcfyx; + } + + public void setDjrq2yx(Integer djrq2yx) + { + this.djrq2yx = djrq2yx; + } + + public Integer getDjrq2yx() + { + return djrq2yx; + } + + public void setDjrq1yx(Integer djrq1yx) + { + this.djrq1yx = djrq1yx; + } + + public Integer getDjrq1yx() + { + return djrq1yx; + } + + public void setBqbyx(Integer bqbyx) + { + this.bqbyx = bqbyx; + } + + public Integer getBqbyx() + { + return bqbyx; + } + + public void setBsbyx(Integer bsbyx) + { + this.bsbyx = bsbyx; + } + + public Integer getBsbyx() + { + return bsbyx; + } + + public void setZxhbyx(Integer zxhbyx) + { + this.zxhbyx = zxhbyx; + } + + public Integer getZxhbyx() + { + return zxhbyx; + } + + public void setSltzgz(Integer sltzgz) + { + this.sltzgz = sltzgz; + } + + public Integer getSltzgz() + { + return sltzgz; + } + + public void setSlzhyj(Integer slzhyj) + { + this.slzhyj = slzhyj; + } + + public Integer getSlzhyj() + { + return slzhyj; + } + + public void setSlxtyctzxh(Integer slxtyctzxh) + { + this.slxtyctzxh = slxtyctzxh; + } + + public Integer getSlxtyctzxh() + { + return slxtyctzxh; + } + + public void setSlxtycqdxh(Integer slxtycqdxh) + { + this.slxtycqdxh = slxtycqdxh; + } + + public Integer getSlxtycqdxh() + { + return slxtycqdxh; + } + + public void setSlxtyckz(Integer slxtyckz) + { + this.slxtyckz = slxtyckz; + } + + public Integer getSlxtyckz() + { + return slxtyckz; + } + + public void setSlxtbdkz(Integer slxtbdkz) + { + this.slxtbdkz = slxtbdkz; + } + + public Integer getSlxtbdkz() + { + return slxtbdkz; + } + + public void setSlxtzdms(Integer slxtzdms) + { + this.slxtzdms = slxtzdms; + } + + public Integer getSlxtzdms() + { + return slxtzdms; + } + + public void setSlxtsdms(Integer slxtsdms) + { + this.slxtsdms = slxtsdms; + } + + public Integer getSlxtsdms() + { + return slxtsdms; + } + + public void setHsylcdyj(Integer hsylcdyj) + { + this.hsylcdyj = hsylcdyj; + } + + public Integer getHsylcdyj() + { + return hsylcdyj; + } + + public void setHsyldyj(Integer hsyldyj) + { + this.hsyldyj = hsyldyj; + } + + public Integer getHsyldyj() + { + return hsyldyj; + } + + public void setGsylcgyj(Integer gsylcgyj) + { + this.gsylcgyj = gsylcgyj; + } + + public Integer getGsylcgyj() + { + return gsylcgyj; + } + + public void setGsylgyj(Integer gsylgyj) + { + this.gsylgyj = gsylgyj; + } + + public Integer getGsylgyj() + { + return gsylgyj; + } + + public void setGsylcdyj(Integer gsylcdyj) + { + this.gsylcdyj = gsylcdyj; + } + + public Integer getGsylcdyj() + { + return gsylcdyj; + } + + public void setGsyldyj(Integer gsyldyj) + { + this.gsyldyj = gsyldyj; + } + + public Integer getGsyldyj() + { + return gsyldyj; + } + + public void setHcgywg(Integer hcgywg) + { + this.hcgywg = hcgywg; + } + + public Integer getHcgywg() + { + return hcgywg; + } + + public void setHcgywcdtz(Integer hcgywcdtz) + { + this.hcgywcdtz = hcgywcdtz; + } + + public Integer getHcgywcdtz() + { + return hcgywcdtz; + } + + public void setHcgywd(Integer hcgywd) + { + this.hcgywd = hcgywd; + } + + public Integer getHcgywd() + { + return hcgywd; + } + + public void setHcgylg(Integer hcgylg) + { + this.hcgylg = hcgylg; + } + + public Integer getHcgylg() + { + return hcgylg; + } + + public void setHcgyld(Integer hcgyld) + { + this.hcgyld = hcgyld; + } + + public Integer getHcgyld() + { + return hcgyld; + } + + public void setLysylgyj(Integer lysylgyj) + { + this.lysylgyj = lysylgyj; + } + + public Integer getLysylgyj() + { + return lysylgyj; + } + + public void setLysyldyj(Integer lysyldyj) + { + this.lysyldyj = lysyldyj; + } + + public Integer getLysyldyj() + { + return lysyldyj; + } + + public void setHswdcgyj(Integer hswdcgyj) + { + this.hswdcgyj = hswdcgyj; + } + + public Integer getHswdcgyj() + { + return hswdcgyj; + } + + public void setHswdgyj(Integer hswdgyj) + { + this.hswdgyj = hswdgyj; + } + + public Integer getHswdgyj() + { + return hswdgyj; + } + + public void setGswdcgtz(Integer gswdcgtz) + { + this.gswdcgtz = gswdcgtz; + } + + public Integer getGswdcgtz() + { + return gswdcgtz; + } + + public void setGswdgyj(Integer gswdgyj) + { + this.gswdgyj = gswdgyj; + } + + public Integer getGswdgyj() + { + return gswdgyj; + } + + public void setGswddyj(Integer gswddyj) + { + this.gswddyj = gswddyj; + } + + public Integer getGswddyj() + { + return gswddyj; + } + + public void setDdf2gz(Integer ddf2gz) + { + this.ddf2gz = ddf2gz; + } + + public Integer getDdf2gz() + { + return ddf2gz; + } + + public void setDdf1gz(Integer ddf1gz) + { + this.ddf1gz = ddf1gz; + } + + public Integer getDdf1gz() + { + return ddf1gz; + } + + public void setLyswdbsqyJ(Integer lyswdbsqyJ) + { + this.lyswdbsqyJ = lyswdbsqyJ; + } + + public Integer getLyswdbsqyJ() + { + return lyswdbsqyJ; + } + + public void setHsylbsqyJ(Integer hsylbsqyJ) + { + this.hsylbsqyJ = hsylbsqyJ; + } + + public Integer getHsylbsqyJ() + { + return hsylbsqyJ; + } + + public void setGsylbsqyJ(Integer gsylbsqyJ) + { + this.gsylbsqyJ = gsylbsqyJ; + } + + public Integer getGsylbsqyJ() + { + return gsylbsqyJ; + } + + public void setHswdbsqyJ(Integer hswdbsqyJ) + { + this.hswdbsqyJ = hswdbsqyJ; + } + + public Integer getHswdbsqyJ() + { + return hswdbsqyJ; + } + + public void setGswdbsqgztz(Integer gswdbsqgztz) + { + this.gswdbsqgztz = gswdbsqgztz; + } + + public Integer getGswdbsqgztz() + { + return gswdbsqgztz; + } + + public void setLsjgz(Integer lsjgz) + { + this.lsjgz = lsjgz; + } + + public Integer getLsjgz() + { + return lsjgz; + } + + public void setDjrq2gz(Integer djrq2gz) + { + this.djrq2gz = djrq2gz; + } + + public Integer getDjrq2gz() + { + return djrq2gz; + } + + public void setDjrq1gz(Integer djrq1gz) + { + this.djrq1gz = djrq1gz; + } + + public Integer getDjrq1gz() + { + return djrq1gz; + } + + public void setBqbgz(Integer bqbgz) + { + this.bqbgz = bqbgz; + } + + public Integer getBqbgz() + { + return bqbgz; + } + + public void setBsbgz(Integer bsbgz) + { + this.bsbgz = bsbgz; + } + + public Integer getBsbgz() + { + return bsbgz; + } + + public void setXhbgz(Integer xhbgz) + { + this.xhbgz = xhbgz; + } + + public Integer getXhbgz() + { + return xhbgz; + } + + public void setZdygz(Integer zdygz) + { + this.zdygz = zdygz; + } + + public Integer getZdygz() + { + return zdygz; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dataTimestamp", getDataTimestamp()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("lsjyx", getLsjyx()) + .append("pqdcfyx", getPqdcfyx()) + .append("djrq2yx", getDjrq2yx()) + .append("djrq1yx", getDjrq1yx()) + .append("bqbyx", getBqbyx()) + .append("bsbyx", getBsbyx()) + .append("zxhbyx", getZxhbyx()) + .append("sltzgz", getSltzgz()) + .append("slzhyj", getSlzhyj()) + .append("slxtyctzxh", getSlxtyctzxh()) + .append("slxtycqdxh", getSlxtycqdxh()) + .append("slxtyckz", getSlxtyckz()) + .append("slxtbdkz", getSlxtbdkz()) + .append("slxtzdms", getSlxtzdms()) + .append("slxtsdms", getSlxtsdms()) + .append("hsylcdyj", getHsylcdyj()) + .append("hsyldyj", getHsyldyj()) + .append("gsylcgyj", getGsylcgyj()) + .append("gsylgyj", getGsylgyj()) + .append("gsylcdyj", getGsylcdyj()) + .append("gsyldyj", getGsyldyj()) + .append("hcgywg", getHcgywg()) + .append("hcgywcdtz", getHcgywcdtz()) + .append("hcgywd", getHcgywd()) + .append("hcgylg", getHcgylg()) + .append("hcgyld", getHcgyld()) + .append("lysylgyj", getLysylgyj()) + .append("lysyldyj", getLysyldyj()) + .append("hswdcgyj", getHswdcgyj()) + .append("hswdgyj", getHswdgyj()) + .append("gswdcgtz", getGswdcgtz()) + .append("gswdgyj", getGswdgyj()) + .append("gswddyj", getGswddyj()) + .append("ddf2gz", getDdf2gz()) + .append("ddf1gz", getDdf1gz()) + .append("lyswdbsqyJ", getLyswdbsqyJ()) + .append("hsylbsqyJ", getHsylbsqyJ()) + .append("gsylbsqyJ", getGsylbsqyJ()) + .append("hswdbsqyJ", getHswdbsqyJ()) + .append("gswdbsqgztz", getGswdbsqgztz()) + .append("lsjgz", getLsjgz()) + .append("djrq2gz", getDjrq2gz()) + .append("djrq1gz", getDjrq1gz()) + .append("bqbgz", getBqbgz()) + .append("bsbgz", getBsbgz()) + .append("xhbgz", getXhbgz()) + .append("zdygz", getZdygz()) + .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/EmsPcsAlarmData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsAlarmData.java new file mode 100644 index 0000000..bc10122 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsAlarmData.java @@ -0,0 +1,1545 @@ +package com.xzzn.ems.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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; + +/** + * pcs设备告警故障数据对象 ems_pcs_alarm_data + * + * @author xzzn + * @date 2025-10-22 + */ +public class EmsPcsAlarmData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 记录唯一ID */ + private Long id; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date dataTimestamp; + + /** 站点ID */ + @Excel(name = "站点ID") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** 故障标志(0-正常,1-故障) */ + @Excel(name = "故障标志", readConverterExp = "0=-正常,1-故障") + private Integer gzbz; + + /** 绝缘阻抗异常(0-正常,1-异常) */ + @Excel(name = "绝缘阻抗异常", readConverterExp = "0=-正常,1-异常") + private Integer jyzkyc; + + /** 交流漏电流异常(0-正常,1-异常) */ + @Excel(name = "交流漏电流异常", readConverterExp = "0=-正常,1-异常") + private Integer jlllyc; + + /** 直流过压(0-正常,1-异常) */ + @Excel(name = "直流过压", readConverterExp = "0=-正常,1-异常") + private Integer zlgv; + + /** 电网过压异常(0-正常,1-异常) */ + @Excel(name = "电网过压异常", readConverterExp = "0=-正常,1-异常") + private Integer dwgyyc; + + /** 电网欠压异常(0-正常,1-异常) */ + @Excel(name = "电网欠压异常", readConverterExp = "0=-正常,1-异常") + private Integer dwqyyc; + + /** 电网过频异常(0-正常,1-异常) */ + @Excel(name = "电网过频异常", readConverterExp = "0=-正常,1-异常") + private Integer dwgpyc; + + /** 电网欠频异常(0-正常,1-异常) */ + @Excel(name = "电网欠频异常", readConverterExp = "0=-正常,1-异常") + private Integer dwqpyc; + + /** 功率模块过温(0-正常,1-异常) */ + @Excel(name = "功率模块过温", readConverterExp = "0=-正常,1-异常") + private Integer glmkgw; + + /** 电网相序异常(0-正常,1-异常) */ + @Excel(name = "电网相序异常", readConverterExp = "0=-正常,1-异常") + private Integer dwxxyc; + + /** 逆变软件过流(0-正常,1-异常) */ + @Excel(name = "逆变软件过流", readConverterExp = "0=-正常,1-异常") + private Integer nbrjgl; + + /** 直流软启动异常(0-正常,1-异常) */ + @Excel(name = "直流软启动异常", readConverterExp = "0=-正常,1-异常") + private Integer zlrqdyc; + + /** 直流开关异常(0-正常,1-异常) */ + @Excel(name = "直流开关异常", readConverterExp = "0=-正常,1-异常") + private Integer zlkgwc; + + /** 交流风机异常(0-正常,1-异常) */ + @Excel(name = "交流风机异常", readConverterExp = "0=-正常,1-异常") + private Integer jlfjyc; + + /** 交流开关异常(0-正常,1-异常) */ + @Excel(name = "交流开关异常", readConverterExp = "0=-正常,1-异常") + private Integer jlkgwc; + + /** 温度开关异常(0-正常,1-异常) */ + @Excel(name = "温度开关异常", readConverterExp = "0=-正常,1-异常") + private Integer wdkgwc; + + /** 内部异常(0-正常,1-异常) */ + @Excel(name = "内部异常", readConverterExp = "0=-正常,1-异常") + private Integer nbyc; + + /** 机内过温(0-正常,1-异常) */ + @Excel(name = "机内过温", readConverterExp = "0=-正常,1-异常") + private Integer jngw; + + /** 交流软启动异常(0-正常,1-异常) */ + @Excel(name = "交流软启动异常", readConverterExp = "0=-正常,1-异常") + private Integer jlrqdyc; + + /** 热交换机异常(0-正常,1-异常) */ + @Excel(name = "热交换机异常", readConverterExp = "0=-正常,1-异常") + private Integer rjhjyc; + + /** 交流防雷器异常(0-正常,1-异常) */ + @Excel(name = "交流防雷器异常", readConverterExp = "0=-正常,1-异常") + private Integer jlflqyc; + + /** 内部急停(0-正常,1-触发) */ + @Excel(name = "内部急停", readConverterExp = "0=-正常,1-触发") + private Integer nbjt; + + /** 外部急停(0-正常,1-触发) */ + @Excel(name = "外部急停", readConverterExp = "0=-正常,1-触发") + private Integer wbjt; + + /** 母线电压不符合开机条件(0-符合,1-不符合) */ + @Excel(name = "母线电压不符合开机条件", readConverterExp = "0=-符合,1-不符合") + private Integer mxdbyfhkjtj; + + /** 母线电流过流(0-正常,1-过流) */ + @Excel(name = "母线电流过流", readConverterExp = "0=-正常,1-过流") + private Integer mxdlgl; + + /** 零偏校准异常(0-正常,1-异常) */ + @Excel(name = "零偏校准异常", readConverterExp = "0=-正常,1-异常") + private Integer lpjzyc; + + /** 门禁告警(0-正常,1-告警) */ + @Excel(name = "门禁告警", readConverterExp = "0=-正常,1-告警") + private Integer mjgj; + + /** 锁相异常(0-正常,1-异常) */ + @Excel(name = "锁相异常", readConverterExp = "0=-正常,1-异常") + private Integer sxyc; + + /** 直流防雷器异常(0-正常,1-异常) */ + @Excel(name = "直流防雷器异常", readConverterExp = "0=-正常,1-异常") + private Integer zlflqyc; + + /** 智能电表通信异常(0-正常,1-异常) */ + @Excel(name = "智能电表通信异常", readConverterExp = "0=-正常,1-异常") + private Integer zndbtxyc; + + /** 逆变硬件过流(0-正常,1-过流) */ + @Excel(name = "逆变硬件过流", readConverterExp = "0=-正常,1-过流") + private Integer nbyjgl; + + /** 驱动异常(0-正常,1-异常) */ + @Excel(name = "驱动异常", readConverterExp = "0=-正常,1-异常") + private Integer qdyc; + + /** ID冲突(0-正常,1-冲突) */ + @Excel(name = "ID冲突", readConverterExp = "0=-正常,1-冲突") + private Integer idct; + + /** 信息共享CAN通信异常(0-正常,1-异常) */ + @Excel(name = "信息共享CAN通信异常", readConverterExp = "0=-正常,1-异常") + private Integer xxgxctxvc; + + /** 并机通信线异常(0-正常,1-异常) */ + @Excel(name = "并机通信线异常", readConverterExp = "0=-正常,1-异常") + private Integer bjtxxyc; + + /** 同步CAN通信异常(0-正常,1-异常) */ + @Excel(name = "同步CAN通信异常", readConverterExp = "0=-正常,1-异常") + private Integer tbctxvc; + + /** 直流电弧异常(0-正常,1-异常) */ + @Excel(name = "直流电弧异常", readConverterExp = "0=-正常,1-异常") + private Integer zldhyc; + + /** 零序过流(0-正常,1-过流) */ + @Excel(name = "零序过流", readConverterExp = "0=-正常,1-过流") + private Integer lxgl; + + /** 直流主接触器异常(0-正常,1-异常) */ + @Excel(name = "直流主接触器异常", readConverterExp = "0=-正常,1-异常") + private Integer zlzjcqyc; + + /** 烟雾告警(0-正常,1-告警) */ + @Excel(name = "烟雾告警", readConverterExp = "0=-正常,1-告警") + private Integer ywgj; + + /** 并机通信异常(0-正常,1-异常) */ + @Excel(name = "并机通信异常", readConverterExp = "0=-正常,1-异常") + private Integer bjtxyc; + + /** HMI CAN通信异常(0-正常,1-异常) */ + @Excel(name = "HMI CAN通信异常", readConverterExp = "0=-正常,1-异常") + private Integer hmictxyc; + + /** 机型设置错误(0-正确,1-错误) */ + @Excel(name = "机型设置错误", readConverterExp = "0=-正确,1-错误") + private Integer jxszcw; + + /** HMI 485通信异常(0-正常,1-异常) */ + @Excel(name = "HMI 485通信异常", readConverterExp = "0=-正常,1-异常") + private Integer hmi485txyc; + + /** 远程通信异常(0-正常,1-异常) */ + @Excel(name = "远程通信异常", readConverterExp = "0=-正常,1-异常") + private Integer yctxyc; + + /** 故障总(0-无故障,1-有故障) */ + @Excel(name = "故障总", readConverterExp = "0=-无故障,1-有故障") + private Integer gzz; + + /** 告警总(0-无告警,1-有告警) */ + @Excel(name = "告警总", readConverterExp = "0=-无告警,1-有告警") + private Integer gjz; + + /** 直流并联模式设置错误(0-正确,1-错误) */ + @Excel(name = "直流并联模式设置错误", readConverterExp = "0=-正确,1-错误") + private Integer zlblmsszcw; + + /** 系统参数不匹配(0-匹配,1-不匹配) */ + @Excel(name = "系统参数不匹配", readConverterExp = "0=-匹配,1-不匹配") + private Integer xtcsbpp; + + /** 电网电压不平衡告警(0-正常,1-告警) */ + @Excel(name = "电网电压不平衡告警", readConverterExp = "0=-正常,1-告警") + private Integer dwdybphgj; + + /** 低电压穿越运行(0-未运行,1-运行中) */ + @Excel(name = "低电压穿越运行", readConverterExp = "0=-未运行,1-运行中") + private Integer ddycyyx; + + /** 高电压穿越运行(0-未运行,1-运行中) */ + @Excel(name = "高电压穿越运行", readConverterExp = "0=-未运行,1-运行中") + private Integer gdycyyx; + + /** 直流风机异常(0-正常,1-异常) */ + @Excel(name = "直流风机异常", readConverterExp = "0=-正常,1-异常") + private Integer zlfjyc; + + /** 散热器温度开关异常(0-正常,1-异常) */ + @Excel(name = "散热器温度开关异常", readConverterExp = "0=-正常,1-异常") + private Integer srqwdkgwc; + + /** 外部温度开关异常(0-正常,1-异常) */ + @Excel(name = "外部温度开关异常", readConverterExp = "0=-正常,1-异常") + private Integer wbwdkgwc; + + /** 辅源变压器温度开关异常(0-正常,1-异常) */ + @Excel(name = "辅源变压器温度开关异常", readConverterExp = "0=-正常,1-异常") + private Integer fybyqwdkgwc; + + /** 电感温度开关异常(0-正常,1-异常) */ + @Excel(name = "电感温度开关异常", readConverterExp = "0=-正常,1-异常") + private Integer dgwdkgwc; + + /** 正极接地异常(0-正常,1-异常) */ + @Excel(name = "正极接地异常", readConverterExp = "0=-正常,1-异常") + private Integer zjjdvc; + + /** 负极接地异常(0-正常,1-异常) */ + @Excel(name = "负极接地异常", readConverterExp = "0=-正常,1-异常") + private Integer fjjdvc; + + /** 交流接地异常(0-正常,1-异常) */ + @Excel(name = "交流接地异常", readConverterExp = "0=-正常,1-异常") + private Integer jljdvc; + + /** 并网接地异常(0-正常,1-异常) */ + @Excel(name = "并网接地异常", readConverterExp = "0=-正常,1-异常") + private Integer bwjdvc; + + /** BMS急停(0-正常,1-触发) */ + @Excel(name = "BMS急停", readConverterExp = "0=-正常,1-触发") + private Integer bmsjt; + + /** 空空换热器异常(0-正常,1-异常) */ + @Excel(name = "空空换热器异常", readConverterExp = "0=-正常,1-异常") + private Integer kkhrqyc; + + /** 电网过欠频待机告警(0-正常,1-告警) */ + @Excel(name = "电网过欠频待机告警", readConverterExp = "0=-正常,1-告警") + private Integer dwgqpdjgj; + + /** 功率模块过温告警(0-正常,1-告警) */ + @Excel(name = "功率模块过温告警", readConverterExp = "0=-正常,1-告警") + private Integer glmkgwgJ; + + /** 电池过压(0-正常,1-过压) */ + @Excel(name = "电池过压", readConverterExp = "0=-正常,1-过压") + private Integer dcgy; + + /** 电池轻载欠压(0-正常,1-欠压) */ + @Excel(name = "电池轻载欠压", readConverterExp = "0=-正常,1-欠压") + private Integer dcqzqy; + + /** 直流过流(0-正常,1-过流) */ + @Excel(name = "直流过流", readConverterExp = "0=-正常,1-过流") + private Integer zlgl; + + /** 输出电压异常(0-正常,1-异常) */ + @Excel(name = "输出电压异常", readConverterExp = "0=-正常,1-异常") + private Integer scdyyc; + + /** 输出电压不符合离网条件(0-符合,1-不符合) */ + @Excel(name = "输出电压不符合离网条件", readConverterExp = "0=-符合,1-不符合") + private Integer scdybfhlwtj; + + /** 过载保护(0-未触发,1-已触发) */ + @Excel(name = "过载保护", readConverterExp = "0=-未触发,1-已触发") + private Integer gzbh; + + /** 短路保护(0-未触发,1-已触发) */ + @Excel(name = "短路保护", readConverterExp = "0=-未触发,1-已触发") + private Integer dlbh; + + /** 内部风机异常(0-正常,1-异常) */ + @Excel(name = "内部风机异常", readConverterExp = "0=-正常,1-异常") + private Integer nbfjyc; + + /** 直流保险丝异常(0-正常,1-异常) */ + @Excel(name = "直流保险丝异常", readConverterExp = "0=-正常,1-异常") + private Integer zlbxsyc; + + /** 电池重载欠压(0-正常,1-欠压) */ + @Excel(name = "电池重载欠压", readConverterExp = "0=-正常,1-欠压") + private Integer dczzqy; + + /** 电池低压告警(0-正常,1-告警) */ + @Excel(name = "电池低压告警", readConverterExp = "0=-正常,1-告警") + private Integer dcdygj; + + /** 外部风机异常(0-正常,1-异常) */ + @Excel(name = "外部风机异常", readConverterExp = "0=-正常,1-异常") + private Integer wbfjyc; + + /** 电池反接(0-正常,1-反接) */ + @Excel(name = "电池反接", readConverterExp = "0=-正常,1-反接") + private Integer dcfj; + + /** 电池电压不符合充电条件(0-符合,1-不符合) */ + @Excel(name = "电池电压不符合充电条件", readConverterExp = "0=-符合,1-不符合") + private Integer dcdybfhcdtj; + + /** 过载告警(0-正常,1-告警) */ + @Excel(name = "过载告警", readConverterExp = "0=-正常,1-告警") + private Integer gzgJ; + + /** 直流电弧模块通信异常(0-正常,1-异常) */ + @Excel(name = "直流电弧模块通信异常", readConverterExp = "0=-正常,1-异常") + private Integer zldhmktxyc; + + /** BMS系统故障(0-正常,1-故障) */ + @Excel(name = "BMS系统故障", readConverterExp = "0=-正常,1-故障") + private Integer bmsxtgz; + + /** BMS通信异常(0-正常,1-异常) */ + @Excel(name = "BMS通信异常", readConverterExp = "0=-正常,1-异常") + private Integer bmstxyc; + + /** BMS干接点异常(0-正常,1-异常) */ + @Excel(name = "BMS干接点异常", readConverterExp = "0=-正常,1-异常") + private Integer bmsgjdyc; + + /** BMS禁充(0-允许,1-禁止) */ + @Excel(name = "BMS禁充", readConverterExp = "0=-允许,1-禁止") + private Integer bmsjc; + + /** BMS禁放(0-允许,1-禁止) */ + @Excel(name = "BMS禁放", readConverterExp = "0=-允许,1-禁止") + private Integer bmsjf; + + /** BMS待机(0-运行,1-待机) */ + @Excel(name = "BMS待机", readConverterExp = "0=-运行,1-待机") + private Integer bmsdj; + + /** BMS告警(0-正常,1-告警) */ + @Excel(name = "BMS告警", readConverterExp = "0=-正常,1-告警") + private Integer bmsgj; + + /** 电感风机异常(0-正常,1-异常) */ + @Excel(name = "电感风机异常", readConverterExp = "0=-正常,1-异常") + private Integer dgfjyc; + + /** 散热器过温告警(0-正常,1-告警) */ + @Excel(name = "散热器过温告警", readConverterExp = "0=-正常,1-告警") + private Integer srqgwgj; + + /** 故障总2(0-无故障,1-有故障) */ + @Excel(name = "故障总2", readConverterExp = "0=-无故障,1-有故障") + private Integer gzz2; + + /** 告警总2(0-无告警,1-有告警) */ + @Excel(name = "告警总2", readConverterExp = "0=-无告警,1-有告警") + private Integer gjz2; + + /** 交流风机寿命异常(0-正常,1-异常) */ + @Excel(name = "交流风机寿命异常", readConverterExp = "0=-正常,1-异常") + private Integer jlfjsmyc; + + /** 直流风机寿命异常(0-正常,1-异常) */ + @Excel(name = "直流风机寿命异常", readConverterExp = "0=-正常,1-异常") + private Integer zlfjsmyc; + + /** 交流开关寿命异常(0-正常,1-异常) */ + @Excel(name = "交流开关寿命异常", readConverterExp = "0=-正常,1-异常") + private Integer jlkgSmyc; + + /** 直流开关寿命异常(0-正常,1-异常) */ + @Excel(name = "直流开关寿命异常", readConverterExp = "0=-正常,1-异常") + private Integer zlkgSmyc; + + /** 液冷机组异常(0-正常,1-异常) */ + @Excel(name = "液冷机组异常", readConverterExp = "0=-正常,1-异常") + private Integer yljzyc; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setGzbz(Integer gzbz) + { + this.gzbz = gzbz; + } + + public Integer getGzbz() + { + return gzbz; + } + + public void setJyzkyc(Integer jyzkyc) + { + this.jyzkyc = jyzkyc; + } + + public Integer getJyzkyc() + { + return jyzkyc; + } + + public void setJlllyc(Integer jlllyc) + { + this.jlllyc = jlllyc; + } + + public Integer getJlllyc() + { + return jlllyc; + } + + public void setZlgv(Integer zlgv) + { + this.zlgv = zlgv; + } + + public Integer getZlgv() + { + return zlgv; + } + + public void setDwgyyc(Integer dwgyyc) + { + this.dwgyyc = dwgyyc; + } + + public Integer getDwgyyc() + { + return dwgyyc; + } + + public void setDwqyyc(Integer dwqyyc) + { + this.dwqyyc = dwqyyc; + } + + public Integer getDwqyyc() + { + return dwqyyc; + } + + public void setDwgpyc(Integer dwgpyc) + { + this.dwgpyc = dwgpyc; + } + + public Integer getDwgpyc() + { + return dwgpyc; + } + + public void setDwqpyc(Integer dwqpyc) + { + this.dwqpyc = dwqpyc; + } + + public Integer getDwqpyc() + { + return dwqpyc; + } + + public void setGlmkgw(Integer glmkgw) + { + this.glmkgw = glmkgw; + } + + public Integer getGlmkgw() + { + return glmkgw; + } + + public void setDwxxyc(Integer dwxxyc) + { + this.dwxxyc = dwxxyc; + } + + public Integer getDwxxyc() + { + return dwxxyc; + } + + public void setNbrjgl(Integer nbrjgl) + { + this.nbrjgl = nbrjgl; + } + + public Integer getNbrjgl() + { + return nbrjgl; + } + + public void setZlrqdyc(Integer zlrqdyc) + { + this.zlrqdyc = zlrqdyc; + } + + public Integer getZlrqdyc() + { + return zlrqdyc; + } + + public void setZlkgwc(Integer zlkgwc) + { + this.zlkgwc = zlkgwc; + } + + public Integer getZlkgwc() + { + return zlkgwc; + } + + public void setJlfjyc(Integer jlfjyc) + { + this.jlfjyc = jlfjyc; + } + + public Integer getJlfjyc() + { + return jlfjyc; + } + + public void setJlkgwc(Integer jlkgwc) + { + this.jlkgwc = jlkgwc; + } + + public Integer getJlkgwc() + { + return jlkgwc; + } + + public void setWdkgwc(Integer wdkgwc) + { + this.wdkgwc = wdkgwc; + } + + public Integer getWdkgwc() + { + return wdkgwc; + } + + public void setNbyc(Integer nbyc) + { + this.nbyc = nbyc; + } + + public Integer getNbyc() + { + return nbyc; + } + + public void setJngw(Integer jngw) + { + this.jngw = jngw; + } + + public Integer getJngw() + { + return jngw; + } + + public void setJlrqdyc(Integer jlrqdyc) + { + this.jlrqdyc = jlrqdyc; + } + + public Integer getJlrqdyc() + { + return jlrqdyc; + } + + public void setRjhjyc(Integer rjhjyc) + { + this.rjhjyc = rjhjyc; + } + + public Integer getRjhjyc() + { + return rjhjyc; + } + + public void setJlflqyc(Integer jlflqyc) + { + this.jlflqyc = jlflqyc; + } + + public Integer getJlflqyc() + { + return jlflqyc; + } + + public void setNbjt(Integer nbjt) + { + this.nbjt = nbjt; + } + + public Integer getNbjt() + { + return nbjt; + } + + public void setWbjt(Integer wbjt) + { + this.wbjt = wbjt; + } + + public Integer getWbjt() + { + return wbjt; + } + + public void setMxdbyfhkjtj(Integer mxdbyfhkjtj) + { + this.mxdbyfhkjtj = mxdbyfhkjtj; + } + + public Integer getMxdbyfhkjtj() + { + return mxdbyfhkjtj; + } + + public void setMxdlgl(Integer mxdlgl) + { + this.mxdlgl = mxdlgl; + } + + public Integer getMxdlgl() + { + return mxdlgl; + } + + public void setLpjzyc(Integer lpjzyc) + { + this.lpjzyc = lpjzyc; + } + + public Integer getLpjzyc() + { + return lpjzyc; + } + + public void setMjgj(Integer mjgj) + { + this.mjgj = mjgj; + } + + public Integer getMjgj() + { + return mjgj; + } + + public void setSxyc(Integer sxyc) + { + this.sxyc = sxyc; + } + + public Integer getSxyc() + { + return sxyc; + } + + public void setZlflqyc(Integer zlflqyc) + { + this.zlflqyc = zlflqyc; + } + + public Integer getZlflqyc() + { + return zlflqyc; + } + + public void setZndbtxyc(Integer zndbtxyc) + { + this.zndbtxyc = zndbtxyc; + } + + public Integer getZndbtxyc() + { + return zndbtxyc; + } + + public void setNbyjgl(Integer nbyjgl) + { + this.nbyjgl = nbyjgl; + } + + public Integer getNbyjgl() + { + return nbyjgl; + } + + public void setQdyc(Integer qdyc) + { + this.qdyc = qdyc; + } + + public Integer getQdyc() + { + return qdyc; + } + + public void setIdct(Integer idct) + { + this.idct = idct; + } + + public Integer getIdct() + { + return idct; + } + + public void setXxgxctxvc(Integer xxgxctxvc) + { + this.xxgxctxvc = xxgxctxvc; + } + + public Integer getXxgxctxvc() + { + return xxgxctxvc; + } + + public void setBjtxxyc(Integer bjtxxyc) + { + this.bjtxxyc = bjtxxyc; + } + + public Integer getBjtxxyc() + { + return bjtxxyc; + } + + public void setTbctxvc(Integer tbctxvc) + { + this.tbctxvc = tbctxvc; + } + + public Integer getTbctxvc() + { + return tbctxvc; + } + + public void setZldhyc(Integer zldhyc) + { + this.zldhyc = zldhyc; + } + + public Integer getZldhyc() + { + return zldhyc; + } + + public void setLxgl(Integer lxgl) + { + this.lxgl = lxgl; + } + + public Integer getLxgl() + { + return lxgl; + } + + public void setZlzjcqyc(Integer zlzjcqyc) + { + this.zlzjcqyc = zlzjcqyc; + } + + public Integer getZlzjcqyc() + { + return zlzjcqyc; + } + + public void setYwgj(Integer ywgj) + { + this.ywgj = ywgj; + } + + public Integer getYwgj() + { + return ywgj; + } + + public void setBjtxyc(Integer bjtxyc) + { + this.bjtxyc = bjtxyc; + } + + public Integer getBjtxyc() + { + return bjtxyc; + } + + public void setHmictxyc(Integer hmictxyc) + { + this.hmictxyc = hmictxyc; + } + + public Integer getHmictxyc() + { + return hmictxyc; + } + + public void setJxszcw(Integer jxszcw) + { + this.jxszcw = jxszcw; + } + + public Integer getJxszcw() + { + return jxszcw; + } + + public void setHmi485txyc(Integer hmi485txyc) + { + this.hmi485txyc = hmi485txyc; + } + + public Integer getHmi485txyc() + { + return hmi485txyc; + } + + public void setYctxyc(Integer yctxyc) + { + this.yctxyc = yctxyc; + } + + public Integer getYctxyc() + { + return yctxyc; + } + + public void setGzz(Integer gzz) + { + this.gzz = gzz; + } + + public Integer getGzz() + { + return gzz; + } + + public void setGjz(Integer gjz) + { + this.gjz = gjz; + } + + public Integer getGjz() + { + return gjz; + } + + public void setZlblmsszcw(Integer zlblmsszcw) + { + this.zlblmsszcw = zlblmsszcw; + } + + public Integer getZlblmsszcw() + { + return zlblmsszcw; + } + + public void setXtcsbpp(Integer xtcsbpp) + { + this.xtcsbpp = xtcsbpp; + } + + public Integer getXtcsbpp() + { + return xtcsbpp; + } + + public void setDwdybphgj(Integer dwdybphgj) + { + this.dwdybphgj = dwdybphgj; + } + + public Integer getDwdybphgj() + { + return dwdybphgj; + } + + public void setDdycyyx(Integer ddycyyx) + { + this.ddycyyx = ddycyyx; + } + + public Integer getDdycyyx() + { + return ddycyyx; + } + + public void setGdycyyx(Integer gdycyyx) + { + this.gdycyyx = gdycyyx; + } + + public Integer getGdycyyx() + { + return gdycyyx; + } + + public void setZlfjyc(Integer zlfjyc) + { + this.zlfjyc = zlfjyc; + } + + public Integer getZlfjyc() + { + return zlfjyc; + } + + public void setSrqwdkgwc(Integer srqwdkgwc) + { + this.srqwdkgwc = srqwdkgwc; + } + + public Integer getSrqwdkgwc() + { + return srqwdkgwc; + } + + public void setWbwdkgwc(Integer wbwdkgwc) + { + this.wbwdkgwc = wbwdkgwc; + } + + public Integer getWbwdkgwc() + { + return wbwdkgwc; + } + + public void setFybyqwdkgwc(Integer fybyqwdkgwc) + { + this.fybyqwdkgwc = fybyqwdkgwc; + } + + public Integer getFybyqwdkgwc() + { + return fybyqwdkgwc; + } + + public void setDgwdkgwc(Integer dgwdkgwc) + { + this.dgwdkgwc = dgwdkgwc; + } + + public Integer getDgwdkgwc() + { + return dgwdkgwc; + } + + public void setZjjdvc(Integer zjjdvc) + { + this.zjjdvc = zjjdvc; + } + + public Integer getZjjdvc() + { + return zjjdvc; + } + + public void setFjjdvc(Integer fjjdvc) + { + this.fjjdvc = fjjdvc; + } + + public Integer getFjjdvc() + { + return fjjdvc; + } + + public void setJljdvc(Integer jljdvc) + { + this.jljdvc = jljdvc; + } + + public Integer getJljdvc() + { + return jljdvc; + } + + public void setBwjdvc(Integer bwjdvc) + { + this.bwjdvc = bwjdvc; + } + + public Integer getBwjdvc() + { + return bwjdvc; + } + + public void setBmsjt(Integer bmsjt) + { + this.bmsjt = bmsjt; + } + + public Integer getBmsjt() + { + return bmsjt; + } + + public void setKkhrqyc(Integer kkhrqyc) + { + this.kkhrqyc = kkhrqyc; + } + + public Integer getKkhrqyc() + { + return kkhrqyc; + } + + public void setDwgqpdjgj(Integer dwgqpdjgj) + { + this.dwgqpdjgj = dwgqpdjgj; + } + + public Integer getDwgqpdjgj() + { + return dwgqpdjgj; + } + + public void setGlmkgwgJ(Integer glmkgwgJ) + { + this.glmkgwgJ = glmkgwgJ; + } + + public Integer getGlmkgwgJ() + { + return glmkgwgJ; + } + + public void setDcgy(Integer dcgy) + { + this.dcgy = dcgy; + } + + public Integer getDcgy() + { + return dcgy; + } + + public void setDcqzqy(Integer dcqzqy) + { + this.dcqzqy = dcqzqy; + } + + public Integer getDcqzqy() + { + return dcqzqy; + } + + public void setZlgl(Integer zlgl) + { + this.zlgl = zlgl; + } + + public Integer getZlgl() + { + return zlgl; + } + + public void setScdyyc(Integer scdyyc) + { + this.scdyyc = scdyyc; + } + + public Integer getScdyyc() + { + return scdyyc; + } + + public void setScdybfhlwtj(Integer scdybfhlwtj) + { + this.scdybfhlwtj = scdybfhlwtj; + } + + public Integer getScdybfhlwtj() + { + return scdybfhlwtj; + } + + public void setGzbh(Integer gzbh) + { + this.gzbh = gzbh; + } + + public Integer getGzbh() + { + return gzbh; + } + + public void setDlbh(Integer dlbh) + { + this.dlbh = dlbh; + } + + public Integer getDlbh() + { + return dlbh; + } + + public void setNbfjyc(Integer nbfjyc) + { + this.nbfjyc = nbfjyc; + } + + public Integer getNbfjyc() + { + return nbfjyc; + } + + public void setZlbxsyc(Integer zlbxsyc) + { + this.zlbxsyc = zlbxsyc; + } + + public Integer getZlbxsyc() + { + return zlbxsyc; + } + + public void setDczzqy(Integer dczzqy) + { + this.dczzqy = dczzqy; + } + + public Integer getDczzqy() + { + return dczzqy; + } + + public void setDcdygj(Integer dcdygj) + { + this.dcdygj = dcdygj; + } + + public Integer getDcdygj() + { + return dcdygj; + } + + public void setWbfjyc(Integer wbfjyc) + { + this.wbfjyc = wbfjyc; + } + + public Integer getWbfjyc() + { + return wbfjyc; + } + + public void setDcfj(Integer dcfj) + { + this.dcfj = dcfj; + } + + public Integer getDcfj() + { + return dcfj; + } + + public void setDcdybfhcdtj(Integer dcdybfhcdtj) + { + this.dcdybfhcdtj = dcdybfhcdtj; + } + + public Integer getDcdybfhcdtj() + { + return dcdybfhcdtj; + } + + public void setGzgJ(Integer gzgJ) + { + this.gzgJ = gzgJ; + } + + public Integer getGzgJ() + { + return gzgJ; + } + + public void setZldhmktxyc(Integer zldhmktxyc) + { + this.zldhmktxyc = zldhmktxyc; + } + + public Integer getZldhmktxyc() + { + return zldhmktxyc; + } + + public void setBmsxtgz(Integer bmsxtgz) + { + this.bmsxtgz = bmsxtgz; + } + + public Integer getBmsxtgz() + { + return bmsxtgz; + } + + public void setBmstxyc(Integer bmstxyc) + { + this.bmstxyc = bmstxyc; + } + + public Integer getBmstxyc() + { + return bmstxyc; + } + + public void setBmsgjdyc(Integer bmsgjdyc) + { + this.bmsgjdyc = bmsgjdyc; + } + + public Integer getBmsgjdyc() + { + return bmsgjdyc; + } + + public void setBmsjc(Integer bmsjc) + { + this.bmsjc = bmsjc; + } + + public Integer getBmsjc() + { + return bmsjc; + } + + public void setBmsjf(Integer bmsjf) + { + this.bmsjf = bmsjf; + } + + public Integer getBmsjf() + { + return bmsjf; + } + + public void setBmsdj(Integer bmsdj) + { + this.bmsdj = bmsdj; + } + + public Integer getBmsdj() + { + return bmsdj; + } + + public void setBmsgj(Integer bmsgj) + { + this.bmsgj = bmsgj; + } + + public Integer getBmsgj() + { + return bmsgj; + } + + public void setDgfjyc(Integer dgfjyc) + { + this.dgfjyc = dgfjyc; + } + + public Integer getDgfjyc() + { + return dgfjyc; + } + + public void setSrqgwgj(Integer srqgwgj) + { + this.srqgwgj = srqgwgj; + } + + public Integer getSrqgwgj() + { + return srqgwgj; + } + + public void setGzz2(Integer gzz2) + { + this.gzz2 = gzz2; + } + + public Integer getGzz2() + { + return gzz2; + } + + public void setGjz2(Integer gjz2) + { + this.gjz2 = gjz2; + } + + public Integer getGjz2() + { + return gjz2; + } + + public void setJlfjsmyc(Integer jlfjsmyc) + { + this.jlfjsmyc = jlfjsmyc; + } + + public Integer getJlfjsmyc() + { + return jlfjsmyc; + } + + public void setZlfjsmyc(Integer zlfjsmyc) + { + this.zlfjsmyc = zlfjsmyc; + } + + public Integer getZlfjsmyc() + { + return zlfjsmyc; + } + + public void setJlkgSmyc(Integer jlkgSmyc) + { + this.jlkgSmyc = jlkgSmyc; + } + + public Integer getJlkgSmyc() + { + return jlkgSmyc; + } + + public void setZlkgSmyc(Integer zlkgSmyc) + { + this.zlkgSmyc = zlkgSmyc; + } + + public Integer getZlkgSmyc() + { + return zlkgSmyc; + } + + public void setYljzyc(Integer yljzyc) + { + this.yljzyc = yljzyc; + } + + public Integer getYljzyc() + { + return yljzyc; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dataTimestamp", getDataTimestamp()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("gzbz", getGzbz()) + .append("jyzkyc", getJyzkyc()) + .append("jlllyc", getJlllyc()) + .append("zlgv", getZlgv()) + .append("dwgyyc", getDwgyyc()) + .append("dwqyyc", getDwqyyc()) + .append("dwgpyc", getDwgpyc()) + .append("dwqpyc", getDwqpyc()) + .append("glmkgw", getGlmkgw()) + .append("dwxxyc", getDwxxyc()) + .append("nbrjgl", getNbrjgl()) + .append("zlrqdyc", getZlrqdyc()) + .append("zlkgwc", getZlkgwc()) + .append("jlfjyc", getJlfjyc()) + .append("jlkgwc", getJlkgwc()) + .append("wdkgwc", getWdkgwc()) + .append("nbyc", getNbyc()) + .append("jngw", getJngw()) + .append("jlrqdyc", getJlrqdyc()) + .append("rjhjyc", getRjhjyc()) + .append("jlflqyc", getJlflqyc()) + .append("nbjt", getNbjt()) + .append("wbjt", getWbjt()) + .append("mxdbyfhkjtj", getMxdbyfhkjtj()) + .append("mxdlgl", getMxdlgl()) + .append("lpjzyc", getLpjzyc()) + .append("mjgj", getMjgj()) + .append("sxyc", getSxyc()) + .append("zlflqyc", getZlflqyc()) + .append("zndbtxyc", getZndbtxyc()) + .append("nbyjgl", getNbyjgl()) + .append("qdyc", getQdyc()) + .append("idct", getIdct()) + .append("xxgxctxvc", getXxgxctxvc()) + .append("bjtxxyc", getBjtxxyc()) + .append("tbctxvc", getTbctxvc()) + .append("zldhyc", getZldhyc()) + .append("lxgl", getLxgl()) + .append("zlzjcqyc", getZlzjcqyc()) + .append("ywgj", getYwgj()) + .append("bjtxyc", getBjtxyc()) + .append("hmictxyc", getHmictxyc()) + .append("jxszcw", getJxszcw()) + .append("hmi485txyc", getHmi485txyc()) + .append("yctxyc", getYctxyc()) + .append("gzz", getGzz()) + .append("gjz", getGjz()) + .append("zlblmsszcw", getZlblmsszcw()) + .append("xtcsbpp", getXtcsbpp()) + .append("dwdybphgj", getDwdybphgj()) + .append("ddycyyx", getDdycyyx()) + .append("gdycyyx", getGdycyyx()) + .append("zlfjyc", getZlfjyc()) + .append("srqwdkgwc", getSrqwdkgwc()) + .append("wbwdkgwc", getWbwdkgwc()) + .append("fybyqwdkgwc", getFybyqwdkgwc()) + .append("dgwdkgwc", getDgwdkgwc()) + .append("zjjdvc", getZjjdvc()) + .append("fjjdvc", getFjjdvc()) + .append("jljdvc", getJljdvc()) + .append("bwjdvc", getBwjdvc()) + .append("bmsjt", getBmsjt()) + .append("kkhrqyc", getKkhrqyc()) + .append("dwgqpdjgj", getDwgqpdjgj()) + .append("glmkgwgJ", getGlmkgwgJ()) + .append("dcgy", getDcgy()) + .append("dcqzqy", getDcqzqy()) + .append("zlgl", getZlgl()) + .append("scdyyc", getScdyyc()) + .append("scdybfhlwtj", getScdybfhlwtj()) + .append("gzbh", getGzbh()) + .append("dlbh", getDlbh()) + .append("nbfjyc", getNbfjyc()) + .append("zlbxsyc", getZlbxsyc()) + .append("dczzqy", getDczzqy()) + .append("dcdygj", getDcdygj()) + .append("wbfjyc", getWbfjyc()) + .append("dcfj", getDcfj()) + .append("dcdybfhcdtj", getDcdybfhcdtj()) + .append("gzgJ", getGzgJ()) + .append("zldhmktxyc", getZldhmktxyc()) + .append("bmsxtgz", getBmsxtgz()) + .append("bmstxyc", getBmstxyc()) + .append("bmsgjdyc", getBmsgjdyc()) + .append("bmsjc", getBmsjc()) + .append("bmsjf", getBmsjf()) + .append("bmsdj", getBmsdj()) + .append("bmsgj", getBmsgj()) + .append("dgfjyc", getDgfjyc()) + .append("srqgwgj", getSrqgwgj()) + .append("gzz2", getGzz2()) + .append("gjz2", getGjz2()) + .append("jlfjsmyc", getJlfjsmyc()) + .append("zlfjsmyc", getZlfjsmyc()) + .append("jlkgSmyc", getJlkgSmyc()) + .append("zlkgSmyc", getZlkgSmyc()) + .append("yljzyc", getYljzyc()) + .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/EmsStackAlarmData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStackAlarmData.java new file mode 100644 index 0000000..a3201a8 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsStackAlarmData.java @@ -0,0 +1,1545 @@ +package com.xzzn.ems.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +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; + +/** + * bmsd告警数据对象 ems_stack_alarm_data + * + * @author xzzn + * @date 2025-10-22 + */ +public class EmsStackAlarmData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** */ + private Long id; + + /** 数据采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "数据采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date dataTimestamp; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + + /** BMS故障状态(0=正常,1=故障) */ + @Excel(name = "BMS故障状态", readConverterExp = "0==正常,1=故障") + private Integer bmsgzzt; + + /** 禁充状态(0=允许充电,1=禁止充电) */ + @Excel(name = "禁充状态", readConverterExp = "0==允许充电,1=禁止充电") + private Integer jczt; + + /** 禁放状态(0=允许放电,1=禁止放电) */ + @Excel(name = "禁放状态", readConverterExp = "0==允许放电,1=禁止放电") + private Integer jfzt; + + /** 堆内各组端电压欠压轻度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端电压欠压轻度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzddyqyqdgjhz; + + /** 堆内各组端电压欠压中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端电压欠压中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzddyqyzdgjhz; + + /** 堆内各组端电压欠压重度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端电压欠压重度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzddyqyzzdgjhz; + + /** 堆内各组端电压过压轻度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端电压过压轻度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzddygyqdgjhz; + + /** 堆内各组端电压过压中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端电压过压中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzddygyzdgjhz; + + /** 堆内各组端电压过压重度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端电压过压重度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzddygyzzdgjhz; + + /** 堆内各组端过流轻度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端过流轻度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzdglqdgjhz; + + /** 堆内各组端过流中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端过流中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzdglzdgjhz; + + /** 堆内各组端过流重度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组端过流重度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzdglzzdgjhz; + + /** 堆内各组绝缘电阻低轻度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组绝缘电阻低轻度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzjydzdqdgjhz; + + /** 堆内各组绝缘电阻低中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组绝缘电阻低中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzjydzdzdgjhz; + + /** 堆内各组绝缘电阻低重度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组绝缘电阻低重度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzjydzdzzdgjhz; + + /** 堆内各组模块欠温度轻度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组模块欠温度轻度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzmkqwdqdgjhz; + + /** 堆内各组模块欠温度中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组模块欠温度中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzmkqwdzdgjhz; + + /** 堆内各组模块欠温度重度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组模块欠温度重度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzmkqwdzzdgjhz; + + /** 堆内各组模块过温度轻度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组模块过温度轻度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzmkgwdqdgjhz; + + /** 堆内各组模块过温度中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组模块过温度中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzmkgwdzdgjhz; + + /** 堆内各组模块过温度重度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各组模块过温度重度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngzmkgwdzzdgjhz; + + /** 堆内各单体过压轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体过压轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtgyqwgjhz; + + /** 堆内各单体过压中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体过压中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtgyzdgjhz; + + /** 堆内各单体过压严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体过压严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtgyyzgjhz; + + /** 堆内各单体欠压轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体欠压轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtqyqwgjhz; + + /** 堆内各单体欠压中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体欠压中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtqyzdgjhz; + + /** 堆内各单体欠压严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体欠压严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtqyyzgjhz; + + /** 堆内各单体压差轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体压差轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtycqwgjhz; + + /** 堆内各单体压差中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体压差中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtyczdgjhz; + + /** 堆内各单体压差严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体压差严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtycyzgjhz; + + /** 堆内各单体欠温轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体欠温轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtqwqwgjhz; + + /** 堆内各单体欠温中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体欠温中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtqwzdgjhz; + + /** 堆内各单体欠温严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体欠温严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtqwyzgjhz; + + /** 堆内各单体过温轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体过温轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtgwqwgjhz; + + /** 堆内各单体过温中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体过温中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtgwzdgjhz; + + /** 堆内各单体过温严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体过温严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtgwyzgjhz; + + /** 堆内各单体温差轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体温差轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtwcqwgjhz; + + /** 堆内各单体温差中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体温差中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtwczdgjhz; + + /** 堆内各单体温差严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体温差严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdtwcyzgjhz; + + /** 堆内各单体 SOC 低轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOC 低轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsocdqwgjhz; + + /** 堆内各单体 SOC 低中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOC 低中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsocdzdgjhz; + + /** 堆内各单体 SOC 低严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOC 低严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsocdyzgjhz; + + /** 堆内各单体 SOC 高轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOC 高轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsocgqwgjhz; + + /** 堆内各单体 SOC 高中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOC 高中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsocgzdgjhz; + + /** 堆内各单体 SOC 高严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOC 高严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsocgyzgjhz; + + /** 堆内各单体 SOH 低轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOH 低轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsohdqwgjhz; + + /** 堆内各单体 SOH 低中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOH 低中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsohdzdgjhz; + + /** 堆内各单体 SOH 低严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOH 低严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsohdyzgjhz; + + /** 堆内各单体 SOH 高轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOH 高轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsohgqwgjhz; + + /** 堆内各单体 SOH 高中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOH 高中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsohgzdgjhz; + + /** 堆内各单体 SOH 高严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各单体 SOH 高严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dtsohgyzgjhz; + + /** 堆内各主控失联汇总(0=正常,1=失联) */ + @Excel(name = "堆内各主控失联汇总", readConverterExp = "0==正常,1=失联") + private Integer dngzkslhz; + + /** 堆内各从控失联告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各从控失联告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngckslgjhz; + + /** 堆内各组电压异常(组间压差大于 20V)(0=正常,1=异常) */ + @Excel(name = "堆内各组电压异常", readConverterExp = "组=间压差大于,2=0V") + private Integer dngzdyyc; + + /** 堆内接触器断开异常(0=正常,1=异常) */ + @Excel(name = "堆内接触器断开异常", readConverterExp = "0==正常,1=异常") + private Integer dnjcqdkyc; + + /** 堆内接触器闭合异常(0=正常,1=异常) */ + @Excel(name = "堆内接触器闭合异常", readConverterExp = "0==正常,1=异常") + private Integer dnjcqbhyc; + + /** 充电禁止(0=允许,1=禁止) */ + @Excel(name = "充电禁止", readConverterExp = "0==允许,1=禁止") + private Integer cdjz; + + /** 放电禁止(0=允许,1=禁止) */ + @Excel(name = "放电禁止", readConverterExp = "0==允许,1=禁止") + private Integer fdjz; + + /** BMS 系统告警汇总(0=无告警,1=有告警) */ + @Excel(name = "BMS 系统告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer bmsxtgjhz; + + /** BMS 系统故障汇总(0=无故障,1=有故障) */ + @Excel(name = "BMS 系统故障汇总", readConverterExp = "0==无故障,1=有故障") + private Integer bmsxtgzhz; + + /** 输入 IN0(0=断开,1=闭合/有效) */ + @Excel(name = "输入 IN0", readConverterExp = "0==断开,1=闭合/有效") + private Integer srin0; + + /** 输入 IN1(0=断开,1=闭合/有效) */ + @Excel(name = "输入 IN1", readConverterExp = "0==断开,1=闭合/有效") + private Integer srin1; + + /** 输入 IN2(0=断开,1=闭合/有效) */ + @Excel(name = "输入 IN2", readConverterExp = "0==断开,1=闭合/有效") + private Integer srin2; + + /** 输入 IN3(0=断开,1=闭合/有效) */ + @Excel(name = "输入 IN3", readConverterExp = "0==断开,1=闭合/有效") + private Integer srin3; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl1; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl2; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl3; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl4; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl5; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl6; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl7; + + /** 预留/reserved */ + @Excel(name = "预留/reserved") + private Integer yl8; + + /** 堆内各端子过温轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各端子过温轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdzgwqwgjhz; + + /** 堆内各端子过温中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各端子过温中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdzgwzdgjhz; + + /** 堆内各端子过温重度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内各端子过温重度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dngdzgwzzdgjhz; + + /** 堆内模块电压过压轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内模块电压过压轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dnmkdygyqwgjhz; + + /** 堆内模块电压过压中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内模块电压过压中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dnmkdygyzdgjhz; + + /** 堆内模块电压过压严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内模块电压过压严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dnmkdygyyzgjhz; + + /** 堆内模块电压欠压轻微告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内模块电压欠压轻微告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dnmkdyqyqwgjhz; + + /** 堆内模块电压欠压中度告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内模块电压欠压中度告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dnmkdyqyzdgjhz; + + /** 堆内模块电压欠压严重告警汇总(0=无告警,1=有告警) */ + @Excel(name = "堆内模块电压欠压严重告警汇总", readConverterExp = "0==无告警,1=有告警") + private Integer dnmkdyqyyzgjhz; + + /** 电压采集失联(0=正常,1=失联) */ + @Excel(name = "电压采集失联", readConverterExp = "0==正常,1=失联") + private Integer dycjsl; + + /** 温度采集失联(0=正常,1=失联) */ + @Excel(name = "温度采集失联", readConverterExp = "0==正常,1=失联") + private Integer wdcjsl; + + /** DIDO-DI0(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI0", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi0; + + /** DIDO-DI1(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI1", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi1; + + /** DIDO-DI2(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI2", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi2; + + /** DIDO-DI3(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI3", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi3; + + /** DIDO-DI4(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI4", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi4; + + /** DIDO-DI5(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI5", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi5; + + /** DIDO-DI6(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI6", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi6; + + /** DIDO-DI7(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI7", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi7; + + /** DIDO-DI8(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI8", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi8; + + /** DIDO-DI9(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI9", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi9; + + /** DIDO-DI10(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI10", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi10; + + /** DIDO-DI11(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI11", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi11; + + /** DIDO-DI12(0=断开,1=闭合/有效) */ + @Excel(name = "DIDO-DI12", readConverterExp = "0==断开,1=闭合/有效") + private Integer didodi12; + + /** 空调-通信失联(0=正常,1=失联) */ + @Excel(name = "空调-通信失联", readConverterExp = "0==正常,1=失联") + private Integer kttxsl; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setDataTimestamp(Date dataTimestamp) + { + this.dataTimestamp = dataTimestamp; + } + + public Date getDataTimestamp() + { + return dataTimestamp; + } + + 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 void setBmsgzzt(Integer bmsgzzt) + { + this.bmsgzzt = bmsgzzt; + } + + public Integer getBmsgzzt() + { + return bmsgzzt; + } + + public void setJczt(Integer jczt) + { + this.jczt = jczt; + } + + public Integer getJczt() + { + return jczt; + } + + public void setJfzt(Integer jfzt) + { + this.jfzt = jfzt; + } + + public Integer getJfzt() + { + return jfzt; + } + + public void setDngzddyqyqdgjhz(Integer dngzddyqyqdgjhz) + { + this.dngzddyqyqdgjhz = dngzddyqyqdgjhz; + } + + public Integer getDngzddyqyqdgjhz() + { + return dngzddyqyqdgjhz; + } + + public void setDngzddyqyzdgjhz(Integer dngzddyqyzdgjhz) + { + this.dngzddyqyzdgjhz = dngzddyqyzdgjhz; + } + + public Integer getDngzddyqyzdgjhz() + { + return dngzddyqyzdgjhz; + } + + public void setDngzddyqyzzdgjhz(Integer dngzddyqyzzdgjhz) + { + this.dngzddyqyzzdgjhz = dngzddyqyzzdgjhz; + } + + public Integer getDngzddyqyzzdgjhz() + { + return dngzddyqyzzdgjhz; + } + + public void setDngzddygyqdgjhz(Integer dngzddygyqdgjhz) + { + this.dngzddygyqdgjhz = dngzddygyqdgjhz; + } + + public Integer getDngzddygyqdgjhz() + { + return dngzddygyqdgjhz; + } + + public void setDngzddygyzdgjhz(Integer dngzddygyzdgjhz) + { + this.dngzddygyzdgjhz = dngzddygyzdgjhz; + } + + public Integer getDngzddygyzdgjhz() + { + return dngzddygyzdgjhz; + } + + public void setDngzddygyzzdgjhz(Integer dngzddygyzzdgjhz) + { + this.dngzddygyzzdgjhz = dngzddygyzzdgjhz; + } + + public Integer getDngzddygyzzdgjhz() + { + return dngzddygyzzdgjhz; + } + + public void setDngzdglqdgjhz(Integer dngzdglqdgjhz) + { + this.dngzdglqdgjhz = dngzdglqdgjhz; + } + + public Integer getDngzdglqdgjhz() + { + return dngzdglqdgjhz; + } + + public void setDngzdglzdgjhz(Integer dngzdglzdgjhz) + { + this.dngzdglzdgjhz = dngzdglzdgjhz; + } + + public Integer getDngzdglzdgjhz() + { + return dngzdglzdgjhz; + } + + public void setDngzdglzzdgjhz(Integer dngzdglzzdgjhz) + { + this.dngzdglzzdgjhz = dngzdglzzdgjhz; + } + + public Integer getDngzdglzzdgjhz() + { + return dngzdglzzdgjhz; + } + + public void setDngzjydzdqdgjhz(Integer dngzjydzdqdgjhz) + { + this.dngzjydzdqdgjhz = dngzjydzdqdgjhz; + } + + public Integer getDngzjydzdqdgjhz() + { + return dngzjydzdqdgjhz; + } + + public void setDngzjydzdzdgjhz(Integer dngzjydzdzdgjhz) + { + this.dngzjydzdzdgjhz = dngzjydzdzdgjhz; + } + + public Integer getDngzjydzdzdgjhz() + { + return dngzjydzdzdgjhz; + } + + public void setDngzjydzdzzdgjhz(Integer dngzjydzdzzdgjhz) + { + this.dngzjydzdzzdgjhz = dngzjydzdzzdgjhz; + } + + public Integer getDngzjydzdzzdgjhz() + { + return dngzjydzdzzdgjhz; + } + + public void setDngzmkqwdqdgjhz(Integer dngzmkqwdqdgjhz) + { + this.dngzmkqwdqdgjhz = dngzmkqwdqdgjhz; + } + + public Integer getDngzmkqwdqdgjhz() + { + return dngzmkqwdqdgjhz; + } + + public void setDngzmkqwdzdgjhz(Integer dngzmkqwdzdgjhz) + { + this.dngzmkqwdzdgjhz = dngzmkqwdzdgjhz; + } + + public Integer getDngzmkqwdzdgjhz() + { + return dngzmkqwdzdgjhz; + } + + public void setDngzmkqwdzzdgjhz(Integer dngzmkqwdzzdgjhz) + { + this.dngzmkqwdzzdgjhz = dngzmkqwdzzdgjhz; + } + + public Integer getDngzmkqwdzzdgjhz() + { + return dngzmkqwdzzdgjhz; + } + + public void setDngzmkgwdqdgjhz(Integer dngzmkgwdqdgjhz) + { + this.dngzmkgwdqdgjhz = dngzmkgwdqdgjhz; + } + + public Integer getDngzmkgwdqdgjhz() + { + return dngzmkgwdqdgjhz; + } + + public void setDngzmkgwdzdgjhz(Integer dngzmkgwdzdgjhz) + { + this.dngzmkgwdzdgjhz = dngzmkgwdzdgjhz; + } + + public Integer getDngzmkgwdzdgjhz() + { + return dngzmkgwdzdgjhz; + } + + public void setDngzmkgwdzzdgjhz(Integer dngzmkgwdzzdgjhz) + { + this.dngzmkgwdzzdgjhz = dngzmkgwdzzdgjhz; + } + + public Integer getDngzmkgwdzzdgjhz() + { + return dngzmkgwdzzdgjhz; + } + + public void setDngdtgyqwgjhz(Integer dngdtgyqwgjhz) + { + this.dngdtgyqwgjhz = dngdtgyqwgjhz; + } + + public Integer getDngdtgyqwgjhz() + { + return dngdtgyqwgjhz; + } + + public void setDngdtgyzdgjhz(Integer dngdtgyzdgjhz) + { + this.dngdtgyzdgjhz = dngdtgyzdgjhz; + } + + public Integer getDngdtgyzdgjhz() + { + return dngdtgyzdgjhz; + } + + public void setDngdtgyyzgjhz(Integer dngdtgyyzgjhz) + { + this.dngdtgyyzgjhz = dngdtgyyzgjhz; + } + + public Integer getDngdtgyyzgjhz() + { + return dngdtgyyzgjhz; + } + + public void setDngdtqyqwgjhz(Integer dngdtqyqwgjhz) + { + this.dngdtqyqwgjhz = dngdtqyqwgjhz; + } + + public Integer getDngdtqyqwgjhz() + { + return dngdtqyqwgjhz; + } + + public void setDngdtqyzdgjhz(Integer dngdtqyzdgjhz) + { + this.dngdtqyzdgjhz = dngdtqyzdgjhz; + } + + public Integer getDngdtqyzdgjhz() + { + return dngdtqyzdgjhz; + } + + public void setDngdtqyyzgjhz(Integer dngdtqyyzgjhz) + { + this.dngdtqyyzgjhz = dngdtqyyzgjhz; + } + + public Integer getDngdtqyyzgjhz() + { + return dngdtqyyzgjhz; + } + + public void setDngdtycqwgjhz(Integer dngdtycqwgjhz) + { + this.dngdtycqwgjhz = dngdtycqwgjhz; + } + + public Integer getDngdtycqwgjhz() + { + return dngdtycqwgjhz; + } + + public void setDngdtyczdgjhz(Integer dngdtyczdgjhz) + { + this.dngdtyczdgjhz = dngdtyczdgjhz; + } + + public Integer getDngdtyczdgjhz() + { + return dngdtyczdgjhz; + } + + public void setDngdtycyzgjhz(Integer dngdtycyzgjhz) + { + this.dngdtycyzgjhz = dngdtycyzgjhz; + } + + public Integer getDngdtycyzgjhz() + { + return dngdtycyzgjhz; + } + + public void setDngdtqwqwgjhz(Integer dngdtqwqwgjhz) + { + this.dngdtqwqwgjhz = dngdtqwqwgjhz; + } + + public Integer getDngdtqwqwgjhz() + { + return dngdtqwqwgjhz; + } + + public void setDngdtqwzdgjhz(Integer dngdtqwzdgjhz) + { + this.dngdtqwzdgjhz = dngdtqwzdgjhz; + } + + public Integer getDngdtqwzdgjhz() + { + return dngdtqwzdgjhz; + } + + public void setDngdtqwyzgjhz(Integer dngdtqwyzgjhz) + { + this.dngdtqwyzgjhz = dngdtqwyzgjhz; + } + + public Integer getDngdtqwyzgjhz() + { + return dngdtqwyzgjhz; + } + + public void setDngdtgwqwgjhz(Integer dngdtgwqwgjhz) + { + this.dngdtgwqwgjhz = dngdtgwqwgjhz; + } + + public Integer getDngdtgwqwgjhz() + { + return dngdtgwqwgjhz; + } + + public void setDngdtgwzdgjhz(Integer dngdtgwzdgjhz) + { + this.dngdtgwzdgjhz = dngdtgwzdgjhz; + } + + public Integer getDngdtgwzdgjhz() + { + return dngdtgwzdgjhz; + } + + public void setDngdtgwyzgjhz(Integer dngdtgwyzgjhz) + { + this.dngdtgwyzgjhz = dngdtgwyzgjhz; + } + + public Integer getDngdtgwyzgjhz() + { + return dngdtgwyzgjhz; + } + + public void setDngdtwcqwgjhz(Integer dngdtwcqwgjhz) + { + this.dngdtwcqwgjhz = dngdtwcqwgjhz; + } + + public Integer getDngdtwcqwgjhz() + { + return dngdtwcqwgjhz; + } + + public void setDngdtwczdgjhz(Integer dngdtwczdgjhz) + { + this.dngdtwczdgjhz = dngdtwczdgjhz; + } + + public Integer getDngdtwczdgjhz() + { + return dngdtwczdgjhz; + } + + public void setDngdtwcyzgjhz(Integer dngdtwcyzgjhz) + { + this.dngdtwcyzgjhz = dngdtwcyzgjhz; + } + + public Integer getDngdtwcyzgjhz() + { + return dngdtwcyzgjhz; + } + + public void setDtsocdqwgjhz(Integer dtsocdqwgjhz) + { + this.dtsocdqwgjhz = dtsocdqwgjhz; + } + + public Integer getDtsocdqwgjhz() + { + return dtsocdqwgjhz; + } + + public void setDtsocdzdgjhz(Integer dtsocdzdgjhz) + { + this.dtsocdzdgjhz = dtsocdzdgjhz; + } + + public Integer getDtsocdzdgjhz() + { + return dtsocdzdgjhz; + } + + public void setDtsocdyzgjhz(Integer dtsocdyzgjhz) + { + this.dtsocdyzgjhz = dtsocdyzgjhz; + } + + public Integer getDtsocdyzgjhz() + { + return dtsocdyzgjhz; + } + + public void setDtsocgqwgjhz(Integer dtsocgqwgjhz) + { + this.dtsocgqwgjhz = dtsocgqwgjhz; + } + + public Integer getDtsocgqwgjhz() + { + return dtsocgqwgjhz; + } + + public void setDtsocgzdgjhz(Integer dtsocgzdgjhz) + { + this.dtsocgzdgjhz = dtsocgzdgjhz; + } + + public Integer getDtsocgzdgjhz() + { + return dtsocgzdgjhz; + } + + public void setDtsocgyzgjhz(Integer dtsocgyzgjhz) + { + this.dtsocgyzgjhz = dtsocgyzgjhz; + } + + public Integer getDtsocgyzgjhz() + { + return dtsocgyzgjhz; + } + + public void setDtsohdqwgjhz(Integer dtsohdqwgjhz) + { + this.dtsohdqwgjhz = dtsohdqwgjhz; + } + + public Integer getDtsohdqwgjhz() + { + return dtsohdqwgjhz; + } + + public void setDtsohdzdgjhz(Integer dtsohdzdgjhz) + { + this.dtsohdzdgjhz = dtsohdzdgjhz; + } + + public Integer getDtsohdzdgjhz() + { + return dtsohdzdgjhz; + } + + public void setDtsohdyzgjhz(Integer dtsohdyzgjhz) + { + this.dtsohdyzgjhz = dtsohdyzgjhz; + } + + public Integer getDtsohdyzgjhz() + { + return dtsohdyzgjhz; + } + + public void setDtsohgqwgjhz(Integer dtsohgqwgjhz) + { + this.dtsohgqwgjhz = dtsohgqwgjhz; + } + + public Integer getDtsohgqwgjhz() + { + return dtsohgqwgjhz; + } + + public void setDtsohgzdgjhz(Integer dtsohgzdgjhz) + { + this.dtsohgzdgjhz = dtsohgzdgjhz; + } + + public Integer getDtsohgzdgjhz() + { + return dtsohgzdgjhz; + } + + public void setDtsohgyzgjhz(Integer dtsohgyzgjhz) + { + this.dtsohgyzgjhz = dtsohgyzgjhz; + } + + public Integer getDtsohgyzgjhz() + { + return dtsohgyzgjhz; + } + + public void setDngzkslhz(Integer dngzkslhz) + { + this.dngzkslhz = dngzkslhz; + } + + public Integer getDngzkslhz() + { + return dngzkslhz; + } + + public void setDngckslgjhz(Integer dngckslgjhz) + { + this.dngckslgjhz = dngckslgjhz; + } + + public Integer getDngckslgjhz() + { + return dngckslgjhz; + } + + public void setDngzdyyc(Integer dngzdyyc) + { + this.dngzdyyc = dngzdyyc; + } + + public Integer getDngzdyyc() + { + return dngzdyyc; + } + + public void setDnjcqdkyc(Integer dnjcqdkyc) + { + this.dnjcqdkyc = dnjcqdkyc; + } + + public Integer getDnjcqdkyc() + { + return dnjcqdkyc; + } + + public void setDnjcqbhyc(Integer dnjcqbhyc) + { + this.dnjcqbhyc = dnjcqbhyc; + } + + public Integer getDnjcqbhyc() + { + return dnjcqbhyc; + } + + public void setCdjz(Integer cdjz) + { + this.cdjz = cdjz; + } + + public Integer getCdjz() + { + return cdjz; + } + + public void setFdjz(Integer fdjz) + { + this.fdjz = fdjz; + } + + public Integer getFdjz() + { + return fdjz; + } + + public void setBmsxtgjhz(Integer bmsxtgjhz) + { + this.bmsxtgjhz = bmsxtgjhz; + } + + public Integer getBmsxtgjhz() + { + return bmsxtgjhz; + } + + public void setBmsxtgzhz(Integer bmsxtgzhz) + { + this.bmsxtgzhz = bmsxtgzhz; + } + + public Integer getBmsxtgzhz() + { + return bmsxtgzhz; + } + + public void setSrin0(Integer srin0) + { + this.srin0 = srin0; + } + + public Integer getSrin0() + { + return srin0; + } + + public void setSrin1(Integer srin1) + { + this.srin1 = srin1; + } + + public Integer getSrin1() + { + return srin1; + } + + public void setSrin2(Integer srin2) + { + this.srin2 = srin2; + } + + public Integer getSrin2() + { + return srin2; + } + + public void setSrin3(Integer srin3) + { + this.srin3 = srin3; + } + + public Integer getSrin3() + { + return srin3; + } + + public void setYl1(Integer yl1) + { + this.yl1 = yl1; + } + + public Integer getYl1() + { + return yl1; + } + + public void setYl2(Integer yl2) + { + this.yl2 = yl2; + } + + public Integer getYl2() + { + return yl2; + } + + public void setYl3(Integer yl3) + { + this.yl3 = yl3; + } + + public Integer getYl3() + { + return yl3; + } + + public void setYl4(Integer yl4) + { + this.yl4 = yl4; + } + + public Integer getYl4() + { + return yl4; + } + + public void setYl5(Integer yl5) + { + this.yl5 = yl5; + } + + public Integer getYl5() + { + return yl5; + } + + public void setYl6(Integer yl6) + { + this.yl6 = yl6; + } + + public Integer getYl6() + { + return yl6; + } + + public void setYl7(Integer yl7) + { + this.yl7 = yl7; + } + + public Integer getYl7() + { + return yl7; + } + + public void setYl8(Integer yl8) + { + this.yl8 = yl8; + } + + public Integer getYl8() + { + return yl8; + } + + public void setDngdzgwqwgjhz(Integer dngdzgwqwgjhz) + { + this.dngdzgwqwgjhz = dngdzgwqwgjhz; + } + + public Integer getDngdzgwqwgjhz() + { + return dngdzgwqwgjhz; + } + + public void setDngdzgwzdgjhz(Integer dngdzgwzdgjhz) + { + this.dngdzgwzdgjhz = dngdzgwzdgjhz; + } + + public Integer getDngdzgwzdgjhz() + { + return dngdzgwzdgjhz; + } + + public void setDngdzgwzzdgjhz(Integer dngdzgwzzdgjhz) + { + this.dngdzgwzzdgjhz = dngdzgwzzdgjhz; + } + + public Integer getDngdzgwzzdgjhz() + { + return dngdzgwzzdgjhz; + } + + public void setDnmkdygyqwgjhz(Integer dnmkdygyqwgjhz) + { + this.dnmkdygyqwgjhz = dnmkdygyqwgjhz; + } + + public Integer getDnmkdygyqwgjhz() + { + return dnmkdygyqwgjhz; + } + + public void setDnmkdygyzdgjhz(Integer dnmkdygyzdgjhz) + { + this.dnmkdygyzdgjhz = dnmkdygyzdgjhz; + } + + public Integer getDnmkdygyzdgjhz() + { + return dnmkdygyzdgjhz; + } + + public void setDnmkdygyyzgjhz(Integer dnmkdygyyzgjhz) + { + this.dnmkdygyyzgjhz = dnmkdygyyzgjhz; + } + + public Integer getDnmkdygyyzgjhz() + { + return dnmkdygyyzgjhz; + } + + public void setDnmkdyqyqwgjhz(Integer dnmkdyqyqwgjhz) + { + this.dnmkdyqyqwgjhz = dnmkdyqyqwgjhz; + } + + public Integer getDnmkdyqyqwgjhz() + { + return dnmkdyqyqwgjhz; + } + + public void setDnmkdyqyzdgjhz(Integer dnmkdyqyzdgjhz) + { + this.dnmkdyqyzdgjhz = dnmkdyqyzdgjhz; + } + + public Integer getDnmkdyqyzdgjhz() + { + return dnmkdyqyzdgjhz; + } + + public void setDnmkdyqyyzgjhz(Integer dnmkdyqyyzgjhz) + { + this.dnmkdyqyyzgjhz = dnmkdyqyyzgjhz; + } + + public Integer getDnmkdyqyyzgjhz() + { + return dnmkdyqyyzgjhz; + } + + public void setDycjsl(Integer dycjsl) + { + this.dycjsl = dycjsl; + } + + public Integer getDycjsl() + { + return dycjsl; + } + + public void setWdcjsl(Integer wdcjsl) + { + this.wdcjsl = wdcjsl; + } + + public Integer getWdcjsl() + { + return wdcjsl; + } + + public void setDidodi0(Integer didodi0) + { + this.didodi0 = didodi0; + } + + public Integer getDidodi0() + { + return didodi0; + } + + public void setDidodi1(Integer didodi1) + { + this.didodi1 = didodi1; + } + + public Integer getDidodi1() + { + return didodi1; + } + + public void setDidodi2(Integer didodi2) + { + this.didodi2 = didodi2; + } + + public Integer getDidodi2() + { + return didodi2; + } + + public void setDidodi3(Integer didodi3) + { + this.didodi3 = didodi3; + } + + public Integer getDidodi3() + { + return didodi3; + } + + public void setDidodi4(Integer didodi4) + { + this.didodi4 = didodi4; + } + + public Integer getDidodi4() + { + return didodi4; + } + + public void setDidodi5(Integer didodi5) + { + this.didodi5 = didodi5; + } + + public Integer getDidodi5() + { + return didodi5; + } + + public void setDidodi6(Integer didodi6) + { + this.didodi6 = didodi6; + } + + public Integer getDidodi6() + { + return didodi6; + } + + public void setDidodi7(Integer didodi7) + { + this.didodi7 = didodi7; + } + + public Integer getDidodi7() + { + return didodi7; + } + + public void setDidodi8(Integer didodi8) + { + this.didodi8 = didodi8; + } + + public Integer getDidodi8() + { + return didodi8; + } + + public void setDidodi9(Integer didodi9) + { + this.didodi9 = didodi9; + } + + public Integer getDidodi9() + { + return didodi9; + } + + public void setDidodi10(Integer didodi10) + { + this.didodi10 = didodi10; + } + + public Integer getDidodi10() + { + return didodi10; + } + + public void setDidodi11(Integer didodi11) + { + this.didodi11 = didodi11; + } + + public Integer getDidodi11() + { + return didodi11; + } + + public void setDidodi12(Integer didodi12) + { + this.didodi12 = didodi12; + } + + public Integer getDidodi12() + { + return didodi12; + } + + public void setKttxsl(Integer kttxsl) + { + this.kttxsl = kttxsl; + } + + public Integer getKttxsl() + { + return kttxsl; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("dataTimestamp", getDataTimestamp()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("bmsgzzt", getBmsgzzt()) + .append("jczt", getJczt()) + .append("jfzt", getJfzt()) + .append("dngzddyqyqdgjhz", getDngzddyqyqdgjhz()) + .append("dngzddyqyzdgjhz", getDngzddyqyzdgjhz()) + .append("dngzddyqyzzdgjhz", getDngzddyqyzzdgjhz()) + .append("dngzddygyqdgjhz", getDngzddygyqdgjhz()) + .append("dngzddygyzdgjhz", getDngzddygyzdgjhz()) + .append("dngzddygyzzdgjhz", getDngzddygyzzdgjhz()) + .append("dngzdglqdgjhz", getDngzdglqdgjhz()) + .append("dngzdglzdgjhz", getDngzdglzdgjhz()) + .append("dngzdglzzdgjhz", getDngzdglzzdgjhz()) + .append("dngzjydzdqdgjhz", getDngzjydzdqdgjhz()) + .append("dngzjydzdzdgjhz", getDngzjydzdzdgjhz()) + .append("dngzjydzdzzdgjhz", getDngzjydzdzzdgjhz()) + .append("dngzmkqwdqdgjhz", getDngzmkqwdqdgjhz()) + .append("dngzmkqwdzdgjhz", getDngzmkqwdzdgjhz()) + .append("dngzmkqwdzzdgjhz", getDngzmkqwdzzdgjhz()) + .append("dngzmkgwdqdgjhz", getDngzmkgwdqdgjhz()) + .append("dngzmkgwdzdgjhz", getDngzmkgwdzdgjhz()) + .append("dngzmkgwdzzdgjhz", getDngzmkgwdzzdgjhz()) + .append("dngdtgyqwgjhz", getDngdtgyqwgjhz()) + .append("dngdtgyzdgjhz", getDngdtgyzdgjhz()) + .append("dngdtgyyzgjhz", getDngdtgyyzgjhz()) + .append("dngdtqyqwgjhz", getDngdtqyqwgjhz()) + .append("dngdtqyzdgjhz", getDngdtqyzdgjhz()) + .append("dngdtqyyzgjhz", getDngdtqyyzgjhz()) + .append("dngdtycqwgjhz", getDngdtycqwgjhz()) + .append("dngdtyczdgjhz", getDngdtyczdgjhz()) + .append("dngdtycyzgjhz", getDngdtycyzgjhz()) + .append("dngdtqwqwgjhz", getDngdtqwqwgjhz()) + .append("dngdtqwzdgjhz", getDngdtqwzdgjhz()) + .append("dngdtqwyzgjhz", getDngdtqwyzgjhz()) + .append("dngdtgwqwgjhz", getDngdtgwqwgjhz()) + .append("dngdtgwzdgjhz", getDngdtgwzdgjhz()) + .append("dngdtgwyzgjhz", getDngdtgwyzgjhz()) + .append("dngdtwcqwgjhz", getDngdtwcqwgjhz()) + .append("dngdtwczdgjhz", getDngdtwczdgjhz()) + .append("dngdtwcyzgjhz", getDngdtwcyzgjhz()) + .append("dtsocdqwgjhz", getDtsocdqwgjhz()) + .append("dtsocdzdgjhz", getDtsocdzdgjhz()) + .append("dtsocdyzgjhz", getDtsocdyzgjhz()) + .append("dtsocgqwgjhz", getDtsocgqwgjhz()) + .append("dtsocgzdgjhz", getDtsocgzdgjhz()) + .append("dtsocgyzgjhz", getDtsocgyzgjhz()) + .append("dtsohdqwgjhz", getDtsohdqwgjhz()) + .append("dtsohdzdgjhz", getDtsohdzdgjhz()) + .append("dtsohdyzgjhz", getDtsohdyzgjhz()) + .append("dtsohgqwgjhz", getDtsohgqwgjhz()) + .append("dtsohgzdgjhz", getDtsohgzdgjhz()) + .append("dtsohgyzgjhz", getDtsohgyzgjhz()) + .append("dngzkslhz", getDngzkslhz()) + .append("dngckslgjhz", getDngckslgjhz()) + .append("dngzdyyc", getDngzdyyc()) + .append("dnjcqdkyc", getDnjcqdkyc()) + .append("dnjcqbhyc", getDnjcqbhyc()) + .append("cdjz", getCdjz()) + .append("fdjz", getFdjz()) + .append("bmsxtgjhz", getBmsxtgjhz()) + .append("bmsxtgzhz", getBmsxtgzhz()) + .append("srin0", getSrin0()) + .append("srin1", getSrin1()) + .append("srin2", getSrin2()) + .append("srin3", getSrin3()) + .append("yl1", getYl1()) + .append("yl2", getYl2()) + .append("yl3", getYl3()) + .append("yl4", getYl4()) + .append("yl5", getYl5()) + .append("yl6", getYl6()) + .append("yl7", getYl7()) + .append("yl8", getYl8()) + .append("dngdzgwqwgjhz", getDngdzgwqwgjhz()) + .append("dngdzgwzdgjhz", getDngdzgwzdgjhz()) + .append("dngdzgwzzdgjhz", getDngdzgwzzdgjhz()) + .append("dnmkdygyqwgjhz", getDnmkdygyqwgjhz()) + .append("dnmkdygyzdgjhz", getDnmkdygyzdgjhz()) + .append("dnmkdygyyzgjhz", getDnmkdygyyzgjhz()) + .append("dnmkdyqyqwgjhz", getDnmkdyqyqwgjhz()) + .append("dnmkdyqyzdgjhz", getDnmkdyqyzdgjhz()) + .append("dnmkdyqyyzgjhz", getDnmkdyqyyzgjhz()) + .append("dycjsl", getDycjsl()) + .append("wdcjsl", getWdcjsl()) + .append("didodi0", getDidodi0()) + .append("didodi1", getDidodi1()) + .append("didodi2", getDidodi2()) + .append("didodi3", getDidodi3()) + .append("didodi4", getDidodi4()) + .append("didodi5", getDidodi5()) + .append("didodi6", getDidodi6()) + .append("didodi7", getDidodi7()) + .append("didodi8", getDidodi8()) + .append("didodi9", getDidodi9()) + .append("didodi10", getDidodi10()) + .append("didodi11", getDidodi11()) + .append("didodi12", getDidodi12()) + .append("kttxsl", getKttxsl()) + .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/mapper/EmsClusterAlarmDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsClusterAlarmDataMapper.java new file mode 100644 index 0000000..b02249c --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsClusterAlarmDataMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsClusterAlarmData; + +/** + * bmsc告警数据Mapper接口 + * + * @author xzzn + * @date 2025-10-22 + */ +public interface EmsClusterAlarmDataMapper +{ + /** + * 查询bmsc告警数据 + * + * @param id bmsc告警数据主键 + * @return bmsc告警数据 + */ + public EmsClusterAlarmData selectEmsClusterAlarmDataById(Long id); + + /** + * 查询bmsc告警数据列表 + * + * @param emsClusterAlarmData bmsc告警数据 + * @return bmsc告警数据集合 + */ + public List selectEmsClusterAlarmDataList(EmsClusterAlarmData emsClusterAlarmData); + + /** + * 新增bmsc告警数据 + * + * @param emsClusterAlarmData bmsc告警数据 + * @return 结果 + */ + public int insertEmsClusterAlarmData(EmsClusterAlarmData emsClusterAlarmData); + + /** + * 修改bmsc告警数据 + * + * @param emsClusterAlarmData bmsc告警数据 + * @return 结果 + */ + public int updateEmsClusterAlarmData(EmsClusterAlarmData emsClusterAlarmData); + + /** + * 删除bmsc告警数据 + * + * @param id bmsc告警数据主键 + * @return 结果 + */ + public int deleteEmsClusterAlarmDataById(Long id); + + /** + * 批量删除bmsc告警数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsClusterAlarmDataByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingAlarmDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingAlarmDataMapper.java new file mode 100644 index 0000000..778354b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsCoolingAlarmDataMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsCoolingAlarmData; + +/** + * ZSLQ告警故障数据Mapper接口 + * + * @author xzzn + * @date 2025-10-22 + */ +public interface EmsCoolingAlarmDataMapper +{ + /** + * 查询ZSLQ告警故障数据 + * + * @param id ZSLQ告警故障数据主键 + * @return ZSLQ告警故障数据 + */ + public EmsCoolingAlarmData selectEmsCoolingAlarmDataById(Long id); + + /** + * 查询ZSLQ告警故障数据列表 + * + * @param emsCoolingAlarmData ZSLQ告警故障数据 + * @return ZSLQ告警故障数据集合 + */ + public List selectEmsCoolingAlarmDataList(EmsCoolingAlarmData emsCoolingAlarmData); + + /** + * 新增ZSLQ告警故障数据 + * + * @param emsCoolingAlarmData ZSLQ告警故障数据 + * @return 结果 + */ + public int insertEmsCoolingAlarmData(EmsCoolingAlarmData emsCoolingAlarmData); + + /** + * 修改ZSLQ告警故障数据 + * + * @param emsCoolingAlarmData ZSLQ告警故障数据 + * @return 结果 + */ + public int updateEmsCoolingAlarmData(EmsCoolingAlarmData emsCoolingAlarmData); + + /** + * 删除ZSLQ告警故障数据 + * + * @param id ZSLQ告警故障数据主键 + * @return 结果 + */ + public int deleteEmsCoolingAlarmDataById(Long id); + + /** + * 批量删除ZSLQ告警故障数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsCoolingAlarmDataByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsAlarmDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsAlarmDataMapper.java new file mode 100644 index 0000000..82b96c7 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsAlarmDataMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsPcsAlarmData; + +/** + * pcs设备告警故障数据Mapper接口 + * + * @author xzzn + * @date 2025-10-22 + */ +public interface EmsPcsAlarmDataMapper +{ + /** + * 查询pcs设备告警故障数据 + * + * @param id pcs设备告警故障数据主键 + * @return pcs设备告警故障数据 + */ + public EmsPcsAlarmData selectEmsPcsAlarmDataById(Long id); + + /** + * 查询pcs设备告警故障数据列表 + * + * @param emsPcsAlarmData pcs设备告警故障数据 + * @return pcs设备告警故障数据集合 + */ + public List selectEmsPcsAlarmDataList(EmsPcsAlarmData emsPcsAlarmData); + + /** + * 新增pcs设备告警故障数据 + * + * @param emsPcsAlarmData pcs设备告警故障数据 + * @return 结果 + */ + public int insertEmsPcsAlarmData(EmsPcsAlarmData emsPcsAlarmData); + + /** + * 修改pcs设备告警故障数据 + * + * @param emsPcsAlarmData pcs设备告警故障数据 + * @return 结果 + */ + public int updateEmsPcsAlarmData(EmsPcsAlarmData emsPcsAlarmData); + + /** + * 删除pcs设备告警故障数据 + * + * @param id pcs设备告警故障数据主键 + * @return 结果 + */ + public int deleteEmsPcsAlarmDataById(Long id); + + /** + * 批量删除pcs设备告警故障数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsPcsAlarmDataByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStackAlarmDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStackAlarmDataMapper.java new file mode 100644 index 0000000..0c398a5 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStackAlarmDataMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsStackAlarmData; + +/** + * bmsd告警数据Mapper接口 + * + * @author xzzn + * @date 2025-10-22 + */ +public interface EmsStackAlarmDataMapper +{ + /** + * 查询bmsd告警数据 + * + * @param id bmsd告警数据主键 + * @return bmsd告警数据 + */ + public EmsStackAlarmData selectEmsStackAlarmDataById(Long id); + + /** + * 查询bmsd告警数据列表 + * + * @param emsStackAlarmData bmsd告警数据 + * @return bmsd告警数据集合 + */ + public List selectEmsStackAlarmDataList(EmsStackAlarmData emsStackAlarmData); + + /** + * 新增bmsd告警数据 + * + * @param emsStackAlarmData bmsd告警数据 + * @return 结果 + */ + public int insertEmsStackAlarmData(EmsStackAlarmData emsStackAlarmData); + + /** + * 修改bmsd告警数据 + * + * @param emsStackAlarmData bmsd告警数据 + * @return 结果 + */ + public int updateEmsStackAlarmData(EmsStackAlarmData emsStackAlarmData); + + /** + * 删除bmsd告警数据 + * + * @param id bmsd告警数据主键 + * @return 结果 + */ + public int deleteEmsStackAlarmDataById(Long id); + + /** + * 批量删除bmsd告警数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsStackAlarmDataByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IFXXAlarmDataProcessService.java b/ems-system/src/main/java/com/xzzn/ems/service/IFXXAlarmDataProcessService.java new file mode 100644 index 0000000..ad949e1 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IFXXAlarmDataProcessService.java @@ -0,0 +1,6 @@ +package com.xzzn.ems.service; + +public interface IFXXAlarmDataProcessService { + + public void handleFxAlarmData(String message); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java b/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java index bdf80fb..c9610c7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IFXXDataProcessService.java @@ -3,6 +3,4 @@ package com.xzzn.ems.service; public interface IFXXDataProcessService { public void handleFxData(String message); - - public void handleFxAlarmData(String message); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXAlarmDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXAlarmDataProcessServiceImpl.java new file mode 100644 index 0000000..fc20b79 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXAlarmDataProcessServiceImpl.java @@ -0,0 +1,634 @@ +package com.xzzn.ems.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.alibaba.fastjson2.TypeReference; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.*; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.MapUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.*; +import com.xzzn.ems.mapper.EmsClusterAlarmDataMapper; +import com.xzzn.ems.mapper.EmsCoolingAlarmDataMapper; +import com.xzzn.ems.mapper.EmsPcsAlarmDataMapper; +import com.xzzn.ems.mapper.EmsStackAlarmDataMapper; +import com.xzzn.ems.service.IEmsAlarmRecordsService; +import com.xzzn.ems.service.IFXXAlarmDataProcessService; +import com.xzzn.ems.utils.AbstractBatteryDataProcessor; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Service +public class FXXAlarmDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXAlarmDataProcessService { + private static final Log log = LogFactory.getLog(FXXAlarmDataProcessServiceImpl.class); + private static final String SITE_ID = "021_FXX_01"; + + @Autowired + private RedisCache redisCache; + + @Autowired + private IEmsAlarmRecordsService iEmsAlarmRecordsService; + @Autowired + private EmsCoolingAlarmDataMapper emsCoolingAlarmDataMapper; + @Autowired + private EmsStackAlarmDataMapper emsStackAlarmDataMapper; + @Autowired + private EmsClusterAlarmDataMapper emsClusterAlarmDataMapper; + @Autowired + private EmsPcsAlarmDataMapper emsPcsAlarmDataMapper; + + // 构造方法(调用父类构造) + public FXXAlarmDataProcessServiceImpl(ObjectMapper objectMapper) { + super(objectMapper); + } + + @Override + public void handleFxAlarmData(String message) { + JSONArray arraylist = JSONArray.parseArray(message); + + // 获取redis缓存-告警信息 + Map alarmMatchInfo= redisCache.getCacheObject(RedisKeyConstants.ALARM_MATCH_INFO); + + for (int i = 0; i < arraylist.size(); i++) { + JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); + + String deviceId = obj.get("Device").toString(); + String jsonData = obj.get("Data").toString(); + Long timestamp = Long.valueOf(obj.get("timestamp").toString()); + Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); + + log.info("deviceId:" + deviceId); + String deviceCategory = ""; + if (deviceId.contains("ZSLQ")) { + coolingDataProcess(deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains("BMSD")) { + deviceCategory = DeviceCategory.STACK.getCode(); + stackDataProcess(deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains("BMSC")) { + deviceCategory = DeviceCategory.CLUSTER.getCode(); + clusterDataProcess(deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains("PCS")) { + deviceCategory = DeviceCategory.PCS.getCode(); + pcsDataProcess(deviceId, jsonData, dataUpdateTime); + } + if (StringUtils.isEmpty(deviceCategory)) { + // 处理告警信息 + alarmDataProcess(deviceId, jsonData, alarmMatchInfo, deviceCategory); + } + } + } + + private void pcsDataProcess(String deviceId, String jsonData, Date dataUpdateTime) { + //中水冷却 + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + EmsPcsAlarmData pcsAlarmData = new EmsPcsAlarmData(); + // 更新时间 + pcsAlarmData.setDataTimestamp(dataUpdateTime); + + // 告警字段 + pcsAlarmData.setYljzyc(MapUtils.getInteger(obj, "YLJZYC")); + pcsAlarmData.setZlkgSmyc(MapUtils.getInteger(obj, "ZLKGSMYC")); + pcsAlarmData.setJlkgSmyc(MapUtils.getInteger(obj, "JLKGSMYC")); + pcsAlarmData.setZlfjsmyc(MapUtils.getInteger(obj, "ZLFJSMYC")); + pcsAlarmData.setJlfjsmyc(MapUtils.getInteger(obj, "JLFJSMYC")); + pcsAlarmData.setGjz2(MapUtils.getInteger(obj, "GJZ2")); + pcsAlarmData.setGzz2(MapUtils.getInteger(obj, "GZZ2")); + pcsAlarmData.setSrqgwgj(MapUtils.getInteger(obj, "SRQGWGJ")); + pcsAlarmData.setDgfjyc(MapUtils.getInteger(obj, "DGFJYC")); + pcsAlarmData.setBmsgj(MapUtils.getInteger(obj, "BMSGJ")); + pcsAlarmData.setBmsdj(MapUtils.getInteger(obj, "BMSDJ")); + pcsAlarmData.setBmsjf(MapUtils.getInteger(obj, "BMSJF")); + pcsAlarmData.setBmsjc(MapUtils.getInteger(obj, "BMSJC")); + pcsAlarmData.setBmsgjdyc(MapUtils.getInteger(obj, "BMSGJDYC")); + pcsAlarmData.setBmstxyc(MapUtils.getInteger(obj, "BMSTXYC")); + pcsAlarmData.setBmsxtgz(MapUtils.getInteger(obj, "BMSXTGZ")); + pcsAlarmData.setZldhmktxyc(MapUtils.getInteger(obj, "ZLDHMKTXYC")); + pcsAlarmData.setGzgJ(MapUtils.getInteger(obj, "GZGJ")); + pcsAlarmData.setDcdybfhcdtj(MapUtils.getInteger(obj, "DCDYBFHCDTJ")); + pcsAlarmData.setDcfj(MapUtils.getInteger(obj, "DCFJ")); + pcsAlarmData.setWbfjyc(MapUtils.getInteger(obj, "WBFJYC")); + pcsAlarmData.setDcdygj(MapUtils.getInteger(obj, "DCDYGJ")); + pcsAlarmData.setDczzqy(MapUtils.getInteger(obj, "DCZZQY")); + pcsAlarmData.setZlbxsyc(MapUtils.getInteger(obj, "ZLBXSYC")); + pcsAlarmData.setNbfjyc(MapUtils.getInteger(obj, "NBFJYC")); + pcsAlarmData.setDlbh(MapUtils.getInteger(obj, "DLBH")); + pcsAlarmData.setGzbh(MapUtils.getInteger(obj, "GZBH")); + pcsAlarmData.setScdybfhlwtj(MapUtils.getInteger(obj, "SCDYBFHLWTJ")); + pcsAlarmData.setScdyyc(MapUtils.getInteger(obj, "SCDYYC")); + pcsAlarmData.setZlgl(MapUtils.getInteger(obj, "ZLGL")); + pcsAlarmData.setDcqzqy(MapUtils.getInteger(obj, "DCQZQY")); + pcsAlarmData.setDcgy(MapUtils.getInteger(obj, "DCGY")); + pcsAlarmData.setGlmkgwgJ(MapUtils.getInteger(obj, "GLMKGWGJ")); + pcsAlarmData.setDwgqpdjgj(MapUtils.getInteger(obj, "DWGQPDJGJ")); + pcsAlarmData.setKkhrqyc(MapUtils.getInteger(obj, "KKHRQYC")); + pcsAlarmData.setBmsjt(MapUtils.getInteger(obj, "BMSJT")); + pcsAlarmData.setBwjdvc(MapUtils.getInteger(obj, "BWJDYC")); + pcsAlarmData.setJljdvc(MapUtils.getInteger(obj, "JLJDYC")); + pcsAlarmData.setFjjdvc(MapUtils.getInteger(obj, "FJJDYC")); + pcsAlarmData.setZjjdvc(MapUtils.getInteger(obj, "ZJJDYC")); + pcsAlarmData.setDgwdkgwc(MapUtils.getInteger(obj, "DGWDKGYC")); + pcsAlarmData.setFybyqwdkgwc(MapUtils.getInteger(obj, "FYBYQWDKGYC")); + pcsAlarmData.setWbwdkgwc(MapUtils.getInteger(obj, "WBWDKGYC")); + pcsAlarmData.setSrqwdkgwc(MapUtils.getInteger(obj, "SRQWDKGYC")); + pcsAlarmData.setZlfjyc(MapUtils.getInteger(obj, "ZLFJYC")); + pcsAlarmData.setGdycyyx(MapUtils.getInteger(obj, "GDYCYYX")); + pcsAlarmData.setDdycyyx(MapUtils.getInteger(obj, "DDYCYYX")); + pcsAlarmData.setDwdybphgj(MapUtils.getInteger(obj, "DWDYBPHGJ")); + pcsAlarmData.setXtcsbpp(MapUtils.getInteger(obj, "XTCSBPP")); + pcsAlarmData.setZlblmsszcw(MapUtils.getInteger(obj, "ZLBLMSSZCW")); + pcsAlarmData.setGjz(MapUtils.getInteger(obj, "GJZ")); + pcsAlarmData.setGzz(MapUtils.getInteger(obj, "GZZ")); + pcsAlarmData.setYctxyc(MapUtils.getInteger(obj, "YCTXYC")); + pcsAlarmData.setHmi485txyc(MapUtils.getInteger(obj, "HMI485TXYC")); + pcsAlarmData.setJxszcw(MapUtils.getInteger(obj, "JXSZCW")); + pcsAlarmData.setHmictxyc(MapUtils.getInteger(obj, "HMICTXYC")); + pcsAlarmData.setBjtxyc(MapUtils.getInteger(obj, "BJTXYC")); + pcsAlarmData.setYwgj(MapUtils.getInteger(obj, "YWGJ")); + pcsAlarmData.setZlzjcqyc(MapUtils.getInteger(obj, "ZLZJCQYC")); + pcsAlarmData.setLxgl(MapUtils.getInteger(obj, "LXGL")); + pcsAlarmData.setZldhyc(MapUtils.getInteger(obj, "ZLDHYC")); + pcsAlarmData.setTbctxvc(MapUtils.getInteger(obj, "TBCTXYC")); + pcsAlarmData.setBjtxxyc(MapUtils.getInteger(obj, "BJTXXYC")); + pcsAlarmData.setXxgxctxvc(MapUtils.getInteger(obj, "XXGXCTXYC")); + pcsAlarmData.setIdct(MapUtils.getInteger(obj, "IDCT")); + pcsAlarmData.setQdyc(MapUtils.getInteger(obj, "QDYC")); + pcsAlarmData.setNbyjgl(MapUtils.getInteger(obj, "NBYJGL")); + pcsAlarmData.setZndbtxyc(MapUtils.getInteger(obj, "ZNDBTXYC")); + pcsAlarmData.setZlflqyc(MapUtils.getInteger(obj, "ZLFLQYC")); + pcsAlarmData.setSxyc(MapUtils.getInteger(obj, "SXYC")); + pcsAlarmData.setMjgj(MapUtils.getInteger(obj, "MJGJ")); + pcsAlarmData.setLpjzyc(MapUtils.getInteger(obj, "LPJZYC")); + pcsAlarmData.setMxdlgl(MapUtils.getInteger(obj, "MXDLGL")); + pcsAlarmData.setMxdbyfhkjtj(MapUtils.getInteger(obj, "MXDYBFHKJTJ")); + pcsAlarmData.setWbjt(MapUtils.getInteger(obj, "WBJT")); + pcsAlarmData.setNbjt(MapUtils.getInteger(obj, "NBJT")); + pcsAlarmData.setJlflqyc(MapUtils.getInteger(obj, "JLFLQYC")); + pcsAlarmData.setRjhjyc(MapUtils.getInteger(obj, "RJHJYC")); + pcsAlarmData.setJlrqdyc(MapUtils.getInteger(obj, "JLRQDYC")); + pcsAlarmData.setJngw(MapUtils.getInteger(obj, "JNGW")); + pcsAlarmData.setNbyc(MapUtils.getInteger(obj, "NBYC")); + pcsAlarmData.setWdkgwc(MapUtils.getInteger(obj, "WDKGYC")); + pcsAlarmData.setJlkgwc(MapUtils.getInteger(obj, "JLKGYC")); + pcsAlarmData.setJlfjyc(MapUtils.getInteger(obj, "JLFJYC")); + pcsAlarmData.setZlkgwc(MapUtils.getInteger(obj, "ZLKGYC")); + pcsAlarmData.setZlrqdyc(MapUtils.getInteger(obj, "ZLRQDYC")); + pcsAlarmData.setNbrjgl(MapUtils.getInteger(obj, "NBRJGL")); + pcsAlarmData.setDwxxyc(MapUtils.getInteger(obj, "DWXXYC")); + pcsAlarmData.setGlmkgw(MapUtils.getInteger(obj, "GLMKGW")); + pcsAlarmData.setDwqpyc(MapUtils.getInteger(obj, "DWQPYC")); + pcsAlarmData.setDwgpyc(MapUtils.getInteger(obj, "DWGPYC")); + pcsAlarmData.setDwqyyc(MapUtils.getInteger(obj, "DWQYYC")); + pcsAlarmData.setDwgyyc(MapUtils.getInteger(obj, "DWGYYC")); + pcsAlarmData.setZlgv(MapUtils.getInteger(obj, "ZLGY")); + pcsAlarmData.setJlllyc(MapUtils.getInteger(obj, "JLLDLYC")); + pcsAlarmData.setJyzkyc(MapUtils.getInteger(obj, "JYZKYC")); + pcsAlarmData.setGzbz(MapUtils.getInteger(obj, "GZBZ")); + pcsAlarmData.setCreateBy("system"); + pcsAlarmData.setCreateTime(DateUtils.getNowDate()); + pcsAlarmData.setUpdateBy("system"); + pcsAlarmData.setUpdateTime(DateUtils.getNowDate()); + pcsAlarmData.setSiteId(SITE_ID); + pcsAlarmData.setDeviceId(deviceId); + emsPcsAlarmDataMapper.insertEmsPcsAlarmData(pcsAlarmData); + } + + private void stackDataProcess(String deviceId, String jsonData, Date dataUpdateTime) { + // bmsd + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + EmsStackAlarmData stackAlarmData = new EmsStackAlarmData(); + // 更新时间 + stackAlarmData.setDataTimestamp(dataUpdateTime); + + // 告警字段 + stackAlarmData.setKttxsl(MapUtils.getInteger(obj, "KTTXSL")); + stackAlarmData.setDidodi12(MapUtils.getInteger(obj, "DIDODI12")); + stackAlarmData.setDidodi11(MapUtils.getInteger(obj, "DIDODI11")); + stackAlarmData.setDidodi10(MapUtils.getInteger(obj, "DIDODI10")); + stackAlarmData.setDidodi9(MapUtils.getInteger(obj, "DIDODI9")); + stackAlarmData.setDidodi8(MapUtils.getInteger(obj, "DIDODI8")); + stackAlarmData.setDidodi7(MapUtils.getInteger(obj, "DIDODI7")); + stackAlarmData.setDidodi6(MapUtils.getInteger(obj, "DIDODI6")); + stackAlarmData.setDidodi5(MapUtils.getInteger(obj, "DIDODI5")); + stackAlarmData.setDidodi4(MapUtils.getInteger(obj, "DIDODI4")); + stackAlarmData.setDidodi3(MapUtils.getInteger(obj, "DIDODI3")); + stackAlarmData.setDidodi2(MapUtils.getInteger(obj, "DIDODI2")); + stackAlarmData.setDidodi1(MapUtils.getInteger(obj, "DIDODI1")); + stackAlarmData.setDidodi0(MapUtils.getInteger(obj, "DIDODI0")); + stackAlarmData.setWdcjsl(MapUtils.getInteger(obj, "WDCJSL")); + stackAlarmData.setDycjsl(MapUtils.getInteger(obj, "DYCJSL")); + stackAlarmData.setDnmkdyqyyzgjhz(MapUtils.getInteger(obj, "DNMKDYQYYZGJHZ")); + stackAlarmData.setDnmkdyqyzdgjhz(MapUtils.getInteger(obj, "DNMKDYQYZDGJHZ")); + stackAlarmData.setDnmkdyqyqwgjhz(MapUtils.getInteger(obj, "DNMKDYQYQWGJHZ")); + stackAlarmData.setDnmkdygyyzgjhz(MapUtils.getInteger(obj, "DNMKDYGYYZGJHZ")); + stackAlarmData.setDnmkdygyzdgjhz(MapUtils.getInteger(obj, "DNMKDYGYZDGJHZ")); + stackAlarmData.setDnmkdygyqwgjhz(MapUtils.getInteger(obj, "DNMKDYGYQWGJHZ")); + stackAlarmData.setDngdzgwzzdgjhz(MapUtils.getInteger(obj, "DNGDZGWZZDGJHZ")); + stackAlarmData.setDngdzgwzdgjhz(MapUtils.getInteger(obj, "DNGDZGWZDGJHZ")); + stackAlarmData.setDngdzgwqwgjhz(MapUtils.getInteger(obj, "DNGDZGWQWGJHZ")); + stackAlarmData.setYl8(MapUtils.getInteger(obj, "YL8")); + stackAlarmData.setYl7(MapUtils.getInteger(obj, "YL7")); + stackAlarmData.setYl6(MapUtils.getInteger(obj, "YL6")); + stackAlarmData.setYl5(MapUtils.getInteger(obj, "YL5")); + stackAlarmData.setYl4(MapUtils.getInteger(obj, "YL4")); + stackAlarmData.setYl3(MapUtils.getInteger(obj, "YL3")); + stackAlarmData.setYl2(MapUtils.getInteger(obj, "YL2")); + stackAlarmData.setYl1(MapUtils.getInteger(obj, "YL1")); + stackAlarmData.setSrin3(MapUtils.getInteger(obj, "SRIN3")); + stackAlarmData.setSrin2(MapUtils.getInteger(obj, "SRIN2")); + stackAlarmData.setSrin1(MapUtils.getInteger(obj, "SRIN1")); + stackAlarmData.setSrin0(MapUtils.getInteger(obj, "SRIN0")); + stackAlarmData.setBmsxtgzhz(MapUtils.getInteger(obj, "BMSXTGZHZ")); + stackAlarmData.setBmsxtgjhz(MapUtils.getInteger(obj, "BMSXTGJHZ")); + stackAlarmData.setFdjz(MapUtils.getInteger(obj, "FDJZ")); + stackAlarmData.setCdjz(MapUtils.getInteger(obj, "CDJZ")); + stackAlarmData.setDnjcqbhyc(MapUtils.getInteger(obj, "DNJCQBHYC")); + stackAlarmData.setDnjcqdkyc(MapUtils.getInteger(obj, "DNJCQDKYC")); + stackAlarmData.setDngzdyyc(MapUtils.getInteger(obj, "DNGZDYYC")); + stackAlarmData.setDngckslgjhz(MapUtils.getInteger(obj, "DNGCKSLGJHZ")); + stackAlarmData.setDngzkslhz(MapUtils.getInteger(obj, "DNGZKSLHZ")); + stackAlarmData.setDtsohgyzgjhz(MapUtils.getInteger(obj, "DTSOHGYZGJHZ")); + stackAlarmData.setDtsohgzdgjhz(MapUtils.getInteger(obj, "DTSOHGZDGJHZ")); + stackAlarmData.setDtsohgqwgjhz(MapUtils.getInteger(obj, "DTSOHGQWGJHZ")); + stackAlarmData.setDtsohdyzgjhz(MapUtils.getInteger(obj, "DTSOHDYZGJHZ")); + stackAlarmData.setDtsohdzdgjhz(MapUtils.getInteger(obj, "DTSOHDZDGJHZ")); + stackAlarmData.setDtsohdqwgjhz(MapUtils.getInteger(obj, "DTSOHDQWGJHZ")); + stackAlarmData.setDtsocgyzgjhz(MapUtils.getInteger(obj, "DTSOCGYZGJHZ")); + stackAlarmData.setDtsocgzdgjhz(MapUtils.getInteger(obj, "DTSOCGZDGJHZ")); + stackAlarmData.setDtsocgqwgjhz(MapUtils.getInteger(obj, "DTSOCGQWGJHZ")); + stackAlarmData.setDtsocdyzgjhz(MapUtils.getInteger(obj, "DTSOCDYZGJHZ")); + stackAlarmData.setDtsocdzdgjhz(MapUtils.getInteger(obj, "DTSOCDZDGJHZ")); + stackAlarmData.setDtsocdqwgjhz(MapUtils.getInteger(obj, "DTSOCDQWGJHZ")); + stackAlarmData.setDngdtwcyzgjhz(MapUtils.getInteger(obj, "DNGDTWCYZGJHZ")); + stackAlarmData.setDngdtwczdgjhz(MapUtils.getInteger(obj, "DNGDTWCZDGJHZ")); + stackAlarmData.setDngdtwcqwgjhz(MapUtils.getInteger(obj, "DNGDTWCQWGJHZ")); + stackAlarmData.setDngdtgwyzgjhz(MapUtils.getInteger(obj, "DNGDTGWYZGJHZ")); + stackAlarmData.setDngdtgwzdgjhz(MapUtils.getInteger(obj, "DNGDTGWZDGJHZ")); + stackAlarmData.setDngdtgwqwgjhz(MapUtils.getInteger(obj, "DNGDTGWQWGJHZ")); + stackAlarmData.setDngdtqwyzgjhz(MapUtils.getInteger(obj, "DNGDTQWYZGJHZ")); + stackAlarmData.setDngdtqwzdgjhz(MapUtils.getInteger(obj, "DNGDTQWZDGJHZ")); + stackAlarmData.setDngdtqwqwgjhz(MapUtils.getInteger(obj, "DNGDTQWQWGJHZ")); + stackAlarmData.setDngdtycyzgjhz(MapUtils.getInteger(obj, "DNGDTYCYZGJHZ")); + stackAlarmData.setDngdtyczdgjhz(MapUtils.getInteger(obj, "DNGDTYCZDGJHZ")); + stackAlarmData.setDngdtycqwgjhz(MapUtils.getInteger(obj, "DNGDTYCQWGJHZ")); + stackAlarmData.setDngdtqyyzgjhz(MapUtils.getInteger(obj, "DNGDTQYYZGJHZ")); + stackAlarmData.setDngdtqyzdgjhz(MapUtils.getInteger(obj, "DNGDTQYZDGJHZ")); + stackAlarmData.setDngdtqyqwgjhz(MapUtils.getInteger(obj, "DNGDTQYQWGJHZ")); + stackAlarmData.setDngdtgyyzgjhz(MapUtils.getInteger(obj, "DNGDTGYYZGJHZ")); + stackAlarmData.setDngdtgyzdgjhz(MapUtils.getInteger(obj, "DNGDTGYZDGJHZ")); + stackAlarmData.setDngdtgyqwgjhz(MapUtils.getInteger(obj, "DNGDTGYQWGJHZ")); + stackAlarmData.setDngzmkgwdzzdgjhz(MapUtils.getInteger(obj, "DNGZMKGWDZZDGJHZ")); + stackAlarmData.setDngzmkgwdzdgjhz(MapUtils.getInteger(obj, "DNGZMKGWDZDGJHZ")); + stackAlarmData.setDngzmkgwdqdgjhz(MapUtils.getInteger(obj, "DNGZMKGWDQDGJHZ")); + stackAlarmData.setDngzmkqwdzzdgjhz(MapUtils.getInteger(obj, "DNGZMKQWDZZDGJHZ")); + stackAlarmData.setDngzmkqwdzdgjhz(MapUtils.getInteger(obj, "DNGZMKQWDZDGJHZ")); + stackAlarmData.setDngzmkqwdqdgjhz(MapUtils.getInteger(obj, "DNGZMKQWDQDGJHZ")); + stackAlarmData.setDngzjydzdzzdgjhz(MapUtils.getInteger(obj, "DNGZJYDZDZZDGJHZ")); + stackAlarmData.setDngzjydzdzdgjhz(MapUtils.getInteger(obj, "DNGZJYDZDZDGJHZ")); + stackAlarmData.setDngzjydzdqdgjhz(MapUtils.getInteger(obj, "DNGZJYDZDQDGJHZ")); + stackAlarmData.setDngzdglzzdgjhz(MapUtils.getInteger(obj, "DNGZDGLZZDGJHZ")); + stackAlarmData.setDngzdglzdgjhz(MapUtils.getInteger(obj, "DNGZDGLZDGJHZ")); + stackAlarmData.setDngzdglqdgjhz(MapUtils.getInteger(obj, "DNGZDGLQDGJHZ")); + stackAlarmData.setDngzddygyzzdgjhz(MapUtils.getInteger(obj, "DNGZDDYGYZZDGJHZ")); + stackAlarmData.setDngzddygyzdgjhz(MapUtils.getInteger(obj, "DNGZDDYGYZDGJHZ")); + stackAlarmData.setDngzddygyqdgjhz(MapUtils.getInteger(obj, "DNGZDDYGYQDGJHZ")); + stackAlarmData.setDngzddyqyzzdgjhz(MapUtils.getInteger(obj, "DNGZDDYQYZZDGJHZ")); + stackAlarmData.setDngzddyqyzdgjhz(MapUtils.getInteger(obj, "DNGZDDYQYZDGJHZ")); + stackAlarmData.setDngzddyqyqdgjhz(MapUtils.getInteger(obj, "DNGZDDYQYQDGJHZ")); + stackAlarmData.setJfzt(MapUtils.getInteger(obj, "JFZT")); + stackAlarmData.setJczt(MapUtils.getInteger(obj, "JCZT")); + stackAlarmData.setBmsgzzt(MapUtils.getInteger(obj, "BMSGZZT")); + + stackAlarmData.setCreateBy("system"); + stackAlarmData.setCreateTime(DateUtils.getNowDate()); + stackAlarmData.setUpdateBy("system"); + stackAlarmData.setUpdateTime(DateUtils.getNowDate()); + stackAlarmData.setSiteId(SITE_ID); + stackAlarmData.setDeviceId(deviceId); + emsStackAlarmDataMapper.insertEmsStackAlarmData(stackAlarmData); + } + + private void clusterDataProcess(String deviceId, String jsonData, Date dataUpdateTime) { + // bmsc + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + EmsClusterAlarmData clusterAlarmData = new EmsClusterAlarmData(); + // 更新时间 + clusterAlarmData.setDataTimestamp(dataUpdateTime); + + // 告警字段 + clusterAlarmData.setC1wdcjgz(MapUtils.getInteger(obj, "C1WDCJGZ")); + clusterAlarmData.setC1dycjgz(MapUtils.getInteger(obj, "C1DYCJGZ")); + clusterAlarmData.setC1mkdygdzzdgj(MapUtils.getInteger(obj, "C1MKDYGDZZDGJ")); + clusterAlarmData.setC1mkdygdzdgj(MapUtils.getInteger(obj, "C1MKDYGDZDGJ")); + clusterAlarmData.setC1mkdygdqdgj(MapUtils.getInteger(obj, "C1MKDYGDQDGJ")); + clusterAlarmData.setC1mkdyggzzdgj(MapUtils.getInteger(obj, "C1MKDYGGZZDGJ")); + clusterAlarmData.setC1mkdyggzdgj(MapUtils.getInteger(obj, "C1MKDYGGZDGJ")); + clusterAlarmData.setC1mkdyggqdgj(MapUtils.getInteger(obj, "C1MKDYGGQDGJ")); + clusterAlarmData.setC1dzwdggzzdgj(MapUtils.getInteger(obj, "C1DZWDGGZZDGJ")); + clusterAlarmData.setC1dzwdggzdgj(MapUtils.getInteger(obj, "C1DZWDGGZDGJ")); + clusterAlarmData.setC1dzwdggqdgj(MapUtils.getInteger(obj, "C1DZWDGGQDGJ")); + clusterAlarmData.setC1ck40txsl(MapUtils.getInteger(obj, "C1CK40TXSL")); + clusterAlarmData.setC1ck39txsl(MapUtils.getInteger(obj, "C1CK39TXSL")); + clusterAlarmData.setC1ck38txsl(MapUtils.getInteger(obj, "C1CK38TXSL")); + clusterAlarmData.setC1ck37txsl(MapUtils.getInteger(obj, "C1CK37TXSL")); + clusterAlarmData.setC1ck36txsl(MapUtils.getInteger(obj, "C1CK36TXSL")); + clusterAlarmData.setC1ck35txsl(MapUtils.getInteger(obj, "C1CK35TXSL")); + clusterAlarmData.setC1ck34txsl(MapUtils.getInteger(obj, "C1CK34TXSL")); + clusterAlarmData.setC1ck33txsl(MapUtils.getInteger(obj, "C1CK33TXSL")); + clusterAlarmData.setC1ck32txsl(MapUtils.getInteger(obj, "C1CK32TXSL")); + clusterAlarmData.setC1ck31txsl(MapUtils.getInteger(obj, "C1CK31TXSL")); + clusterAlarmData.setC1ck30txsl(MapUtils.getInteger(obj, "C1CK30TXSL")); + clusterAlarmData.setC1ck29txsl(MapUtils.getInteger(obj, "C1CK29TXSL")); + clusterAlarmData.setC1ck28txsl(MapUtils.getInteger(obj, "C1CK28TXSL")); + clusterAlarmData.setC1ck27txsl(MapUtils.getInteger(obj, "C1CK27TXSL")); + clusterAlarmData.setC1ck26txsl(MapUtils.getInteger(obj, "C1CK26TXSL")); + clusterAlarmData.setC1ck25txsl(MapUtils.getInteger(obj, "C1CK25TXSL")); + clusterAlarmData.setC1ck24txsl(MapUtils.getInteger(obj, "C1CK24TXSL")); + clusterAlarmData.setC1ck23txsl(MapUtils.getInteger(obj, "C1CK23TXSL")); + clusterAlarmData.setC1ck22txsl(MapUtils.getInteger(obj, "C1CK22TXSL")); + clusterAlarmData.setC1ck21txsl(MapUtils.getInteger(obj, "C1CK21TXSL")); + clusterAlarmData.setC1ck20txsl(MapUtils.getInteger(obj, "C1CK20TXSL")); + clusterAlarmData.setC1ck19txsl(MapUtils.getInteger(obj, "C1CK19TXSL")); + clusterAlarmData.setC1ck18txsl(MapUtils.getInteger(obj, "C1CK18TXSL")); + clusterAlarmData.setC1ck17txsl(MapUtils.getInteger(obj, "C1CK17TXSL")); + clusterAlarmData.setC1ck16txsl(MapUtils.getInteger(obj, "C1CK16TXSL")); + clusterAlarmData.setC1ck15txsl(MapUtils.getInteger(obj, "C1CK15TXSL")); + clusterAlarmData.setC1ck14txsl(MapUtils.getInteger(obj, "C1CK14TXSL")); + clusterAlarmData.setC1ck13txsl(MapUtils.getInteger(obj, "C1CK13TXSL")); + clusterAlarmData.setC1ck12txsl(MapUtils.getInteger(obj, "C1CK12TXSL")); + clusterAlarmData.setC1ck11txsl(MapUtils.getInteger(obj, "C1CK11TXSL")); + clusterAlarmData.setC1ck10txsl(MapUtils.getInteger(obj, "C1CK10TXSL")); + clusterAlarmData.setC1ck9txsl(MapUtils.getInteger(obj, "C1CK9TXSL")); + clusterAlarmData.setC1ck8txsl(MapUtils.getInteger(obj, "C1CK8TXSL")); + clusterAlarmData.setC1ck7txsl(MapUtils.getInteger(obj, "C1CK7TXSL")); + clusterAlarmData.setC1ck6txsl(MapUtils.getInteger(obj, "C1CK6TXSL")); + clusterAlarmData.setC1ck5txsl(MapUtils.getInteger(obj, "C1CK5TXSL")); + clusterAlarmData.setC1ck4txsl(MapUtils.getInteger(obj, "C1CK4TXSL")); + clusterAlarmData.setC1ck3txsl(MapUtils.getInteger(obj, "C1CK3TXSL")); + clusterAlarmData.setC1ck2txsl(MapUtils.getInteger(obj, "C1CK2TXSL")); + clusterAlarmData.setC1ck1txsl(MapUtils.getInteger(obj, "C1CK1TXSL")); + clusterAlarmData.setC1dtwczzdgj(MapUtils.getInteger(obj, "C1DTWCZZDGJ")); + clusterAlarmData.setC1dtwczdgj(MapUtils.getInteger(obj, "C1DTWCZDGJ")); + clusterAlarmData.setC1dtwcqdgj(MapUtils.getInteger(obj, "C1DTWCQDGJ")); + clusterAlarmData.setC1dtyczzdgj(MapUtils.getInteger(obj, "C1DTYCZZDGJ")); + clusterAlarmData.setC1dtyczdgj(MapUtils.getInteger(obj, "C1DTYCZDGJ")); + clusterAlarmData.setC1dtycqdgj(MapUtils.getInteger(obj, "C1DTYCQDGJ")); + clusterAlarmData.setC1sohdzzdgj(MapUtils.getInteger(obj, "C1SOHDZZDGJ")); + clusterAlarmData.setC1sohdzdgj(MapUtils.getInteger(obj, "C1SOHDZDGJ")); + clusterAlarmData.setC1sohdqdgj(MapUtils.getInteger(obj, "C1SOHDQDGJ")); + clusterAlarmData.setC1socgzzdgj(MapUtils.getInteger(obj, "C1SOCGZZDGJ")); + clusterAlarmData.setC1socgzdgj(MapUtils.getInteger(obj, "C1SOCGZDGJ")); + clusterAlarmData.setC1socdzzdgj(MapUtils.getInteger(obj, "C1SOCDZZDGJ")); + clusterAlarmData.setC1socdzdgj(MapUtils.getInteger(obj, "C1SOCDZDGJ")); + clusterAlarmData.setC1socdqdgj(MapUtils.getInteger(obj, "C1SOCDQDGJ")); + clusterAlarmData.setC1dtgwzzdgj(MapUtils.getInteger(obj, "C1DTGWZZDGJ")); + clusterAlarmData.setC1dtgwzdgj(MapUtils.getInteger(obj, "C1DTGWZDGJ")); + clusterAlarmData.setC1dtgwqdgj(MapUtils.getInteger(obj, "C1DTGWQDGJ")); + clusterAlarmData.setC1dtqwzzdgj(MapUtils.getInteger(obj, "C1DTQWZZDGJ")); + clusterAlarmData.setC1dtqwzdgj(MapUtils.getInteger(obj, "C1DTQWZDGJ")); + clusterAlarmData.setC1dtqwqdgj(MapUtils.getInteger(obj, "C1DTQWQDGJ")); + clusterAlarmData.setC1dtgyzzdgj(MapUtils.getInteger(obj, "C1DTGYZZDGJ")); + clusterAlarmData.setC1dtgyzdgj(MapUtils.getInteger(obj, "C1DTGYZDGJ")); + clusterAlarmData.setC1dtgyqdgj(MapUtils.getInteger(obj, "C1DTGYQDGJ")); + clusterAlarmData.setC1dtqyzzdgj(MapUtils.getInteger(obj, "C1DTQYZZDGJ")); + clusterAlarmData.setC1dtqyzdgj(MapUtils.getInteger(obj, "C1DTQYZDGJ")); + clusterAlarmData.setC1dtqyqdgj(MapUtils.getInteger(obj, "C1DTQYQDGJ")); + clusterAlarmData.setC1ddlzzdgj(MapUtils.getInteger(obj, "C1DDLZZDGJ")); + clusterAlarmData.setC1ddlzdgj(MapUtils.getInteger(obj, "C1DDLZDGJ")); + clusterAlarmData.setC1ddlqdgj(MapUtils.getInteger(obj, "C1DDLQDGJ")); + clusterAlarmData.setC1ddygyzzdgj(MapUtils.getInteger(obj, "C1DDYGYZZDGJ")); + clusterAlarmData.setC1ddygyzdgj(MapUtils.getInteger(obj, "C1DDYGYZDGJ")); + clusterAlarmData.setC1ddygyqdgj(MapUtils.getInteger(obj, "C1DDYGYQDGJ")); + clusterAlarmData.setC1ddyqyzzdgj(MapUtils.getInteger(obj, "C1DDYQYZZDGJ")); + clusterAlarmData.setC1ddyqyzdgj(MapUtils.getInteger(obj, "C1DDYQYZDGJ")); + clusterAlarmData.setC1ddyqyqdgj(MapUtils.getInteger(obj, "C1DDYQYQDGJ")); + clusterAlarmData.setC1zktxsl(MapUtils.getInteger(obj, "C1ZKTXSL")); + clusterAlarmData.setC1socgqdgj(MapUtils.getInteger(obj, "C1SOCGQDGJ")); + + clusterAlarmData.setCreateBy("system"); + clusterAlarmData.setCreateTime(DateUtils.getNowDate()); + clusterAlarmData.setUpdateBy("system"); + clusterAlarmData.setUpdateTime(DateUtils.getNowDate()); + clusterAlarmData.setSiteId(SITE_ID); + clusterAlarmData.setDeviceId(deviceId); + emsClusterAlarmDataMapper.insertEmsClusterAlarmData(clusterAlarmData); + } + + private void coolingDataProcess(String deviceId, String jsonData, Date dataUpdateTime) { + //中水冷却 + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + EmsCoolingAlarmData coolingAlarmData = new EmsCoolingAlarmData(); + // 更新时间 + coolingAlarmData.setDataTimestamp(dataUpdateTime); + + // 告警字段 + // 从Map中获取值并转为Integer,适配tinyint字段 + coolingAlarmData.setLsjyx(MapUtils.getInteger(obj, "LSJYX")); + coolingAlarmData.setPqdcfyx(MapUtils.getInteger(obj, "PQDCFYX")); + coolingAlarmData.setDjrq2yx(MapUtils.getInteger(obj, "DJRQ2YX")); + coolingAlarmData.setDjrq1yx(MapUtils.getInteger(obj, "DJRQ1YX")); + coolingAlarmData.setBqbyx(MapUtils.getInteger(obj, "BQBYX")); + coolingAlarmData.setBsbyx(MapUtils.getInteger(obj, "BSBYX")); + coolingAlarmData.setZxhbyx(MapUtils.getInteger(obj, "ZXHBYX")); // 此处不再报错 + coolingAlarmData.setSltzgz(MapUtils.getInteger(obj, "SLTZGZ")); + coolingAlarmData.setSlzhyj(MapUtils.getInteger(obj, "SLZHYJ")); + coolingAlarmData.setSlxtyctzxh(MapUtils.getInteger(obj, "SLXTYCTZXH")); + coolingAlarmData.setSlxtycqdxh(MapUtils.getInteger(obj, "SLXTYCQDXH")); + coolingAlarmData.setSlxtyckz(MapUtils.getInteger(obj, "SLXTYCKZ")); + coolingAlarmData.setSlxtbdkz(MapUtils.getInteger(obj, "SLXTBDKZ")); + coolingAlarmData.setSlxtzdms(MapUtils.getInteger(obj, "SLXTZDMS")); + coolingAlarmData.setSlxtsdms(MapUtils.getInteger(obj, "SLXTSDMS")); + coolingAlarmData.setHsylcdyj(MapUtils.getInteger(obj, "HSYLCDYJ")); + coolingAlarmData.setHsyldyj(MapUtils.getInteger(obj, "HSYLDYJ")); + coolingAlarmData.setGsylcgyj(MapUtils.getInteger(obj, "GSYLCGYJ")); + coolingAlarmData.setGsylgyj(MapUtils.getInteger(obj, "GSYLGYJ")); + coolingAlarmData.setGsylcdyj(MapUtils.getInteger(obj, "GSYLCDYJ")); + coolingAlarmData.setGsyldyj(MapUtils.getInteger(obj, "GSYLDYJ")); + coolingAlarmData.setHcgywg(MapUtils.getInteger(obj, "HCGYWG")); + coolingAlarmData.setHcgywcdtz(MapUtils.getInteger(obj, "HCGYWCDTZ")); + coolingAlarmData.setHcgywd(MapUtils.getInteger(obj, "HCGYWD")); + coolingAlarmData.setHcgylg(MapUtils.getInteger(obj, "HCGYLG")); + coolingAlarmData.setHcgyld(MapUtils.getInteger(obj, "HCGYLD")); + coolingAlarmData.setLysylgyj(MapUtils.getInteger(obj, "LYSYLGYJ")); + coolingAlarmData.setLysyldyj(MapUtils.getInteger(obj, "LYSYLDYJ")); + coolingAlarmData.setHswdcgyj(MapUtils.getInteger(obj, "HSWDCGYJ")); + coolingAlarmData.setHswdgyj(MapUtils.getInteger(obj, "HSWDGYJ")); + coolingAlarmData.setGswdcgtz(MapUtils.getInteger(obj, "GSWDCGTZ")); + coolingAlarmData.setGswdgyj(MapUtils.getInteger(obj, "GSWDGYJ")); + coolingAlarmData.setGswddyj(MapUtils.getInteger(obj, "GSWDDYJ")); + coolingAlarmData.setDdf2gz(MapUtils.getInteger(obj, "DDF2GZ")); + coolingAlarmData.setDdf1gz(MapUtils.getInteger(obj, "DDF1GZ")); + coolingAlarmData.setLyswdbsqyJ(MapUtils.getInteger(obj, "LYSWDBSQYJ")); + coolingAlarmData.setHsylbsqyJ(MapUtils.getInteger(obj, "HSYLBSQYJ")); + coolingAlarmData.setGsylbsqyJ(MapUtils.getInteger(obj, "GSYLBSQYJ")); + coolingAlarmData.setHswdbsqyJ(MapUtils.getInteger(obj, "HSWDBSQYJ")); + coolingAlarmData.setGswdbsqgztz(MapUtils.getInteger(obj, "GSWDBSQGZTZ")); + coolingAlarmData.setLsjgz(MapUtils.getInteger(obj, "LSJGZ")); + coolingAlarmData.setDjrq2gz(MapUtils.getInteger(obj, "DJRQ2GZ")); + coolingAlarmData.setDjrq1gz(MapUtils.getInteger(obj, "DJRQ1GZ")); + coolingAlarmData.setBqbgz(MapUtils.getInteger(obj, "BQBGZ")); + coolingAlarmData.setBsbgz(MapUtils.getInteger(obj, "BSBGZ")); + coolingAlarmData.setXhbgz(MapUtils.getInteger(obj, "XHBGZ")); + coolingAlarmData.setZdygz(MapUtils.getInteger(obj, "ZDYGZ")); + + coolingAlarmData.setCreateBy("system"); + coolingAlarmData.setCreateTime(DateUtils.getNowDate()); + coolingAlarmData.setUpdateBy("system"); + coolingAlarmData.setUpdateTime(DateUtils.getNowDate()); + coolingAlarmData.setSiteId(SITE_ID); + coolingAlarmData.setDeviceId(deviceId); + emsCoolingAlarmDataMapper.insertEmsCoolingAlarmData(coolingAlarmData); + } + + @Override + public void processBatch(List batchData) { + super.processBatch(batchData); + } + + private void alarmDataProcess(String deviceId, String jsonData, + Map alarmInfoData, String category) { + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + String redisKey = RedisKeyConstants.LATEST_ALARM_RECORD + "_" + SITE_ID +"_" + deviceId; + // 获取redis里面的当前有效告警遍历添加到已存在告警key里面 + Map currentAlarm = redisCache.getCacheMap(redisKey); + final Set currentAlarmKeys = new HashSet<>(); + if (currentAlarm != null && !currentAlarm.isEmpty()) { + currentAlarm.keySet().stream() + .filter(Objects::nonNull) + .map(Object::toString) + .forEach(currentAlarmKeys::add); + } + + // 结合同步数据,筛选簇需要更新的告警信息 + List needUpdateKeys = obj.entrySet().stream() + .filter(entry -> { + Object valueObj = entry.getValue(); + if (valueObj == null) { + return false; + } + int value = Integer.parseInt(valueObj.toString()); + return value == 0 && currentAlarmKeys.contains(entry.getKey()); + }) + .map(Map.Entry::getKey) + .collect(Collectors.toList()); + + // 批量查询数据库-需要更新的数据 + Map needUpdateMap = new HashMap<>(); + if (!needUpdateKeys.isEmpty()) { + List records = iEmsAlarmRecordsService.getAllUnfinishedRecords(needUpdateKeys,SITE_ID, deviceId); + // 转为Map便于快速获取 + needUpdateMap = records.stream() + .collect(Collectors.toMap( + EmsAlarmRecords::getAlarmPoint, + record -> record + )); + } + + + List saveOrUpdateList = new ArrayList<>(); + List newAddRecordList = new ArrayList<>(); + List toRemoveFromRedis = new ArrayList<>(); + + // 遍历数据map + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + Integer value = (Integer) entry.getValue(); + Boolean isCurrentAlarm = currentAlarmKeys.contains(key); + + // 值为 1且不在当前告警里面 - 新增告警 + if (value == 1 && !isCurrentAlarm) { + String matchRedisKey = category + "_" + key; + Object cacheObj = alarmInfoData.get(matchRedisKey); + if (cacheObj == null) { + // 处理空数据逻辑 + return; + } + EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class); + EmsAlarmRecords emsAlarmRecord = convertAlarmRecord(deviceId,matchInfo); + saveOrUpdateList.add(emsAlarmRecord); + newAddRecordList.add(emsAlarmRecord); + } else if (value == 0 && isCurrentAlarm) {// 值为 0且在当前告警里面 - 更新告警已处理 + EmsAlarmRecords existingAlarm = needUpdateMap.get(key); + if (existingAlarm != null) { + existingAlarm.setStatus(AlarmStatus.DONE.getCode()); + existingAlarm.setUpdateTime(new Date()); + existingAlarm.setAlarmEndTime(new Date()); + saveOrUpdateList.add(existingAlarm); + toRemoveFromRedis.add(key); + } + } + } + + // 批量处理插入和更新操作 + if (saveOrUpdateList != null && saveOrUpdateList.size() > 0) { + iEmsAlarmRecordsService.batchProcessAlarmRecords(saveOrUpdateList); + } + // 已处理的从redis里面删除 + if (!toRemoveFromRedis.isEmpty()) { + redisCache.deleteAllCacheMapValue(RedisKeyConstants.LATEST_ALARM_RECORD + SITE_ID,toRemoveFromRedis.toArray()); + } + // 批量添加新增的告警到Redis + Map newAlarms = newAddRecordList.stream() + .filter(a -> !AlarmStatus.DONE.getCode().equals(a.getStatus())) + .collect(Collectors.toMap(EmsAlarmRecords::getAlarmPoint, a -> a)); + if (!newAlarms.isEmpty()) { + // 本次新增的放入redis + redisCache.setAllCacheMapValue(redisKey, newAlarms); + } + } + + private EmsAlarmRecords convertAlarmRecord(String deviceId, EmsAlarmMatchData matchInfo) { + EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); + emsAlarmRecords.setSiteId(SITE_ID); + emsAlarmRecords.setDeviceId(deviceId); + emsAlarmRecords.setDeviceType(DeviceType.TCP.toString()); + emsAlarmRecords.setAlarmLevel(AlarmLevelStatus.GENERAL.getCode()); + emsAlarmRecords.setStatus(AlarmStatus.WAITING.getCode()); + emsAlarmRecords.setAlarmStartTime(DateUtils.getNowDate()); + emsAlarmRecords.setCreateTime(DateUtils.getNowDate()); + emsAlarmRecords.setCreateBy("system"); + emsAlarmRecords.setUpdateTime(DateUtils.getNowDate()); + emsAlarmRecords.setUpdateBy("system"); + + if (matchInfo != null) { + emsAlarmRecords.setAlarmPoint(matchInfo.getPoint()); + emsAlarmRecords.setAlarmContent(matchInfo.getAlarmDescription()); + } + return emsAlarmRecords; + } + + // 空数据不处理 + private boolean checkJsonDataEmpty(String jsonData) { + boolean flag = false; + try { + if (StringUtils.isEmpty(jsonData)) { + flag = true; + } + JsonNode jsonNode = objectMapper.readTree(jsonData); + // 判断是否为空对象({}) + if (jsonNode.isObject() && jsonNode.isEmpty()) { + flag = true ; + } + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + return flag; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index a808968..fb0665f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -947,17 +947,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl && dataTimeStr.compareTo(endTime) < 0; } - private String concateCurrentDayTime(String startTime) { - DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm"); - LocalTime time = LocalTime.parse(startTime, timeFormatter); - - LocalDate today = LocalDate.now(); - LocalDateTime targetDateTime = LocalDateTime.of(today, time); - - DateTimeFormatter resultFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); - return targetDateTime.format(resultFormatter); - } - private EmsDailyEnergyData initEnergyData() { // 先获取数据库当天数据,存在则更新时间,不存在则初始化 EmsDailyEnergyData energyData = emsDailyEnergyDataMapper.getDataByDate(SITE_ID,DateUtils.getDate()); @@ -1026,142 +1015,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } @Override - public void handleFxAlarmData(String message) { - JSONArray arraylist = JSONArray.parseArray(message); - - // 获取redis缓存-告警信息 - Map alarmMatchInfo= redisCache.getCacheObject(RedisKeyConstants.ALARM_MATCH_INFO); - - for (int i = 0; i < arraylist.size(); i++) { - JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); - - String deviceId = obj.get("Device").toString(); - String jsonData = obj.get("Data").toString(); - - log.info("deviceId:" + deviceId); - - if (deviceId.contains("BMSD")) { - alarmDataProcess(deviceId, jsonData, alarmMatchInfo, DeviceCategory.STACK.getCode()); - } else if (deviceId.contains("BMSC")) { - alarmDataProcess(deviceId, jsonData, alarmMatchInfo, DeviceCategory.CLUSTER.getCode()); - } else if (deviceId.contains("PCS")) { - alarmDataProcess(deviceId, jsonData, alarmMatchInfo, DeviceCategory.PCS.getCode()); - } - } - } - - private void alarmDataProcess(String deviceId, String jsonData, - Map alarmInfoData, String category) { - Map obj = JSON.parseObject(jsonData, new TypeReference>() { - }); - - String redisKey = RedisKeyConstants.LATEST_ALARM_RECORD + "_" + SITE_ID +"_" + deviceId; - // 获取redis里面的当前有效告警遍历添加到已存在告警key里面 - Map currentAlarm = redisCache.getCacheMap(redisKey); - final Set currentAlarmKeys = new HashSet<>(); - if (currentAlarm != null && !currentAlarm.isEmpty()) { - currentAlarm.keySet().stream() - .filter(Objects::nonNull) - .map(Object::toString) - .forEach(currentAlarmKeys::add); - } - - // 结合同步数据,筛选簇需要更新的告警信息 - List needUpdateKeys = obj.entrySet().stream() - .filter(entry -> { - Object valueObj = entry.getValue(); - if (valueObj == null) { - return false; - } - int value = Integer.parseInt(valueObj.toString()); - return value == 0 && currentAlarmKeys.contains(entry.getKey()); - }) - .map(Map.Entry::getKey) - .collect(Collectors.toList()); - - // 批量查询数据库-需要更新的数据 - Map needUpdateMap = new HashMap<>(); - if (!needUpdateKeys.isEmpty()) { - List records = iEmsAlarmRecordsService.getAllUnfinishedRecords(needUpdateKeys,SITE_ID, deviceId); - // 转为Map便于快速获取 - needUpdateMap = records.stream() - .collect(Collectors.toMap( - EmsAlarmRecords::getAlarmPoint, - record -> record - )); - } - - - List saveOrUpdateList = new ArrayList<>(); - List newAddRecordList = new ArrayList<>(); - List toRemoveFromRedis = new ArrayList<>(); - - // 遍历数据map - for (Map.Entry entry : obj.entrySet()) { - String key = entry.getKey(); - Integer value = (Integer) entry.getValue(); - Boolean isCurrentAlarm = currentAlarmKeys.contains(key); - - // 值为 1且不在当前告警里面 - 新增告警 - if (value == 1 && !isCurrentAlarm) { - String matchRedisKey = category + "_" + key; - Object cacheObj = alarmInfoData.get(matchRedisKey); - if (cacheObj == null) { - // 处理空数据逻辑 - return; - } - EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class); - EmsAlarmRecords emsAlarmRecord = convertAlarmRecord(deviceId,matchInfo); - saveOrUpdateList.add(emsAlarmRecord); - newAddRecordList.add(emsAlarmRecord); - } else if (value == 0 && isCurrentAlarm) {// 值为 0且在当前告警里面 - 更新告警已处理 - EmsAlarmRecords existingAlarm = needUpdateMap.get(key); - if (existingAlarm != null) { - existingAlarm.setStatus(AlarmStatus.DONE.getCode()); - existingAlarm.setUpdateTime(new Date()); - existingAlarm.setAlarmEndTime(new Date()); - saveOrUpdateList.add(existingAlarm); - toRemoveFromRedis.add(key); - } - } - } - - // 批量处理插入和更新操作 - if (saveOrUpdateList != null && saveOrUpdateList.size() > 0) { - iEmsAlarmRecordsService.batchProcessAlarmRecords(saveOrUpdateList); - } - // 已处理的从redis里面删除 - if (!toRemoveFromRedis.isEmpty()) { - redisCache.deleteAllCacheMapValue(RedisKeyConstants.LATEST_ALARM_RECORD + SITE_ID,toRemoveFromRedis.toArray()); - } - // 批量添加新增的告警到Redis - Map newAlarms = newAddRecordList.stream() - .filter(a -> !AlarmStatus.DONE.getCode().equals(a.getStatus())) - .collect(Collectors.toMap(EmsAlarmRecords::getAlarmPoint, a -> a)); - if (!newAlarms.isEmpty()) { - // 本次新增的放入redis - redisCache.setAllCacheMapValue(redisKey, newAlarms); - } - } - - private EmsAlarmRecords convertAlarmRecord(String deviceId, EmsAlarmMatchData matchInfo) { - EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); - emsAlarmRecords.setSiteId(SITE_ID); - emsAlarmRecords.setDeviceId(deviceId); - emsAlarmRecords.setDeviceType(DeviceType.TCP.toString()); - emsAlarmRecords.setAlarmLevel(AlarmLevelStatus.GENERAL.getCode()); - emsAlarmRecords.setStatus(AlarmStatus.WAITING.getCode()); - emsAlarmRecords.setAlarmStartTime(DateUtils.getNowDate()); - emsAlarmRecords.setCreateTime(DateUtils.getNowDate()); - emsAlarmRecords.setCreateBy("system"); - emsAlarmRecords.setUpdateTime(DateUtils.getNowDate()); - emsAlarmRecords.setUpdateBy("system"); - - if (matchInfo != null) { - emsAlarmRecords.setAlarmPoint(matchInfo.getPoint()); - emsAlarmRecords.setAlarmContent(matchInfo.getAlarmDescription()); - } - return emsAlarmRecords; + public void processBatch(List batchData) { + super.processBatch(batchData); } // 空数据不处理 diff --git a/ems-system/src/main/resources/mapper/ems/EmsClusterAlarmDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsClusterAlarmDataMapper.xml new file mode 100644 index 0000000..21dedba --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsClusterAlarmDataMapper.xml @@ -0,0 +1,526 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, data_timestamp, site_id, device_id, c1zktxsl, c1ddyqyqdgj, c1ddyqyzdgj, c1ddyqyzzdgj, c1ddygyqdgj, c1ddygyzdgj, c1ddygyzzdgj, c1ddlqdgj, c1ddlzdgj, c1ddlzzdgj, c1dtqyqdgj, c1dtqyzdgj, c1dtqyzzdgj, c1dtgyqdgj, c1dtgyzdgj, c1dtgyzzdgj, c1dtqwqdgj, c1dtqwzdgj, c1dtqwzzdgj, c1dtgwqdgj, c1dtgwzdgj, c1dtgwzzdgj, c1socdqdgj, c1socdzdgj, c1socdzzdgj, c1socgqdgj, c1socgzdgj, c1socgzzdgj, c1sohdqdgj, c1sohdzdgj, c1sohdzzdgj, c1dtycqdgj, c1dtyczdgj, c1dtyczzdgj, c1dtwcqdgj, c1dtwczdgj, c1dtwczzdgj, c1ck1txsl, c1ck2txsl, c1ck3txsl, c1ck4txsl, c1ck5txsl, c1ck6txsl, c1ck7txsl, c1ck8txsl, c1ck9txsl, c1ck10txsl, c1ck11txsl, c1ck12txsl, c1ck13txsl, c1ck14txsl, c1ck15txsl, c1ck16txsl, c1ck17txsl, c1ck18txsl, c1ck19txsl, c1ck20txsl, c1ck21txsl, c1ck22txsl, c1ck23txsl, c1ck24txsl, c1ck25txsl, c1ck26txsl, c1ck27txsl, c1ck28txsl, c1ck29txsl, c1ck30txsl, c1ck31txsl, c1ck32txsl, c1ck33txsl, c1ck34txsl, c1ck35txsl, c1ck36txsl, c1ck37txsl, c1ck38txsl, c1ck39txsl, c1ck40txsl, c1dzwdggqdgj, c1dzwdggzdgj, c1dzwdggzzdgj, c1mkdyggqdgj, c1mkdyggzdgj, c1mkdyggzzdgj, c1mkdygdqdgj, c1mkdygdzdgj, c1mkdygdzzdgj, c1dycjgz, c1wdcjgz, create_by, create_time, update_by, update_time, remark from ems_cluster_alarm_data + + + + + + + + insert into ems_cluster_alarm_data + + data_timestamp, + site_id, + device_id, + c1zktxsl, + c1ddyqyqdgj, + c1ddyqyzdgj, + c1ddyqyzzdgj, + c1ddygyqdgj, + c1ddygyzdgj, + c1ddygyzzdgj, + c1ddlqdgj, + c1ddlzdgj, + c1ddlzzdgj, + c1dtqyqdgj, + c1dtqyzdgj, + c1dtqyzzdgj, + c1dtgyqdgj, + c1dtgyzdgj, + c1dtgyzzdgj, + c1dtqwqdgj, + c1dtqwzdgj, + c1dtqwzzdgj, + c1dtgwqdgj, + c1dtgwzdgj, + c1dtgwzzdgj, + c1socdqdgj, + c1socdzdgj, + c1socdzzdgj, + c1socgqdgj, + c1socgzdgj, + c1socgzzdgj, + c1sohdqdgj, + c1sohdzdgj, + c1sohdzzdgj, + c1dtycqdgj, + c1dtyczdgj, + c1dtyczzdgj, + c1dtwcqdgj, + c1dtwczdgj, + c1dtwczzdgj, + c1ck1txsl, + c1ck2txsl, + c1ck3txsl, + c1ck4txsl, + c1ck5txsl, + c1ck6txsl, + c1ck7txsl, + c1ck8txsl, + c1ck9txsl, + c1ck10txsl, + c1ck11txsl, + c1ck12txsl, + c1ck13txsl, + c1ck14txsl, + c1ck15txsl, + c1ck16txsl, + c1ck17txsl, + c1ck18txsl, + c1ck19txsl, + c1ck20txsl, + c1ck21txsl, + c1ck22txsl, + c1ck23txsl, + c1ck24txsl, + c1ck25txsl, + c1ck26txsl, + c1ck27txsl, + c1ck28txsl, + c1ck29txsl, + c1ck30txsl, + c1ck31txsl, + c1ck32txsl, + c1ck33txsl, + c1ck34txsl, + c1ck35txsl, + c1ck36txsl, + c1ck37txsl, + c1ck38txsl, + c1ck39txsl, + c1ck40txsl, + c1dzwdggqdgj, + c1dzwdggzdgj, + c1dzwdggzzdgj, + c1mkdyggqdgj, + c1mkdyggzdgj, + c1mkdyggzzdgj, + c1mkdygdqdgj, + c1mkdygdzdgj, + c1mkdygdzzdgj, + c1dycjgz, + c1wdcjgz, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{dataTimestamp}, + #{siteId}, + #{deviceId}, + #{c1zktxsl}, + #{c1ddyqyqdgj}, + #{c1ddyqyzdgj}, + #{c1ddyqyzzdgj}, + #{c1ddygyqdgj}, + #{c1ddygyzdgj}, + #{c1ddygyzzdgj}, + #{c1ddlqdgj}, + #{c1ddlzdgj}, + #{c1ddlzzdgj}, + #{c1dtqyqdgj}, + #{c1dtqyzdgj}, + #{c1dtqyzzdgj}, + #{c1dtgyqdgj}, + #{c1dtgyzdgj}, + #{c1dtgyzzdgj}, + #{c1dtqwqdgj}, + #{c1dtqwzdgj}, + #{c1dtqwzzdgj}, + #{c1dtgwqdgj}, + #{c1dtgwzdgj}, + #{c1dtgwzzdgj}, + #{c1socdqdgj}, + #{c1socdzdgj}, + #{c1socdzzdgj}, + #{c1socgqdgj}, + #{c1socgzdgj}, + #{c1socgzzdgj}, + #{c1sohdqdgj}, + #{c1sohdzdgj}, + #{c1sohdzzdgj}, + #{c1dtycqdgj}, + #{c1dtyczdgj}, + #{c1dtyczzdgj}, + #{c1dtwcqdgj}, + #{c1dtwczdgj}, + #{c1dtwczzdgj}, + #{c1ck1txsl}, + #{c1ck2txsl}, + #{c1ck3txsl}, + #{c1ck4txsl}, + #{c1ck5txsl}, + #{c1ck6txsl}, + #{c1ck7txsl}, + #{c1ck8txsl}, + #{c1ck9txsl}, + #{c1ck10txsl}, + #{c1ck11txsl}, + #{c1ck12txsl}, + #{c1ck13txsl}, + #{c1ck14txsl}, + #{c1ck15txsl}, + #{c1ck16txsl}, + #{c1ck17txsl}, + #{c1ck18txsl}, + #{c1ck19txsl}, + #{c1ck20txsl}, + #{c1ck21txsl}, + #{c1ck22txsl}, + #{c1ck23txsl}, + #{c1ck24txsl}, + #{c1ck25txsl}, + #{c1ck26txsl}, + #{c1ck27txsl}, + #{c1ck28txsl}, + #{c1ck29txsl}, + #{c1ck30txsl}, + #{c1ck31txsl}, + #{c1ck32txsl}, + #{c1ck33txsl}, + #{c1ck34txsl}, + #{c1ck35txsl}, + #{c1ck36txsl}, + #{c1ck37txsl}, + #{c1ck38txsl}, + #{c1ck39txsl}, + #{c1ck40txsl}, + #{c1dzwdggqdgj}, + #{c1dzwdggzdgj}, + #{c1dzwdggzzdgj}, + #{c1mkdyggqdgj}, + #{c1mkdyggzdgj}, + #{c1mkdyggzzdgj}, + #{c1mkdygdqdgj}, + #{c1mkdygdzdgj}, + #{c1mkdygdzzdgj}, + #{c1dycjgz}, + #{c1wdcjgz}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_cluster_alarm_data + + data_timestamp = #{dataTimestamp}, + site_id = #{siteId}, + device_id = #{deviceId}, + c1zktxsl = #{c1zktxsl}, + c1ddyqyqdgj = #{c1ddyqyqdgj}, + c1ddyqyzdgj = #{c1ddyqyzdgj}, + c1ddyqyzzdgj = #{c1ddyqyzzdgj}, + c1ddygyqdgj = #{c1ddygyqdgj}, + c1ddygyzdgj = #{c1ddygyzdgj}, + c1ddygyzzdgj = #{c1ddygyzzdgj}, + c1ddlqdgj = #{c1ddlqdgj}, + c1ddlzdgj = #{c1ddlzdgj}, + c1ddlzzdgj = #{c1ddlzzdgj}, + c1dtqyqdgj = #{c1dtqyqdgj}, + c1dtqyzdgj = #{c1dtqyzdgj}, + c1dtqyzzdgj = #{c1dtqyzzdgj}, + c1dtgyqdgj = #{c1dtgyqdgj}, + c1dtgyzdgj = #{c1dtgyzdgj}, + c1dtgyzzdgj = #{c1dtgyzzdgj}, + c1dtqwqdgj = #{c1dtqwqdgj}, + c1dtqwzdgj = #{c1dtqwzdgj}, + c1dtqwzzdgj = #{c1dtqwzzdgj}, + c1dtgwqdgj = #{c1dtgwqdgj}, + c1dtgwzdgj = #{c1dtgwzdgj}, + c1dtgwzzdgj = #{c1dtgwzzdgj}, + c1socdqdgj = #{c1socdqdgj}, + c1socdzdgj = #{c1socdzdgj}, + c1socdzzdgj = #{c1socdzzdgj}, + c1socgqdgj = #{c1socgqdgj}, + c1socgzdgj = #{c1socgzdgj}, + c1socgzzdgj = #{c1socgzzdgj}, + c1sohdqdgj = #{c1sohdqdgj}, + c1sohdzdgj = #{c1sohdzdgj}, + c1sohdzzdgj = #{c1sohdzzdgj}, + c1dtycqdgj = #{c1dtycqdgj}, + c1dtyczdgj = #{c1dtyczdgj}, + c1dtyczzdgj = #{c1dtyczzdgj}, + c1dtwcqdgj = #{c1dtwcqdgj}, + c1dtwczdgj = #{c1dtwczdgj}, + c1dtwczzdgj = #{c1dtwczzdgj}, + c1ck1txsl = #{c1ck1txsl}, + c1ck2txsl = #{c1ck2txsl}, + c1ck3txsl = #{c1ck3txsl}, + c1ck4txsl = #{c1ck4txsl}, + c1ck5txsl = #{c1ck5txsl}, + c1ck6txsl = #{c1ck6txsl}, + c1ck7txsl = #{c1ck7txsl}, + c1ck8txsl = #{c1ck8txsl}, + c1ck9txsl = #{c1ck9txsl}, + c1ck10txsl = #{c1ck10txsl}, + c1ck11txsl = #{c1ck11txsl}, + c1ck12txsl = #{c1ck12txsl}, + c1ck13txsl = #{c1ck13txsl}, + c1ck14txsl = #{c1ck14txsl}, + c1ck15txsl = #{c1ck15txsl}, + c1ck16txsl = #{c1ck16txsl}, + c1ck17txsl = #{c1ck17txsl}, + c1ck18txsl = #{c1ck18txsl}, + c1ck19txsl = #{c1ck19txsl}, + c1ck20txsl = #{c1ck20txsl}, + c1ck21txsl = #{c1ck21txsl}, + c1ck22txsl = #{c1ck22txsl}, + c1ck23txsl = #{c1ck23txsl}, + c1ck24txsl = #{c1ck24txsl}, + c1ck25txsl = #{c1ck25txsl}, + c1ck26txsl = #{c1ck26txsl}, + c1ck27txsl = #{c1ck27txsl}, + c1ck28txsl = #{c1ck28txsl}, + c1ck29txsl = #{c1ck29txsl}, + c1ck30txsl = #{c1ck30txsl}, + c1ck31txsl = #{c1ck31txsl}, + c1ck32txsl = #{c1ck32txsl}, + c1ck33txsl = #{c1ck33txsl}, + c1ck34txsl = #{c1ck34txsl}, + c1ck35txsl = #{c1ck35txsl}, + c1ck36txsl = #{c1ck36txsl}, + c1ck37txsl = #{c1ck37txsl}, + c1ck38txsl = #{c1ck38txsl}, + c1ck39txsl = #{c1ck39txsl}, + c1ck40txsl = #{c1ck40txsl}, + c1dzwdggqdgj = #{c1dzwdggqdgj}, + c1dzwdggzdgj = #{c1dzwdggzdgj}, + c1dzwdggzzdgj = #{c1dzwdggzzdgj}, + c1mkdyggqdgj = #{c1mkdyggqdgj}, + c1mkdyggzdgj = #{c1mkdyggzdgj}, + c1mkdyggzzdgj = #{c1mkdyggzzdgj}, + c1mkdygdqdgj = #{c1mkdygdqdgj}, + c1mkdygdzdgj = #{c1mkdygdzdgj}, + c1mkdygdzzdgj = #{c1mkdygdzzdgj}, + c1dycjgz = #{c1dycjgz}, + c1wdcjgz = #{c1wdcjgz}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_cluster_alarm_data where id = #{id} + + + + delete from ems_cluster_alarm_data where id in + + #{id} + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsCoolingAlarmDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsCoolingAlarmDataMapper.xml new file mode 100644 index 0000000..a6db7b3 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsCoolingAlarmDataMapper.xml @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, data_timestamp, site_id, device_id, lsjyx, pqdcfyx, djrq2yx, djrq1yx, bqbyx, bsbyx, zxhbyx, sltzgz, slzhyj, slxtyctzxh, slxtycqdxh, slxtyckz, slxtbdkz, slxtzdms, slxtsdms, hsylcdyj, hsyldyj, gsylcgyj, gsylgyj, gsylcdyj, gsyldyj, hcgywg, hcgywcdtz, hcgywd, hcgylg, hcgyld, lysylgyj, lysyldyj, hswdcgyj, hswdgyj, gswdcgtz, gswdgyj, gswddyj, ddf2gz, ddf1gz, lyswdbsqyJ, hsylbsqyJ, gsylbsqyJ, hswdbsqyJ, gswdbsqgztz, lsjgz, djrq2gz, djrq1gz, bqbgz, bsbgz, xhbgz, zdygz, create_by, create_time, update_by, update_time, remark from ems_cooling_alarm_data + + + + + + + + insert into ems_cooling_alarm_data + + data_timestamp, + site_id, + device_id, + lsjyx, + pqdcfyx, + djrq2yx, + djrq1yx, + bqbyx, + bsbyx, + zxhbyx, + sltzgz, + slzhyj, + slxtyctzxh, + slxtycqdxh, + slxtyckz, + slxtbdkz, + slxtzdms, + slxtsdms, + hsylcdyj, + hsyldyj, + gsylcgyj, + gsylgyj, + gsylcdyj, + gsyldyj, + hcgywg, + hcgywcdtz, + hcgywd, + hcgylg, + hcgyld, + lysylgyj, + lysyldyj, + hswdcgyj, + hswdgyj, + gswdcgtz, + gswdgyj, + gswddyj, + ddf2gz, + ddf1gz, + lyswdbsqyJ, + hsylbsqyJ, + gsylbsqyJ, + hswdbsqyJ, + gswdbsqgztz, + lsjgz, + djrq2gz, + djrq1gz, + bqbgz, + bsbgz, + xhbgz, + zdygz, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{dataTimestamp}, + #{siteId}, + #{deviceId}, + #{lsjyx}, + #{pqdcfyx}, + #{djrq2yx}, + #{djrq1yx}, + #{bqbyx}, + #{bsbyx}, + #{zxhbyx}, + #{sltzgz}, + #{slzhyj}, + #{slxtyctzxh}, + #{slxtycqdxh}, + #{slxtyckz}, + #{slxtbdkz}, + #{slxtzdms}, + #{slxtsdms}, + #{hsylcdyj}, + #{hsyldyj}, + #{gsylcgyj}, + #{gsylgyj}, + #{gsylcdyj}, + #{gsyldyj}, + #{hcgywg}, + #{hcgywcdtz}, + #{hcgywd}, + #{hcgylg}, + #{hcgyld}, + #{lysylgyj}, + #{lysyldyj}, + #{hswdcgyj}, + #{hswdgyj}, + #{gswdcgtz}, + #{gswdgyj}, + #{gswddyj}, + #{ddf2gz}, + #{ddf1gz}, + #{lyswdbsqyJ}, + #{hsylbsqyJ}, + #{gsylbsqyJ}, + #{hswdbsqyJ}, + #{gswdbsqgztz}, + #{lsjgz}, + #{djrq2gz}, + #{djrq1gz}, + #{bqbgz}, + #{bsbgz}, + #{xhbgz}, + #{zdygz}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_cooling_alarm_data + + data_timestamp = #{dataTimestamp}, + site_id = #{siteId}, + device_id = #{deviceId}, + lsjyx = #{lsjyx}, + pqdcfyx = #{pqdcfyx}, + djrq2yx = #{djrq2yx}, + djrq1yx = #{djrq1yx}, + bqbyx = #{bqbyx}, + bsbyx = #{bsbyx}, + zxhbyx = #{zxhbyx}, + sltzgz = #{sltzgz}, + slzhyj = #{slzhyj}, + slxtyctzxh = #{slxtyctzxh}, + slxtycqdxh = #{slxtycqdxh}, + slxtyckz = #{slxtyckz}, + slxtbdkz = #{slxtbdkz}, + slxtzdms = #{slxtzdms}, + slxtsdms = #{slxtsdms}, + hsylcdyj = #{hsylcdyj}, + hsyldyj = #{hsyldyj}, + gsylcgyj = #{gsylcgyj}, + gsylgyj = #{gsylgyj}, + gsylcdyj = #{gsylcdyj}, + gsyldyj = #{gsyldyj}, + hcgywg = #{hcgywg}, + hcgywcdtz = #{hcgywcdtz}, + hcgywd = #{hcgywd}, + hcgylg = #{hcgylg}, + hcgyld = #{hcgyld}, + lysylgyj = #{lysylgyj}, + lysyldyj = #{lysyldyj}, + hswdcgyj = #{hswdcgyj}, + hswdgyj = #{hswdgyj}, + gswdcgtz = #{gswdcgtz}, + gswdgyj = #{gswdgyj}, + gswddyj = #{gswddyj}, + ddf2gz = #{ddf2gz}, + ddf1gz = #{ddf1gz}, + lyswdbsqyJ = #{lyswdbsqyJ}, + hsylbsqyJ = #{hsylbsqyJ}, + gsylbsqyJ = #{gsylbsqyJ}, + hswdbsqyJ = #{hswdbsqyJ}, + gswdbsqgztz = #{gswdbsqgztz}, + lsjgz = #{lsjgz}, + djrq2gz = #{djrq2gz}, + djrq1gz = #{djrq1gz}, + bqbgz = #{bqbgz}, + bsbgz = #{bsbgz}, + xhbgz = #{xhbgz}, + zdygz = #{zdygz}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_cooling_alarm_data where id = #{id} + + + + delete from ems_cooling_alarm_data where id in + + #{id} + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsAlarmDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsAlarmDataMapper.xml new file mode 100644 index 0000000..de59108 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsAlarmDataMapper.xml @@ -0,0 +1,571 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, data_timestamp, site_id, device_id, gzbz, jyzkyc, jlllyc, zlgv, dwgyyc, dwqyyc, dwgpyc, dwqpyc, glmkgw, dwxxyc, nbrjgl, zlrqdyc, zlkgwc, jlfjyc, jlkgwc, wdkgwc, nbyc, jngw, jlrqdyc, rjhjyc, jlflqyc, nbjt, wbjt, mxdbyfhkjtj, mxdlgl, lpjzyc, mjgj, sxyc, zlflqyc, zndbtxyc, nbyjgl, qdyc, idct, xxgxctxvc, bjtxxyc, tbctxvc, zldhyc, lxgl, zlzjcqyc, ywgj, bjtxyc, hmictxyc, jxszcw, hmi485txyc, yctxyc, gzz, gjz, zlblmsszcw, xtcsbpp, dwdybphgj, ddycyyx, gdycyyx, zlfjyc, srqwdkgwc, wbwdkgwc, fybyqwdkgwc, dgwdkgwc, zjjdvc, fjjdvc, jljdvc, bwjdvc, bmsjt, kkhrqyc, dwgqpdjgj, glmkgwgJ, dcgy, dcqzqy, zlgl, scdyyc, scdybfhlwtj, gzbh, dlbh, nbfjyc, zlbxsyc, dczzqy, dcdygj, wbfjyc, dcfj, dcdybfhcdtj, gzgJ, zldhmktxyc, bmsxtgz, bmstxyc, bmsgjdyc, bmsjc, bmsjf, bmsdj, bmsgj, dgfjyc, srqgwgj, gzz2, gjz2, jlfjsmyc, zlfjsmyc, jlkgSmyc, zlkgSmyc, yljzyc, create_by, create_time, update_by, update_time, remark from ems_pcs_alarm_data + + + + + + + + insert into ems_pcs_alarm_data + + data_timestamp, + site_id, + device_id, + gzbz, + jyzkyc, + jlllyc, + zlgv, + dwgyyc, + dwqyyc, + dwgpyc, + dwqpyc, + glmkgw, + dwxxyc, + nbrjgl, + zlrqdyc, + zlkgwc, + jlfjyc, + jlkgwc, + wdkgwc, + nbyc, + jngw, + jlrqdyc, + rjhjyc, + jlflqyc, + nbjt, + wbjt, + mxdbyfhkjtj, + mxdlgl, + lpjzyc, + mjgj, + sxyc, + zlflqyc, + zndbtxyc, + nbyjgl, + qdyc, + idct, + xxgxctxvc, + bjtxxyc, + tbctxvc, + zldhyc, + lxgl, + zlzjcqyc, + ywgj, + bjtxyc, + hmictxyc, + jxszcw, + hmi485txyc, + yctxyc, + gzz, + gjz, + zlblmsszcw, + xtcsbpp, + dwdybphgj, + ddycyyx, + gdycyyx, + zlfjyc, + srqwdkgwc, + wbwdkgwc, + fybyqwdkgwc, + dgwdkgwc, + zjjdvc, + fjjdvc, + jljdvc, + bwjdvc, + bmsjt, + kkhrqyc, + dwgqpdjgj, + glmkgwgJ, + dcgy, + dcqzqy, + zlgl, + scdyyc, + scdybfhlwtj, + gzbh, + dlbh, + nbfjyc, + zlbxsyc, + dczzqy, + dcdygj, + wbfjyc, + dcfj, + dcdybfhcdtj, + gzgJ, + zldhmktxyc, + bmsxtgz, + bmstxyc, + bmsgjdyc, + bmsjc, + bmsjf, + bmsdj, + bmsgj, + dgfjyc, + srqgwgj, + gzz2, + gjz2, + jlfjsmyc, + zlfjsmyc, + jlkgSmyc, + zlkgSmyc, + yljzyc, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{dataTimestamp}, + #{siteId}, + #{deviceId}, + #{gzbz}, + #{jyzkyc}, + #{jlllyc}, + #{zlgv}, + #{dwgyyc}, + #{dwqyyc}, + #{dwgpyc}, + #{dwqpyc}, + #{glmkgw}, + #{dwxxyc}, + #{nbrjgl}, + #{zlrqdyc}, + #{zlkgwc}, + #{jlfjyc}, + #{jlkgwc}, + #{wdkgwc}, + #{nbyc}, + #{jngw}, + #{jlrqdyc}, + #{rjhjyc}, + #{jlflqyc}, + #{nbjt}, + #{wbjt}, + #{mxdbyfhkjtj}, + #{mxdlgl}, + #{lpjzyc}, + #{mjgj}, + #{sxyc}, + #{zlflqyc}, + #{zndbtxyc}, + #{nbyjgl}, + #{qdyc}, + #{idct}, + #{xxgxctxvc}, + #{bjtxxyc}, + #{tbctxvc}, + #{zldhyc}, + #{lxgl}, + #{zlzjcqyc}, + #{ywgj}, + #{bjtxyc}, + #{hmictxyc}, + #{jxszcw}, + #{hmi485txyc}, + #{yctxyc}, + #{gzz}, + #{gjz}, + #{zlblmsszcw}, + #{xtcsbpp}, + #{dwdybphgj}, + #{ddycyyx}, + #{gdycyyx}, + #{zlfjyc}, + #{srqwdkgwc}, + #{wbwdkgwc}, + #{fybyqwdkgwc}, + #{dgwdkgwc}, + #{zjjdvc}, + #{fjjdvc}, + #{jljdvc}, + #{bwjdvc}, + #{bmsjt}, + #{kkhrqyc}, + #{dwgqpdjgj}, + #{glmkgwgJ}, + #{dcgy}, + #{dcqzqy}, + #{zlgl}, + #{scdyyc}, + #{scdybfhlwtj}, + #{gzbh}, + #{dlbh}, + #{nbfjyc}, + #{zlbxsyc}, + #{dczzqy}, + #{dcdygj}, + #{wbfjyc}, + #{dcfj}, + #{dcdybfhcdtj}, + #{gzgJ}, + #{zldhmktxyc}, + #{bmsxtgz}, + #{bmstxyc}, + #{bmsgjdyc}, + #{bmsjc}, + #{bmsjf}, + #{bmsdj}, + #{bmsgj}, + #{dgfjyc}, + #{srqgwgj}, + #{gzz2}, + #{gjz2}, + #{jlfjsmyc}, + #{zlfjsmyc}, + #{jlkgSmyc}, + #{zlkgSmyc}, + #{yljzyc}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_pcs_alarm_data + + data_timestamp = #{dataTimestamp}, + site_id = #{siteId}, + device_id = #{deviceId}, + gzbz = #{gzbz}, + jyzkyc = #{jyzkyc}, + jlllyc = #{jlllyc}, + zlgv = #{zlgv}, + dwgyyc = #{dwgyyc}, + dwqyyc = #{dwqyyc}, + dwgpyc = #{dwgpyc}, + dwqpyc = #{dwqpyc}, + glmkgw = #{glmkgw}, + dwxxyc = #{dwxxyc}, + nbrjgl = #{nbrjgl}, + zlrqdyc = #{zlrqdyc}, + zlkgwc = #{zlkgwc}, + jlfjyc = #{jlfjyc}, + jlkgwc = #{jlkgwc}, + wdkgwc = #{wdkgwc}, + nbyc = #{nbyc}, + jngw = #{jngw}, + jlrqdyc = #{jlrqdyc}, + rjhjyc = #{rjhjyc}, + jlflqyc = #{jlflqyc}, + nbjt = #{nbjt}, + wbjt = #{wbjt}, + mxdbyfhkjtj = #{mxdbyfhkjtj}, + mxdlgl = #{mxdlgl}, + lpjzyc = #{lpjzyc}, + mjgj = #{mjgj}, + sxyc = #{sxyc}, + zlflqyc = #{zlflqyc}, + zndbtxyc = #{zndbtxyc}, + nbyjgl = #{nbyjgl}, + qdyc = #{qdyc}, + idct = #{idct}, + xxgxctxvc = #{xxgxctxvc}, + bjtxxyc = #{bjtxxyc}, + tbctxvc = #{tbctxvc}, + zldhyc = #{zldhyc}, + lxgl = #{lxgl}, + zlzjcqyc = #{zlzjcqyc}, + ywgj = #{ywgj}, + bjtxyc = #{bjtxyc}, + hmictxyc = #{hmictxyc}, + jxszcw = #{jxszcw}, + hmi485txyc = #{hmi485txyc}, + yctxyc = #{yctxyc}, + gzz = #{gzz}, + gjz = #{gjz}, + zlblmsszcw = #{zlblmsszcw}, + xtcsbpp = #{xtcsbpp}, + dwdybphgj = #{dwdybphgj}, + ddycyyx = #{ddycyyx}, + gdycyyx = #{gdycyyx}, + zlfjyc = #{zlfjyc}, + srqwdkgwc = #{srqwdkgwc}, + wbwdkgwc = #{wbwdkgwc}, + fybyqwdkgwc = #{fybyqwdkgwc}, + dgwdkgwc = #{dgwdkgwc}, + zjjdvc = #{zjjdvc}, + fjjdvc = #{fjjdvc}, + jljdvc = #{jljdvc}, + bwjdvc = #{bwjdvc}, + bmsjt = #{bmsjt}, + kkhrqyc = #{kkhrqyc}, + dwgqpdjgj = #{dwgqpdjgj}, + glmkgwgJ = #{glmkgwgJ}, + dcgy = #{dcgy}, + dcqzqy = #{dcqzqy}, + zlgl = #{zlgl}, + scdyyc = #{scdyyc}, + scdybfhlwtj = #{scdybfhlwtj}, + gzbh = #{gzbh}, + dlbh = #{dlbh}, + nbfjyc = #{nbfjyc}, + zlbxsyc = #{zlbxsyc}, + dczzqy = #{dczzqy}, + dcdygj = #{dcdygj}, + wbfjyc = #{wbfjyc}, + dcfj = #{dcfj}, + dcdybfhcdtj = #{dcdybfhcdtj}, + gzgJ = #{gzgJ}, + zldhmktxyc = #{zldhmktxyc}, + bmsxtgz = #{bmsxtgz}, + bmstxyc = #{bmstxyc}, + bmsgjdyc = #{bmsgjdyc}, + bmsjc = #{bmsjc}, + bmsjf = #{bmsjf}, + bmsdj = #{bmsdj}, + bmsgj = #{bmsgj}, + dgfjyc = #{dgfjyc}, + srqgwgj = #{srqgwgj}, + gzz2 = #{gzz2}, + gjz2 = #{gjz2}, + jlfjsmyc = #{jlfjsmyc}, + zlfjsmyc = #{zlfjsmyc}, + jlkgSmyc = #{jlkgSmyc}, + zlkgSmyc = #{zlkgSmyc}, + yljzyc = #{yljzyc}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_pcs_alarm_data where id = #{id} + + + + delete from ems_pcs_alarm_data where id in + + #{id} + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStackAlarmDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStackAlarmDataMapper.xml new file mode 100644 index 0000000..7fa6235 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsStackAlarmDataMapper.xml @@ -0,0 +1,571 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, data_timestamp, site_id, device_id, bmsgzzt, jczt, jfzt, dngzddyqyqdgjhz, dngzddyqyzdgjhz, dngzddyqyzzdgjhz, dngzddygyqdgjhz, dngzddygyzdgjhz, dngzddygyzzdgjhz, dngzdglqdgjhz, dngzdglzdgjhz, dngzdglzzdgjhz, dngzjydzdqdgjhz, dngzjydzdzdgjhz, dngzjydzdzzdgjhz, dngzmkqwdqdgjhz, dngzmkqwdzdgjhz, dngzmkqwdzzdgjhz, dngzmkgwdqdgjhz, dngzmkgwdzdgjhz, dngzmkgwdzzdgjhz, dngdtgyqwgjhz, dngdtgyzdgjhz, dngdtgyyzgjhz, dngdtqyqwgjhz, dngdtqyzdgjhz, dngdtqyyzgjhz, dngdtycqwgjhz, dngdtyczdgjhz, dngdtycyzgjhz, dngdtqwqwgjhz, dngdtqwzdgjhz, dngdtqwyzgjhz, dngdtgwqwgjhz, dngdtgwzdgjhz, dngdtgwyzgjhz, dngdtwcqwgjhz, dngdtwczdgjhz, dngdtwcyzgjhz, dtsocdqwgjhz, dtsocdzdgjhz, dtsocdyzgjhz, dtsocgqwgjhz, dtsocgzdgjhz, dtsocgyzgjhz, dtsohdqwgjhz, dtsohdzdgjhz, dtsohdyzgjhz, dtsohgqwgjhz, dtsohgzdgjhz, dtsohgyzgjhz, dngzkslhz, dngckslgjhz, dngzdyyc, dnjcqdkyc, dnjcqbhyc, cdjz, fdjz, bmsxtgjhz, bmsxtgzhz, srin0, srin1, srin2, srin3, yl1, yl2, yl3, yl4, yl5, yl6, yl7, yl8, dngdzgwqwgjhz, dngdzgwzdgjhz, dngdzgwzzdgjhz, dnmkdygyqwgjhz, dnmkdygyzdgjhz, dnmkdygyyzgjhz, dnmkdyqyqwgjhz, dnmkdyqyzdgjhz, dnmkdyqyyzgjhz, dycjsl, wdcjsl, didodi0, didodi1, didodi2, didodi3, didodi4, didodi5, didodi6, didodi7, didodi8, didodi9, didodi10, didodi11, didodi12, kttxsl, create_by, create_time, update_by, update_time, remark from ems_stack_alarm_data + + + + + + + + insert into ems_stack_alarm_data + + data_timestamp, + site_id, + device_id, + bmsgzzt, + jczt, + jfzt, + dngzddyqyqdgjhz, + dngzddyqyzdgjhz, + dngzddyqyzzdgjhz, + dngzddygyqdgjhz, + dngzddygyzdgjhz, + dngzddygyzzdgjhz, + dngzdglqdgjhz, + dngzdglzdgjhz, + dngzdglzzdgjhz, + dngzjydzdqdgjhz, + dngzjydzdzdgjhz, + dngzjydzdzzdgjhz, + dngzmkqwdqdgjhz, + dngzmkqwdzdgjhz, + dngzmkqwdzzdgjhz, + dngzmkgwdqdgjhz, + dngzmkgwdzdgjhz, + dngzmkgwdzzdgjhz, + dngdtgyqwgjhz, + dngdtgyzdgjhz, + dngdtgyyzgjhz, + dngdtqyqwgjhz, + dngdtqyzdgjhz, + dngdtqyyzgjhz, + dngdtycqwgjhz, + dngdtyczdgjhz, + dngdtycyzgjhz, + dngdtqwqwgjhz, + dngdtqwzdgjhz, + dngdtqwyzgjhz, + dngdtgwqwgjhz, + dngdtgwzdgjhz, + dngdtgwyzgjhz, + dngdtwcqwgjhz, + dngdtwczdgjhz, + dngdtwcyzgjhz, + dtsocdqwgjhz, + dtsocdzdgjhz, + dtsocdyzgjhz, + dtsocgqwgjhz, + dtsocgzdgjhz, + dtsocgyzgjhz, + dtsohdqwgjhz, + dtsohdzdgjhz, + dtsohdyzgjhz, + dtsohgqwgjhz, + dtsohgzdgjhz, + dtsohgyzgjhz, + dngzkslhz, + dngckslgjhz, + dngzdyyc, + dnjcqdkyc, + dnjcqbhyc, + cdjz, + fdjz, + bmsxtgjhz, + bmsxtgzhz, + srin0, + srin1, + srin2, + srin3, + yl1, + yl2, + yl3, + yl4, + yl5, + yl6, + yl7, + yl8, + dngdzgwqwgjhz, + dngdzgwzdgjhz, + dngdzgwzzdgjhz, + dnmkdygyqwgjhz, + dnmkdygyzdgjhz, + dnmkdygyyzgjhz, + dnmkdyqyqwgjhz, + dnmkdyqyzdgjhz, + dnmkdyqyyzgjhz, + dycjsl, + wdcjsl, + didodi0, + didodi1, + didodi2, + didodi3, + didodi4, + didodi5, + didodi6, + didodi7, + didodi8, + didodi9, + didodi10, + didodi11, + didodi12, + kttxsl, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{dataTimestamp}, + #{siteId}, + #{deviceId}, + #{bmsgzzt}, + #{jczt}, + #{jfzt}, + #{dngzddyqyqdgjhz}, + #{dngzddyqyzdgjhz}, + #{dngzddyqyzzdgjhz}, + #{dngzddygyqdgjhz}, + #{dngzddygyzdgjhz}, + #{dngzddygyzzdgjhz}, + #{dngzdglqdgjhz}, + #{dngzdglzdgjhz}, + #{dngzdglzzdgjhz}, + #{dngzjydzdqdgjhz}, + #{dngzjydzdzdgjhz}, + #{dngzjydzdzzdgjhz}, + #{dngzmkqwdqdgjhz}, + #{dngzmkqwdzdgjhz}, + #{dngzmkqwdzzdgjhz}, + #{dngzmkgwdqdgjhz}, + #{dngzmkgwdzdgjhz}, + #{dngzmkgwdzzdgjhz}, + #{dngdtgyqwgjhz}, + #{dngdtgyzdgjhz}, + #{dngdtgyyzgjhz}, + #{dngdtqyqwgjhz}, + #{dngdtqyzdgjhz}, + #{dngdtqyyzgjhz}, + #{dngdtycqwgjhz}, + #{dngdtyczdgjhz}, + #{dngdtycyzgjhz}, + #{dngdtqwqwgjhz}, + #{dngdtqwzdgjhz}, + #{dngdtqwyzgjhz}, + #{dngdtgwqwgjhz}, + #{dngdtgwzdgjhz}, + #{dngdtgwyzgjhz}, + #{dngdtwcqwgjhz}, + #{dngdtwczdgjhz}, + #{dngdtwcyzgjhz}, + #{dtsocdqwgjhz}, + #{dtsocdzdgjhz}, + #{dtsocdyzgjhz}, + #{dtsocgqwgjhz}, + #{dtsocgzdgjhz}, + #{dtsocgyzgjhz}, + #{dtsohdqwgjhz}, + #{dtsohdzdgjhz}, + #{dtsohdyzgjhz}, + #{dtsohgqwgjhz}, + #{dtsohgzdgjhz}, + #{dtsohgyzgjhz}, + #{dngzkslhz}, + #{dngckslgjhz}, + #{dngzdyyc}, + #{dnjcqdkyc}, + #{dnjcqbhyc}, + #{cdjz}, + #{fdjz}, + #{bmsxtgjhz}, + #{bmsxtgzhz}, + #{srin0}, + #{srin1}, + #{srin2}, + #{srin3}, + #{yl1}, + #{yl2}, + #{yl3}, + #{yl4}, + #{yl5}, + #{yl6}, + #{yl7}, + #{yl8}, + #{dngdzgwqwgjhz}, + #{dngdzgwzdgjhz}, + #{dngdzgwzzdgjhz}, + #{dnmkdygyqwgjhz}, + #{dnmkdygyzdgjhz}, + #{dnmkdygyyzgjhz}, + #{dnmkdyqyqwgjhz}, + #{dnmkdyqyzdgjhz}, + #{dnmkdyqyyzgjhz}, + #{dycjsl}, + #{wdcjsl}, + #{didodi0}, + #{didodi1}, + #{didodi2}, + #{didodi3}, + #{didodi4}, + #{didodi5}, + #{didodi6}, + #{didodi7}, + #{didodi8}, + #{didodi9}, + #{didodi10}, + #{didodi11}, + #{didodi12}, + #{kttxsl}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_stack_alarm_data + + data_timestamp = #{dataTimestamp}, + site_id = #{siteId}, + device_id = #{deviceId}, + bmsgzzt = #{bmsgzzt}, + jczt = #{jczt}, + jfzt = #{jfzt}, + dngzddyqyqdgjhz = #{dngzddyqyqdgjhz}, + dngzddyqyzdgjhz = #{dngzddyqyzdgjhz}, + dngzddyqyzzdgjhz = #{dngzddyqyzzdgjhz}, + dngzddygyqdgjhz = #{dngzddygyqdgjhz}, + dngzddygyzdgjhz = #{dngzddygyzdgjhz}, + dngzddygyzzdgjhz = #{dngzddygyzzdgjhz}, + dngzdglqdgjhz = #{dngzdglqdgjhz}, + dngzdglzdgjhz = #{dngzdglzdgjhz}, + dngzdglzzdgjhz = #{dngzdglzzdgjhz}, + dngzjydzdqdgjhz = #{dngzjydzdqdgjhz}, + dngzjydzdzdgjhz = #{dngzjydzdzdgjhz}, + dngzjydzdzzdgjhz = #{dngzjydzdzzdgjhz}, + dngzmkqwdqdgjhz = #{dngzmkqwdqdgjhz}, + dngzmkqwdzdgjhz = #{dngzmkqwdzdgjhz}, + dngzmkqwdzzdgjhz = #{dngzmkqwdzzdgjhz}, + dngzmkgwdqdgjhz = #{dngzmkgwdqdgjhz}, + dngzmkgwdzdgjhz = #{dngzmkgwdzdgjhz}, + dngzmkgwdzzdgjhz = #{dngzmkgwdzzdgjhz}, + dngdtgyqwgjhz = #{dngdtgyqwgjhz}, + dngdtgyzdgjhz = #{dngdtgyzdgjhz}, + dngdtgyyzgjhz = #{dngdtgyyzgjhz}, + dngdtqyqwgjhz = #{dngdtqyqwgjhz}, + dngdtqyzdgjhz = #{dngdtqyzdgjhz}, + dngdtqyyzgjhz = #{dngdtqyyzgjhz}, + dngdtycqwgjhz = #{dngdtycqwgjhz}, + dngdtyczdgjhz = #{dngdtyczdgjhz}, + dngdtycyzgjhz = #{dngdtycyzgjhz}, + dngdtqwqwgjhz = #{dngdtqwqwgjhz}, + dngdtqwzdgjhz = #{dngdtqwzdgjhz}, + dngdtqwyzgjhz = #{dngdtqwyzgjhz}, + dngdtgwqwgjhz = #{dngdtgwqwgjhz}, + dngdtgwzdgjhz = #{dngdtgwzdgjhz}, + dngdtgwyzgjhz = #{dngdtgwyzgjhz}, + dngdtwcqwgjhz = #{dngdtwcqwgjhz}, + dngdtwczdgjhz = #{dngdtwczdgjhz}, + dngdtwcyzgjhz = #{dngdtwcyzgjhz}, + dtsocdqwgjhz = #{dtsocdqwgjhz}, + dtsocdzdgjhz = #{dtsocdzdgjhz}, + dtsocdyzgjhz = #{dtsocdyzgjhz}, + dtsocgqwgjhz = #{dtsocgqwgjhz}, + dtsocgzdgjhz = #{dtsocgzdgjhz}, + dtsocgyzgjhz = #{dtsocgyzgjhz}, + dtsohdqwgjhz = #{dtsohdqwgjhz}, + dtsohdzdgjhz = #{dtsohdzdgjhz}, + dtsohdyzgjhz = #{dtsohdyzgjhz}, + dtsohgqwgjhz = #{dtsohgqwgjhz}, + dtsohgzdgjhz = #{dtsohgzdgjhz}, + dtsohgyzgjhz = #{dtsohgyzgjhz}, + dngzkslhz = #{dngzkslhz}, + dngckslgjhz = #{dngckslgjhz}, + dngzdyyc = #{dngzdyyc}, + dnjcqdkyc = #{dnjcqdkyc}, + dnjcqbhyc = #{dnjcqbhyc}, + cdjz = #{cdjz}, + fdjz = #{fdjz}, + bmsxtgjhz = #{bmsxtgjhz}, + bmsxtgzhz = #{bmsxtgzhz}, + srin0 = #{srin0}, + srin1 = #{srin1}, + srin2 = #{srin2}, + srin3 = #{srin3}, + yl1 = #{yl1}, + yl2 = #{yl2}, + yl3 = #{yl3}, + yl4 = #{yl4}, + yl5 = #{yl5}, + yl6 = #{yl6}, + yl7 = #{yl7}, + yl8 = #{yl8}, + dngdzgwqwgjhz = #{dngdzgwqwgjhz}, + dngdzgwzdgjhz = #{dngdzgwzdgjhz}, + dngdzgwzzdgjhz = #{dngdzgwzzdgjhz}, + dnmkdygyqwgjhz = #{dnmkdygyqwgjhz}, + dnmkdygyzdgjhz = #{dnmkdygyzdgjhz}, + dnmkdygyyzgjhz = #{dnmkdygyyzgjhz}, + dnmkdyqyqwgjhz = #{dnmkdyqyqwgjhz}, + dnmkdyqyzdgjhz = #{dnmkdyqyzdgjhz}, + dnmkdyqyyzgjhz = #{dnmkdyqyyzgjhz}, + dycjsl = #{dycjsl}, + wdcjsl = #{wdcjsl}, + didodi0 = #{didodi0}, + didodi1 = #{didodi1}, + didodi2 = #{didodi2}, + didodi3 = #{didodi3}, + didodi4 = #{didodi4}, + didodi5 = #{didodi5}, + didodi6 = #{didodi6}, + didodi7 = #{didodi7}, + didodi8 = #{didodi8}, + didodi9 = #{didodi9}, + didodi10 = #{didodi10}, + didodi11 = #{didodi11}, + didodi12 = #{didodi12}, + kttxsl = #{kttxsl}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_stack_alarm_data where id = #{id} + + + + delete from ems_stack_alarm_data where id in + + #{id} + + + \ No newline at end of file -- 2.49.0 From 0108b4f108511c37f3e542c95959960eec6d43db Mon Sep 17 00:00:00 2001 From: mashili Date: Fri, 24 Oct 2025 19:08:57 +0800 Subject: [PATCH 192/336] =?UTF-8?q?task61-=E5=91=8A=E8=AD=A6=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4=E6=96=B9=E6=A1=88=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsFaultProtectionPlanController.java | 105 ++++++++++ .../xzzn/ems/domain/EmsDevicesSetting.java | 13 ++ .../ems/domain/EmsFaultProtectionPlan.java | 191 ++++++++++++++++++ .../xzzn/ems/domain/vo/SiteDeviceListVo.java | 12 +- .../mapper/EmsFaultProtectionPlanMapper.java | 61 ++++++ .../IEmsFaultProtectionPlanService.java | 61 ++++++ .../EmsFaultProtectionPlanServiceImpl.java | 96 +++++++++ .../mapper/ems/EmsDevicesSettingMapper.xml | 7 +- .../ems/EmsFaultProtectionPlanMapper.xml | 117 +++++++++++ .../mapper/ems/EmsSiteSettingMapper.xml | 2 +- 10 files changed, 657 insertions(+), 8 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultProtectionPlan.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java new file mode 100644 index 0000000..6b9a747 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java @@ -0,0 +1,105 @@ +package com.xzzn.web.controller.ems; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.xzzn.ems.service.IEmsFaultProtectionPlanService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.xzzn.common.annotation.Log; +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.BusinessType; +import com.xzzn.ems.domain.EmsFaultProtectionPlan; +import com.xzzn.common.utils.poi.ExcelUtil; +import com.xzzn.common.core.page.TableDataInfo; + +/** + * 故障告警保护方案Controller + * + * @author xzzn + * @date 2025-10-22 + */ +@RestController +@RequestMapping("/ems/protectPlan") +public class EmsFaultProtectionPlanController extends BaseController +{ + @Autowired + private IEmsFaultProtectionPlanService emsFaultProtectionPlanService; + + /** + * 查询故障告警保护方案列表 + */ + @PreAuthorize("@ss.hasPermi('system:plan:list')") + @GetMapping("/list") + public TableDataInfo list(EmsFaultProtectionPlan emsFaultProtectionPlan) + { + startPage(); + List list = emsFaultProtectionPlanService.selectEmsFaultProtectionPlanList(emsFaultProtectionPlan); + return getDataTable(list); + } + + /** + * 导出故障告警保护方案列表 + */ + @PreAuthorize("@ss.hasPermi('system:plan:export')") + @Log(title = "故障告警保护方案", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsFaultProtectionPlan emsFaultProtectionPlan) + { + List list = emsFaultProtectionPlanService.selectEmsFaultProtectionPlanList(emsFaultProtectionPlan); + ExcelUtil util = new ExcelUtil(EmsFaultProtectionPlan.class); + util.exportExcel(response, list, "故障告警保护方案数据"); + } + + /** + * 获取故障告警保护方案详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:plan:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(emsFaultProtectionPlanService.selectEmsFaultProtectionPlanById(id)); + } + + /** + * 新增故障告警保护方案 + */ + @PreAuthorize("@ss.hasPermi('system:plan:add')") + @Log(title = "故障告警保护方案", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsFaultProtectionPlan emsFaultProtectionPlan) + { + return toAjax(emsFaultProtectionPlanService.insertEmsFaultProtectionPlan(emsFaultProtectionPlan)); + } + + /** + * 修改故障告警保护方案 + */ + @PreAuthorize("@ss.hasPermi('system:plan:edit')") + @Log(title = "故障告警保护方案", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsFaultProtectionPlan emsFaultProtectionPlan) + { + return toAjax(emsFaultProtectionPlanService.updateEmsFaultProtectionPlan(emsFaultProtectionPlan)); + } + + /** + * 删除故障告警保护方案 + */ + @PreAuthorize("@ss.hasPermi('system:plan:remove')") + @Log(title = "故障告警保护方案", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(emsFaultProtectionPlanService.deleteEmsFaultProtectionPlanByIds(ids)); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java index 694d0e8..d2a350e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java @@ -102,6 +102,10 @@ public class EmsDevicesSetting extends BaseEntity @Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”") private String deviceCategory; + /** 设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ + @Excel(name = "设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机") + private String runningStatus; + /** 设备图像地址 */ @Excel(name = "设备图像地址") private String pictureUrl; @@ -316,6 +320,14 @@ public class EmsDevicesSetting extends BaseEntity return deviceCategory; } + public String getRunningStatus() { + return runningStatus; + } + + public void setRunningStatus(String runningStatus) { + this.runningStatus = runningStatus; + } + public void setPictureUrl(String pictureUrl) { this.pictureUrl = pictureUrl; @@ -350,6 +362,7 @@ public class EmsDevicesSetting extends BaseEntity .append("deviceId", getDeviceId()) .append("parentId", getParentId()) .append("deviceCategory", getDeviceCategory()) + .append("runningStatus", getRunningStatus()) .append("pictureUrl", getPictureUrl()) .toString(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultProtectionPlan.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultProtectionPlan.java new file mode 100644 index 0000000..b8d7458 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultProtectionPlan.java @@ -0,0 +1,191 @@ +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_fault_protection_plan + * + * @author xzzn + * @date 2025-10-24 + */ +public class EmsFaultProtectionPlan extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 故障名称(如:总压高、放电总压过低) */ + @Excel(name = "故障名称", readConverterExp = "如=:总压高、放电总压过低") + private String faultName; + + /** 故障等级(1级/2级/3级) */ + @Excel(name = "故障等级", readConverterExp = "1=级/2级/3级") + private Integer faultLevel; + + /** 保护设置:点位/故障值/比较方式/释放值等 */ + @Excel(name = "保护设置:点位/故障值/比较方式/释放值等") + private String protectionSettings; + + /** 故障延时(秒,如:3S→3) */ + @Excel(name = "故障延时", readConverterExp = "秒=,如:3S→3") + private Long faultDelaySeconds; + + /** 保护方案:修改目标点位和值 */ + @Excel(name = "保护方案:修改目标点位和值") + private String protectionPlan; + + /** 释放延时(秒,如:5S→5,3级可能无) */ + @Excel(name = "释放延时", readConverterExp = "秒=,如:5S→5,3级可能无") + private Long releaseDelaySeconds; + + /** 处理方案描述(例如:报警,降功率50%运行) */ + @Excel(name = "处理方案描述", readConverterExp = "例=如:报警,降功率50%运行") + private String description; + + /** 是否触发告警(0 - 不告警;1 - 告警) */ + @Excel(name = "是否触发告警", readConverterExp = "0=不告警;1=告警") + private Integer isAlert; + + /** 方案是否启用 0-未启用 1-已启用 */ + @Excel(name = "方案是否启用 0-未启用 1-已启用") + private Long status; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public void setFaultName(String faultName) + { + this.faultName = faultName; + } + + public String getFaultName() + { + return faultName; + } + + public void setFaultLevel(Integer faultLevel) + { + this.faultLevel = faultLevel; + } + + public Integer getFaultLevel() + { + return faultLevel; + } + + public void setProtectionSettings(String protectionSettings) + { + this.protectionSettings = protectionSettings; + } + + public String getProtectionSettings() + { + return protectionSettings; + } + + public void setFaultDelaySeconds(Long faultDelaySeconds) + { + this.faultDelaySeconds = faultDelaySeconds; + } + + public Long getFaultDelaySeconds() + { + return faultDelaySeconds; + } + + public void setProtectionPlan(String protectionPlan) + { + this.protectionPlan = protectionPlan; + } + + public String getProtectionPlan() + { + return protectionPlan; + } + + public void setReleaseDelaySeconds(Long releaseDelaySeconds) + { + this.releaseDelaySeconds = releaseDelaySeconds; + } + + public Long getReleaseDelaySeconds() + { + return releaseDelaySeconds; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getDescription() + { + return description; + } + + public void setIsAlert(Integer isAlert) + { + this.isAlert = isAlert; + } + + public Integer getIsAlert() + { + return isAlert; + } + + public void setStatus(Long status) + { + this.status = status; + } + + public Long getStatus() + { + return status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("siteId", getSiteId()) + .append("faultName", getFaultName()) + .append("faultLevel", getFaultLevel()) + .append("protectionSettings", getProtectionSettings()) + .append("faultDelaySeconds", getFaultDelaySeconds()) + .append("protectionPlan", getProtectionPlan()) + .append("releaseDelaySeconds", getReleaseDelaySeconds()) + .append("description", getDescription()) + .append("isAlert", getIsAlert()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java index ba37363..f1df91e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -15,8 +15,8 @@ public class SiteDeviceListVo { private String deviceName; /** 设备类型 */ private String deviceType; - /** 通信状态 */ - private String communicationStatus; + /** 运行状态 */ + private String runningStatus; /** 设备类型 */ private String deviceCategory; /** 设备类型 */ @@ -78,12 +78,12 @@ public class SiteDeviceListVo { this.deviceType = deviceType; } - public String getCommunicationStatus() { - return communicationStatus; + public String getRunningStatus() { + return runningStatus; } - public void setCommunicationStatus(String communicationStatus) { - this.communicationStatus = communicationStatus; + public void setRunningStatus(String runningStatus) { + this.runningStatus = runningStatus; } public String getDeviceCategory() { diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java new file mode 100644 index 0000000..35c5eba --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsFaultProtectionPlan; + +/** + * 故障告警保护方案Mapper接口 + * + * @author xzzn + * @date 2025-10-24 + */ +public interface EmsFaultProtectionPlanMapper +{ + /** + * 查询故障告警保护方案 + * + * @param id 故障告警保护方案主键 + * @return 故障告警保护方案 + */ + public EmsFaultProtectionPlan selectEmsFaultProtectionPlanById(Long id); + + /** + * 查询故障告警保护方案列表 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 故障告警保护方案集合 + */ + public List selectEmsFaultProtectionPlanList(EmsFaultProtectionPlan emsFaultProtectionPlan); + + /** + * 新增故障告警保护方案 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 结果 + */ + public int insertEmsFaultProtectionPlan(EmsFaultProtectionPlan emsFaultProtectionPlan); + + /** + * 修改故障告警保护方案 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 结果 + */ + public int updateEmsFaultProtectionPlan(EmsFaultProtectionPlan emsFaultProtectionPlan); + + /** + * 删除故障告警保护方案 + * + * @param id 故障告警保护方案主键 + * @return 结果 + */ + public int deleteEmsFaultProtectionPlanById(Long id); + + /** + * 批量删除故障告警保护方案 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsFaultProtectionPlanByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java new file mode 100644 index 0000000..8746bf2 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsFaultProtectionPlan; + +/** + * 故障告警保护方案Service接口 + * + * @author xzzn + * @date 2025-10-24 + */ +public interface IEmsFaultProtectionPlanService +{ + /** + * 查询故障告警保护方案 + * + * @param id 故障告警保护方案主键 + * @return 故障告警保护方案 + */ + public EmsFaultProtectionPlan selectEmsFaultProtectionPlanById(Long id); + + /** + * 查询故障告警保护方案列表 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 故障告警保护方案集合 + */ + public List selectEmsFaultProtectionPlanList(EmsFaultProtectionPlan emsFaultProtectionPlan); + + /** + * 新增故障告警保护方案 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 结果 + */ + public int insertEmsFaultProtectionPlan(EmsFaultProtectionPlan emsFaultProtectionPlan); + + /** + * 修改故障告警保护方案 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 结果 + */ + public int updateEmsFaultProtectionPlan(EmsFaultProtectionPlan emsFaultProtectionPlan); + + /** + * 批量删除故障告警保护方案 + * + * @param ids 需要删除的故障告警保护方案主键集合 + * @return 结果 + */ + public int deleteEmsFaultProtectionPlanByIds(Long[] ids); + + /** + * 删除故障告警保护方案信息 + * + * @param id 故障告警保护方案主键 + * @return 结果 + */ + public int deleteEmsFaultProtectionPlanById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java new file mode 100644 index 0000000..d252b73 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper; +import com.xzzn.ems.domain.EmsFaultProtectionPlan; +import com.xzzn.ems.service.IEmsFaultProtectionPlanService; + +/** + * 故障告警保护方案Service业务层处理 + * + * @author xzzn + * @date 2025-10-24 + */ +@Service +public class EmsFaultProtectionPlanServiceImpl implements IEmsFaultProtectionPlanService +{ + @Autowired + private EmsFaultProtectionPlanMapper emsFaultProtectionPlanMapper; + + /** + * 查询故障告警保护方案 + * + * @param id 故障告警保护方案主键 + * @return 故障告警保护方案 + */ + @Override + public EmsFaultProtectionPlan selectEmsFaultProtectionPlanById(Long id) + { + return emsFaultProtectionPlanMapper.selectEmsFaultProtectionPlanById(id); + } + + /** + * 查询故障告警保护方案列表 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 故障告警保护方案 + */ + @Override + public List selectEmsFaultProtectionPlanList(EmsFaultProtectionPlan emsFaultProtectionPlan) + { + return emsFaultProtectionPlanMapper.selectEmsFaultProtectionPlanList(emsFaultProtectionPlan); + } + + /** + * 新增故障告警保护方案 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 结果 + */ + @Override + public int insertEmsFaultProtectionPlan(EmsFaultProtectionPlan emsFaultProtectionPlan) + { + emsFaultProtectionPlan.setCreateTime(DateUtils.getNowDate()); + return emsFaultProtectionPlanMapper.insertEmsFaultProtectionPlan(emsFaultProtectionPlan); + } + + /** + * 修改故障告警保护方案 + * + * @param emsFaultProtectionPlan 故障告警保护方案 + * @return 结果 + */ + @Override + public int updateEmsFaultProtectionPlan(EmsFaultProtectionPlan emsFaultProtectionPlan) + { + emsFaultProtectionPlan.setUpdateTime(DateUtils.getNowDate()); + return emsFaultProtectionPlanMapper.updateEmsFaultProtectionPlan(emsFaultProtectionPlan); + } + + /** + * 批量删除故障告警保护方案 + * + * @param ids 需要删除的故障告警保护方案主键 + * @return 结果 + */ + @Override + public int deleteEmsFaultProtectionPlanByIds(Long[] ids) + { + return emsFaultProtectionPlanMapper.deleteEmsFaultProtectionPlanByIds(ids); + } + + /** + * 删除故障告警保护方案信息 + * + * @param id 故障告警保护方案主键 + * @return 结果 + */ + @Override + public int deleteEmsFaultProtectionPlanById(Long id) + { + return emsFaultProtectionPlanMapper.deleteEmsFaultProtectionPlanById(id); + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 3c666ec..fa6e930 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -26,11 +26,12 @@ + - select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category, picture_url from ems_devices_setting + select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category, running_status, picture_url from ems_devices_setting @@ -88,6 +90,7 @@ device_id, parent_id, device_category, + running_status, picture_url, @@ -111,6 +114,7 @@ #{deviceId}, #{parentId}, #{deviceCategory}, + #{runningStatus}, #{pictureUrl}, @@ -138,6 +142,7 @@ device_id = #{deviceId}, parent_id = #{parentId}, device_category = #{deviceCategory}, + running_status = #{runningStatus}, picture_url = #{pictureUrl}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml new file mode 100644 index 0000000..c221022 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + select id, site_id, fault_name, fault_level, protection_settings, fault_delay_seconds, protection_plan, release_delay_seconds, description, is_alert, status, create_by, create_time, update_by, update_time from ems_fault_protection_plan + + + + + + + + insert into ems_fault_protection_plan + + site_id, + fault_name, + fault_level, + protection_settings, + fault_delay_seconds, + protection_plan, + release_delay_seconds, + description, + is_alert, + status, + create_by, + create_time, + update_by, + update_time, + + + #{siteId}, + #{faultName}, + #{faultLevel}, + #{protectionSettings}, + #{faultDelaySeconds}, + #{protectionPlan}, + #{releaseDelaySeconds}, + #{description}, + #{isAlert}, + #{status}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update ems_fault_protection_plan + + site_id = #{siteId}, + fault_name = #{faultName}, + fault_level = #{faultLevel}, + protection_settings = #{protectionSettings}, + fault_delay_seconds = #{faultDelaySeconds}, + protection_plan = #{protectionPlan}, + release_delay_seconds = #{releaseDelaySeconds}, + description = #{description}, + is_alert = #{isAlert}, + status = #{status}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from ems_fault_protection_plan where id = #{id} + + + + delete from ems_fault_protection_plan where id in + + #{id} + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index bf2424a..5d4f681 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -136,7 +136,7 @@ + + + update ems_strategy_running set `status`= #{status} where site_id = #{siteId} + + + \ No newline at end of file -- 2.49.0 From 82e63e28d3fd239ef20d8e37d57ec9b23cd52889 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 29 Oct 2025 18:38:34 +0800 Subject: [PATCH 196/336] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=9D=E6=8A=A4?= =?UTF-8?q?=E6=96=B9=E6=A1=88=E8=BD=AE=E8=AF=A2-=E5=88=9D=E7=A8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 5 +- .../manager/ModbusConnectionManager.java | 2 +- .../framework/web/service/ModbusService.java | 182 +++++++- .../com/xzzn/quartz/task/ModbusPoller.java | 4 + .../xzzn/quartz/task/ProtectionPlanTask.java | 416 ++++++++++++++++++ .../xzzn/ems/domain/vo/ProtectionPlanVo.java | 74 ++++ .../ems/domain/vo/ProtectionSettingVo.java | 118 +++++ .../impl/DDSDataProcessServiceImpl.java | 4 +- .../impl/FXXDataProcessServiceImpl.java | 4 +- 9 files changed, 803 insertions(+), 6 deletions(-) create mode 100644 ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionPlanVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 37d7394..8d080d8 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -63,7 +63,7 @@ public class RedisKeyConstants public static final String COOLING = "COOLING_"; /** - * 存放单个设备同步过来的原始数据 + * 存放单个设备同步过来的原始数据-最晚一次数据 */ public static final String ORIGINAL_MQTT_DATA = "MQTT_"; @@ -87,4 +87,7 @@ public class RedisKeyConstants public static final String DDS_TOTAL_REVENUE = "total_revenue_"; /** fx实时总收益和当日实时收益 */ public static final String FXX_REALTIME_REVENUE = "realtime_revenue_"; + + /** 每个设备最新数据-设置失效时间-判断是否正常同步数据 */ + public static final String SYNC_DATA= "SYNC_DATA_"; } diff --git a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java index 6ca81fc..cf968c9 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java +++ b/ems-framework/src/main/java/com/xzzn/framework/manager/ModbusConnectionManager.java @@ -95,7 +95,7 @@ public class ModbusConnectionManager implements ApplicationRunner { */ private TCPMasterConnection createRawConnection(EmsDevicesSetting device) throws Exception { try { - InetAddress addr = InetAddress.getByName("192.168.80.100"); + InetAddress addr = InetAddress.getByName("10.1.0.230"); TCPMasterConnection connection = new TCPMasterConnection(addr); connection.setPort(502); connection.setTimeout(5000); diff --git a/ems-framework/src/main/java/com/xzzn/framework/web/service/ModbusService.java b/ems-framework/src/main/java/com/xzzn/framework/web/service/ModbusService.java index 5783d18..ed7ac59 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/web/service/ModbusService.java +++ b/ems-framework/src/main/java/com/xzzn/framework/web/service/ModbusService.java @@ -2,11 +2,16 @@ package com.xzzn.framework.web.service; import com.ghgande.j2mod.modbus.ModbusException; import com.ghgande.j2mod.modbus.ModbusIOException; +import com.ghgande.j2mod.modbus.io.ModbusSerialTransaction; import com.ghgande.j2mod.modbus.io.ModbusTCPTransaction; import com.ghgande.j2mod.modbus.msg.ReadInputRegistersRequest; import com.ghgande.j2mod.modbus.msg.ReadInputRegistersResponse; +import com.ghgande.j2mod.modbus.msg.WriteMultipleRegistersRequest; +import com.ghgande.j2mod.modbus.msg.WriteSingleRegisterRequest; import com.ghgande.j2mod.modbus.net.SerialConnection; import com.ghgande.j2mod.modbus.net.TCPMasterConnection; +import com.ghgande.j2mod.modbus.procimg.Register; +import com.ghgande.j2mod.modbus.procimg.SimpleRegister; import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,8 +47,26 @@ public class ModbusService { } } - private int[] readRtuRegisters(SerialConnection connection, int startAddr, int count) { - return null; + private int[] readRtuRegisters(SerialConnection connection, int startAddr, int count) throws ModbusException { + if (!connection.isOpen()) { + throw new ModbusIOException("RTU连接未建立"); + } + ReadInputRegistersRequest request = new ReadInputRegistersRequest(startAddr, count); + ModbusSerialTransaction transaction = new ModbusSerialTransaction(connection); + transaction.setRequest(request); + transaction.setRetries(2); + + try { + transaction.execute(); + ReadInputRegistersResponse response = (ReadInputRegistersResponse) transaction.getResponse(); + if (response == null) { + throw new ModbusException("RTU响应为空"); + } + return parseRegisters(response); + } catch (ModbusException e) { + logger.error("读取RTU寄存器失败: {}", e.getMessage()); + throw e; + } } private int[] readTcpRegisters(TCPMasterConnection conn, int start, int count) throws ModbusException { @@ -98,4 +121,159 @@ public class ModbusService { return new int[0]; } + /** + * 写入单个寄存器(支持TCP/RTU) + * @param connection 连接对象(TCPMasterConnection 或 SerialConnection) + * @param registerAddr 寄存器地址 + * @param value 要写入的值(16位整数) + */ + @Retryable( + value = {ModbusException.class}, + maxAttempts = 3, + backoff = @Backoff(delay = 1000, multiplier = 2) + ) + @CircuitBreaker(name = "modbusOperation", fallbackMethod = "writeRegisterFallback") + public boolean writeSingleRegister(Object connection, int registerAddr, int value) throws ModbusException { + try { + if (connection instanceof TCPMasterConnection) { + return writeTcpSingleRegister((TCPMasterConnection) connection, registerAddr, value); + } else if (connection instanceof SerialConnection) { + return writeRtuSingleRegister((SerialConnection) connection, registerAddr, value); + } + throw new IllegalArgumentException("不支持的连接类型: " + connection.getClass().getName()); + } catch (ModbusIOException e) { + throw new ModbusException("写入通信故障", e); + } catch (Exception e) { + throw new ModbusException("写入系统错误", e); + } + } + + /** + * 写入多个寄存器(支持TCP/RTU) + * @param connection 连接对象 + * @param startAddr 起始寄存器地址 + * @param values 要写入的值数组(每个值为16位整数) + */ + @Retryable( + value = {ModbusException.class}, + maxAttempts = 3, + backoff = @Backoff(delay = 1000, multiplier = 2) + ) + @CircuitBreaker(name = "modbusOperation", fallbackMethod = "writeRegisterFallback") + public boolean writeMultipleRegisters(Object connection, int startAddr, int[] values) throws ModbusException { + try { + if (connection instanceof TCPMasterConnection) { + return writeTcpMultipleRegisters((TCPMasterConnection) connection, startAddr, values); + } else if (connection instanceof SerialConnection) { + return writeRtuMultipleRegisters((SerialConnection) connection, startAddr, values); + } + throw new IllegalArgumentException("不支持的连接类型: " + connection.getClass().getName()); + } catch (ModbusIOException e) { + throw new ModbusException("写入通信故障", e); + } catch (Exception e) { + throw new ModbusException("写入系统错误", e); + } + } + + // ==================== TCP写入实现 ==================== + private boolean writeTcpSingleRegister(TCPMasterConnection conn, int registerAddr, int value) throws ModbusException { + if (!conn.isConnected()) { + throw new ModbusIOException("TCP连接未建立,无法写入"); + } + // 创建写入单个寄存器的请求(功能码06) + WriteSingleRegisterRequest request = new WriteSingleRegisterRequest(registerAddr, new SimpleRegister(value)); + ModbusTCPTransaction transaction = new ModbusTCPTransaction(conn); + transaction.setRequest(request); + transaction.setRetries(2); + + try { + transaction.execute(); + logger.info("TCP写入单个寄存器成功,地址:{},值:{}", registerAddr, value); + return true; + } catch (ModbusException e) { + logger.error("TCP写入单个寄存器失败,地址:{},值:{}", registerAddr, value, e); + throw e; + } + } + + private boolean writeTcpMultipleRegisters(TCPMasterConnection conn, int startAddr, int[] values) throws ModbusException { + if (!conn.isConnected()) { + throw new ModbusIOException("TCP连接未建立,无法写入"); + } + // 转换值数组为寄存器数组 + Register[] registers = new Register[values.length]; + for (int i = 0; i < values.length; i++) { + registers[i] = new SimpleRegister(values[i]); + } + // 创建写入多个寄存器的请求(功能码16) + WriteMultipleRegistersRequest request = new WriteMultipleRegistersRequest(startAddr, registers); + ModbusTCPTransaction transaction = new ModbusTCPTransaction(conn); + transaction.setRequest(request); + transaction.setRetries(2); + + try { + transaction.execute(); + logger.info("TCP写入多个寄存器成功,起始地址:{},数量:{}", startAddr, values.length); + return true; + } catch (ModbusException e) { + logger.error("TCP写入多个寄存器失败,起始地址:{}", startAddr, e); + throw e; + } + } + + + // ==================== RTU写入实现 ==================== + private boolean writeRtuSingleRegister(SerialConnection connection, int registerAddr, int value) throws ModbusException { + if (!connection.isOpen()) { + throw new ModbusIOException("RTU串口未打开,请先建立连接"); + } + WriteSingleRegisterRequest request = new WriteSingleRegisterRequest(registerAddr, new SimpleRegister(value)); + ModbusSerialTransaction transaction = new ModbusSerialTransaction(connection); + transaction.setRequest(request); + transaction.setRetries(2); + + try { + transaction.execute(); + logger.info("RTU写入单个寄存器成功,地址:{},值:{}", registerAddr, value); + return true; + } catch (ModbusException e) { + logger.error("RTU写入单个寄存器失败,地址:{},值:{}", registerAddr, value, e); + throw e; + } + } + + private boolean writeRtuMultipleRegisters(SerialConnection connection, int startAddr, int[] values) throws ModbusException { + if (!connection.isOpen()) { + throw new ModbusIOException("RTU串口未打开,请先建立连接"); + } + Register[] registers = new Register[values.length]; + for (int i = 0; i < values.length; i++) { + registers[i] = new SimpleRegister(values[i]); + } + WriteMultipleRegistersRequest request = new WriteMultipleRegistersRequest(startAddr, registers); + ModbusSerialTransaction transaction = new ModbusSerialTransaction(connection); + transaction.setRequest(request); + transaction.setRetries(2); + + try { + transaction.execute(); + logger.info("RTU写入多个寄存器成功,起始地址:{},数量:{}", startAddr, values.length); + return true; + } catch (ModbusException e) { + logger.error("RTU写入多个寄存器失败,起始地址:{}", startAddr, e); + throw e; + } + } + + + // ==================== 写入操作的降级方法 ==================== + public boolean writeRegisterFallback(Object connection, int addr, int value, Exception e) { + logger.warn("写入单个寄存器降级(原因: {}),地址:{}", e.getMessage(), addr); + return false; + } + + public boolean writeRegisterFallback(Object connection, int startAddr, int[] values, Exception e) { + logger.warn("写入多个寄存器降级(原因: {}),起始地址:{}", e.getMessage(), startAddr); + return false; + } } \ No newline at end of file diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java index ea4a175..4032535 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java @@ -71,6 +71,10 @@ public class ModbusPoller { // 获取连接 wrapper = connectionManager.getConnection(device); + if(wrapper == null || !wrapper.isActive()){ + logger.error("轮询设备{}连接失败: {}", device.getId()); + return; + } // 读取保持寄存器 int[] data = modbusService.readHoldingRegisters( wrapper.getConnection(), diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java new file mode 100644 index 0000000..64cd426 --- /dev/null +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java @@ -0,0 +1,416 @@ +package com.xzzn.quartz.task; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.AlarmLevelStatus; +import com.xzzn.common.enums.AlarmStatus; +import com.xzzn.common.enums.ProtPlanStatus; +import com.xzzn.common.enums.StrategyStatus; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsAlarmRecords; +import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.EmsFaultProtectionPlan; +import com.xzzn.ems.domain.vo.ProtectionPlanVo; +import com.xzzn.ems.domain.vo.ProtectionSettingVo; +import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper; +import com.xzzn.ems.mapper.EmsStrategyRunningMapper; +import com.xzzn.ems.service.IEmsFaultProtectionPlanService; +import com.xzzn.framework.manager.ModbusConnectionManager; +import com.xzzn.framework.manager.ModbusConnectionWrapper; +import com.xzzn.framework.web.service.ModbusService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 告警保护方案轮询 + * + * @author xzzn + */ +@Component("protectionPlanTask") +public class ProtectionPlanTask { + private static final Logger logger = LoggerFactory.getLogger(ProtectionPlanTask.class); + @Resource(name = "scheduledExecutorService") + private ScheduledExecutorService scheduledExecutorService; + @Autowired + private IEmsFaultProtectionPlanService iEmsFaultProtectionPlanService; + @Autowired + private EmsAlarmRecordsMapper emsAlarmRecordsMapper; + @Autowired + private EmsStrategyRunningMapper emsStrategyRunningMapper; + @Autowired + private EmsFaultProtectionPlanMapper emsFaultProtectionPlanMapper; + @Autowired + private RedisCache redisCache; + private static final ObjectMapper objectMapper = new ObjectMapper(); + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; + @Autowired + private ModbusConnectionManager connectionManager; + @Autowired + private ModbusService modbusService; + + public ProtectionPlanTask(IEmsFaultProtectionPlanService iEmsFaultProtectionPlanService) { + this.iEmsFaultProtectionPlanService = iEmsFaultProtectionPlanService; + } + + public void pollPlanList() { + Long planId = 0L; + try { + // 获取所有方案,轮询 + List planList = iEmsFaultProtectionPlanService.selectEmsFaultProtectionPlanList(null); + + for (EmsFaultProtectionPlan plan : planList) { + planId = plan.getId(); + String siteId = plan.getSiteId(); + if (StringUtils.isEmpty(siteId)) { + return; + } + // 保护前提 + String protectionSettings = plan.getProtectionSettings(); + final List protSettings = objectMapper.readValue( + protectionSettings, + new TypeReference>() {} + ); + if (protSettings == null) { + return; + } + + // 处理告警保护方案 + boolean isHighLevel = dealWithProtectionPlan(plan, protSettings); + if (isHighLevel) { + // 触发最高故障等级-结束循环 + return; + } + } + } catch (Exception e) { + logger.error("轮询失败,方案id为:", planId, e); + } + } + + // 处理告警保护方案-返回触发下发方案时是否最高等级 + private boolean dealWithProtectionPlan(EmsFaultProtectionPlan plan, List protSettings) { + boolean isHighLevel = false; + + String siteId = plan.getSiteId(); + final Integer isAlertAlarm = plan.getIsAlert(); + final Long status = plan.getStatus(); + // 看方案是否启用,走不同判断 + if (status == ProtPlanStatus.STOP.getCode()) { + // 未启用,获取方案的故障值与最新数据判断是否需要下发方案 + if(checkIsNeedIssuedPlan(protSettings, siteId)){ + if("3".equals(plan.getFaultLevel())){ + isHighLevel = true;//最高故障等级 + } + // 延时 + final int faultDelay = plan.getFaultDelaySeconds().intValue(); + ScheduledFuture delayTask = scheduledExecutorService.schedule(() -> { + // 延时后再次确认是否仍满足触发条件(防止期间状态变化) + if (checkIsNeedIssuedPlan(protSettings, siteId)) { + // 判断是否需要生成告警 + if (isAlertAlarm == 1) { + logger.info("<生成告警> 方案ID:{},站点:{}", plan.getId(), siteId); + EmsAlarmRecords alarmRecords = addAlarmRecord(siteId,"PCS", plan.getDescription(), + getAlarmLevel(plan.getFaultLevel())); + emsAlarmRecordsMapper.insertEmsAlarmRecords(alarmRecords); + } + + // 是否有保护方案,有则通过modbus连接设备下发方案 + String protPlanJson = plan.getProtectionPlan(); + if (protPlanJson != null && !protPlanJson.isEmpty()) { + logger.info("<下发保护方案> 方案内容:{}", protPlanJson); + executeProtectionActions(protPlanJson,siteId,plan.getId()); // 执行Modbus指令 + } + + // 更新方案状态为“已启用” + logger.info("<方案已启用> 方案ID:{}", plan.getId()); + plan.setStatus(ProtPlanStatus.RUNNING.getCode()); + emsFaultProtectionPlanMapper.updateEmsFaultProtectionPlan(plan); + } + }, faultDelay, TimeUnit.SECONDS); + } + } else { + String deviceId = protSettings.get(0).getDeviceId(); + // 已启用,则获取方案的释放值与最新数据判断是否需要取消方案 + if(checkIsNeedCancelPlan(protSettings, siteId)){ + // 延时, + int releaseDelay = plan.getReleaseDelaySeconds().intValue(); + ScheduledFuture delayTask = scheduledExecutorService.schedule(() -> { + // 判断是否已存在未处理告警,有着取消 + if(isAlertAlarm == 1){ + logger.info("<取消告警>"); + EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.getFailedRecord(siteId,deviceId, + plan.getDescription(),getAlarmLevel(plan.getFaultLevel())); + if(emsAlarmRecords != null){ + emsAlarmRecords.setStatus(AlarmStatus.DONE.getCode()); + emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords); + } + } + // 更新该站点策略为启用 + updateStrategyRunning(siteId); + }, releaseDelay, TimeUnit.SECONDS); + } + } + + return isHighLevel; + } + + // 下发保护方案 + private void executeProtectionActions(String protPlanJson, String siteId, Long planId){ + final List protPlanList; + try { + protPlanList = objectMapper.readValue( + protPlanJson, + new TypeReference>() {} + ); + if (protPlanList == null) { + return; + } + + // 遍历保护方案 + for (ProtectionPlanVo plan : protPlanList) { + if (StringUtils.isEmpty(plan.getDeviceId()) || StringUtils.isEmpty(plan.getPoint())) { + return; + } + + // 通过modbus连接设备,发送数据 + executeSinglePlan(plan,siteId); + } + + + } catch (Exception e) { + logger.error("下发保护方案失败,方案id为:", planId, e); + } + } + + private void executeSinglePlan(ProtectionPlanVo plan, String siteId) throws Exception { + String deviceId = plan.getDeviceId(); + // 获取设备地址信息 + EmsDevicesSetting device = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); + if (device == null || StringUtils.isEmpty(device.getIpAddress()) || device.getIpPort()==null) { + return; + } + // 获取设备连接 + ModbusConnectionWrapper wrapper = connectionManager.getConnection(device); + if (wrapper == null || !wrapper.isActive()) { + logger.info("<设备连接无效>"); + return; + } + + // 写入寄存器 + boolean success = modbusService.writeSingleRegister( + wrapper.getConnection(), + 1, + plan.getValue().intValue()); + + if (!success) { + logger.error("写入失败,设备地址:{}", device.getIpAddress()); + } + + } + + // 校验释放值是否取消方案 + private boolean checkIsNeedCancelPlan(List protSettings, String siteId) { + BigDecimal releaseValue = BigDecimal.ZERO; + + StringBuilder conditionSb = new StringBuilder(); + for (int i = 0; i < protSettings.size(); i++) { + ProtectionSettingVo vo = protSettings.get(i); + String deviceId = vo.getDeviceId(); + String point = vo.getPoint(); + releaseValue = vo.getFaultValue(); + if(StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(point) || releaseValue == null + || StringUtils.isEmpty(vo.getReleaseOperator())){ + return false; + } + // 获取点位最新值 + BigDecimal lastPointValue = getPointLastValue(deviceId, point, siteId); + if(lastPointValue == null){ + return false; + } + + // 拼接校验语句-最新值+比较方式+故障值+与下一点位关系(最后一个条件后不加关系) + conditionSb.append(lastPointValue).append(vo.getReleaseOperator()).append(releaseValue); + if (i < protSettings.size() - 1) { + String relation = vo.getRelationNext(); + conditionSb.append(" ").append(relation).append(" "); + } + + // 执行比较语句 + return executeWithParser(conditionSb.toString()); + } + return true; + } + + // 校验故障值是否需要下发方案 + private boolean checkIsNeedIssuedPlan(List protSettings, String siteId) { + BigDecimal faultValue = BigDecimal.ZERO; + + StringBuilder conditionSb = new StringBuilder(); + for (int i = 0; i < protSettings.size(); i++) { + ProtectionSettingVo vo = protSettings.get(i); + String deviceId = vo.getDeviceId(); + String point = vo.getPoint(); + faultValue = vo.getFaultValue(); + if(StringUtils.isEmpty(deviceId) || StringUtils.isEmpty(point) || faultValue == null + || StringUtils.isEmpty(vo.getFaultOperator())){ + return false; + } + // 获取点位最新值 + BigDecimal lastPointValue = getPointLastValue(deviceId, point, siteId); + if(lastPointValue == null){ + return false; + } + + // 拼接校验语句-最新值+比较方式+故障值+与下一点位关系(最后一个条件后不加关系) + conditionSb.append(lastPointValue).append(vo.getFaultOperator()).append(faultValue); + if (i < protSettings.size() - 1) { + String relation = vo.getRelationNext(); + conditionSb.append(" ").append(relation).append(" "); + } + + // 执行比较语句 + return executeWithParser(conditionSb.toString()); + } + return true; + } + + private BigDecimal getPointLastValue(String deviceId, String point, String siteId) { + JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.SYNC_DATA + siteId + "_" + deviceId); + if(mqttJson == null){ + return null; + } + String jsonData = mqttJson.get("Data").toString(); + if(StringUtils.isEmpty(jsonData)){ + return null; + } + Map obj = JSON.parseObject(jsonData, new com.alibaba.fastjson2.TypeReference>() {}); + return StringUtils.getBigDecimal(obj.get(point)); + } + + // 更新站点策略为启用 + private void updateStrategyRunning(String siteId) { + if (!StringUtils.isEmpty(siteId)) { + emsStrategyRunningMapper.updateStatusRunning(siteId, StrategyStatus.RUNNING.getCode()); + } + } + + private EmsAlarmRecords addAlarmRecord(String siteId, String deviceId,String content,String level) { + EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); + emsAlarmRecords.setSiteId(siteId); + emsAlarmRecords.setDeviceId(deviceId); + emsAlarmRecords.setAlarmContent(content); + emsAlarmRecords.setAlarmLevel(level); + emsAlarmRecords.setAlarmStartTime(new Date()); + emsAlarmRecords.setStatus(AlarmStatus.WAITING.getCode()); + emsAlarmRecords.setDeviceType("TCP"); + emsAlarmRecords.setCreateBy("system"); + emsAlarmRecords.setCreateTime(new Date()); + return emsAlarmRecords; + } + + // 故障等级-告警等级匹配 + private String getAlarmLevel(Integer faultLevel) { + if (ObjectUtils.isEmpty(faultLevel) || faultLevel < 1 || faultLevel > 3) { + logger.warn("非法故障等级:{},默认返回普通告警", faultLevel); + return AlarmLevelStatus.EMERGENCY.getCode(); + } + switch (faultLevel) { + case 1: return AlarmLevelStatus.GENERAL.getCode(); + case 2: return AlarmLevelStatus.SERIOUS.getCode(); + case 3: return AlarmLevelStatus.EMERGENCY.getCode(); + default: + logger.error("未匹配的故障等级:{}", faultLevel); + return AlarmLevelStatus.EMERGENCY.getCode(); + } + } + + // 自定义表达式解析器(仅支持简单运算符和逻辑关系) + public boolean executeWithParser(String conditionStr) { + if (conditionStr == null || conditionStr.isEmpty()) { + return false; + } + + // 1. 拆分逻辑关系(提取 && 或 ||) + List logicRelations = new ArrayList<>(); + Pattern logicPattern = Pattern.compile("(&&|\\|\\|)"); + Matcher logicMatcher = logicPattern.matcher(conditionStr); + while (logicMatcher.find()) { + logicRelations.add(logicMatcher.group()); + } + + // 2. 拆分原子条件(如 "3.55>3.52") + String[] atomicConditions = logicPattern.split(conditionStr); + + // 3. 解析每个原子条件并计算结果 + List atomicResults = new ArrayList<>(); + Pattern conditionPattern = Pattern.compile("(\\d+\\.?\\d*)\\s*([><]=?|==)\\s*(\\d+\\.?\\d*)"); + for (String atomic : atomicConditions) { + Matcher matcher = conditionPattern.matcher(atomic.trim()); + if (!matcher.matches()) { + logger.error("无效的原子条件:{}", atomic); + return false; + } + double left = Double.parseDouble(matcher.group(1)); // 左值(最新值) + String operator = matcher.group(2); // 运算符 + double right = Double.parseDouble(matcher.group(3)); // 右值(故障值) + + // 执行比较 + boolean result; + switch (operator) { + case ">": + result = left > right; + break; + case ">=": + result = left >= right; + break; + case "<": + result = left < right; + break; + case "<=": + result = left <= right; + break; + case "==": + result = left == right; + break; + default: + result = false; + break; + } + atomicResults.add(result); + } + + // 4. 组合原子结果(根据逻辑关系) + boolean finalResult = atomicResults.get(0); + for (int i = 0; i < logicRelations.size(); i++) { + String relation = logicRelations.get(i); + boolean nextResult = atomicResults.get(i + 1); + if ("&&".equals(relation)) { + finalResult = finalResult && nextResult; + } else if ("||".equals(relation)) { + finalResult = finalResult || nextResult; + } + } + return finalResult; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionPlanVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionPlanVo.java new file mode 100644 index 0000000..c6d12b0 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionPlanVo.java @@ -0,0 +1,74 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 告警保护方案-保护方案设置 + */ +public class ProtectionPlanVo { + /** 设备 */ + private String deviceId; + + /** 点位 */ + private String point; + + /** 点位名称 */ + private String pointName; + + /** 设置值 */ + private BigDecimal value; + + /** 设备类型 */ + private String deviceCategory; + + /** 设备类型名称 */ + private String categoryName; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getPoint() { + return point; + } + + public void setPoint(String point) { + this.point = point; + } + + public String getPointName() { + return pointName; + } + + public void setPointName(String pointName) { + this.pointName = pointName; + } + + public BigDecimal getValue() { + return value; + } + + public void setValue(BigDecimal value) { + this.value = value; + } + + public String getDeviceCategory() { + return deviceCategory; + } + + public void setDeviceCategory(String deviceCategory) { + this.deviceCategory = deviceCategory; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java new file mode 100644 index 0000000..229b60b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java @@ -0,0 +1,118 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 告警保护方案-保护前提设置 + */ +public class ProtectionSettingVo { + /** 设备 */ + private String deviceId; + + /** 点位 */ + private String point; + + /** 点位名称 */ + private String pointName; + + /** 故障值 */ + private BigDecimal faultValue; + + /** 故障值比较方式 如"<="、"<"、"=="、">="、">" */ + private String faultOperator; + + /** 释放值 */ + private BigDecimal releaseValue; + + /** 释放值比较方式 如"<="、"<"、"=="、">="、">"*/ + private String releaseOperator; + + /** 与下一点位关系: && 、|| */ + private String relationNext; + + /** 设备类型 */ + private String deviceCategory; + + /** 设备类型名称 */ + private String categoryName; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getPoint() { + return point; + } + + public void setPoint(String point) { + this.point = point; + } + + public String getPointName() { + return pointName; + } + + public void setPointName(String pointName) { + this.pointName = pointName; + } + + public BigDecimal getFaultValue() { + return faultValue; + } + + public void setFaultValue(BigDecimal faultValue) { + this.faultValue = faultValue; + } + + public String getFaultOperator() { + return faultOperator; + } + + public void setFaultOperator(String faultOperator) { + this.faultOperator = faultOperator; + } + + public BigDecimal getReleaseValue() { + return releaseValue; + } + + public void setReleaseValue(BigDecimal releaseValue) { + this.releaseValue = releaseValue; + } + + public String getReleaseOperator() { + return releaseOperator; + } + + public void setReleaseOperator(String releaseOperator) { + this.releaseOperator = releaseOperator; + } + + public String getRelationNext() { + return relationNext; + } + + public void setRelationNext(String relationNext) { + this.relationNext = relationNext; + } + + public String getDeviceCategory() { + return deviceCategory; + } + + public void setDeviceCategory(String deviceCategory) { + this.deviceCategory = deviceCategory; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index b7cad26..0e67719 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -108,8 +108,10 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return; } - // 存放mqtt原始每个设备数据,便于后面点位获取数据 + // 存放mqtt原始每个设备最晚一次数据,便于后面点位获取数据 redisCache.setCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + SITE_ID + "_" + deviceId, obj); + // 存放每次同步数据,失效时间(同同步时间)-用于判断是否正常同步数据 + redisCache.setCacheObject(RedisKeyConstants.SYNC_DATA + SITE_ID + "_" + deviceId, obj, 2, TimeUnit.MINUTES); // 处理相关数据 if (deviceId.contains("BMSD")) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 8aad846..32bed2c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -110,8 +110,10 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl return; } - // 存放mqtt原始每个设备数据,便于后面点位获取数据 + // 存放mqtt原始每个设备最晚一次数据,便于后面点位获取数据 redisCache.setCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + SITE_ID + "_" + deviceId, obj); + // 存放每次同步数据,失效时间(同同步时间)-用于判断是否正常同步数据 + redisCache.setCacheObject(RedisKeyConstants.SYNC_DATA + SITE_ID + "_" + deviceId, obj, 1, TimeUnit.MINUTES); if (deviceId.contains("BMSD")) { batteryStackDataProcess(deviceId, jsonData); -- 2.49.0 From 3598cb2d66143979fed66679f0ab845ad27317bc Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 30 Oct 2025 16:52:06 +0800 Subject: [PATCH 197/336] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=9D=E6=8A=A4?= =?UTF-8?q?=E6=96=B9=E6=A1=88=E8=BD=AE=E8=AF=A2-=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/quartz/task/ProtectionPlanTask.java | 29 ++++++++++++------- .../ems/mapper/EmsAlarmRecordsMapper.java | 5 ++-- .../ems/mapper/EmsStrategyRunningMapper.java | 5 ++++ .../mapper/ems/EmsAlarmRecordsMapper.xml | 6 ++-- .../mapper/ems/EmsStrategyRunningMapper.xml | 20 ++++++++++--- 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java index 64cd426..b3f74bf 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java @@ -14,6 +14,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsAlarmRecords; import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.EmsFaultProtectionPlan; +import com.xzzn.ems.domain.EmsStrategyRunning; import com.xzzn.ems.domain.vo.ProtectionPlanVo; import com.xzzn.ems.domain.vo.ProtectionSettingVo; import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; @@ -104,7 +105,7 @@ public class ProtectionPlanTask { } } } catch (Exception e) { - logger.error("轮询失败,方案id为:", planId, e); + logger.error("轮询失败,方案id为:{}", planId, e); } } @@ -130,7 +131,7 @@ public class ProtectionPlanTask { // 判断是否需要生成告警 if (isAlertAlarm == 1) { logger.info("<生成告警> 方案ID:{},站点:{}", plan.getId(), siteId); - EmsAlarmRecords alarmRecords = addAlarmRecord(siteId,"PCS", plan.getDescription(), + EmsAlarmRecords alarmRecords = addAlarmRecord(siteId,plan.getFaultName(), getAlarmLevel(plan.getFaultLevel())); emsAlarmRecordsMapper.insertEmsAlarmRecords(alarmRecords); } @@ -139,7 +140,7 @@ public class ProtectionPlanTask { String protPlanJson = plan.getProtectionPlan(); if (protPlanJson != null && !protPlanJson.isEmpty()) { logger.info("<下发保护方案> 方案内容:{}", protPlanJson); - executeProtectionActions(protPlanJson,siteId,plan.getId()); // 执行Modbus指令 + //executeProtectionActions(protPlanJson,siteId,plan.getId()); // 执行Modbus指令 } // 更新方案状态为“已启用” @@ -150,7 +151,6 @@ public class ProtectionPlanTask { }, faultDelay, TimeUnit.SECONDS); } } else { - String deviceId = protSettings.get(0).getDeviceId(); // 已启用,则获取方案的释放值与最新数据判断是否需要取消方案 if(checkIsNeedCancelPlan(protSettings, siteId)){ // 延时, @@ -159,13 +159,18 @@ public class ProtectionPlanTask { // 判断是否已存在未处理告警,有着取消 if(isAlertAlarm == 1){ logger.info("<取消告警>"); - EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.getFailedRecord(siteId,deviceId, - plan.getDescription(),getAlarmLevel(plan.getFaultLevel())); + EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.getFailedRecord(siteId, + plan.getFaultName(),getAlarmLevel(plan.getFaultLevel())); if(emsAlarmRecords != null){ emsAlarmRecords.setStatus(AlarmStatus.DONE.getCode()); emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords); } } + // 更新方案状态为“未启用” + logger.info("<方案变更为未启用> 方案ID:{}", plan.getId()); + plan.setStatus(ProtPlanStatus.STOP.getCode()); + plan.setUpdateBy("system"); + emsFaultProtectionPlanMapper.updateEmsFaultProtectionPlan(plan); // 更新该站点策略为启用 updateStrategyRunning(siteId); }, releaseDelay, TimeUnit.SECONDS); @@ -310,15 +315,19 @@ public class ProtectionPlanTask { // 更新站点策略为启用 private void updateStrategyRunning(String siteId) { - if (!StringUtils.isEmpty(siteId)) { - emsStrategyRunningMapper.updateStatusRunning(siteId, StrategyStatus.RUNNING.getCode()); + // 获取是否有正在运行的策略,如果有则不更改 + EmsStrategyRunning emsStrategyRunning = emsStrategyRunningMapper.getRunningStrategy(siteId); + if (emsStrategyRunning == null) { + // 获取已存在并且状态为:未启用和已暂停的最晚一条策略,更新为已启用 + emsStrategyRunning = emsStrategyRunningMapper.getPendingStrategy(siteId); + emsStrategyRunning.setStatus(StrategyStatus.RUNNING.getCode()); + emsStrategyRunningMapper.updateEmsStrategyRunning(emsStrategyRunning); } } - private EmsAlarmRecords addAlarmRecord(String siteId, String deviceId,String content,String level) { + private EmsAlarmRecords addAlarmRecord(String siteId, String content,String level) { EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); emsAlarmRecords.setSiteId(siteId); - emsAlarmRecords.setDeviceId(deviceId); emsAlarmRecords.setAlarmContent(content); emsAlarmRecords.setAlarmLevel(level); emsAlarmRecords.setAlarmStartTime(new Date()); diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java index d7eeb52..e09669d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAlarmRecordsMapper.java @@ -92,8 +92,9 @@ public interface EmsAlarmRecordsMapper public int getDeviceAlarmNum(@Param("siteId") String siteId, @Param("deviceId") String deviceId); //获取未处理的订阅失败告警 - public EmsAlarmRecords getFailedRecord(@Param("siteId")String siteId, @Param("deviceId")String deviceId, - @Param("content") String content,@Param("status")String status); + public EmsAlarmRecords getFailedRecord(@Param("siteId")String siteId, + @Param("content") String content, + @Param("level")String level); // 批量处理告警数据 public void batchUpsert(@Param("recordsList")List recordsList); diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java index 1bd6a0e..b25295a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyRunningMapper.java @@ -75,4 +75,9 @@ public interface EmsStrategyRunningMapper // 获取运行中的策略 public List getPendingPollerStrategy(String siteId); + + // 获取正在运行的策略 + public EmsStrategyRunning getRunningStrategy(String siteId); + // 获取已存在并且状态为:未启用和已暂停的最晚一条策略, + public EmsStrategyRunning getPendingStrategy(String siteId); } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index fa7a31d..f1913fc 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -153,7 +153,7 @@ t.ticket_no as ticketNo, t.id from ems_alarm_records t - INNER JOIN ems_devices_setting t2 on t.site_id = t2.site_id and t.device_id = t2.device_id + LEFT JOIN ems_devices_setting t2 on t.site_id = t2.site_id and t.device_id = t2.device_id where t.site_id = #{siteId} AND t.device_type = #{deviceType} @@ -186,9 +186,9 @@ diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml index 6560e2e..8d78504 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyRunningMapper.xml @@ -115,10 +115,6 @@ and `status` = 1 - - update ems_strategy_running set `status`= #{status} where site_id = #{siteId} - - + + + + \ No newline at end of file -- 2.49.0 From c2682f38a8166af13634fd7472efa8ad25dd7082 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 5 Nov 2025 14:58:05 +0800 Subject: [PATCH 198/336] =?UTF-8?q?=E7=82=B9=E4=BD=8D=E6=B8=85=E5=8D=95-?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsPointMatchController.java | 65 ++++++++++++ .../com/xzzn/ems/domain/EmsPointMatch.java | 34 ++++++- .../xzzn/ems/domain/vo/PointDataRequest.java | 20 ++++ .../ems/domain/vo/PointQueryResponse.java | 30 +++++- .../xzzn/ems/mapper/EmsPointMatchMapper.java | 19 ++-- .../ems/service/IEmsPointMatchService.java | 32 ++++++ .../impl/EmsDeviceSettingServiceImpl.java | 16 +-- .../impl/EmsPointMatchServiceImpl.java | 99 +++++++++++++++++++ .../mapper/ems/EmsPointMatchMapper.xml | 38 ++++++- 9 files changed, 329 insertions(+), 24 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java new file mode 100644 index 0000000..ad98c35 --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java @@ -0,0 +1,65 @@ +package com.xzzn.web.controller.ems; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.xzzn.common.annotation.Log; +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.BusinessType; +import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.service.IEmsPointMatchService; +import com.xzzn.common.utils.poi.ExcelUtil; +import org.springframework.web.multipart.MultipartFile; + +/** + * 点位匹配Controller + * + * @author xzzn + * @date 2025-11-04 + */ +@RestController +@RequestMapping("/ems/pointMatch") +public class EmsPointMatchController extends BaseController +{ + @Autowired + private IEmsPointMatchService emsPointMatchService; + + /** + * 导出点位匹配列表 + */ + @PreAuthorize("@ss.hasPermi('system:match:export')") + @Log(title = "点位匹配", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsPointMatch emsPointMatch) + { + List list = emsPointMatchService.selectEmsPointMatchList(emsPointMatch); + ExcelUtil util = new ExcelUtil(EmsPointMatch.class); + util.exportExcel(response, list, "点位匹配数据"); + } + + /** + * 上传点位清单 + * @param file + * @param updateSupport + * @return + * @throws Exception + */ + @PreAuthorize("@ss.hasPermi('system:user:import')") + @Log(title = "点位匹配", businessType = BusinessType.IMPORT) + @PostMapping("/importData") + public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception + { + ExcelUtil util = new ExcelUtil(EmsPointMatch.class); + List pointMatcheList = util.importExcel(file.getInputStream()); + String operName = getUsername(); + String message = emsPointMatchService.importPoint(pointMatcheList, updateSupport, operName); + return success(message); + } + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java index c15a3d0..9bc8f12 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -9,7 +9,7 @@ import com.xzzn.common.annotation.Excel; * 点位匹配对象 ems_point_match * * @author xzzn - * @date 2025-10-14 + * @date 2025-11-04 */ public class EmsPointMatch extends BaseEntity { @@ -54,8 +54,16 @@ public class EmsPointMatch extends BaseEntity @Excel(name = "数据单位") private String dataUnit; - /** 数据类型:1-瞬时值 2-增量 */ - @Excel(name = "数据类型:1-瞬时值 2-增量") + /** 地址 */ + @Excel(name = "地址") + private String ipAddress; + + /** 端口 */ + @Excel(name = "端口") + private Integer ipPort; + + /** 数据类型:1-瞬时值 2-累计值 */ + @Excel(name = "数据类型:1-瞬时值 2-累计值") private Long dataType; /** 点位是否需要区分多设备:0-不需要 1-需要 */ @@ -162,6 +170,24 @@ public class EmsPointMatch extends BaseEntity return dataUnit; } + public void setIpAddress(String ipAddress) + { + this.ipAddress = ipAddress; + } + + public String getIpAddress() + { + return ipAddress; + } + + public Integer getIpPort() { + return ipPort; + } + + public void setIpPort(Integer ipPort) { + this.ipPort = ipPort; + } + public void setDataType(Long dataType) { this.dataType = dataType; @@ -195,6 +221,8 @@ public class EmsPointMatch extends BaseEntity .append("dataPointName", getDataPointName()) .append("dataDevice", getDataDevice()) .append("dataUnit", getDataUnit()) + .append("ipAddress", getIpAddress()) + .append("ipPort", getIpPort()) .append("dataType", getDataType()) .append("needDiffDeviceId", getNeedDiffDeviceId()) .append("createBy", getCreateBy()) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java index cddf9f5..994b54a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java @@ -31,6 +31,26 @@ public class PointDataRequest { private String sortData; /** 父类deviceId */ private String parentId; + /** modbus地址 */ + private String ipAddress; + /** modbus端口 */ + private Integer ipPort; + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public Integer getIpPort() { + return ipPort; + } + + public void setIpPort(Integer ipPort) { + this.ipPort = ipPort; + } public String getParentId() { return parentId; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java index a9c24b1..18e72e2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java @@ -42,9 +42,13 @@ public class PointQueryResponse @Excel(name = "数据单位") private String dataUnit; - public String getDataUnit() { - return dataUnit; - } + /** 地址 */ + @Excel(name = "地址") + private String ipAddress; + + /** 端口 */ + @Excel(name = "端口") + private String ipPort; public void setDataUnit(String dataUnit) { this.dataUnit = dataUnit; @@ -105,4 +109,24 @@ public class PointQueryResponse public void setPointName(String pointName) { this.pointName = pointName; } + + public String getDataUnit() { + return dataUnit; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getIpPort() { + return ipPort; + } + + public void setIpPort(String ipPort) { + this.ipPort = ipPort; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index b3d4f72..27f9497 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -125,12 +125,19 @@ public interface EmsPointMatchMapper public List getSingleSiteDevicePoints(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("pointName")String pointName, - @Param("dataPoint")String dataPoint); + @Param("dataPoint")String dataPoint, + @Param("ipAddress")String ipAddress, + @Param("ipPort")Integer ipPort); // 单个站点单个设备点位查询-电池簇使用 public List getClusterDevicePoints(@Param("siteId")String siteId, - @Param("deviceId")String deviceId, - @Param("parentDeviceId")String parentDeviceId, - @Param("deviceCategory")String deviceCategory, - @Param("pointName")String pointName, - @Param("dataPoint")String dataPoint); + @Param("deviceId")String deviceId, + @Param("parentDeviceId")String parentDeviceId, + @Param("deviceCategory")String deviceCategory, + @Param("pointName")String pointName, + @Param("dataPoint")String dataPoint, + @Param("ipAddress")String ipAddress, + @Param("ipPort")Integer ipPort); + + // 根据站点,设备类别,点位,获取唯一数据 + public EmsPointMatch getUniquePoint(String siteId, String deviceCategory, String dataPoint); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java new file mode 100644 index 0000000..2242e4e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java @@ -0,0 +1,32 @@ +package com.xzzn.ems.service; + +import java.util.List; + +import com.xzzn.ems.domain.EmsPointMatch; + +/** + * 点位匹配Service接口 + * + * @author xzzn + * @date 2025-11-04 + */ +public interface IEmsPointMatchService +{ + /** + * 查询点位匹配列表 + * + * @param emsPointMatch 点位匹配 + * @return 点位匹配集合 + */ + public List selectEmsPointMatchList(EmsPointMatch emsPointMatch); + + + /** + * 上传点位清单 + * @param userList + * @param updateSupport + * @param operName + * @return + */ + public String importPoint(List userList, boolean updateSupport, String operName); +} 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 5d3d2a9..f5e1d53 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 @@ -140,15 +140,17 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService String dataPointName = request.getDataPointName(); String dataPoint = request.getDataPoint(); String parentDeviceId = request.getParentId(); + String ipAddress = request.getIpAddress(); + Integer ipPort = request.getIpPort(); // 电动所的电池簇特殊处理-来源pcs+bmsd if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { - response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory,dataPointName,dataPoint); + response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort); } else if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { response = specialDealWithBattery(siteId,deviceId,deviceCategory, - dataPointName,dataPoint,parentDeviceId); + dataPointName,dataPoint,parentDeviceId,ipAddress,ipPort); } else { response = emsPointMatchMapper.getSingleSiteDevicePoints( - siteId,deviceCategory,dataPointName,dataPoint); + siteId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort); // 从redis取最新数据 JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); if(mqttJson == null){ @@ -233,9 +235,9 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService } private List specialDealWithBattery(String siteId, String deviceId, String deviceCategory, - String dataPointName, String dataPoint, String parentDeviceId) { + String dataPointName, String dataPoint, String parentDeviceId, String ipAddress, Integer ipPort) { List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory, - dataPointName,dataPoint); + dataPointName,dataPoint,ipAddress,ipPort); // 获取redis同步最新数据 JSONObject jsonObject = new JSONObject(); @@ -314,12 +316,12 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService // 对于dds的电池簇点位最新数据获取特殊处理 private List specialDealWithDDSCluster(String siteId, String deviceId, String deviceCategory, - String dataPointName, String dataPoint) { + String dataPointName, String dataPoint, String ipAddress, Integer ipPort) { // 替换为对应的父类id String bmsdDeviceId = deviceId.replace("BMSC","BMSD"); List response = emsPointMatchMapper - .getClusterDevicePoints(siteId,deviceId,bmsdDeviceId,deviceCategory,dataPointName,dataPoint); + .getClusterDevicePoints(siteId,deviceId,bmsdDeviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort); JSONObject mergedData = new JSONObject(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java new file mode 100644 index 0000000..5cfc126 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -0,0 +1,99 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; + +import com.xzzn.common.exception.ServiceException; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.common.utils.bean.BeanValidators; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsPointMatchMapper; +import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.service.IEmsPointMatchService; + +import javax.validation.Validator; + +/** + * 点位匹配Service业务层处理 + * + * @author xzzn + * @date 2025-11-04 + */ +@Service +public class EmsPointMatchServiceImpl implements IEmsPointMatchService +{ + @Autowired + private EmsPointMatchMapper emsPointMatchMapper; + @Autowired + protected Validator validator; + + /** + * 查询点位匹配列表 + * + * @param emsPointMatch 点位匹配 + * @return 点位匹配 + */ + @Override + public List selectEmsPointMatchList(EmsPointMatch emsPointMatch) + { + return emsPointMatchMapper.selectEmsPointMatchList(emsPointMatch); + } + + /** + * 上传点位清单 + * @param pointMatchList + * @param isUpdateSupport + * @param operName + * @return + */ + @Override + public String importPoint(List pointMatchList, boolean isUpdateSupport, String operName) { + if (StringUtils.isNull(pointMatchList) || pointMatchList.size() == 0) + { + throw new ServiceException("导入用户数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (EmsPointMatch pointMatch : pointMatchList) + { + try + { + // 验证点位是否存在 + EmsPointMatch point = emsPointMatchMapper.getUniquePoint(pointMatch.getSiteId(), + pointMatch.getDeviceCategory(),pointMatch.getDataPoint()); + if (StringUtils.isNull(point)) { + BeanValidators.validateWithException(validator, pointMatch); + pointMatch.setCreateBy(operName); + emsPointMatchMapper.insertEmsPointMatch(pointMatch); + successNum++; + successMsg.append("
" + successNum + "、站点 " + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint()+ " 导入成功"); + } else if (isUpdateSupport) { + BeanValidators.validateWithException(validator, pointMatch); + pointMatch.setUpdateBy(operName); + emsPointMatchMapper.updateEmsPointMatch(pointMatch); + successNum++; + successMsg.append("
" + successNum + "、站点 " + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint()+ " 更新成功"); + } else { + failureNum++; + failureMsg.append("
" + failureNum + "、站点" + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint() + " 已存在"); + } + } + catch (Exception e) { + failureNum++; + String msg = "
" + failureNum + "、站点" + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint() + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + } + } + if (failureNum > 0) { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } else { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } + + +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 4a0f96e..4e1f76f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -15,6 +15,8 @@ + + @@ -25,7 +27,7 @@ - select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark from ems_point_match + select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark from ems_point_match \ No newline at end of file -- 2.49.0 From 72c7c0c3e0d1b9049a722624125ebdc0804318a2 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 6 Nov 2025 15:32:33 +0800 Subject: [PATCH 199/336] =?UTF-8?q?=E7=82=B9=E4=BD=8D=E6=B8=85=E5=8D=95-?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/mapper/EmsPointMatchMapper.java | 2 +- .../xzzn/ems/service/impl/EmsPointMatchServiceImpl.java | 9 +++------ .../main/resources/mapper/ems/EmsPointMatchMapper.xml | 7 +++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 27f9497..19a1f29 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -139,5 +139,5 @@ public interface EmsPointMatchMapper @Param("ipPort")Integer ipPort); // 根据站点,设备类别,点位,获取唯一数据 - public EmsPointMatch getUniquePoint(String siteId, String deviceCategory, String dataPoint); + public EmsPointMatch getUniquePoint(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("dataPoint")String dataPoint); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index 5cfc126..25942cb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -56,10 +56,8 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService int failureNum = 0; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); - for (EmsPointMatch pointMatch : pointMatchList) - { - try - { + for (EmsPointMatch pointMatch : pointMatchList) { + try { // 验证点位是否存在 EmsPointMatch point = emsPointMatchMapper.getUniquePoint(pointMatch.getSiteId(), pointMatch.getDeviceCategory(),pointMatch.getDataPoint()); @@ -79,8 +77,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService failureNum++; failureMsg.append("
" + failureNum + "、站点" + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint() + " 已存在"); } - } - catch (Exception e) { + } catch (Exception e) { failureNum++; String msg = "
" + failureNum + "、站点" + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint() + " 导入失败:"; failureMsg.append(msg + e.getMessage()); diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 4e1f76f..c0560cf 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -419,4 +419,11 @@ and tmp.ipPort = #{ipPort}
+ + \ No newline at end of file -- 2.49.0 From 43edc47aaa9b6e69f0e689701281a89fbccf8ad9 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 6 Nov 2025 19:39:53 +0800 Subject: [PATCH 200/336] =?UTF-8?q?=E9=AA=8C=E6=94=B65-mqtt=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsFaultProtectionPlanController.java | 2 + .../ems/EmsMqttTopicConfigController.java | 106 ++++++++++++++++++ .../xzzn/ems/domain/EmsMqttTopicConfig.java | 62 +++++++--- .../ems/mapper/EmsMqttTopicConfigMapper.java | 61 ++++++++++ .../service/IEmsMqttTopicConfigService.java | 61 ++++++++++ .../impl/EmsMqttTopicConfigServiceImpl.java | 96 ++++++++++++++++ .../mapper/ems/EmsMqttTopicConfigMapper.xml | 87 ++++++++++++++ 7 files changed, 459 insertions(+), 16 deletions(-) create mode 100644 ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsMqttTopicConfigController.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttTopicConfigService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttTopicConfigServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java index 6b9a747..58e0570 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsFaultProtectionPlanController.java @@ -78,6 +78,7 @@ public class EmsFaultProtectionPlanController extends BaseController @PostMapping public AjaxResult add(@RequestBody EmsFaultProtectionPlan emsFaultProtectionPlan) { + emsFaultProtectionPlan.setCreateBy(getUsername()); return toAjax(emsFaultProtectionPlanService.insertEmsFaultProtectionPlan(emsFaultProtectionPlan)); } @@ -89,6 +90,7 @@ public class EmsFaultProtectionPlanController extends BaseController @PutMapping public AjaxResult edit(@RequestBody EmsFaultProtectionPlan emsFaultProtectionPlan) { + emsFaultProtectionPlan.setUpdateBy(getUsername()); return toAjax(emsFaultProtectionPlanService.updateEmsFaultProtectionPlan(emsFaultProtectionPlan)); } diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsMqttTopicConfigController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsMqttTopicConfigController.java new file mode 100644 index 0000000..5dc661d --- /dev/null +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsMqttTopicConfigController.java @@ -0,0 +1,106 @@ +package com.xzzn.web.controller.ems; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.xzzn.common.annotation.Log; +import com.xzzn.common.core.controller.BaseController; +import com.xzzn.common.core.domain.AjaxResult; +import com.xzzn.common.enums.BusinessType; +import com.xzzn.ems.domain.EmsMqttTopicConfig; +import com.xzzn.ems.service.IEmsMqttTopicConfigService; +import com.xzzn.common.utils.poi.ExcelUtil; +import com.xzzn.common.core.page.TableDataInfo; + +/** + * 站点topic配置Controller + * + * @author xzzn + * @date 2025-11-06 + */ +@RestController +@RequestMapping("/ems/mqttConfig") +public class EmsMqttTopicConfigController extends BaseController +{ + @Autowired + private IEmsMqttTopicConfigService emsMqttTopicConfigService; + + /** + * 查询站点topic配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:config:list')") + @GetMapping("/list") + public TableDataInfo list(EmsMqttTopicConfig emsMqttTopicConfig) + { + startPage(); + List list = emsMqttTopicConfigService.selectEmsMqttTopicConfigList(emsMqttTopicConfig); + return getDataTable(list); + } + + /** + * 导出站点topic配置列表 + */ + @PreAuthorize("@ss.hasPermi('system:config:export')") + @Log(title = "站点topic配置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EmsMqttTopicConfig emsMqttTopicConfig) + { + List list = emsMqttTopicConfigService.selectEmsMqttTopicConfigList(emsMqttTopicConfig); + ExcelUtil util = new ExcelUtil(EmsMqttTopicConfig.class); + util.exportExcel(response, list, "站点topic配置数据"); + } + + /** + * 获取站点topic配置详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:config:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(emsMqttTopicConfigService.selectEmsMqttTopicConfigById(id)); + } + + /** + * 新增站点topic配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:add')") + @Log(title = "站点topic配置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EmsMqttTopicConfig emsMqttTopicConfig) + { + emsMqttTopicConfig.setCreateBy(getUsername()); + return toAjax(emsMqttTopicConfigService.insertEmsMqttTopicConfig(emsMqttTopicConfig)); + } + + /** + * 修改站点topic配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:edit')") + @Log(title = "站点topic配置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EmsMqttTopicConfig emsMqttTopicConfig) + { + emsMqttTopicConfig.setUpdateBy(getUsername()); + return toAjax(emsMqttTopicConfigService.updateEmsMqttTopicConfig(emsMqttTopicConfig)); + } + + /** + * 删除站点topic配置 + */ + @PreAuthorize("@ss.hasPermi('system:config:remove')") + @Log(title = "站点topic配置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(emsMqttTopicConfigService.deleteEmsMqttTopicConfigByIds(ids)); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java index ec16a32..0698b1b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java @@ -9,7 +9,7 @@ import com.xzzn.common.annotation.Excel; * 站点topic配置对象 ems_mqtt_topic_config * * @author xzzn - * @date 2025-10-21 + * @date 2025-11-06 */ public class EmsMqttTopicConfig extends BaseEntity { @@ -18,14 +18,22 @@ public class EmsMqttTopicConfig extends BaseEntity /** 主键 */ private Long id; - /** 站点id */ - @Excel(name = "站点id") - private String siteId; - /** 订阅topic */ @Excel(name = "订阅topic") private String mqttTopic; + /** topic描述 */ + @Excel(name = "topic描述") + private String topicName; + + /** 对应方法 */ + @Excel(name = "对应方法") + private String method; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + public void setId(Long id) { this.id = id; @@ -36,16 +44,6 @@ public class EmsMqttTopicConfig extends BaseEntity return id; } - public void setSiteId(String siteId) - { - this.siteId = siteId; - } - - public String getSiteId() - { - return siteId; - } - public void setMqttTopic(String mqttTopic) { this.mqttTopic = mqttTopic; @@ -56,12 +54,44 @@ public class EmsMqttTopicConfig extends BaseEntity return mqttTopic; } + public void setTopicName(String topicName) + { + this.topicName = topicName; + } + + public String getTopicName() + { + return topicName; + } + + public void setMethod(String method) + { + this.method = method; + } + + public String getMethod() + { + return method; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) - .append("siteId", getSiteId()) .append("mqttTopic", getMqttTopic()) + .append("topicName", getTopicName()) + .append("method", getMethod()) + .append("siteId", getSiteId()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java new file mode 100644 index 0000000..0e8c019 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsMqttTopicConfig; + +/** + * 站点topic配置Mapper接口 + * + * @author xzzn + * @date 2025-11-06 + */ +public interface EmsMqttTopicConfigMapper +{ + /** + * 查询站点topic配置 + * + * @param id 站点topic配置主键 + * @return 站点topic配置 + */ + public EmsMqttTopicConfig selectEmsMqttTopicConfigById(Long id); + + /** + * 查询站点topic配置列表 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 站点topic配置集合 + */ + public List selectEmsMqttTopicConfigList(EmsMqttTopicConfig emsMqttTopicConfig); + + /** + * 新增站点topic配置 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 结果 + */ + public int insertEmsMqttTopicConfig(EmsMqttTopicConfig emsMqttTopicConfig); + + /** + * 修改站点topic配置 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 结果 + */ + public int updateEmsMqttTopicConfig(EmsMqttTopicConfig emsMqttTopicConfig); + + /** + * 删除站点topic配置 + * + * @param id 站点topic配置主键 + * @return 结果 + */ + public int deleteEmsMqttTopicConfigById(Long id); + + /** + * 批量删除站点topic配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsMqttTopicConfigByIds(Long[] ids); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttTopicConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttTopicConfigService.java new file mode 100644 index 0000000..efc756a --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsMqttTopicConfigService.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsMqttTopicConfig; + +/** + * 站点topic配置Service接口 + * + * @author xzzn + * @date 2025-11-06 + */ +public interface IEmsMqttTopicConfigService +{ + /** + * 查询站点topic配置 + * + * @param id 站点topic配置主键 + * @return 站点topic配置 + */ + public EmsMqttTopicConfig selectEmsMqttTopicConfigById(Long id); + + /** + * 查询站点topic配置列表 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 站点topic配置集合 + */ + public List selectEmsMqttTopicConfigList(EmsMqttTopicConfig emsMqttTopicConfig); + + /** + * 新增站点topic配置 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 结果 + */ + public int insertEmsMqttTopicConfig(EmsMqttTopicConfig emsMqttTopicConfig); + + /** + * 修改站点topic配置 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 结果 + */ + public int updateEmsMqttTopicConfig(EmsMqttTopicConfig emsMqttTopicConfig); + + /** + * 批量删除站点topic配置 + * + * @param ids 需要删除的站点topic配置主键集合 + * @return 结果 + */ + public int deleteEmsMqttTopicConfigByIds(Long[] ids); + + /** + * 删除站点topic配置信息 + * + * @param id 站点topic配置主键 + * @return 结果 + */ + public int deleteEmsMqttTopicConfigById(Long id); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttTopicConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttTopicConfigServiceImpl.java new file mode 100644 index 0000000..c2bf042 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsMqttTopicConfigServiceImpl.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; +import com.xzzn.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.domain.EmsMqttTopicConfig; +import com.xzzn.ems.service.IEmsMqttTopicConfigService; + +/** + * 站点topic配置Service业务层处理 + * + * @author xzzn + * @date 2025-11-06 + */ +@Service +public class EmsMqttTopicConfigServiceImpl implements IEmsMqttTopicConfigService +{ + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + + /** + * 查询站点topic配置 + * + * @param id 站点topic配置主键 + * @return 站点topic配置 + */ + @Override + public EmsMqttTopicConfig selectEmsMqttTopicConfigById(Long id) + { + return emsMqttTopicConfigMapper.selectEmsMqttTopicConfigById(id); + } + + /** + * 查询站点topic配置列表 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 站点topic配置 + */ + @Override + public List selectEmsMqttTopicConfigList(EmsMqttTopicConfig emsMqttTopicConfig) + { + return emsMqttTopicConfigMapper.selectEmsMqttTopicConfigList(emsMqttTopicConfig); + } + + /** + * 新增站点topic配置 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 结果 + */ + @Override + public int insertEmsMqttTopicConfig(EmsMqttTopicConfig emsMqttTopicConfig) + { + emsMqttTopicConfig.setCreateTime(DateUtils.getNowDate()); + return emsMqttTopicConfigMapper.insertEmsMqttTopicConfig(emsMqttTopicConfig); + } + + /** + * 修改站点topic配置 + * + * @param emsMqttTopicConfig 站点topic配置 + * @return 结果 + */ + @Override + public int updateEmsMqttTopicConfig(EmsMqttTopicConfig emsMqttTopicConfig) + { + emsMqttTopicConfig.setUpdateTime(DateUtils.getNowDate()); + return emsMqttTopicConfigMapper.updateEmsMqttTopicConfig(emsMqttTopicConfig); + } + + /** + * 批量删除站点topic配置 + * + * @param ids 需要删除的站点topic配置主键 + * @return 结果 + */ + @Override + public int deleteEmsMqttTopicConfigByIds(Long[] ids) + { + return emsMqttTopicConfigMapper.deleteEmsMqttTopicConfigByIds(ids); + } + + /** + * 删除站点topic配置信息 + * + * @param id 站点topic配置主键 + * @return 结果 + */ + @Override + public int deleteEmsMqttTopicConfigById(Long id) + { + return emsMqttTopicConfigMapper.deleteEmsMqttTopicConfigById(id); + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml new file mode 100644 index 0000000..4e9d96f --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + select id, mqtt_topic, topic_name, method, siteId, create_by, create_time, update_by, update_time from ems_mqtt_topic_config + + + + + + + + insert into ems_mqtt_topic_config + + mqtt_topic, + topic_name, + method, + siteId, + create_by, + create_time, + update_by, + update_time, + + + #{mqttTopic}, + #{topicName}, + #{method}, + #{siteId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update ems_mqtt_topic_config + + mqtt_topic = #{mqttTopic}, + topic_name = #{topicName}, + method = #{method}, + siteId = #{siteId}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from ems_mqtt_topic_config where id = #{id} + + + + delete from ems_mqtt_topic_config where id in + + #{id} + + + \ No newline at end of file -- 2.49.0 From 5381cd597c89d94a686085eefee39120b95323c0 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 11 Nov 2025 10:37:04 +0800 Subject: [PATCH 201/336] =?UTF-8?q?mqtt=E9=85=8D=E7=BD=AE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 89 +++++++++++++++---- .../xzzn/ems/domain/EmsMqttTopicConfig.java | 43 +++++++-- .../ems/mapper/EmsMqttTopicConfigMapper.java | 3 + .../mapper/ems/EmsMqttTopicConfigMapper.xml | 30 +++++-- 4 files changed, 135 insertions(+), 30 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index a68f394..ec1d846 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -1,23 +1,25 @@ package com.xzzn.web.controller.ems; -import com.xzzn.ems.service.IDDSDataProcessService; -import com.xzzn.ems.service.IEmsMqttMessageService; -import com.xzzn.ems.service.IFXXAlarmDataProcessService; -import com.xzzn.ems.service.IFXXDataProcessService; +import com.alibaba.fastjson2.JSON; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsMqttTopicConfig; +import com.xzzn.ems.domain.MqttSyncStrategyLog; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.service.*; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.framework.web.service.MqttSubscriber; +import org.apache.commons.collections4.CollectionUtils; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; -import java.util.Date; +import java.util.List; @Service public class MqttMessageController implements MqttPublisher, MqttSubscriber { @@ -39,6 +41,11 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IFXXAlarmDataProcessService fXXAlarmDataProcessService; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + @Autowired + private IEmsStrategyService emsStrategyService; + @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { this.mqttLifecycleManager = mqttLifecycleManager; @@ -46,8 +53,31 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @PostConstruct public void init() { + List topicConfigList = emsMqttTopicConfigMapper.selectEmsMqttTopicConfigList(null); + + if (CollectionUtils.isEmpty (topicConfigList)) { + log.info ("未查询到任何 MQTT 主题配置,跳过订阅"); + return; + } + + for (EmsMqttTopicConfig topicConfig : topicConfigList) { + String topic = topicConfig.getMqttTopic(); + if (StringUtils.isEmpty(topic)) { + log.info ("主题配置 ID:" +topicConfig.getId() +"的 mqttTopic 为空,跳过订阅"); + continue; + } + + int qos = topicConfig.getQos() == null ? 1 : topicConfig.getQos(); + if (qos < 0 || qos > 2) { + log.info ("主题:" + topic +"的 QoS值"+ qos + "不合法,自动调整为1"); + qos = 1; + } + + IMqttMessageListener listener = getMqttListenerByTopic(topic, topicConfig.getId()); + subscribe(topic, qos, listener); + } // 订阅奉贤系统状态主题 - subscribe("021_FXX_01_UP", 1, this::handleDeviceData); + /*subscribe("021_FXX_01_UP", 1, this::handleDeviceData); subscribe("021_FXX_01_RECALL", 1, this::handleDeviceData); subscribe("021_FXX_01_DOWN", 1, this::handleDeviceData); subscribe("021_FXX_01", 1, this::handleSystemStatus); @@ -57,10 +87,22 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { subscribe("021_DDS_01_UP", 1, this::handleDeviceData); subscribe("021_DDS_01_RECALL", 1, this::handleDeviceData); subscribe("021_DDS_01_DOWN", 1, this::handleDeviceData); - subscribe("021_DDS_01", 1, this::handleSystemStatus); + subscribe("021_DDS_01", 1, this::handleSystemStatus);*/ } + private IMqttMessageListener getMqttListenerByTopic(String topic, Long id) { + if (topic.contains("ALARM_UP")) { + return this::handleAlarmData; + } else if (topic.endsWith("_01")) { + return this::handleSystemStatus; + } else if (topic.contains("STRATEGY")) { + return this::handleStrategyData; + } else { + return this::handleDeviceData; + } + } + // 处理系统状态消息 private void handleSystemStatus(String topic, MqttMessage message) { String payload = new String(message.getPayload()); @@ -109,6 +151,29 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } } + + // 处理运行策略数据 + private void handleStrategyData(String topic, MqttMessage message) { + String payload = new String(message.getPayload()); + System.out.println("[处理运行策略数据] data: " + payload); + try { + // 业务处理逻辑 + MqttSyncStrategyLog strategyLog = JSON.parseObject(payload, MqttSyncStrategyLog.class); + if (strategyLog != null) { + String content = strategyLog.getContent(); + // 根据不同操作更新 + String operateType = strategyLog.getOperateType(); + if (!StringUtils.isEmpty(operateType)) { + emsStrategyService.dealStrategyData(content,operateType); + } + } + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + } catch (Exception e) { + log.error("Failed to process system status message: " + e.getMessage(), e); + } + + } + @Override public void publish(String topic, String message) throws MqttException { mqttLifecycleManager.publish(topic, message, 0); @@ -136,12 +201,4 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } } - - /*private static final long FORCE_INTERVAL = 60 * 1000; // 1分钟(毫秒) - @Scheduled(fixedRate = FORCE_INTERVAL) // 每分钟执行一次 - public void scheduledForceSave() { - System.out.println("执行定时强制存储任务:" + new Date()); - - }*/ - } \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java index 0698b1b..33b36a2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java @@ -14,7 +14,6 @@ import com.xzzn.common.annotation.Excel; public class EmsMqttTopicConfig extends BaseEntity { private static final long serialVersionUID = 1L; - /** 主键 */ private Long id; @@ -22,13 +21,21 @@ public class EmsMqttTopicConfig extends BaseEntity @Excel(name = "订阅topic") private String mqttTopic; + /** QoS等级(0/1/2) */ + @Excel(name = "QoS等级", readConverterExp = "0=/1/2") + private Integer qos; + /** topic描述 */ @Excel(name = "topic描述") private String topicName; /** 对应方法 */ @Excel(name = "对应方法") - private String method; + private String handleMethod; + + /** 处理器类型:(device=设备数据,system=系统状态,alarm=告警数据等) */ + @Excel(name = "处理器类型:(device=设备数据,system=系统状态,alarm=告警数据等)") + private String handleType; /** 站点id */ @Excel(name = "站点id") @@ -54,6 +61,16 @@ public class EmsMqttTopicConfig extends BaseEntity return mqttTopic; } + public void setQos(Integer qos) + { + this.qos = qos; + } + + public Integer getQos() + { + return qos; + } + public void setTopicName(String topicName) { this.topicName = topicName; @@ -64,14 +81,24 @@ public class EmsMqttTopicConfig extends BaseEntity return topicName; } - public void setMethod(String method) + public void setHandleMethod(String handleMethod) { - this.method = method; + this.handleMethod = handleMethod; } - public String getMethod() + public String getHandleMethod() { - return method; + return handleMethod; + } + + public void setHandleType(String handleType) + { + this.handleType = handleType; + } + + public String getHandleType() + { + return handleType; } public void setSiteId(String siteId) @@ -89,8 +116,10 @@ public class EmsMqttTopicConfig extends BaseEntity return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) .append("mqttTopic", getMqttTopic()) + .append("qos", getQos()) .append("topicName", getTopicName()) - .append("method", getMethod()) + .append("handleMethod", getHandleMethod()) + .append("handleType", getHandleType()) .append("siteId", getSiteId()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java index 0e8c019..10a9fa0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java @@ -58,4 +58,7 @@ public interface EmsMqttTopicConfigMapper * @return 结果 */ public int deleteEmsMqttTopicConfigByIds(Long[] ids); + + // 判断topic是否存在 + public String checkTopicIsExist(String strategyTopic); } diff --git a/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml index 4e9d96f..dd0ab8d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml @@ -7,8 +7,10 @@ + - + + @@ -17,15 +19,17 @@ - select id, mqtt_topic, topic_name, method, siteId, create_by, create_time, update_by, update_time from ems_mqtt_topic_config + select id, mqtt_topic, qos, topic_name, handle_method, handle_type, siteId, create_by, create_time, update_by, update_time from ems_mqtt_topic_config @@ -39,8 +43,10 @@ insert into ems_mqtt_topic_config mqtt_topic, + qos, topic_name, - method, + handle_method, + handle_type, siteId, create_by, create_time, @@ -49,8 +55,10 @@ #{mqttTopic}, + #{qos}, #{topicName}, - #{method}, + #{handleMethod}, + #{handleType}, #{siteId}, #{createBy}, #{createTime}, @@ -63,8 +71,10 @@ update ems_mqtt_topic_config mqtt_topic = #{mqttTopic}, + qos = #{qos}, topic_name = #{topicName}, - method = #{method}, + handle_method = #{handleMethod}, + handle_type = #{handleType}, siteId = #{siteId}, create_by = #{createBy}, create_time = #{createTime}, @@ -84,4 +94,10 @@ #{id} + + \ No newline at end of file -- 2.49.0 From 49a83fd420798e7e0718ff36a19ec5be713b1f9e Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 11 Nov 2025 10:37:46 +0800 Subject: [PATCH 202/336] =?UTF-8?q?=E9=AA=8C=E6=94=B62-=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/aspectj/StrategySyncAspect.java | 243 ++++++++++++++++++ .../xzzn/ems/service/IEmsStrategyService.java | 3 + .../service/impl/EmsStrategyServiceImpl.java | 15 ++ 3 files changed, 261 insertions(+) create mode 100644 ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java new file mode 100644 index 0000000..b7eb2c7 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java @@ -0,0 +1,243 @@ +package com.xzzn.framework.aspectj; + +import com.alibaba.fastjson2.JSON; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsStrategyRunning; +import com.xzzn.ems.domain.MqttSyncStrategyLog; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.mapper.MqttSyncStrategyLogMapper; +import com.xzzn.framework.web.service.MqttPublisher; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cglib.beans.BeanMap; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +@Aspect +@Component +public class StrategySyncAspect { + @Autowired + private MqttPublisher mqttPublisher; + @Autowired + private MqttSyncStrategyLogMapper mqttSyncStrategyLogMapper; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final String STRATEGY_TOPIC = "EMS_STRATEGY_UP"; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + + // 定义切点:拦截策略相关表的Mapper方法 + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyRunningMapper.stopEmsStrategyRunning(..)) && args(id)) ") + public void stopPointCut(Long id) { + System.out.println("【停止策略切面】StrategyAspect 被实例化"); + } + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyRunningMapper.insertEmsStrategyRunning(..)) && args(insertEntity)) ") + public void insertPointCut(EmsStrategyRunning insertEntity) { + System.out.println("【新增策略切面】StrategyAspect 被实例化"); + } + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyRunningMapper.updateEmsStrategyRunning(..)) && args(updateEntity)) ") + public void updatePointCut(EmsStrategyRunning updateEntity) { + System.out.println("【更新策略切面】StrategyAspect 被实例化"); + } + + // 方法执行成功后发布同步消息 + @AfterReturning(pointcut = "updatePointCut(insertEntity)", returning = "result") + public void afterUpdate(JoinPoint joinPoint, EmsStrategyRunning insertEntity, Integer result) { + System.out.println("【更新策略切面进入成功】"); + if (result == 0) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String tableName = getTableNameFromMethod(methodName); // 从Mapper类名提取表名 + + // 构建日志同步消息 + MqttSyncStrategyLog message = new MqttSyncStrategyLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(tableName); + message.setCreateTime(new Date()); + message.setTopic(STRATEGY_TOPIC); + message.setStatus("SUCCESS"); + + try { + // 数据转换 + String content = convertEntityToJson(insertEntity); + message.setContent(content); + + // 发布到MQTT主题 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); + if (!StringUtils.isEmpty(topic)) { + mqttPublisher.publish(topic, objectMapper.writeValueAsString(message), 1); + } + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncStrategyLogMapper.insertMqttSyncStrategyLog(message); + } + + @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") + public void afterInsert(JoinPoint joinPoint, EmsStrategyRunning insertEntity, Integer result) { + System.out.println("【新增策略切面进入成功】"); + if (result == 0) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String tableName = getTableNameFromMethod(methodName); // 从Mapper类名提取表名 + + // 构建日志同步消息 + MqttSyncStrategyLog message = new MqttSyncStrategyLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(tableName); + message.setCreateTime(new Date()); + message.setTopic(STRATEGY_TOPIC); + message.setStatus("SUCCESS"); + + try { + // 数据转换 + String content = convertEntityToJson(insertEntity); + message.setContent(content); + + // 发布到MQTT主题 + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncStrategyLogMapper.insertMqttSyncStrategyLog(message); + } + + @AfterReturning(pointcut = "stopPointCut(id)", returning = "result") + public void afterStop(JoinPoint joinPoint, Long id, Integer result) { + System.out.println("【停止策略切面进入成功】"); + if (result == 0) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String tableName = getTableNameFromMethod(methodName); // 从Mapper类名提取表名 + + + // 构建日志同步消息 + MqttSyncStrategyLog message = new MqttSyncStrategyLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(tableName); + message.setCreateTime(new Date()); + message.setTopic(STRATEGY_TOPIC); + message.setStatus("SUCCESS"); + + try { + // 数据转换 + Map idMap = new HashMap<>(); + idMap.put("id", id); // 手动将参数值映射到"id"字段 + String content = JSON.toJSONString(idMap); + message.setContent(content); + + // 发布到MQTT主题 + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncStrategyLogMapper.insertMqttSyncStrategyLog(message); + } + + // 从方法名判断操作类型(示例:insert→INSERT,update→UPDATE,delete→DELETE) + private String getOperateType(String methodName) { + if (methodName.startsWith("insert")) return "INSERT"; + if (methodName.startsWith("stop")) return "STOP"; + if (methodName.startsWith("update") || methodName.startsWith("stop")) return "UPDATE"; + if (methodName.startsWith("delete")) return "DELETE"; + return "UNKNOWN"; + } + + // 从Mapper类名提取表名(示例:StrategyMapper→strategy) + private String getTableNameFromMethod(String methodName) { + // 实际需通过JoinPoint获取Mapper类名,再转换为表名(如StrategyTemplateMapper→strategy_template) + return "strategy"; // 简化示例 + } + + // 从方法参数提取数据(示例:若参数是实体类,转成Map) + private Map extractDataFromParams(Object[] args) { + // 实际需反射获取实体类的字段和值(如id、name等) + Map data = new HashMap<>(); + if (args == null || args.length == 0) { + return data; + } + + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + if (arg == null) { + continue; // 跳过null参数 + } + + // 处理基本类型/包装类/字符串(直接作为值存入,key为"param0"、"param1"等) + if (isBasicType(arg.getClass())) { + String key = "param" + i; // 基本类型参数用"param0"、"param1"作为key + data.put(key, arg); + } else { + Map beanMap = beanToMap(arg); + data.putAll(beanMap); // 合并实体类的字段到结果Map + } + } + + return data; + } + + /** + * 判断是否为基本类型或包装类或字符串 + */ + private boolean isBasicType(Class clazz) { + return clazz.isPrimitive() // 基本类型(int、long、boolean等) + || clazz == String.class // 字符串 + || Number.class.isAssignableFrom(clazz) // 数字包装类(Integer、Long等) + || clazz == Boolean.class; // 布尔包装类 + } + + /** + * 将实体类转换为Map(字段名为key,字段值为value) + */ + private Map beanToMap(Object bean) { + Map map = new HashMap<>(); + if (bean == null) { + return map; + } + + // 方式1:使用BeanMap(简洁高效) + BeanMap beanMap = BeanMap.create(bean); + for (Object key : beanMap.keySet()) { + map.put(key.toString(), beanMap.get(key)); + } + + return map; + } + + // 在方法中转换 + public String convertEntityToJson(EmsStrategyRunning insertEntity) throws Exception { + if (insertEntity == null) { + return null; // 空对象返回空JSON + } + + // 将实体类转换为JSON字符串 + return objectMapper.writeValueAsString(insertEntity); + } + +} \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java index dfeefff..30fb174 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java @@ -27,4 +27,7 @@ public interface IEmsStrategyService public List getAuxStrategyList(); public int configStrategy(EmsStrategyRunning emsStrategyRunning); + + // 接收云上运行策略配置 + public void dealStrategyData(String content, String operateType); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java index 3f358a2..a7e3ad8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java @@ -1,7 +1,10 @@ package com.xzzn.ems.service.impl; import java.util.List; + +import com.alibaba.fastjson2.JSON; import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsStrategyRunning; import com.xzzn.ems.domain.vo.StrategyRunningVo; import com.xzzn.ems.mapper.EmsStrategyRunningMapper; @@ -62,4 +65,16 @@ public class EmsStrategyServiceImpl implements IEmsStrategyService emsStrategyRunning.setCreateTime(DateUtils.getNowDate()); return emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning); } + + @Override + public void dealStrategyData(String content, String operateType) { + if (StringUtils.isEmpty(content)) { + return; + } +// switch (operateType) { +// case "INSERT": +// EmsStrategyRunning emsStrategyRunning = JSON.parseObject(content, EmsStrategyRunning.class); +// emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning); +// } + } } -- 2.49.0 From 1b5fcea5cd34e8b5aade734cfb019ba455466907 Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 11 Nov 2025 15:42:19 +0800 Subject: [PATCH 203/336] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 122 +++++------ .../src/main/resources/application-prod.yml | 207 ++++++++++++++++++ ems-admin/src/main/resources/application.yml | 60 +++++ 3 files changed, 328 insertions(+), 61 deletions(-) create mode 100644 ems-admin/src/main/resources/application-prod.yml diff --git a/ems-admin/src/main/resources/application-druid.yml b/ems-admin/src/main/resources/application-druid.yml index c7ce773..6408036 100644 --- a/ems-admin/src/main/resources/application-druid.yml +++ b/ems-admin/src/main/resources/application-druid.yml @@ -1,61 +1,61 @@ -# 数据源配置 -spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - url: jdbc:mysql://122.51.194.184:13306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: ems - password: 12345678 - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置连接超时时间 - connectTimeout: 30000 - # 配置网络超时时间 - socketTimeout: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: xzzn - login-password: 123456 - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true \ No newline at end of file +## 数据源配置 +#spring: +# datasource: +# type: com.alibaba.druid.pool.DruidDataSource +# driverClassName: com.mysql.cj.jdbc.Driver +# druid: +# # 主库数据源 +# master: +# url: jdbc:mysql://122.51.194.184:13306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: ems +# password: 12345678 +# # 从库数据源 +# slave: +# # 从数据源开关/默认关闭 +# enabled: false +# url: +# username: +# password: +# # 初始连接数 +# initialSize: 5 +# # 最小连接池数量 +# minIdle: 10 +# # 最大连接池数量 +# maxActive: 20 +# # 配置获取连接等待超时的时间 +# maxWait: 60000 +# # 配置连接超时时间 +# connectTimeout: 30000 +# # 配置网络超时时间 +# socketTimeout: 60000 +# # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 +# timeBetweenEvictionRunsMillis: 60000 +# # 配置一个连接在池中最小生存的时间,单位是毫秒 +# minEvictableIdleTimeMillis: 300000 +# # 配置一个连接在池中最大生存的时间,单位是毫秒 +# maxEvictableIdleTimeMillis: 900000 +# # 配置检测连接是否有效 +# validationQuery: SELECT 1 FROM DUAL +# testWhileIdle: true +# testOnBorrow: false +# testOnReturn: false +# webStatFilter: +# enabled: true +# statViewServlet: +# enabled: true +# # 设置白名单,不填则允许所有访问 +# allow: +# url-pattern: /druid/* +# # 控制台管理用户名和密码 +# login-username: xzzn +# login-password: 123456 +# filter: +# stat: +# enabled: true +# # 慢SQL记录 +# log-slow-sql: true +# slow-sql-millis: 1000 +# merge-sql: true +# wall: +# config: +# multi-statement-allow: true \ No newline at end of file diff --git a/ems-admin/src/main/resources/application-prod.yml b/ems-admin/src/main/resources/application-prod.yml new file mode 100644 index 0000000..b38d43f --- /dev/null +++ b/ems-admin/src/main/resources/application-prod.yml @@ -0,0 +1,207 @@ +# 项目相关配置 +xzzn: + # 名称 + name: EMS + # 版本 + version: 0.0.1 + # 版权年份 + copyrightYear: 2025 + # 文件路径 示例( Windows配置D:/xzzn/uploadPath,Linux配置 /home/xzzn/uploadPath) + profile: /home/xzzn/uploadPath + # 获取ip地址开关 + addressEnabled: false + # 验证码类型 math 数字计算 char 字符验证 + captchaType: math + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为8080 + port: 8089 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + +# 日志配置 +logging: + level: + com.xzzn: info + org.springframework: warn + +# 用户配置 +user: + password: + # 密码最大错误次数 + maxRetryCount: 5 + # 密码锁定时间(默认10分钟) + lockTime: 10 + +# Spring配置 +spring: + # 资源信息 + messages: + # 国际化资源文件路径 + basename: i18n/messages + profiles: + active: druid + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: true + # redis 配置 + redis: + # 地址 + host: 172.17.0.9 + # 端口,默认为6379 + port: 6739 + # 数据库索引 + database: 0 + # 密码 + password: 12345678 + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms + # 数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://172.17.0.13 3306:3306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ems + password: Aa112211! + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: xzzn + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +# token配置 +token: + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklmnopqrstuvwxyz + # 令牌有效期(默认30分钟) + expireTime: 30 + +# MyBatis配置 +mybatis: + # 搜索指定包别名 + typeAliasesPackage: com.xzzn.**.domain + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 + configLocation: classpath:mybatis/mybatis-config.xml + +# PageHelper分页插件 +pagehelper: + helperDialect: mysql + supportMethodsArguments: true + params: count=countSql + +# Swagger配置 +swagger: + # 是否开启swagger + enabled: true + # 请求前缀 + pathMapping: /dev-api + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* + +mqtt: + broker.url: tcp://122.51.194.184:1883 + client.id: ems-cloud + username: dmbroker + #password: qwer1234 + connection-timeout: 15 + keep-alive-interval: 30 + automatic-reconnect: true + +modbus: + pool: + max-total: 20 + max-idle: 10 + min-idle: 3 + poll: + interval: "0 */5 * * * *" # 5分钟间隔 + timeout: 30000 # 30秒超时 diff --git a/ems-admin/src/main/resources/application.yml b/ems-admin/src/main/resources/application.yml index afad4c3..41a1ccc 100644 --- a/ems-admin/src/main/resources/application.yml +++ b/ems-admin/src/main/resources/application.yml @@ -87,6 +87,66 @@ spring: max-active: 8 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms + # 数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://122.51.194.184:13306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ems + password: 12345678 + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: xzzn + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true # token配置 token: -- 2.49.0 From fa280097ebf7ed15ca6fde9693313c100a8ce5ad Mon Sep 17 00:00:00 2001 From: mashili Date: Tue, 11 Nov 2025 17:14:40 +0800 Subject: [PATCH 204/336] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application-prod.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ems-admin/src/main/resources/application-prod.yml b/ems-admin/src/main/resources/application-prod.yml index b38d43f..5f7be2a 100644 --- a/ems-admin/src/main/resources/application-prod.yml +++ b/ems-admin/src/main/resources/application-prod.yml @@ -51,8 +51,6 @@ spring: messages: # 国际化资源文件路径 basename: i18n/messages - profiles: - active: druid # 文件上传 servlet: multipart: @@ -70,7 +68,7 @@ spring: # 地址 host: 172.17.0.9 # 端口,默认为6379 - port: 6739 + port: 6379 # 数据库索引 database: 0 # 密码 @@ -94,7 +92,7 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://172.17.0.13 3306:3306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://172.17.0.13:3306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: ems password: Aa112211! # 从库数据源 -- 2.49.0 From be4da8c58dc7e7a458d421023e04d1718098f4f8 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 12 Nov 2025 15:26:30 +0800 Subject: [PATCH 205/336] =?UTF-8?q?=E7=94=9F=E4=BA=A7mqtt=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application-prod.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ems-admin/src/main/resources/application-prod.yml b/ems-admin/src/main/resources/application-prod.yml index 5f7be2a..50100c4 100644 --- a/ems-admin/src/main/resources/application-prod.yml +++ b/ems-admin/src/main/resources/application-prod.yml @@ -187,10 +187,10 @@ xss: urlPatterns: /system/*,/monitor/*,/tool/* mqtt: - broker.url: tcp://122.51.194.184:1883 + broker.url: tcp://121.5.164.6:1883 client.id: ems-cloud - username: dmbroker - #password: qwer1234 + username: admin + password: Aa112211! connection-timeout: 15 keep-alive-interval: 30 automatic-reconnect: true -- 2.49.0 From f1e819ba2b1ceea37b1bb616be32489439fdca14 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 12 Nov 2025 23:21:04 +0800 Subject: [PATCH 206/336] =?UTF-8?q?=E7=94=9F=E4=BA=A7mqtt=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application-prod.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ems-admin/src/main/resources/application-prod.yml b/ems-admin/src/main/resources/application-prod.yml index 50100c4..00b6232 100644 --- a/ems-admin/src/main/resources/application-prod.yml +++ b/ems-admin/src/main/resources/application-prod.yml @@ -189,8 +189,8 @@ xss: mqtt: broker.url: tcp://121.5.164.6:1883 client.id: ems-cloud - username: admin - password: Aa112211! + username: dmbroker + password: qwer1234 connection-timeout: 15 keep-alive-interval: 30 automatic-reconnect: true -- 2.49.0 From 38ade0c2edc054cb694e09eccd5873e28b19a790 Mon Sep 17 00:00:00 2001 From: mashili Date: Thu, 13 Nov 2025 00:02:47 +0800 Subject: [PATCH 207/336] =?UTF-8?q?=E9=AA=8C=E6=94=B63-=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4=E5=91=8A=E8=AD=A6=E5=90=8C=E6=AD=A5=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 35 ++- .../aspectj/FaultProtPlanAspect.java | 262 ++++++++++++++++++ .../framework/aspectj/StrategySyncAspect.java | 94 ++++--- .../java/com/xzzn/ems/domain/MqttSyncLog.java | 158 +++++++++++ .../mapper/EmsFaultProtectionPlanMapper.java | 6 + .../xzzn/ems/mapper/MqttSyncLogMapper.java | 63 +++++ .../IEmsFaultProtectionPlanService.java | 3 + .../xzzn/ems/service/IMqttSyncLogService.java | 66 +++++ .../EmsFaultProtectionPlanServiceImpl.java | 46 +++ .../service/impl/EmsStrategyServiceImpl.java | 32 ++- .../service/impl/MqttSyncLogServiceImpl.java | 150 ++++++++++ .../ems/EmsFaultProtectionPlanMapper.xml | 7 + .../mapper/ems/MqttSyncLogMapper.xml | 100 +++++++ 13 files changed, 960 insertions(+), 62 deletions(-) create mode 100644 ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/MqttSyncLogMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index ec1d846..006a7a6 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -3,7 +3,7 @@ package com.xzzn.web.controller.ems; import com.alibaba.fastjson2.JSON; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsMqttTopicConfig; -import com.xzzn.ems.domain.MqttSyncStrategyLog; +import com.xzzn.ems.domain.MqttSyncLog; import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; import com.xzzn.ems.service.*; import com.xzzn.framework.manager.MqttLifecycleManager; @@ -45,6 +45,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; @Autowired private IEmsStrategyService emsStrategyService; + @Autowired + private IMqttSyncLogService iMqttSyncLogService; @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { @@ -98,6 +100,8 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { return this::handleSystemStatus; } else if (topic.contains("STRATEGY")) { return this::handleStrategyData; + } else if (topic.contains("PROTECTION_PLAN")) { + return this::handleFaultProtPlanData; } else { return this::handleDeviceData; } @@ -158,20 +162,29 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[处理运行策略数据] data: " + payload); try { // 业务处理逻辑 - MqttSyncStrategyLog strategyLog = JSON.parseObject(payload, MqttSyncStrategyLog.class); - if (strategyLog != null) { - String content = strategyLog.getContent(); - // 根据不同操作更新 - String operateType = strategyLog.getOperateType(); - if (!StringUtils.isEmpty(operateType)) { - emsStrategyService.dealStrategyData(content,operateType); - } - } + iMqttSyncLogService.handleMqttStrategyData(payload); + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); } catch (Exception e) { - log.error("Failed to process system status message: " + e.getMessage(), e); + log.error("Failed to process strategy data message: " + e.getMessage(), e); } + } + // 处理设备保护告警策略数据 + private void handleFaultProtPlanData(String topic, MqttMessage message) { + String payload = new String(message.getPayload()); + System.out.println("[处理设备保护告警策略数据] data: " + payload); + try { + // 业务处理逻辑 + MqttSyncLog planLog = JSON.parseObject(payload, MqttSyncLog.class); + if (planLog != null) { + iMqttSyncLogService.handleMqttPlanData(planLog); + } + + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + } catch (Exception e) { + log.error("Failed to process strategy data message: " + e.getMessage(), e); + } } @Override diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java new file mode 100644 index 0000000..8352f5a --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java @@ -0,0 +1,262 @@ +package com.xzzn.framework.aspectj; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsFaultProtectionPlan; +import com.xzzn.ems.domain.MqttSyncLog; +import com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.mapper.MqttSyncLogMapper; +import com.xzzn.framework.web.service.MqttPublisher; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cglib.beans.BeanMap; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * 设备保护告警同步 + */ +@Aspect +@Component +public class FaultProtPlanAspect { + @Autowired + private MqttPublisher mqttPublisher; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final String STRATEGY_TOPIC = "FAULT_PROTECTION_PLAN_UP"; + private static final String TABLE_NAME = "ems_fault_protection_plan"; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + @Autowired + private EmsFaultProtectionPlanMapper emsFaultProtectionPlanMapper; + + // 用ThreadLocal暂存删除前的对象 + private ThreadLocal beforeDeleteThreadLocal = new ThreadLocal<>(); + @Before("execution(* com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper.deleteEmsFaultProtectionPlanByIds(..)) && args(ids)") + public void beforeDelete(JoinPoint joinPoint, Long[] ids) { + // 获取删除的id + Object[] args = joinPoint.getArgs(); + if (args == null || args.length == 0) { + return; + } + Long[] id = (Long[]) args[0]; + + // 查询删除前的数据 + EmsFaultProtectionPlan faultInfo = emsFaultProtectionPlanMapper.selectEmsFaultProtectionPlanById(id[0]); + beforeDeleteThreadLocal.set(faultInfo); // 暂存 + } + + // 定义切点:拦截策略相关表的Mapper方法 + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper.insertEmsFaultProtectionPlan(..)) && args(insertEntity)) ") + public void insertPointCut(EmsFaultProtectionPlan insertEntity) { + System.out.println("【新增设备保护告警】FaultProtPlanAspect 实例化"); + } + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper.updateEmsFaultProtectionPlan(..)) && args(updateEntity)) ") + public void updatePointCut(EmsFaultProtectionPlan updateEntity) { + System.out.println("【更新设备保护告警】FaultProtPlanAspect 实例化"); + } + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper.deleteEmsFaultProtectionPlanByIds(..)) && args(ids)) ") + public void deletePointCut(Long[] ids) { + System.out.println("【删除设备保护告警】FaultProtPlanAspect 实例化"); + } + + // 方法执行成功后发布同步消息 + @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") + public void afterInsert(JoinPoint joinPoint, EmsFaultProtectionPlan insertEntity, Integer result) { + System.out.println("【新增设备保护告警切面进入成功】"); + if (result == 0) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String siteId = insertEntity.getSiteId(); + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType,siteId); + + try { + // 数据转换 + String content = convertEntityToJson(insertEntity); + message.setContent(content); + + // 发布到MQTT主题 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); + if (StringUtils.isEmpty(topic)) { + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + } + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + @AfterReturning(pointcut = "updatePointCut(updateEntity)", returning = "result") + public void afterUpdate(JoinPoint joinPoint, EmsFaultProtectionPlan updateEntity, Integer result) { + System.out.println("【更新设备保护告警切面进入成功】"); + if (result == 0) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String siteId = updateEntity.getSiteId(); + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType,siteId); + + try { + // 数据转换 + String content = convertEntityToJson(updateEntity); + message.setContent(content); + + // 发布到MQTT主题 - 判断区分本地还是云上 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); + if (StringUtils.isEmpty(topic)) { + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + } + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + @AfterReturning(pointcut = "deletePointCut(id)", returning = "result") + public void afterDelete(JoinPoint joinPoint, Long[] id, Integer result) { + System.out.println("【删除设备保护告警切面进入成功】"); + if (result == 0) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + + // 从ThreadLocal中获取删除前的对象 + EmsFaultProtectionPlan faultInfo = beforeDeleteThreadLocal.get(); + if (faultInfo == null) { + return; + } + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType,faultInfo.getSiteId()); + + try { + // 数据转换 + String content = convertEntityToJson(faultInfo); + message.setContent(content); + + // 发布到MQTT主题 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); + if (StringUtils.isEmpty(topic)) { + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + } + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + + // 构建同步信息 + private MqttSyncLog createMessageObject(String operateType, String siteId) { + MqttSyncLog message = new MqttSyncLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(TABLE_NAME); + message.setCreateTime(new Date()); + message.setTopic(STRATEGY_TOPIC); + message.setStatus("SUCCESS"); + message.setTarget(siteId); + return message; + } + + // 从方法名判断操作类型(示例:insert→INSERT,update→UPDATE,delete→DELETE) + private String getOperateType(String methodName) { + if (methodName.startsWith("insert")) return "INSERT"; + if (methodName.startsWith("stop")) return "STOP"; + if (methodName.startsWith("update") || methodName.startsWith("stop")) return "UPDATE"; + if (methodName.startsWith("delete")) return "DELETE"; + return "UNKNOWN"; + } + + // 从方法参数提取数据(示例:若参数是实体类,转成Map) + private Map extractDataFromParams(Object[] args) { + // 实际需反射获取实体类的字段和值(如id、name等) + Map data = new HashMap<>(); + if (args == null || args.length == 0) { + return data; + } + + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + if (arg == null) { + continue; // 跳过null参数 + } + + // 处理基本类型/包装类/字符串(直接作为值存入,key为"param0"、"param1"等) + if (isBasicType(arg.getClass())) { + String key = "param" + i; // 基本类型参数用"param0"、"param1"作为key + data.put(key, arg); + } else { + Map beanMap = beanToMap(arg); + data.putAll(beanMap); // 合并实体类的字段到结果Map + } + } + + return data; + } + + /** + * 判断是否为基本类型或包装类或字符串 + */ + private boolean isBasicType(Class clazz) { + return clazz.isPrimitive() // 基本类型(int、long、boolean等) + || clazz == String.class // 字符串 + || Number.class.isAssignableFrom(clazz) // 数字包装类(Integer、Long等) + || clazz == Boolean.class; // 布尔包装类 + } + + /** + * 将实体类转换为Map(字段名为key,字段值为value) + */ + private Map beanToMap(Object bean) { + Map map = new HashMap<>(); + if (bean == null) { + return map; + } + + // 方式1:使用BeanMap(简洁高效) + BeanMap beanMap = BeanMap.create(bean); + for (Object key : beanMap.keySet()) { + map.put(key.toString(), beanMap.get(key)); + } + + return map; + } + + // 在方法中转换 + public String convertEntityToJson(EmsFaultProtectionPlan insertEntity) throws Exception { + if (insertEntity == null) { + return null; // 空对象返回空JSON + } + + // 将实体类转换为JSON字符串 + return objectMapper.writeValueAsString(insertEntity); + } + + +} \ No newline at end of file diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java index b7eb2c7..518c214 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java @@ -4,9 +4,10 @@ import com.alibaba.fastjson2.JSON; import com.fasterxml.jackson.databind.ObjectMapper; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsStrategyRunning; -import com.xzzn.ems.domain.MqttSyncStrategyLog; +import com.xzzn.ems.domain.MqttSyncLog; import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; -import com.xzzn.ems.mapper.MqttSyncStrategyLogMapper; +import com.xzzn.ems.mapper.EmsStrategyRunningMapper; +import com.xzzn.ems.mapper.MqttSyncLogMapper; import com.xzzn.framework.web.service.MqttPublisher; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; @@ -21,18 +22,24 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; +/** + * 策略运行切面同步 + */ @Aspect @Component public class StrategySyncAspect { @Autowired private MqttPublisher mqttPublisher; - @Autowired - private MqttSyncStrategyLogMapper mqttSyncStrategyLogMapper; private static final ObjectMapper objectMapper = new ObjectMapper(); private static final String STRATEGY_TOPIC = "EMS_STRATEGY_UP"; + private static final String TABLE_NAME = "ems_strategy_running"; @Autowired private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + @Autowired + private EmsStrategyRunningMapper emsStrategyRunningMapper; // 定义切点:拦截策略相关表的Mapper方法 @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyRunningMapper.stopEmsStrategyRunning(..)) && args(id)) ") @@ -49,8 +56,8 @@ public class StrategySyncAspect { } // 方法执行成功后发布同步消息 - @AfterReturning(pointcut = "updatePointCut(insertEntity)", returning = "result") - public void afterUpdate(JoinPoint joinPoint, EmsStrategyRunning insertEntity, Integer result) { + @AfterReturning(pointcut = "updatePointCut(updateEntity)", returning = "result") + public void afterUpdate(JoinPoint joinPoint, EmsStrategyRunning updateEntity, Integer result) { System.out.println("【更新策略切面进入成功】"); if (result == 0) { return; @@ -58,33 +65,27 @@ public class StrategySyncAspect { // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); - String tableName = getTableNameFromMethod(methodName); // 从Mapper类名提取表名 + String siteId = updateEntity.getSiteId(); // 构建日志同步消息 - MqttSyncStrategyLog message = new MqttSyncStrategyLog(); - message.setSyncId(UUID.randomUUID().toString()); - message.setOperateType(operateType); - message.setTableName(tableName); - message.setCreateTime(new Date()); - message.setTopic(STRATEGY_TOPIC); - message.setStatus("SUCCESS"); + MqttSyncLog message = createMessageObject(operateType,siteId); try { // 数据转换 - String content = convertEntityToJson(insertEntity); + String content = convertEntityToJson(updateEntity); message.setContent(content); - // 发布到MQTT主题 + // 发布到MQTT主题 - 判断区分本地还是云上 String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); - if (!StringUtils.isEmpty(topic)) { - mqttPublisher.publish(topic, objectMapper.writeValueAsString(message), 1); + if (StringUtils.isEmpty(topic)) { + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); } } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); } // 存储同步信息 - mqttSyncStrategyLogMapper.insertMqttSyncStrategyLog(message); + mqttSyncLogMapper.insertMqttSyncLog(message); } @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") @@ -96,16 +97,10 @@ public class StrategySyncAspect { // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); - String tableName = getTableNameFromMethod(methodName); // 从Mapper类名提取表名 + String siteId = insertEntity.getSiteId(); // 构建日志同步消息 - MqttSyncStrategyLog message = new MqttSyncStrategyLog(); - message.setSyncId(UUID.randomUUID().toString()); - message.setOperateType(operateType); - message.setTableName(tableName); - message.setCreateTime(new Date()); - message.setTopic(STRATEGY_TOPIC); - message.setStatus("SUCCESS"); + MqttSyncLog message = createMessageObject(operateType, siteId); try { // 数据转换 @@ -113,13 +108,16 @@ public class StrategySyncAspect { message.setContent(content); // 发布到MQTT主题 - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); + if (StringUtils.isEmpty(topic)) { + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + } } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); } // 存储同步信息 - mqttSyncStrategyLogMapper.insertMqttSyncStrategyLog(message); + mqttSyncLogMapper.insertMqttSyncLog(message); } @AfterReturning(pointcut = "stopPointCut(id)", returning = "result") @@ -131,17 +129,11 @@ public class StrategySyncAspect { // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); - String tableName = getTableNameFromMethod(methodName); // 从Mapper类名提取表名 - + EmsStrategyRunning emsStrategyRunning = emsStrategyRunningMapper.selectEmsStrategyRunningById(id); + String siteId = emsStrategyRunning==null ? null : emsStrategyRunning.getSiteId(); // 构建日志同步消息 - MqttSyncStrategyLog message = new MqttSyncStrategyLog(); - message.setSyncId(UUID.randomUUID().toString()); - message.setOperateType(operateType); - message.setTableName(tableName); - message.setCreateTime(new Date()); - message.setTopic(STRATEGY_TOPIC); - message.setStatus("SUCCESS"); + MqttSyncLog message = createMessageObject(operateType, siteId); try { // 数据转换 @@ -151,15 +143,30 @@ public class StrategySyncAspect { message.setContent(content); // 发布到MQTT主题 - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); + if (StringUtils.isEmpty(topic)) { + mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); + } } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); } // 存储同步信息 - mqttSyncStrategyLogMapper.insertMqttSyncStrategyLog(message); + mqttSyncLogMapper.insertMqttSyncLog(message); } + // 构建同步信息 + private MqttSyncLog createMessageObject(String operateType, String siteId) { + MqttSyncLog message = new MqttSyncLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(TABLE_NAME); + message.setCreateTime(new Date()); + message.setTopic(STRATEGY_TOPIC); + message.setStatus("SUCCESS"); + message.setTarget(siteId); + return message; + } // 从方法名判断操作类型(示例:insert→INSERT,update→UPDATE,delete→DELETE) private String getOperateType(String methodName) { if (methodName.startsWith("insert")) return "INSERT"; @@ -169,12 +176,6 @@ public class StrategySyncAspect { return "UNKNOWN"; } - // 从Mapper类名提取表名(示例:StrategyMapper→strategy) - private String getTableNameFromMethod(String methodName) { - // 实际需通过JoinPoint获取Mapper类名,再转换为表名(如StrategyTemplateMapper→strategy_template) - return "strategy"; // 简化示例 - } - // 从方法参数提取数据(示例:若参数是实体类,转成Map) private Map extractDataFromParams(Object[] args) { // 实际需反射获取实体类的字段和值(如id、name等) @@ -240,4 +241,5 @@ public class StrategySyncAspect { return objectMapper.writeValueAsString(insertEntity); } + } \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java b/ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java new file mode 100644 index 0000000..cc8b5cf --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java @@ -0,0 +1,158 @@ +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; + +/** + * MQTT云上本地同步日志对象 mqtt_sync_log + * + * @author xzzn + * @date 2025-11-12 + */ +public class MqttSyncLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 同步消息唯一标识(与消息中的syncId一致) */ + @Excel(name = "同步消息唯一标识", readConverterExp = "与=消息中的syncId一致") + private String syncId; + + /** MQTT主题 */ + @Excel(name = "MQTT主题") + private String topic; + + /** 操作类型:INSERT/UPDATE/DELETE */ + @Excel(name = "操作类型:INSERT/UPDATE/DELETE") + private String operateType; + + /** 涉及的表名 */ + @Excel(name = "涉及的表名") + private String tableName; + + /** 同步数据内容(JSON格式) */ + @Excel(name = "同步数据内容", readConverterExp = "J=SON格式") + private String content; + + /** 处理状态:SUCCESS/FAIL */ + @Excel(name = "处理状态:SUCCESS/FAIL") + private String status; + + /** 失败原因(status=FAIL时填写) */ + @Excel(name = "失败原因", readConverterExp = "s=tatus=FAIL时填写") + private String errorMsg; + + /** 同步目标 */ + @Excel(name = "同步目标") + private String target; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSyncId(String syncId) + { + this.syncId = syncId; + } + + public String getSyncId() + { + return syncId; + } + + public void setTopic(String topic) + { + this.topic = topic; + } + + public String getTopic() + { + return topic; + } + + public void setOperateType(String operateType) + { + this.operateType = operateType; + } + + public String getOperateType() + { + return operateType; + } + + public void setTableName(String tableName) + { + this.tableName = tableName; + } + + public String getTableName() + { + return tableName; + } + + public void setContent(String content) + { + this.content = content; + } + + public String getContent() + { + return content; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + public void setErrorMsg(String errorMsg) + { + this.errorMsg = errorMsg; + } + + public String getErrorMsg() + { + return errorMsg; + } + + public void setTarget(String target) + { + this.target = target; + } + + public String getTarget() + { + return target; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("syncId", getSyncId()) + .append("topic", getTopic()) + .append("operateType", getOperateType()) + .append("tableName", getTableName()) + .append("content", getContent()) + .append("status", getStatus()) + .append("errorMsg", getErrorMsg()) + .append("target", getTarget()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java index 35c5eba..c5e08ce 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultProtectionPlanMapper.java @@ -2,6 +2,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsFaultProtectionPlan; +import org.apache.ibatis.annotations.Param; /** * 故障告警保护方案Mapper接口 @@ -58,4 +59,9 @@ public interface EmsFaultProtectionPlanMapper * @return 结果 */ public int deleteEmsFaultProtectionPlanByIds(Long[] ids); + + // 根据站点+faultName+faultLevel 同步删除 + public void deleteEmsFaultProtectionPlan(@Param("siteId")String siteId, + @Param("faultName")String faultName, + @Param("faultLevel")Integer faultLevel); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/MqttSyncLogMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/MqttSyncLogMapper.java new file mode 100644 index 0000000..e8199d0 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/MqttSyncLogMapper.java @@ -0,0 +1,63 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.MqttSyncLog; + +/** + * MQTT云上本地同步日志Mapper接口 + * + * @author xzzn + * @date 2025-11-12 + */ +public interface MqttSyncLogMapper +{ + /** + * 查询MQTT云上本地同步日志 + * + * @param id MQTT云上本地同步日志主键 + * @return MQTT云上本地同步日志 + */ + public MqttSyncLog selectMqttSyncLogById(Long id); + + /** + * 查询MQTT云上本地同步日志列表 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return MQTT云上本地同步日志集合 + */ + public List selectMqttSyncLogList(MqttSyncLog mqttSyncLog); + + /** + * 新增MQTT云上本地同步日志 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return 结果 + */ + public int insertMqttSyncLog(MqttSyncLog mqttSyncLog); + + /** + * 修改MQTT云上本地同步日志 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return 结果 + */ + public int updateMqttSyncLog(MqttSyncLog mqttSyncLog); + + /** + * 删除MQTT云上本地同步日志 + * + * @param id MQTT云上本地同步日志主键 + * @return 结果 + */ + public int deleteMqttSyncLogById(Long id); + + /** + * 批量删除MQTT云上本地同步日志 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMqttSyncLogByIds(Long[] ids); + + public MqttSyncLog selectMqttSyncLogBySyncId(String syncId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java index 8746bf2..36cbf28 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultProtectionPlanService.java @@ -58,4 +58,7 @@ public interface IEmsFaultProtectionPlanService * @return 结果 */ public int deleteEmsFaultProtectionPlanById(Long id); + + // 处理云上同步设备保护告警信息 + public void dealSyncData(String content, String operateType); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java b/ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java new file mode 100644 index 0000000..b984e0f --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java @@ -0,0 +1,66 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.MqttSyncLog; + +/** + * MQTT云上本地同步日志Service接口 + * + * @author xzzn + * @date 2025-11-12 + */ +public interface IMqttSyncLogService +{ + /** + * 查询MQTT云上本地同步日志 + * + * @param id MQTT云上本地同步日志主键 + * @return MQTT云上本地同步日志 + */ + public MqttSyncLog selectMqttSyncLogById(Long id); + + /** + * 查询MQTT云上本地同步日志列表 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return MQTT云上本地同步日志集合 + */ + public List selectMqttSyncLogList(MqttSyncLog mqttSyncLog); + + /** + * 新增MQTT云上本地同步日志 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return 结果 + */ + public int insertMqttSyncLog(MqttSyncLog mqttSyncLog); + + /** + * 修改MQTT云上本地同步日志 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return 结果 + */ + public int updateMqttSyncLog(MqttSyncLog mqttSyncLog); + + /** + * 批量删除MQTT云上本地同步日志 + * + * @param ids 需要删除的MQTT云上本地同步日志主键集合 + * @return 结果 + */ + public int deleteMqttSyncLogByIds(Long[] ids); + + /** + * 删除MQTT云上本地同步日志信息 + * + * @param id MQTT云上本地同步日志主键 + * @return 结果 + */ + public int deleteMqttSyncLogById(Long id); + + // 处理策略信息 + public void handleMqttStrategyData(String payload); + // 处理设备告警保护信息 + public void handleMqttPlanData(MqttSyncLog planLog); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java index d252b73..6da7cf1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultProtectionPlanServiceImpl.java @@ -1,7 +1,13 @@ package com.xzzn.ems.service.impl; import java.util.List; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsStrategyRunning; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper; @@ -93,4 +99,44 @@ public class EmsFaultProtectionPlanServiceImpl implements IEmsFaultProtectionPla { return emsFaultProtectionPlanMapper.deleteEmsFaultProtectionPlanById(id); } + + @Override + public void dealSyncData(String content, String operateType) { + if (StringUtils.isEmpty(content)) { + return; + } + + EmsFaultProtectionPlan faultProtectionPlan = JSON.parseObject(content, EmsFaultProtectionPlan.class); + switch(operateType) { + case "INSERT": + insertEmsFaultProtectionPlan(faultProtectionPlan); + break; + case "UPDATE": + updateEmsFaultProtectionPlan(faultProtectionPlan); + break; + case "DELETE": + // 根据站点+faultName+faultLevel 删除 + String siteId = faultProtectionPlan.getSiteId(); + String faultName = faultProtectionPlan.getFaultName(); + Integer faultLevel = faultProtectionPlan.getFaultLevel(); + emsFaultProtectionPlanMapper.deleteEmsFaultProtectionPlan(siteId, faultName, faultLevel); + break; + default: + break; + } + } + + private static Long[] convertJsonToLongArray(String json) { + // 解析 JSON 为 JSONObject + JSONObject jsonObject = JSON.parseObject(json); + // 获取 "id" 对应的 JSONArray + JSONArray idArray = jsonObject.getJSONArray("id"); + + if (idArray == null) { + return new Long[0]; // 数组不存在时返回空数组 + } + + // 转换为 Long 数组 + return idArray.toArray(new Long[0]); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java index a7e3ad8..0c277be 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java @@ -71,10 +71,32 @@ public class EmsStrategyServiceImpl implements IEmsStrategyService if (StringUtils.isEmpty(content)) { return; } -// switch (operateType) { -// case "INSERT": -// EmsStrategyRunning emsStrategyRunning = JSON.parseObject(content, EmsStrategyRunning.class); -// emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning); -// } + EmsStrategyRunning emsStrategyRunning = JSON.parseObject(content, EmsStrategyRunning.class); + switch (operateType) { + case "INSERT": + emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning); + break; + case "STOP": + Long id = emsStrategyRunning.getId(); + emsStrategyRunningMapper.stopEmsStrategyRunning(id); + break; + case "UPDATE": + String siteId = emsStrategyRunning.getSiteId(); + Long mainId = emsStrategyRunning.getMainStrategyId(); + Long auxId = emsStrategyRunning.getAuxiliaryStrategyId(); + EmsStrategyRunning existStrategy = emsStrategyRunningMapper.getRunningStrategy(siteId); + if (existStrategy != null) { // 存在正在运行的则更新 + existStrategy.setMainStrategyId(mainId); + existStrategy.setAuxiliaryStrategyId(auxId); + emsStrategyRunningMapper.updateEmsStrategyRunning(emsStrategyRunning); + } else { // 不存在着插入 + emsStrategyRunning.setCreateTime(DateUtils.getNowDate()); + emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning); + } + break; + default: + // 未知操作类型-不同步 + break; + } } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java new file mode 100644 index 0000000..8797e9e --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java @@ -0,0 +1,150 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; + +import com.alibaba.fastjson2.JSON; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.service.IEmsFaultProtectionPlanService; +import com.xzzn.ems.service.IEmsStrategyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.MqttSyncLogMapper; +import com.xzzn.ems.domain.MqttSyncLog; +import com.xzzn.ems.service.IMqttSyncLogService; + +/** + * MQTT云上本地同步日志Service业务层处理 + * + * @author xzzn + * @date 2025-11-12 + */ +@Service +public class MqttSyncLogServiceImpl implements IMqttSyncLogService +{ + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + @Autowired + private IEmsFaultProtectionPlanService emsFaultProtectionPlanService; + @Autowired + private IEmsStrategyService emsStrategyService; + + /** + * 查询MQTT云上本地同步日志 + * + * @param id MQTT云上本地同步日志主键 + * @return MQTT云上本地同步日志 + */ + @Override + public MqttSyncLog selectMqttSyncLogById(Long id) + { + return mqttSyncLogMapper.selectMqttSyncLogById(id); + } + + /** + * 查询MQTT云上本地同步日志列表 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return MQTT云上本地同步日志 + */ + @Override + public List selectMqttSyncLogList(MqttSyncLog mqttSyncLog) + { + return mqttSyncLogMapper.selectMqttSyncLogList(mqttSyncLog); + } + + /** + * 新增MQTT云上本地同步日志 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return 结果 + */ + @Override + public int insertMqttSyncLog(MqttSyncLog mqttSyncLog) + { + mqttSyncLog.setCreateTime(DateUtils.getNowDate()); + return mqttSyncLogMapper.insertMqttSyncLog(mqttSyncLog); + } + + /** + * 修改MQTT云上本地同步日志 + * + * @param mqttSyncLog MQTT云上本地同步日志 + * @return 结果 + */ + @Override + public int updateMqttSyncLog(MqttSyncLog mqttSyncLog) + { + return mqttSyncLogMapper.updateMqttSyncLog(mqttSyncLog); + } + + /** + * 批量删除MQTT云上本地同步日志 + * + * @param ids 需要删除的MQTT云上本地同步日志主键 + * @return 结果 + */ + @Override + public int deleteMqttSyncLogByIds(Long[] ids) + { + return mqttSyncLogMapper.deleteMqttSyncLogByIds(ids); + } + + /** + * 删除MQTT云上本地同步日志信息 + * + * @param id MQTT云上本地同步日志主键 + * @return 结果 + */ + @Override + public int deleteMqttSyncLogById(Long id) + { + return mqttSyncLogMapper.deleteMqttSyncLogById(id); + } + + /** + * 处理云上运行策略数据 + * @param payload + */ + @Override + public void handleMqttStrategyData(String payload) { + MqttSyncLog syncLog = JSON.parseObject(payload, MqttSyncLog.class); + if (syncLog != null) { + // 校验是否存在 + String syncId = syncLog.getSyncId(); + MqttSyncLog existLog = mqttSyncLogMapper.selectMqttSyncLogBySyncId(syncId); + if (existLog == null) { + // 根据不同操作更新 + String operateType = syncLog.getOperateType(); + if (!StringUtils.isEmpty(operateType)) { + emsStrategyService.dealStrategyData(syncLog.getContent(),operateType); + } + } + // 保存日志 + insertMqttSyncLog(syncLog); + } + } + + /** + * 处理云上同步的告警保护信息 + * @param planLog + */ + @Override + public void handleMqttPlanData(MqttSyncLog planLog) { + // 校验是否存在 + String syncId = planLog.getSyncId(); + MqttSyncLog existLog = mqttSyncLogMapper.selectMqttSyncLogBySyncId(syncId); + if (existLog != null) { + return; + } + // 保存日志 + insertMqttSyncLog(planLog); + + // 处理数据 + String operateType = planLog.getOperateType(); + if (!StringUtils.isEmpty(operateType)) { + emsFaultProtectionPlanService.dealSyncData(planLog.getContent(),operateType); + } + + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml index c221022..ea7ca86 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsFaultProtectionPlanMapper.xml @@ -114,4 +114,11 @@ #{id} + + + delete from ems_fault_protection_plan + where site_id = #{siteId} + and fault_name = #{faultName} + and fault_level = #{faultLevel} + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml b/ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml new file mode 100644 index 0000000..1a1a2f1 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + select id, sync_id, topic, operate_type, table_name, content, status, error_msg, target, create_time from mqtt_sync_log + + + + + + + + insert into mqtt_sync_log + + sync_id, + topic, + operate_type, + table_name, + content, + status, + error_msg, + target, + create_time, + + + #{syncId}, + #{topic}, + #{operateType}, + #{tableName}, + #{content}, + #{status}, + #{errorMsg}, + #{target}, + #{createTime}, + + + + + update mqtt_sync_log + + sync_id = #{syncId}, + topic = #{topic}, + operate_type = #{operateType}, + table_name = #{tableName}, + content = #{content}, + status = #{status}, + error_msg = #{errorMsg}, + target = #{target}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from mqtt_sync_log where id = #{id} + + + + delete from mqtt_sync_log where id in + + #{id} + + + + + \ No newline at end of file -- 2.49.0 From 25e03ab0284316efce8047d38affb13cbe8066b1 Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 16 Nov 2025 21:00:29 +0800 Subject: [PATCH 208/336] =?UTF-8?q?=E3=80=90=E9=AA=8C=E6=94=B6=E3=80=918?= =?UTF-8?q?=20=E6=9C=AC=E5=9C=B0=E8=AE=BE=E5=A4=87=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aspectj/DeviceChangeLogAspect.java | 97 +++++++++++++ .../com/xzzn/quartz/task/ModbusPoller.java | 54 ++++++- .../xzzn/ems/domain/EmsDeviceChangeLog.java | 134 ++++++++++++++++++ .../ems/mapper/EmsDeviceChangeLogMapper.java | 65 +++++++++ .../service/IEmsDeviceChangeLogService.java | 64 +++++++++ .../impl/EmsDeviceChangeLogServiceImpl.java | 128 +++++++++++++++++ .../mapper/ems/EmsDeviceChangeLogMapper.xml | 106 ++++++++++++++ 7 files changed, 643 insertions(+), 5 deletions(-) create mode 100644 ems-framework/src/main/java/com/xzzn/framework/aspectj/DeviceChangeLogAspect.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsDeviceChangeLog.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsDeviceChangeLogMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceChangeLogService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceChangeLogServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsDeviceChangeLogMapper.xml diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/DeviceChangeLogAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/DeviceChangeLogAspect.java new file mode 100644 index 0000000..7b5c608 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/DeviceChangeLogAspect.java @@ -0,0 +1,97 @@ +package com.xzzn.framework.aspectj; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsDeviceChangeLog; +import com.xzzn.ems.domain.MqttSyncLog; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.mapper.MqttSyncLogMapper; +import com.xzzn.framework.web.service.MqttPublisher; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.UUID; + +/** + * 设备运行状态变更日志同步 + * 本地 - 云端 + */ +@Aspect +@Component +public class DeviceChangeLogAspect { + + private static final Log logger = LogFactory.getLog(DeviceChangeLogAspect.class); + @Autowired + private MqttPublisher mqttPublisher; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final String MQTT_TOPIC = "DEVICE_CHANGE_LOG_UP"; + private static final String TABLE_NAME = "ems_device_change_log"; + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + + // 定义切点:拦截策略相关表的Mapper方法 + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsDeviceChangeLogMapper.insertEmsDeviceChangeLog(..)) && args(insertEntity)) ") + public void insertPointCut(EmsDeviceChangeLog insertEntity) { + logger.info("【新增设备运行状态变更日志】DeviceChangeLogAspect 实例化"); + } + + // 方法执行成功后发布同步消息 + @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") + public void afterInsert(JoinPoint joinPoint, EmsDeviceChangeLog insertEntity, Integer result) { + logger.info("【新增设备运行状态变更日志下发数据切面进入成功】"); + if (result == 0 || insertEntity == null) { + return; + } + + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String operateType = "INSERT"; + String siteId = insertEntity.getSiteId(); + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType,siteId); + + try { + // 数据转换 + String content = objectMapper.writeValueAsString(insertEntity); + message.setContent(content); + + // mqtt同步到云端 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + + // 构建同步信息 + private MqttSyncLog createMessageObject(String operateType, String siteId) { + MqttSyncLog message = new MqttSyncLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(TABLE_NAME); + message.setCreateTime(new Date()); + message.setTopic(MQTT_TOPIC); + message.setStatus("SUCCESS"); + message.setSyncObject(siteId); + message.setTarget("CLOUD"); + return message; + } +} \ No newline at end of file diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java index 4032535..3e121d0 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java @@ -1,9 +1,12 @@ package com.xzzn.quartz.task; import com.xzzn.common.enums.DeviceRunningStatus; +import com.xzzn.ems.domain.EmsDeviceChangeLog; import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.mapper.EmsDeviceChangeLogMapper; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsMqttMessageMapper; +import com.xzzn.ems.service.impl.EmsDeviceSettingServiceImpl; import com.xzzn.framework.manager.ModbusConnectionManager; import com.xzzn.framework.manager.ModbusConnectionWrapper; import com.xzzn.framework.manager.MqttLifecycleManager; @@ -14,7 +17,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Date; import java.util.List; +import java.util.UUID; /** * 轮询设备-通过modbus协议读取数据 @@ -33,6 +38,10 @@ public class ModbusPoller { private EmsDevicesSettingMapper deviceRepo; @Autowired private EmsMqttMessageMapper emsMqttMessageMapper; + @Autowired + private EmsDeviceSettingServiceImpl emsDeviceSettingServiceImpl; + @Autowired + private EmsDeviceChangeLogMapper emsDeviceChangeLogMapper; @Autowired public ModbusPoller(MqttLifecycleManager mqttLifecycleManager) { @@ -41,8 +50,9 @@ public class ModbusPoller { public void pollAllDevices() { logger.info("开始执行Modbus设备轮询..."); - - List activeDevices = deviceRepo.selectEmsDevicesSettingList(null); + EmsDevicesSetting selectEntity = new EmsDevicesSetting(); + selectEntity.setRunningStatus(DeviceRunningStatus.RUNNING.getCode()); + List activeDevices = deviceRepo.selectEmsDevicesSettingList(selectEntity); EmsDevicesSetting device = activeDevices.get(0); try { @@ -91,16 +101,39 @@ public class ModbusPoller { wrapper.close(); connectionManager.removeConnection(Integer.parseInt(device.getDeviceId())); } - throw new RuntimeException("轮询设备失败", e); + + // 设备轮询不到修改运行状态 + String beforeStatus = device.getRunningStatus(); + device.setRunningStatus(DeviceRunningStatus.SHUTDOWN.getCode()); + emsDeviceSettingServiceImpl.updateDevice(device); + + // 轮询设备,设备状态变更日志 + EmsDeviceChangeLog log = createLogEntity(beforeStatus,device); + emsDeviceChangeLogMapper.insertEmsDeviceChangeLog(log); + + throw new RuntimeException("轮询设备失败", e); } } // 处理获取到的数据 private void processData(EmsDevicesSetting device, int[] data) throws MqttException { + String beforeStatus = device.getRunningStatus(); + Boolean error = true; if (data == null || data.length == 0) { logger.warn("设备{}返回空数据", device.getId()); // 设备读取不到-设置设备故障 device.setRunningStatus(DeviceRunningStatus.FAULT.getCode()); + error = false; + } else { + // 恢复设备状态 - 运行 + device.setRunningStatus(DeviceRunningStatus.RUNNING.getCode()); + } + emsDeviceSettingServiceImpl.updateDevice(device); + // 轮询设备,设备状态变更日志 + EmsDeviceChangeLog log = createLogEntity(beforeStatus,device); + emsDeviceChangeLogMapper.insertEmsDeviceChangeLog(log); + // 错误数据-不处理直接返回 + if (!error) { return; } @@ -116,8 +149,6 @@ public class ModbusPoller { /* String siteId = device.getSiteId(); if (siteId.startsWith("021_DDS")) { - ems_devices_setting - dDSDataProcessService.handleDdsData(message); } else if (siteId.startsWith("021_FXX")) { fXXDataProcessService.handleFxData(message); @@ -132,4 +163,17 @@ public class ModbusPoller { // 将设备数据下发到mqtt服务器上 mqttLifecycleManager.publish(topic, dataJson, 0);*/ } + + private EmsDeviceChangeLog createLogEntity(String beforeStatus, EmsDevicesSetting device) { + EmsDeviceChangeLog log = new EmsDeviceChangeLog(); + log.setLogId(UUID.randomUUID().toString()); + log.setLogTime(new Date()); + log.setSiteId(device.getSiteId()); + log.setDeviceId(device.getDeviceId()); + log.setBeforeStatus(beforeStatus); + log.setAfterStatus(device.getRunningStatus()); + log.setCreateBy("sys"); + log.setCreateTime(new Date()); + return log; + } } \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDeviceChangeLog.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDeviceChangeLog.java new file mode 100644 index 0000000..350c8e2 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDeviceChangeLog.java @@ -0,0 +1,134 @@ +package com.xzzn.ems.domain; + +import java.util.Date; + +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_device_change_log + * + * @author xzzn + * @date 2025-11-15 + */ +public class EmsDeviceChangeLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 日志ID(UUID) */ + @Excel(name = "日志ID", readConverterExp = "U=UID") + private String logId; + + /** 日志时间(精确到秒) */ + @Excel(name = "日志时间", readConverterExp = "精=确到秒") + private Date logTime; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备id */ + @Excel(name = "设备id") + private String deviceId; + + /** 变更前状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ + @Excel(name = "变更前状态:0-离线、1-待机、2-运行、3-故障、4-停机") + private String beforeStatus; + + /** 变更后状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ + @Excel(name = "变更后状态:0-离线、1-待机、2-运行、3-故障、4-停机") + private String afterStatus; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setLogId(String logId) + { + this.logId = logId; + } + + public String getLogId() + { + return logId; + } + + public void setLogTime(Date logTime) + { + this.logTime = logTime; + } + + public Date getLogTime() + { + return logTime; + } + + 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 void setBeforeStatus(String beforeStatus) + { + this.beforeStatus = beforeStatus; + } + + public String getBeforeStatus() + { + return beforeStatus; + } + + public void setAfterStatus(String afterStatus) + { + this.afterStatus = afterStatus; + } + + public String getAfterStatus() + { + return afterStatus; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("logId", getLogId()) + .append("logTime", getLogTime()) + .append("siteId", getSiteId()) + .append("deviceId", getDeviceId()) + .append("beforeStatus", getBeforeStatus()) + .append("afterStatus", getAfterStatus()) + .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/mapper/EmsDeviceChangeLogMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDeviceChangeLogMapper.java new file mode 100644 index 0000000..bf81415 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDeviceChangeLogMapper.java @@ -0,0 +1,65 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsDeviceChangeLog; +import com.xzzn.ems.domain.EmsFaultIssueLog; + +/** + * 设备状态变更记录Mapper接口 + * + * @author xzzn + * @date 2025-11-15 + */ +public interface EmsDeviceChangeLogMapper +{ + /** + * 查询设备状态变更记录 + * + * @param id 设备状态变更记录主键 + * @return 设备状态变更记录 + */ + public EmsDeviceChangeLog selectEmsDeviceChangeLogById(Long id); + + /** + * 查询设备状态变更记录列表 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 设备状态变更记录集合 + */ + public List selectEmsDeviceChangeLogList(EmsDeviceChangeLog emsDeviceChangeLog); + + /** + * 新增设备状态变更记录 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 结果 + */ + public int insertEmsDeviceChangeLog(EmsDeviceChangeLog emsDeviceChangeLog); + + /** + * 修改设备状态变更记录 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 结果 + */ + public int updateEmsDeviceChangeLog(EmsDeviceChangeLog emsDeviceChangeLog); + + /** + * 删除设备状态变更记录 + * + * @param id 设备状态变更记录主键 + * @return 结果 + */ + public int deleteEmsDeviceChangeLogById(Long id); + + /** + * 批量删除设备状态变更记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsDeviceChangeLogByIds(Long[] ids); + + // 根据logId获取日志 + public EmsDeviceChangeLog selectDeviceChangeLogByLogId(String logId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceChangeLogService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceChangeLogService.java new file mode 100644 index 0000000..ba6e7d7 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsDeviceChangeLogService.java @@ -0,0 +1,64 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsDeviceChangeLog; + +/** + * 设备状态变更记录Service接口 + * + * @author xzzn + * @date 2025-11-15 + */ +public interface IEmsDeviceChangeLogService +{ + /** + * 查询设备状态变更记录 + * + * @param id 设备状态变更记录主键 + * @return 设备状态变更记录 + */ + public EmsDeviceChangeLog selectEmsDeviceChangeLogById(Long id); + + /** + * 查询设备状态变更记录列表 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 设备状态变更记录集合 + */ + public List selectEmsDeviceChangeLogList(EmsDeviceChangeLog emsDeviceChangeLog); + + /** + * 新增设备状态变更记录 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 结果 + */ + public int insertEmsDeviceChangeLog(EmsDeviceChangeLog emsDeviceChangeLog); + + /** + * 修改设备状态变更记录 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 结果 + */ + public int updateEmsDeviceChangeLog(EmsDeviceChangeLog emsDeviceChangeLog); + + /** + * 批量删除设备状态变更记录 + * + * @param ids 需要删除的设备状态变更记录主键集合 + * @return 结果 + */ + public int deleteEmsDeviceChangeLogByIds(Long[] ids); + + /** + * 删除设备状态变更记录信息 + * + * @param id 设备状态变更记录主键 + * @return 结果 + */ + public int deleteEmsDeviceChangeLogById(Long id); + + // 处理本地端同步设备状态变更数据 + public void dealSyncData(String content, String operateType); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceChangeLogServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceChangeLogServiceImpl.java new file mode 100644 index 0000000..87354e6 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsDeviceChangeLogServiceImpl.java @@ -0,0 +1,128 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; + +import com.alibaba.fastjson2.JSON; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsFaultIssueLog; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsDeviceChangeLogMapper; +import com.xzzn.ems.domain.EmsDeviceChangeLog; +import com.xzzn.ems.service.IEmsDeviceChangeLogService; + +/** + * 设备状态变更记录Service业务层处理 + * + * @author xzzn + * @date 2025-11-15 + */ +@Service +public class EmsDeviceChangeLogServiceImpl implements IEmsDeviceChangeLogService +{ + @Autowired + private EmsDeviceChangeLogMapper emsDeviceChangeLogMapper; + + /** + * 查询设备状态变更记录 + * + * @param id 设备状态变更记录主键 + * @return 设备状态变更记录 + */ + @Override + public EmsDeviceChangeLog selectEmsDeviceChangeLogById(Long id) + { + return emsDeviceChangeLogMapper.selectEmsDeviceChangeLogById(id); + } + + /** + * 查询设备状态变更记录列表 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 设备状态变更记录 + */ + @Override + public List selectEmsDeviceChangeLogList(EmsDeviceChangeLog emsDeviceChangeLog) + { + return emsDeviceChangeLogMapper.selectEmsDeviceChangeLogList(emsDeviceChangeLog); + } + + /** + * 新增设备状态变更记录 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 结果 + */ + @Override + public int insertEmsDeviceChangeLog(EmsDeviceChangeLog emsDeviceChangeLog) + { + emsDeviceChangeLog.setCreateTime(DateUtils.getNowDate()); + return emsDeviceChangeLogMapper.insertEmsDeviceChangeLog(emsDeviceChangeLog); + } + + /** + * 修改设备状态变更记录 + * + * @param emsDeviceChangeLog 设备状态变更记录 + * @return 结果 + */ + @Override + public int updateEmsDeviceChangeLog(EmsDeviceChangeLog emsDeviceChangeLog) + { + emsDeviceChangeLog.setUpdateTime(DateUtils.getNowDate()); + return emsDeviceChangeLogMapper.updateEmsDeviceChangeLog(emsDeviceChangeLog); + } + + /** + * 批量删除设备状态变更记录 + * + * @param ids 需要删除的设备状态变更记录主键 + * @return 结果 + */ + @Override + public int deleteEmsDeviceChangeLogByIds(Long[] ids) + { + return emsDeviceChangeLogMapper.deleteEmsDeviceChangeLogByIds(ids); + } + + /** + * 删除设备状态变更记录信息 + * + * @param id 设备状态变更记录主键 + * @return 结果 + */ + @Override + public int deleteEmsDeviceChangeLogById(Long id) + { + return emsDeviceChangeLogMapper.deleteEmsDeviceChangeLogById(id); + } + + @Override + public void dealSyncData(String content, String operateType) { + if (StringUtils.isEmpty(content)) { + return; + } + + EmsDeviceChangeLog changeLog = JSON.parseObject(content, EmsDeviceChangeLog.class); + String logId = changeLog.getLogId(); + if (checkLogIsExist(logId)) { + return; + } + switch(operateType) { + case "INSERT": + insertEmsDeviceChangeLog(changeLog); + break; + default: + break; + } + } + + private boolean checkLogIsExist(String logId) { + EmsDeviceChangeLog changeLog = emsDeviceChangeLogMapper.selectDeviceChangeLogByLogId(logId); + if (changeLog != null) { + return true; + } + return false; + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsDeviceChangeLogMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDeviceChangeLogMapper.xml new file mode 100644 index 0000000..48c9a56 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsDeviceChangeLogMapper.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + select id, log_id, log_time, siteId, deviceId, before_status, after_status, create_by, create_time, update_by, update_time, remark from ems_device_change_log + + + + + + + + insert into ems_device_change_log + + log_id, + log_time, + siteId, + deviceId, + before_status, + after_status, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{logId}, + #{logTime}, + #{siteId}, + #{deviceId}, + #{beforeStatus}, + #{afterStatus}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_device_change_log + + log_id = #{logId}, + log_time = #{logTime}, + siteId = #{siteId}, + deviceId = #{deviceId}, + before_status = #{beforeStatus}, + after_status = #{afterStatus}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_device_change_log where id = #{id} + + + + delete from ems_device_change_log where id in + + #{id} + + + + + \ No newline at end of file -- 2.49.0 From bfbb0ae475dfba7c4fdf10ec3b1709879dc69f2b Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 16 Nov 2025 21:22:09 +0800 Subject: [PATCH 209/336] =?UTF-8?q?=E3=80=90=E9=AA=8C=E6=94=B6=E3=80=913?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aspectj/FaultProtPlanAspect.java | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java index 8352f5a..bea0f63 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java @@ -8,6 +8,8 @@ import com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper; import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; import com.xzzn.ems.mapper.MqttSyncLogMapper; import com.xzzn.framework.web.service.MqttPublisher; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; @@ -23,16 +25,18 @@ import java.util.Map; import java.util.UUID; /** - * 设备保护告警同步 + * 设备保护告警方案同步 + * 云端 - 本地 */ @Aspect @Component public class FaultProtPlanAspect { + private static final Log logger = LogFactory.getLog(FaultProtPlanAspect.class); @Autowired private MqttPublisher mqttPublisher; private static final ObjectMapper objectMapper = new ObjectMapper(); - private static final String STRATEGY_TOPIC = "FAULT_PROTECTION_PLAN_UP"; + private static final String MQTT_TOPIC = "FAULT_PROTECTION_PLAN_UP"; private static final String TABLE_NAME = "ems_fault_protection_plan"; @Autowired private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; @@ -60,24 +64,31 @@ public class FaultProtPlanAspect { // 定义切点:拦截策略相关表的Mapper方法 @Pointcut("(execution(* com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper.insertEmsFaultProtectionPlan(..)) && args(insertEntity)) ") public void insertPointCut(EmsFaultProtectionPlan insertEntity) { - System.out.println("【新增设备保护告警】FaultProtPlanAspect 实例化"); + logger.info("【新增设备保护告警】FaultProtPlanAspect 实例化"); } @Pointcut("(execution(* com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper.updateEmsFaultProtectionPlan(..)) && args(updateEntity)) ") public void updatePointCut(EmsFaultProtectionPlan updateEntity) { - System.out.println("【更新设备保护告警】FaultProtPlanAspect 实例化"); + logger.info("【更新设备保护告警】FaultProtPlanAspect 实例化"); } @Pointcut("(execution(* com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper.deleteEmsFaultProtectionPlanByIds(..)) && args(ids)) ") public void deletePointCut(Long[] ids) { - System.out.println("【删除设备保护告警】FaultProtPlanAspect 实例化"); + logger.info("【删除设备保护告警】FaultProtPlanAspect 实例化"); } // 方法执行成功后发布同步消息 @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") public void afterInsert(JoinPoint joinPoint, EmsFaultProtectionPlan insertEntity, Integer result) { - System.out.println("【新增设备保护告警切面进入成功】"); - if (result == 0) { + logger.info("【新增设备保护告警切面进入成功】"); + if (result == 0 || insertEntity == null) { return; } + + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); @@ -92,10 +103,7 @@ public class FaultProtPlanAspect { message.setContent(content); // 发布到MQTT主题 - String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); - if (StringUtils.isEmpty(topic)) { - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); - } + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); @@ -105,10 +113,16 @@ public class FaultProtPlanAspect { } @AfterReturning(pointcut = "updatePointCut(updateEntity)", returning = "result") public void afterUpdate(JoinPoint joinPoint, EmsFaultProtectionPlan updateEntity, Integer result) { - System.out.println("【更新设备保护告警切面进入成功】"); - if (result == 0) { + logger.info("【更新设备保护告警切面进入成功】"); + if (result == 0 || updateEntity == null) { return; } + // 校验是否配置监听topic-监听则不发布 + /*String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + }*/ + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); @@ -122,11 +136,8 @@ public class FaultProtPlanAspect { String content = convertEntityToJson(updateEntity); message.setContent(content); - // 发布到MQTT主题 - 判断区分本地还是云上 - String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); - if (StringUtils.isEmpty(topic)) { - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); - } + // 发布到MQTT主题 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); @@ -136,10 +147,16 @@ public class FaultProtPlanAspect { } @AfterReturning(pointcut = "deletePointCut(id)", returning = "result") public void afterDelete(JoinPoint joinPoint, Long[] id, Integer result) { - System.out.println("【删除设备保护告警切面进入成功】"); - if (result == 0) { + logger.info("【删除设备保护告警切面进入成功】"); + if (result == 0 || id == null) { return; } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); @@ -159,10 +176,7 @@ public class FaultProtPlanAspect { message.setContent(content); // 发布到MQTT主题 - String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); - if (StringUtils.isEmpty(topic)) { - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); - } + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); @@ -178,8 +192,9 @@ public class FaultProtPlanAspect { message.setOperateType(operateType); message.setTableName(TABLE_NAME); message.setCreateTime(new Date()); - message.setTopic(STRATEGY_TOPIC); + message.setTopic(MQTT_TOPIC); message.setStatus("SUCCESS"); + message.setSyncObject("CLOUD"); message.setTarget(siteId); return message; } -- 2.49.0 From c62aa46fcbd25be806cf20f1ca01db8897fc146d Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 16 Nov 2025 22:27:53 +0800 Subject: [PATCH 210/336] =?UTF-8?q?=E3=80=90=E9=AA=8C=E6=94=B6=E3=80=913?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java index bea0f63..45ead76 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultProtPlanAspect.java @@ -118,10 +118,10 @@ public class FaultProtPlanAspect { return; } // 校验是否配置监听topic-监听则不发布 - /*String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); if (!StringUtils.isEmpty(topic)) { return; - }*/ + } // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); -- 2.49.0 From 3ee99fa8d47922d29fdb186b0a9e397fc3a36e9a Mon Sep 17 00:00:00 2001 From: mashili Date: Sun, 16 Nov 2025 22:48:14 +0800 Subject: [PATCH 211/336] =?UTF-8?q?=E3=80=90=E9=AA=8C=E6=94=B6=E3=80=916-?= =?UTF-8?q?=E4=BF=9D=E6=8A=A4=E6=96=B9=E6=A1=88=E5=91=8A=E8=AD=A6=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E4=BA=91=E7=AB=AF&&=20=E3=80=90=E9=AA=8C=E6=94=B6?= =?UTF-8?q?=E3=80=917-=E4=B8=8B=E5=8F=91=E6=93=8D=E4=BD=9C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=90=8C=E6=AD=A5=E4=BA=91=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aspectj/FaultPlanAlarmAspect.java | 104 ++++++++++++ .../aspectj/FaultPlanIssueAspect.java | 98 ++++++++++++ .../xzzn/quartz/task/ProtectionPlanTask.java | 41 +++-- .../com/xzzn/ems/domain/EmsFaultIssueLog.java | 150 ++++++++++++++++++ .../ems/mapper/EmsFaultIssueLogMapper.java | 64 ++++++++ .../ems/service/IEmsAlarmRecordsService.java | 3 + .../ems/service/IEmsFaultIssueLogService.java | 64 ++++++++ .../impl/EmsAlarmRecordsServiceImpl.java | 18 ++- .../impl/EmsFaultIssueLogServiceImpl.java | 129 +++++++++++++++ .../mapper/ems/EmsFaultIssueLogMapper.xml | 111 +++++++++++++ 10 files changed, 767 insertions(+), 15 deletions(-) create mode 100644 ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanAlarmAspect.java create mode 100644 ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanIssueAspect.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultIssueLog.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultIssueLogMapper.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultIssueLogService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultIssueLogServiceImpl.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsFaultIssueLogMapper.xml diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanAlarmAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanAlarmAspect.java new file mode 100644 index 0000000..f7096c7 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanAlarmAspect.java @@ -0,0 +1,104 @@ +package com.xzzn.framework.aspectj; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsAlarmRecords; +import com.xzzn.ems.domain.MqttSyncLog; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.mapper.MqttSyncLogMapper; +import com.xzzn.framework.web.service.MqttPublisher; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.UUID; + +/** + * 本地保护告警信息同步云端 + * 本地 - 云端 + * @author xzzn + */ +@Aspect +@Component +public class FaultPlanAlarmAspect +{ + + private static final Log logger = LogFactory.getLog(FaultPlanAlarmAspect.class); + + private static final ObjectMapper objectMapper = new ObjectMapper(); + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + @Autowired + private MqttPublisher mqttPublisher; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + + private static final String MQTT_TOPIC = "FAULT_ALARM_RECORD_UP"; + private static final String TABLE_NAME = "ems_alarm_records"; + // 切入点:拦截所有添加了@SyncAfterInsert注解的方法 + @Pointcut("@annotation(com.xzzn.common.annotation.SyncAfterInsert)") + public void syncInsertPointcut() {} + + // 方法执行成功后同步数据 + @AfterReturning(pointcut = "syncInsertPointcut()", returning = "result") + public void afterInsert(JoinPoint joinPoint, Integer result) { + logger.info("【新增保护策略告警数据切面进入成功】"); + if (result == 0) { + return; + } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + + // 获取参数中的EmsAlarmRecords对象 + Object[] args = joinPoint.getArgs(); + EmsAlarmRecords alarmRecords = null; + for (Object arg : args) { + if (arg instanceof EmsAlarmRecords) { + alarmRecords = (EmsAlarmRecords) arg; + break; + } + } + if (alarmRecords == null) { + return; + } + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject("INSERT", alarmRecords.getSiteId()); + try { + // 同步内容 + String content = objectMapper.writeValueAsString(alarmRecords); + message.setContent(content); + + // 发布到MQTT主题-同步到云端 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + + // 构建同步信息 + private MqttSyncLog createMessageObject(String operateType, String siteId) { + MqttSyncLog message = new MqttSyncLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(TABLE_NAME); + message.setCreateTime(new Date()); + message.setTopic(MQTT_TOPIC); + message.setStatus("SUCCESS"); + message.setSyncObject(siteId); + message.setTarget("CLOUD"); + return message; + } +} diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanIssueAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanIssueAspect.java new file mode 100644 index 0000000..c23842f --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/FaultPlanIssueAspect.java @@ -0,0 +1,98 @@ +package com.xzzn.framework.aspectj; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsFaultIssueLog; +import com.xzzn.ems.domain.MqttSyncLog; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.mapper.MqttSyncLogMapper; +import com.xzzn.framework.web.service.MqttPublisher; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * 保护告警方案下发日志同步 + * 本地 - 云端 + */ +@Aspect +@Component +public class FaultPlanIssueAspect { + + private static final Log logger = LogFactory.getLog(FaultPlanIssueAspect.class); + @Autowired + private MqttPublisher mqttPublisher; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final String MQTT_TOPIC = "FAULT_PLAN_ISSUE_UP"; + private static final String TABLE_NAME = "ems_fault_issue_log"; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + + // 定义切点:拦截策略相关表的Mapper方法 + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsFaultIssueLogMapper.insertEmsFaultIssueLog(..)) && args(insertEntity)) ") + public void insertPointCut(EmsFaultIssueLog insertEntity) { + logger.info("【新增保护告警策略下发数据】FaultPlanIssueAspect 实例化"); + } + + // 方法执行成功后发布同步消息 + @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") + public void afterInsert(JoinPoint joinPoint, EmsFaultIssueLog insertEntity, Integer result) { + logger.info("【新增保护告警策略下发数据切面进入成功】"); + if (result == 0 || insertEntity == null) { + return; + } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String operateType = "INSERT"; + String siteId = insertEntity.getSiteId(); + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType,siteId); + + try { + // 数据转换 + String content = objectMapper.writeValueAsString(insertEntity); + message.setContent(content); + + // mqtt同步到云端 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + + // 构建同步信息 + private MqttSyncLog createMessageObject(String operateType, String siteId) { + MqttSyncLog message = new MqttSyncLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(TABLE_NAME); + message.setCreateTime(new Date()); + message.setTopic(MQTT_TOPIC); + message.setStatus("SUCCESS"); + message.setSyncObject(siteId); + message.setTarget("CLOUD"); + return message; + } +} \ No newline at end of file diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java index b3f74bf..a809cae 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ProtectionPlanTask.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.annotation.SyncAfterInsert; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.AlarmLevelStatus; @@ -11,16 +12,10 @@ import com.xzzn.common.enums.AlarmStatus; import com.xzzn.common.enums.ProtPlanStatus; import com.xzzn.common.enums.StrategyStatus; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.EmsAlarmRecords; -import com.xzzn.ems.domain.EmsDevicesSetting; -import com.xzzn.ems.domain.EmsFaultProtectionPlan; -import com.xzzn.ems.domain.EmsStrategyRunning; +import com.xzzn.ems.domain.*; import com.xzzn.ems.domain.vo.ProtectionPlanVo; import com.xzzn.ems.domain.vo.ProtectionSettingVo; -import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; -import com.xzzn.ems.mapper.EmsDevicesSettingMapper; -import com.xzzn.ems.mapper.EmsFaultProtectionPlanMapper; -import com.xzzn.ems.mapper.EmsStrategyRunningMapper; +import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsFaultProtectionPlanService; import com.xzzn.framework.manager.ModbusConnectionManager; import com.xzzn.framework.manager.ModbusConnectionWrapper; @@ -33,10 +28,7 @@ import org.springframework.util.ObjectUtils; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -70,6 +62,8 @@ public class ProtectionPlanTask { private ModbusConnectionManager connectionManager; @Autowired private ModbusService modbusService; + @Autowired + private EmsFaultIssueLogMapper emsFaultIssueLogMapper; public ProtectionPlanTask(IEmsFaultProtectionPlanService iEmsFaultProtectionPlanService) { this.iEmsFaultProtectionPlanService = iEmsFaultProtectionPlanService; @@ -110,6 +104,8 @@ public class ProtectionPlanTask { } // 处理告警保护方案-返回触发下发方案时是否最高等级 + // 需要同步云端 + @SyncAfterInsert private boolean dealWithProtectionPlan(EmsFaultProtectionPlan plan, List protSettings) { boolean isHighLevel = false; @@ -140,7 +136,7 @@ public class ProtectionPlanTask { String protPlanJson = plan.getProtectionPlan(); if (protPlanJson != null && !protPlanJson.isEmpty()) { logger.info("<下发保护方案> 方案内容:{}", protPlanJson); - //executeProtectionActions(protPlanJson,siteId,plan.getId()); // 执行Modbus指令 + executeProtectionActions(protPlanJson,siteId,plan.getId(),plan.getFaultLevel()); // 执行Modbus指令 } // 更新方案状态为“已启用” @@ -181,7 +177,7 @@ public class ProtectionPlanTask { } // 下发保护方案 - private void executeProtectionActions(String protPlanJson, String siteId, Long planId){ + private void executeProtectionActions(String protPlanJson, String siteId, Long planId, Integer faultLevel){ final List protPlanList; try { protPlanList = objectMapper.readValue( @@ -197,6 +193,10 @@ public class ProtectionPlanTask { if (StringUtils.isEmpty(plan.getDeviceId()) || StringUtils.isEmpty(plan.getPoint())) { return; } + // 给设备发送指令记录日志,并同步云端 + EmsFaultIssueLog faultIssueLog = createLogEntity(plan,siteId); + faultIssueLog.setLogLevel(faultLevel); + emsFaultIssueLogMapper.insertEmsFaultIssueLog(faultIssueLog); // 通过modbus连接设备,发送数据 executeSinglePlan(plan,siteId); @@ -208,6 +208,19 @@ public class ProtectionPlanTask { } } + private EmsFaultIssueLog createLogEntity(ProtectionPlanVo plan,String siteId) { + EmsFaultIssueLog faultIssueLog = new EmsFaultIssueLog(); + faultIssueLog.setLogId(UUID.randomUUID().toString()); + faultIssueLog.setLogTime(new Date()); + faultIssueLog.setSiteId(siteId); + faultIssueLog.setDeviceId(plan.getDeviceId()); + faultIssueLog.setPoint(plan.getPoint()); + faultIssueLog.setValue(plan.getValue()); + faultIssueLog.setCreateBy("sys"); + faultIssueLog.setCreateTime(new Date()); + return faultIssueLog; + } + private void executeSinglePlan(ProtectionPlanVo plan, String siteId) throws Exception { String deviceId = plan.getDeviceId(); // 获取设备地址信息 diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultIssueLog.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultIssueLog.java new file mode 100644 index 0000000..5e1b042 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsFaultIssueLog.java @@ -0,0 +1,150 @@ +package com.xzzn.ems.domain; + +import java.math.BigDecimal; +import java.util.Date; + +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_fault_issue_log + * + * @author xzzn + * @date 2025-11-15 + */ +public class EmsFaultIssueLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 日志ID(UUID) */ + @Excel(name = "日志ID", readConverterExp = "U=UID") + private String logId; + + /** 日志时间(精确到秒) */ + @Excel(name = "日志时间", readConverterExp = "精=确到秒") + private Date logTime; + + /** 日志等级(同方案等级1/2/3等) */ + @Excel(name = "日志等级", readConverterExp = "同=方案等级1/2/3等") + private Integer logLevel; + + /** 站点名称/编号 */ + @Excel(name = "站点名称/编号") + private String siteId; + + /** 设备ID */ + @Excel(name = "设备ID") + private String deviceId; + + /** 操作点位 */ + @Excel(name = "操作点位") + private String point; + + /** 设置数据 */ + @Excel(name = "设置数据") + private BigDecimal value; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setLogId(String logId) + { + this.logId = logId; + } + + public String getLogId() + { + return logId; + } + + public void setLogTime(Date logTime) + { + this.logTime = logTime; + } + + public Date getLogTime() + { + return logTime; + } + + public void setLogLevel(Integer logLevel) + { + this.logLevel = logLevel; + } + + public Integer getLogLevel() + { + return logLevel; + } + + 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 void setPoint(String point) + { + this.point = point; + } + + public String getPoint() + { + return point; + } + + public void setValue(BigDecimal value) + { + this.value = value; + } + + public BigDecimal getValue() + { + return value; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("logId", getLogId()) + .append("logTime", getLogTime()) + .append("logLevel", getLogLevel()) + .append("site", getSiteId()) + .append("deviceId", getDeviceId()) + .append("point", getPoint()) + .append("value", getValue()) + .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/mapper/EmsFaultIssueLogMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultIssueLogMapper.java new file mode 100644 index 0000000..47380ad --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsFaultIssueLogMapper.java @@ -0,0 +1,64 @@ +package com.xzzn.ems.mapper; + +import java.util.List; +import com.xzzn.ems.domain.EmsFaultIssueLog; + +/** + * 告警保护方案下发日志Mapper接口 + * + * @author xzzn + * @date 2025-11-15 + */ +public interface EmsFaultIssueLogMapper +{ + /** + * 查询告警保护方案下发日志 + * + * @param id 告警保护方案下发日志主键 + * @return 告警保护方案下发日志 + */ + public EmsFaultIssueLog selectEmsFaultIssueLogById(Long id); + + /** + * 查询告警保护方案下发日志列表 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 告警保护方案下发日志集合 + */ + public List selectEmsFaultIssueLogList(EmsFaultIssueLog emsFaultIssueLog); + + /** + * 新增告警保护方案下发日志 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 结果 + */ + public int insertEmsFaultIssueLog(EmsFaultIssueLog emsFaultIssueLog); + + /** + * 修改告警保护方案下发日志 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 结果 + */ + public int updateEmsFaultIssueLog(EmsFaultIssueLog emsFaultIssueLog); + + /** + * 删除告警保护方案下发日志 + * + * @param id 告警保护方案下发日志主键 + * @return 结果 + */ + public int deleteEmsFaultIssueLogById(Long id); + + /** + * 批量删除告警保护方案下发日志 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsFaultIssueLogByIds(Long[] ids); + + // 根据logId获取日志 + public EmsFaultIssueLog selectEmsFaultIssueLogByLogId(String logId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java index 139d857..38e66bf 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -95,4 +95,7 @@ public interface IEmsAlarmRecordsService // 根据site_id和deviceId更新对应的redis public void updateRedisAlarmRecords(String siteId, String deviceId); + + // 处理本地端同步的保护策略告警信息 + public void dealSyncData(String content, String operateType); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultIssueLogService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultIssueLogService.java new file mode 100644 index 0000000..d4071c3 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsFaultIssueLogService.java @@ -0,0 +1,64 @@ +package com.xzzn.ems.service; + +import java.util.List; +import com.xzzn.ems.domain.EmsFaultIssueLog; + +/** + * 告警保护方案下发日志Service接口 + * + * @author xzzn + * @date 2025-11-15 + */ +public interface IEmsFaultIssueLogService +{ + /** + * 查询告警保护方案下发日志 + * + * @param id 告警保护方案下发日志主键 + * @return 告警保护方案下发日志 + */ + public EmsFaultIssueLog selectEmsFaultIssueLogById(Long id); + + /** + * 查询告警保护方案下发日志列表 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 告警保护方案下发日志集合 + */ + public List selectEmsFaultIssueLogList(EmsFaultIssueLog emsFaultIssueLog); + + /** + * 新增告警保护方案下发日志 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 结果 + */ + public int insertEmsFaultIssueLog(EmsFaultIssueLog emsFaultIssueLog); + + /** + * 修改告警保护方案下发日志 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 结果 + */ + public int updateEmsFaultIssueLog(EmsFaultIssueLog emsFaultIssueLog); + + /** + * 批量删除告警保护方案下发日志 + * + * @param ids 需要删除的告警保护方案下发日志主键集合 + * @return 结果 + */ + public int deleteEmsFaultIssueLogByIds(Long[] ids); + + /** + * 删除告警保护方案下发日志信息 + * + * @param id 告警保护方案下发日志主键 + * @return 结果 + */ + public int deleteEmsFaultIssueLogById(Long id); + + // 处理本地端同步的告警保护下发日志信息 + public void dealSyncData(String content, String operateType); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index 08fcc62..0d37974 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -4,6 +4,7 @@ import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import com.alibaba.fastjson2.JSON; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.domain.entity.SysUser; import com.xzzn.common.core.redis.RedisCache; @@ -18,7 +19,6 @@ import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; import com.xzzn.ems.mapper.EmsAlarmMatchDataMapper; import com.xzzn.ems.mapper.EmsTicketMapper; -import com.xzzn.ems.service.IEmsTicketService; import com.xzzn.system.mapper.SysUserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -292,5 +292,21 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService redisCache.setAllCacheMapValue(redisKey, newAlarms); } + @Override + public void dealSyncData(String content, String operateType) { + if (StringUtils.isEmpty(content)) { + return; + } + + EmsAlarmRecords alarmRecords = JSON.parseObject(content, EmsAlarmRecords.class); + switch(operateType) { + case "INSERT": + insertEmsAlarmRecords(alarmRecords); + break; + default: + break; + } + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultIssueLogServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultIssueLogServiceImpl.java new file mode 100644 index 0000000..99712be --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsFaultIssueLogServiceImpl.java @@ -0,0 +1,129 @@ +package com.xzzn.ems.service.impl; + +import java.util.List; + +import com.alibaba.fastjson2.JSON; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsAlarmRecords; +import com.xzzn.ems.service.IFXXAlarmDataProcessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.xzzn.ems.mapper.EmsFaultIssueLogMapper; +import com.xzzn.ems.domain.EmsFaultIssueLog; +import com.xzzn.ems.service.IEmsFaultIssueLogService; + +/** + * 告警保护方案下发日志Service业务层处理 + * + * @author xzzn + * @date 2025-11-15 + */ +@Service +public class EmsFaultIssueLogServiceImpl implements IEmsFaultIssueLogService +{ + @Autowired + private EmsFaultIssueLogMapper emsFaultIssueLogMapper; + + /** + * 查询告警保护方案下发日志 + * + * @param id 告警保护方案下发日志主键 + * @return 告警保护方案下发日志 + */ + @Override + public EmsFaultIssueLog selectEmsFaultIssueLogById(Long id) + { + return emsFaultIssueLogMapper.selectEmsFaultIssueLogById(id); + } + + /** + * 新增告警保护方案下发日志 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 结果 + */ + @Override + public int insertEmsFaultIssueLog(EmsFaultIssueLog emsFaultIssueLog) + { + emsFaultIssueLog.setCreateTime(DateUtils.getNowDate()); + return emsFaultIssueLogMapper.insertEmsFaultIssueLog(emsFaultIssueLog); + } + + /** + * 查询告警保护方案下发日志列表 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 告警保护方案下发日志 + */ + @Override + public List selectEmsFaultIssueLogList(EmsFaultIssueLog emsFaultIssueLog) + { + return emsFaultIssueLogMapper.selectEmsFaultIssueLogList(emsFaultIssueLog); + } + + /** + * 修改告警保护方案下发日志 + * + * @param emsFaultIssueLog 告警保护方案下发日志 + * @return 结果 + */ + @Override + public int updateEmsFaultIssueLog(EmsFaultIssueLog emsFaultIssueLog) + { + emsFaultIssueLog.setUpdateTime(DateUtils.getNowDate()); + return emsFaultIssueLogMapper.updateEmsFaultIssueLog(emsFaultIssueLog); + } + + /** + * 批量删除告警保护方案下发日志 + * + * @param ids 需要删除的告警保护方案下发日志主键 + * @return 结果 + */ + @Override + public int deleteEmsFaultIssueLogByIds(Long[] ids) + { + return emsFaultIssueLogMapper.deleteEmsFaultIssueLogByIds(ids); + } + + /** + * 删除告警保护方案下发日志信息 + * + * @param id 告警保护方案下发日志主键 + * @return 结果 + */ + @Override + public int deleteEmsFaultIssueLogById(Long id) + { + return emsFaultIssueLogMapper.deleteEmsFaultIssueLogById(id); + } + + @Override + public void dealSyncData(String content, String operateType) { + if (StringUtils.isEmpty(content)) { + return; + } + + EmsFaultIssueLog issueLog = JSON.parseObject(content, EmsFaultIssueLog.class); + String logId = issueLog.getLogId(); + if (checkLogIsExist(logId)) { + return; + } + switch(operateType) { + case "INSERT": + insertEmsFaultIssueLog(issueLog); + break; + default: + break; + } + } + + private boolean checkLogIsExist(String logId) { + EmsFaultIssueLog issueLog = emsFaultIssueLogMapper.selectEmsFaultIssueLogByLogId(logId); + if (issueLog != null) { + return true; + } + return false; + } +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsFaultIssueLogMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsFaultIssueLogMapper.xml new file mode 100644 index 0000000..15ebfe7 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsFaultIssueLogMapper.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + select id, log_id, log_time, log_level, site_id, device_id, point, value, create_by, create_time, update_by, update_time, remark from ems_fault_issue_log + + + + + + + + insert into ems_fault_issue_log + + log_id, + log_time, + log_level, + site_id, + device_id, + point, + value, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{logId}, + #{logTime}, + #{logLevel}, + #{siteId}, + #{deviceId}, + #{point}, + #{value}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_fault_issue_log + + log_id = #{logId}, + log_time = #{logTime}, + log_level = #{logLevel}, + site_id = #{siteId}, + device_id = #{deviceId}, + point = #{point}, + value = #{value}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_fault_issue_log where id = #{id} + + + + delete from ems_fault_issue_log where id in + + #{id} + + + + + \ No newline at end of file -- 2.49.0 From aab2b1d94e6e711806fdf52ec52062f1b288919b Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 17 Nov 2025 02:45:35 +0800 Subject: [PATCH 212/336] =?UTF-8?q?=E3=80=90=E9=AA=8C=E6=94=B6=E3=80=912?= =?UTF-8?q?=20=E8=BF=90=E8=A1=8C=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ct.java => StrategyRunningSyncAspect.java} | 86 +++--- .../aspectj/StrategyTempSyncAspect.java | 250 ++++++++++++++++++ .../aspectj/StrategyTimeConfigSyncAspect.java | 231 ++++++++++++++++ .../ems/domain/vo/SyncStrategyTempVo.java | 39 +++ .../domain/vo/SyncStrategyTimeConfigVo.java | 40 +++ .../xzzn/ems/mapper/EmsStrategyMapper.java | 3 + .../mapper/EmsStrategyTimeConfigMapper.java | 6 + .../xzzn/ems/service/IEmsStrategyService.java | 2 +- .../ems/service/IEmsStrategyTempService.java | 4 + .../IEmsStrategyTimeConfigService.java | 3 + .../service/impl/EmsStrategyServiceImpl.java | 72 ++++- .../impl/EmsStrategyTempServiceImpl.java | 63 +++++ .../EmsStrategyTimeConfigServiceImpl.java | 74 ++++++ .../mapper/ems/EmsStrategyMapper.xml | 5 + .../ems/EmsStrategyTimeConfigMapper.xml | 7 + 15 files changed, 839 insertions(+), 46 deletions(-) rename ems-framework/src/main/java/com/xzzn/framework/aspectj/{StrategySyncAspect.java => StrategyRunningSyncAspect.java} (75%) create mode 100644 ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java create mode 100644 ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTempVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTimeConfigVo.java diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyRunningSyncAspect.java similarity index 75% rename from ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java rename to ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyRunningSyncAspect.java index 518c214..3892603 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategySyncAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyRunningSyncAspect.java @@ -5,10 +5,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsStrategyRunning; import com.xzzn.ems.domain.MqttSyncLog; +import com.xzzn.ems.domain.vo.StrategyRunningVo; import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; import com.xzzn.ems.mapper.EmsStrategyRunningMapper; import com.xzzn.ems.mapper.MqttSyncLogMapper; import com.xzzn.framework.web.service.MqttPublisher; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; @@ -17,22 +20,22 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cglib.beans.BeanMap; import org.springframework.stereotype.Component; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; +import java.util.*; /** * 策略运行切面同步 + * 云端 - 本地 */ @Aspect @Component -public class StrategySyncAspect { +public class StrategyRunningSyncAspect { + + private static final Log logger = LogFactory.getLog(StrategyRunningSyncAspect.class); @Autowired private MqttPublisher mqttPublisher; private static final ObjectMapper objectMapper = new ObjectMapper(); - private static final String STRATEGY_TOPIC = "EMS_STRATEGY_UP"; + private static final String MQTT_TOPIC = "EMS_STRATEGY_UP"; private static final String TABLE_NAME = "ems_strategy_running"; @Autowired private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; @@ -41,27 +44,32 @@ public class StrategySyncAspect { @Autowired private EmsStrategyRunningMapper emsStrategyRunningMapper; - // 定义切点:拦截策略相关表的Mapper方法 @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyRunningMapper.stopEmsStrategyRunning(..)) && args(id)) ") public void stopPointCut(Long id) { - System.out.println("【停止策略切面】StrategyAspect 被实例化"); + logger.info("【停止策略切面】StrategyAspect 被实例化"); } @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyRunningMapper.insertEmsStrategyRunning(..)) && args(insertEntity)) ") public void insertPointCut(EmsStrategyRunning insertEntity) { - System.out.println("【新增策略切面】StrategyAspect 被实例化"); + logger.info("【新增策略切面】StrategyAspect 被实例化"); } @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyRunningMapper.updateEmsStrategyRunning(..)) && args(updateEntity)) ") public void updatePointCut(EmsStrategyRunning updateEntity) { - System.out.println("【更新策略切面】StrategyAspect 被实例化"); + logger.info("【更新策略切面】StrategyAspect 被实例化"); } // 方法执行成功后发布同步消息 @AfterReturning(pointcut = "updatePointCut(updateEntity)", returning = "result") public void afterUpdate(JoinPoint joinPoint, EmsStrategyRunning updateEntity, Integer result) { - System.out.println("【更新策略切面进入成功】"); - if (result == 0) { + logger.info("【更新策略切面进入成功】"); + if (result == 0 || updateEntity == null) { return; } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); @@ -72,14 +80,16 @@ public class StrategySyncAspect { try { // 数据转换 - String content = convertEntityToJson(updateEntity); + List runningVos = emsStrategyRunningMapper.getRunningList(siteId); + if (runningVos == null || runningVos.size() == 0) { + return; + } + StrategyRunningVo runningVo = runningVos.get(0); + String content = objectMapper.writeValueAsString(runningVo); message.setContent(content); - // 发布到MQTT主题 - 判断区分本地还是云上 - String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); - if (StringUtils.isEmpty(topic)) { - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); - } + // 发布到MQTT主题 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); @@ -90,10 +100,16 @@ public class StrategySyncAspect { @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") public void afterInsert(JoinPoint joinPoint, EmsStrategyRunning insertEntity, Integer result) { - System.out.println("【新增策略切面进入成功】"); - if (result == 0) { + logger.info("【新增策略切面进入成功】"); + if (result == 0 || insertEntity == null) { return; } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); @@ -104,14 +120,16 @@ public class StrategySyncAspect { try { // 数据转换 - String content = convertEntityToJson(insertEntity); + List runningVos = emsStrategyRunningMapper.getRunningList(siteId); + if (runningVos == null || runningVos.size() == 0) { + return; + } + StrategyRunningVo runningVo = runningVos.get(0); + String content = objectMapper.writeValueAsString(runningVo); message.setContent(content); // 发布到MQTT主题 - String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); - if (StringUtils.isEmpty(topic)) { - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); - } + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); @@ -122,10 +140,16 @@ public class StrategySyncAspect { @AfterReturning(pointcut = "stopPointCut(id)", returning = "result") public void afterStop(JoinPoint joinPoint, Long id, Integer result) { - System.out.println("【停止策略切面进入成功】"); - if (result == 0) { + logger.info("【停止策略切面进入成功】"); + if (result == 0 || id == null) { return; } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 String methodName = joinPoint.getSignature().getName(); String operateType = getOperateType(methodName); @@ -143,10 +167,7 @@ public class StrategySyncAspect { message.setContent(content); // 发布到MQTT主题 - String topic = emsMqttTopicConfigMapper.checkTopicIsExist(STRATEGY_TOPIC); - if (StringUtils.isEmpty(topic)) { - mqttPublisher.publish(STRATEGY_TOPIC, objectMapper.writeValueAsString(message), 1); - } + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); } catch (Exception e) { message.setStatus("FAIL"); message.setErrorMsg(e.getMessage()); @@ -162,8 +183,9 @@ public class StrategySyncAspect { message.setOperateType(operateType); message.setTableName(TABLE_NAME); message.setCreateTime(new Date()); - message.setTopic(STRATEGY_TOPIC); + message.setTopic(MQTT_TOPIC); message.setStatus("SUCCESS"); + message.setSyncObject("CLOUD"); message.setTarget(siteId); return message; } diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java new file mode 100644 index 0000000..d12b416 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java @@ -0,0 +1,250 @@ +package com.xzzn.framework.aspectj; + +import com.alibaba.fastjson2.JSON; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.common.utils.bean.BeanUtils; +import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.vo.SyncStrategyTempVo; +import com.xzzn.ems.mapper.*; +import com.xzzn.framework.web.service.MqttPublisher; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cglib.beans.BeanMap; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * 策略模板数据同步 + * 云端 - 本地 + */ +@Aspect +@Component +public class StrategyTempSyncAspect { + + private static final Log logger = LogFactory.getLog(StrategyTempSyncAspect.class); + @Autowired + private MqttPublisher mqttPublisher; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final String MQTT_TOPIC = "EMS_STRATEGY_UP"; + private static final String TABLE_NAME = "ems_strategy_temp"; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + @Autowired + private EmsStrategyMapper emsStrategyMapper; + @Autowired + private EmsStrategyTempMapper emsStrategyTempMapper; + + // 用ThreadLocal暂存删除前的对象 + private ThreadLocal beforeDeleteThreadLocal = new ThreadLocal<>(); + @Before("execution(* com.xzzn.ems.mapper.EmsStrategyTempMapper.deleteEmsStrategyTempById(..)) && args(templateId)") + public void beforeDelete(JoinPoint joinPoint, String templateId) { + // 查询删除前的数据-仅存一获取siteId + List tempList = emsStrategyTempMapper.selectStrategyTempByTempId(templateId); + if (tempList != null && tempList.size() > 0) { + beforeDeleteThreadLocal.set(tempList.get(0)); // 暂存 + } + } + + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyTempMapper.deleteEmsStrategyTempById(..)) && args(templateId)) ") + public void deletePointCut(String templateId) { + logger.info("【删除策略模版切面】StrategyTempSyncAspect 被实例化"); + } + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyTempMapper.insertEmsStrategyTemp(..)) && args(insertEntity)) ") + public void insertPointCut(EmsStrategyTemp insertEntity) { + logger.info("【新增策略模版切面】StrategyTempSyncAspect 被实例化"); + } + + // 方法执行成功后发布同步消息 + @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") + public void afterInsert(JoinPoint joinPoint, EmsStrategyTemp insertEntity, Integer result) { + logger.info("【新增策略切面进入成功】"); + if (result == 0 || insertEntity == null) { + return; + } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String siteId = insertEntity.getSiteId(); + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType, siteId); + + try { + // 校验策略id是否存在 + Long strategyId = insertEntity.getStrategyId(); + if (strategyId == null) { + return; + } + // 数据转换 + SyncStrategyTempVo tempVo = convertEntity(insertEntity); + String content = objectMapper.writeValueAsString(tempVo); + message.setContent(content); + + // 发布到MQTT主题 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + private SyncStrategyTempVo convertEntity(EmsStrategyTemp insertEntity) { + SyncStrategyTempVo tempVo = new SyncStrategyTempVo(); + BeanUtils.copyProperties(insertEntity, tempVo); + EmsStrategy strategy = emsStrategyMapper.selectEmsStrategyById(insertEntity.getStrategyId()); + if (strategy != null) { + tempVo.setStrategyName(strategy.getStrategyName()); + tempVo.setStrategyType(strategy.getStrategyType()); + } + return tempVo; + } + + @AfterReturning(pointcut = "deletePointCut(templateId)", returning = "result") + public void afterDelete(JoinPoint joinPoint, String templateId, Integer result) { + logger.info("【删除策略模版切面进入成功】"); + if (result == 0 || StringUtils.isEmpty(templateId)) { + return; + } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + // 从ThreadLocal中获取删除前的对象 + EmsStrategyTemp strategyTemp = beforeDeleteThreadLocal.get(); + String siteId = ""; + if (strategyTemp != null) { + siteId = strategyTemp.getSiteId(); + } + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType, siteId); + + try { + // 数据转换 + Map idMap = new HashMap<>(); + idMap.put("templateId", templateId); // 手动将参数值映射到"id"字段 + String content = JSON.toJSONString(idMap); + message.setContent(content); + + // 发布到MQTT主题 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + + // 构建同步信息 + private MqttSyncLog createMessageObject(String operateType, String siteId) { + MqttSyncLog message = new MqttSyncLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(TABLE_NAME); + message.setCreateTime(new Date()); + message.setTopic(MQTT_TOPIC); + message.setStatus("SUCCESS"); + message.setSyncObject("CLOUD"); + message.setTarget(siteId); + return message; + } + // 从方法名判断操作类型(示例:insert→INSERT,update→UPDATE,delete→DELETE) + private String getOperateType(String methodName) { + if (methodName.startsWith("insert")) return "INSERT"; + if (methodName.startsWith("stop")) return "STOP"; + if (methodName.startsWith("update") || methodName.startsWith("stop")) return "UPDATE"; + if (methodName.startsWith("delete")) return "DELETE"; + return "UNKNOWN"; + } + + // 从方法参数提取数据(示例:若参数是实体类,转成Map) + private Map extractDataFromParams(Object[] args) { + // 实际需反射获取实体类的字段和值(如id、name等) + Map data = new HashMap<>(); + if (args == null || args.length == 0) { + return data; + } + + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + if (arg == null) { + continue; // 跳过null参数 + } + + // 处理基本类型/包装类/字符串(直接作为值存入,key为"param0"、"param1"等) + if (isBasicType(arg.getClass())) { + String key = "param" + i; // 基本类型参数用"param0"、"param1"作为key + data.put(key, arg); + } else { + Map beanMap = beanToMap(arg); + data.putAll(beanMap); // 合并实体类的字段到结果Map + } + } + + return data; + } + + /** + * 判断是否为基本类型或包装类或字符串 + */ + private boolean isBasicType(Class clazz) { + return clazz.isPrimitive() // 基本类型(int、long、boolean等) + || clazz == String.class // 字符串 + || Number.class.isAssignableFrom(clazz) // 数字包装类(Integer、Long等) + || clazz == Boolean.class; // 布尔包装类 + } + + /** + * 将实体类转换为Map(字段名为key,字段值为value) + */ + private Map beanToMap(Object bean) { + Map map = new HashMap<>(); + if (bean == null) { + return map; + } + + // 方式1:使用BeanMap(简洁高效) + BeanMap beanMap = BeanMap.create(bean); + for (Object key : beanMap.keySet()) { + map.put(key.toString(), beanMap.get(key)); + } + + return map; + } + + // 在方法中转换 + public String convertEntityToJson(EmsStrategyRunning insertEntity) throws Exception { + if (insertEntity == null) { + return null; // 空对象返回空JSON + } + + // 将实体类转换为JSON字符串 + return objectMapper.writeValueAsString(insertEntity); + } + + +} \ No newline at end of file diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java new file mode 100644 index 0000000..69f7e26 --- /dev/null +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java @@ -0,0 +1,231 @@ +package com.xzzn.framework.aspectj; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.common.utils.bean.BeanUtils; +import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.vo.SyncStrategyTimeConfigVo; +import com.xzzn.ems.mapper.*; +import com.xzzn.framework.web.service.MqttPublisher; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cglib.beans.BeanMap; +import org.springframework.stereotype.Component; + +import java.util.*; + +/** + * 策略时间配置同步 + * 云端 - 本地 + */ +@Aspect +@Component +public class StrategyTimeConfigSyncAspect { + + private static final Log logger = LogFactory.getLog(StrategyTimeConfigSyncAspect.class); + @Autowired + private MqttPublisher mqttPublisher; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final String MQTT_TOPIC = "EMS_STRATEGY_UP"; + private static final String TABLE_NAME = "ems_strategy_temp"; + @Autowired + private EmsMqttTopicConfigMapper emsMqttTopicConfigMapper; + @Autowired + private MqttSyncLogMapper mqttSyncLogMapper; + @Autowired + private EmsStrategyMapper emsStrategyMapper; + @Autowired + private EmsStrategyTempMapper emsStrategyTempMapper; + + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper.insertEmsStrategyTimeConfig(..)) && args(insertEntity)) ") + public void insertPointCut(EmsStrategyTimeConfig insertEntity) { + logger.info("【新增策略模版时间配置切面】StrategyTimeConfigSyncAspect 被实例化"); + } + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper.updateEmsStrategyTimeConfig(..)) && args(updateEntity)) ") + public void updatePointCut(EmsStrategyTimeConfig updateEntity) { + logger.info("【更新策略模版时间配置切面】StrategyTimeConfigSyncAspect 被实例化"); + } + + // 方法执行成功后发布同步消息 + @AfterReturning(pointcut = "insertPointCut(insertEntity)", returning = "result") + public void afterInsert(JoinPoint joinPoint, EmsStrategyTimeConfig insertEntity, Integer result) { + logger.info("【新增策略模版时间切面进入成功】"); + if (result == 0 || insertEntity == null) { + return; + } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String siteId = insertEntity.getSiteId(); + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType, siteId); + + try { + // 校验策略id是否存在 + Long strategyId = insertEntity.getStrategyId(); + if (strategyId == null) { + return; + } + // 数据转换 + SyncStrategyTimeConfigVo timeConfigVo = convertEntity(insertEntity); + String content = objectMapper.writeValueAsString(timeConfigVo); + message.setContent(content); + + // 发布到MQTT主题 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + private SyncStrategyTimeConfigVo convertEntity(EmsStrategyTimeConfig insertEntity) { + SyncStrategyTimeConfigVo timeConfigVo = new SyncStrategyTimeConfigVo(); + BeanUtils.copyProperties(insertEntity, timeConfigVo); + EmsStrategy strategy = emsStrategyMapper.selectEmsStrategyById(insertEntity.getStrategyId()); + if (strategy != null) { + timeConfigVo.setStrategyName(strategy.getStrategyName()); + timeConfigVo.setStrategyType(strategy.getStrategyType()); + } + return timeConfigVo; + } + + @AfterReturning(pointcut = "updatePointCut(updateEntity)", returning = "result") + public void afterUpdate(JoinPoint joinPoint, EmsStrategyTimeConfig updateEntity, Integer result) { + logger.info("【删除策略模版切面进入成功】"); + if (result == 0 || updateEntity == null) { + return; + } + // 校验是否配置监听topic-监听则不发布 + String topic = emsMqttTopicConfigMapper.checkTopicIsExist(MQTT_TOPIC); + if (!StringUtils.isEmpty(topic)) { + return; + } + + // 解析方法名,获取操作类型(INSERT/UPDATE/DELETE)和表名 + String methodName = joinPoint.getSignature().getName(); + String operateType = getOperateType(methodName); + String siteId = updateEntity.getSiteId(); + + // 构建日志同步消息 + MqttSyncLog message = createMessageObject(operateType, siteId); + + try { + // 数据转换 + SyncStrategyTimeConfigVo timeConfigVo = convertEntity(updateEntity); + String content = objectMapper.writeValueAsString(timeConfigVo); + message.setContent(content); + + // 发布到MQTT主题 + mqttPublisher.publish(MQTT_TOPIC, objectMapper.writeValueAsString(message), 1); + } catch (Exception e) { + message.setStatus("FAIL"); + message.setErrorMsg(e.getMessage()); + } + // 存储同步信息 + mqttSyncLogMapper.insertMqttSyncLog(message); + } + + // 构建同步信息 + private MqttSyncLog createMessageObject(String operateType, String siteId) { + MqttSyncLog message = new MqttSyncLog(); + message.setSyncId(UUID.randomUUID().toString()); + message.setOperateType(operateType); + message.setTableName(TABLE_NAME); + message.setCreateTime(new Date()); + message.setTopic(MQTT_TOPIC); + message.setStatus("SUCCESS"); + message.setSyncObject("CLOUD"); + message.setTarget(siteId); + return message; + } + // 从方法名判断操作类型(示例:insert→INSERT,update→UPDATE,delete→DELETE) + private String getOperateType(String methodName) { + if (methodName.startsWith("insert")) return "INSERT"; + if (methodName.startsWith("stop")) return "STOP"; + if (methodName.startsWith("update") || methodName.startsWith("stop")) return "UPDATE"; + if (methodName.startsWith("delete")) return "DELETE"; + return "UNKNOWN"; + } + + // 从方法参数提取数据(示例:若参数是实体类,转成Map) + private Map extractDataFromParams(Object[] args) { + // 实际需反射获取实体类的字段和值(如id、name等) + Map data = new HashMap<>(); + if (args == null || args.length == 0) { + return data; + } + + for (int i = 0; i < args.length; i++) { + Object arg = args[i]; + if (arg == null) { + continue; // 跳过null参数 + } + + // 处理基本类型/包装类/字符串(直接作为值存入,key为"param0"、"param1"等) + if (isBasicType(arg.getClass())) { + String key = "param" + i; // 基本类型参数用"param0"、"param1"作为key + data.put(key, arg); + } else { + Map beanMap = beanToMap(arg); + data.putAll(beanMap); // 合并实体类的字段到结果Map + } + } + + return data; + } + + /** + * 判断是否为基本类型或包装类或字符串 + */ + private boolean isBasicType(Class clazz) { + return clazz.isPrimitive() // 基本类型(int、long、boolean等) + || clazz == String.class // 字符串 + || Number.class.isAssignableFrom(clazz) // 数字包装类(Integer、Long等) + || clazz == Boolean.class; // 布尔包装类 + } + + /** + * 将实体类转换为Map(字段名为key,字段值为value) + */ + private Map beanToMap(Object bean) { + Map map = new HashMap<>(); + if (bean == null) { + return map; + } + + // 方式1:使用BeanMap(简洁高效) + BeanMap beanMap = BeanMap.create(bean); + for (Object key : beanMap.keySet()) { + map.put(key.toString(), beanMap.get(key)); + } + + return map; + } + + // 在方法中转换 + public String convertEntityToJson(EmsStrategyRunning insertEntity) throws Exception { + if (insertEntity == null) { + return null; // 空对象返回空JSON + } + + // 将实体类转换为JSON字符串 + return objectMapper.writeValueAsString(insertEntity); + } + + +} \ No newline at end of file diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTempVo.java new file mode 100644 index 0000000..49407c9 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTempVo.java @@ -0,0 +1,39 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; +import com.xzzn.ems.domain.EmsStrategyTemp; + +/** + * 同步策略模版对象 + * + * @author xzzn + * @date 2025-11-16 + */ +public class SyncStrategyTempVo extends EmsStrategyTemp +{ + private static final long serialVersionUID = 1L; + + /** 策略名称,如“削峰填谷” */ + @Excel(name = "策略名称,如“削峰填谷”") + private String strategyName; + + /** 策略类型:1 - 主策略;2 - 辅助策略 */ + @Excel(name = "策略类型:1 - 主策略;2 - 辅助策略") + private Long strategyType; + + public String getStrategyName() { + return strategyName; + } + + public void setStrategyName(String strategyName) { + this.strategyName = strategyName; + } + + public Long getStrategyType() { + return strategyType; + } + + public void setStrategyType(Long strategyType) { + this.strategyType = strategyType; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTimeConfigVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTimeConfigVo.java new file mode 100644 index 0000000..71fe0bd --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SyncStrategyTimeConfigVo.java @@ -0,0 +1,40 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; + +/** + * 同步策略时间配置对象 + * + * @author xzzn + * @date 2025-11-16 + */ +public class SyncStrategyTimeConfigVo extends EmsStrategyTimeConfig +{ + private static final long serialVersionUID = 1L; + + /** 策略名称,如“削峰填谷” */ + @Excel(name = "策略名称,如“削峰填谷”") + private String strategyName; + + /** 策略类型:1 - 主策略;2 - 辅助策略 */ + @Excel(name = "策略类型:1 - 主策略;2 - 辅助策略") + private Long strategyType; + + public String getStrategyName() { + return strategyName; + } + + public void setStrategyName(String strategyName) { + this.strategyName = strategyName; + } + + public Long getStrategyType() { + return strategyType; + } + + public void setStrategyType(Long strategyType) { + this.strategyType = strategyType; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java index 6d430fc..396c04d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyMapper.java @@ -60,4 +60,7 @@ public interface EmsStrategyMapper public int deleteEmsStrategyByIds(Long[] ids); public List getStrategyListByType(Long type); + + // 通过名称获取策略 + public EmsStrategy getStrategyByName(String strategyName); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java index b6eb10e..94cbaf7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsStrategyTimeConfigMapper.java @@ -3,6 +3,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsStrategyTimeConfig; import com.xzzn.ems.domain.vo.StrategyTimeConfigVo; +import org.apache.ibatis.annotations.Param; /** * 时间配置Mapper接口 @@ -71,4 +72,9 @@ public interface EmsStrategyTimeConfigMapper // 设置该模版的时间配置为待下发 public void updateTimeConfigWaitingPost(String templateId); + + // 判断时间配置是否存在 + public EmsStrategyTimeConfig getExistTimeConfig(@Param("siteId")String siteId, + @Param("strategyId")Long strategyId, + @Param("month")Long month); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java index 30fb174..69fc6a9 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyService.java @@ -29,5 +29,5 @@ public interface IEmsStrategyService public int configStrategy(EmsStrategyRunning emsStrategyRunning); // 接收云上运行策略配置 - public void dealStrategyData(String content, String operateType); + public void dealStrategyRunningData(String content, String operateType); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java index 35ac3b8..9a4fe55 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTempService.java @@ -3,6 +3,7 @@ package com.xzzn.ems.service; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.JsonProcessingException; import com.xzzn.ems.domain.EmsStrategyTemp; import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; @@ -32,4 +33,7 @@ public interface IEmsStrategyTempService //根据templateId删除模板 public int deleteStrategyTempById(String templateId); + + // 处理同步数据 + public void dealStrategyTempData(String content, String operateType) throws JsonProcessingException; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java index 3a8a1ea..383c84d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStrategyTimeConfigService.java @@ -67,4 +67,7 @@ public interface IEmsStrategyTimeConfigService * @return 时间配置集合 */ public List getStrategyTimeList(EmsStrategyTimeConfig emsStrategyTimeConfig); + + // 处理同步数据 + public void dealStrategyTimeData(String content, String operateType); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java index 0c277be..5900c46 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyServiceImpl.java @@ -3,11 +3,13 @@ package com.xzzn.ems.service.impl; import java.util.List; import com.alibaba.fastjson2.JSON; +import com.xzzn.common.enums.StrategyStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsStrategyRunning; import com.xzzn.ems.domain.vo.StrategyRunningVo; import com.xzzn.ems.mapper.EmsStrategyRunningMapper; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsStrategyMapper; @@ -67,31 +69,43 @@ public class EmsStrategyServiceImpl implements IEmsStrategyService } @Override - public void dealStrategyData(String content, String operateType) { + public void dealStrategyRunningData(String content, String operateType) { if (StringUtils.isEmpty(content)) { return; } - EmsStrategyRunning emsStrategyRunning = JSON.parseObject(content, EmsStrategyRunning.class); + String siteId = ""; + EmsStrategyRunning emsStrategyRunning = new EmsStrategyRunning(); switch (operateType) { case "INSERT": + StrategyRunningVo insertVo = JSON.parseObject(content, StrategyRunningVo.class); + BeanUtils.copyProperties(insertVo, emsStrategyRunning); + // 先校验策略是否存在,不存在则插入 + dealStrategyData(emsStrategyRunning, insertVo); + // 新增策略运行数据 emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning); break; case "STOP": - Long id = emsStrategyRunning.getId(); - emsStrategyRunningMapper.stopEmsStrategyRunning(id); + EmsStrategyRunning vo = JSON.parseObject(content, EmsStrategyRunning.class); + siteId = vo.getSiteId(); + // 停止站点正在运行的策略即可 + EmsStrategyRunning runningStrategy = emsStrategyRunningMapper.getRunningStrategy(siteId); + emsStrategyRunningMapper.stopEmsStrategyRunning(runningStrategy.getId()); break; case "UPDATE": - String siteId = emsStrategyRunning.getSiteId(); - Long mainId = emsStrategyRunning.getMainStrategyId(); - Long auxId = emsStrategyRunning.getAuxiliaryStrategyId(); + StrategyRunningVo updateVo = JSON.parseObject(content, StrategyRunningVo.class); + siteId = updateVo.getSiteId(); + // 获取该站点是否有正在运行的策略,无则新增,有则更新 EmsStrategyRunning existStrategy = emsStrategyRunningMapper.getRunningStrategy(siteId); - if (existStrategy != null) { // 存在正在运行的则更新 - existStrategy.setMainStrategyId(mainId); - existStrategy.setAuxiliaryStrategyId(auxId); - emsStrategyRunningMapper.updateEmsStrategyRunning(emsStrategyRunning); - } else { // 不存在着插入 - emsStrategyRunning.setCreateTime(DateUtils.getNowDate()); + if (existStrategy == null) { + BeanUtils.copyProperties(updateVo, emsStrategyRunning); + // 先校验策略是否存在,不存在则插入 + dealStrategyData(emsStrategyRunning, updateVo); emsStrategyRunningMapper.insertEmsStrategyRunning(emsStrategyRunning); + } else { + // 校验更新的主副策略是否存在,不存在则插入,存在则获取id + dealStrategyData(existStrategy, updateVo); + emsStrategyRunning.setCreateTime(DateUtils.getNowDate()); + emsStrategyRunningMapper.updateEmsStrategyRunning(existStrategy); } break; default: @@ -99,4 +113,36 @@ public class EmsStrategyServiceImpl implements IEmsStrategyService break; } } + + private void dealStrategyData(EmsStrategyRunning emsStrategyRunning, StrategyRunningVo insertVo) { + // 主策略 + String mainStrategyName = insertVo.getMainStrategyName(); + EmsStrategy mainStrategy = emsStrategyMapper.getStrategyByName(mainStrategyName); + if (mainStrategy != null) { + emsStrategyRunning.setMainStrategyId(mainStrategy.getId()); + } else { + mainStrategy = createStrategyEntity(mainStrategyName, 1L); + emsStrategyMapper.insertEmsStrategy(mainStrategy); + emsStrategyRunning.setMainStrategyId(mainStrategy.getId()); + } + // 副策略 + String auxStrategyName = insertVo.getAuxStrategyName(); + EmsStrategy auxStrategy = emsStrategyMapper.getStrategyByName(auxStrategyName); + if (auxStrategy != null) { + emsStrategyRunning.setAuxiliaryStrategyId(auxStrategy.getId()); + } else { + auxStrategy = createStrategyEntity(mainStrategyName, 2L); + emsStrategyMapper.insertEmsStrategy(auxStrategy); + emsStrategyRunning.setAuxiliaryStrategyId(auxStrategy.getId()); + } + } + + private EmsStrategy createStrategyEntity(String strategyName, Long type) { + EmsStrategy strategy = new EmsStrategy(); + strategy.setStrategyType(type); + strategy.setStrategyName(strategyName); + strategy.setStatus(StrategyStatus.RUNNING.getCode()); + strategy.setCreateTime(DateUtils.getNowDate()); + return strategy; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index ace1826..11703b6 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -3,12 +3,22 @@ package com.xzzn.ems.service.impl; import java.util.List; import java.util.Map; +import com.alibaba.fastjson2.JSON; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.enums.StrategyStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanUtils; +import com.xzzn.ems.domain.EmsStrategy; +import com.xzzn.ems.domain.EmsStrategyRunning; import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; +import com.xzzn.ems.domain.vo.StrategyRunningVo; import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; +import com.xzzn.ems.domain.vo.SyncStrategyTempVo; import com.xzzn.ems.mapper.EmsStrategyCurveMapper; +import com.xzzn.ems.mapper.EmsStrategyMapper; import com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -33,7 +43,10 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService private EmsStrategyTimeConfigMapper emsStrategyTimeConfigMapper; @Autowired private EmsStrategyCurveMapper emsStrategyCurveMapper; + @Autowired + private EmsStrategyMapper emsStrategyMapper; + private static final ObjectMapper objectMapper = new ObjectMapper(); /** * 查询模板列表 * @@ -123,4 +136,54 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService return emsStrategyTempMapper.deleteTempByTempId(templateId); } + + @Override + public void dealStrategyTempData(String content, String operateType) throws JsonProcessingException { + if (StringUtils.isEmpty(content)) { + return; + } + String siteId = ""; + EmsStrategyTemp temp = new EmsStrategyTemp(); + switch (operateType) { + case "INSERT": + SyncStrategyTempVo syncVo = JSON.parseObject(content, SyncStrategyTempVo.class); + BeanUtils.copyProperties(syncVo, temp); + // 先校验策略是否存在,不存在则插入 + dealStrategyData(temp, syncVo); + // 新增策略运行数据 + emsStrategyTempMapper.insertEmsStrategyTemp(temp); + break; + case "DELETE": + JsonNode jsonNode = objectMapper.readTree(content); + String tempId = jsonNode.get("templateId").asText(); + // 删除模版 + deleteStrategyTempById(tempId); + break; + default: + // 未知操作类型-不同步 + break; + } + } + + private void dealStrategyData(EmsStrategyTemp temp, SyncStrategyTempVo syncVo) { + // 主策略 + String mainStrategyName = syncVo.getStrategyName(); + EmsStrategy strategy = emsStrategyMapper.getStrategyByName(mainStrategyName); + if (strategy != null) { + temp.setStrategyId(strategy.getId()); + } else { + strategy = createStrategyEntity(mainStrategyName, syncVo.getStrategyType()); + emsStrategyMapper.insertEmsStrategy(strategy); + temp.setStrategyId(strategy.getId()); + } + } + + private EmsStrategy createStrategyEntity(String strategyName, Long type) { + EmsStrategy strategy = new EmsStrategy(); + strategy.setStrategyType(type); + strategy.setStrategyName(strategyName); + strategy.setStatus(StrategyStatus.RUNNING.getCode()); + strategy.setCreateTime(DateUtils.getNowDate()); + return strategy; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java index 9a6c42e..bd612d8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTimeConfigServiceImpl.java @@ -1,10 +1,17 @@ package com.xzzn.ems.service.impl; import java.util.List; + +import com.alibaba.fastjson2.JSON; +import com.xzzn.common.enums.StrategyStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; +import com.xzzn.common.utils.bean.BeanUtils; +import com.xzzn.ems.domain.EmsStrategy; import com.xzzn.ems.domain.vo.StrategyTimeConfigVo; +import com.xzzn.ems.domain.vo.SyncStrategyTimeConfigVo; import com.xzzn.ems.mapper.EmsStrategyCurveMapper; +import com.xzzn.ems.mapper.EmsStrategyMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper; @@ -24,6 +31,8 @@ public class EmsStrategyTimeConfigServiceImpl implements IEmsStrategyTimeConfigS private EmsStrategyTimeConfigMapper emsStrategyTimeConfigMapper; @Autowired private EmsStrategyCurveMapper emsStrategyCurveMapper; + @Autowired + private EmsStrategyMapper emsStrategyMapper; /** * 查询时间配置 @@ -129,4 +138,69 @@ public class EmsStrategyTimeConfigServiceImpl implements IEmsStrategyTimeConfigS { return emsStrategyTimeConfigMapper.getStrategyTimeList(emsStrategyTimeConfig); } + + @Override + public void dealStrategyTimeData(String content, String operateType) { + if (StringUtils.isEmpty(content)) { + return; + } + String siteId = ""; + EmsStrategyTimeConfig timeConfig = new EmsStrategyTimeConfig(); + SyncStrategyTimeConfigVo syncVo = JSON.parseObject(content, SyncStrategyTimeConfigVo.class); + BeanUtils.copyProperties(syncVo, timeConfig); + // 先校验策略是否存在,不存在则插入 + dealStrategyData(timeConfig, syncVo); + switch (operateType) { + case "INSERT": + // 新增策略运行数据 + emsStrategyTimeConfigMapper.insertEmsStrategyTimeConfig(timeConfig); + break; + case "UPDATE": + // 根据站点 + strategyId + 月份判断是否存在数据存在则更新否则插入 + if (checkExistConfig(timeConfig)) { + emsStrategyTimeConfigMapper.updateEmsStrategyTimeConfig(timeConfig); + } else { + timeConfig.setCreateTime(DateUtils.getNowDate()); + emsStrategyTimeConfigMapper.insertEmsStrategyTimeConfig(timeConfig); + } + break; + default: + // 未知操作类型-不同步 + break; + } + } + + private boolean checkExistConfig(EmsStrategyTimeConfig timeConfig) { + boolean result = true; + String siteId = timeConfig.getSiteId(); + Long strategyId = timeConfig.getStrategyId(); + Long month = timeConfig.getMonth(); + EmsStrategyTimeConfig emsStrategyTimeConfig = emsStrategyTimeConfigMapper.getExistTimeConfig(siteId,strategyId,month); + if (emsStrategyTimeConfig == null) { + result = false; + } + return result; + } + + private void dealStrategyData(EmsStrategyTimeConfig temp, SyncStrategyTimeConfigVo syncVo) { + // 主策略 + String mainStrategyName = syncVo.getStrategyName(); + EmsStrategy strategy = emsStrategyMapper.getStrategyByName(mainStrategyName); + if (strategy != null) { + temp.setStrategyId(strategy.getId()); + } else { + strategy = createStrategyEntity(mainStrategyName, syncVo.getStrategyType()); + emsStrategyMapper.insertEmsStrategy(strategy); + temp.setStrategyId(strategy.getId()); + } + } + + private EmsStrategy createStrategyEntity(String strategyName, Long type) { + EmsStrategy strategy = new EmsStrategy(); + strategy.setStrategyType(type); + strategy.setStrategyName(strategyName); + strategy.setStatus(StrategyStatus.RUNNING.getCode()); + strategy.setCreateTime(DateUtils.getNowDate()); + return strategy; + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyMapper.xml index 8fd9c53..b286573 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyMapper.xml @@ -89,4 +89,9 @@ and strategy_type = #{type}
+ + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index bfe9938..157f534 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -127,4 +127,11 @@ update ems_strategy_time_config set isPost = 1 where template_id = #{templateId} + + \ No newline at end of file -- 2.49.0 From 3753075b101fbaa309f34206e4b9dd949985ad60 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 17 Nov 2025 02:47:43 +0800 Subject: [PATCH 213/336] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=97=A5=E5=BF=97&?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ems/MqttMessageController.java | 61 ++++++- .../java/com/xzzn/ems/domain/MqttSyncLog.java | 15 ++ .../xzzn/ems/service/IMqttSyncLogService.java | 8 +- .../service/impl/MqttSyncLogServiceImpl.java | 172 +++++++++++++++--- .../mapper/ems/MqttSyncLogMapper.xml | 7 +- 5 files changed, 232 insertions(+), 31 deletions(-) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 006a7a6..afdaf19 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -100,8 +100,14 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { return this::handleSystemStatus; } else if (topic.contains("STRATEGY")) { return this::handleStrategyData; - } else if (topic.contains("PROTECTION_PLAN")) { + } else if (topic.equals("FAULT_PROTECTION_PLAN_UP")) { return this::handleFaultProtPlanData; + } else if (topic.equals("FAULT_ALARM_RECORD_UP")) { + return this::handleFaultAlarmData; + } else if (topic.equals("FAULT_PLAN_ISSUE_UP")) { + return this::handleFaultPlanIssueData; + } else if (topic.equals("DEVICE_CHANGE_LOG_UP")) { + return this::handleDeviceChangeLogData; } else { return this::handleDeviceData; } @@ -156,7 +162,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } - // 处理运行策略数据 + // 处理运行策略数据:云端-本地 private void handleStrategyData(String topic, MqttMessage message) { String payload = new String(message.getPayload()); System.out.println("[处理运行策略数据] data: " + payload); @@ -170,20 +176,59 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } } - // 处理设备保护告警策略数据 + // 处理设备保护告警策略数据:云端-本地 private void handleFaultProtPlanData(String topic, MqttMessage message) { String payload = new String(message.getPayload()); System.out.println("[处理设备保护告警策略数据] data: " + payload); try { // 业务处理逻辑 - MqttSyncLog planLog = JSON.parseObject(payload, MqttSyncLog.class); - if (planLog != null) { - iMqttSyncLogService.handleMqttPlanData(planLog); - } + iMqttSyncLogService.handleMqttPlanData(payload); emsMqttMessageService.insertMqttOriginalMessage(topic,payload); } catch (Exception e) { - log.error("Failed to process strategy data message: " + e.getMessage(), e); + log.error("Failed to process fault plan data message: " + e.getMessage(), e); + } + } + + // 处理保护策略告警信息:本地-云端 + private void handleFaultAlarmData(String topic, MqttMessage message) { + String payload = new String(message.getPayload()); + System.out.println("[处理本地保护策略告警信息到云端] data: " + payload); + try { + // 业务处理逻辑 + iMqttSyncLogService.handleFaultAlarmData(payload); + + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + } catch (Exception e) { + log.error("Failed to process fault plan alarm data message: " + e.getMessage(), e); + } + } + + // 处理保护策略下发日志:本地-云端 + private void handleFaultPlanIssueData(String topic, MqttMessage message) { + String payload = new String(message.getPayload()); + System.out.println("[处理本地保护策略下发日志到云端] data: " + payload); + try { + // 业务处理逻辑 + iMqttSyncLogService.handleFaultPlanIssueData(payload); + + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + } catch (Exception e) { + log.error("Failed to process fault plan issue log message: " + e.getMessage(), e); + } + } + + // 处理设备状态变更日志:本地-云端 + private void handleDeviceChangeLogData(String topic, MqttMessage message) { + String payload = new String(message.getPayload()); + System.out.println("[处理本地的保护策略告警信息到云端] data: " + payload); + try { + // 业务处理逻辑 + iMqttSyncLogService.handleDeviceChangeLogData(payload); + + emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + } catch (Exception e) { + log.error("Failed to process device change log message: " + e.getMessage(), e); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java b/ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java index cc8b5cf..a2b72aa 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/MqttSyncLog.java @@ -46,6 +46,10 @@ public class MqttSyncLog extends BaseEntity @Excel(name = "失败原因", readConverterExp = "s=tatus=FAIL时填写") private String errorMsg; + /** 同步对象 */ + @Excel(name = "同步对象") + private String syncObject; + /** 同步目标 */ @Excel(name = "同步目标") private String target; @@ -130,6 +134,16 @@ public class MqttSyncLog extends BaseEntity return errorMsg; } + public void setSyncObject(String syncObject) + { + this.syncObject = syncObject; + } + + public String getSyncObject() + { + return syncObject; + } + public void setTarget(String target) { this.target = target; @@ -151,6 +165,7 @@ public class MqttSyncLog extends BaseEntity .append("content", getContent()) .append("status", getStatus()) .append("errorMsg", getErrorMsg()) + .append("syncObject", getSyncObject()) .append("target", getTarget()) .append("createTime", getCreateTime()) .toString(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java b/ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java index b984e0f..0e1d51b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IMqttSyncLogService.java @@ -62,5 +62,11 @@ public interface IMqttSyncLogService // 处理策略信息 public void handleMqttStrategyData(String payload); // 处理设备告警保护信息 - public void handleMqttPlanData(MqttSyncLog planLog); + public void handleMqttPlanData(String payload); + // 处理设备保护策略触发的告警信息 + public void handleFaultAlarmData(String payload); + // 处理保护策略告警信息 + public void handleFaultPlanIssueData(String payload); + // 处理设备运行状态变更 + public void handleDeviceChangeLogData(String payload); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java index 8797e9e..42401b0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/MqttSyncLogServiceImpl.java @@ -5,13 +5,13 @@ import java.util.List; import com.alibaba.fastjson2.JSON; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.service.IEmsFaultProtectionPlanService; -import com.xzzn.ems.service.IEmsStrategyService; +import com.xzzn.ems.domain.EmsSiteSetting; +import com.xzzn.ems.mapper.EmsSiteSettingMapper; +import com.xzzn.ems.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.xzzn.ems.mapper.MqttSyncLogMapper; import com.xzzn.ems.domain.MqttSyncLog; -import com.xzzn.ems.service.IMqttSyncLogService; /** * MQTT云上本地同步日志Service业务层处理 @@ -28,6 +28,18 @@ public class MqttSyncLogServiceImpl implements IMqttSyncLogService private IEmsFaultProtectionPlanService emsFaultProtectionPlanService; @Autowired private IEmsStrategyService emsStrategyService; + @Autowired + private IEmsAlarmRecordsService emsAlarmRecordsService; + @Autowired + private EmsSiteSettingMapper emsSiteSettingMapper; + @Autowired + private IEmsFaultIssueLogService emsFaultIssueLogService; + @Autowired + private IEmsDeviceChangeLogService emsDeviceChangeLogService; + @Autowired + private IEmsStrategyTempService emsStrategyTempService; + @Autowired + private IEmsStrategyTimeConfigService emsStrategyTimeConfigService; /** * 查询MQTT云上本地同步日志 @@ -102,12 +114,103 @@ public class MqttSyncLogServiceImpl implements IMqttSyncLogService return mqttSyncLogMapper.deleteMqttSyncLogById(id); } + // 校验同步目标是否该站点 + private boolean checkIsSite(String target) { + if (StringUtils.isEmpty(target)) { + return false; + } + EmsSiteSetting emsSiteSetting = emsSiteSettingMapper.selectEmsSiteSettingBySiteId(target); + if (emsSiteSetting == null) { + return false; + } + return true; + } + /** * 处理云上运行策略数据 + * 云上-本地:校验是否该站点 * @param payload */ @Override public void handleMqttStrategyData(String payload) { + MqttSyncLog syncLog = JSON.parseObject(payload, MqttSyncLog.class); + if (syncLog != null) { + // 校验是否该站点数据 + if (!checkIsSite(syncLog.getTarget())) { + return; + } + // 校验是否存在 + String syncId = syncLog.getSyncId(); + MqttSyncLog existLog = mqttSyncLogMapper.selectMqttSyncLogBySyncId(syncId); + if (existLog == null) { + try { + // 根据不同操作更新 + String operateType = syncLog.getOperateType(); + if (!StringUtils.isEmpty(operateType)) { + // 不同表操作 + String tableName = syncLog.getTableName(); + switch (tableName) { + case "ems_strategy_running": + emsStrategyService.dealStrategyRunningData(syncLog.getContent(), operateType); + break; + case "ems_strategy_temp": + emsStrategyTempService.dealStrategyTempData(syncLog.getContent(), operateType); + break; + case "ems_strategy_time_config": + emsStrategyTimeConfigService.dealStrategyTimeData(syncLog.getContent(), operateType); + break; + default: + break; + } + } + } catch (Exception e) { + syncLog.setStatus("FAIL"); + syncLog.setErrorMsg(e.getMessage()); + } + // 保存日志 + insertMqttSyncLog(syncLog); + } + } + } + + /** + * 处理云上同步的告警保护信息 + * 云上-本地:校验是否该站点 + * @param payload + */ + @Override + public void handleMqttPlanData(String payload) { + MqttSyncLog planLog = JSON.parseObject(payload, MqttSyncLog.class); + if (planLog != null) { + // 校验是否该站点数据 + if (!checkIsSite(planLog.getTarget())) { + return; + } + + // 校验是否存在 + String syncId = planLog.getSyncId(); + MqttSyncLog existLog = mqttSyncLogMapper.selectMqttSyncLogBySyncId(syncId); + if (existLog == null) { + // 处理数据 + String operateType = planLog.getOperateType(); + if (!StringUtils.isEmpty(operateType)) { + emsFaultProtectionPlanService.dealSyncData(planLog.getContent(), operateType); + } + + // 保存日志 + insertMqttSyncLog(planLog); + } + } + + } + + /** + * 处理设备保护策略触发的告警信息 + * 本地-云上 + * @param payload + */ + @Override + public void handleFaultAlarmData(String payload) { MqttSyncLog syncLog = JSON.parseObject(payload, MqttSyncLog.class); if (syncLog != null) { // 校验是否存在 @@ -117,34 +220,61 @@ public class MqttSyncLogServiceImpl implements IMqttSyncLogService // 根据不同操作更新 String operateType = syncLog.getOperateType(); if (!StringUtils.isEmpty(operateType)) { - emsStrategyService.dealStrategyData(syncLog.getContent(),operateType); + emsAlarmRecordsService.dealSyncData(syncLog.getContent(),operateType); } + + // 保存日志 + insertMqttSyncLog(syncLog); } - // 保存日志 - insertMqttSyncLog(syncLog); } } /** - * 处理云上同步的告警保护信息 - * @param planLog + * 处理保护策略告警信息 + * 本地-云上 + * @param payload */ @Override - public void handleMqttPlanData(MqttSyncLog planLog) { - // 校验是否存在 - String syncId = planLog.getSyncId(); - MqttSyncLog existLog = mqttSyncLogMapper.selectMqttSyncLogBySyncId(syncId); - if (existLog != null) { - return; - } - // 保存日志 - insertMqttSyncLog(planLog); + public void handleFaultPlanIssueData(String payload) { + MqttSyncLog syncLog = JSON.parseObject(payload, MqttSyncLog.class); + if (syncLog != null) { + // 校验是否存在 + String syncId = syncLog.getSyncId(); + MqttSyncLog existLog = mqttSyncLogMapper.selectMqttSyncLogBySyncId(syncId); + if (existLog == null) { + // 根据不同操作更新 + String operateType = syncLog.getOperateType(); + if (!StringUtils.isEmpty(operateType)) { + emsFaultIssueLogService.dealSyncData(syncLog.getContent(),operateType); + } - // 处理数据 - String operateType = planLog.getOperateType(); - if (!StringUtils.isEmpty(operateType)) { - emsFaultProtectionPlanService.dealSyncData(planLog.getContent(),operateType); + // 保存日志 + insertMqttSyncLog(syncLog); + } } + } + /** + * 处理设备运行状态变更日志 + * 本地-云上 + * @param payload + */ + @Override + public void handleDeviceChangeLogData(String payload) { + MqttSyncLog syncLog = JSON.parseObject(payload, MqttSyncLog.class); + if (syncLog == null) { + // 校验是否存在 + String syncId = syncLog.getSyncId(); + MqttSyncLog existLog = mqttSyncLogMapper.selectMqttSyncLogBySyncId(syncId); + if (existLog == null) { + // 根据不同操作更新 + String operateType = syncLog.getOperateType(); + if (!StringUtils.isEmpty(operateType)) { + emsDeviceChangeLogService.dealSyncData(syncLog.getContent(),operateType); + } + // 保存日志 + insertMqttSyncLog(syncLog); + } + } } } diff --git a/ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml b/ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml index 1a1a2f1..01a0bd6 100644 --- a/ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/MqttSyncLogMapper.xml @@ -13,12 +13,13 @@ + - select id, sync_id, topic, operate_type, table_name, content, status, error_msg, target, create_time from mqtt_sync_log + select id, sync_id, topic, operate_type, table_name, content, status, error_msg, sync_object, target, create_time from mqtt_sync_log @@ -50,6 +52,7 @@ content, status, error_msg, + sync_object, target, create_time, @@ -61,6 +64,7 @@ #{content}, #{status}, #{errorMsg}, + #{syncObject}, #{target}, #{createTime}, @@ -76,6 +80,7 @@ content = #{content}, status = #{status}, error_msg = #{errorMsg}, + sync_object = #{syncObject}, target = #{target}, create_time = #{createTime}, -- 2.49.0 From 1cc7d5355982c119b301b506c0fe5b2a36bcdfd7 Mon Sep 17 00:00:00 2001 From: mashili Date: Mon, 17 Nov 2025 12:15:07 +0800 Subject: [PATCH 214/336] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/utils/MapUtils.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 ems-common/src/main/java/com/xzzn/common/utils/MapUtils.java diff --git a/ems-common/src/main/java/com/xzzn/common/utils/MapUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/MapUtils.java new file mode 100644 index 0000000..cb1fc03 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/utils/MapUtils.java @@ -0,0 +1,44 @@ +package com.xzzn.common.utils; + +import java.util.Map; + +public class MapUtils { + /** + * 从Map中获取值并转为Integer(适配tinyint字段) + * @param map 数据源Map + * @param key 字段名 + * @return 转换后的Integer,默认返回0(可根据业务调整默认值) + */ + public static Integer getInteger(Map map, String key) { + // 1. 处理Map为null或key不存在的情况 + if (map == null || !map.containsKey(key)) { + return 0; + } + // 2. 获取原始值 + Object value = map.get(key); + if (value == null) { + return 0; + } + // 3. 转换为Integer(处理常见类型) + if (value instanceof Integer) { + return (Integer) value; + } else if (value instanceof Long) { + // 若Map中存的是Long(如JSON解析时数字默认转为Long) + return ((Long) value).intValue(); + } else if (value instanceof String) { + // 若值是字符串类型(如"1") + try { + return Integer.parseInt((String) value); + } catch (NumberFormatException e) { + // 字符串无法转数字,返回默认值 + return 0; + } + } else if (value instanceof Boolean) { + // 特殊情况:布尔值转整数(true→1,false→0) + return (Boolean) value ? 1 : 0; + } else { + // 其他不支持的类型,返回默认值 + return 0; + } + } +} \ No newline at end of file -- 2.49.0 From 36f08e5f06a116ee9c266324c6c685ad17a15ee3 Mon Sep 17 00:00:00 2001 From: mashili Date: Wed, 19 Nov 2025 10:05:51 +0800 Subject: [PATCH 215/336] =?UTF-8?q?=E6=BC=8F=E6=8F=90=E4=BA=A4-=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/common/annotation/SyncAfterInsert.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ems-common/src/main/java/com/xzzn/common/annotation/SyncAfterInsert.java diff --git a/ems-common/src/main/java/com/xzzn/common/annotation/SyncAfterInsert.java b/ems-common/src/main/java/com/xzzn/common/annotation/SyncAfterInsert.java new file mode 100644 index 0000000..49b6d85 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/annotation/SyncAfterInsert.java @@ -0,0 +1,11 @@ +package com.xzzn.common.annotation; + +import java.lang.annotation.*; + +/** + * 标记:调用insert后需要同步数据到其他服务器 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface SyncAfterInsert { +} \ No newline at end of file -- 2.49.0 From 55d648d12c135da772d7110ab1b81cf1b9f122a5 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Wed, 19 Nov 2025 13:28:09 +0800 Subject: [PATCH 216/336] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/pom.xml | 5 +- .../src/main/resources/application-local.yml | 205 ++++++++++++++++++ 2 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 ems-admin/src/main/resources/application-local.yml diff --git a/ems-admin/pom.xml b/ems-admin/pom.xml index ed00efc..33dacfd 100644 --- a/ems-admin/pom.xml +++ b/ems-admin/pom.xml @@ -39,8 +39,9 @@ - mysql - mysql-connector-java + com.mysql + mysql-connector-j + 8.0.33 diff --git a/ems-admin/src/main/resources/application-local.yml b/ems-admin/src/main/resources/application-local.yml new file mode 100644 index 0000000..ac9c414 --- /dev/null +++ b/ems-admin/src/main/resources/application-local.yml @@ -0,0 +1,205 @@ +# 项目相关配置 +xzzn: + # 名称 + name: EMS + # 版本 + version: 0.0.1 + # 版权年份 + copyrightYear: 2025 + # 文件路径 示例( Windows配置D:/xzzn/uploadPath,Linux配置 /home/xzzn/uploadPath) + profile: ../uploadPath + # 获取ip地址开关 + addressEnabled: false + # 验证码类型 math 数字计算 char 字符验证 + captchaType: math + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为8080 + port: 8089 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + +# 日志配置 +logging: + level: + com.xzzn: info + org.springframework: warn + +# 用户配置 +user: + password: + # 密码最大错误次数 + maxRetryCount: 5 + # 密码锁定时间(默认10分钟) + lockTime: 10 + +# Spring配置 +spring: + # 资源信息 + messages: + # 国际化资源文件路径 + basename: i18n/messages + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: true + # redis 配置 + redis: + # 地址 + host: 127.0.0.1 + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + password: 12345678 + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms + # 数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://127.0.0.1:3306/setri_ems?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: ems + password: Aa112211! + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: xzzn + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + +# token配置 +token: + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklmnopqrstuvwxyz + # 令牌有效期(默认30分钟) + expireTime: 30 + +# MyBatis配置 +mybatis: + # 搜索指定包别名 + typeAliasesPackage: com.xzzn.**.domain + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 + configLocation: classpath:mybatis/mybatis-config.xml + +# PageHelper分页插件 +pagehelper: + helperDialect: mysql + supportMethodsArguments: true + params: count=countSql + +# Swagger配置 +swagger: + # 是否开启swagger + enabled: true + # 请求前缀 + pathMapping: /dev-api + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* + +mqtt: + broker.url: tcp://121.5.164.6:1883 + client.id: ems-cloud + username: dmbroker + password: qwer1234 + connection-timeout: 15 + keep-alive-interval: 30 + automatic-reconnect: true + +modbus: + pool: + max-total: 20 + max-idle: 10 + min-idle: 3 + poll: + interval: "0 */5 * * * *" # 5分钟间隔 + timeout: 30000 # 30秒超时 -- 2.49.0 From 7298acc7859824edbe452a3e496868292737d47a Mon Sep 17 00:00:00 2001 From: dashixiong Date: Wed, 19 Nov 2025 14:05:40 +0800 Subject: [PATCH 217/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/logback.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-admin/src/main/resources/logback.xml b/ems-admin/src/main/resources/logback.xml index 8f26067..45e383b 100644 --- a/ems-admin/src/main/resources/logback.xml +++ b/ems-admin/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + -- 2.49.0 From a5e977c0d1025b6a2cf47a1d2cea6202041b583f Mon Sep 17 00:00:00 2001 From: gaojinming Date: Tue, 25 Nov 2025 14:23:26 +0800 Subject: [PATCH 218/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E8=AE=BE=E5=A4=87=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E8=BF=90=E8=A1=8C=E9=A1=B5=E9=9D=A2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=9B=BE=E6=8C=89=E7=85=A7=E5=B0=8F=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E5=85=B1=E7=94=A8=E6=97=B6=E9=97=B4=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=97=B6=E9=97=B4=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 17 +- .../xzzn/ems/domain/vo/BatteryAveSOCVo.java | 13 ++ .../xzzn/ems/domain/vo/BatteryAveTempVo.java | 13 ++ .../ems/domain/vo/EnergyStoragePowVo.java | 13 ++ .../com/xzzn/ems/domain/vo/PcsMaxTempVo.java | 14 ++ .../ems/domain/vo/RunningGraphRequest.java | 45 +++++ .../xzzn/ems/service/ISingleSiteService.java | 8 +- .../service/impl/SingleSiteServiceImpl.java | 167 ++++++++++-------- .../mapper/ems/EmsBatteryClusterMapper.xml | 7 +- .../mapper/ems/EmsBatteryStackMapper.xml | 14 +- .../resources/mapper/ems/EmsPcsDataMapper.xml | 33 ++-- 11 files changed, 232 insertions(+), 112 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/RunningGraphRequest.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 3134973..785206a 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -7,6 +7,7 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.vo.BMSBatteryDataList; import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; import com.xzzn.ems.domain.vo.DateSearchRequest; +import com.xzzn.ems.domain.vo.RunningGraphRequest; import com.xzzn.ems.domain.vo.SiteBatteryDataList; import com.xzzn.ems.service.IEmsSiteService; import com.xzzn.ems.service.IEmsStatsReportService; @@ -55,27 +56,27 @@ public class EmsSiteMonitorController extends BaseController{ * 单站监控-设备监控-实时运行曲线图数据 */ @GetMapping("/runningGraph/storagePower") - public AjaxResult getRunningGraphStorage(@RequestParam String siteId) + public AjaxResult getRunningGraphStorage(RunningGraphRequest request) { - return success(iSingleSiteService.getRunningGraphStorage(siteId)); + return success(iSingleSiteService.getRunningGraphStorage(request)); } @GetMapping("/runningGraph/pcsMaxTemp") - public AjaxResult getRunningGraphPcsMaxTemp(@RequestParam String siteId) + public AjaxResult getRunningGraphPcsMaxTemp(RunningGraphRequest request) { - return success(iSingleSiteService.getRunningGraphPcsMaxTemp(siteId)); + return success(iSingleSiteService.getRunningGraphPcsMaxTemp(request)); } @GetMapping("/runningGraph/batteryAveSoc") - public AjaxResult getRunningGraphBatterySoc(@RequestParam String siteId) + public AjaxResult getRunningGraphBatterySoc(RunningGraphRequest request) { - return success(iSingleSiteService.getRunningGraphBatterySoc(siteId)); + return success(iSingleSiteService.getRunningGraphBatterySoc(request)); } @GetMapping("/runningGraph/batteryAveTemp") - public AjaxResult getRunningGraphBatteryTemp(@RequestParam String siteId) + public AjaxResult getRunningGraphBatteryTemp(RunningGraphRequest request) { - return success(iSingleSiteService.getRunningGraphBatteryTemp(siteId)); + return success(iSingleSiteService.getRunningGraphBatteryTemp(request)); } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java index d85a12c..9d60a7c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveSOCVo.java @@ -8,6 +8,11 @@ import java.util.Date; * */ public class BatteryAveSOCVo { + /** + * 游标显示日期 + */ + private String dateDay; + /** * 数据时间 */ @@ -33,4 +38,12 @@ public class BatteryAveSOCVo { public void setBatterySOC(BigDecimal batterySOC) { this.batterySOC = batterySOC; } + + public String getDateDay() { + return dateDay; + } + + public void setDateDay(String dateDay) { + this.dateDay = dateDay; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java index b79e0de..9e5736e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BatteryAveTempVo.java @@ -8,6 +8,11 @@ import java.util.Date; * */ public class BatteryAveTempVo { + /** + * 游标显示日期 + */ + private String dateDay; + /** * 数据时间 */ @@ -33,4 +38,12 @@ public class BatteryAveTempVo { public void setBatteryTemp(BigDecimal batteryTemp) { this.batteryTemp = batteryTemp; } + + public String getDateDay() { + return dateDay; + } + + public void setDateDay(String dateDay) { + this.dateDay = dateDay; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java index 713c34d..0512662 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java @@ -8,6 +8,11 @@ import java.util.Date; * */ public class EnergyStoragePowVo { + /** + * 游标显示日期 + */ + private String dateDay; + /** * 显示日期 */ @@ -54,6 +59,14 @@ public class EnergyStoragePowVo { return pcsTotalReactivePower; } + public String getDateDay() { + return dateDay; + } + + public void setDateDay(String dateDay) { + this.dateDay = dateDay; + } + public void setPcsTotalReactivePower(BigDecimal pcsTotalReactivePower) { this.pcsTotalReactivePower = pcsTotalReactivePower; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempVo.java index 04d6978..a336e51 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PcsMaxTempVo.java @@ -7,6 +7,12 @@ import java.math.BigDecimal; * */ public class PcsMaxTempVo { + + /** + * 游标显示日期 + */ + private String dateDay; + /** * 数据时间 */ @@ -42,4 +48,12 @@ public class PcsMaxTempVo { public void setTemp(BigDecimal temp) { this.temp = temp; } + + public String getDateDay() { + return dateDay; + } + + public void setDateDay(String dateDay) { + this.dateDay = dateDay; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/RunningGraphRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/RunningGraphRequest.java new file mode 100644 index 0000000..a144147 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/RunningGraphRequest.java @@ -0,0 +1,45 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +/** + * 实时运行曲线图请求参数 + */ +public class RunningGraphRequest { + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date startDate; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date endDate; + + private String siteId; + + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index fa88d06..0faff27 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -17,7 +17,7 @@ public interface ISingleSiteService public SiteMonitorRunningHeadInfoVo getSiteRunningHeadInfo(String siteId); - public SiteMonitorRuningInfoVo getRunningGraphStorage(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphStorage(RunningGraphRequest request); public List getPcsDetailInfo(String siteId); @@ -32,11 +32,11 @@ public interface ISingleSiteService public List getAmmeterDataList(String siteId); - public SiteMonitorRuningInfoVo getRunningGraphPcsMaxTemp(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphPcsMaxTemp(RunningGraphRequest request); - public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(RunningGraphRequest request); - public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(RunningGraphRequest request); public List getClusterBatteryList(String siteId, String stackDeviceId, String clusterDeviceId); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 6f09eeb..8d01440 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -165,46 +165,50 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取单站监控实时运行-PCS有功无功功率 @Override - public SiteMonitorRuningInfoVo getRunningGraphStorage(String siteId) { + public SiteMonitorRuningInfoVo getRunningGraphStorage(RunningGraphRequest request) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); - if (!StringUtils.isEmpty(siteId)) { - // 时间暂定今日+昨日 - Date today = DateUtils.getNowDate(); - Date yesterday = DateUtils.addDays(today, -1); - - //pcs有功无功 - List pcsPowerList = new ArrayList<>(); - List energyStoragePowList = emsPcsDataMapper.getStoragePowerList(siteId, yesterday, today); - - // List -> 按pcs的deviceId分组转成List - if (!CollectionUtils.isEmpty(energyStoragePowList)) { - Map> dataMap = energyStoragePowList.stream() - .collect(Collectors.groupingBy( - EnergyStoragePowVo::getDeviceId, - Collectors.toList())); - - pcsPowerList = dataMap.entrySet().stream() - .map(entry -> { - PcsPowerList pcdData = new PcsPowerList(); - pcdData.setDeviceId(entry.getKey()); - pcdData.setEnergyStoragePowList(entry.getValue()); - return pcdData; - }).collect(Collectors.toList()); - - // 生成时间列表(每分钟一个) - List targetMinutes = new ArrayList<>(60); - LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); - LocalDateTime endDate = DateUtils.toLocalDateTime(today); - while (startDate.isBefore(endDate)) { - targetMinutes.add(startDate); - startDate = startDate.plusMinutes(1); // 递增1分钟 - } - // 根据时间列表填充数据 - pcsPowerList = fullFillData(pcsPowerList,targetMinutes); - } - - siteMonitorRuningInfoVo.setPcsPowerList(pcsPowerList); + if (Objects.isNull(request) || StringUtils.isEmpty(request.getSiteId())) { + return siteMonitorRuningInfoVo; } +// // 时间暂定今日+昨日 +// Date today = DateUtils.getNowDate(); +// Date yesterday = DateUtils.addDays(today, -1); + Date startDate = request.getStartDate(); + Date endDate = request.getEndDate(); + + //pcs有功无功 + List pcsPowerList = new ArrayList<>(); + List energyStoragePowList = emsPcsDataMapper.getStoragePowerList(request.getSiteId(), startDate, endDate); + + // List -> 按pcs的deviceId分组转成List + if (!CollectionUtils.isEmpty(energyStoragePowList)) { + Map> dataMap = energyStoragePowList.stream() + .collect(Collectors.groupingBy( + EnergyStoragePowVo::getDeviceId, + Collectors.toList())); + + pcsPowerList = dataMap.entrySet().stream() + .map(entry -> { + PcsPowerList pcdData = new PcsPowerList(); + pcdData.setDeviceId(entry.getKey()); + pcdData.setEnergyStoragePowList(entry.getValue()); + return pcdData; + }).collect(Collectors.toList()); + +// // 生成时间列表(每分钟一个) +// List targetMinutes = new ArrayList<>(60); +// LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); +// LocalDateTime endDate = DateUtils.toLocalDateTime(today); +// while (startDate.isBefore(endDate)) { +// targetMinutes.add(startDate); +// startDate = startDate.plusMinutes(1); // 递增1分钟 +// } +// // 根据时间列表填充数据 +// pcsPowerList = fullFillData(pcsPowerList, targetMinutes); + } + + siteMonitorRuningInfoVo.setPcsPowerList(pcsPowerList); + return siteMonitorRuningInfoVo; } private List fullFillData(List pcsPowerList, List targetMinutes) { @@ -259,18 +263,21 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取单站监控实时运行-pcs最高温度 @Override - public SiteMonitorRuningInfoVo getRunningGraphPcsMaxTemp(String siteId) { + public SiteMonitorRuningInfoVo getRunningGraphPcsMaxTemp(RunningGraphRequest request) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); List pcsMaxTempList = new ArrayList<>(); - // 时间暂定今日+昨日 - Date today = new Date(); - Date yesterday = DateUtils.addDays(today, -1); +// // 时间暂定今日+昨日 +// Date today = new Date(); +// Date yesterday = DateUtils.addDays(today, -1); + String siteId = request.getSiteId(); + Date startDate = request.getStartDate(); + Date endDate = request.getEndDate(); //PCS最高温度list List pcsMaxTempVos = new ArrayList<>(); if (SiteEnum.FX.getCode().equals(siteId)) { - pcsMaxTempVos = emsPcsDataMapper.getFXMaxTemp(siteId, yesterday, today); + pcsMaxTempVos = emsPcsDataMapper.getFXMaxTemp(siteId, startDate, endDate); } else if (SiteEnum.DDS.getCode().equals(siteId)) { - pcsMaxTempVos = emsPcsDataMapper.getDDSMaxTemp(siteId, yesterday, today); + pcsMaxTempVos = emsPcsDataMapper.getDDSMaxTemp(siteId, startDate, endDate); } // List -> 按pcs的deviceId分组转成List @@ -288,16 +295,16 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return pcdData; }).collect(Collectors.toList()); - // 生成时间列表(每小时一个) - List targetHours = new ArrayList<>(60); - LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); - LocalDateTime endDate = DateUtils.toLocalDateTime(today); - while (startDate.isBefore(endDate)) { - targetHours.add(startDate); - startDate = startDate.plusHours(1); // 递增1小时 - } - // 根据时间列表填充数据 - pcsMaxTempList = fullFillMaxTempData(pcsMaxTempList,targetHours); +// // 生成时间列表(每小时一个) +// List targetHours = new ArrayList<>(60); +// LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); +// LocalDateTime endDate = DateUtils.toLocalDateTime(today); +// while (startDate.isBefore(endDate)) { +// targetHours.add(startDate); +// startDate = startDate.plusHours(1); // 递增1小时 +// } +// // 根据时间列表填充数据 +// pcsMaxTempList = fullFillMaxTempData(pcsMaxTempList,targetHours); } siteMonitorRuningInfoVo.setPcsMaxTempList(pcsMaxTempList); @@ -355,35 +362,49 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 获取单站监控实时运行-平均soc @Override - public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(String siteId) { + public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(RunningGraphRequest request) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); - if (!StringUtils.isEmpty(siteId)) { - // 时间暂定今日+昨日 - Date today = new Date(); - Date yesterday = DateUtils.addDays(today, -1); + if (!StringUtils.isEmpty(request.getSiteId())) { +// // 时间暂定今日+昨日 +// Date today = new Date(); +// Date yesterday = DateUtils.addDays(today, -1); //电池平均soclist - List batteryAveSOCList = emsBatteryStackMapper.getAveSocList(siteId, yesterday, today); + List batteryAveSOCList = emsBatteryStackMapper.getAveSocList(request.getSiteId(), request.getStartDate(), request.getEndDate()); siteMonitorRuningInfoVo.setBatteryAveSOCList(batteryAveSOCList); } return siteMonitorRuningInfoVo; } // 获取单站监控实时运行-电池平均温度 @Override - public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(String siteId) { + public SiteMonitorRuningInfoVo getRunningGraphBatteryTemp(RunningGraphRequest request) { SiteMonitorRuningInfoVo siteMonitorRuningInfoVo = new SiteMonitorRuningInfoVo(); - if (!StringUtils.isEmpty(siteId)) { - // 时间暂定今日+昨日 - Date today = new Date(); - Date yesterday = DateUtils.addDays(today, -1); - //电池平均温度list - List batteryAveTempList = new ArrayList<>(); - if (SiteEnum.FX.getCode().equals(siteId)) { - batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, yesterday, today); - } else if (SiteEnum.DDS.getCode().equals(siteId)) { - batteryAveTempList = emsBatteryStackMapper.getBatteryAveTempList(siteId, yesterday, today); - } - siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); + if (Objects.isNull(request) || StringUtils.isEmpty(request.getSiteId())) { + return siteMonitorRuningInfoVo; } + String siteId = request.getSiteId(); + Date startDate = request.getStartDate(); + Date endDate = request.getEndDate(); + //电池平均温度list + List batteryAveTempList = new ArrayList<>(); + if (SiteEnum.FX.getCode().equals(siteId)) { + batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, startDate, endDate); + } else if (SiteEnum.DDS.getCode().equals(siteId)) { + batteryAveTempList = emsBatteryStackMapper.getBatteryAveTempList(siteId, startDate, endDate); + } + siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); +// if (!StringUtils.isEmpty(siteId)) { +// // 时间暂定今日+昨日 +// Date today = new Date(); +// Date yesterday = DateUtils.addDays(today, -1); +// //电池平均温度list +// List batteryAveTempList = new ArrayList<>(); +// if (SiteEnum.FX.getCode().equals(siteId)) { +// batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, yesterday, today); +// } else if (SiteEnum.DDS.getCode().equals(siteId)) { +// batteryAveTempList = emsBatteryStackMapper.getBatteryAveTempList(siteId, yesterday, today); +// } +// siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); +// } return siteMonitorRuningInfoVo; } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 0c693ce..90a8074 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -327,13 +327,12 @@ diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 0e3e080..58171c9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -347,13 +347,12 @@ @@ -495,13 +494,12 @@ diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 302d1a0..6359898 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -461,13 +461,14 @@ SELECT t.site_id,t.device_id as deviceId, t.total_active_power AS pcsTotalActPower, t.total_reactive_power AS pcsTotalReactivePower, - DATE_FORMAT(t.data_update_time, '%Y-%m-%d %H:%i:00') AS createDate + DATE_FORMAT(t.create_time, '%Y-%m-%d') AS dateDay, + DATE_FORMAT(t.data_update_time, '%H:%i:00') AS createDate FROM ems_pcs_data t WHERE t.site_id = #{siteId} - AND t.data_update_time >= Date(#{startDate}) - AND t.data_update_time <= #{endDate} - GROUP BY t.site_id, deviceId,pcsTotalActPower,pcsTotalReactivePower,createDate - ORDER BY createDate + AND Date(t.data_update_time) between #{startDate} and #{endDate} + AND minute(t.data_update_time) = 0 + GROUP BY t.site_id, deviceId,pcsTotalActPower,pcsTotalReactivePower,dateDay,createDate + ORDER BY dateDay,createDate \ No newline at end of file -- 2.49.0 From e87abc28076aadb04257fbd9b18c9fba4ea2c000 Mon Sep 17 00:00:00 2001 From: gaojinming Date: Wed, 26 Nov 2025 19:07:38 +0800 Subject: [PATCH 219/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E8=AE=BE=E5=A4=87=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E7=B1=BB=E5=88=AB=E6=96=B0=E5=A2=9E=E5=8A=A8=E7=8E=AF=E3=80=81?= =?UTF-8?q?=E6=B6=88=E9=98=B2=E8=AE=BE=E5=A4=87=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteMonitorController.java | 18 +++ .../java/com/xzzn/ems/domain/vo/DhDataVo.java | 55 ++++++++++ .../java/com/xzzn/ems/domain/vo/XfDataVo.java | 103 ++++++++++++++++++ .../xzzn/ems/service/ISingleSiteService.java | 5 +- .../service/impl/SingleSiteServiceImpl.java | 52 ++++++++- 5 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/DhDataVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/XfDataVo.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java index 785206a..bfbb189 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsSiteMonitorController.java @@ -187,6 +187,24 @@ public class EmsSiteMonitorController extends BaseController{ return success(iSingleSiteService.getAmmeterDataList(siteId)); } + /** + * 动环数据 + */ + @GetMapping("/getDhDataList") + public AjaxResult getDhDataList(@RequestParam String siteId) + { + return success(iSingleSiteService.getDhDataList(siteId)); + } + + /** + * 消防数据 + */ + @GetMapping("/getXfDataList") + public AjaxResult getXfDataList(@RequestParam String siteId) + { + return success(iSingleSiteService.getXfDataList(siteId)); + } + /** * 单站监控-首页-点位展示 * 储能功率、电网功率、负荷功率、光伏功率 diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DhDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DhDataVo.java new file mode 100644 index 0000000..d42c8af --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DhDataVo.java @@ -0,0 +1,55 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +import java.math.BigDecimal; + +/** + * 动环数据 + */ +public class DhDataVo { + + /** 设备唯一标识符 */ + private String deviceId; + + /** 动环名称 */ + private String deviceName; + + /** 湿度 */ + private BigDecimal humidity; + + /** 温度 */ + private BigDecimal temperature; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public BigDecimal getHumidity() { + return humidity; + } + + public void setHumidity(BigDecimal humidity) { + this.humidity = humidity; + } + + public BigDecimal getTemperature() { + return temperature; + } + + public void setTemperature(BigDecimal temperature) { + this.temperature = temperature; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/XfDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/XfDataVo.java new file mode 100644 index 0000000..f80acf5 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/XfDataVo.java @@ -0,0 +1,103 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xzzn.common.annotation.Excel; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 消防数据 + */ +public class XfDataVo { + + /** 设备唯一标识符 */ + private String deviceId; + + /** 消防名称 */ + private String deviceName; + + /** 通信状态 */ + private String emsCommunicationStatus; + + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date dataUpdateTime; + + /** 主电源备用电池状态 */ + private BigDecimal dczt; + + /** 手自动状态延时状态 */ + private BigDecimal yszt; + + /** 启动喷洒气体喷洒状态 */ + private BigDecimal pszt; + + /** 压力开关状态电磁阀状态 */ + private BigDecimal dcfzt; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + + public String getEmsCommunicationStatus() { + return emsCommunicationStatus; + } + + public void setEmsCommunicationStatus(String emsCommunicationStatus) { + this.emsCommunicationStatus = emsCommunicationStatus; + } + + public Date getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(Date dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + + public BigDecimal getDczt() { + return dczt; + } + + public void setDczt(BigDecimal dczt) { + this.dczt = dczt; + } + + public BigDecimal getYszt() { + return yszt; + } + + public void setYszt(BigDecimal yszt) { + this.yszt = yszt; + } + + public BigDecimal getPszt() { + return pszt; + } + + public void setPszt(BigDecimal pszt) { + this.pszt = pszt; + } + + public BigDecimal getDcfzt() { + return dcfzt; + } + + public void setDcfzt(BigDecimal dcfzt) { + this.dcfzt = dcfzt; + } + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java index 0faff27..9b82eab 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/ISingleSiteService.java @@ -1,6 +1,5 @@ package com.xzzn.ems.service; -import com.xzzn.ems.domain.EmsCoolingData; import com.xzzn.ems.domain.vo.*; import java.util.List; @@ -32,6 +31,10 @@ public interface ISingleSiteService public List getAmmeterDataList(String siteId); + List getDhDataList(String siteId); + + List getXfDataList(String siteId); + public SiteMonitorRuningInfoVo getRunningGraphPcsMaxTemp(RunningGraphRequest request); public SiteMonitorRuningInfoVo getRunningGraphBatterySoc(RunningGraphRequest request); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 8d01440..a8a55ca 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -22,7 +22,6 @@ import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; @@ -749,6 +748,57 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } + /** + * 获取动环设备参数 + * @param siteId + * @return + */ + @Override + public List getDhDataList(String siteId) { + List emsDhDataList = new ArrayList<>(); + + List> dhDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.DH.getCode()); + for (Map dhDevice : dhDeviceList) { + DhDataVo dhDataVo = new DhDataVo(); + dhDataVo.setDeviceName(dhDevice.get("deviceName").toString()); + // 从redis取堆单个详细数据 + String dhDeviceId = dhDevice.get("id").toString(); + EmsDhData dhData = redisCache.getCacheObject(RedisKeyConstants.DH + siteId + "_" + dhDeviceId); + if (dhData != null) { + BeanUtils.copyProperties(dhData, dhDataVo); + } + + emsDhDataList.add(dhDataVo); + } + return emsDhDataList; + } + + /** + * 获取消防设备参数 + * @param siteId + * @return + */ + @Override + public List getXfDataList(String siteId) { + List emsXfDataList = new ArrayList<>(); + + List> xfDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.XF.getCode()); + for (Map xfDevice : xfDeviceList) { + XfDataVo xfDataVo = new XfDataVo(); + xfDataVo.setDeviceName(xfDevice.get("deviceName").toString()); + // 从redis取堆单个详细数据 + String xfDeviceId = xfDevice.get("id").toString(); + EmsXfData xfData = redisCache.getCacheObject(RedisKeyConstants.XF + siteId + "_" + xfDeviceId); + if (xfData != null) { + BeanUtils.copyProperties(xfData, xfDataVo); + xfDataVo.setDataUpdateTime(xfData.getDataTimestamp()); + } + xfDataVo.setEmsCommunicationStatus(xfDevice.get("communicationStatus") == null ? "" : xfDevice.get("communicationStatus").toString()); + emsXfDataList.add(xfDataVo); + } + return emsXfDataList; + } + /** * 单站监控-首页-获取重点数据 * @param requestVo -- 2.49.0 From d9c0ff733a79f25bb850ddbf2acecaaaccc78a1e Mon Sep 17 00:00:00 2001 From: gaojinming Date: Fri, 28 Nov 2025 11:58:45 +0800 Subject: [PATCH 220/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E6=B8=85=E5=8D=95=E4=B8=8A=E4=BC=A0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsPointMatchController.java | 22 ++++ .../common/constant/RedisKeyConstants.java | 5 + .../com/xzzn/ems/domain/EmsPointMatch.java | 13 +++ .../ems/domain/vo/DevicePointMatchVo.java | 96 ++++++++++++++++ .../ems/domain/vo/ImportPointDataRequest.java | 61 ++++++++++ .../com/xzzn/ems/enums/DeviceMatchTable.java | 82 ++++++++++++++ .../xzzn/ems/mapper/EmsPointMatchMapper.java | 4 + .../ems/service/IEmsPointMatchService.java | 4 + .../impl/EmsPointMatchServiceImpl.java | 105 ++++++++++++++++++ .../com/xzzn/ems/utils/MatchTableUtils.java | 33 ++++++ .../mapper/ems/EmsPointMatchMapper.xml | 22 +++- 11 files changed, 446 insertions(+), 1 deletion(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java index ad98c35..75b1ca9 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java @@ -2,10 +2,13 @@ package com.xzzn.web.controller.ems; import java.util.List; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; 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.RestController; import com.xzzn.common.annotation.Log; @@ -13,6 +16,8 @@ import com.xzzn.common.core.controller.BaseController; import com.xzzn.common.core.domain.AjaxResult; import com.xzzn.common.enums.BusinessType; import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.DevicePointMatchVo; +import com.xzzn.ems.domain.vo.ImportPointDataRequest; import com.xzzn.ems.service.IEmsPointMatchService; import com.xzzn.common.utils.poi.ExcelUtil; import org.springframework.web.multipart.MultipartFile; @@ -62,4 +67,21 @@ public class EmsPointMatchController extends BaseController return success(message); } + /** + * 上传设备的点位清单 + * @param request + * @return + * @throws Exception + */ + @PreAuthorize("@ss.hasPermi('system:user:import')") + @Log(title = "点位匹配", businessType = BusinessType.IMPORT) + @PostMapping("/importDataByDevice") + public void importDataByDevice(@Valid ImportPointDataRequest request, HttpServletResponse response) { + List list = emsPointMatchService.importDataByDevice(request, getUsername()); + if (CollectionUtils.isNotEmpty(list)) { + ExcelUtil util = new ExcelUtil<>(DevicePointMatchVo.class); + util.exportExcel(response, list, "点位匹配数据"); + } + } + } diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 8d080d8..dc83d4f 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -62,6 +62,11 @@ public class RedisKeyConstants */ public static final String COOLING = "COOLING_"; + /** + * 点位匹配数据 redis key + */ + public static final String POINT_MATCH = "POINT_MATCH_"; + /** * 存放单个设备同步过来的原始数据-最晚一次数据 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java index 9bc8f12..1abe5e0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -70,6 +70,10 @@ public class EmsPointMatch extends BaseEntity @Excel(name = "点位是否需要区分多设备:0-不需要 1-需要") private Long needDiffDeviceId; + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + public void setId(Long id) { this.id = id; @@ -208,6 +212,14 @@ public class EmsPointMatch extends BaseEntity return needDiffDeviceId; } + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -230,6 +242,7 @@ public class EmsPointMatch extends BaseEntity .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("remark", getRemark()) + .append("deviceId", getDeviceId()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java new file mode 100644 index 0000000..d8903d7 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java @@ -0,0 +1,96 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +import java.io.Serializable; + +/** + * 点位清单上传参数 + */ +public class DevicePointMatchVo implements Serializable { + private static final long serialVersionUID = 1L; + + /** 点位匹配字段 */ + @Excel(name = "点位匹配字段") + private String matchField; + + /** 数据点位 */ + @Excel(name = "数据点位") + private String dataPoint; + + /** 数据点位名称 */ + @Excel(name = "数据点位名称") + private String dataPointName; + + /** 数据单位 */ + @Excel(name = "数据单位") + private String dataUnit; +// +// /** 数据点位来源设备 */ +// @Excel(name = "数据点位来源设备") +// private String dataDevice; + + /** 寄存器地址 */ + @Excel(name = "寄存器地址") + private String ipAddress; + + /** 错误信息 */ + @Excel(name = "错误信息") + private String errorMsg; + + public String getMatchField() { + return matchField; + } + + public void setMatchField(String matchField) { + this.matchField = matchField; + } + + public String getDataPoint() { + return dataPoint; + } + + public void setDataPoint(String dataPoint) { + this.dataPoint = dataPoint; + } + + public String getDataPointName() { + return dataPointName; + } + + public void setDataPointName(String dataPointName) { + this.dataPointName = dataPointName; + } + + public String getDataUnit() { + return dataUnit; + } + + public void setDataUnit(String dataUnit) { + this.dataUnit = dataUnit; + } + +// public String getDataDevice() { +// return dataDevice; +// } +// +// public void setDataDevice(String dataDevice) { +// this.dataDevice = dataDevice; +// } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java new file mode 100644 index 0000000..d5a6416 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java @@ -0,0 +1,61 @@ +package com.xzzn.ems.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +import org.springframework.web.multipart.MultipartFile; + +/** + * 上传设备点位清单请求参数 + */ +public class ImportPointDataRequest { + + /** 站点id */ + @NotBlank(message = "站点ID不能为空") + private String siteId; + /** 设备id */ + @NotBlank(message = "设备ID不能为空") + private String deviceId; + /** 设备类型 */ + @NotBlank(message = "设备类型不能为空") + private String deviceCategory; + /** 上传点位清单文件 */ + @NotNull(message = "点位清单文件不能为空") + private MultipartFile file; + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceCategory() { + return deviceCategory; + } + + public void setDeviceCategory(String deviceCategory) { + this.deviceCategory = deviceCategory; + } + + public MultipartFile getFile() { + return file; + } + + public void setFile(MultipartFile file) { + this.file = file; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java b/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java new file mode 100644 index 0000000..5a9c59d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java @@ -0,0 +1,82 @@ +package com.xzzn.ems.enums; + +import com.xzzn.ems.domain.EmsAmmeterData; +import com.xzzn.ems.domain.EmsBatteryCluster; +import com.xzzn.ems.domain.EmsBatteryData; +import com.xzzn.ems.domain.EmsBatteryGroup; +import com.xzzn.ems.domain.EmsBatteryStack; +import com.xzzn.ems.domain.EmsCoolingData; +import com.xzzn.ems.domain.EmsPcsBranchData; +import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.domain.EmsXfData; + +import java.util.HashMap; +import java.util.Map; + +/** + * 设备匹配表枚举类 + */ +public enum DeviceMatchTable +{ + PCS("PCS", "ems_pcs_data", EmsPcsData.class), + BRANCH("BRANCH", "ems_pcs_branch_data", EmsPcsBranchData.class), + STACK("STACK", "ems_battery_stack", EmsBatteryStack.class), + CLUSTER("CLUSTER", "ems_battery_cluster", EmsBatteryCluster.class), + BATTERY("BATTERY", "ems_battery_data", EmsBatteryData.class), + AMMETER("AMMETER", "ems_ammeter_data", EmsAmmeterData.class), + COOLING("COOLING", "ems_cooling_data", EmsCoolingData.class), + DH("DH", "ems_dh_data", EmsBatteryData.class), + XF("XF", "ems_xf_data", EmsXfData.class), + BATTERY_GROUP("BATTERY_GROUP", "ems_battery_group", EmsBatteryGroup.class); + + private final String code; + private final String matchTable; + + private final Class matchTableClass; + + DeviceMatchTable(String code, String matchTable, Class matchTableClass) + { + this.code = code; + this.matchTable = matchTable; + this.matchTableClass = matchTableClass; + } + + public String getCode() + { + return code; + } + + public String getMatchTable() { + return matchTable; + } + + public Class getMatchTableClass() { + return matchTableClass; + } + + // 缓存code与matchTable的映射(优化查询效率) + private static final Map DEVICE_MATCH_TABLE_MAP = new HashMap<>(); + + // 缓存table与实体类的映射(优化查询效率) + private static final Map> TABLE_TO_CLASS_MAP = new HashMap<>(); + + // 静态块初始化缓存 + static { + for (DeviceMatchTable category : DeviceMatchTable.values()) { + DEVICE_MATCH_TABLE_MAP.put(category.code, category.matchTable); + TABLE_TO_CLASS_MAP.put(category.matchTable, category.matchTableClass); + } + } + + + // 通过code获取matchTable的方法 + public static String getMatchTableByCode(String code) { + return DEVICE_MATCH_TABLE_MAP.get(code); // 从缓存中直接获取,效率高 + } + + // 通过table获取实体类的方法 + public static Class getClassByTable(String matchTable) { + return TABLE_TO_CLASS_MAP.get(matchTable); // 从缓存中直接获取,效率高 + } + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 19a1f29..433589f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -140,4 +140,8 @@ public interface EmsPointMatchMapper // 根据站点,设备类别,点位,获取唯一数据 public EmsPointMatch getUniquePoint(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("dataPoint")String dataPoint); + + EmsPointMatch getOnePointMatch(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory, @Param("dataPoint") String dataPoint); + + List getDevicePointMatchList(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java index 2242e4e..c9027ac 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java @@ -3,6 +3,8 @@ package com.xzzn.ems.service; import java.util.List; import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.DevicePointMatchVo; +import com.xzzn.ems.domain.vo.ImportPointDataRequest; /** * 点位匹配Service接口 @@ -29,4 +31,6 @@ public interface IEmsPointMatchService * @return */ public String importPoint(List userList, boolean updateSupport, String operName); + + public List importDataByDevice(ImportPointDataRequest request, String operName); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index 25942cb..d3c3ff7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -1,15 +1,33 @@ package com.xzzn.ems.service.impl; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import com.alibaba.fastjson2.JSON; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.exception.ServiceException; import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanValidators; + +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.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; + +import com.xzzn.common.utils.poi.ExcelUtil; +import com.xzzn.ems.domain.vo.DevicePointMatchVo; +import com.xzzn.ems.domain.vo.ImportPointDataRequest; +import com.xzzn.ems.enums.DeviceMatchTable; import com.xzzn.ems.mapper.EmsPointMatchMapper; import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.service.IEmsPointMatchService; +import com.xzzn.ems.utils.MatchTableUtils; import javax.validation.Validator; @@ -22,10 +40,13 @@ import javax.validation.Validator; @Service public class EmsPointMatchServiceImpl implements IEmsPointMatchService { + private static final Logger log = LoggerFactory.getLogger(EmsPointMatchServiceImpl.class); @Autowired private EmsPointMatchMapper emsPointMatchMapper; @Autowired protected Validator validator; + @Autowired + private RedisCache redisCache; /** * 查询点位匹配列表 @@ -92,5 +113,89 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService return successMsg.toString(); } + @Override + @Transactional(rollbackFor = Exception.class) + public List importDataByDevice(ImportPointDataRequest request, String operName) { + ExcelUtil util = new ExcelUtil<>(DevicePointMatchVo.class); + List pointMatchList = new ArrayList<>(); + MultipartFile file = request.getFile(); + if (file.isEmpty()) { + throw new ServiceException("点位清单文件不能为空"); + } + try { + pointMatchList = util.importExcel(file.getInputStream()); + } catch (IOException e) { + log.info("点位清单导入失败:{}", e.getMessage()); + throw new ServiceException("点位清单导入失败!"); + } + if (CollectionUtils.isEmpty(pointMatchList)) { + throw new ServiceException("导入用户数据不能为空!"); + } + String siteId = request.getSiteId(); + String deviceId = request.getDeviceId(); + String deviceCategory = request.getDeviceCategory(); + List errorList = new ArrayList<>(); + for (DevicePointMatchVo pointMatch : pointMatchList) { + try { + //校验点位清单文件内容 + if (validDevicePointMatch(pointMatch, errorList)) { + continue; + } + EmsPointMatch savePoint = new EmsPointMatch(); + BeanUtils.copyProperties(pointMatch, savePoint); + savePoint.setSiteId(siteId); + savePoint.setDeviceId(deviceId); + savePoint.setDeviceCategory(deviceCategory); + savePoint.setMatchTable(DeviceMatchTable.getMatchTableByCode(deviceCategory)); + savePoint.setPointName(MatchTableUtils.getFieldAnnotation(DeviceMatchTable.getClassByTable(savePoint.getMatchTable()), StringUtils.toCamelCase(savePoint.getMatchField()))); + savePoint.setCreateBy(operName); + savePoint.setUpdateBy(operName); + // 验证点位是否存在 + EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceId, deviceCategory, pointMatch.getDataPoint()); + if (StringUtils.isNull(dbPoint)) { + emsPointMatchMapper.insertEmsPointMatch(savePoint); + } else { + emsPointMatchMapper.updateEmsPointMatch(savePoint); + } + } catch (Exception e) { + log.info("点位清单导入失败:{}", e.getMessage()); + throw new ServiceException("点位清单导入失败!"); + } + } + // 同步到Redis + syncToRedis(siteId, deviceId, deviceCategory); + return errorList; + } + + private boolean validDevicePointMatch(DevicePointMatchVo pointMatch, List errorList) { + StringBuilder errorMsg = new StringBuilder(); + if (StringUtils.isBlank(pointMatch.getMatchField())) { + errorMsg.append("点位匹配字段不能为空;"); + } + if (StringUtils.isBlank(pointMatch.getDataPoint())) { + errorMsg.append("数据点位不能为空;"); + } + if (StringUtils.isBlank(pointMatch.getDataPointName())) { + errorMsg.append("数据点位名称不能为空;"); + } +// if (StringUtils.isBlank(pointMatch.getDataDevice())) { +// errorMsg.append("数据点位来源设备不能为空;"); +// } + if (errorMsg.length() > 0) { + pointMatch.setErrorMsg(errorMsg.toString()); + errorList.add(pointMatch); + return true; + } + return false; + } + + private void syncToRedis(String siteId, String deviceId, String deviceCategory) { + // 同步到Redis + String pointMatchKey = RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId + "_" + deviceId; + List pointMatchData = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceId, deviceCategory); +// log.info("同步点位匹配数据到Redis key:{} data:{}", pointMatchKey, pointMatchData); + redisCache.setCacheObject(pointMatchKey, pointMatchData); + log.info("点位匹配数据同步完成 data:{}", JSON.toJSONString(redisCache.getCacheObject(pointMatchKey))); + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java b/ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java new file mode 100644 index 0000000..49649f6 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java @@ -0,0 +1,33 @@ +package com.xzzn.ems.utils; + +import com.xzzn.common.annotation.Excel; +import com.xzzn.common.utils.StringUtils; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * 匹配表工具类 + */ +public class MatchTableUtils { + + /** + * 获取字段注解信息 + */ + public static String getFieldAnnotation(Class clazz, String filedName) + { + List tempFields = new ArrayList<>(); + tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); + for (Field field : tempFields) { + if (StringUtils.equals(filedName, field.getName()) && field.isAnnotationPresent(Excel.class)) + { + Excel column = field.getAnnotation(Excel.class); + return column.name(); + } + } + return null; + } + +} diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index c0560cf..2dd6aad 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -24,10 +24,11 @@ + - select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark from ems_point_match + select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, device_id from ems_point_match + + + \ No newline at end of file -- 2.49.0 From b38bc36ad602e469e08584652812af7f00b1acc8 Mon Sep 17 00:00:00 2001 From: zq Date: Sat, 29 Nov 2025 19:54:10 +0800 Subject: [PATCH 221/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-021=5FFXX=5F01=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=82=B9=E4=BD=8D=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=AF=BB=E5=8F=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=E8=AE=BE=E5=A4=87=E7=82=B9=E4=BD=8D=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=EF=BC=8C=E5=AD=98=E5=82=A8=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E7=82=B9=E4=BD=8D=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/utils/DataUtils.java | 39 + .../ems/domain/vo/DevicePointMatchInfo.java | 116 +++ .../com/xzzn/ems/enums/DeviceMatchTable.java | 3 +- .../ems/service/IEmsPointMatchService.java | 6 + .../impl/EmsPointMatchServiceImpl.java | 13 +- .../impl/FXXDataProcessServiceImpl.java | 738 ++++++++++-------- .../utils/DevicePointMatchDataProcessor.java | 180 +++++ .../com/xzzn/ems/utils/MatchTableUtils.java | 33 - .../biz/configData/DevicePointMatch.json | 311 ++++++++ 9 files changed, 1092 insertions(+), 347 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/utils/DataUtils.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchInfo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java delete mode 100644 ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java create mode 100644 ems-system/src/main/resources/biz/configData/DevicePointMatch.json diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DataUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DataUtils.java new file mode 100644 index 0000000..692681c --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/utils/DataUtils.java @@ -0,0 +1,39 @@ +package com.xzzn.common.utils; + + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class DataUtils { + private static final Log log = LogFactory.getLog(DataUtils.class); + + public static String getJSONFromFile(InputStream inputStream) { + BufferedReader bufferReader = null; + StringBuffer stringBuffer = new StringBuffer(); + try { + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8"); + bufferReader = new BufferedReader(inputStreamReader); + stringBuffer = new StringBuffer(); + String lineData = null; + while ((lineData = bufferReader.readLine()) != null) { + stringBuffer.append(lineData); + } + } catch (Exception e) { + log.warn("getJSONFromFile error", e); + } finally { + if (null != bufferReader) { + try { + bufferReader.close(); + inputStream.close(); + } catch (Exception e) { + log.warn("getJSONFromFile error", e); + } + } + } + return stringBuffer.toString(); + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchInfo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchInfo.java new file mode 100644 index 0000000..c375476 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchInfo.java @@ -0,0 +1,116 @@ +package com.xzzn.ems.domain.vo; + +import java.util.Map; + +public class DevicePointMatchInfo { + + private Map pcs; + + private Map branch; + + private Map stack; + + private Map cluster; + + private Map battery; + + private Map ammeterLoad; + + private Map ammeterMete; + + private Map cooling; + + private Map dh; + + private Map xf; + + private Map batteryGroup; + + public Map getPcs() { + return pcs; + } + + public void setPcs(Map pcs) { + this.pcs = pcs; + } + + public Map getBranch() { + return branch; + } + + public void setBranch(Map branch) { + this.branch = branch; + } + + public Map getStack() { + return stack; + } + + public void setStack(Map stack) { + this.stack = stack; + } + + public Map getCluster() { + return cluster; + } + + public void setCluster(Map cluster) { + this.cluster = cluster; + } + + public Map getBattery() { + return battery; + } + + public void setBattery(Map battery) { + this.battery = battery; + } + + public Map getAmmeterLoad() { + return ammeterLoad; + } + + public void setAmmeterLoad(Map ammeterLoad) { + this.ammeterLoad = ammeterLoad; + } + + public Map getAmmeterMete() { + return ammeterMete; + } + + public void setAmmeterMete(Map ammeterMete) { + this.ammeterMete = ammeterMete; + } + + public Map getCooling() { + return cooling; + } + + public void setCooling(Map cooling) { + this.cooling = cooling; + } + + public Map getDh() { + return dh; + } + + public void setDh(Map dh) { + this.dh = dh; + } + + public Map getXf() { + return xf; + } + + public void setXf(Map xf) { + this.xf = xf; + } + + public Map getBatteryGroup() { + return batteryGroup; + } + + public void setBatteryGroup(Map batteryGroup) { + this.batteryGroup = batteryGroup; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java b/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java index 5a9c59d..835a8ca 100644 --- a/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java +++ b/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java @@ -6,6 +6,7 @@ import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsBatteryGroup; import com.xzzn.ems.domain.EmsBatteryStack; import com.xzzn.ems.domain.EmsCoolingData; +import com.xzzn.ems.domain.EmsDhData; import com.xzzn.ems.domain.EmsPcsBranchData; import com.xzzn.ems.domain.EmsPcsData; import com.xzzn.ems.domain.EmsXfData; @@ -25,7 +26,7 @@ public enum DeviceMatchTable BATTERY("BATTERY", "ems_battery_data", EmsBatteryData.class), AMMETER("AMMETER", "ems_ammeter_data", EmsAmmeterData.class), COOLING("COOLING", "ems_cooling_data", EmsCoolingData.class), - DH("DH", "ems_dh_data", EmsBatteryData.class), + DH("DH", "ems_dh_data", EmsDhData.class), XF("XF", "ems_xf_data", EmsXfData.class), BATTERY_GROUP("BATTERY_GROUP", "ems_battery_group", EmsBatteryGroup.class); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java index c9027ac..675da0d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java @@ -32,5 +32,11 @@ public interface IEmsPointMatchService */ public String importPoint(List userList, boolean updateSupport, String operName); + /** + * 上传设备的点位清单 + * @param request + * @return + * @throws Exception + */ public List importDataByDevice(ImportPointDataRequest request, String operName); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index d3c3ff7..2363075 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -3,6 +3,7 @@ package com.xzzn.ems.service.impl; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import com.alibaba.fastjson2.JSON; import com.xzzn.common.constant.RedisKeyConstants; @@ -27,7 +28,7 @@ import com.xzzn.ems.enums.DeviceMatchTable; import com.xzzn.ems.mapper.EmsPointMatchMapper; import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.service.IEmsPointMatchService; -import com.xzzn.ems.utils.MatchTableUtils; +import com.xzzn.ems.utils.DevicePointMatchDataProcessor; import javax.validation.Validator; @@ -113,6 +114,12 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService return successMsg.toString(); } + /** + * 导入设备点位清单数据到数据库,并同步到Redis + * @param request + * @param operName + * @return + */ @Override @Transactional(rollbackFor = Exception.class) public List importDataByDevice(ImportPointDataRequest request, String operName) { @@ -148,12 +155,12 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService savePoint.setDeviceId(deviceId); savePoint.setDeviceCategory(deviceCategory); savePoint.setMatchTable(DeviceMatchTable.getMatchTableByCode(deviceCategory)); - savePoint.setPointName(MatchTableUtils.getFieldAnnotation(DeviceMatchTable.getClassByTable(savePoint.getMatchTable()), StringUtils.toCamelCase(savePoint.getMatchField()))); + savePoint.setPointName(DevicePointMatchDataProcessor.getFieldAnnotation(DeviceMatchTable.getClassByTable(savePoint.getMatchTable()), StringUtils.toCamelCase(savePoint.getMatchField()))); savePoint.setCreateBy(operName); savePoint.setUpdateBy(operName); // 验证点位是否存在 EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceId, deviceCategory, pointMatch.getDataPoint()); - if (StringUtils.isNull(dbPoint)) { + if (Objects.isNull(dbPoint)) { emsPointMatchMapper.insertEmsPointMatch(savePoint); } else { emsPointMatchMapper.updateEmsPointMatch(savePoint); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 32bed2c..5bfdbfa 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -15,17 +15,25 @@ import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.*; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import com.xzzn.ems.domain.vo.EnergyPriceVo; +import com.xzzn.ems.enums.DeviceMatchTable; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; +import com.xzzn.ems.utils.DevicePointMatchDataProcessor; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.yaml.snakeyaml.introspector.PropertyUtils; +import java.lang.reflect.Field; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; @@ -34,6 +42,7 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; @Service @@ -84,6 +93,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private IEmsEnergyPriceConfigService emsEnergyPriceConfigService; @Autowired private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; + @Autowired + private DevicePointMatchDataProcessor devicePointMatchDataProcessor; // 构造方法(调用父类构造) public FXXDataProcessServiceImpl(ObjectMapper objectMapper) { @@ -144,13 +155,19 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl }); EmsCoolingData coolingData = new EmsCoolingData(); - coolingData.setGsTemp(StringUtils.getBigDecimal(obj.get("GSWD"))); - coolingData.setHsTemp(StringUtils.getBigDecimal(obj.get("HSWD"))); - coolingData.setGsPressure(StringUtils.getBigDecimal(obj.get("GSYL"))); - coolingData.setHsPressure(StringUtils.getBigDecimal(obj.get("HSYL"))); - coolingData.setLysTemp(StringUtils.getBigDecimal(obj.get("LYSWD"))); - coolingData.setVb01Kd(StringUtils.getBigDecimal(obj.get("VB1KD"))); - coolingData.setVb02Kd(StringUtils.getBigDecimal(obj.get("VB2KD"))); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.COOLING.getCode()); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, obj, coolingData); + } else { + coolingData.setGsTemp(StringUtils.getBigDecimal(obj.get("GSWD"))); + coolingData.setHsTemp(StringUtils.getBigDecimal(obj.get("HSWD"))); + coolingData.setGsPressure(StringUtils.getBigDecimal(obj.get("GSYL"))); + coolingData.setHsPressure(StringUtils.getBigDecimal(obj.get("HSYL"))); + coolingData.setLysTemp(StringUtils.getBigDecimal(obj.get("LYSWD"))); + coolingData.setVb01Kd(StringUtils.getBigDecimal(obj.get("VB1KD"))); + coolingData.setVb02Kd(StringUtils.getBigDecimal(obj.get("VB2KD"))); + } coolingData.setCreateBy("system"); coolingData.setCreateTime(DateUtils.getNowDate()); @@ -162,6 +179,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsCoolingDataMapper.insertEmsCoolingData(coolingData); redisCache.setCacheObject(RedisKeyConstants.COOLING + SITE_ID + "_" +deviceId, coolingData); + + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.COOLING, "ZSLQ"); } private void dhDataProcess(String deviceId, String dataJson) { @@ -171,9 +190,14 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl //DH EmsDhData dhData = new EmsDhData(); - - dhData.setHumidity(StringUtils.getBigDecimal(obj.get("SD3"))); - dhData.setTemperature(StringUtils.getBigDecimal(obj.get("WD3"))); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.DH.getCode()); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, obj, dhData); + } else { + dhData.setHumidity(StringUtils.getBigDecimal(obj.get("SD3"))); + dhData.setTemperature(StringUtils.getBigDecimal(obj.get("WD3"))); + } dhData.setCreateBy("system"); dhData.setCreateTime(DateUtils.getNowDate()); @@ -184,6 +208,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsDhDataMapper.insertEmsDhData(dhData); redisCache.setCacheObject(RedisKeyConstants.DH + SITE_ID + "_" +deviceId, dhData); + + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.DH, "donghuan"); } private void batteryStackDataProcess(String deviceId, String dataJson) { @@ -200,58 +226,66 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - // 电池堆状态数据设置 - dataStack.setOperationStatus(StringUtils.getString(obj.get("DCZT"))); - dataStack.setStackVoltage(StringUtils.getBigDecimal(obj.get("DCDDY"))); - dataStack.setStackCurrent(StringUtils.getBigDecimal(obj.get("DCDDL"))); - dataStack.setStackSoc(StringUtils.getBigDecimal(obj.get("DCDSOC"))); - dataStack.setStackSoh(StringUtils.getBigDecimal(obj.get("DCDSOH"))); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.STACK.getCode()); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, obj, dataStack); + } else { - // 电压极值信息 - dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDCDY"))); - dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("ZGDCDYZH"))); - dataStack.setMaxVoltageCellId(StringUtils.getLong(obj.get("ZGDCDYZHDH"))); - dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDCDY"))); - dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("ZDDCDYZH"))); - dataStack.setMinVoltageCellId(StringUtils.getLong(obj.get("ZDDCDYZHDH"))); + // 电池堆状态数据设置 + dataStack.setOperationStatus(StringUtils.getString(obj.get("DCZT"))); + dataStack.setStackVoltage(StringUtils.getBigDecimal(obj.get("DCDDY"))); + dataStack.setStackCurrent(StringUtils.getBigDecimal(obj.get("DCDDL"))); + dataStack.setStackSoc(StringUtils.getBigDecimal(obj.get("DCDSOC"))); + dataStack.setStackSoh(StringUtils.getBigDecimal(obj.get("DCDSOH"))); - // 温度极值信息 - dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDCWD"))); - dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("ZGDCWDZH"))); - dataStack.setMaxTempCellId(StringUtils.getLong(obj.get("ZGDCWDZHDH"))); - dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDCWD"))); - dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("ZDDCWDZH"))); - dataStack.setMinTempCellId(StringUtils.getLong(obj.get("ZDDCWDZHDH"))); + // 电压极值信息 + dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDCDY"))); + dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("ZGDCDYZH"))); + dataStack.setMaxVoltageCellId(StringUtils.getLong(obj.get("ZGDCDYZHDH"))); + dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDCDY"))); + dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("ZDDCDYZH"))); + dataStack.setMinVoltageCellId(StringUtils.getLong(obj.get("ZDDCDYZHDH"))); - // 电量统计信息 - dataStack.setTotalChargeCapacity(StringUtils.getBigDecimal(obj.get("DLJCDDL"))); - dataStack.setTotalDischargeCapacity(StringUtils.getBigDecimal(obj.get("DLCFDDL"))); - dataStack.setSessionChargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJCDDL"))); - dataStack.setSessionDischargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJFDDL"))); - dataStack.setAvailableChargeCapacity(StringUtils.getBigDecimal(obj.get("DKCDL"))); - dataStack.setAvailableDischargeCapacity(StringUtils.getBigDecimal(obj.get("DKFDL"))); + // 温度极值信息 + dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDCWD"))); + dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("ZGDCWDZH"))); + dataStack.setMaxTempCellId(StringUtils.getLong(obj.get("ZGDCWDZHDH"))); + dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDCWD"))); + dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("ZDDCWDZH"))); + dataStack.setMinTempCellId(StringUtils.getLong(obj.get("ZDDCWDZHDH"))); -// 时间信息 - dataStack.setRemainingDischargeTime(StringUtils.getLong(obj.get("KYFDSJ"))); - dataStack.setRemainingChargeTime(StringUtils.getLong(obj.get("KYCDSJ"))); + // 电量统计信息 + dataStack.setTotalChargeCapacity(StringUtils.getBigDecimal(obj.get("DLJCDDL"))); + dataStack.setTotalDischargeCapacity(StringUtils.getBigDecimal(obj.get("DLCFDDL"))); + dataStack.setSessionChargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJCDDL"))); + dataStack.setSessionDischargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJFDDL"))); + dataStack.setAvailableChargeCapacity(StringUtils.getBigDecimal(obj.get("DKCDL"))); + dataStack.setAvailableDischargeCapacity(StringUtils.getBigDecimal(obj.get("DKFDL"))); -// 功率/电流限制 - dataStack.setMaxDischargePower(StringUtils.getBigDecimal(obj.get("YXZDFDGL"))); - dataStack.setMaxChargePower(StringUtils.getBigDecimal(obj.get("YXZDCDGL"))); - dataStack.setMaxDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDFDDL"))); - dataStack.setMaxChargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDCDDL"))); + // 时间信息 + dataStack.setRemainingDischargeTime(StringUtils.getLong(obj.get("KYFDSJ"))); + dataStack.setRemainingChargeTime(StringUtils.getLong(obj.get("KYCDSJ"))); - // 当日统计 - dataStack.setDailyDischargeCycles(StringUtils.getLong(obj.get("DTFDCS"))); - dataStack.setDailyChargeCycles(StringUtils.getLong(obj.get("DTCDCS"))); - dataStack.setDailyDischargeCapacity(StringUtils.getBigDecimal(obj.get("DTFDDL"))); - dataStack.setDailyChargeCapacity(StringUtils.getBigDecimal(obj.get("DTCDDL"))); + // 功率/电流限制 + dataStack.setMaxDischargePower(StringUtils.getBigDecimal(obj.get("YXZDFDGL"))); + dataStack.setMaxChargePower(StringUtils.getBigDecimal(obj.get("YXZDCDGL"))); + dataStack.setMaxDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDFDDL"))); + dataStack.setMaxChargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDCDDL"))); - // 系统状态 - dataStack.setOperatingTemp(StringUtils.getBigDecimal(obj.get("YXWD"))); - dataStack.setBmsStatus(StringUtils.getString(obj.get("BMSDDQZT"))); - dataStack.setBmsChargeStatus(StringUtils.getString(obj.get("BMSCFDZT"))); - dataStack.setStackInsulationResistance(StringUtils.getBigDecimal(obj.get("DCDJYDZ"))); + // 当日统计 + dataStack.setDailyDischargeCycles(StringUtils.getLong(obj.get("DTFDCS"))); + dataStack.setDailyChargeCycles(StringUtils.getLong(obj.get("DTCDCS"))); + dataStack.setDailyDischargeCapacity(StringUtils.getBigDecimal(obj.get("DTFDDL"))); + dataStack.setDailyChargeCapacity(StringUtils.getBigDecimal(obj.get("DTCDDL"))); + + // 系统状态 + dataStack.setOperatingTemp(StringUtils.getBigDecimal(obj.get("YXWD"))); + dataStack.setBmsStatus(StringUtils.getString(obj.get("BMSDDQZT"))); + dataStack.setBmsChargeStatus(StringUtils.getString(obj.get("BMSCFDZT"))); + dataStack.setStackInsulationResistance(StringUtils.getBigDecimal(obj.get("DCDJYDZ"))); + + } dataStack.setCreateBy("system"); @@ -264,8 +298,41 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsBatteryStackMapper.insertEmsBatteryStack(dataStack); redisCache.setCacheObject(RedisKeyConstants.STACK + SITE_ID + "_" +deviceId, dataStack); + + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.STACK, "BMSD"); } + private void saveDeviceData(List pointMatchList, Map obj, Object entity) { + Map pointMatchMap = pointMatchList.stream().collect(Collectors.toMap(data -> StringUtils.toCamelCase(data.getMatchField()), EmsPointMatch::getDataPoint)); + Field[] fields = entity.getClass().getDeclaredFields(); + for (Field field : fields) { + if (pointMatchMap.containsKey(field.getName())) { + field.setAccessible(true); + try { + Object matchValue = obj.get(pointMatchMap.get(field.getName())); + Class fieldType = field.getType(); + if (String.class.equals(fieldType)) { + matchValue = StringUtils.getString(matchValue); + } else if (Long.class.equals(fieldType)) { + matchValue = StringUtils.getLong(matchValue); + } else if (BigDecimal.class.equals(fieldType)) { + matchValue = StringUtils.getBigDecimal(matchValue); + } + field.set(entity, matchValue); + } catch (IllegalAccessException e) { + log.warn("batteryStackDataProcess 设置字段值时出错", e); + } + } + } + } + + private void saveDevicePointMatchData(List pointMatchList, String deviceId, + DeviceMatchTable pointMatchType, String dataDevice){ + if (CollectionUtils.isNotEmpty(pointMatchList)) { + return; + } + devicePointMatchDataProcessor.saveDevicePointMatch(SITE_ID, deviceId, pointMatchType, dataDevice); + } private void batteryClusterDataProcess(String deviceId, String dataJson) { @@ -283,43 +350,59 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } //BMS 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); - // 设置所有 BigDecimal 类型字段为 ZERO - data.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); - data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); - data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); - data.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); - data.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); - data.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); - data.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - data.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); - data.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - data.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); - data.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); - data.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); - data.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); - data.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); - data.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); - data.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); - data.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); - data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); - data.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - data.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - data.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - data.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); - data.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); - data.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); - data.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); - data.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); - data.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); - data.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); - data.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); - data.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); - data.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); - data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); - data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.CLUSTER.getCode()); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, obj, data); + } else { + + // 设置所有 BigDecimal 类型字段为 ZERO + data.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); + data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); + data.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); + data.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); + data.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); + data.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); + data.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); + data.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); + data.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); + data.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); + data.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); + data.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); + data.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); + data.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); + data.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); + data.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); + data.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); + data.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); + data.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); + data.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); + data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); + data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); + + // 其他非 BigDecimal 字段 + data.setMaxCellVoltageId(StringUtils.getString(obj.get("ZGDTDYDYD"))); + data.setMinCellVoltageId(StringUtils.getString(obj.get("ZDDTDYDYD"))); + data.setMaxCellTempId(StringUtils.getString(obj.get("ZGDTWDDYD"))); + data.setMinCellTempId(StringUtils.getString(obj.get("ZDDTWDDYD"))); + data.setMaxCellSocId(StringUtils.getString(obj.get("ZGDTSOCDYD"))); + data.setMinCellSocId(StringUtils.getString(obj.get("ZDDTSOCDYD"))); + data.setMaxCellSohId(StringUtils.getString(obj.get("ZGDTSOHDYD"))); + data.setMinCellSohId(StringUtils.getString(obj.get("ZDDTSOHDYD"))); + } - // 其他非 BigDecimal 字段 data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); @@ -329,14 +412,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl data.setUpdateTime(DateUtils.getNowDate()); data.setSiteId(SITE_ID); data.setDeviceId(deviceId); - data.setMaxCellVoltageId(StringUtils.getString(obj.get("ZGDTDYDYD"))); - data.setMinCellVoltageId(StringUtils.getString(obj.get("ZDDTDYDYD"))); - data.setMaxCellTempId(StringUtils.getString(obj.get("ZGDTWDDYD"))); - data.setMinCellTempId(StringUtils.getString(obj.get("ZDDTWDDYD"))); - data.setMaxCellSocId(StringUtils.getString(obj.get("ZGDTSOCDYD"))); - data.setMinCellSocId(StringUtils.getString(obj.get("ZDDTSOCDYD"))); - data.setMaxCellSohId(StringUtils.getString(obj.get("ZGDTSOHDYD"))); - data.setMinCellSohId(StringUtils.getString(obj.get("ZDDTSOHDYD"))); if (StringUtils.isNotBlank(stackDeviceId)) { data.setStackDeviceId(stackDeviceId); } else { @@ -346,6 +421,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.CLUSTER, "BMSC"); } private void batteryDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { @@ -368,6 +444,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String oneHourAgoStr = oneHourAgo.format(formatter); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.BATTERY.getCode()); //单体电池 for (Map.Entry> record : records.entrySet()) { String recordId = record.getKey(); @@ -376,10 +454,15 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsBatteryData batteryData = new EmsBatteryData(); batteryData.setDeviceId(recordId); batteryData.setBatteryCellId(recordId); - batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); - batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); - batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); - batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); + + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, fields, batteryData); + } else { + batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); + batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); + batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); + batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); + } batteryData.setBatteryCluster(deviceId); batteryData.setBatteryPack(stackDeviceId); @@ -412,6 +495,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId); redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId, list); + + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.BATTERY, "BMSC"); } // 批量处理每日最新数据 @@ -434,8 +519,67 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl private void pcsDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); + //pcs EmsPcsData pcsData = new EmsPcsData(); + + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.PCS.getCode()); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, obj, pcsData); + } else { + + // 功率与能量类字段 + pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("YGGL"))); + pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); + pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("XTWGGL"))); + pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); + pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); + pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("ZCDL"))); + pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFDL"))); + pcsData.setAcChargeActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); + pcsData.setAcCapacitiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); + pcsData.setAcDischargeActivePower(StringUtils.getBigDecimal(obj.get("JLCFDYGGL"))); + pcsData.setAcInductiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCGXWGGL"))); + pcsData.setMaxCapacitivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDRXWGNL"))); + pcsData.setMaxInductivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDGXWGNL"))); + pcsData.setMaxChargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKCGL"))); + pcsData.setMaxDischargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKFGL"))); + + + // 温度与环境参数 +// pcsData.setPcsModuleTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setPcsEnvironmentTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setAcFrequency(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + + // 状态指示类 + pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); + pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); + String acSwitchStatus = StringUtils.getString(obj.get("JLKGZT")); + pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String dcSwitchStatus = StringUtils.getString(obj.get("ZLKGZT")); + pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String controlMode = StringUtils.getString(obj.get("YCTT")); + pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); + + // 电流参数 + pcsData.setSysUCurrent(StringUtils.getBigDecimal(obj.get("XTSCUXDL"))); + pcsData.setSysVCurrent(StringUtils.getBigDecimal(obj.get("XTSCVXDL"))); + pcsData.setSysWCurrent(StringUtils.getBigDecimal(obj.get("XTSCWXDL"))); + + // 直流参数 +// pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); +// pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); + + // 三相温度 + pcsData.setuTemperature(StringUtils.getBigDecimal(obj.get("DY1UXIGBTWD"))); + pcsData.setvTemperature(StringUtils.getBigDecimal(obj.get("DY1VXIGBTWD"))); + pcsData.setwTemperature(StringUtils.getBigDecimal(obj.get("DY1WXIGBTWD"))); + + } + // 时间与状态类字段 pcsData.setDataUpdateTime(dataUpdateTime); pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); @@ -443,55 +587,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl pcsData.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); - // 功率与能量类字段 - pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("YGGL"))); - pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); - pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("XTWGGL"))); - pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); - pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); - pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); - pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); - pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("ZCDL"))); - pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFDL"))); - pcsData.setAcChargeActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); - pcsData.setAcCapacitiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); - pcsData.setAcDischargeActivePower(StringUtils.getBigDecimal(obj.get("JLCFDYGGL"))); - pcsData.setAcInductiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCGXWGGL"))); - pcsData.setMaxCapacitivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDRXWGNL"))); - pcsData.setMaxInductivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDGXWGNL"))); - pcsData.setMaxChargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKCGL"))); - pcsData.setMaxDischargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKFGL"))); - - - // 温度与环境参数 -// pcsData.setPcsModuleTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); -// pcsData.setPcsEnvironmentTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); -// pcsData.setAcFrequency(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); - - // 状态指示类 - pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); - pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); - String acSwitchStatus = StringUtils.getString(obj.get("JLKGZT")); - pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); - String dcSwitchStatus = StringUtils.getString(obj.get("ZLKGZT")); - pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); - String controlMode = StringUtils.getString(obj.get("YCTT")); - pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); - - // 电流参数 - pcsData.setSysUCurrent(StringUtils.getBigDecimal(obj.get("XTSCUXDL"))); - pcsData.setSysVCurrent(StringUtils.getBigDecimal(obj.get("XTSCVXDL"))); - pcsData.setSysWCurrent(StringUtils.getBigDecimal(obj.get("XTSCWXDL"))); - - // 直流参数 -// pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); -// pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); - - // 三相温度 - pcsData.setuTemperature(StringUtils.getBigDecimal(obj.get("DY1UXIGBTWD"))); - pcsData.setvTemperature(StringUtils.getBigDecimal(obj.get("DY1VXIGBTWD"))); - pcsData.setwTemperature(StringUtils.getBigDecimal(obj.get("DY1WXIGBTWD"))); - // 系统管理字段 pcsData.setCreateBy("system"); pcsData.setCreateTime(DateUtils.getNowDate()); @@ -504,13 +599,15 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsPcsDataMapper.insertEmsPcsData(pcsData); redisCache.setCacheObject(RedisKeyConstants.PCS + SITE_ID + "_" +deviceId, pcsData); - + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.PCS, "PCS"); } private void pcsBranchDataProcess(String deviceId, String dataJson) { Map> records = processDataPrefix(JSON.parseObject(dataJson, new TypeReference>() {})); List list = new ArrayList<>(); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.BRANCH.getCode()); //PCS支路 for (Map.Entry> record : records.entrySet()) { @@ -521,28 +618,32 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl data.setDeviceId(deviceId); data.setSiteId(SITE_ID); data.setGridStatus(GridStatus.GRID.getCode()); - data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); - data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); - data.setDcCurrent(StringUtils.getBigDecimal(fields.get("ZLDL"))); - data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWUXDY"))); - data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWVXDY"))); - data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWWXDY"))); - data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("SCUXDL"))); - data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("SCVXDL"))); - data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("SCWXDL"))); - data.setApparentPower(StringUtils.getBigDecimal(fields.get("SZGL"))); - data.setActivePower(StringUtils.getBigDecimal(fields.get("YGGL"))); - data.setReactivePower(StringUtils.getBigDecimal(fields.get("WGGL"))); - data.setPowerFactor(StringUtils.getBigDecimal(fields.get("GLYS"))); - data.setFrequency(StringUtils.getBigDecimal(fields.get("PL"))); - data.setInternalTemp(StringUtils.getBigDecimal(fields.get("DY1WD"))); - data.setuIgbtTemp(StringUtils.getBigDecimal(fields.get("UXIGBTWD"))); - data.setvIgbtTemp(StringUtils.getBigDecimal(fields.get("VXIGBTWD"))); - data.setwIgbtTemp(StringUtils.getBigDecimal(fields.get("WXIGBTWD"))); - data.setAvailablePower(StringUtils.getBigDecimal(fields.get("KYGL"))); - data.setTotalLoadRatio(StringUtils.getBigDecimal(fields.get("ZFZB"))); - data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); - data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, fields, data); + } else { + data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); + data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); + data.setDcCurrent(StringUtils.getBigDecimal(fields.get("ZLDL"))); + data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWUXDY"))); + data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWVXDY"))); + data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWWXDY"))); + data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("SCUXDL"))); + data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("SCVXDL"))); + data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("SCWXDL"))); + data.setApparentPower(StringUtils.getBigDecimal(fields.get("SZGL"))); + data.setActivePower(StringUtils.getBigDecimal(fields.get("YGGL"))); + data.setReactivePower(StringUtils.getBigDecimal(fields.get("WGGL"))); + data.setPowerFactor(StringUtils.getBigDecimal(fields.get("GLYS"))); + data.setFrequency(StringUtils.getBigDecimal(fields.get("PL"))); + data.setInternalTemp(StringUtils.getBigDecimal(fields.get("DY1WD"))); + data.setuIgbtTemp(StringUtils.getBigDecimal(fields.get("UXIGBTWD"))); + data.setvIgbtTemp(StringUtils.getBigDecimal(fields.get("VXIGBTWD"))); + data.setwIgbtTemp(StringUtils.getBigDecimal(fields.get("WXIGBTWD"))); + data.setAvailablePower(StringUtils.getBigDecimal(fields.get("KYGL"))); + data.setTotalLoadRatio(StringUtils.getBigDecimal(fields.get("ZFZB"))); + data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); + data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); + } data.setBranchId(recordId); data.setCreateBy("system"); data.setCreateTime(DateUtils.getNowDate()); @@ -555,6 +656,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.BRANCH + SITE_ID + "_" +deviceId, list); + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.BRANCH, "PCS"); } } @@ -569,83 +671,90 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 更新时间 dataLoad.setDataUpdateTime(dataUpdateTime); - // 电能设置-组合有功 - dataLoad.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); - dataLoad.setCurrentCombActivePeak(StringUtils.getBigDecimal(obj.get("DQZHYGJDN"))); - dataLoad.setCurrentCombActiveHigh(StringUtils.getBigDecimal(obj.get("DQZHYGFDN"))); - dataLoad.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); - dataLoad.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); - // 电能设置-正向有功 - dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); - dataLoad.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); - dataLoad.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); - dataLoad.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); - dataLoad.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); - // 电能设置-反向有功 - dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); - dataLoad.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); - dataLoad.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); - dataLoad.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); - dataLoad.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))); - // 电能设置-组合无功 - dataLoad.setCurrentCombReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZHWGZDN"))); - dataLoad.setCurrentCombReactivePeak(StringUtils.getBigDecimal(obj.get("DQZHWGJDN"))); - dataLoad.setCurrentCombReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZHWGFDN"))); - dataLoad.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); - dataLoad.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); - // 电能设置-正向无功 - dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); - dataLoad.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); - dataLoad.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); - dataLoad.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); - dataLoad.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); - // 电能设置-反向无功 - dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); - dataLoad.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); - dataLoad.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); - dataLoad.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); - dataLoad.setCurrentReverseReactiveValley(StringUtils.getBigDecimal(obj.get("DQFXWGGDN"))); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.AMMETER.getCode()); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, obj, dataLoad); + } else { - // 电压+电流 - dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); - dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); - dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); - dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); - dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); - dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + // 电能设置-组合有功 + dataLoad.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); + dataLoad.setCurrentCombActivePeak(StringUtils.getBigDecimal(obj.get("DQZHYGJDN"))); + dataLoad.setCurrentCombActiveHigh(StringUtils.getBigDecimal(obj.get("DQZHYGFDN"))); + dataLoad.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); + dataLoad.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); + // 电能设置-正向有功 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); + dataLoad.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); + dataLoad.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); + dataLoad.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); + dataLoad.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); + // 电能设置-反向有功 + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); + dataLoad.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); + dataLoad.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); + dataLoad.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); + dataLoad.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))); + // 电能设置-组合无功 + dataLoad.setCurrentCombReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZHWGZDN"))); + dataLoad.setCurrentCombReactivePeak(StringUtils.getBigDecimal(obj.get("DQZHWGJDN"))); + dataLoad.setCurrentCombReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZHWGFDN"))); + dataLoad.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); + dataLoad.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); + // 电能设置-正向无功 + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); + dataLoad.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); + dataLoad.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); + dataLoad.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); + dataLoad.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); + // 电能设置-反向无功 + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); + dataLoad.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); + dataLoad.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); + dataLoad.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); + dataLoad.setCurrentReverseReactiveValley(StringUtils.getBigDecimal(obj.get("DQFXWGGDN"))); - dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); - dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("CBXDY"))); - dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("ACXDY"))); + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); - // 频率 - dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("PL"))); + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("CBXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("ACXDY"))); - // 功率 有功+总+无功+无总+视在 - dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); - dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); - dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); - dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); - dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); - dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); - dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); - dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); - dataLoad.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); - dataLoad.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); - dataLoad.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); - dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("PL"))); - // 功率因数 - dataLoad.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); - dataLoad.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); - dataLoad.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); - dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + // 功率 有功+总+无功+无总+视在 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataLoad.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); + dataLoad.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); + dataLoad.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); - // 需量 - dataLoad.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); - dataLoad.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); - dataLoad.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); + // 功率因数 + dataLoad.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); + dataLoad.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); + dataLoad.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + // 需量 + dataLoad.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); + dataLoad.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); + dataLoad.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); + + } dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); dataLoad.setUpdateBy("system"); @@ -656,6 +765,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.AMMETER, "LOAD"); } private void dealFXXDailyChargeDate(String deviceId, String dataJson) { @@ -694,79 +805,84 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsAmmeterData dataLoad = new EmsAmmeterData(); // 更新时间 dataLoad.setDataUpdateTime(dataUpdateTime); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.AMMETER.getCode()); + if (CollectionUtils.isNotEmpty(pointMatchList)) { + saveDeviceData(pointMatchList, obj, dataLoad); + } else { + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); - // 电压+电流 - dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); - dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); - dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); - dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); - dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); - dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); - dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); - dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); - dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); - // 频率 - dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); + // 功率 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); - // 功率 - dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); - dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); - dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); - dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); - dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); - dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); - dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); - dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); - dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); - dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + // 二次相关数据 + dataLoad.setSecondaryAbLineVoltage(StringUtils.getBigDecimal(obj.get("ECABXDY"))); + dataLoad.setSecondaryAPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECAXDL"))); + dataLoad.setSecondaryAPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECAXDY"))); + dataLoad.setSecondaryAPowerFactor(StringUtils.getBigDecimal(obj.get("ECAXGLYS"))); + dataLoad.setSecondaryAApparentPower(StringUtils.getBigDecimal(obj.get("ECAXSZGL"))); + dataLoad.setSecondaryAReactivePower(StringUtils.getBigDecimal(obj.get("ECAXWGGL"))); + dataLoad.setSecondaryAActivePower(StringUtils.getBigDecimal(obj.get("ECAXYGGL"))); + dataLoad.setSecondaryBcLineVoltage(StringUtils.getBigDecimal(obj.get("ECBCXDY"))); + dataLoad.setSecondaryBPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECBXDL"))); + dataLoad.setSecondaryBPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECBXDY"))); + dataLoad.setSecondaryBPowerFactor(StringUtils.getBigDecimal(obj.get("ECBXGLYS"))); + dataLoad.setSecondaryBApparentPower(StringUtils.getBigDecimal(obj.get("ECBXSZGL"))); + dataLoad.setSecondaryBReactivePower(StringUtils.getBigDecimal(obj.get("ECBXWGGL"))); + dataLoad.setSecondaryBActivePower(StringUtils.getBigDecimal(obj.get("ECBXYGGL"))); + dataLoad.setSecondaryCaLineVoltage(StringUtils.getBigDecimal(obj.get("ECCAXDY"))); + dataLoad.setSecondaryCPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECCXDL"))); + dataLoad.setSecondaryCPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECCXDY"))); + dataLoad.setSecondaryCPowerFactor(StringUtils.getBigDecimal(obj.get("ECCXGLYS"))); + dataLoad.setSecondaryCApparentPower(StringUtils.getBigDecimal(obj.get("ECCXSZGL"))); + dataLoad.setSecondaryCReactivePower(StringUtils.getBigDecimal(obj.get("ECCXWGGL"))); + dataLoad.setSecondaryCActivePower(StringUtils.getBigDecimal(obj.get("ECCXYGGL"))); + dataLoad.setSecondaryGridFrequency(StringUtils.getBigDecimal(obj.get("ECDWPL"))); + dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXWGDN"))); + dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXYGDN"))); + dataLoad.setSecondaryTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ECZGLYS"))); + dataLoad.setSecondaryTotalApparentPower(StringUtils.getBigDecimal(obj.get("ECZSZFL"))); + dataLoad.setSecondaryTotalReactivePower(StringUtils.getBigDecimal(obj.get("ECZWGGL"))); + dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXWGDN"))); + dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXYGDN"))); + dataLoad.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ECZYGGL"))); - // 二次相关数据 - dataLoad.setSecondaryAbLineVoltage(StringUtils.getBigDecimal(obj.get("ECABXDY"))); - dataLoad.setSecondaryAPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECAXDL"))); - dataLoad.setSecondaryAPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECAXDY"))); - dataLoad.setSecondaryAPowerFactor(StringUtils.getBigDecimal(obj.get("ECAXGLYS"))); - dataLoad.setSecondaryAApparentPower(StringUtils.getBigDecimal(obj.get("ECAXSZGL"))); - dataLoad.setSecondaryAReactivePower(StringUtils.getBigDecimal(obj.get("ECAXWGGL"))); - dataLoad.setSecondaryAActivePower(StringUtils.getBigDecimal(obj.get("ECAXYGGL"))); - dataLoad.setSecondaryBcLineVoltage(StringUtils.getBigDecimal(obj.get("ECBCXDY"))); - dataLoad.setSecondaryBPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECBXDL"))); - dataLoad.setSecondaryBPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECBXDY"))); - dataLoad.setSecondaryBPowerFactor(StringUtils.getBigDecimal(obj.get("ECBXGLYS"))); - dataLoad.setSecondaryBApparentPower(StringUtils.getBigDecimal(obj.get("ECBXSZGL"))); - dataLoad.setSecondaryBReactivePower(StringUtils.getBigDecimal(obj.get("ECBXWGGL"))); - dataLoad.setSecondaryBActivePower(StringUtils.getBigDecimal(obj.get("ECBXYGGL"))); - dataLoad.setSecondaryCaLineVoltage(StringUtils.getBigDecimal(obj.get("ECCAXDY"))); - dataLoad.setSecondaryCPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECCXDL"))); - dataLoad.setSecondaryCPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECCXDY"))); - dataLoad.setSecondaryCPowerFactor(StringUtils.getBigDecimal(obj.get("ECCXGLYS"))); - dataLoad.setSecondaryCApparentPower(StringUtils.getBigDecimal(obj.get("ECCXSZGL"))); - dataLoad.setSecondaryCReactivePower(StringUtils.getBigDecimal(obj.get("ECCXWGGL"))); - dataLoad.setSecondaryCActivePower(StringUtils.getBigDecimal(obj.get("ECCXYGGL"))); - dataLoad.setSecondaryGridFrequency(StringUtils.getBigDecimal(obj.get("ECDWPL"))); - dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXWGDN"))); - dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXYGDN"))); - dataLoad.setSecondaryTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ECZGLYS"))); - dataLoad.setSecondaryTotalApparentPower(StringUtils.getBigDecimal(obj.get("ECZSZFL"))); - dataLoad.setSecondaryTotalReactivePower(StringUtils.getBigDecimal(obj.get("ECZWGGL"))); - dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXWGDN"))); - dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXYGDN"))); - dataLoad.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ECZYGGL"))); + // 需量 + dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("FXYGDN"))); + dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); + dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); - // 需量 - dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("FXWGDN"))); - dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("FXYGDN"))); - dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); - dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); - - // 正反向有功无功电能 - dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); - dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("FXYGDN"))); - dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); - dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + // 正反向有功无功电能 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("FXYGDN"))); + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + } dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); dataLoad.setUpdateBy("system"); @@ -778,6 +894,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); + saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.AMMETER, "METE"); + // 处理电表每日充放电数据 dealAmmeterDailyDate(obj, dataUpdateTime, lastAmmeterData); } diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java new file mode 100644 index 0000000..a61f8de --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java @@ -0,0 +1,180 @@ +package com.xzzn.ems.utils; + + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.xzzn.common.annotation.Excel; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.utils.DataUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.DevicePointMatchInfo; +import com.xzzn.ems.enums.DeviceMatchTable; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsPointMatchMapper; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import javax.annotation.PostConstruct; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.stereotype.Service; + +@Service +public class DevicePointMatchDataProcessor { + + private static final Log log = LogFactory.getLog(DevicePointMatchDataProcessor.class); + + private DevicePointMatchInfo devicePointMatchInfo; + + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; + @Autowired + private EmsPointMatchMapper emsPointMatchMapper; + + @Autowired + private RedisCache redisCache; + + /** + * 初始化加载设备匹配点位配置数据 + */ + @PostConstruct + public void init() + { + try { + ClassPathResource classPathResource = new ClassPathResource("biz/configData/DevicePointMatch.json"); + String configJson = DataUtils.getJSONFromFile(classPathResource.getInputStream()); + devicePointMatchInfo = JSONObject.parseObject(configJson, DevicePointMatchInfo.class); + log.info("初始化设备匹配点位配置数据成功。"+ JSON.toJSONString(devicePointMatchInfo)); + } catch (Exception ex) { + log.error("OcrMedicalStdHandler 设置mapping数据异常。", ex); + } + } + + /** + * 获取字段注解信息 + */ + public static String getFieldAnnotation(Class clazz, String filedName) + { + List tempFields = new ArrayList<>(); + tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); + for (Field field : tempFields) { + if (StringUtils.equals(filedName, field.getName()) && field.isAnnotationPresent(Excel.class)) + { + Excel column = field.getAnnotation(Excel.class); + return column.name(); + } + } + return null; + } + + public List getDevicePointMatch(String siteId, String deviceId, String deviceCategory) { +// List pointMatchList = new ArrayList<>(); +// EmsDevicesSetting devicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); +// if (devicesSetting == null) { +// log.info("未找到设备配置信息,siteId: " + siteId + ", deviceId: "+ deviceId); +// return pointMatchList; +// } + List pointMatchList = redisCache.getCacheList(getPointTacthCacheKey(siteId, deviceId, deviceCategory)); + if (CollectionUtils.isEmpty(pointMatchList)) { + pointMatchList = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceId, deviceCategory); + } + + return pointMatchList; + } + + public void saveDevicePointMatch(String siteId, String deviceId, DeviceMatchTable pointMatchType, String dataDevice) { +// EmsDevicesSetting devicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); +// if (devicesSetting == null) { +// return; +// } +// String deviceCategory = devicesSetting.getDeviceCategory(); + String deviceCategory = pointMatchType.getCode(); + Map devicePintointMtachInfo = this.getDevicePointMtachInfo(pointMatchType, dataDevice); + if (devicePintointMtachInfo.isEmpty()) { + return; + } + + try { + devicePintointMtachInfo.forEach((key, value) -> { + // 查询点位是否存在 + EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceId, deviceCategory, value); + if (!Objects.isNull(dbPoint)) { + return; + } + EmsPointMatch pointMatch = new EmsPointMatch(); + pointMatch.setSiteId(siteId); + pointMatch.setDeviceId(deviceId); + pointMatch.setDeviceCategory(deviceCategory); + pointMatch.setMatchTable(DeviceMatchTable.getMatchTableByCode(deviceCategory)); + pointMatch.setMatchField(StringUtils.toUnderScoreCase(key)); + pointMatch.setDataPoint(value); + pointMatch.setPointName(getFieldAnnotation(DeviceMatchTable.getClassByTable(pointMatch.getMatchTable()), StringUtils.toCamelCase(pointMatch.getMatchField()))); + pointMatch.setDataDevice(dataDevice); +// pointMatch.setDataPointName(""); +// pointMatch.setDataUnit(""); + pointMatch.setCreateBy("system"); + pointMatch.setUpdateBy("system"); + emsPointMatchMapper.insertEmsPointMatch(pointMatch); + }); + } catch (Exception e) { + log.info("保存设备点位匹配信息异常,siteId: " + siteId + ", deviceId: "+ deviceId + "异常信息:" + e.getMessage()); + } + } + + private Map getDevicePointMtachInfo(DeviceMatchTable pointMatchType, String dataDevice) { + switch (pointMatchType) { + case PCS: + return devicePointMatchInfo.getPcs(); + case BRANCH: + return devicePointMatchInfo.getBranch(); + case STACK: + return devicePointMatchInfo.getStack(); + case CLUSTER: + return devicePointMatchInfo.getCluster(); + case BATTERY: + return devicePointMatchInfo.getBattery(); + case AMMETER: + if (dataDevice.equals("LOAD")) { + return devicePointMatchInfo.getAmmeterLoad(); + } else { + return devicePointMatchInfo.getAmmeterMete(); + } + case COOLING: + return devicePointMatchInfo.getCooling(); + case DH: + return devicePointMatchInfo.getDh(); + case XF: + return devicePointMatchInfo.getXf(); + case BATTERY_GROUP: + return devicePointMatchInfo.getBatteryGroup(); + default: + return new HashMap<>(); + } + } + + /** + * 设置点位缓存key + * @param siteId + * @param deviceId + * @param deviceCategory + * @return 点位缓存key + */ + public static String getPointTacthCacheKey(String siteId, String deviceId, String deviceCategory) + { + return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId + "_" + deviceId; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java b/ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java deleted file mode 100644 index 49649f6..0000000 --- a/ems-system/src/main/java/com/xzzn/ems/utils/MatchTableUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.xzzn.ems.utils; - -import com.xzzn.common.annotation.Excel; -import com.xzzn.common.utils.StringUtils; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * 匹配表工具类 - */ -public class MatchTableUtils { - - /** - * 获取字段注解信息 - */ - public static String getFieldAnnotation(Class clazz, String filedName) - { - List tempFields = new ArrayList<>(); - tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); - for (Field field : tempFields) { - if (StringUtils.equals(filedName, field.getName()) && field.isAnnotationPresent(Excel.class)) - { - Excel column = field.getAnnotation(Excel.class); - return column.name(); - } - } - return null; - } - -} diff --git a/ems-system/src/main/resources/biz/configData/DevicePointMatch.json b/ems-system/src/main/resources/biz/configData/DevicePointMatch.json new file mode 100644 index 0000000..1ea40f8 --- /dev/null +++ b/ems-system/src/main/resources/biz/configData/DevicePointMatch.json @@ -0,0 +1,311 @@ +{ + "pcs": { + "totalActivePower": "YGGL", + "dailyAcChargeEnergy": "RCDL", + "totalReactivePower": "XTWGGL", + "dailyAcDischargeEnergy": "RFDL", + "totalApparentPower": "XTSZGL", + "totalPowerFactor": "GLYS", + "dcPower": "XTSZGL", + "totalAcChargeEnergy": "ZCDL", + "totalAcDischargeEnergy": "ZFDL", + "acChargeActivePower": "JLCCDYGGL", + "acCapacitiveReactivePower": "JLCRXWGGL", + "acDischargeActivePower": "JLCFDYGGL", + "acInductiveReactivePower": "JLCGXWGGL", + "maxCapacitivePowerCapacity": "ZDRXWGNL", + "maxInductivePowerCapacity": "ZDGXWGNL", + "maxChargePowerCapacity": "ZDKCGL", + "maxDischargePowerCapacity": "ZDKFGL", + + "sysUCurrent": "XTSCUXDL", + "sysVCurrent": "XTSCVXDL", + "sysWCurrent": "XTSCWXDL", + + "uTemperature": "DY1UXIGBTWD", + "vTemperature": "DY1VXIGBTWD", + "wTemperature": "DY1WXIGBTWD" + + }, + "branch": { + "dcPower": "ZLGL", + "dcVoltage": "ZLDY", + "dcCurrent": "ZLDL", + "gridUVoltage": "DWUXDY", + "gridVVoltage": "DWVXDY", + "gridWVoltage": "DWWXDY", + "outputUCurrent": "SCUXDL", + "outputVCurrent": "SCVXDL", + "outputWCurrent": "SCWXDL", + "apparentPower": "SZGL", + "activePower": "YGGL", + "reactivePower": "WGGL", + "powerFactor": "GLYS", + "frequency": "PL", + "internalTemp": "DY1WD", + "uIgbtTemp": "UXIGBTWD", + "vIgbtTemp": "VXIGBTWD", + "wIgbtTemp": "WXIGBTWD", + "availablePower": "KYGL", + "totalLoadRatio": "ZFZB", + "acLeakageCurrent": "JLLDL", + "insulationResistance": "JYZK" + + }, + "stack": { + "operationStatus": "DCZT", + "stackVoltage": "DCDDY", + "stackCurrent": "DCDDL", + "stackSoc": "DCDSOC", + "stackSoh": "DCDSOH", + + "maxCellVoltage": "ZGDCDY", + "maxVoltageGroupId": "ZGDCDYZH", + "maxVoltageCellId": "ZGDCDYZHDH", + "minCellVoltage": "ZDDCDY", + "minVoltageGroupId": "ZDDCDYZH", + "minVoltageCellId": "ZDDCDYZHDH", + + "maxCellTemp": "ZGDCWD", + "maxTempGroupId": "ZGDCWDZH", + "maxTempCellId": "ZGDCWDZHDH", + "minCellTemp": "ZDDCWD", + "minTempGroupId": "ZDDCWDZH", + "minTempCellId": "ZDDCWDZHDH", + + "totalChargeCapacity": "DLJCDDL", + "totalDischargeCapacity": "DLCFDDL", + "sessionChargeCapacity": "DDCLJCDDL", + "sessionDischargeCapacity": "DDCLJFDDL", + "availableChargeCapacity": "DKCDL", + "availableDischargeCapacity": "DKFDL", + + "remainingDischargeTime": "KYFDSJ", + "remainingChargeTime": "KYCDSJ", + + "maxDischargePower": "YXZDFDGL", + "maxChargePower": "YXZDCDGL", + "maxDischargeCurrent": "YXZDFDDL", + "maxChargeCurrent": "YXZDCDDL", + + "dailyDischargeCycles": "DTFDCS", + "dailyChargeCycles": "DTCDCS", + "dailyDischargeCapacity": "DTFDDL", + "dailyChargeCapacity": "DTCDDL", + + "operatingTemp": "YXWD", + "bmsStatus": "BMSDDQZT", + "bmsChargeStatus": "BMSCFDZT", + "stackInsulationResistance": "DCDJYDZ" + }, + "cluster": { + "chargeableCapacity": "KCDL", + "clusterVoltage": "ZDY", + "clusterCurrent": "ZDL", + "totalChargedCapacity": "LJCDDL", + "dischargeableCapacity": "KFDL", + "totalDischargedCapacity": "LJFDDL", + "soh": "ZSOH", + "averageTemperature": "MKWD", + "insulationResistance": "ZJYDZ", + "currentSoc": "ZSOC", + "maxAllowedChargePower": "YXCDZDGL", + "maxAllowedDischargePower": "YXFDZDGL", + "maxAllowedChargeVoltage": "YXCDZDDY", + "maxAllowedDischargeVoltage": "YXFDZDDY", + "maxAllowedChargeCurrent": "YXCDZDDL", + "maxAllowedDischargeCurrent": "YXFDZDDL", + "batteryPackVoltage": "ZDY", + "batteryPackCurrent": "ZDL", + "batteryPackTemp": "MKWD", + "batteryPackSoc": "ZSOC", + "batteryPackSoh": "ZSOH", + "batteryPackInsulationResistance": "ZJYDZ", + "avgCellVoltage": "PJDTDY", + "avgCellTemp": "PJDTWD", + "maxCellVoltage": "ZGDTDY", + "minCellVoltage": "ZDDTDY", + "maxCellTemp": "ZGDTWD", + "minCellTemp": "ZDDTWD", + "maxCellSoc": "ZGDTSOC", + "minCellSoc": "ZDDTSOC", + "maxCellSoh": "ZGDTSOH", + "minCellSoh": "ZDDTSOH", + "totalChargeEnergy": "DCLJCDDL", + "totalDischargeEnergy": "DCLJFDDL", + + "maxCellVoltageId": "ZGDTDYDYD", + "minCellVoltageId": "ZDDTDYDYD", + "maxCellTempId": "ZGDTWDDYD", + "minCellTempId": "ZDDTWDDYD", + "maxCellSocId": "ZGDTSOCDYD", + "minCellSocId": "ZDDTSOCDYD", + "maxCellSohId": "ZGDTSOHDYD", + "minCellSohId": "ZDDTSOHDYD" + + }, + "battery": { + "soc": "DTSOC", + "soh": "DTSOH", + "temperature": "DTWD", + "voltage": "DTDY" + + }, + "ammeterLoad": { + "currentCombActiveTotal": "DQZHYGZDN", + "currentCombActivePeak": "DQZHYGJDN", + "currentCombActiveHigh": "DQZHYGFDN", + "currentCombActiveFlat": "DQZHYGPDN", + "currentCombActiveValley": "DQZHYGGDN", + + "currentForwardActiveTotal": "DQZXYGZDN", + "currentForwardActivePeak": "DQZXYGJDN", + "currentForwardActiveHigh": "DQZXYGFDN", + "currentForwardActiveFlat": "DQZXYGPDN", + "currentForwardActiveValley": "DQZXYGGDN", + + "currentReverseActiveTotal": "DQFXYGZDN", + "currentReverseActivePeak": "DQFXYGJDN", + "currentReverseActiveHigh": "DQFXYGFDN", + "currentReverseActiveFlat": "DQFXYGPDN", + "currentReverseActiveValley": "DQFXYGGDN", + + "currentCombReactiveTotal": "DQZHWGZDN", + "currentCombReactivePeak": "DQZHWGJDN", + "currentCombReactiveHigh": "DQZHWGFDN", + "currentCombReactiveFlat": "DQZHWGPDN", + "currentCombReactiveValley": "DQZHWGGDN", + + "currentForwardReactiveTotal": "DQZXWGZDN", + "currentForwardReactivePeak": "DQZXWGJDN", + "currentForwardReactiveHigh": "DQZXWGFDN", + "currentForwardReactiveFlat": "DQZXWGPDN", + "currentForwardReactiveValley": "DQZXWGGDN", + + "currentReverseReactiveTotal": "DQFXWGZDN", + "currentReverseReactivePeak": "DQFXWGJDN", + "currentReverseReactiveHigh": "DQFXWGFDN", + "currentReverseReactiveFlat": "DQFXWGPDN", + "currentReverseReactiveValley": "DQFXWGGDN", + + "phaseAVoltage": "AXDY", + "phaseBVoltage": "BXDY", + "phaseCVoltage": "CXDY", + "phaseACurrent": "AXDL", + "phaseBCurrent": "BXDL", + "phaseCCurrent": "CXDL", + + "abLineVoltage": "ABXDY", + "cbLineVoltage": "CBXDY", + "acLineVoltage": "ACXDY", + + "frequency": "PL", + + "phaseAActivePower": "AXYGGL", + "phaseBActivePower": "BXYGGL", + "phaseCActivePower": "CXYGGL", + "totalActivePower": "ZYGGL", + "phaseAReactivePower": "AXWGGL", + "phaseBReactivePower": "BXWGGL", + "phaseCReactivePower": "CXWGGL", + "totalReactivePower": "ZWGGL", + "phaseAApparentPower": "AXSZGL", + "phaseBApparentPower": "BXSZGL", + "phaseCApparentPower": "CXSZGL", + "totalApparentPower": "ZSZGL", + + "phaseAPowerFactor": "AXGLYS", + "phaseBPowerFactor": "BXGLYS", + "phaseCPowerFactor": "CXGLYS", + "totalPowerFactor": "ZGLYS", + + "forwardAcMaxDemand": "ZXYGZDXL", + "reverseAcMaxDemand": "FXYGZDXL", + "dailyForwardMaxDemand": "DRZXYGZDXL" + + }, + "ammeterMete": { + "phaseAVoltage": "AXDY", + "phaseBVoltage": "BXDY", + "phaseCVoltage": "CXDY", + "phaseACurrent": "AXDL", + "phaseBCurrent": "BXDL", + "phaseCCurrent": "CXDL", + + "abLineVoltage": "ABXDY", + "cbLineVoltage": "BCXDY", + "acLineVoltage": "CAXDY", + + "frequency": "DWPL", + + "phaseAActivePower": "AXYGGL", + "phaseBActivePower": "BXYGGL", + "phaseCActivePower": "CXYGGL", + "totalActivePower": "ZYGGL", + "phaseAReactivePower": "AXWGGL", + "phaseBReactivePower": "BXWGGL", + "phaseCReactivePower": "CXWGGL", + "totalReactivePower": "ZWGGL", + + "totalApparentPower": "ZSZGL", + "totalPowerFactor": "ZGLYS", + + "secondaryAbLineVoltage": "ECABXDY", + "secondaryAPhaseCurrent": "ECAXDL", + "secondaryAPhaseVoltage": "ECAXDY", + "secondaryAPowerFactor": "ECAXGLYS", + "secondaryAApparentPower": "ECAXSZGL", + "secondaryAReactivePower": "ECAXWGGL", + "secondaryAActivePower": "ECAXYGGL", + "secondaryBcLineVoltage": "ECBCXDY", + "secondaryBPhaseCurrent": "ECBXDL", + "secondaryBPhaseVoltage": "ECBXDY", + "secondaryBPowerFactor": "ECBXGLYS", + "secondaryBApparentPower": "ECBXSZGL", + "secondaryBReactivePower": "ECBXWGGL", + "secondaryBActivePower": "ECBXYGGL", + "secondaryCaLineVoltage": "ECCAXDY", + "secondaryCPhaseCurrent": "ECCXDL", + "secondaryCPhaseVoltage": "ECCXDY", + "secondaryCPowerFactor": "ECCXGLYS", + "secondaryCApparentPower": "ECCXSZGL", + "secondaryCReactivePower": "ECCXWGGL", + "secondaryCActivePower": "ECCXYGGL", + "secondaryGridFrequency": "ECDWPL", + "secondaryReverseReactiveEnergy": "ECFXWGDN", + "secondaryNegativeActiveEnergy": "ECFXYGDN", + "secondaryTotalPowerFactor": "ECZGLYS", + "secondaryTotalApparentPower": "ECZSZFL", + "secondaryTotalReactivePower": "ECZWGGL", + "secondaryPositiveReactiveEnergy": "ECZXWGDN", + "secondaryPositiveActiveEnergy": "ECZXYGDN", + "secondaryTotalActivePower": "ECZYGGL", + + "reverseReactiveEnergyEqMinus": "FXWGDN", + "reverseActiveEnergyEpMinus": "FXYGDN", + "positiveReactiveEnergyEqPlus": "ZXWGDN", + "positiveActiveEnergyEpPlus": "ZXYGDN", + + "currentForwardActiveTotal": "ZXYGDN", + "currentReverseActiveTotal": "FXYGDN", + "currentForwardReactiveTotal": "ZXWGDN", + "currentReverseReactiveTotal": "FXWGDN" + + }, + "dh": { + "humidity": "SD3", + "temperature": "WD3" + + }, + "cooling": { + "gsTemp": "GSWD", + "hsTemp": "HSWD", + "gsPressure": "GSYL", + "hsPressure": "HSYL", + "lysTemp": "LYSWD", + "vb01Kd": "VB1KD", + "vb02Kd": "VB2KD" + + } + +} \ No newline at end of file -- 2.49.0 From c068e7d4ab4e9aa044eda8e011065c5bf124f9d9 Mon Sep 17 00:00:00 2001 From: zq Date: Sun, 30 Nov 2025 10:26:03 +0800 Subject: [PATCH 222/336] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=99=E7=82=B9-?= =?UTF-8?q?=E7=94=B5=E5=8A=A8=E6=89=80=E5=86=85=E9=83=A8=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=9F=A5=E8=AF=A2=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/ems/EmsBatteryClusterMapper.xml | 12 ++++++++---- .../mapper/ems/EmsBatteryStackMapper.xml | 18 +++++++++++------- .../resources/mapper/ems/EmsPcsDataMapper.xml | 9 ++++++--- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 90a8074..6268281 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -331,10 +331,14 @@ DATE_FORMAT(t.create_time, '%Y-%m-%d') AS dateDay, DATE_FORMAT(t.create_time, '%H:00:00') AS createDate from ems_battery_cluster t - where t.site_id = #{siteId} - AND Date(t.create_time) between #{startDate} and #{endDate} - GROUP BY t.site_id,dateDay,createDate - order by dateDay,createDate + WHERE t.site_id = #{siteId} + AND t.create_time >= #{startDate} + AND t.create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) + GROUP BY t.site_id, + DATE_FORMAT(t.create_time, '%Y-%m-%d'), + DATE_FORMAT(t.create_time, '%H:00:00') + ORDER BY dateDay, createDate + select t.site_id, - round(avg(t.avg_cell_temp)) as batteryTemp, + round(avg(t.avg_temperature)) as batteryTemp, DATE_FORMAT(t.create_time, '%Y-%m-%d') AS dateDay, - DATE_FORMAT(t.create_time, '%H:00:00') AS createDate + DATE_FORMAT(t.create_time, '%H:00:00') AS createDate from ems_battery_stack t - where t.site_id = #{siteId} - AND Date(t.create_time) between #{startDate} and #{endDate} - GROUP BY t.site_id,dateDay,createDate - order by dateDay,createDate + WHERE t.site_id = #{siteId} + AND t.create_time >= #{startDate} + AND t.create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) + GROUP BY t.site_id, + DATE_FORMAT(t.create_time, '%Y-%m-%d'), + DATE_FORMAT(t.create_time, '%H:00:00') + ORDER BY dateDay, createDate @@ -499,7 +502,8 @@ DATE_FORMAT(t.create_time, '%H:00:00') AS createDate from ems_battery_stack t where t.site_id = #{siteId} - AND Date(t.create_time) between #{startDate} and #{endDate} + AND t.create_time >= #{startDate} + AND t.create_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) GROUP BY t.site_id,dateDay,createDate order by dateDay,createDate diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 6359898..1d064cb 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -465,7 +465,8 @@ DATE_FORMAT(t.data_update_time, '%H:%i:00') AS createDate FROM ems_pcs_data t WHERE t.site_id = #{siteId} - AND Date(t.data_update_time) between #{startDate} and #{endDate} + AND t.data_update_time >= #{startDate} + AND t.data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) AND minute(t.data_update_time) = 0 GROUP BY t.site_id, deviceId,pcsTotalActPower,pcsTotalReactivePower,dateDay,createDate ORDER BY dateDay,createDate @@ -587,7 +588,8 @@ from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%Y-%m-%d %H:00:00') AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p WHERE p.site_id = #{siteId} - AND Date(p.data_update_time) between #{startDate} and #{endDate} + AND p.data_update_time >= #{startDate} + AND p.data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) AND minute(p.data_update_time) = 0 GROUP BY p.site_id, p.device_id,dateHour ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id @@ -610,7 +612,8 @@ from ( SELECT p.site_id, p.device_id,DATE_FORMAT(p.data_update_time, '%Y-%m-%d %H:00:00') AS dateHour,MAX(p.data_update_time) as max_update_time FROM ems_pcs_data p WHERE p.site_id = #{siteId} - AND Date(p.data_update_time) between #{startDate} and #{endDate} + AND p.data_update_time >= #{startDate} + AND p.data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) AND minute(p.data_update_time) = 0 GROUP BY p.site_id, p.device_id,dateHour ) latest inner join ems_pcs_data t ON latest.site_id = t.site_id -- 2.49.0 From 3735c4f4d8d7c8283699e5def95d1d99b651f446 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 5 Dec 2025 08:46:19 +0800 Subject: [PATCH 223/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E8=AE=BE=E5=A4=87=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E8=A7=A3=E6=9E=90=EF=BC=9B=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E6=B8=85=E5=8D=95=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsStatisticalReportController.java | 11 + .../controller/ems/MqttMessageController.java | 89 +- .../common/constant/RedisKeyConstants.java | 5 + .../java/com/xzzn/common/enums/PointType.java | 45 + .../com/xzzn/common/enums/SiteDevice.java | 57 + .../xzzn/common/enums/TopicHandleType.java | 39 + .../xzzn/ems/domain/EmsMqttTopicConfig.java | 4 +- .../com/xzzn/ems/domain/EmsPointMatch.java | 16 +- .../domain/vo/AmmeterRevenueStatisListVo.java | 131 ++ .../ems/domain/vo/DevicePointMatchVo.java | 13 + .../ems/domain/vo/ImportPointDataRequest.java | 11 - .../xzzn/ems/domain/vo/PointDataRequest.java | 10 + .../ems/domain/vo/PointQueryResponse.java | 2 +- .../com/xzzn/ems/enums/DeviceMatchTable.java | 17 +- .../mapper/EmsEnergyPriceConfigMapper.java | 4 + .../ems/mapper/EmsMqttTopicConfigMapper.java | 2 + .../xzzn/ems/mapper/EmsPointMatchMapper.java | 10 +- .../service/IDeviceDataProcessService.java | 8 + .../ems/service/IEmsStatsReportService.java | 2 + .../impl/DeviceDataProcessServiceImpl.java | 1604 +++++++++++++++++ .../impl/EmsDeviceSettingServiceImpl.java | 18 +- .../impl/EmsPointMatchServiceImpl.java | 26 +- .../impl/EmsStatsReportServiceImpl.java | 39 + .../impl/FXXDataProcessServiceImpl.java | 662 +++---- .../utils/DevicePointMatchDataProcessor.java | 31 +- .../mapper/ems/EmsEnergyPriceConfigMapper.xml | 14 + .../mapper/ems/EmsMqttTopicConfigMapper.xml | 5 + .../mapper/ems/EmsPointMatchMapper.xml | 18 +- 28 files changed, 2441 insertions(+), 452 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/PointType.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/TopicHandleType.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterRevenueStatisListVo.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/IDeviceDataProcessService.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java index 230b980..5930831 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsStatisticalReportController.java @@ -118,6 +118,17 @@ public class EmsStatisticalReportController extends BaseController return getDataTable(dataList); } + /** + * 概率统计-电表收益报表 + */ + @GetMapping("/getAmmeterRevenueData") + public TableDataInfo getAmmeterRevenueData(StatisAmmeterDateRequest requestVo) + { + startPage(); + List dataList = ieEmsStatsReportService.getAmmeterRevenueDataResult(requestVo); + return getDataTable(dataList); + } + /** * 概率统计-功率曲线 */ diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index afdaf19..cf7c641 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -1,6 +1,9 @@ package com.xzzn.web.controller.ems; import com.alibaba.fastjson2.JSON; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.TopicHandleType; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsMqttTopicConfig; import com.xzzn.ems.domain.MqttSyncLog; @@ -39,6 +42,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IDDSDataProcessService dDSDataProcessService; + @Autowired + private IDeviceDataProcessService deviceDataProcessService; + @Autowired private IFXXAlarmDataProcessService fXXAlarmDataProcessService; @Autowired @@ -48,6 +54,9 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { @Autowired private IMqttSyncLogService iMqttSyncLogService; + @Autowired + private RedisCache redisCache; + @Autowired public MqttMessageController(MqttLifecycleManager mqttLifecycleManager) { this.mqttLifecycleManager = mqttLifecycleManager; @@ -75,7 +84,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { qos = 1; } - IMqttMessageListener listener = getMqttListenerByTopic(topic, topicConfig.getId()); + IMqttMessageListener listener = getMqttListenerByTopic(topic, topicConfig.getHandleType()); subscribe(topic, qos, listener); } // 订阅奉贤系统状态主题 @@ -93,23 +102,28 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { } - private IMqttMessageListener getMqttListenerByTopic(String topic, Long id) { - if (topic.contains("ALARM_UP")) { - return this::handleAlarmData; - } else if (topic.endsWith("_01")) { - return this::handleSystemStatus; - } else if (topic.contains("STRATEGY")) { - return this::handleStrategyData; - } else if (topic.equals("FAULT_PROTECTION_PLAN_UP")) { - return this::handleFaultProtPlanData; - } else if (topic.equals("FAULT_ALARM_RECORD_UP")) { - return this::handleFaultAlarmData; - } else if (topic.equals("FAULT_PLAN_ISSUE_UP")) { - return this::handleFaultPlanIssueData; - } else if (topic.equals("DEVICE_CHANGE_LOG_UP")) { - return this::handleDeviceChangeLogData; - } else { - return this::handleDeviceData; + private IMqttMessageListener getMqttListenerByTopic(String topic, String handleType) { + TopicHandleType topicHandleType = TopicHandleType.getEnumByCode(handleType); + switch (topicHandleType) { + case DEVICE: + return this::handleDeviceData; + case DEVICE_ALARM: + return this::handleAlarmData; + case STRATEGY: + if (topic.equals("FAULT_PROTECTION_PLAN_UP")) { + return this::handleFaultProtPlanData; + } else if (topic.equals("FAULT_ALARM_RECORD_UP")) { + return this::handleFaultAlarmData; + } else if (topic.equals("FAULT_PLAN_ISSUE_UP")) { + return this::handleFaultPlanIssueData; + } else if (topic.equals("DEVICE_CHANGE_LOG_UP")) { + return this::handleDeviceChangeLogData; + } else { + return this::handleStrategyData; + } + default: + log.warn("Unknown handle type: " + handleType + ", using default handler"); + return this::handleSystemStatus; } } @@ -129,18 +143,19 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { // 处理设备数据 private void handleDeviceData(String topic, MqttMessage message) { String payload = new String(message.getPayload()); - System.out.println("[DEVICE] data: " + payload); + log.info("[DEVICE] data: " + payload); try { // 业务处理逻辑 - if (topic.startsWith("021_DDS")) { - dDSDataProcessService.handleDdsData(payload); - } else if (topic.startsWith("021_FXX")) { - fXXDataProcessService.handleFxData(payload); - } +// if (topic.startsWith("021_DDS")) { +// dDSDataProcessService.handleDdsData(payload); +// } else if (topic.startsWith("021_FXX")) { +// fXXDataProcessService.handleFxData(payload); +// } + deviceDataProcessService.handleDeviceData(payload, getSiteIdByTopic(topic)); - emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + emsMqttMessageService.insertMqttOriginalMessage(topic, payload); } catch (Exception e) { - log.error("Failed to process system status message: " + e.getMessage(), e); + log.error("Failed to process device data message: " + e.getMessage(), e); } } @@ -151,17 +166,29 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { System.out.println("[DEVICE] data: " + payload); try { // 业务处理逻辑 - if (topic.startsWith("021_FXX")) { - fXXAlarmDataProcessService.handleFxAlarmData(payload); - } +// if (topic.startsWith("021_FXX")) { +// fXXAlarmDataProcessService.handleFxAlarmData(payload); +// } + deviceDataProcessService.handleAlarmData(payload, getSiteIdByTopic(topic)); - emsMqttMessageService.insertMqttOriginalMessage(topic,payload); + emsMqttMessageService.insertMqttOriginalMessage(topic, payload); } catch (Exception e) { - log.error("Failed to process alarm data message: " + e.getMessage(), e); + log.error("Failed to process device alarm data message: " + e.getMessage(), e); } } + private String getSiteIdByTopic(String topic) { + String siteId = redisCache.getCacheObject(RedisKeyConstants.SITE_ID + topic); + if (StringUtils.isEmpty(siteId)) { + EmsMqttTopicConfig topicConfig = emsMqttTopicConfigMapper.selectOneByTopic(topic); + siteId = topicConfig.getSiteId(); + redisCache.setCacheObject(RedisKeyConstants.SITE_ID + topic, siteId); + } + log.info("当前处理数据站点:" + siteId + ",topic: " + topic); + return siteId; + } + // 处理运行策略数据:云端-本地 private void handleStrategyData(String topic, MqttMessage message) { String payload = new String(message.getPayload()); diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index dc83d4f..78b682a 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -67,6 +67,11 @@ public class RedisKeyConstants */ public static final String POINT_MATCH = "POINT_MATCH_"; + /** + * topic对应站点ID redis key + */ + public static final String SITE_ID = "SITE_ID_"; + /** * 存放单个设备同步过来的原始数据-最晚一次数据 */ diff --git a/ems-common/src/main/java/com/xzzn/common/enums/PointType.java b/ems-common/src/main/java/com/xzzn/common/enums/PointType.java new file mode 100644 index 0000000..fe6da19 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/PointType.java @@ -0,0 +1,45 @@ +package com.xzzn.common.enums; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * 设备点位类型 + */ +public enum PointType +{ + YES(1, "是"), + NO(0, "否"); + + private final Integer code; + private final String info; + + private static final Map CODE_NAME_MAP = new HashMap<>(PointType.values().length); + + static { + Arrays.stream(PointType.values()).forEach(record -> { + CODE_NAME_MAP.put(record.code, record.info); + }); + } + + PointType(Integer code, String info) + { + this.code = code; + this.info = info; + } + + public String getInfoByCode(Integer code) { + return CODE_NAME_MAP.get(code); + } + + public Integer getCode() + { + return code; + } + + public String getInfo() + { + return info; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java b/ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java new file mode 100644 index 0000000..3725068 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java @@ -0,0 +1,57 @@ +package com.xzzn.common.enums; + +/** + * + */ +public enum SiteDevice +{ + /** + * 电池堆 + */ + BMSD, + + /** + * 电池簇 + */ + BMSC, + + /** + * PCS设备 + */ + PCS, + + /** + * 电表-总表 + */ + LOAD, + + /** + * 电表-光伏电表 + */ + METEGF, + + /** + * 电表-储能电表 + */ + METE, + + /** + * 电表-储能电表 + */ + METE0, + + /** + * 动环 + */ + donghuan, + + /** + * 动环 + */ + DH, + + /** + * 中水冷却 + */ + ZSLQ +} diff --git a/ems-common/src/main/java/com/xzzn/common/enums/TopicHandleType.java b/ems-common/src/main/java/com/xzzn/common/enums/TopicHandleType.java new file mode 100644 index 0000000..deedc64 --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/TopicHandleType.java @@ -0,0 +1,39 @@ +package com.xzzn.common.enums; + +/** + * MQTT主题处理类型未知类型 + */ +public enum TopicHandleType { + DEVICE("DEVICE", "设备数据"), + DEVICE_ALARM("DEVICE_ALARM", "设备告警数据"), + STRATEGY("STRATEGY", "策略数据"), + SYSTEM("SYSTEM", "系统数据"), + ; + + private final String code; + private final String info; + + TopicHandleType(String code, String info) { + this.code = code; + this.info = info; + } + + public String getName() { + return code; + } + + public String getInfo() { + return info; + } + + // 根据名称查找枚举 + public static TopicHandleType getEnumByCode(String code) { + for (TopicHandleType type : values()) { + if (type.getName().equals(code)) { + return type; + } + } + // 默认返回SYSTEM + return SYSTEM; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java index 33b36a2..db6a9bb 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsMqttTopicConfig.java @@ -33,8 +33,8 @@ public class EmsMqttTopicConfig extends BaseEntity @Excel(name = "对应方法") private String handleMethod; - /** 处理器类型:(device=设备数据,system=系统状态,alarm=告警数据等) */ - @Excel(name = "处理器类型:(device=设备数据,system=系统状态,alarm=告警数据等)") + /** 处理器类型:(DEVICE=设备数据,SYSTEM=系统状态,ALARM=告警数据等) */ + @Excel(name = "处理器类型:(DEVICE=设备数据,SYSTEM=系统状态,ALARM=告警数据等)") private String handleType; /** 站点id */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java index 1abe5e0..bca5c30 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -70,9 +70,9 @@ public class EmsPointMatch extends BaseEntity @Excel(name = "点位是否需要区分多设备:0-不需要 1-需要") private Long needDiffDeviceId; - /** 设备唯一标识符 */ - @Excel(name = "设备唯一标识符") - private String deviceId; + /** 是否告警点位 */ + @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是") + private Integer isAlarm; public void setId(Long id) { @@ -212,12 +212,12 @@ public class EmsPointMatch extends BaseEntity return needDiffDeviceId; } - public String getDeviceId() { - return deviceId; + public Integer getIsAlarm() { + return isAlarm; } - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; + public void setIsAlarm(Integer isAlarm) { + this.isAlarm = isAlarm; } @Override @@ -242,7 +242,7 @@ public class EmsPointMatch extends BaseEntity .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("remark", getRemark()) - .append("deviceId", getDeviceId()) + .append("isAlarm", getIsAlarm()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterRevenueStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterRevenueStatisListVo.java new file mode 100644 index 0000000..614f5a7 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterRevenueStatisListVo.java @@ -0,0 +1,131 @@ +package com.xzzn.ems.domain.vo; + +import java.math.BigDecimal; + +/** + * 电表收益数据 + */ +public class AmmeterRevenueStatisListVo { + + + /** 类别 */ + private String dataTime; + + /** 组合有功-总 */ + private BigDecimal activeTotalPrice = BigDecimal.ZERO; + + /** 组合有功-尖 */ + private BigDecimal activePeakPrice = BigDecimal.ZERO; + + /** 组合有功-峰 */ + private BigDecimal activeHighPrice = BigDecimal.ZERO; + + /** 组合有功-平 */ + private BigDecimal activeFlatPrice = BigDecimal.ZERO; + + /** 组合有功-谷 */ + private BigDecimal activeValleyPrice = BigDecimal.ZERO; + + /** 组合无功-总 */ + private BigDecimal reActiveTotalPrice = BigDecimal.ZERO; + + /** 组合无功-尖 */ + private BigDecimal reActivePeakPrice = BigDecimal.ZERO; + + /** 组合无功-峰 */ + private BigDecimal reActiveHighPrice = BigDecimal.ZERO; + + /** 组合无功-平 */ + private BigDecimal reActiveFlatPrice = BigDecimal.ZERO; + + /** 组合无功-谷 */ + private BigDecimal reActiveValleyPrice = BigDecimal.ZERO; + + public String getDataTime() { + return dataTime; + } + + public void setDataTime(String dataTime) { + this.dataTime = dataTime; + } + + public BigDecimal getActiveTotalPrice() { + return activeTotalPrice; + } + + public void setActiveTotalPrice(BigDecimal activeTotalPrice) { + this.activeTotalPrice = activeTotalPrice; + } + + public BigDecimal getActivePeakPrice() { + return activePeakPrice; + } + + public void setActivePeakPrice(BigDecimal activePeakPrice) { + this.activePeakPrice = activePeakPrice; + } + + public BigDecimal getActiveHighPrice() { + return activeHighPrice; + } + + public void setActiveHighPrice(BigDecimal activeHighPrice) { + this.activeHighPrice = activeHighPrice; + } + + public BigDecimal getActiveFlatPrice() { + return activeFlatPrice; + } + + public void setActiveFlatPrice(BigDecimal activeFlatPrice) { + this.activeFlatPrice = activeFlatPrice; + } + + public BigDecimal getActiveValleyPrice() { + return activeValleyPrice; + } + + public void setActiveValleyPrice(BigDecimal activeValleyPrice) { + this.activeValleyPrice = activeValleyPrice; + } + + public BigDecimal getReActiveTotalPrice() { + return reActiveTotalPrice; + } + + public void setReActiveTotalPrice(BigDecimal reActiveTotalPrice) { + this.reActiveTotalPrice = reActiveTotalPrice; + } + + public BigDecimal getReActivePeakPrice() { + return reActivePeakPrice; + } + + public void setReActivePeakPrice(BigDecimal reActivePeakPrice) { + this.reActivePeakPrice = reActivePeakPrice; + } + + public BigDecimal getReActiveHighPrice() { + return reActiveHighPrice; + } + + public void setReActiveHighPrice(BigDecimal reActiveHighPrice) { + this.reActiveHighPrice = reActiveHighPrice; + } + + public BigDecimal getReActiveFlatPrice() { + return reActiveFlatPrice; + } + + public void setReActiveFlatPrice(BigDecimal reActiveFlatPrice) { + this.reActiveFlatPrice = reActiveFlatPrice; + } + + public BigDecimal getReActiveValleyPrice() { + return reActiveValleyPrice; + } + + public void setReActiveValleyPrice(BigDecimal reActiveValleyPrice) { + this.reActiveValleyPrice = reActiveValleyPrice; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java index d8903d7..b69fdb7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java @@ -25,6 +25,10 @@ public class DevicePointMatchVo implements Serializable { /** 数据单位 */ @Excel(name = "数据单位") private String dataUnit; + + /** 是否告警点位 */ + @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是") + private String isAlarm; // // /** 数据点位来源设备 */ // @Excel(name = "数据点位来源设备") @@ -78,6 +82,15 @@ public class DevicePointMatchVo implements Serializable { // this.dataDevice = dataDevice; // } + + public String getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(String isAlarm) { + this.isAlarm = isAlarm; + } + public String getIpAddress() { return ipAddress; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java index d5a6416..3406156 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java @@ -17,9 +17,6 @@ public class ImportPointDataRequest { /** 站点id */ @NotBlank(message = "站点ID不能为空") private String siteId; - /** 设备id */ - @NotBlank(message = "设备ID不能为空") - private String deviceId; /** 设备类型 */ @NotBlank(message = "设备类型不能为空") private String deviceCategory; @@ -35,14 +32,6 @@ public class ImportPointDataRequest { this.siteId = siteId; } - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - public String getDeviceCategory() { return deviceCategory; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java index 994b54a..dcfffc4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataRequest.java @@ -35,6 +35,16 @@ public class PointDataRequest { private String ipAddress; /** modbus端口 */ private Integer ipPort; + /** 是否告警点位 */ + private Integer isAlarm; + + public Integer getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(Integer isAlarm) { + this.isAlarm = isAlarm; + } public String getIpAddress() { return ipAddress; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java index 18e72e2..ec8b249 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointQueryResponse.java @@ -43,7 +43,7 @@ public class PointQueryResponse private String dataUnit; /** 地址 */ - @Excel(name = "地址") + @Excel(name = "寄存器地址") private String ipAddress; /** 端口 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java b/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java index 835a8ca..1f2164b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java +++ b/ems-system/src/main/java/com/xzzn/ems/enums/DeviceMatchTable.java @@ -5,10 +5,14 @@ import com.xzzn.ems.domain.EmsBatteryCluster; import com.xzzn.ems.domain.EmsBatteryData; import com.xzzn.ems.domain.EmsBatteryGroup; import com.xzzn.ems.domain.EmsBatteryStack; +import com.xzzn.ems.domain.EmsClusterAlarmData; +import com.xzzn.ems.domain.EmsCoolingAlarmData; import com.xzzn.ems.domain.EmsCoolingData; import com.xzzn.ems.domain.EmsDhData; +import com.xzzn.ems.domain.EmsPcsAlarmData; import com.xzzn.ems.domain.EmsPcsBranchData; import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.domain.EmsStackAlarmData; import com.xzzn.ems.domain.EmsXfData; import java.util.HashMap; @@ -28,7 +32,14 @@ public enum DeviceMatchTable COOLING("COOLING", "ems_cooling_data", EmsCoolingData.class), DH("DH", "ems_dh_data", EmsDhData.class), XF("XF", "ems_xf_data", EmsXfData.class), - BATTERY_GROUP("BATTERY_GROUP", "ems_battery_group", EmsBatteryGroup.class); + BATTERY_GROUP("BATTERY_GROUP", "ems_battery_group", EmsBatteryGroup.class), + + /** 告警点位 */ + COOLING_ALARM("COOLING_ALARM", "ems_cooling_alarm_data", EmsCoolingAlarmData.class), + STACK_ALARM("STACK_ALARM", "ems_stack_alarm_data", EmsStackAlarmData.class), + CLUSTER_ALARM("CLUSTER_ALARM", "ems_cluster_alarm_data", EmsClusterAlarmData.class), + PCS_ALARM("PCS_ALARM", "ems_pcs_alarm_data", EmsPcsAlarmData.class), + ; private final String code; private final String matchTable; @@ -80,4 +91,8 @@ public enum DeviceMatchTable return TABLE_TO_CLASS_MAP.get(matchTable); // 从缓存中直接获取,效率高 } + public static String getAlarmMatchTableByCode(String code) { + return DEVICE_MATCH_TABLE_MAP.get(code + "_ALARM"); // 从缓存中直接获取,效率高 + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java index 4e80ad0..2dfbe86 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java @@ -76,4 +76,8 @@ public interface EmsEnergyPriceConfigMapper // 获取所有有效站点的电价配置 public List getAllSitePriceConfig( @Param("currentYear")int currentYear, @Param("currentMonth")int currentMonth); + // 查询指定时间范围的电价配置列表 + public List getConfigListByTimeFrame(@Param("siteId")String siteId, + @Param("startTime")String startTime, + @Param("endTime")String endTime); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java index 10a9fa0..4128555 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsMqttTopicConfigMapper.java @@ -61,4 +61,6 @@ public interface EmsMqttTopicConfigMapper // 判断topic是否存在 public String checkTopicIsExist(String strategyTopic); + + EmsMqttTopicConfig selectOneByTopic(String topic); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 433589f..077bc8f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -127,7 +127,8 @@ public interface EmsPointMatchMapper @Param("pointName")String pointName, @Param("dataPoint")String dataPoint, @Param("ipAddress")String ipAddress, - @Param("ipPort")Integer ipPort); + @Param("ipPort")Integer ipPort, + @Param("isAlarm")Integer isAlarm); // 单个站点单个设备点位查询-电池簇使用 public List getClusterDevicePoints(@Param("siteId")String siteId, @Param("deviceId")String deviceId, @@ -136,12 +137,13 @@ public interface EmsPointMatchMapper @Param("pointName")String pointName, @Param("dataPoint")String dataPoint, @Param("ipAddress")String ipAddress, - @Param("ipPort")Integer ipPort); + @Param("ipPort")Integer ipPort, + @Param("isAlarm")Integer isAlarm); // 根据站点,设备类别,点位,获取唯一数据 public EmsPointMatch getUniquePoint(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("dataPoint")String dataPoint); - EmsPointMatch getOnePointMatch(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory, @Param("dataPoint") String dataPoint); + EmsPointMatch getOnePointMatch(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory, @Param("dataPoint") String dataPoint); - List getDevicePointMatchList(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory); + List getDevicePointMatchList(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IDeviceDataProcessService.java b/ems-system/src/main/java/com/xzzn/ems/service/IDeviceDataProcessService.java new file mode 100644 index 0000000..2c07bd8 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/IDeviceDataProcessService.java @@ -0,0 +1,8 @@ +package com.xzzn.ems.service; + +public interface IDeviceDataProcessService { + + public void handleDeviceData(String message, String siteId); + + public void handleAlarmData(String message, String siteId); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java index bb5bc8e..db3e010 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsStatsReportService.java @@ -26,6 +26,8 @@ public interface IEmsStatsReportService public List getAmmeterDataResult(StatisAmmeterDateRequest requestVo); + List getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo); + public List getPowerDataList(DateSearchRequest requestVo); public List getSingleBatteryData(DateSearchRequest requestVo); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java new file mode 100644 index 0000000..7ca6ba2 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -0,0 +1,1604 @@ +package com.xzzn.ems.service.impl; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.alibaba.fastjson2.TypeReference; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xzzn.common.constant.Constants; +import com.xzzn.common.constant.RedisKeyConstants; +import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.AlarmLevelStatus; +import com.xzzn.common.enums.AlarmStatus; +import com.xzzn.common.enums.BranchStatus; +import com.xzzn.common.enums.ChargeStatus; +import com.xzzn.common.enums.CommunicationStatus; +import com.xzzn.common.enums.ControlModeStatus; +import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.enums.DeviceRunningStatus; +import com.xzzn.common.enums.DeviceType; +import com.xzzn.common.enums.GridStatus; +import com.xzzn.common.enums.SiteDevice; +import com.xzzn.common.enums.SiteEnum; +import com.xzzn.common.enums.SwitchStatus; +import com.xzzn.common.enums.WorkStatus; +import com.xzzn.common.utils.DateUtils; +import com.xzzn.common.utils.MapUtils; +import com.xzzn.common.utils.StringUtils; +import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; +import com.xzzn.ems.domain.vo.EnergyPriceVo; +import com.xzzn.ems.enums.DeviceMatchTable; +import com.xzzn.ems.mapper.EmsAmmeterDataMapper; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper; +import com.xzzn.ems.mapper.EmsBatteryGroupMapper; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; +import com.xzzn.ems.mapper.EmsClusterAlarmDataMapper; +import com.xzzn.ems.mapper.EmsCoolingAlarmDataMapper; +import com.xzzn.ems.mapper.EmsCoolingDataMapper; +import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; +import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsDhDataMapper; +import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper; +import com.xzzn.ems.mapper.EmsPcsAlarmDataMapper; +import com.xzzn.ems.mapper.EmsPcsBranchDataMapper; +import com.xzzn.ems.mapper.EmsPcsDataMapper; +import com.xzzn.ems.mapper.EmsStackAlarmDataMapper; +import com.xzzn.ems.mapper.EmsXfDataMapper; +import com.xzzn.ems.service.IDeviceDataProcessService; +import com.xzzn.ems.service.IEmsAlarmRecordsService; +import com.xzzn.ems.service.IEmsDeviceSettingService; +import com.xzzn.ems.service.IEmsEnergyPriceConfigService; +import com.xzzn.ems.service.IFXXDataProcessService; +import com.xzzn.ems.utils.AbstractBatteryDataProcessor; +import com.xzzn.ems.utils.DevicePointMatchDataProcessor; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IDeviceDataProcessService { + private static final Log log = LogFactory.getLog(DeviceDataProcessServiceImpl.class); + + private static final Pattern PATTERN = Pattern.compile("(BMSD\\d{2})(ZT|SOC|SOH|DL|DY|BDSC)"); + // 匹配DTDC+数字格式的正则(提取序号) + private static final Pattern DTDC_PATTERN = Pattern.compile("DTDC(\\d+)([A-Za-z]*)"); + + @Autowired + private EmsBatteryClusterMapper emsBatteryClusterMapper; + @Autowired + private EmsBatteryStackMapper emsBatteryStackMapper; + @Autowired + private EmsBatteryDataMapper emsBatteryDataMapper; + @Autowired + private EmsPcsDataMapper emsPcsDataMapper; + @Autowired + private EmsPcsBranchDataMapper emsPcsBranchDataMapper; + @Autowired + private EmsAmmeterDataMapper emsAmmeterDataMapper; + @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; + @Autowired + private EmsBatteryDataMinutesMapper emsBatteryDataMinutesMapper; + @Autowired + private EmsDailyChargeDataMapper emsDailyChargeDataMapper; + @Autowired + private EmsXfDataMapper emsXfDataMapper; + @Autowired + private EmsDhDataMapper emsDhDataMapper; + @Autowired + private EmsCoolingDataMapper emsCoolingDataMapper; + @Autowired + private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; + @Autowired + private EmsBatteryGroupMapper emsBatteryGroupMapper; + + @Autowired + private EmsCoolingAlarmDataMapper emsCoolingAlarmDataMapper; + @Autowired + private EmsStackAlarmDataMapper emsStackAlarmDataMapper; + @Autowired + private EmsClusterAlarmDataMapper emsClusterAlarmDataMapper; + @Autowired + private EmsPcsAlarmDataMapper emsPcsAlarmDataMapper; + + @Autowired + private EmsBatteryDailyLatestServiceImpl emsBatteryDailyLatestServiceImpl; + @Autowired + private IEmsAlarmRecordsService iEmsAlarmRecordsService; + @Autowired + private IEmsEnergyPriceConfigService emsEnergyPriceConfigService; + @Autowired + private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; + @Autowired + private IEmsDeviceSettingService iEmsDeviceSettingService; + @Autowired + private DevicePointMatchDataProcessor devicePointMatchDataProcessor; + + @Autowired + private RedisCache redisCache; + + // 构造方法(调用父类构造) + public DeviceDataProcessServiceImpl(ObjectMapper objectMapper) { + super(objectMapper); + } + + @Override + public void handleDeviceData(String message, String siteId) { + JSONArray arraylist = JSONArray.parseArray(message); + + for (int i = 0; i < arraylist.size(); i++) { + JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); + + String deviceId = obj.getString("Device"); + String jsonData = obj.getString("Data"); + Long timestamp = obj.getLong("timestamp"); + Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); + + log.info("deviceId:" + deviceId); + boolean isEmpty = checkJsonDataEmpty(jsonData); + if (isEmpty) { + // 添加设备告警 + iEmsAlarmRecordsService.addEmptyDataAlarmRecord(siteId, deviceId); + return; + } + + // 存放mqtt原始每个设备最晚一次数据,便于后面点位获取数据 + redisCache.setCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId, obj); + // 存放每次同步数据,失效时间(同同步时间)-用于判断是否正常同步数据 + redisCache.setCacheObject(RedisKeyConstants.SYNC_DATA + siteId + "_" + deviceId, obj, 1, TimeUnit.MINUTES); + + if (deviceId.contains(SiteDevice.BMSD.name())) { + batteryStackDataProcess(siteId, deviceId, jsonData); + batteryGroupDataProcess(siteId, deviceId, jsonData); + batteryDataProcessFromBmsd(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains(SiteDevice.BMSC.name())) { + batteryClusterDataProcess(siteId, deviceId, jsonData); + batteryDataProcessFromBmsc(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains(SiteDevice.PCS.name())) { + pcsDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + pcsBranchDataProcess(siteId, deviceId, jsonData); + batteryClusterDataProcess(siteId, jsonData); + } else if (deviceId.contains(SiteDevice.LOAD.name())) { + loadDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains(SiteDevice.METEGF.name()) + || deviceId.contains(SiteDevice.METE.name()) + || deviceId.contains(SiteDevice.METE0.name())) { + meteDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains("XF")) { + meteXFProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains(SiteDevice.DH.name()) || deviceId.contains(SiteDevice.donghuan.name())) { + dhDataProcess(siteId, deviceId, jsonData); + } else if (deviceId.contains(SiteDevice.ZSLQ.name())) { + coolingDataProcess(siteId, deviceId, jsonData); + } + } + } + + private void coolingDataProcess(String siteId, String deviceId, String jsonData) { + //中水冷却 + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.COOLING.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理中水冷却数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + EmsCoolingData coolingData = new EmsCoolingData(); + + saveDeviceData(pointMatchList, obj, coolingData); + + coolingData.setCreateBy("system"); + coolingData.setCreateTime(DateUtils.getNowDate()); + coolingData.setUpdateBy("system"); + coolingData.setUpdateTime(DateUtils.getNowDate()); + coolingData.setSiteId(siteId); + coolingData.setDeviceId(deviceId); + + emsCoolingDataMapper.insertEmsCoolingData(coolingData); + + redisCache.setCacheObject(RedisKeyConstants.COOLING + siteId + "_" + deviceId, coolingData); + + } + + private void meteXFProcess(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { + //消防 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.XF.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理动环数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + // 暂时只更新设备表的设备状态 ZDYBYDCZT-主电源备用电池状态 + // 数据存表 + EmsXfData xfData = new EmsXfData(); + xfData.setDataTimestamp(dataUpdateTime); + + saveDeviceData(pointMatchList, obj, xfData); + + xfData.setCreateBy("system"); + xfData.setCreateTime(DateUtils.getNowDate()); + xfData.setUpdateBy("system"); + xfData.setUpdateTime(DateUtils.getNowDate()); + xfData.setSiteId(siteId); + xfData.setDeviceId(deviceId); + emsXfDataMapper.insertEmsXfData(xfData); + + redisCache.setCacheObject(RedisKeyConstants.XF + siteId + "_" + deviceId, xfData); + // 状态枚举还没有提供 + EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); + emsDevicesSetting.setCommunicationStatus(StringUtils.getString(xfData.getDczt())); + emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); + emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); + } + + private void dhDataProcess(String siteId, String deviceId, String dataJson) { + //动环 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.DH.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理动环数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + //DH + EmsDhData dhData = new EmsDhData(); + + saveDeviceData(pointMatchList, obj, dhData); + + dhData.setCreateBy("system"); + dhData.setCreateTime(DateUtils.getNowDate()); + dhData.setUpdateBy("system"); + dhData.setUpdateTime(DateUtils.getNowDate()); + dhData.setSiteId(siteId); + dhData.setDeviceId(deviceId); + emsDhDataMapper.insertEmsDhData(dhData); + + redisCache.setCacheObject(RedisKeyConstants.DH + siteId + "_" + deviceId, dhData); + + } + + private void batteryStackDataProcess(String siteId, String deviceId, String dataJson) { + + //电池堆 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + // 将原始数据存一下方便后面簇数据使用 + redisCache.setCacheObject(RedisKeyConstants.ORIGINAL_BMSD + siteId + "_" + deviceId, obj); + + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.STACK.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理电池堆数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + //BMS 电池簇 + EmsBatteryStack dataStack = new EmsBatteryStack(); + + // 其他非 BigDecimal 字段 + dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + + saveDeviceData(pointMatchList, obj, dataStack); + + dataStack.setCreateBy("system"); + dataStack.setCreateTime(DateUtils.getNowDate()); + dataStack.setUpdateBy("system"); + dataStack.setUpdateTime(DateUtils.getNowDate()); + dataStack.setSiteId(siteId); + dataStack.setDeviceId(deviceId); + + emsBatteryStackMapper.insertEmsBatteryStack(dataStack); + + redisCache.setCacheObject(RedisKeyConstants.STACK + siteId + "_" + deviceId, dataStack); + + } + + private void batteryGroupDataProcess(String siteId, String deviceId, String jsonData) { + if (!SiteEnum.DDS.getCode().equals(siteId)) { + return; + } + //电池组 + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + Map groupMap = new HashMap<>(); + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + // 跳过空键 + if (key == null || key.trim().isEmpty()) { + continue; + } + Matcher matcher = PATTERN.matcher(key); + if (matcher.matches()) { + String groupDeviceId = matcher.group(1); + String property = matcher.group(2); + EmsBatteryGroup dataGroup = groupMap.getOrDefault(groupDeviceId, new EmsBatteryGroup()); + dataGroup.setDeviceId(groupDeviceId); + dataGroup.setSiteId(siteId); + dataGroup.setCreateBy("system"); + dataGroup.setCreateTime(DateUtils.getNowDate()); + dataGroup.setUpdateBy("system"); + dataGroup.setUpdateTime(DateUtils.getNowDate()); + + setPropertyValue(dataGroup, property, entry.getValue()); + groupMap.put(groupDeviceId, dataGroup); + } + } + + // 批量插入数据库 + if (org.apache.commons.collections4.MapUtils.isNotEmpty(groupMap)) { + List batteryGroupList = new ArrayList<>(groupMap.values()); + emsBatteryGroupMapper.batchInsertGroupData(batteryGroupList); + redisCache.setCacheObject(RedisKeyConstants.GROUP + siteId + "_" + deviceId, batteryGroupList); + } + + } + + private void batteryDataProcessFromBmsd(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { + if (!SiteEnum.DDS.getCode().equals(siteId)) { + return; + } + //电池组 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + List dataList = new ArrayList<>(); + + // 前一个小时 + LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String oneHourAgoStr = oneHourAgo.format(formatter); + + Map dataMap = new HashMap<>(); + Map dailyMap = new HashMap<>(); + Map minutesMap = new HashMap<>(); + + String clusterId = getClusterDeviceIdByParentDeviceId(siteId, deviceId); + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + + if (key.startsWith("DTDC")) { + Matcher matcher = DTDC_PATTERN.matcher(key); + if (matcher.matches()) { + String batteryCellId = matcher.group(1); + String property = matcher.group(2); + + EmsBatteryData data = dataMap.getOrDefault(batteryCellId, new EmsBatteryData()); + if (StringUtils.isNotEmpty(batteryCellId)) { + data.setDataTimestamp(dataUpdateTime); + data.setBatteryPack(deviceId); + data.setBatteryCluster(clusterId); + data.setClusterDeviceId(clusterId); + data.setBatteryCellId(batteryCellId); + data.setSiteId(siteId); + data.setDeviceId(batteryCellId); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + } + // 根据后缀设置对应属性 + setDTDCPropertyValue(data, property, entry.getValue()); + dataMap.put(batteryCellId, data); + + // 每日最新数据:按batteryCellId去重 + EmsBatteryDataDailyLatest daily = dailyMap.getOrDefault(batteryCellId, new EmsBatteryDataDailyLatest()); + BeanUtils.copyProperties(data, daily); + daily.setDateDay(DateUtils.getNowDate()); + dailyMap.put(batteryCellId, daily); + + // 分钟级的表,上报的数据直接存入,数据上限是 1 个小时 + EmsBatteryDataMinutes minutes = minutesMap.getOrDefault(batteryCellId, new EmsBatteryDataMinutes()); + BeanUtils.copyProperties(data, minutes); + minutesMap.put(batteryCellId, minutes); + } + } + } + if (!CollectionUtils.sizeIsEmpty(dataMap)) { + dataList = new ArrayList<>(dataMap.values()); + emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList)); + + redisCache.deleteList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); + redisCache.setCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId, dataList); + } + // 批量处理每日最新数据 + List dailyList = new ArrayList<>(dailyMap.values()); + if (!dailyList.isEmpty()) { + dailyList = new ArrayList<>(dailyMap.values()); + emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList); + } + + // 实时插入每分钟数据 + List minutesList = new ArrayList<>(minutesMap.values()); + if (!minutesList.isEmpty()) { + emsBatteryDataMinutesMapper.insertMinutesBatteryDataList(minutesList); + } + // 清理分钟级表里一小时前数据 + emsBatteryDataMinutesMapper.deleteByTimeBeforeOneHour(oneHourAgoStr); + + // 分片处理时级,天级,月级数据 + if (CollectionUtils.isNotEmpty(dataList)) { + super.processBatch(dataList); + } + } + + private String getClusterDeviceIdByParentDeviceId(String siteId, String deviceId) { + String clusterId = "BMSC01"; + Map> map = redisCache.getCacheObject(RedisKeyConstants.INIT_DEVICE_INFO); + if (map == null || map.isEmpty()) { + map = iEmsDeviceSettingService.initDeviceInfo(); + } + // 不为空,则查找子类的簇id + if (map != null && !map.isEmpty()) { + List list = map.get(siteId); + if (CollectionUtils.isNotEmpty(list)) { + for (EmsDevicesSetting emsDevicesSetting : list) { + if (deviceId.equals(emsDevicesSetting.getParentId())) { + clusterId = emsDevicesSetting.getDeviceId(); + } + } + } + } + return clusterId; + } + + private void setDTDCPropertyValue(EmsBatteryData data, String property, Object value) { + BigDecimal numberValue = null; + if (value instanceof Number) { + numberValue = new BigDecimal(value.toString()); + } + switch (property) { + case "DY": + data.setVoltage(numberValue); + break; + case "WD": + data.setTemperature(numberValue); + break; + case "NZ": + data.setInterResistance(numberValue); + break; + } + } + + //根据属性名设置对应的值 + private static void setPropertyValue(EmsBatteryGroup groupData, String property, Object value) { + BigDecimal numberValue = null; + if (value instanceof Number) { + numberValue = new BigDecimal(value.toString()); + } + + switch (property) { + case "ZT": + if (numberValue != null) { + groupData.setStatus(numberValue.toString()); + } + break; + case "SOC": + groupData.setSoc(numberValue); + break; + case "SOH": + groupData.setSoh(numberValue); + break; + case "DL": + groupData.setCurrent(numberValue); + break; + case "DY": + groupData.setVoltage(numberValue); + break; + case "BDSC": + groupData.setEstimatedBackupDuration(numberValue); + break; + } + } + + private void saveDeviceData(List pointMatchList, Map obj, Object entity) { + Map pointMatchMap = pointMatchList.stream() + .collect(Collectors.toMap( + data -> StringUtils.toCamelCase(data.getMatchField()), + EmsPointMatch::getDataPoint, + (existing, replacement) -> replacement)); + Field[] fields = entity.getClass().getDeclaredFields(); + for (Field field : fields) { + if (pointMatchMap.containsKey(field.getName())) { + field.setAccessible(true); + try { + Object matchValue = obj.get(pointMatchMap.get(field.getName())); + Class fieldType = field.getType(); + if (String.class.equals(fieldType)) { + matchValue = StringUtils.getString(matchValue); + } else if (Long.class.equals(fieldType)) { + matchValue = StringUtils.getLong(matchValue); + } else if (BigDecimal.class.equals(fieldType)) { + matchValue = StringUtils.getBigDecimal(matchValue); + } else if (Integer.class.equals(fieldType)) { + matchValue = MapUtils.getInteger(obj, pointMatchMap.get(field.getName())); + } + field.set(entity, matchValue); + } catch (IllegalAccessException e) { + log.warn("deviceDataProcess 设置字段值时出错", e); + } + } + } + } + + private void batteryClusterDataProcess(String siteId, String deviceId, String dataJson) { + + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.CLUSTER.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理电池簇数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + String stackDeviceId = getStackDeviceId(deviceId); + //BMS 电池簇 + EmsBatteryCluster data = new EmsBatteryCluster(); + + saveDeviceData(pointMatchList, obj, data); + + data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + data.setSiteId(siteId); + data.setDeviceId(deviceId); + if (StringUtils.isNotBlank(stackDeviceId)) { + data.setStackDeviceId(stackDeviceId); + } else { + data.setStackDeviceId("1"); + } + emsBatteryClusterMapper.insertEmsBatteryCluster(data); + + redisCache.setCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + deviceId, data); + + } + + private String getStackDeviceId(String deviceId) { + EmsDevicesSetting joken = new EmsDevicesSetting(); + joken.setDeviceId(deviceId); + List up = emsDevicesSettingMapper.selectEmsDevicesSettingList(joken); + String stackDeviceId = ""; + if (CollectionUtils.isNotEmpty(up)) { + stackDeviceId = up.get(0).getParentId(); + if (StringUtils.isNotEmpty(stackDeviceId)) { + stackDeviceId = "1"; + } + } + + return stackDeviceId; + } + + private void batteryDataProcessFromBmsc(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { + + //单体电池 + Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() { + })); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.BATTERY.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理单体电池数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + List list = new ArrayList<>(); + List dailyList = new ArrayList<>(); + List minutesList = new ArrayList<>(); + // 前一个小时 + LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String oneHourAgoStr = oneHourAgo.format(formatter); + //单体电池 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsBatteryData batteryData = new EmsBatteryData(); + batteryData.setDeviceId(recordId); + batteryData.setBatteryCellId(recordId); + + saveDeviceData(pointMatchList, fields, batteryData); + + batteryData.setBatteryCluster(deviceId); + batteryData.setBatteryPack(getStackDeviceId(deviceId)); + + // 时间戳 + batteryData.setDataTimestamp(dataUpdateTime); + // 系统管理字段 + batteryData.setCreateBy("system"); + batteryData.setCreateTime(DateUtils.getNowDate()); + batteryData.setUpdateBy("system"); + batteryData.setUpdateTime(DateUtils.getNowDate()); + // ID字段 + batteryData.setSiteId(siteId); + batteryData.setClusterDeviceId(deviceId); + list.add(batteryData); + + // 每日最新数据 + EmsBatteryDataDailyLatest daily = new EmsBatteryDataDailyLatest(); + BeanUtils.copyProperties(batteryData, daily); + daily.setDateDay(DateUtils.getNowDate()); + dailyList.add(daily); + + // 分钟级的表,上报的数据直接存入,数据上限是 1 个小时 + EmsBatteryDataMinutes minutes = new EmsBatteryDataMinutes(); + BeanUtils.copyProperties(batteryData, minutes); + minutesList.add(minutes); + } + + if (CollectionUtils.isNotEmpty(list)) { + emsBatteryDataMapper.insertEmsBatteryDataList(list); + + redisCache.deleteList(RedisKeyConstants.BATTERY + siteId + "_" + deviceId); + redisCache.setCacheList(RedisKeyConstants.BATTERY + siteId + "_" + deviceId, list); + + } + + // 批量处理每日最新数据 + if (CollectionUtils.isNotEmpty(dailyList)) { + emsBatteryDailyLatestServiceImpl.batchProcessBatteryData(dailyList); + } + // 实时插入每分钟数据 + if (CollectionUtils.isNotEmpty(minutesList)) { + emsBatteryDataMinutesMapper.insertMinutesBatteryDataList(minutesList); + } + // 清理分钟级表里一小时前数据 + emsBatteryDataMinutesMapper.deleteByTimeBeforeOneHour(oneHourAgoStr); + + // 分片处理时级,天级,月级数据 + if (CollectionUtils.isNotEmpty(list)) { + super.processBatch(list); + } + } + + private void pcsDataProcess(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.PCS.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理PCS数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + //pcs + EmsPcsData pcsData = new EmsPcsData(); + + saveDeviceData(pointMatchList, obj, pcsData); + + // 状态指示类 + pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); + pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); + pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); + pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); + pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); + + // 时间与状态类字段 + pcsData.setDataUpdateTime(dataUpdateTime); + pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); + pcsData.setGridStatus(GridStatus.GRID.getCode()); + pcsData.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); + pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); + + // 系统管理字段 + pcsData.setCreateBy("system"); + pcsData.setCreateTime(DateUtils.getNowDate()); + pcsData.setUpdateBy("system"); + pcsData.setUpdateTime(DateUtils.getNowDate()); + pcsData.setSiteId(siteId); + pcsData.setDeviceId(deviceId); + pcsData.setDateMonth(DateUtils.getNowMonthLong()); + pcsData.setDateDay(DateUtils.getNowDayLong()); + + emsPcsDataMapper.insertEmsPcsData(pcsData); + redisCache.setCacheObject(RedisKeyConstants.PCS + siteId + "_" + deviceId, pcsData); + + if (SiteEnum.FX.getCode().equals(siteId)) { + //更新每日充放电数据 + dealFXXDailyChargeDate(siteId, deviceId, pcsData); + } + } + + private void pcsBranchDataProcess(String siteId, String deviceId, String dataJson) { + + Map> records = processDataPrefix(JSON.parseObject(dataJson, new TypeReference>() { + })); + List list = new ArrayList<>(); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.BRANCH.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理PCS支路数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + //PCS支路 + for (Map.Entry> record : records.entrySet()) { + String recordId = record.getKey(); + Map fields = record.getValue(); + + EmsPcsBranchData data = new EmsPcsBranchData(); + data.setDeviceId(deviceId); + data.setSiteId(siteId); + data.setGridStatus(GridStatus.GRID.getCode()); + + saveDeviceData(pointMatchList, fields, data); + + data.setBranchId(recordId); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + list.add(data); + } + if (CollectionUtils.isNotEmpty(list)) { + emsPcsBranchDataMapper.insertPcsBranchDataList(list); + + redisCache.setCacheObject(RedisKeyConstants.BRANCH + siteId + "_" + deviceId, list); + + } + + } + + private void loadDataProcess(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { + + //总表 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.AMMETER.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理LOAD总表数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + EmsAmmeterData dataLoad = new EmsAmmeterData(); + // 更新时间 + dataLoad.setDataUpdateTime(dataUpdateTime); + + saveDeviceData(pointMatchList, obj, dataLoad); + + dataLoad.setCreateBy("system"); + dataLoad.setCreateTime(DateUtils.getNowDate()); + dataLoad.setUpdateBy("system"); + dataLoad.setUpdateTime(DateUtils.getNowDate()); + dataLoad.setSiteId(siteId); + dataLoad.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataLoad); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + siteId + "_" + deviceId, dataLoad); + + } + + private void batteryClusterDataProcess(String siteId, String dataJson) { + if (!SiteEnum.DDS.getCode().equals(siteId)) { + return; + } + + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + + List deviceIds = Arrays.asList("BMSC02", "BMSC01"); + for (String deviceId : deviceIds) { + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.CLUSTER.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理LOAD总表数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + //BMSC 电池簇 + EmsBatteryCluster data = new EmsBatteryCluster(); + // 其他非 BigDecimal 字段 + data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 + data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + data.setSiteId(siteId); + String stackDeviceId = getDeviceParent(siteId, deviceId); + if (StringUtils.isNotBlank(stackDeviceId)) { + data.setStackDeviceId(stackDeviceId); + } else { + data.setStackDeviceId("1"); + } + // 获取redis获取最新的BMSD数据 + Map stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD + siteId + "_" + stackDeviceId); + data.setDeviceId(deviceId); + saveDeviceData(pointMatchList, obj, data); + + // 取堆里面数据 + saveDeviceData(pointMatchList, stackObj, data); + + emsBatteryClusterMapper.insertEmsBatteryCluster(data); + redisCache.setCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + deviceId, data); + + } + + } + + private String getDeviceParent(String siteId, String deviceId) { + Map> map = redisCache.getCacheObject(RedisKeyConstants.INIT_DEVICE_INFO); + if (map == null || map.isEmpty()) { + map = iEmsDeviceSettingService.initDeviceInfo(); + } + // 不为空,则查找父类 + String stackDeviceId = "1"; + if (map != null && !map.isEmpty()) { + List list = map.get(siteId); + if (list == null || list.isEmpty()) { + EmsDevicesSetting deviceInfo = new EmsDevicesSetting(); + deviceInfo.setDeviceId(deviceId); + deviceInfo.setSiteId(siteId); + list = emsDevicesSettingMapper.selectEmsDevicesSettingList(deviceInfo); + if (list == null || list.isEmpty()) { + return stackDeviceId; + } + } + for (EmsDevicesSetting emsDevicesSetting : list) { + if (deviceId.equals(emsDevicesSetting.getDeviceId())) { + stackDeviceId = emsDevicesSetting.getParentId(); + } + } + } + return stackDeviceId; + } + + private void dealFXXDailyChargeDate(String siteId, String deviceId, EmsPcsData pcsData) { + log.info("start dealFXXDailyChargeDate"); + //日充放电数据 + if (pcsData == null) { + log.info("日充放电数据为空, deviceId: " + deviceId); + return; + } + + // 初始化当日数据 + EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); + emsDailyChargeData.setSiteId(siteId); + emsDailyChargeData.setDeviceId(deviceId); + emsDailyChargeData.setDateTime(DateUtils.getNowDate()); + emsDailyChargeData.setTotalChargeData(pcsData.getTotalAcChargeEnergy()); + emsDailyChargeData.setTotalDischargeData(pcsData.getTotalAcDischargeEnergy()); + emsDailyChargeData.setChargeData(pcsData.getDailyAcChargeEnergy()); + emsDailyChargeData.setDischargeData(pcsData.getDailyAcDischargeEnergy()); + emsDailyChargeData.setCreateBy("system"); + emsDailyChargeData.setCreateTime(DateUtils.getNowDate()); + emsDailyChargeData.setUpdateBy("system"); + emsDailyChargeData.setUpdateTime(DateUtils.getNowDate()); + // 插入或更新每日充放电数据表 + emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); + log.info("end dealFXXDailyChargeDate"); + } + + private void meteDataProcess(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { + + //总表 + Map obj = JSON.parseObject(dataJson, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.AMMETER.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理METE储能电表数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + // 获取上次数据,便于后面计算差值均无则默认0 + EmsAmmeterData lastAmmeterData = getLastAmmeterData(siteId, deviceId); + + EmsAmmeterData dataMete = new EmsAmmeterData(); + // 更新时间 + dataMete.setDataUpdateTime(dataUpdateTime); + + saveDeviceData(pointMatchList, obj, dataMete); + + dataMete.setCreateBy("system"); + dataMete.setCreateTime(DateUtils.getNowDate()); + dataMete.setUpdateBy("system"); + dataMete.setUpdateTime(DateUtils.getNowDate()); + dataMete.setSiteId(siteId); + dataMete.setDeviceId(deviceId); + + emsAmmeterDataMapper.insertEmsAmmeterData(dataMete); + + redisCache.setCacheObject(RedisKeyConstants.AMMETER + siteId + "_" + deviceId, dataMete); + + // 处理电表每日充放电数据 + if (!deviceId.contains(SiteDevice.METEGF.name()) && !deviceId.contains(SiteDevice.METE0.name())) { + if (SiteEnum.FX.getCode().equals(siteId)) { + dealAmmeterDailyDate(siteId, obj, dataUpdateTime, lastAmmeterData); + } else if (SiteEnum.DDS.getCode().equals(siteId)) { + dealDDSDailyChargeDate(siteId, obj, deviceId); + } + } + } + + private EmsAmmeterData getLastAmmeterData(String siteId, String deviceId) { + // 先从redis取,取不到查数据 + EmsAmmeterData lastData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" + deviceId); + if (lastData == null) { + lastData = emsAmmeterDataMapper.getLastData(siteId, deviceId); + if (lastData == null) { + lastData = new EmsAmmeterData(); + lastData.setSiteId(siteId); + lastData.setDeviceId(deviceId); + lastData.setCurrentForwardActiveTotal(BigDecimal.ZERO); + lastData.setCurrentReverseActiveTotal(BigDecimal.ZERO); + } + } + return lastData; + } + + private void dealDDSDailyChargeDate(String siteId, Map obj, String deviceId) { + // 初始化今日充放电 + BigDecimal dailyDisChargeDate = new BigDecimal(0); + BigDecimal dailyChargeDate = new BigDecimal(0); + + BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN")); + BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN")); + // 初始化当日数据-总的 + EmsDailyChargeData emsDailyChargeData = initDailyChargeData(siteId, deviceId, nowTotalChargeDate, nowTotalDisChargeDate); + // 获取redis存放昨日最晚数据 + String yestDate = DateUtils.getYesterdayDate(); + String yestDateRedisKey = RedisKeyConstants.AMMETER + siteId + "_" + deviceId + "_" + yestDate; + EmsAmmeterData yestData = redisCache.getCacheObject(yestDateRedisKey); + if (yestData == null) { + // redis没有这查电表总数据表取截止到昨日最新第一条数据 + yestData = emsAmmeterDataMapper.getYestLatestDate(siteId, deviceId, yestDate); + // 数据存redis-有效期1天 + redisCache.setCacheObject(yestDateRedisKey, yestData, Constants.DATE_VALID_TIME, TimeUnit.DAYS); + } + if (yestData != null) { + // 今日总数据-昨日总数据=今日充放电 + BigDecimal yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal(); + BigDecimal yestTotalChargeDate = yestData.getCurrentForwardActiveTotal(); + + dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); + dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); + emsDailyChargeData.setChargeData(dailyChargeDate); + emsDailyChargeData.setDischargeData(dailyDisChargeDate); + } + + // 插入或更新每日充放电数据表 + emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); + + // 初始化数据-尖峰平谷 + EmsDailyEnergyData energyData = initEnergyData(siteId); + // 计算尖峰平谷差值,更新表 + calcEnergyDiffAndRevenue(siteId, energyData, obj, yestData); + energyData.setCalcTime(DateUtils.getNowDate()); + // 插入或更新电表每日差值数据表 + emsDailyEnergyDataMapper.insertOrUpdateData(energyData); + } + + private EmsDailyChargeData initDailyChargeData(String siteId, String deviceId, BigDecimal nowTotalChargeDate, + BigDecimal nowTotalDisChargeDate) { + EmsDailyChargeData emsDailyChargeData = new EmsDailyChargeData(); + emsDailyChargeData.setSiteId(siteId); + emsDailyChargeData.setDeviceId(deviceId); + emsDailyChargeData.setDateTime(DateUtils.getNowDate()); + emsDailyChargeData.setTotalChargeData(nowTotalChargeDate); + emsDailyChargeData.setTotalDischargeData(nowTotalDisChargeDate); + emsDailyChargeData.setCreateBy("system"); + emsDailyChargeData.setCreateTime(DateUtils.getNowDate()); + emsDailyChargeData.setUpdateBy("system"); + emsDailyChargeData.setUpdateTime(DateUtils.getNowDate()); + return emsDailyChargeData; + } + + private void calcEnergyDiffAndRevenue(String siteId, EmsDailyEnergyData energyData, Map obj, EmsAmmeterData yestData) { + + // 获取当月电价 + String key = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); + EnergyPriceVo priceVo = redisCache.getCacheObject(key); + + // 计算尖峰平谷差值 + // 正反向-尖 + BigDecimal peakChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGJDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActivePeak()); + energyData.setPeakChargeDiff(peakChargeDiff); + BigDecimal peakDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGJDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActivePeak()); + energyData.setPeakDischargeDiff(peakDischargeDiff); + // 正反向-峰 + BigDecimal highChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGFDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveHigh()); + energyData.setHighChargeDiff(highChargeDiff); + BigDecimal highDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGFDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveHigh()); + energyData.setHighDischargeDiff(highDischargeDiff); + // 正反向-平 + BigDecimal flatChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGPDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveFlat()); + energyData.setFlatChargeDiff(flatChargeDiff); + BigDecimal flatDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGPDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveFlat()); + energyData.setFlatDischargeDiff(flatDisChargeDiff); + // 正反向-谷 + BigDecimal valleyChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGGDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveValley()); + energyData.setValleyChargeDiff(valleyChargeDiff); + BigDecimal valleyDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGGDN")) + .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveValley()); + energyData.setValleyDischargeDiff(valleyDisChargeDiff); + + + BigDecimal totalRevenue = getYestLastData(siteId); + BigDecimal dayRevenue = BigDecimal.ZERO; + BigDecimal price = BigDecimal.ZERO; + // 计算当日收益,尖峰平谷收益累加,(放电量-充电量)*电价 + if (priceVo != null) { + price = priceVo.getPeak() == null ? BigDecimal.ZERO : priceVo.getPeak(); + BigDecimal peakRevenue = peakDischargeDiff.subtract(peakChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(peakRevenue); + price = priceVo.getHigh() == null ? BigDecimal.ZERO : priceVo.getHigh(); + BigDecimal highRevenue = highDischargeDiff.subtract(highChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(highRevenue); + price = priceVo.getFlat() == null ? BigDecimal.ZERO : priceVo.getFlat(); + BigDecimal flatRevenue = flatDisChargeDiff.subtract(flatChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(flatRevenue); + price = priceVo.getValley() == null ? BigDecimal.ZERO : priceVo.getValley(); + BigDecimal valleyRevenue = valleyDisChargeDiff.subtract(valleyChargeDiff).multiply(price); + dayRevenue = dayRevenue.add(valleyRevenue); + energyData.setDayRevenue(dayRevenue); + } + // 总收益 = 昨日总收益+今日实时收益 + totalRevenue = totalRevenue.add(dayRevenue); + energyData.setTotalRevenue(totalRevenue); + } + + private BigDecimal getYestLastData(String siteId) { + // dds存的是累计到昨日总收益 + String yestDate = DateUtils.getYesterdayDayString(); + String redisKey = RedisKeyConstants.DDS_TOTAL_REVENUE + siteId + "_" + yestDate; + BigDecimal yestLastTotalRevenue = redisCache.getCacheObject(redisKey); + if (yestLastTotalRevenue == null) { + yestLastTotalRevenue = emsDailyEnergyDataMapper.getLastTotalRevenue(siteId); + if (yestLastTotalRevenue == null) { + yestLastTotalRevenue = BigDecimal.ZERO; + } + redisCache.setCacheObject(redisKey, yestLastTotalRevenue, 1, TimeUnit.DAYS); + } + return yestLastTotalRevenue; + } + + private void dealAmmeterDailyDate(String siteId, Map obj, Date dataUpdateTime, EmsAmmeterData lastData) { + // 先获取当月电价配置,redis没有这查数据库,都没有则返回 + String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); + EnergyPriceVo priceVo = redisCache.getCacheObject(priceKey); + if (priceVo == null) { + priceVo = emsEnergyPriceConfigService.getCurrentMonthPrice(siteId); + redisCache.setCacheObject(priceKey, priceVo, 31, TimeUnit.DAYS); + if (priceVo == null) { + return; + } + } + List timeRanges = priceVo.getRange(); + if (timeRanges == null) { + return; + } + + // 根据时间范围判断数据类型(尖峰平谷),无法确定数据类型则不处理 + String costType = ""; + String startTime = ""; + for (EnergyPriceTimeRange timeRange : timeRanges) { + startTime = timeRange.getStartTime(); + if (isInPriceTimeRange(startTime, timeRange.getEndTime(), dataUpdateTime)) { + costType = timeRange.getCostType(); + break; + } + } + if (StringUtils.isEmpty(costType)) { + return; + } + + //初始化电表每日差值对象 + EmsDailyEnergyData energyData = initEnergyData(siteId); + + // 根据 costType,计算本次与上次数据差值,累加到对应的数据类型里面 + setDiffByCostType(siteId, costType, energyData, lastData, obj, priceVo); + + // 插入或更新电表每日差值数据表 + emsDailyEnergyDataMapper.insertOrUpdateData(energyData); + } + + private void setDiffByCostType(String siteId, String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData, + Map obj, EnergyPriceVo priceVo) { + BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN")); + BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN")); + currentChargeData = currentChargeData != null ? currentChargeData : BigDecimal.ZERO; + currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO; + + // 获取上次实时总收益+当日实时总收益,初始化电价 + Map revenueMap = getRealTimeData(siteId); + BigDecimal totalRevenue = revenueMap.get("totalRevenue") == null ? BigDecimal.ZERO : revenueMap.get("totalRevenue"); + BigDecimal dayRevenue = revenueMap.get("dayRevenue") == null ? BigDecimal.ZERO : revenueMap.get("dayRevenue"); + BigDecimal price = BigDecimal.ZERO; + // 计算时段差值,按照数据类型累加 + // 计算当日累加收益,尖峰平谷收益在当日原基础累加,(放电量-充电量)*电价 + BigDecimal chargeDiffData = currentChargeData.subtract( + lastData.getCurrentForwardActiveTotal() == null ? BigDecimal.ZERO : lastData.getCurrentForwardActiveTotal()); + BigDecimal disChargeDiffData = currentDischargeData.subtract( + lastData.getCurrentReverseActiveTotal() == null ? BigDecimal.ZERO : lastData.getCurrentReverseActiveTotal() + ); + switch (costType) { + case "peak": + // 增加电量 + BigDecimal peakCharge = energyData.getPeakChargeDiff() == null ? BigDecimal.ZERO : energyData.getPeakChargeDiff(); + energyData.setPeakChargeDiff(peakCharge.add(chargeDiffData)); + BigDecimal peakDischarge = energyData.getPeakDischargeDiff() == null ? BigDecimal.ZERO : energyData.getPeakDischargeDiff(); + energyData.setPeakDischargeDiff(peakDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getPeak() == null ? BigDecimal.ZERO : priceVo.getPeak(); + break; + case "high": + // 增加电量 + BigDecimal highCharge = energyData.getHighChargeDiff() == null ? BigDecimal.ZERO : energyData.getHighChargeDiff(); + energyData.setHighChargeDiff(highCharge.add(chargeDiffData)); + BigDecimal highDischarge = energyData.getHighDischargeDiff() == null ? BigDecimal.ZERO : energyData.getHighDischargeDiff(); + energyData.setHighDischargeDiff(highDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getHigh() == null ? BigDecimal.ZERO : priceVo.getHigh(); + break; + case "flat": + // 增加电量 + BigDecimal flatCharge = energyData.getFlatChargeDiff() == null ? BigDecimal.ZERO : energyData.getFlatChargeDiff(); + energyData.setFlatChargeDiff(flatCharge.add(chargeDiffData)); + BigDecimal flatDischarge = energyData.getFlatDischargeDiff() == null ? BigDecimal.ZERO : energyData.getFlatDischargeDiff(); + energyData.setFlatDischargeDiff(flatDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getFlat() == null ? BigDecimal.ZERO : priceVo.getFlat(); + break; + case "valley": + // 增加电量 + BigDecimal valleyCharge = energyData.getValleyChargeDiff() == null ? BigDecimal.ZERO : energyData.getValleyChargeDiff(); + energyData.setValleyChargeDiff(valleyCharge.add(chargeDiffData)); + BigDecimal valleyDischarge = energyData.getValleyDischargeDiff() == null ? BigDecimal.ZERO : energyData.getValleyDischargeDiff(); + energyData.setValleyDischargeDiff(valleyDischarge.add(disChargeDiffData)); + + // 电价 + price = priceVo.getValley() == null ? BigDecimal.ZERO : priceVo.getValley(); + break; + default: + return; + } + + // 计算本次累加收益 + BigDecimal addRevenue = disChargeDiffData.subtract(chargeDiffData).multiply(price); + dayRevenue = dayRevenue.add(addRevenue); + energyData.setDayRevenue(dayRevenue); + // 总收益 = 上次实时总收益+今日实时增加的收益 + totalRevenue = totalRevenue.add(addRevenue); + energyData.setTotalRevenue(totalRevenue); + + // 存redis便于下次取用 + String today = DateUtils.getDate(); + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId + "_" + today; + Map realTimeRevenue = new HashMap<>(); + realTimeRevenue.put("totalRevenue", totalRevenue); + realTimeRevenue.put("dayRevenue", dayRevenue); + redisCache.setCacheObject(redisKey, realTimeRevenue, 1, TimeUnit.DAYS); + } + + private Map getRealTimeData(String siteId) { + // fx取实时总收益和当天实时收益 + String today = DateUtils.getDate(); + String redisKey = RedisKeyConstants.FXX_REALTIME_REVENUE + siteId + "_" + today; + Map realTimeRevenue = redisCache.getCacheObject(redisKey); + if (realTimeRevenue == null) { + // 查数据库 + realTimeRevenue = iEmsEnergyPriceConfigService.getDayRevenueMap(siteId); + if (realTimeRevenue == null) { + realTimeRevenue = new HashMap<>(); + realTimeRevenue.put("totalRevenue", BigDecimal.ZERO); + realTimeRevenue.put("dayRevenue", BigDecimal.ZERO); + } + redisCache.setCacheObject(redisKey, realTimeRevenue, 1, TimeUnit.DAYS); + } + return realTimeRevenue; + } + + private boolean isInPriceTimeRange(String startTime, String endTime, Date dataUpdateTime) { + if (startTime == null || endTime == null || dataUpdateTime == null) { + return false; + } + LocalDateTime time = DateUtils.toLocalDateTime(dataUpdateTime); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + String dataTimeStr = time.format(formatter); + // 比较时间范围 + return dataTimeStr.compareTo(startTime) >= 0 + && dataTimeStr.compareTo(endTime) < 0; + } + + private EmsDailyEnergyData initEnergyData(String siteId) { + // 先获取数据库当天数据,存在则更新时间,不存在则初始化 + EmsDailyEnergyData energyData = emsDailyEnergyDataMapper.getDataByDate(siteId, DateUtils.getDate()); + if (energyData == null) { + energyData = new EmsDailyEnergyData(); + energyData.setSiteId(siteId); + energyData.setDataDate(DateUtils.getNowDate()); + energyData.setCreateBy("system"); + energyData.setCreateTime(DateUtils.getNowDate()); + } + energyData.setUpdateBy("system"); + energyData.setCalcTime(DateUtils.getNowDate()); + return energyData; + } + + // 数据分组处理 + private static Map> processData(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 提取记录ID(最后3位) + String recordId = key.substring(key.length() - 3); + try { + Long.parseLong(recordId); + } catch (Exception e) { + continue; + } + + // 提取字段类型(前缀) + String fieldType = key.substring(0, key.length() - 3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + return records; + } + + private static Map> processDataPrefix(Map rawData) { + Map> records = new HashMap<>(); + + for (Map.Entry entry : rawData.entrySet()) { + String key = entry.getKey(); + // 确保键长度足够 + if (key.length() < 3) { + continue; + } + + // 提取记录ID(前3位) + String recordId = key.substring(0, 3); + if (!recordId.startsWith("DY")) { + continue; + } + + // 提取字段类型(剩余部分) + String fieldType = key.substring(3); + + // 初始化记录 + records.putIfAbsent(recordId, new HashMap<>()); + // 存入字段值 + records.get(recordId).put(fieldType, entry.getValue()); + } + if (records.isEmpty() && rawData.size() > 0) { + records.put("DY1", rawData); + } + return records; + } + + @Override + public void handleAlarmData(String message, String siteId) { + JSONArray arraylist = JSONArray.parseArray(message); + + // 获取redis缓存-告警信息 + Map alarmMatchInfo = redisCache.getCacheObject(RedisKeyConstants.ALARM_MATCH_INFO); + + for (int i = 0; i < arraylist.size(); i++) { + JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); + + String deviceId = obj.getString("Device"); + String jsonData = obj.getString("Data"); + Long timestamp = obj.getLong("timestamp"); + Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); + + log.info("deviceId:" + deviceId); + String deviceCategory = ""; + if (deviceId.contains(SiteDevice.ZSLQ.name())) { + coolingAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains(SiteDevice.BMSD.name())) { + deviceCategory = DeviceCategory.STACK.getCode(); + stackAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains(SiteDevice.BMSC.name())) { + deviceCategory = DeviceCategory.CLUSTER.getCode(); + clusterAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else if (deviceId.contains(SiteDevice.PCS.name())) { + deviceCategory = DeviceCategory.PCS.getCode(); + pcsAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } + if (StringUtils.isEmpty(deviceCategory)) { + // 处理告警信息 + alarmDataProcess(siteId, deviceId, jsonData, alarmMatchInfo, deviceCategory); + } + } + } + + private void pcsAlarmDataProcess(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { + //pcs + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.PCS.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理中水冷却告警数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + EmsPcsAlarmData pcsAlarmData = new EmsPcsAlarmData(); + // 更新时间 + pcsAlarmData.setDataTimestamp(dataUpdateTime); + + saveDeviceData(pointMatchList, obj, pcsAlarmData); + + pcsAlarmData.setCreateBy("system"); + pcsAlarmData.setCreateTime(DateUtils.getNowDate()); + pcsAlarmData.setUpdateBy("system"); + pcsAlarmData.setUpdateTime(DateUtils.getNowDate()); + pcsAlarmData.setSiteId(siteId); + pcsAlarmData.setDeviceId(deviceId); + emsPcsAlarmDataMapper.insertEmsPcsAlarmData(pcsAlarmData); + } + + private void stackAlarmDataProcess(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { + // bmsd + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.STACK.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理电池堆告警数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + EmsStackAlarmData stackAlarmData = new EmsStackAlarmData(); + // 更新时间 + stackAlarmData.setDataTimestamp(dataUpdateTime); + + saveDeviceData(pointMatchList, obj, stackAlarmData); + + stackAlarmData.setCreateBy("system"); + stackAlarmData.setCreateTime(DateUtils.getNowDate()); + stackAlarmData.setUpdateBy("system"); + stackAlarmData.setUpdateTime(DateUtils.getNowDate()); + stackAlarmData.setSiteId(siteId); + stackAlarmData.setDeviceId(deviceId); + emsStackAlarmDataMapper.insertEmsStackAlarmData(stackAlarmData); + } + + private void clusterAlarmDataProcess(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { + // bmsc + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.CLUSTER.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理电池簇告警数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + EmsClusterAlarmData clusterAlarmData = new EmsClusterAlarmData(); + // 更新时间 + clusterAlarmData.setDataTimestamp(dataUpdateTime); + + saveDeviceData(pointMatchList, obj, clusterAlarmData); + + clusterAlarmData.setCreateBy("system"); + clusterAlarmData.setCreateTime(DateUtils.getNowDate()); + clusterAlarmData.setUpdateBy("system"); + clusterAlarmData.setUpdateTime(DateUtils.getNowDate()); + clusterAlarmData.setSiteId(siteId); + clusterAlarmData.setDeviceId(deviceId); + emsClusterAlarmDataMapper.insertEmsClusterAlarmData(clusterAlarmData); + } + + private void coolingAlarmDataProcess(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { + //中水冷却 + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + // 点位匹配数据 + List pointMatchList = devicePointMatchDataProcessor.getDeviceAlarmPointMatch(siteId, deviceId, DeviceMatchTable.COOLING.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + log.info("未找到匹配的点位数据,无法处理中水冷却告警数据,siteId: " + siteId + ",deviceId: " + deviceId); + return; + } + + EmsCoolingAlarmData coolingAlarmData = new EmsCoolingAlarmData(); + // 更新时间 + coolingAlarmData.setDataTimestamp(dataUpdateTime); + + saveDeviceData(pointMatchList, obj, coolingAlarmData); + + coolingAlarmData.setCreateBy("system"); + coolingAlarmData.setCreateTime(DateUtils.getNowDate()); + coolingAlarmData.setUpdateBy("system"); + coolingAlarmData.setUpdateTime(DateUtils.getNowDate()); + coolingAlarmData.setSiteId(siteId); + coolingAlarmData.setDeviceId(deviceId); + emsCoolingAlarmDataMapper.insertEmsCoolingAlarmData(coolingAlarmData); + } + + private void alarmDataProcess(String siteId, String deviceId, String jsonData, + Map alarmInfoData, String category) { + Map obj = JSON.parseObject(jsonData, new TypeReference>() { + }); + + String redisKey = RedisKeyConstants.LATEST_ALARM_RECORD + "_" + siteId + "_" + deviceId; + // 获取redis里面的当前有效告警遍历添加到已存在告警key里面 + Map currentAlarm = redisCache.getCacheMap(redisKey); + final Set currentAlarmKeys = new HashSet<>(); + if (currentAlarm != null && !currentAlarm.isEmpty()) { + currentAlarm.keySet().stream() + .filter(Objects::nonNull) + .map(Object::toString) + .forEach(currentAlarmKeys::add); + } + + // 结合同步数据,筛选簇需要更新的告警信息 + List needUpdateKeys = obj.entrySet().stream() + .filter(entry -> { + Object valueObj = entry.getValue(); + if (valueObj == null) { + return false; + } + int value = Integer.parseInt(valueObj.toString()); + return value == 0 && currentAlarmKeys.contains(entry.getKey()); + }) + .map(Map.Entry::getKey) + .collect(Collectors.toList()); + + // 批量查询数据库-需要更新的数据 + Map needUpdateMap = new HashMap<>(); + if (!needUpdateKeys.isEmpty()) { + List records = iEmsAlarmRecordsService.getAllUnfinishedRecords(needUpdateKeys, siteId, deviceId); + // 转为Map便于快速获取 + needUpdateMap = records.stream() + .collect(Collectors.toMap( + EmsAlarmRecords::getAlarmPoint, + record -> record + )); + } + + + List saveOrUpdateList = new ArrayList<>(); + List newAddRecordList = new ArrayList<>(); + List toRemoveFromRedis = new ArrayList<>(); + + // 遍历数据map + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + Integer value = (Integer) entry.getValue(); + Boolean isCurrentAlarm = currentAlarmKeys.contains(key); + + // 值为 1且不在当前告警里面 - 新增告警 + if (value == 1 && !isCurrentAlarm) { + String matchRedisKey = category + "_" + key; + Object cacheObj = alarmInfoData.get(matchRedisKey); + if (cacheObj == null) { + // 处理空数据逻辑 + return; + } + EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class); + EmsAlarmRecords emsAlarmRecord = convertAlarmRecord(siteId, deviceId, matchInfo); + saveOrUpdateList.add(emsAlarmRecord); + newAddRecordList.add(emsAlarmRecord); + } else if (value == 0 && isCurrentAlarm) {// 值为 0且在当前告警里面 - 更新告警已处理 + EmsAlarmRecords existingAlarm = needUpdateMap.get(key); + if (existingAlarm != null) { + existingAlarm.setStatus(AlarmStatus.DONE.getCode()); + existingAlarm.setUpdateTime(new Date()); + existingAlarm.setAlarmEndTime(new Date()); + saveOrUpdateList.add(existingAlarm); + toRemoveFromRedis.add(key); + } + } + } + + // 批量处理插入和更新操作 + if (CollectionUtils.isNotEmpty(saveOrUpdateList)) { + iEmsAlarmRecordsService.batchProcessAlarmRecords(saveOrUpdateList); + } + // 已处理的从redis里面删除 + if (!toRemoveFromRedis.isEmpty()) { + redisCache.deleteAllCacheMapValue(RedisKeyConstants.LATEST_ALARM_RECORD + siteId, toRemoveFromRedis.toArray()); + } + // 批量添加新增的告警到Redis + Map newAlarms = newAddRecordList.stream() + .filter(a -> !AlarmStatus.DONE.getCode().equals(a.getStatus())) + .collect(Collectors.toMap(EmsAlarmRecords::getAlarmPoint, a -> a)); + if (!newAlarms.isEmpty()) { + // 本次新增的放入redis + redisCache.setAllCacheMapValue(redisKey, newAlarms); + } + } + + private EmsAlarmRecords convertAlarmRecord(String siteId, String deviceId, EmsAlarmMatchData matchInfo) { + EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords(); + emsAlarmRecords.setSiteId(siteId); + emsAlarmRecords.setDeviceId(deviceId); + emsAlarmRecords.setDeviceType(DeviceType.TCP.toString()); + emsAlarmRecords.setAlarmLevel(AlarmLevelStatus.GENERAL.getCode()); + emsAlarmRecords.setStatus(AlarmStatus.WAITING.getCode()); + emsAlarmRecords.setAlarmStartTime(DateUtils.getNowDate()); + emsAlarmRecords.setCreateTime(DateUtils.getNowDate()); + emsAlarmRecords.setCreateBy("system"); + emsAlarmRecords.setUpdateTime(DateUtils.getNowDate()); + emsAlarmRecords.setUpdateBy("system"); + + if (matchInfo != null) { + emsAlarmRecords.setAlarmPoint(matchInfo.getPoint()); + emsAlarmRecords.setAlarmContent(matchInfo.getAlarmDescription()); + } + return emsAlarmRecords; + } + + @Override + public void processBatch(List batchData) { + super.processBatch(batchData); + } + + // 空数据不处理 + private boolean checkJsonDataEmpty(String jsonData) { + boolean flag = false; + try { + if (StringUtils.isEmpty(jsonData)) { + flag = true; + } + JsonNode jsonNode = objectMapper.readTree(jsonData); + // 判断是否为空对象({}) + if (jsonNode.isObject() && jsonNode.isEmpty()) { + flag = true; + } + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + return flag; + } +} 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 f5e1d53..390f8eb 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 @@ -6,6 +6,7 @@ import com.alibaba.fastjson2.TypeReference; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.enums.PointType; import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; @@ -142,15 +143,16 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService String parentDeviceId = request.getParentId(); String ipAddress = request.getIpAddress(); Integer ipPort = request.getIpPort(); + Integer isAlarm = request.getIsAlarm() == null ? PointType.YES.getCode() : request.getIsAlarm(); // 电动所的电池簇特殊处理-来源pcs+bmsd if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { - response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort); + response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort,isAlarm); } else if (DeviceCategory.BATTERY.getCode().equals(deviceCategory)) { response = specialDealWithBattery(siteId,deviceId,deviceCategory, - dataPointName,dataPoint,parentDeviceId,ipAddress,ipPort); + dataPointName,dataPoint,parentDeviceId,ipAddress,ipPort,isAlarm); } else { response = emsPointMatchMapper.getSingleSiteDevicePoints( - siteId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort); + siteId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort,isAlarm); // 从redis取最新数据 JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); if(mqttJson == null){ @@ -235,9 +237,10 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService } private List specialDealWithBattery(String siteId, String deviceId, String deviceCategory, - String dataPointName, String dataPoint, String parentDeviceId, String ipAddress, Integer ipPort) { + String dataPointName, String dataPoint, String parentDeviceId, + String ipAddress, Integer ipPort, Integer isAlarm) { List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory, - dataPointName,dataPoint,ipAddress,ipPort); + dataPointName,dataPoint,ipAddress,ipPort,isAlarm); // 获取redis同步最新数据 JSONObject jsonObject = new JSONObject(); @@ -316,12 +319,13 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService // 对于dds的电池簇点位最新数据获取特殊处理 private List specialDealWithDDSCluster(String siteId, String deviceId, String deviceCategory, - String dataPointName, String dataPoint, String ipAddress, Integer ipPort) { + String dataPointName, String dataPoint, String ipAddress, + Integer ipPort, Integer isAlarm) { // 替换为对应的父类id String bmsdDeviceId = deviceId.replace("BMSC","BMSD"); List response = emsPointMatchMapper - .getClusterDevicePoints(siteId,deviceId,bmsdDeviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort); + .getClusterDevicePoints(siteId,deviceId,bmsdDeviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort,isAlarm); JSONObject mergedData = new JSONObject(); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index 2363075..ff625e5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -2,16 +2,22 @@ package com.xzzn.ems.service.impl; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; import com.alibaba.fastjson2.JSON; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.PointType; import com.xzzn.common.exception.ServiceException; import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanValidators; +import org.apache.commons.compress.utils.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -140,7 +146,6 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService } String siteId = request.getSiteId(); - String deviceId = request.getDeviceId(); String deviceCategory = request.getDeviceCategory(); List errorList = new ArrayList<>(); for (DevicePointMatchVo pointMatch : pointMatchList) { @@ -152,17 +157,22 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService EmsPointMatch savePoint = new EmsPointMatch(); BeanUtils.copyProperties(pointMatch, savePoint); savePoint.setSiteId(siteId); - savePoint.setDeviceId(deviceId); savePoint.setDeviceCategory(deviceCategory); - savePoint.setMatchTable(DeviceMatchTable.getMatchTableByCode(deviceCategory)); + if (StringUtils.isNotBlank(pointMatch.getIsAlarm()) && String.valueOf(PointType.YES.getCode()).equals(pointMatch.getIsAlarm())) { + savePoint.setMatchTable(DeviceMatchTable.getAlarmMatchTableByCode(deviceCategory)); + savePoint.setIsAlarm(PointType.YES.getCode()); + } else { + savePoint.setMatchTable(DeviceMatchTable.getMatchTableByCode(deviceCategory)); + } savePoint.setPointName(DevicePointMatchDataProcessor.getFieldAnnotation(DeviceMatchTable.getClassByTable(savePoint.getMatchTable()), StringUtils.toCamelCase(savePoint.getMatchField()))); savePoint.setCreateBy(operName); savePoint.setUpdateBy(operName); // 验证点位是否存在 - EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceId, deviceCategory, pointMatch.getDataPoint()); + EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceCategory, pointMatch.getDataPoint()); if (Objects.isNull(dbPoint)) { emsPointMatchMapper.insertEmsPointMatch(savePoint); } else { + savePoint.setId(dbPoint.getId()); emsPointMatchMapper.updateEmsPointMatch(savePoint); } } catch (Exception e) { @@ -171,7 +181,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService } } // 同步到Redis - syncToRedis(siteId, deviceId, deviceCategory); + syncToRedis(siteId, deviceCategory); return errorList; } @@ -197,10 +207,10 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService return false; } - private void syncToRedis(String siteId, String deviceId, String deviceCategory) { + private void syncToRedis(String siteId, String deviceCategory) { // 同步到Redis - String pointMatchKey = RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId + "_" + deviceId; - List pointMatchData = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceId, deviceCategory); + String pointMatchKey = DevicePointMatchDataProcessor.getPointMacthCacheKey(siteId, deviceCategory); + List pointMatchData = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceCategory); // log.info("同步点位匹配数据到Redis key:{} data:{}", pointMatchKey, pointMatchData); redisCache.setCacheObject(pointMatchKey, pointMatchData); log.info("点位匹配数据同步完成 data:{}", JSON.toJSONString(redisCache.getCacheObject(pointMatchKey))); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 03dd35d..9c4641b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -3,10 +3,12 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsAmmeterData; +import com.xzzn.ems.domain.EmsEnergyPriceConfig; import com.xzzn.ems.domain.vo.*; import com.xzzn.ems.mapper.*; import com.xzzn.ems.service.IEmsStatsReportService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -16,6 +18,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -43,6 +46,8 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService private EmsDailyChargeDataMapper emsDailyChargeDataMapper; @Autowired private EmsDailyEnergyDataMapper emsDailyEnergyDataMapper; + @Autowired + private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; // 电量指标 @Override @@ -305,6 +310,40 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService return dataList; } + @Override + public List getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) { + //查询电表数据 + List dataList = emsDailyEnergyDataMapper.getDataBySiteId(requestVo.getSiteId(), requestVo.getStartTime(), requestVo.getEndTime()); + if (CollectionUtils.isEmpty(dataList)){ + return null; + } + //查询电价配置 + List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(requestVo.getSiteId(), requestVo.getStartTime(), requestVo.getEndTime()); + if (CollectionUtils.isEmpty(priceConfigList)){ + return null; + } + Map priceConfigMap = priceConfigList.stream().collect(Collectors.toMap(data -> data.getYear() + "-" + String.format("%02d", Integer.parseInt(data.getMonth())), Function.identity())); + List resultList = new ArrayList<>(); + dataList.forEach(ammeter -> { + EmsEnergyPriceConfig price = priceConfigMap.get(ammeter.getDataTime().substring(0, 7)); + resultList.add(calculateDailyBill(ammeter, price)); + }); + + return resultList; + } + + public static AmmeterRevenueStatisListVo calculateDailyBill(AmmeterStatisListVo ammeter, EmsEnergyPriceConfig price) { + AmmeterRevenueStatisListVo ammeterRevenue = new AmmeterRevenueStatisListVo(); + ammeterRevenue.setDataTime(ammeter.getDataTime()); + if (price != null) { +// BigDecimal activeTotalPrice = ammeter.getActiveTotalKwh().multiply(new BigDecimal(price.getPeak())); +// BigDecimal activePeakPrice = ammeter.getActivePeakKwh().multiply(new BigDecimal(price.getPeak())); +// BigDecimal activeHighPrice = ammeter.getActiveHighKwh().multiply(new BigDecimal(price.getHigh())); +// BigDecimal activeFlatPrice = ammeter.getActiveFlatKwh().multiply(new BigDecimal(price.getFlat())); + } + return ammeterRevenue; + } + private void dealWithAmmeterTotalDate(AmmeterStatisListVo ammeterStatisListVo, AmmeterStatisListVo totalVo) { // 有功 totalVo.setActiveTotalKwh(totalVo.getActiveTotalKwh().add(ammeterStatisListVo.getActiveTotalKwh())); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 5bfdbfa..8f9d2bd 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -155,19 +155,14 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl }); EmsCoolingData coolingData = new EmsCoolingData(); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.COOLING.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, obj, coolingData); - } else { - coolingData.setGsTemp(StringUtils.getBigDecimal(obj.get("GSWD"))); - coolingData.setHsTemp(StringUtils.getBigDecimal(obj.get("HSWD"))); - coolingData.setGsPressure(StringUtils.getBigDecimal(obj.get("GSYL"))); - coolingData.setHsPressure(StringUtils.getBigDecimal(obj.get("HSYL"))); - coolingData.setLysTemp(StringUtils.getBigDecimal(obj.get("LYSWD"))); - coolingData.setVb01Kd(StringUtils.getBigDecimal(obj.get("VB1KD"))); - coolingData.setVb02Kd(StringUtils.getBigDecimal(obj.get("VB2KD"))); - } + + coolingData.setGsTemp(StringUtils.getBigDecimal(obj.get("GSWD"))); + coolingData.setHsTemp(StringUtils.getBigDecimal(obj.get("HSWD"))); + coolingData.setGsPressure(StringUtils.getBigDecimal(obj.get("GSYL"))); + coolingData.setHsPressure(StringUtils.getBigDecimal(obj.get("HSYL"))); + coolingData.setLysTemp(StringUtils.getBigDecimal(obj.get("LYSWD"))); + coolingData.setVb01Kd(StringUtils.getBigDecimal(obj.get("VB1KD"))); + coolingData.setVb02Kd(StringUtils.getBigDecimal(obj.get("VB2KD"))); coolingData.setCreateBy("system"); coolingData.setCreateTime(DateUtils.getNowDate()); @@ -180,7 +175,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.COOLING + SITE_ID + "_" +deviceId, coolingData); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.COOLING, "ZSLQ"); } private void dhDataProcess(String deviceId, String dataJson) { @@ -190,14 +184,8 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl //DH EmsDhData dhData = new EmsDhData(); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.DH.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, obj, dhData); - } else { - dhData.setHumidity(StringUtils.getBigDecimal(obj.get("SD3"))); - dhData.setTemperature(StringUtils.getBigDecimal(obj.get("WD3"))); - } + dhData.setHumidity(StringUtils.getBigDecimal(obj.get("SD3"))); + dhData.setTemperature(StringUtils.getBigDecimal(obj.get("WD3"))); dhData.setCreateBy("system"); dhData.setCreateTime(DateUtils.getNowDate()); @@ -209,7 +197,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.DH + SITE_ID + "_" +deviceId, dhData); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.DH, "donghuan"); } private void batteryStackDataProcess(String deviceId, String dataJson) { @@ -226,66 +213,58 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.STACK.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, obj, dataStack); - } else { + // 电池堆状态数据设置 + dataStack.setOperationStatus(StringUtils.getString(obj.get("DCZT"))); + dataStack.setStackVoltage(StringUtils.getBigDecimal(obj.get("DCDDY"))); + dataStack.setStackCurrent(StringUtils.getBigDecimal(obj.get("DCDDL"))); + dataStack.setStackSoc(StringUtils.getBigDecimal(obj.get("DCDSOC"))); + dataStack.setStackSoh(StringUtils.getBigDecimal(obj.get("DCDSOH"))); - // 电池堆状态数据设置 - dataStack.setOperationStatus(StringUtils.getString(obj.get("DCZT"))); - dataStack.setStackVoltage(StringUtils.getBigDecimal(obj.get("DCDDY"))); - dataStack.setStackCurrent(StringUtils.getBigDecimal(obj.get("DCDDL"))); - dataStack.setStackSoc(StringUtils.getBigDecimal(obj.get("DCDSOC"))); - dataStack.setStackSoh(StringUtils.getBigDecimal(obj.get("DCDSOH"))); + // 电压极值信息 + dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDCDY"))); + dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("ZGDCDYZH"))); + dataStack.setMaxVoltageCellId(StringUtils.getLong(obj.get("ZGDCDYZHDH"))); + dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDCDY"))); + dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("ZDDCDYZH"))); + dataStack.setMinVoltageCellId(StringUtils.getLong(obj.get("ZDDCDYZHDH"))); - // 电压极值信息 - dataStack.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDCDY"))); - dataStack.setMaxVoltageGroupId(StringUtils.getLong(obj.get("ZGDCDYZH"))); - dataStack.setMaxVoltageCellId(StringUtils.getLong(obj.get("ZGDCDYZHDH"))); - dataStack.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDCDY"))); - dataStack.setMinVoltageGroupId(StringUtils.getLong(obj.get("ZDDCDYZH"))); - dataStack.setMinVoltageCellId(StringUtils.getLong(obj.get("ZDDCDYZHDH"))); + // 温度极值信息 + dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDCWD"))); + dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("ZGDCWDZH"))); + dataStack.setMaxTempCellId(StringUtils.getLong(obj.get("ZGDCWDZHDH"))); + dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDCWD"))); + dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("ZDDCWDZH"))); + dataStack.setMinTempCellId(StringUtils.getLong(obj.get("ZDDCWDZHDH"))); - // 温度极值信息 - dataStack.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDCWD"))); - dataStack.setMaxTempGroupId(StringUtils.getLong(obj.get("ZGDCWDZH"))); - dataStack.setMaxTempCellId(StringUtils.getLong(obj.get("ZGDCWDZHDH"))); - dataStack.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDCWD"))); - dataStack.setMinTempGroupId(StringUtils.getLong(obj.get("ZDDCWDZH"))); - dataStack.setMinTempCellId(StringUtils.getLong(obj.get("ZDDCWDZHDH"))); + // 电量统计信息 + dataStack.setTotalChargeCapacity(StringUtils.getBigDecimal(obj.get("DLJCDDL"))); + dataStack.setTotalDischargeCapacity(StringUtils.getBigDecimal(obj.get("DLCFDDL"))); + dataStack.setSessionChargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJCDDL"))); + dataStack.setSessionDischargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJFDDL"))); + dataStack.setAvailableChargeCapacity(StringUtils.getBigDecimal(obj.get("DKCDL"))); + dataStack.setAvailableDischargeCapacity(StringUtils.getBigDecimal(obj.get("DKFDL"))); - // 电量统计信息 - dataStack.setTotalChargeCapacity(StringUtils.getBigDecimal(obj.get("DLJCDDL"))); - dataStack.setTotalDischargeCapacity(StringUtils.getBigDecimal(obj.get("DLCFDDL"))); - dataStack.setSessionChargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJCDDL"))); - dataStack.setSessionDischargeCapacity(StringUtils.getBigDecimal(obj.get("DDCLJFDDL"))); - dataStack.setAvailableChargeCapacity(StringUtils.getBigDecimal(obj.get("DKCDL"))); - dataStack.setAvailableDischargeCapacity(StringUtils.getBigDecimal(obj.get("DKFDL"))); + // 时间信息 + dataStack.setRemainingDischargeTime(StringUtils.getLong(obj.get("KYFDSJ"))); + dataStack.setRemainingChargeTime(StringUtils.getLong(obj.get("KYCDSJ"))); - // 时间信息 - dataStack.setRemainingDischargeTime(StringUtils.getLong(obj.get("KYFDSJ"))); - dataStack.setRemainingChargeTime(StringUtils.getLong(obj.get("KYCDSJ"))); + // 功率/电流限制 + dataStack.setMaxDischargePower(StringUtils.getBigDecimal(obj.get("YXZDFDGL"))); + dataStack.setMaxChargePower(StringUtils.getBigDecimal(obj.get("YXZDCDGL"))); + dataStack.setMaxDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDFDDL"))); + dataStack.setMaxChargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDCDDL"))); - // 功率/电流限制 - dataStack.setMaxDischargePower(StringUtils.getBigDecimal(obj.get("YXZDFDGL"))); - dataStack.setMaxChargePower(StringUtils.getBigDecimal(obj.get("YXZDCDGL"))); - dataStack.setMaxDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDFDDL"))); - dataStack.setMaxChargeCurrent(StringUtils.getBigDecimal(obj.get("YXZDCDDL"))); + // 当日统计 + dataStack.setDailyDischargeCycles(StringUtils.getLong(obj.get("DTFDCS"))); + dataStack.setDailyChargeCycles(StringUtils.getLong(obj.get("DTCDCS"))); + dataStack.setDailyDischargeCapacity(StringUtils.getBigDecimal(obj.get("DTFDDL"))); + dataStack.setDailyChargeCapacity(StringUtils.getBigDecimal(obj.get("DTCDDL"))); - // 当日统计 - dataStack.setDailyDischargeCycles(StringUtils.getLong(obj.get("DTFDCS"))); - dataStack.setDailyChargeCycles(StringUtils.getLong(obj.get("DTCDCS"))); - dataStack.setDailyDischargeCapacity(StringUtils.getBigDecimal(obj.get("DTFDDL"))); - dataStack.setDailyChargeCapacity(StringUtils.getBigDecimal(obj.get("DTCDDL"))); - - // 系统状态 - dataStack.setOperatingTemp(StringUtils.getBigDecimal(obj.get("YXWD"))); - dataStack.setBmsStatus(StringUtils.getString(obj.get("BMSDDQZT"))); - dataStack.setBmsChargeStatus(StringUtils.getString(obj.get("BMSCFDZT"))); - dataStack.setStackInsulationResistance(StringUtils.getBigDecimal(obj.get("DCDJYDZ"))); - - } + // 系统状态 + dataStack.setOperatingTemp(StringUtils.getBigDecimal(obj.get("YXWD"))); + dataStack.setBmsStatus(StringUtils.getString(obj.get("BMSDDQZT"))); + dataStack.setBmsChargeStatus(StringUtils.getString(obj.get("BMSCFDZT"))); + dataStack.setStackInsulationResistance(StringUtils.getBigDecimal(obj.get("DCDJYDZ"))); dataStack.setCreateBy("system"); @@ -299,7 +278,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.STACK + SITE_ID + "_" +deviceId, dataStack); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.STACK, "BMSD"); } private void saveDeviceData(List pointMatchList, Map obj, Object entity) { @@ -350,58 +328,51 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl } //BMS 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.CLUSTER.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, obj, data); - } else { + // 设置所有 BigDecimal 类型字段为 ZERO + data.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); + data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); + data.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); + data.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); + data.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); + data.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); + data.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); + data.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); + data.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); + data.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); + data.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); + data.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); + data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); + data.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); + data.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); + data.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); + data.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); + data.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); + data.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); + data.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); + data.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); + data.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); + data.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); + data.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); + data.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); + data.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); + data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); + data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); - // 设置所有 BigDecimal 类型字段为 ZERO - data.setChargeableCapacity(StringUtils.getBigDecimal(obj.get("KCDL"))); - data.setClusterVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); - data.setClusterCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); - data.setTotalChargedCapacity(StringUtils.getBigDecimal(obj.get("LJCDDL"))); - data.setDischargeableCapacity(StringUtils.getBigDecimal(obj.get("KFDL"))); - data.setTotalDischargedCapacity(StringUtils.getBigDecimal(obj.get("LJFDDL"))); - data.setSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - data.setAverageTemperature(StringUtils.getBigDecimal(obj.get("MKWD"))); - data.setInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - data.setCurrentSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - data.setMaxAllowedChargePower(StringUtils.getBigDecimal(obj.get("YXCDZDGL"))); - data.setMaxAllowedDischargePower(StringUtils.getBigDecimal(obj.get("YXFDZDGL"))); - data.setMaxAllowedChargeVoltage(StringUtils.getBigDecimal(obj.get("YXCDZDDY"))); - data.setMaxAllowedDischargeVoltage(StringUtils.getBigDecimal(obj.get("YXFDZDDY"))); - data.setMaxAllowedChargeCurrent(StringUtils.getBigDecimal(obj.get("YXCDZDDL"))); - data.setMaxAllowedDischargeCurrent(StringUtils.getBigDecimal(obj.get("YXFDZDDL"))); - data.setBatteryPackVoltage(StringUtils.getBigDecimal(obj.get("ZDY"))); - data.setBatteryPackCurrent(StringUtils.getBigDecimal(obj.get("ZDL"))); - data.setBatteryPackTemp(StringUtils.getBigDecimal(obj.get("MKWD"))); - data.setBatteryPackSoc(StringUtils.getBigDecimal(obj.get("ZSOC"))); - data.setBatteryPackSoh(StringUtils.getBigDecimal(obj.get("ZSOH"))); - data.setBatteryPackInsulationResistance(StringUtils.getBigDecimal(obj.get("ZJYDZ"))); - data.setAvgCellVoltage(StringUtils.getBigDecimal(obj.get("PJDTDY"))); - data.setAvgCellTemp(StringUtils.getBigDecimal(obj.get("PJDTWD"))); - data.setMaxCellVoltage(StringUtils.getBigDecimal(obj.get("ZGDTDY"))); - data.setMinCellVoltage(StringUtils.getBigDecimal(obj.get("ZDDTDY"))); - data.setMaxCellTemp(StringUtils.getBigDecimal(obj.get("ZGDTWD"))); - data.setMinCellTemp(StringUtils.getBigDecimal(obj.get("ZDDTWD"))); - data.setMaxCellSoc(StringUtils.getBigDecimal(obj.get("ZGDTSOC"))); - data.setMinCellSoc(StringUtils.getBigDecimal(obj.get("ZDDTSOC"))); - data.setMaxCellSoh(StringUtils.getBigDecimal(obj.get("ZGDTSOH"))); - data.setMinCellSoh(StringUtils.getBigDecimal(obj.get("ZDDTSOH"))); - data.setTotalChargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJCDDL"))); - data.setTotalDischargeEnergy(StringUtils.getBigDecimal(obj.get("DCLJFDDL"))); - - // 其他非 BigDecimal 字段 - data.setMaxCellVoltageId(StringUtils.getString(obj.get("ZGDTDYDYD"))); - data.setMinCellVoltageId(StringUtils.getString(obj.get("ZDDTDYDYD"))); - data.setMaxCellTempId(StringUtils.getString(obj.get("ZGDTWDDYD"))); - data.setMinCellTempId(StringUtils.getString(obj.get("ZDDTWDDYD"))); - data.setMaxCellSocId(StringUtils.getString(obj.get("ZGDTSOCDYD"))); - data.setMinCellSocId(StringUtils.getString(obj.get("ZDDTSOCDYD"))); - data.setMaxCellSohId(StringUtils.getString(obj.get("ZGDTSOHDYD"))); - data.setMinCellSohId(StringUtils.getString(obj.get("ZDDTSOHDYD"))); - } + // 其他非 BigDecimal 字段 + data.setMaxCellVoltageId(StringUtils.getString(obj.get("ZGDTDYDYD"))); + data.setMinCellVoltageId(StringUtils.getString(obj.get("ZDDTDYDYD"))); + data.setMaxCellTempId(StringUtils.getString(obj.get("ZGDTWDDYD"))); + data.setMinCellTempId(StringUtils.getString(obj.get("ZDDTWDDYD"))); + data.setMaxCellSocId(StringUtils.getString(obj.get("ZGDTSOCDYD"))); + data.setMinCellSocId(StringUtils.getString(obj.get("ZDDTSOCDYD"))); + data.setMaxCellSohId(StringUtils.getString(obj.get("ZGDTSOHDYD"))); + data.setMinCellSohId(StringUtils.getString(obj.get("ZDDTSOHDYD"))); data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); @@ -421,7 +392,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.CLUSTER + SITE_ID + "_" +deviceId, data); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.CLUSTER, "BMSC"); } private void batteryDataProcess(String deviceId, String dataJson, Date dataUpdateTime) { @@ -444,8 +414,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl LocalDateTime oneHourAgo = LocalDateTime.now().minus(1, ChronoUnit.HOURS); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String oneHourAgoStr = oneHourAgo.format(formatter); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.BATTERY.getCode()); //单体电池 for (Map.Entry> record : records.entrySet()) { String recordId = record.getKey(); @@ -455,14 +423,10 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl batteryData.setDeviceId(recordId); batteryData.setBatteryCellId(recordId); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, fields, batteryData); - } else { - batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); - batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); - batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); - batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); - } + batteryData.setSoc(StringUtils.getBigDecimal(fields.get("DTSOC"))); + batteryData.setSoh(StringUtils.getBigDecimal(fields.get("DTSOH"))); + batteryData.setTemperature(StringUtils.getBigDecimal(fields.get("DTWD"))); + batteryData.setVoltage(StringUtils.getBigDecimal(fields.get("DTDY"))); batteryData.setBatteryCluster(deviceId); batteryData.setBatteryPack(stackDeviceId); @@ -496,7 +460,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.deleteList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId); redisCache.setCacheList(RedisKeyConstants.BATTERY + SITE_ID + "_" + deviceId, list); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.BATTERY, "BMSC"); } // 批量处理每日最新数据 @@ -523,62 +486,54 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl //pcs EmsPcsData pcsData = new EmsPcsData(); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.PCS.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, obj, pcsData); - } else { - - // 功率与能量类字段 - pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("YGGL"))); - pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); - pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("XTWGGL"))); - pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); - pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); - pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); - pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); - pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("ZCDL"))); - pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFDL"))); - pcsData.setAcChargeActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); - pcsData.setAcCapacitiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); - pcsData.setAcDischargeActivePower(StringUtils.getBigDecimal(obj.get("JLCFDYGGL"))); - pcsData.setAcInductiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCGXWGGL"))); - pcsData.setMaxCapacitivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDRXWGNL"))); - pcsData.setMaxInductivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDGXWGNL"))); - pcsData.setMaxChargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKCGL"))); - pcsData.setMaxDischargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKFGL"))); + // 功率与能量类字段 + pcsData.setTotalActivePower(StringUtils.getBigDecimal(obj.get("YGGL"))); + pcsData.setDailyAcChargeEnergy(StringUtils.getBigDecimal(obj.get("RCDL"))); + pcsData.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("XTWGGL"))); + pcsData.setDailyAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("RFDL"))); + pcsData.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("GLYS"))); + pcsData.setDcPower(StringUtils.getBigDecimal(obj.get("XTSZGL"))); + pcsData.setTotalAcChargeEnergy(StringUtils.getBigDecimal(obj.get("ZCDL"))); + pcsData.setTotalAcDischargeEnergy(StringUtils.getBigDecimal(obj.get("ZFDL"))); + pcsData.setAcChargeActivePower(StringUtils.getBigDecimal(obj.get("JLCCDYGGL"))); + pcsData.setAcCapacitiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCRXWGGL"))); + pcsData.setAcDischargeActivePower(StringUtils.getBigDecimal(obj.get("JLCFDYGGL"))); + pcsData.setAcInductiveReactivePower(StringUtils.getBigDecimal(obj.get("JLCGXWGGL"))); + pcsData.setMaxCapacitivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDRXWGNL"))); + pcsData.setMaxInductivePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDGXWGNL"))); + pcsData.setMaxChargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKCGL"))); + pcsData.setMaxDischargePowerCapacity(StringUtils.getBigDecimal(obj.get("ZDKFGL"))); - // 温度与环境参数 + // 温度与环境参数 // pcsData.setPcsModuleTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); // pcsData.setPcsEnvironmentTemperature(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); // pcsData.setAcFrequency(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); - // 状态指示类 - pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); - pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); - String acSwitchStatus = StringUtils.getString(obj.get("JLKGZT")); - pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); - String dcSwitchStatus = StringUtils.getString(obj.get("ZLKGZT")); - pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); - String controlMode = StringUtils.getString(obj.get("YCTT")); - pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); + // 状态指示类 + pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); + pcsData.setDischargeStatus(ChargeStatus.CHARGING.getCode()); + String acSwitchStatus = StringUtils.getString(obj.get("JLKGZT")); + pcsData.setAcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String dcSwitchStatus = StringUtils.getString(obj.get("ZLKGZT")); + pcsData.setDcSwitchStatus(SwitchStatus.CLOSED.getCode()); + String controlMode = StringUtils.getString(obj.get("YCTT")); + pcsData.setRemoteControlStatus(ControlModeStatus.REMOTE.getCode()); - // 电流参数 - pcsData.setSysUCurrent(StringUtils.getBigDecimal(obj.get("XTSCUXDL"))); - pcsData.setSysVCurrent(StringUtils.getBigDecimal(obj.get("XTSCVXDL"))); - pcsData.setSysWCurrent(StringUtils.getBigDecimal(obj.get("XTSCWXDL"))); + // 电流参数 + pcsData.setSysUCurrent(StringUtils.getBigDecimal(obj.get("XTSCUXDL"))); + pcsData.setSysVCurrent(StringUtils.getBigDecimal(obj.get("XTSCVXDL"))); + pcsData.setSysWCurrent(StringUtils.getBigDecimal(obj.get("XTSCWXDL"))); - // 直流参数 + // 直流参数 // pcsData.setDcVoltage(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); // pcsData.setDcCurrent(StringUtils.getBigDecimal(obj.get("ChargeableCapacity"))); - // 三相温度 - pcsData.setuTemperature(StringUtils.getBigDecimal(obj.get("DY1UXIGBTWD"))); - pcsData.setvTemperature(StringUtils.getBigDecimal(obj.get("DY1VXIGBTWD"))); - pcsData.setwTemperature(StringUtils.getBigDecimal(obj.get("DY1WXIGBTWD"))); - - } + // 三相温度 + pcsData.setuTemperature(StringUtils.getBigDecimal(obj.get("DY1UXIGBTWD"))); + pcsData.setvTemperature(StringUtils.getBigDecimal(obj.get("DY1VXIGBTWD"))); + pcsData.setwTemperature(StringUtils.getBigDecimal(obj.get("DY1WXIGBTWD"))); // 时间与状态类字段 pcsData.setDataUpdateTime(dataUpdateTime); @@ -599,15 +554,13 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl emsPcsDataMapper.insertEmsPcsData(pcsData); redisCache.setCacheObject(RedisKeyConstants.PCS + SITE_ID + "_" +deviceId, pcsData); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.PCS, "PCS"); + } private void pcsBranchDataProcess(String deviceId, String dataJson) { Map> records = processDataPrefix(JSON.parseObject(dataJson, new TypeReference>() {})); List list = new ArrayList<>(); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.BRANCH.getCode()); //PCS支路 for (Map.Entry> record : records.entrySet()) { @@ -618,32 +571,28 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl data.setDeviceId(deviceId); data.setSiteId(SITE_ID); data.setGridStatus(GridStatus.GRID.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, fields, data); - } else { - data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); - data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); - data.setDcCurrent(StringUtils.getBigDecimal(fields.get("ZLDL"))); - data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWUXDY"))); - data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWVXDY"))); - data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWWXDY"))); - data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("SCUXDL"))); - data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("SCVXDL"))); - data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("SCWXDL"))); - data.setApparentPower(StringUtils.getBigDecimal(fields.get("SZGL"))); - data.setActivePower(StringUtils.getBigDecimal(fields.get("YGGL"))); - data.setReactivePower(StringUtils.getBigDecimal(fields.get("WGGL"))); - data.setPowerFactor(StringUtils.getBigDecimal(fields.get("GLYS"))); - data.setFrequency(StringUtils.getBigDecimal(fields.get("PL"))); - data.setInternalTemp(StringUtils.getBigDecimal(fields.get("DY1WD"))); - data.setuIgbtTemp(StringUtils.getBigDecimal(fields.get("UXIGBTWD"))); - data.setvIgbtTemp(StringUtils.getBigDecimal(fields.get("VXIGBTWD"))); - data.setwIgbtTemp(StringUtils.getBigDecimal(fields.get("WXIGBTWD"))); - data.setAvailablePower(StringUtils.getBigDecimal(fields.get("KYGL"))); - data.setTotalLoadRatio(StringUtils.getBigDecimal(fields.get("ZFZB"))); - data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); - data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); - } + data.setDcPower(StringUtils.getBigDecimal(fields.get("ZLGL"))); + data.setDcVoltage(StringUtils.getBigDecimal(fields.get("ZLDY"))); + data.setDcCurrent(StringUtils.getBigDecimal(fields.get("ZLDL"))); + data.setGridUVoltage(StringUtils.getBigDecimal(fields.get("DWUXDY"))); + data.setGridVVoltage(StringUtils.getBigDecimal(fields.get("DWVXDY"))); + data.setGridWVoltage(StringUtils.getBigDecimal(fields.get("DWWXDY"))); + data.setOutputUCurrent(StringUtils.getBigDecimal(fields.get("SCUXDL"))); + data.setOutputVCurrent(StringUtils.getBigDecimal(fields.get("SCVXDL"))); + data.setOutputWCurrent(StringUtils.getBigDecimal(fields.get("SCWXDL"))); + data.setApparentPower(StringUtils.getBigDecimal(fields.get("SZGL"))); + data.setActivePower(StringUtils.getBigDecimal(fields.get("YGGL"))); + data.setReactivePower(StringUtils.getBigDecimal(fields.get("WGGL"))); + data.setPowerFactor(StringUtils.getBigDecimal(fields.get("GLYS"))); + data.setFrequency(StringUtils.getBigDecimal(fields.get("PL"))); + data.setInternalTemp(StringUtils.getBigDecimal(fields.get("DY1WD"))); + data.setuIgbtTemp(StringUtils.getBigDecimal(fields.get("UXIGBTWD"))); + data.setvIgbtTemp(StringUtils.getBigDecimal(fields.get("VXIGBTWD"))); + data.setwIgbtTemp(StringUtils.getBigDecimal(fields.get("WXIGBTWD"))); + data.setAvailablePower(StringUtils.getBigDecimal(fields.get("KYGL"))); + data.setTotalLoadRatio(StringUtils.getBigDecimal(fields.get("ZFZB"))); + data.setAcLeakageCurrent(StringUtils.getBigDecimal(fields.get("JLLDL"))); + data.setInsulationResistance(StringUtils.getBigDecimal(fields.get("JYZK"))); data.setBranchId(recordId); data.setCreateBy("system"); data.setCreateTime(DateUtils.getNowDate()); @@ -656,7 +605,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.BRANCH + SITE_ID + "_" +deviceId, list); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.BRANCH, "PCS"); } } @@ -671,90 +619,83 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl // 更新时间 dataLoad.setDataUpdateTime(dataUpdateTime); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.AMMETER.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, obj, dataLoad); - } else { + // 电能设置-组合有功 + dataLoad.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); + dataLoad.setCurrentCombActivePeak(StringUtils.getBigDecimal(obj.get("DQZHYGJDN"))); + dataLoad.setCurrentCombActiveHigh(StringUtils.getBigDecimal(obj.get("DQZHYGFDN"))); + dataLoad.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); + dataLoad.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); + // 电能设置-正向有功 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); + dataLoad.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); + dataLoad.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); + dataLoad.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); + dataLoad.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); + // 电能设置-反向有功 + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); + dataLoad.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); + dataLoad.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); + dataLoad.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); + dataLoad.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))); + // 电能设置-组合无功 + dataLoad.setCurrentCombReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZHWGZDN"))); + dataLoad.setCurrentCombReactivePeak(StringUtils.getBigDecimal(obj.get("DQZHWGJDN"))); + dataLoad.setCurrentCombReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZHWGFDN"))); + dataLoad.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); + dataLoad.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); + // 电能设置-正向无功 + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); + dataLoad.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); + dataLoad.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); + dataLoad.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); + dataLoad.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); + // 电能设置-反向无功 + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); + dataLoad.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); + dataLoad.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); + dataLoad.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); + dataLoad.setCurrentReverseReactiveValley(StringUtils.getBigDecimal(obj.get("DQFXWGGDN"))); - // 电能设置-组合有功 - dataLoad.setCurrentCombActiveTotal(StringUtils.getBigDecimal(obj.get("DQZHYGZDN"))); - dataLoad.setCurrentCombActivePeak(StringUtils.getBigDecimal(obj.get("DQZHYGJDN"))); - dataLoad.setCurrentCombActiveHigh(StringUtils.getBigDecimal(obj.get("DQZHYGFDN"))); - dataLoad.setCurrentCombActiveFlat(StringUtils.getBigDecimal(obj.get("DQZHYGPDN"))); - dataLoad.setCurrentCombActiveValley(StringUtils.getBigDecimal(obj.get("DQZHYGGDN"))); - // 电能设置-正向有功 - dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("DQZXYGZDN"))); - dataLoad.setCurrentForwardActivePeak(StringUtils.getBigDecimal(obj.get("DQZXYGJDN"))); - dataLoad.setCurrentForwardActiveHigh(StringUtils.getBigDecimal(obj.get("DQZXYGFDN"))); - dataLoad.setCurrentForwardActiveFlat(StringUtils.getBigDecimal(obj.get("DQZXYGPDN"))); - dataLoad.setCurrentForwardActiveValley(StringUtils.getBigDecimal(obj.get("DQZXYGGDN"))); - // 电能设置-反向有功 - dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("DQFXYGZDN"))); - dataLoad.setCurrentReverseActivePeak(StringUtils.getBigDecimal(obj.get("DQFXYGJDN"))); - dataLoad.setCurrentReverseActiveHigh(StringUtils.getBigDecimal(obj.get("DQFXYGFDN"))); - dataLoad.setCurrentReverseActiveFlat(StringUtils.getBigDecimal(obj.get("DQFXYGPDN"))); - dataLoad.setCurrentReverseActiveValley(StringUtils.getBigDecimal(obj.get("DQFXYGGDN"))); - // 电能设置-组合无功 - dataLoad.setCurrentCombReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZHWGZDN"))); - dataLoad.setCurrentCombReactivePeak(StringUtils.getBigDecimal(obj.get("DQZHWGJDN"))); - dataLoad.setCurrentCombReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZHWGFDN"))); - dataLoad.setCurrentCombReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZHWGPDN"))); - dataLoad.setCurrentCombReactiveValley(StringUtils.getBigDecimal(obj.get("DQZHWGGDN"))); - // 电能设置-正向无功 - dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("DQZXWGZDN"))); - dataLoad.setCurrentForwardReactivePeak(StringUtils.getBigDecimal(obj.get("DQZXWGJDN"))); - dataLoad.setCurrentForwardReactiveHigh(StringUtils.getBigDecimal(obj.get("DQZXWGFDN"))); - dataLoad.setCurrentForwardReactiveFlat(StringUtils.getBigDecimal(obj.get("DQZXWGPDN"))); - dataLoad.setCurrentForwardReactiveValley(StringUtils.getBigDecimal(obj.get("DQZXWGGDN"))); - // 电能设置-反向无功 - dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("DQFXWGZDN"))); - dataLoad.setCurrentReverseReactivePeak(StringUtils.getBigDecimal(obj.get("DQFXWGJDN"))); - dataLoad.setCurrentReverseReactiveHigh(StringUtils.getBigDecimal(obj.get("DQFXWGFDN"))); - dataLoad.setCurrentReverseReactiveFlat(StringUtils.getBigDecimal(obj.get("DQFXWGPDN"))); - dataLoad.setCurrentReverseReactiveValley(StringUtils.getBigDecimal(obj.get("DQFXWGGDN"))); + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); - // 电压+电流 - dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); - dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); - dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); - dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); - dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); - dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("CBXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("ACXDY"))); - dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); - dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("CBXDY"))); - dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("ACXDY"))); + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("PL"))); - // 频率 - dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("PL"))); + // 功率 有功+总+无功+无总+视在 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + dataLoad.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); + dataLoad.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); + dataLoad.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); - // 功率 有功+总+无功+无总+视在 - dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); - dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); - dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); - dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); - dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); - dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); - dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); - dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); - dataLoad.setPhaseAApparentPower(StringUtils.getBigDecimal(obj.get("AXSZGL"))); - dataLoad.setPhaseBApparentPower(StringUtils.getBigDecimal(obj.get("BXSZGL"))); - dataLoad.setPhaseCApparentPower(StringUtils.getBigDecimal(obj.get("CXSZGL"))); - dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + // 功率因数 + dataLoad.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); + dataLoad.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); + dataLoad.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); - // 功率因数 - dataLoad.setPhaseAPowerFactor(StringUtils.getBigDecimal(obj.get("AXGLYS"))); - dataLoad.setPhaseBPowerFactor(StringUtils.getBigDecimal(obj.get("BXGLYS"))); - dataLoad.setPhaseCPowerFactor(StringUtils.getBigDecimal(obj.get("CXGLYS"))); - dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + // 需量 + dataLoad.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); + dataLoad.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); + dataLoad.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); - // 需量 - dataLoad.setForwardAcMaxDemand(StringUtils.getBigDecimal(obj.get("ZXYGZDXL"))); - dataLoad.setReverseAcMaxDemand(StringUtils.getBigDecimal(obj.get("FXYGZDXL"))); - dataLoad.setDailyForwardMaxDemand(StringUtils.getBigDecimal(obj.get("DRZXYGZDXL"))); - - } dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); dataLoad.setUpdateBy("system"); @@ -766,7 +707,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.AMMETER, "LOAD"); } private void dealFXXDailyChargeDate(String deviceId, String dataJson) { @@ -805,84 +745,78 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl EmsAmmeterData dataLoad = new EmsAmmeterData(); // 更新时间 dataLoad.setDataUpdateTime(dataUpdateTime); - // 点位匹配数据 - List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(SITE_ID, deviceId, DeviceMatchTable.AMMETER.getCode()); - if (CollectionUtils.isNotEmpty(pointMatchList)) { - saveDeviceData(pointMatchList, obj, dataLoad); - } else { - // 电压+电流 - dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); - dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); - dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); - dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); - dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); - dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); + // 电压+电流 + dataLoad.setPhaseAVoltage(StringUtils.getBigDecimal(obj.get("AXDY"))); + dataLoad.setPhaseBVoltage(StringUtils.getBigDecimal(obj.get("BXDY"))); + dataLoad.setPhaseCVoltage(StringUtils.getBigDecimal(obj.get("CXDY"))); + dataLoad.setPhaseACurrent(StringUtils.getBigDecimal(obj.get("AXDL"))); + dataLoad.setPhaseBCurrent(StringUtils.getBigDecimal(obj.get("BXDL"))); + dataLoad.setPhaseCCurrent(StringUtils.getBigDecimal(obj.get("CXDL"))); - dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); - dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); - dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); + dataLoad.setAbLineVoltage(StringUtils.getBigDecimal(obj.get("ABXDY"))); + dataLoad.setCbLineVoltage(StringUtils.getBigDecimal(obj.get("BCXDY"))); + dataLoad.setAcLineVoltage(StringUtils.getBigDecimal(obj.get("CAXDY"))); - // 频率 - dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); + // 频率 + dataLoad.setFrequency(StringUtils.getBigDecimal(obj.get("DWPL"))); - // 功率 - dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); - dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); - dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); - dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); - dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); - dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); - dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); - dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); + // 功率 + dataLoad.setPhaseAActivePower(StringUtils.getBigDecimal(obj.get("AXYGGL"))); + dataLoad.setPhaseBActivePower(StringUtils.getBigDecimal(obj.get("BXYGGL"))); + dataLoad.setPhaseCActivePower(StringUtils.getBigDecimal(obj.get("CXYGGL"))); + dataLoad.setTotalActivePower(StringUtils.getBigDecimal(obj.get("ZYGGL"))); + dataLoad.setPhaseAReactivePower(StringUtils.getBigDecimal(obj.get("AXWGGL"))); + dataLoad.setPhaseBReactivePower(StringUtils.getBigDecimal(obj.get("BXWGGL"))); + dataLoad.setPhaseCReactivePower(StringUtils.getBigDecimal(obj.get("CXWGGL"))); + dataLoad.setTotalReactivePower(StringUtils.getBigDecimal(obj.get("ZWGGL"))); - dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); - dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); + dataLoad.setTotalApparentPower(StringUtils.getBigDecimal(obj.get("ZSZGL"))); + dataLoad.setTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ZGLYS"))); - // 二次相关数据 - dataLoad.setSecondaryAbLineVoltage(StringUtils.getBigDecimal(obj.get("ECABXDY"))); - dataLoad.setSecondaryAPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECAXDL"))); - dataLoad.setSecondaryAPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECAXDY"))); - dataLoad.setSecondaryAPowerFactor(StringUtils.getBigDecimal(obj.get("ECAXGLYS"))); - dataLoad.setSecondaryAApparentPower(StringUtils.getBigDecimal(obj.get("ECAXSZGL"))); - dataLoad.setSecondaryAReactivePower(StringUtils.getBigDecimal(obj.get("ECAXWGGL"))); - dataLoad.setSecondaryAActivePower(StringUtils.getBigDecimal(obj.get("ECAXYGGL"))); - dataLoad.setSecondaryBcLineVoltage(StringUtils.getBigDecimal(obj.get("ECBCXDY"))); - dataLoad.setSecondaryBPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECBXDL"))); - dataLoad.setSecondaryBPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECBXDY"))); - dataLoad.setSecondaryBPowerFactor(StringUtils.getBigDecimal(obj.get("ECBXGLYS"))); - dataLoad.setSecondaryBApparentPower(StringUtils.getBigDecimal(obj.get("ECBXSZGL"))); - dataLoad.setSecondaryBReactivePower(StringUtils.getBigDecimal(obj.get("ECBXWGGL"))); - dataLoad.setSecondaryBActivePower(StringUtils.getBigDecimal(obj.get("ECBXYGGL"))); - dataLoad.setSecondaryCaLineVoltage(StringUtils.getBigDecimal(obj.get("ECCAXDY"))); - dataLoad.setSecondaryCPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECCXDL"))); - dataLoad.setSecondaryCPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECCXDY"))); - dataLoad.setSecondaryCPowerFactor(StringUtils.getBigDecimal(obj.get("ECCXGLYS"))); - dataLoad.setSecondaryCApparentPower(StringUtils.getBigDecimal(obj.get("ECCXSZGL"))); - dataLoad.setSecondaryCReactivePower(StringUtils.getBigDecimal(obj.get("ECCXWGGL"))); - dataLoad.setSecondaryCActivePower(StringUtils.getBigDecimal(obj.get("ECCXYGGL"))); - dataLoad.setSecondaryGridFrequency(StringUtils.getBigDecimal(obj.get("ECDWPL"))); - dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXWGDN"))); - dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXYGDN"))); - dataLoad.setSecondaryTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ECZGLYS"))); - dataLoad.setSecondaryTotalApparentPower(StringUtils.getBigDecimal(obj.get("ECZSZFL"))); - dataLoad.setSecondaryTotalReactivePower(StringUtils.getBigDecimal(obj.get("ECZWGGL"))); - dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXWGDN"))); - dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXYGDN"))); - dataLoad.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ECZYGGL"))); + // 二次相关数据 + dataLoad.setSecondaryAbLineVoltage(StringUtils.getBigDecimal(obj.get("ECABXDY"))); + dataLoad.setSecondaryAPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECAXDL"))); + dataLoad.setSecondaryAPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECAXDY"))); + dataLoad.setSecondaryAPowerFactor(StringUtils.getBigDecimal(obj.get("ECAXGLYS"))); + dataLoad.setSecondaryAApparentPower(StringUtils.getBigDecimal(obj.get("ECAXSZGL"))); + dataLoad.setSecondaryAReactivePower(StringUtils.getBigDecimal(obj.get("ECAXWGGL"))); + dataLoad.setSecondaryAActivePower(StringUtils.getBigDecimal(obj.get("ECAXYGGL"))); + dataLoad.setSecondaryBcLineVoltage(StringUtils.getBigDecimal(obj.get("ECBCXDY"))); + dataLoad.setSecondaryBPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECBXDL"))); + dataLoad.setSecondaryBPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECBXDY"))); + dataLoad.setSecondaryBPowerFactor(StringUtils.getBigDecimal(obj.get("ECBXGLYS"))); + dataLoad.setSecondaryBApparentPower(StringUtils.getBigDecimal(obj.get("ECBXSZGL"))); + dataLoad.setSecondaryBReactivePower(StringUtils.getBigDecimal(obj.get("ECBXWGGL"))); + dataLoad.setSecondaryBActivePower(StringUtils.getBigDecimal(obj.get("ECBXYGGL"))); + dataLoad.setSecondaryCaLineVoltage(StringUtils.getBigDecimal(obj.get("ECCAXDY"))); + dataLoad.setSecondaryCPhaseCurrent(StringUtils.getBigDecimal(obj.get("ECCXDL"))); + dataLoad.setSecondaryCPhaseVoltage(StringUtils.getBigDecimal(obj.get("ECCXDY"))); + dataLoad.setSecondaryCPowerFactor(StringUtils.getBigDecimal(obj.get("ECCXGLYS"))); + dataLoad.setSecondaryCApparentPower(StringUtils.getBigDecimal(obj.get("ECCXSZGL"))); + dataLoad.setSecondaryCReactivePower(StringUtils.getBigDecimal(obj.get("ECCXWGGL"))); + dataLoad.setSecondaryCActivePower(StringUtils.getBigDecimal(obj.get("ECCXYGGL"))); + dataLoad.setSecondaryGridFrequency(StringUtils.getBigDecimal(obj.get("ECDWPL"))); + dataLoad.setSecondaryReverseReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXWGDN"))); + dataLoad.setSecondaryNegativeActiveEnergy(StringUtils.getBigDecimal(obj.get("ECFXYGDN"))); + dataLoad.setSecondaryTotalPowerFactor(StringUtils.getBigDecimal(obj.get("ECZGLYS"))); + dataLoad.setSecondaryTotalApparentPower(StringUtils.getBigDecimal(obj.get("ECZSZFL"))); + dataLoad.setSecondaryTotalReactivePower(StringUtils.getBigDecimal(obj.get("ECZWGGL"))); + dataLoad.setSecondaryPositiveReactiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXWGDN"))); + dataLoad.setSecondaryPositiveActiveEnergy(StringUtils.getBigDecimal(obj.get("ECZXYGDN"))); + dataLoad.setSecondaryTotalActivePower(StringUtils.getBigDecimal(obj.get("ECZYGGL"))); - // 需量 - dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("FXWGDN"))); - dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("FXYGDN"))); - dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); - dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + // 需量 + dataLoad.setReverseReactiveEnergyEqMinus(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + dataLoad.setReverseActiveEnergyEpMinus(StringUtils.getBigDecimal(obj.get("FXYGDN"))); + dataLoad.setPositiveReactiveEnergyEqPlus(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); + dataLoad.setPositiveActiveEnergyEpPlus(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); - // 正反向有功无功电能 - dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); - dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("FXYGDN"))); - dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); - dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("FXWGDN"))); + // 正反向有功无功电能 + dataLoad.setCurrentForwardActiveTotal(StringUtils.getBigDecimal(obj.get("ZXYGDN"))); + dataLoad.setCurrentReverseActiveTotal(StringUtils.getBigDecimal(obj.get("FXYGDN"))); + dataLoad.setCurrentForwardReactiveTotal(StringUtils.getBigDecimal(obj.get("ZXWGDN"))); + dataLoad.setCurrentReverseReactiveTotal(StringUtils.getBigDecimal(obj.get("FXWGDN"))); - } dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); dataLoad.setUpdateBy("system"); @@ -894,8 +828,6 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl redisCache.setCacheObject(RedisKeyConstants.AMMETER + SITE_ID + "_" +deviceId, dataLoad); - saveDevicePointMatchData(pointMatchList, deviceId, DeviceMatchTable.AMMETER, "METE"); - // 处理电表每日充放电数据 dealAmmeterDailyDate(obj, dataUpdateTime, lastAmmeterData); } diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java index a61f8de..2b1c72c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java +++ b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java @@ -7,11 +7,13 @@ import com.xzzn.common.annotation.Excel; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.DeviceCategory; +import com.xzzn.common.enums.PointType; import com.xzzn.common.utils.DataUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDevicesSetting; import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.domain.vo.DevicePointMatchInfo; +import com.xzzn.ems.domain.vo.StackStatisListVo; import com.xzzn.ems.enums.DeviceMatchTable; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.mapper.EmsPointMatchMapper; @@ -23,6 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; @@ -82,15 +85,31 @@ public class DevicePointMatchDataProcessor { } public List getDevicePointMatch(String siteId, String deviceId, String deviceCategory) { + return getDevicePointMatch(siteId, deviceId, deviceCategory, false); + } + + public List getDeviceAlarmPointMatch(String siteId, String deviceId, String deviceCategory) { + return getDevicePointMatch(siteId, deviceId, deviceCategory, true); + } + + private List getDevicePointMatch(String siteId, String deviceId, String deviceCategory, boolean isAlarm) { // List pointMatchList = new ArrayList<>(); // EmsDevicesSetting devicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); // if (devicesSetting == null) { // log.info("未找到设备配置信息,siteId: " + siteId + ", deviceId: "+ deviceId); // return pointMatchList; // } - List pointMatchList = redisCache.getCacheList(getPointTacthCacheKey(siteId, deviceId, deviceCategory)); + List pointMatchList = redisCache.getCacheList(getPointMacthCacheKey(siteId, deviceCategory)); if (CollectionUtils.isEmpty(pointMatchList)) { - pointMatchList = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceId, deviceCategory); + pointMatchList = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceCategory); + } + if (CollectionUtils.isNotEmpty(pointMatchList)) { + Map> map = pointMatchList.stream().collect(Collectors.groupingBy(EmsPointMatch::getIsAlarm)); + if (isAlarm) { + pointMatchList = map.get(PointType.YES.getCode()); + } else { + pointMatchList = map.get(PointType.NO.getCode()); + } } return pointMatchList; @@ -111,13 +130,12 @@ public class DevicePointMatchDataProcessor { try { devicePintointMtachInfo.forEach((key, value) -> { // 查询点位是否存在 - EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceId, deviceCategory, value); + EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceCategory, value); if (!Objects.isNull(dbPoint)) { return; } EmsPointMatch pointMatch = new EmsPointMatch(); pointMatch.setSiteId(siteId); - pointMatch.setDeviceId(deviceId); pointMatch.setDeviceCategory(deviceCategory); pointMatch.setMatchTable(DeviceMatchTable.getMatchTableByCode(deviceCategory)); pointMatch.setMatchField(StringUtils.toUnderScoreCase(key)); @@ -169,12 +187,11 @@ public class DevicePointMatchDataProcessor { /** * 设置点位缓存key * @param siteId - * @param deviceId * @param deviceCategory * @return 点位缓存key */ - public static String getPointTacthCacheKey(String siteId, String deviceId, String deviceCategory) + public static String getPointMacthCacheKey(String siteId, String deviceCategory) { - return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId + "_" + deviceId; + return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId; } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml index a9a19ff..534389d 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml @@ -177,4 +177,18 @@ where t.`year` = #{currentYear} and t.`month` = #{currentMonth} + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml index dd0ab8d..8c5de17 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsMqttTopicConfigMapper.xml @@ -100,4 +100,9 @@ from ems_mqtt_topic_config where mqtt_topic = #{strategyTopic} + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 2dd6aad..c3e4db8 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -24,11 +24,11 @@ - + - select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, device_id from ems_point_match + select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, is_alarm from ems_point_match \ No newline at end of file -- 2.49.0 From 8e631b7b3021dc785b9462dd4a30bda1f5546470 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 5 Dec 2025 08:57:06 +0800 Subject: [PATCH 224/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E5=91=8A=E8=AD=A6=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/EmsDeviceSettingServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 390f8eb..3c27c12 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 @@ -143,7 +143,7 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService String parentDeviceId = request.getParentId(); String ipAddress = request.getIpAddress(); Integer ipPort = request.getIpPort(); - Integer isAlarm = request.getIsAlarm() == null ? PointType.YES.getCode() : request.getIsAlarm(); + Integer isAlarm = request.getIsAlarm() == null ? PointType.NO.getCode() : request.getIsAlarm(); // 电动所的电池簇特殊处理-来源pcs+bmsd if (siteId.equals(DDS_SITE_ID) && DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { response = specialDealWithDDSCluster(siteId,deviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort,isAlarm); -- 2.49.0 From a31b607872edb69163516092f20dedd9b4a9c02b Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 5 Dec 2025 08:58:00 +0800 Subject: [PATCH 225/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E5=91=8A=E8=AD=A6=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java index bca5c30..3d80901 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -55,7 +55,7 @@ public class EmsPointMatch extends BaseEntity private String dataUnit; /** 地址 */ - @Excel(name = "地址") + @Excel(name = "寄存器地址") private String ipAddress; /** 端口 */ -- 2.49.0 From 62340387bb3da95c260ae8608a89f2b429b9e4f6 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 5 Dec 2025 17:15:13 +0800 Subject: [PATCH 226/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E4=BC=98=E5=8C=96=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E6=B8=85=E5=8D=95=E5=AF=BC=E5=87=BA=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsPointMatchController.java | 5 +- .../domain/vo/DevicePointMatchExportVo.java | 97 +++++++++++++++++++ .../ems/domain/vo/DevicePointMatchVo.java | 25 +++-- .../xzzn/ems/mapper/EmsPointMatchMapper.java | 4 + .../ems/service/IEmsPointMatchService.java | 3 +- .../impl/EmsPointMatchServiceImpl.java | 8 +- .../mapper/ems/EmsPointMatchMapper.xml | 18 ++++ 7 files changed, 139 insertions(+), 21 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchExportVo.java diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java index 75b1ca9..8441650 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/EmsPointMatchController.java @@ -16,6 +16,7 @@ import com.xzzn.common.core.controller.BaseController; import com.xzzn.common.core.domain.AjaxResult; import com.xzzn.common.enums.BusinessType; import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.DevicePointMatchExportVo; import com.xzzn.ems.domain.vo.DevicePointMatchVo; import com.xzzn.ems.domain.vo.ImportPointDataRequest; import com.xzzn.ems.service.IEmsPointMatchService; @@ -43,8 +44,8 @@ public class EmsPointMatchController extends BaseController @PostMapping("/export") public void export(HttpServletResponse response, EmsPointMatch emsPointMatch) { - List list = emsPointMatchService.selectEmsPointMatchList(emsPointMatch); - ExcelUtil util = new ExcelUtil(EmsPointMatch.class); + List list = emsPointMatchService.selectEmsPointMatchList(emsPointMatch); + ExcelUtil util = new ExcelUtil<>(DevicePointMatchExportVo.class); util.exportExcel(response, list, "点位匹配数据"); } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchExportVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchExportVo.java new file mode 100644 index 0000000..cdaff1a --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchExportVo.java @@ -0,0 +1,97 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +import java.io.Serializable; + +/** + * 点位清单导出参数 + */ +public class DevicePointMatchExportVo implements Serializable { + private static final long serialVersionUID = 1L; + + /** 点位匹配字段 */ + @Excel(name = "点位匹配字段") + private String matchField; + + /** 存储点位名称 */ + @Excel(name = "点位匹配字段名称") + private String pointName; + + /** 数据点位 */ + @Excel(name = "数据点位") + private String dataPoint; + + /** 数据点位名称 */ + @Excel(name = "数据点位名称") + private String dataPointName; + + /** 数据单位 */ + @Excel(name = "数据单位") + private String dataUnit; + + /** 是否告警点位 */ + @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是") + private String isAlarm; + + /** 寄存器地址 */ + @Excel(name = "寄存器地址") + private String ipAddress; + + public String getPointName() { + return pointName; + } + + public void setPointName(String pointName) { + this.pointName = pointName; + } + + public String getMatchField() { + return matchField; + } + + public void setMatchField(String matchField) { + this.matchField = matchField; + } + + public String getDataPoint() { + return dataPoint; + } + + public void setDataPoint(String dataPoint) { + this.dataPoint = dataPoint; + } + + public String getDataPointName() { + return dataPointName; + } + + public void setDataPointName(String dataPointName) { + this.dataPointName = dataPointName; + } + + public String getDataUnit() { + return dataUnit; + } + + public void setDataUnit(String dataUnit) { + this.dataUnit = dataUnit; + } + + public String getIsAlarm() { + return isAlarm; + } + + public void setIsAlarm(String isAlarm) { + this.isAlarm = isAlarm; + } + + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + +} diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java index b69fdb7..a333f89 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java @@ -14,6 +14,10 @@ public class DevicePointMatchVo implements Serializable { @Excel(name = "点位匹配字段") private String matchField; + /** 存储点位名称 */ + @Excel(name = "点位匹配字段名称") + private String pointName; + /** 数据点位 */ @Excel(name = "数据点位") private String dataPoint; @@ -29,10 +33,6 @@ public class DevicePointMatchVo implements Serializable { /** 是否告警点位 */ @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是") private String isAlarm; -// -// /** 数据点位来源设备 */ -// @Excel(name = "数据点位来源设备") -// private String dataDevice; /** 寄存器地址 */ @Excel(name = "寄存器地址") @@ -42,6 +42,14 @@ public class DevicePointMatchVo implements Serializable { @Excel(name = "错误信息") private String errorMsg; + public String getPointName() { + return pointName; + } + + public void setPointName(String pointName) { + this.pointName = pointName; + } + public String getMatchField() { return matchField; } @@ -74,15 +82,6 @@ public class DevicePointMatchVo implements Serializable { this.dataUnit = dataUnit; } -// public String getDataDevice() { -// return dataDevice; -// } -// -// public void setDataDevice(String dataDevice) { -// this.dataDevice = dataDevice; -// } - - public String getIsAlarm() { return isAlarm; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 077bc8f..b799df3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Map; import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.DevicePointMatchExportVo; +import com.xzzn.ems.domain.vo.DevicePointMatchVo; import com.xzzn.ems.domain.vo.GeneralQueryDataVo; import com.xzzn.ems.domain.vo.PointQueryResponse; import org.apache.ibatis.annotations.Param; @@ -146,4 +148,6 @@ public interface EmsPointMatchMapper EmsPointMatch getOnePointMatch(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory, @Param("dataPoint") String dataPoint); List getDevicePointMatchList(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); + + List selectEmsPointMatchExportList(EmsPointMatch emsPointMatch); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java index 675da0d..121ec50 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsPointMatchService.java @@ -3,6 +3,7 @@ package com.xzzn.ems.service; import java.util.List; import com.xzzn.ems.domain.EmsPointMatch; +import com.xzzn.ems.domain.vo.DevicePointMatchExportVo; import com.xzzn.ems.domain.vo.DevicePointMatchVo; import com.xzzn.ems.domain.vo.ImportPointDataRequest; @@ -20,7 +21,7 @@ public interface IEmsPointMatchService * @param emsPointMatch 点位匹配 * @return 点位匹配集合 */ - public List selectEmsPointMatchList(EmsPointMatch emsPointMatch); + public List selectEmsPointMatchList(EmsPointMatch emsPointMatch); /** diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index ff625e5..0e9d660 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -28,6 +28,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import com.xzzn.common.utils.poi.ExcelUtil; +import com.xzzn.ems.domain.vo.DevicePointMatchExportVo; import com.xzzn.ems.domain.vo.DevicePointMatchVo; import com.xzzn.ems.domain.vo.ImportPointDataRequest; import com.xzzn.ems.enums.DeviceMatchTable; @@ -62,9 +63,9 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService * @return 点位匹配 */ @Override - public List selectEmsPointMatchList(EmsPointMatch emsPointMatch) + public List selectEmsPointMatchList(EmsPointMatch emsPointMatch) { - return emsPointMatchMapper.selectEmsPointMatchList(emsPointMatch); + return emsPointMatchMapper.selectEmsPointMatchExportList(emsPointMatch); } /** @@ -196,9 +197,6 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService if (StringUtils.isBlank(pointMatch.getDataPointName())) { errorMsg.append("数据点位名称不能为空;"); } -// if (StringUtils.isBlank(pointMatch.getDataDevice())) { -// errorMsg.append("数据点位来源设备不能为空;"); -// } if (errorMsg.length() > 0) { pointMatch.setErrorMsg(errorMsg.toString()); errorList.add(pointMatch); diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index c3e4db8..29f9581 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -450,4 +450,22 @@ where site_id = #{siteId} and device_category = #{deviceCategory} + + + \ No newline at end of file -- 2.49.0 From 3605702209a1ebc55195b54afc1cd2f1399cbab0 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 5 Dec 2025 18:07:12 +0800 Subject: [PATCH 227/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-BMS=E7=94=B5=E6=B1=A0=E7=B0=87?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/EmsBatteryCluster.java | 15 +++++++++++++++ .../xzzn/ems/domain/vo/BMSBatteryClusterVo.java | 15 +++++++++++++++ .../impl/DeviceDataProcessServiceImpl.java | 10 ++++++---- .../mapper/ems/EmsBatteryClusterMapper.xml | 5 +++++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java index e1a00c3..2bc12c1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java @@ -1,7 +1,9 @@ package com.xzzn.ems.domain; import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import com.xzzn.common.core.domain.BaseEntity; import com.xzzn.common.utils.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -21,6 +23,11 @@ public class EmsBatteryCluster extends BaseEntity /** */ private Long id; + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date dataUpdateTime; + /** 工作状态:0-正常 1-异常 2-停止 */ @Excel(name = "工作状态:0-正常 1-异常 2-停止") private String workStatus; @@ -223,6 +230,14 @@ public class EmsBatteryCluster extends BaseEntity return id; } + public Date getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(Date dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + public void setWorkStatus(String workStatus) { this.workStatus = workStatus; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java index dfae301..020ade0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/BMSBatteryClusterVo.java @@ -1,6 +1,9 @@ package com.xzzn.ems.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; + import java.math.BigDecimal; +import java.util.Date; import java.util.List; /** @@ -12,6 +15,10 @@ public class BMSBatteryClusterVo { /** 设备名称 */ private String deviceName; + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date dataUpdateTime; + /** 工作状态 */ private String workStatus; @@ -70,6 +77,14 @@ public class BMSBatteryClusterVo { this.deviceName = deviceName; } + public Date getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(Date dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + public String getWorkStatus() { return workStatus; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 7ca6ba2..c4ee196 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -182,12 +182,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i batteryGroupDataProcess(siteId, deviceId, jsonData); batteryDataProcessFromBmsd(siteId, deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains(SiteDevice.BMSC.name())) { - batteryClusterDataProcess(siteId, deviceId, jsonData); + batteryClusterDataProcess(siteId, deviceId, jsonData, dataUpdateTime); batteryDataProcessFromBmsc(siteId, deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains(SiteDevice.PCS.name())) { pcsDataProcess(siteId, deviceId, jsonData, dataUpdateTime); pcsBranchDataProcess(siteId, deviceId, jsonData); - batteryClusterDataProcess(siteId, jsonData); + batteryClusterDataProcess(siteId, jsonData, dataUpdateTime); } else if (deviceId.contains(SiteDevice.LOAD.name())) { loadDataProcess(siteId, deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains(SiteDevice.METEGF.name()) @@ -560,7 +560,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } } - private void batteryClusterDataProcess(String siteId, String deviceId, String dataJson) { + private void batteryClusterDataProcess(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); @@ -576,6 +576,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i saveDeviceData(pointMatchList, obj, data); + data.setDataUpdateTime(dataUpdateTime); data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); @@ -812,7 +813,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } - private void batteryClusterDataProcess(String siteId, String dataJson) { + private void batteryClusterDataProcess(String siteId, String dataJson, Date dataUpdateTime) { if (!SiteEnum.DDS.getCode().equals(siteId)) { return; } @@ -831,6 +832,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i //BMSC 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); // 其他非 BigDecimal 字段 + data.setDataUpdateTime(dataUpdateTime); data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 6268281..e64219f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -6,6 +6,7 @@ + @@ -68,6 +69,7 @@ + and data_update_time = #{dataUpdateTime} and work_status = #{workStatus} and pcs_communication_status = #{pcsCommunicationStatus} and ems_communication_status = #{emsCommunicationStatus} @@ -142,6 +144,7 @@ insert into ems_battery_stack + data_update_time, work_status, pcs_communication_status, ems_communication_status, @@ -204,6 +207,7 @@ circuit_breaker_status, + #{dataUpdateTime}, #{workStatus}, #{pcsCommunicationStatus}, #{emsCommunicationStatus}, @@ -270,6 +274,7 @@ update ems_battery_stack + data_update_time = #{dataUpdateTime}, work_status = #{workStatus}, pcs_communication_status = #{pcsCommunicationStatus}, ems_communication_status = #{emsCommunicationStatus}, -- 2.49.0 From 70c990051b24ccf4eede09be915f4ae5a895051d Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 5 Dec 2025 18:25:39 +0800 Subject: [PATCH 229/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E6=B6=B2=E5=86=B7=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/domain/EmsCoolingData.java | 15 +++++++++++++++ .../com/xzzn/ems/domain/vo/CoolingDataViewVo.java | 14 ++++++++++++++ .../impl/DeviceDataProcessServiceImpl.java | 5 +++-- .../resources/mapper/ems/EmsCoolingDataMapper.xml | 5 +++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java index 2e85dc8..d539cd2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsCoolingData.java @@ -1,7 +1,9 @@ package com.xzzn.ems.domain; import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; import com.xzzn.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -20,6 +22,11 @@ public class EmsCoolingData extends BaseEntity /** */ private Long id; + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date dataUpdateTime; + /** 系统名称,如1#液冷 */ @Excel(name = "系统名称,如1#液冷") private String systemName; @@ -102,6 +109,14 @@ public class EmsCoolingData extends BaseEntity return id; } + public Date getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(Date dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + public void setSystemName(String systemName) { this.systemName = systemName; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java index 9f19015..3ae5e4b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/CoolingDataViewVo.java @@ -1,8 +1,10 @@ package com.xzzn.ems.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import com.xzzn.common.annotation.Excel; import java.math.BigDecimal; +import java.util.Date; /** * 单站监控-液冷 @@ -13,6 +15,10 @@ public class CoolingDataViewVo { /** 设备名称 */ private String deviceName; + /** 数据更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date dataUpdateTime; + /** 供水温度 */ @Excel(name = "供水温度") private BigDecimal gsTemp; @@ -52,6 +58,14 @@ public class CoolingDataViewVo { this.deviceName = deviceName; } + public Date getDataUpdateTime() { + return dataUpdateTime; + } + + public void setDataUpdateTime(Date dataUpdateTime) { + this.dataUpdateTime = dataUpdateTime; + } + public BigDecimal getGsTemp() { return gsTemp; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 0c8b166..f689a87 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -199,12 +199,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } else if (deviceId.contains(SiteDevice.DH.name()) || deviceId.contains(SiteDevice.donghuan.name())) { dhDataProcess(siteId, deviceId, jsonData); } else if (deviceId.contains(SiteDevice.ZSLQ.name())) { - coolingDataProcess(siteId, deviceId, jsonData); + coolingDataProcess(siteId, deviceId, jsonData, dataUpdateTime); } } } - private void coolingDataProcess(String siteId, String deviceId, String jsonData) { + private void coolingDataProcess(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { //中水冷却 Map obj = JSON.parseObject(jsonData, new TypeReference>() { }); @@ -219,6 +219,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i saveDeviceData(pointMatchList, obj, coolingData); + coolingData.setDataUpdateTime(dataUpdateTime); coolingData.setCreateBy("system"); coolingData.setCreateTime(DateUtils.getNowDate()); coolingData.setUpdateBy("system"); diff --git a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml index ed058c2..0ed3595 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsCoolingDataMapper.xml @@ -6,6 +6,7 @@ + @@ -38,6 +39,7 @@ + and data_update_time = #{dataUpdateTime} and humidity = #{humidity} and temperature = #{temperature} and site_id = #{siteId} @@ -39,6 +41,7 @@ insert into ems_dh_data + data_update_time, humidity, temperature, create_by, @@ -50,6 +53,7 @@ device_id, + #{dataUpdateTime}, #{humidity}, #{temperature}, #{createBy}, @@ -65,6 +69,7 @@ update ems_dh_data + data_update_time = #{dataUpdateTime}, humidity = #{humidity}, temperature = #{temperature}, create_by = #{createBy}, -- 2.49.0 From fc5f56b3b07652402b27e13256e885c34e1a93d7 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 5 Dec 2025 19:15:04 +0800 Subject: [PATCH 231/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E4=BF=AE=E6=94=B9=E7=94=B5=E8=A1=A8?= =?UTF-8?q?=E6=AF=8F=E6=97=A5=E5=85=85=E6=94=BE=E7=94=B5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?hardcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDataProcessServiceImpl.java | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 4e2a344..0bc8a93 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -953,9 +953,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 处理电表每日充放电数据 if (!deviceId.contains(SiteDevice.METEGF.name()) && !deviceId.contains(SiteDevice.METE0.name())) { if (SiteEnum.FX.getCode().equals(siteId)) { - dealAmmeterDailyDate(siteId, obj, dataUpdateTime, lastAmmeterData); + dealAmmeterDailyDate(siteId, dataMete, dataUpdateTime, lastAmmeterData); } else if (SiteEnum.DDS.getCode().equals(siteId)) { - dealDDSDailyChargeDate(siteId, obj, deviceId); + dealDDSDailyChargeDate(siteId, dataMete, deviceId); } } } @@ -976,13 +976,15 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i return lastData; } - private void dealDDSDailyChargeDate(String siteId, Map obj, String deviceId) { + private void dealDDSDailyChargeDate(String siteId, EmsAmmeterData currentData, String deviceId) { // 初始化今日充放电 BigDecimal dailyDisChargeDate = new BigDecimal(0); BigDecimal dailyChargeDate = new BigDecimal(0); - BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN")); - BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN")); +// BigDecimal nowTotalDisChargeDate = StringUtils.getBigDecimal(obj.get("DQFXZYGDN")); +// BigDecimal nowTotalChargeDate = StringUtils.getBigDecimal(obj.get("DQZXZYGDN")); + BigDecimal nowTotalDisChargeDate = currentData.getCurrentReverseActiveTotal(); + BigDecimal nowTotalChargeDate = currentData.getCurrentForwardActiveTotal(); // 初始化当日数据-总的 EmsDailyChargeData emsDailyChargeData = initDailyChargeData(siteId, deviceId, nowTotalChargeDate, nowTotalDisChargeDate); // 获取redis存放昨日最晚数据 @@ -1012,7 +1014,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 初始化数据-尖峰平谷 EmsDailyEnergyData energyData = initEnergyData(siteId); // 计算尖峰平谷差值,更新表 - calcEnergyDiffAndRevenue(siteId, energyData, obj, yestData); + calcEnergyDiffAndRevenue(siteId, energyData, currentData, yestData); energyData.setCalcTime(DateUtils.getNowDate()); // 插入或更新电表每日差值数据表 emsDailyEnergyDataMapper.insertOrUpdateData(energyData); @@ -1033,7 +1035,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i return emsDailyChargeData; } - private void calcEnergyDiffAndRevenue(String siteId, EmsDailyEnergyData energyData, Map obj, EmsAmmeterData yestData) { + private void calcEnergyDiffAndRevenue(String siteId, EmsDailyEnergyData energyData, EmsAmmeterData currentData, EmsAmmeterData yestData) { // 获取当月电价 String key = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); @@ -1041,31 +1043,47 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 计算尖峰平谷差值 // 正反向-尖 - BigDecimal peakChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGJDN")) +// BigDecimal peakChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGJDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActivePeak()); + BigDecimal peakChargeDiff = currentData.getCurrentForwardActivePeak() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActivePeak()); energyData.setPeakChargeDiff(peakChargeDiff); - BigDecimal peakDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGJDN")) +// BigDecimal peakDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGJDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActivePeak()); + BigDecimal peakDischargeDiff = currentData.getCurrentReverseActivePeak() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActivePeak()); energyData.setPeakDischargeDiff(peakDischargeDiff); // 正反向-峰 - BigDecimal highChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGFDN")) +// BigDecimal highChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGFDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveHigh()); + BigDecimal highChargeDiff = currentData.getCurrentForwardActiveHigh() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveHigh()); energyData.setHighChargeDiff(highChargeDiff); - BigDecimal highDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGFDN")) +// BigDecimal highDischargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGFDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveHigh()); + BigDecimal highDischargeDiff = currentData.getCurrentReverseActiveHigh() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveHigh()); energyData.setHighDischargeDiff(highDischargeDiff); // 正反向-平 - BigDecimal flatChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGPDN")) +// BigDecimal flatChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGPDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveFlat()); + BigDecimal flatChargeDiff = currentData.getCurrentForwardActiveFlat() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveFlat()); energyData.setFlatChargeDiff(flatChargeDiff); - BigDecimal flatDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGPDN")) +// BigDecimal flatDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGPDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveFlat()); + BigDecimal flatDisChargeDiff = currentData.getCurrentReverseActiveFlat() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveFlat()); energyData.setFlatDischargeDiff(flatDisChargeDiff); // 正反向-谷 - BigDecimal valleyChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGGDN")) +// BigDecimal valleyChargeDiff = StringUtils.getBigDecimal(obj.get("DQZXYGGDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveValley()); + BigDecimal valleyChargeDiff = currentData.getCurrentForwardActiveValley() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentForwardActiveValley()); energyData.setValleyChargeDiff(valleyChargeDiff); - BigDecimal valleyDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGGDN")) +// BigDecimal valleyDisChargeDiff = StringUtils.getBigDecimal(obj.get("DQFXYGGDN")) +// .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveValley()); + BigDecimal valleyDisChargeDiff = currentData.getCurrentReverseActiveValley() .subtract(yestData == null ? new BigDecimal(0) : yestData.getCurrentReverseActiveValley()); energyData.setValleyDischargeDiff(valleyDisChargeDiff); @@ -1109,7 +1127,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i return yestLastTotalRevenue; } - private void dealAmmeterDailyDate(String siteId, Map obj, Date dataUpdateTime, EmsAmmeterData lastData) { + private void dealAmmeterDailyDate(String siteId, EmsAmmeterData currentData, Date dataUpdateTime, EmsAmmeterData lastData) { // 先获取当月电价配置,redis没有这查数据库,都没有则返回 String priceKey = RedisKeyConstants.ENERGY_PRICE_TIME + siteId + "_" + LocalDate.now().getYear() + LocalDate.now().getMonthValue(); EnergyPriceVo priceVo = redisCache.getCacheObject(priceKey); @@ -1143,16 +1161,18 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i EmsDailyEnergyData energyData = initEnergyData(siteId); // 根据 costType,计算本次与上次数据差值,累加到对应的数据类型里面 - setDiffByCostType(siteId, costType, energyData, lastData, obj, priceVo); + setDiffByCostType(siteId, costType, energyData, lastData, currentData, priceVo); // 插入或更新电表每日差值数据表 emsDailyEnergyDataMapper.insertOrUpdateData(energyData); } private void setDiffByCostType(String siteId, String costType, EmsDailyEnergyData energyData, EmsAmmeterData lastData, - Map obj, EnergyPriceVo priceVo) { - BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN")); - BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN")); + EmsAmmeterData currentData, EnergyPriceVo priceVo) { +// BigDecimal currentChargeData = StringUtils.getBigDecimal(obj.get("ZXYGDN")); +// BigDecimal currentDischargeData = StringUtils.getBigDecimal(obj.get("FXYGDN")); + BigDecimal currentChargeData = currentData.getCurrentForwardActiveTotal(); + BigDecimal currentDischargeData = currentData.getCurrentReverseActiveTotal(); currentChargeData = currentChargeData != null ? currentChargeData : BigDecimal.ZERO; currentDischargeData = currentDischargeData != null ? currentDischargeData : BigDecimal.ZERO; -- 2.49.0 From 28dfb0c15228b1e446cd26602a6dc9d0fe917335 Mon Sep 17 00:00:00 2001 From: zq Date: Sun, 7 Dec 2025 18:35:32 +0800 Subject: [PATCH 232/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?-=E6=94=B6=E7=9B=8A=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/enums/CostType.java | 42 ++++++ .../java/com/xzzn/common/utils/DateUtils.java | 51 +++++++ .../ems/domain/vo/AmmeterStatisListVo.java | 10 ++ .../ems/domain/vo/EnergyPriceConfigVo.java | 101 ++++++++++++++ .../xzzn/ems/mapper/EmsAmmeterDataMapper.java | 6 + .../mapper/EmsEnergyPriceConfigMapper.java | 7 +- .../impl/EmsStatsReportServiceImpl.java | 130 +++++++++++++++--- .../mapper/ems/EmsAmmeterDataMapper.xml | 79 +++++++++++ .../mapper/ems/EmsEnergyPriceConfigMapper.xml | 43 ++++-- 9 files changed, 435 insertions(+), 34 deletions(-) create mode 100644 ems-common/src/main/java/com/xzzn/common/enums/CostType.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceConfigVo.java diff --git a/ems-common/src/main/java/com/xzzn/common/enums/CostType.java b/ems-common/src/main/java/com/xzzn/common/enums/CostType.java new file mode 100644 index 0000000..19632bb --- /dev/null +++ b/ems-common/src/main/java/com/xzzn/common/enums/CostType.java @@ -0,0 +1,42 @@ +package com.xzzn.common.enums; + +/** + * 电量类型 + */ +public enum CostType +{ + PEAK("peak", "尖"), + HIGH("high", "峰"), + FLAT("flat", "平"), + VALLEY("valley", "谷"), + ; + + private final String code; + private final String info; + + CostType(String code, String info) + { + this.code = code; + this.info = info; + } + + public String getCode() + { + return code; + } + + public String getInfo() + { + return info; + } + + public static CostType getEnumByCode(String code) + { + for (CostType costType : CostType.values()) { + if (costType.code.equals(code)) { + return costType; + } + } + return null; + } +} diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index fb0ddc2..29ff17c 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -1,5 +1,7 @@ package com.xzzn.common.utils; +import com.xzzn.common.annotation.Log; + import java.lang.management.ManagementFactory; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -9,11 +11,13 @@ import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.logging.LogFactory; /** * 时间工具类 @@ -22,6 +26,8 @@ import org.apache.commons.lang3.time.DateFormatUtils; */ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { + private static final org.apache.commons.logging.Log log = LogFactory.getLog(DateUtils.class); + public static String YYYY = "yyyy"; public static String YYYY_MM = "yyyy-MM"; @@ -408,4 +414,49 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils // 格式化并返回 return yesterday.format(formatter); } + + /** + * 获取日期的开始时间 + * @param dateString 格式为yyyy-MM-dd的日期字符串 + * @return 日期的开始时间字符串 + */ + public static String getDayBeginString(String dateString) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + try { + // 解析日期字符串 + LocalDate date = LocalDate.parse(dateString, formatter); + + // 创建时间段的开始时间 00:00:00 + LocalDateTime startTime = date.atTime(LocalTime.MIN); + + return convertToString(startTime); + } catch (DateTimeParseException e) { + log.info("Error parsing date: " + e.getMessage()); + } + + return dateString + " 00:00:00"; + } + + /** + * 获取日期的结束时间 + * @param dateString 格式为yyyy-MM-dd的日期字符串 + * @return 日期的结束时间字符串 + */ + public static String getDayEndString(String dateString) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + try { + // 解析日期字符串 + LocalDate date = LocalDate.parse(dateString, formatter); + + // 创建时间段的结束时间 23:59:59 + LocalDateTime endTime = date.atTime(LocalTime.MAX); + + return convertToString(endTime); + } catch (DateTimeParseException e) { + log.info("Error parsing date: " + e.getMessage()); + } + + return dateString + " 23:59:59"; + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java index 91b69bf..405e144 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java @@ -11,6 +11,8 @@ public class AmmeterStatisListVo { /** 类别 */ private String dataTime; + private String timePart; + /** 组合有功-总 (kWh) */ private BigDecimal activeTotalKwh = BigDecimal.ZERO; @@ -52,6 +54,14 @@ public class AmmeterStatisListVo { this.dataTime = dataTime; } + public String getTimePart() { + return timePart; + } + + public void setTimePart(String timePart) { + this.timePart = timePart; + } + public BigDecimal getActiveTotalKwh() { return activeTotalKwh; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceConfigVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceConfigVo.java new file mode 100644 index 0000000..ef7635d --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyPriceConfigVo.java @@ -0,0 +1,101 @@ +package com.xzzn.ems.domain.vo; + +import com.xzzn.common.annotation.Excel; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 电价配置-电价列表-对象 + * + */ +public class EnergyPriceConfigVo { + + /** 时间格式 yyyy-MM */ + private String yearMonth; + /** 尖电价(元/kWh) */ + @Excel(name = "尖电价(元/kWh)") + private BigDecimal peak; + /** 峰电价(元/kWh) */ + @Excel(name = "峰电价(元/kWh)") + private BigDecimal high; + /** 平电价(元/kWh) */ + @Excel(name = "平电价(元/kWh)") + private BigDecimal flat; + /** 谷电价(元/kWh) */ + @Excel(name = "谷电价(元/kWh)") + private BigDecimal valley; + /** 时段开始时间 */ + @Excel(name = "时段开始时间") + private String startTime; + /** 时段结束时间 */ + @Excel(name = "时段结束时间") + private String endTime; + /** 电价类型: 尖-peak,峰-high,平-flat,谷=valley */ + @Excel(name = "电价类型: 尖-peak,峰-high,平-flat,谷=valley") + private String costType; + + public String getYearMonth() { + return yearMonth; + } + + public void setYearMonth(String yearMonth) { + this.yearMonth = yearMonth; + } + + public BigDecimal getPeak() { + return peak; + } + + public void setPeak(BigDecimal peak) { + this.peak = peak; + } + + public BigDecimal getHigh() { + return high; + } + + public void setHigh(BigDecimal high) { + this.high = high; + } + + public BigDecimal getFlat() { + return flat; + } + + public void setFlat(BigDecimal flat) { + this.flat = flat; + } + + public BigDecimal getValley() { + return valley; + } + + public void setValley(BigDecimal valley) { + this.valley = valley; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getCostType() { + return costType; + } + + public void setCostType(String costType) { + this.costType = costType; + } +} diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java index 62a1bdf..3593730 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsAmmeterDataMapper.java @@ -93,4 +93,10 @@ public interface EmsAmmeterDataMapper // 获取最新数据 public EmsAmmeterData getLastData(@Param("siteId")String siteId, @Param("deviceId")String deviceId); + List selectHourlyAmmeterData(@Param("siteId") String siteId, + @Param("startTime") String startTime, + @Param("endTime") String endTime); + List selectDailyAmmeterData(@Param("siteId") String siteId, + @Param("startTime") String startTime, + @Param("endTime") String endTime); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java index 2dfbe86..95041c4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsEnergyPriceConfigMapper.java @@ -3,6 +3,7 @@ package com.xzzn.ems.mapper; import java.util.List; import com.xzzn.ems.domain.EmsEnergyPriceConfig; +import com.xzzn.ems.domain.vo.EnergyPriceConfigVo; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import org.apache.ibatis.annotations.Param; @@ -77,7 +78,7 @@ public interface EmsEnergyPriceConfigMapper public List getAllSitePriceConfig( @Param("currentYear")int currentYear, @Param("currentMonth")int currentMonth); // 查询指定时间范围的电价配置列表 - public List getConfigListByTimeFrame(@Param("siteId")String siteId, - @Param("startTime")String startTime, - @Param("endTime")String endTime); + public List getConfigListByTimeFrame(@Param("siteId")String siteId, + @Param("startDate")String startDate, + @Param("endDate")String endDate); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 9c4641b..cf6b466 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -1,5 +1,6 @@ package com.xzzn.ems.service.impl; +import com.xzzn.common.enums.CostType; import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsAmmeterData; @@ -16,6 +17,9 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; import java.util.function.Function; @@ -312,38 +316,122 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Override public List getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) { - //查询电表数据 - List dataList = emsDailyEnergyDataMapper.getDataBySiteId(requestVo.getSiteId(), requestVo.getStartTime(), requestVo.getEndTime()); - if (CollectionUtils.isEmpty(dataList)){ - return null; - } - //查询电价配置 - List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(requestVo.getSiteId(), requestVo.getStartTime(), requestVo.getEndTime()); - if (CollectionUtils.isEmpty(priceConfigList)){ - return null; - } - Map priceConfigMap = priceConfigList.stream().collect(Collectors.toMap(data -> data.getYear() + "-" + String.format("%02d", Integer.parseInt(data.getMonth())), Function.identity())); + String siteId = requestVo.getSiteId(); + String startTime = DateUtils.getDayBeginString(requestVo.getStartTime()); + String endTime = DateUtils.getDayEndString(requestVo.getEndTime()); List resultList = new ArrayList<>(); - dataList.forEach(ammeter -> { - EmsEnergyPriceConfig price = priceConfigMap.get(ammeter.getDataTime().substring(0, 7)); - resultList.add(calculateDailyBill(ammeter, price)); + List dataList = new ArrayList<>(); + //查询电价配置 + List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(siteId, requestVo.getStartTime(), requestVo.getEndTime()); + if (CollectionUtils.isEmpty(priceConfigList)){ + return Collections.emptyList(); + } + //查询电表数据 + if (SiteEnum.FX.getCode().equals(siteId)) { + dataList = emsAmmeterDataMapper.selectHourlyAmmeterData(siteId, startTime, endTime); + } else { + // 其他站点暂时默认与电动所内部一致处理,按天查询数据 + dataList = emsAmmeterDataMapper.selectDailyAmmeterData(siteId, startTime, endTime); + } + if (CollectionUtils.isEmpty(dataList)) { + return Collections.emptyList(); + } + Map> priceConfigMap = priceConfigList.stream().collect(Collectors.groupingBy(EnergyPriceConfigVo::getYearMonth)); + Map> ammeterMap = dataList.stream().collect(Collectors.groupingBy(AmmeterStatisListVo::getDataTime)); + List dateList = generateTargetDates(requestVo.getStartTime(), requestVo.getEndTime()); + dateList.forEach(date -> { + String dateTime = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + List priceConfigs = priceConfigMap.get(dateTime.substring(0, 7)); + List ammeterStatisListVos = ammeterMap.get(dateTime); + resultList.add(calculateDailyBill(siteId, dateTime, ammeterStatisListVos, priceConfigs)); }); return resultList; } - public static AmmeterRevenueStatisListVo calculateDailyBill(AmmeterStatisListVo ammeter, EmsEnergyPriceConfig price) { + public static AmmeterRevenueStatisListVo calculateDailyBill(String siteId, String dateTime, List ammeterList, List priceList) { AmmeterRevenueStatisListVo ammeterRevenue = new AmmeterRevenueStatisListVo(); - ammeterRevenue.setDataTime(ammeter.getDataTime()); - if (price != null) { -// BigDecimal activeTotalPrice = ammeter.getActiveTotalKwh().multiply(new BigDecimal(price.getPeak())); -// BigDecimal activePeakPrice = ammeter.getActivePeakKwh().multiply(new BigDecimal(price.getPeak())); -// BigDecimal activeHighPrice = ammeter.getActiveHighKwh().multiply(new BigDecimal(price.getHigh())); -// BigDecimal activeFlatPrice = ammeter.getActiveFlatKwh().multiply(new BigDecimal(price.getFlat())); + ammeterRevenue.setDataTime(dateTime); + if (CollectionUtils.isEmpty(ammeterList) || CollectionUtils.isEmpty(priceList)) { + return ammeterRevenue; } + if (SiteEnum.FX.getCode().equals(siteId)) { + for (AmmeterStatisListVo ammeter : ammeterList) { + for (EnergyPriceConfigVo priceConfig : priceList) { + if (isInTimeRange(priceConfig.getStartTime(), priceConfig.getEndTime(), ammeter.getTimePart())) { + calculateByCostType(ammeter, priceConfig, ammeterRevenue); + } + } + } + } else { + // 其他站点暂时默认与电动所内部一致处理,按天计算逻辑 + AmmeterStatisListVo ammeter = ammeterList.get(0); + EnergyPriceConfigVo price = priceList.get(0); + ammeterRevenue.setActivePeakPrice(ammeter.getActivePeakKwh().multiply(price.getPeak())); + ammeterRevenue.setActiveHighPrice(ammeter.getActiveHighKwh().multiply(price.getHigh())); + ammeterRevenue.setActiveFlatPrice(ammeter.getActiveFlatKwh().multiply(price.getFlat())); + ammeterRevenue.setActiveValleyPrice(ammeter.getActiveValleyKwh().multiply(price.getValley())); + ammeterRevenue.setReActivePeakPrice(ammeter.getReActivePeakKwh().multiply(price.getPeak())); + ammeterRevenue.setReActiveHighPrice(ammeter.getReActiveHighKwh().multiply(price.getHigh())); + ammeterRevenue.setReActiveFlatPrice(ammeter.getReActiveFlatKwh().multiply(price.getFlat())); + ammeterRevenue.setReActiveValleyPrice(ammeter.getReActiveValleyKwh().multiply(price.getValley())); + } + ammeterRevenue.setActiveTotalPrice(ammeterRevenue.getActivePeakPrice().add(ammeterRevenue.getActiveHighPrice()).add(ammeterRevenue.getActiveFlatPrice()).add(ammeterRevenue.getActiveValleyPrice())); + ammeterRevenue.setReActiveTotalPrice(ammeterRevenue.getReActivePeakPrice().add(ammeterRevenue.getReActiveHighPrice()).add(ammeterRevenue.getReActiveFlatPrice()).add(ammeterRevenue.getReActiveValleyPrice())); return ammeterRevenue; } + private static boolean isInTimeRange(String startTimeStr, String endTimeStr, String timePartStr) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + // 解析时间字符串为LocalTime对象 + LocalTime checkTime = LocalTime.parse(timePartStr, formatter); + // 定义时间范围 + LocalTime startTime = LocalTime.parse(startTimeStr, formatter); + LocalTime endTime = LocalTime.parse(endTimeStr, formatter); + // 判断时间是否在指定范围内 + return checkTime.compareTo(startTime) >= 0 + && checkTime.compareTo(endTime) < 0; + } + + private static void calculateByCostType(AmmeterStatisListVo ammeter, EnergyPriceConfigVo priceConfig, AmmeterRevenueStatisListVo ammeterRevenue) { + switch (CostType.getEnumByCode(priceConfig.getCostType())) { + case PEAK: + ammeterRevenue.setActivePeakPrice(ammeterRevenue.getActivePeakPrice().add(ammeter.getActiveTotalKwh().multiply(priceConfig.getPeak()))); + ammeterRevenue.setReActivePeakPrice(ammeterRevenue.getReActivePeakPrice().add(ammeter.getReActiveTotalKwh().multiply(priceConfig.getPeak()))); + break; + case HIGH: + ammeterRevenue.setActiveHighPrice(ammeterRevenue.getActiveHighPrice().add(ammeter.getActiveTotalKwh().multiply(priceConfig.getHigh()))); + ammeterRevenue.setReActiveHighPrice(ammeterRevenue.getReActiveHighPrice().add(ammeter.getReActiveTotalKwh().multiply(priceConfig.getHigh()))); + break; + case FLAT: + ammeterRevenue.setActiveFlatPrice(ammeterRevenue.getActiveFlatPrice().add(ammeter.getActiveTotalKwh().multiply(priceConfig.getFlat()))); + ammeterRevenue.setReActiveFlatPrice(ammeterRevenue.getReActiveFlatPrice().add(ammeter.getReActiveTotalKwh().multiply(priceConfig.getFlat()))); + break; + case VALLEY: + ammeterRevenue.setActiveValleyPrice(ammeterRevenue.getActiveValleyPrice().add(ammeter.getActiveTotalKwh().multiply(priceConfig.getValley()))); + ammeterRevenue.setReActiveValleyPrice(ammeterRevenue.getReActiveValleyPrice().add(ammeter.getReActiveTotalKwh().multiply(priceConfig.getValley()))); + break; + default: + break; + } + } + + private static List generateTargetDates(String startDateStr, String endDateStr) { + // 定义日期格式 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + // 解析日期字符串 + LocalDate startDate = LocalDate.parse(startDateStr, formatter); + LocalDate endDate = LocalDate.parse(endDateStr, formatter); + + List targetDates = new ArrayList<>(); + targetDates.add(startDate); // 添加起始日期 + while (startDate.isBefore(endDate)) { + startDate = startDate.plusDays(1); // 递增1天 + targetDates.add(startDate); // 添加递增后的日期 + } + return targetDates; + } + private void dealWithAmmeterTotalDate(AmmeterStatisListVo ammeterStatisListVo, AmmeterStatisListVo totalVo) { // 有功 totalVo.setActiveTotalKwh(totalVo.getActiveTotalKwh().add(ammeterStatisListVo.getActiveTotalKwh())); diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index f49a05a..f679965 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -1061,4 +1061,83 @@ and device_id = #{deviceId} ORDER BY data_update_time DESC LIMIT 1 + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml index 534389d..68823f9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsEnergyPriceConfigMapper.xml @@ -177,18 +177,41 @@ where t.`year` = #{currentYear} and t.`month` = #{currentMonth} - + select + epc.yearMonth as yearMonth, + epc.peak, + epc.high, + epc.flat, + epc.valley, + eptc.start_time as startTime, + eptc.end_time as endTime, + eptc.cost_type as costType + from + ( + select + id, site_id, peak, high, flat, valley, + CONCAT(year, '-', LPAD(month, 2, '0')) as yearMonth, + STR_TO_DATE(CONCAT(year, '-', month, '-01'), '%Y-%m-%d') as dateTime + from ems_energy_price_config + where 1 = 1 + + and site_id = #{siteId} + + order by year, month + ) epc + left join ems_price_time_config eptc on eptc.price_id = epc.id - - and site_id = #{siteId} - - - and STR_TO_DATE(CONCAT(year, '-', month, '-01'), '%Y-%m-%d') between #{startTime} and #{endTime} + + ( + (#{startDate} between dateTime and LAST_DAY(dateTime)) + or + ( #{endDate} between dateTime and LAST_DAY(dateTime)) + or + (dateTime between #{startDate} and #{endDate}) + ) - order by - `year` asc, - `month` desc; + order by epc.yearMonth, eptc.start_time \ No newline at end of file -- 2.49.0 From b7aaf85a3ffaf146253fdaa2ed4b25a9468a362c Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 8 Dec 2025 18:48:05 +0800 Subject: [PATCH 233/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E7=82=B9=E4=BD=8D=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E6=9E=9A=E4=B8=BE=E6=98=A0?= =?UTF-8?q?=E5=B0=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 5 + .../xzzn/ems/domain/EmsPointEnumMatch.java | 147 ++++++++++++++++++ .../domain/vo/DevicePointMatchExportVo.java | 24 +++ .../ems/domain/vo/DevicePointMatchVo.java | 24 +++ .../ems/mapper/EmsPointEnumMatchMapper.java | 70 +++++++++ .../impl/DeviceDataProcessServiceImpl.java | 68 +++++--- .../impl/EmsPointMatchServiceImpl.java | 93 +++++++++-- .../utils/DevicePointMatchDataProcessor.java | 35 +++++ .../mapper/ems/EmsPointEnumMatchMapper.xml | 122 +++++++++++++++ 9 files changed, 555 insertions(+), 33 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/EmsPointEnumMatch.java create mode 100644 ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java create mode 100644 ems-system/src/main/resources/mapper/ems/EmsPointEnumMatchMapper.xml diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 78b682a..6163a90 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -67,6 +67,11 @@ public class RedisKeyConstants */ public static final String POINT_MATCH = "POINT_MATCH_"; + /** + * 点位枚举匹配数据 redis key + */ + public static final String POINT_ENUM_MATCH = "POINT_ENUM_MATCH_"; + /** * topic对应站点ID redis key */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointEnumMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointEnumMatch.java new file mode 100644 index 0000000..6c55f0b --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointEnumMatch.java @@ -0,0 +1,147 @@ +package com.xzzn.ems.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.xzzn.common.annotation.Excel; +import com.xzzn.common.core.domain.BaseEntity; + +/** + * 点位枚举匹配对象 ems_point_enum_match + * + * @author xzzn + * @date 2025-12-08 + */ +public class EmsPointEnumMatch extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键自增长 */ + private Long id; + + /** 点位匹配字段 */ + @Excel(name = "点位匹配字段") + private String matchField; + + /** 站点id */ + @Excel(name = "站点id") + private String siteId; + + /** 设备类别,例如“STACK/CLUSTER/PCS等” */ + @Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”") + private String deviceCategory; + + /** 系统枚举代码 */ + @Excel(name = "系统枚举代码") + private String enumCode; + + /** 系统枚举名称 */ + @Excel(name = "系统枚举名称") + private String enumName; + + /** 系统枚举描述 */ + @Excel(name = "系统枚举描述") + private String enumDesc; + + /** 数据枚举代码 */ + @Excel(name = "数据枚举代码") + private String dataEnumCode; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setMatchField(String matchField) + { + this.matchField = matchField; + } + + public String getMatchField() + { + return matchField; + } + + public void setSiteId(String siteId) + { + this.siteId = siteId; + } + + public String getSiteId() + { + return siteId; + } + + public void setDeviceCategory(String deviceCategory) + { + this.deviceCategory = deviceCategory; + } + + public String getDeviceCategory() + { + return deviceCategory; + } + + public void setEnumCode(String enumCode) + { + this.enumCode = enumCode; + } + + public String getEnumCode() + { + return enumCode; + } + + public void setEnumName(String enumName) + { + this.enumName = enumName; + } + + public String getEnumName() + { + return enumName; + } + + public void setEnumDesc(String enumDesc) + { + this.enumDesc = enumDesc; + } + + public String getEnumDesc() + { + return enumDesc; + } + + public void setDataEnumCode(String dataEnumCode) + { + this.dataEnumCode = dataEnumCode; + } + + public String getDataEnumCode() + { + return dataEnumCode; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("matchField", getMatchField()) + .append("siteId", getSiteId()) + .append("deviceCategory", getDeviceCategory()) + .append("enumCode", getEnumCode()) + .append("enumName", getEnumName()) + .append("enumDesc", getEnumDesc()) + .append("dataEnumCode", getDataEnumCode()) + .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/DevicePointMatchExportVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchExportVo.java index cdaff1a..6dec12c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchExportVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchExportVo.java @@ -18,6 +18,10 @@ public class DevicePointMatchExportVo implements Serializable { @Excel(name = "点位匹配字段名称") private String pointName; + /** 数据枚举映射-导出枚举名称 */ + @Excel(name = "数据枚举映射") + private String matchFieldEnum; + /** 数据点位 */ @Excel(name = "数据点位") private String dataPoint; @@ -30,6 +34,10 @@ public class DevicePointMatchExportVo implements Serializable { @Excel(name = "数据单位") private String dataUnit; + /** 数据枚举 */ + @Excel(name = "数据枚举") + private String dataEnum; + /** 是否告警点位 */ @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是") private String isAlarm; @@ -54,6 +62,14 @@ public class DevicePointMatchExportVo implements Serializable { this.matchField = matchField; } + public String getMatchFieldEnum() { + return matchFieldEnum; + } + + public void setMatchFieldEnum(String matchFieldEnum) { + this.matchFieldEnum = matchFieldEnum; + } + public String getDataPoint() { return dataPoint; } @@ -78,6 +94,14 @@ public class DevicePointMatchExportVo implements Serializable { this.dataUnit = dataUnit; } + public String getDataEnum() { + return dataEnum; + } + + public void setDataEnum(String dataEnum) { + this.dataEnum = dataEnum; + } + public String getIsAlarm() { return isAlarm; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java index a333f89..1730fc2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointMatchVo.java @@ -18,6 +18,10 @@ public class DevicePointMatchVo implements Serializable { @Excel(name = "点位匹配字段名称") private String pointName; + /** 数据枚举映射 */ + @Excel(name = "数据枚举映射") + private String matchFieldEnum; + /** 数据点位 */ @Excel(name = "数据点位") private String dataPoint; @@ -30,6 +34,10 @@ public class DevicePointMatchVo implements Serializable { @Excel(name = "数据单位") private String dataUnit; + /** 数据枚举 */ + @Excel(name = "数据枚举") + private String dataEnum; + /** 是否告警点位 */ @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是") private String isAlarm; @@ -58,6 +66,22 @@ public class DevicePointMatchVo implements Serializable { this.matchField = matchField; } + public String getMatchFieldEnum() { + return matchFieldEnum; + } + + public void setMatchFieldEnum(String matchFieldEnum) { + this.matchFieldEnum = matchFieldEnum; + } + + public String getDataEnum() { + return dataEnum; + } + + public void setDataEnum(String dataEnum) { + this.dataEnum = dataEnum; + } + public String getDataPoint() { return dataPoint; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java new file mode 100644 index 0000000..7b6a7f3 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java @@ -0,0 +1,70 @@ +package com.xzzn.ems.mapper; + +import com.xzzn.ems.domain.EmsPointEnumMatch; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +/** + * 点位枚举匹配Mapper接口 + * + * @author xzzn + * @date 2025-12-08 + */ +public interface EmsPointEnumMatchMapper +{ + /** + * 查询点位枚举匹配 + * + * @param id 点位枚举匹配主键 + * @return 点位枚举匹配 + */ + public EmsPointEnumMatch selectEmsPointEnumMatchById(Long id); + + /** + * 查询点位枚举匹配列表 + * + * @param emsPointEnumMatch 点位枚举匹配 + * @return 点位枚举匹配集合 + */ + public List selectEmsPointEnumMatchList(EmsPointEnumMatch emsPointEnumMatch); + + /** + * 新增点位枚举匹配 + * + * @param emsPointEnumMatch 点位枚举匹配 + * @return 结果 + */ + public int insertEmsPointEnumMatch(EmsPointEnumMatch emsPointEnumMatch); + + /** + * 修改点位枚举匹配 + * + * @param emsPointEnumMatch 点位枚举匹配 + * @return 结果 + */ + public int updateEmsPointEnumMatch(EmsPointEnumMatch emsPointEnumMatch); + + public void updateDataEnumCodeById(EmsPointEnumMatch pointEnumMatch); + + /** + * 删除点位枚举匹配 + * + * @param id 点位枚举匹配主键 + * @return 结果 + */ + public int deleteEmsPointEnumMatchById(Long id); + + /** + * 批量删除点位枚举匹配 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEmsPointEnumMatchByIds(Long[] ids); + + public List selectList(@Param("siteId") String siteId, + @Param("deviceCategory") String deviceCategory, + @Param("matchField") String matchField); +} diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 0bc8a93..ecfdee2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -72,6 +72,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; @@ -214,10 +215,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理中水冷却数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.COOLING.getCode()); EmsCoolingData coolingData = new EmsCoolingData(); - saveDeviceData(pointMatchList, obj, coolingData); + saveDeviceData(pointMatchList, obj, coolingData, pointEnumMatchMap); coolingData.setDataUpdateTime(dataUpdateTime); coolingData.setCreateBy("system"); @@ -243,13 +245,14 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理动环数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.XF.getCode()); // 暂时只更新设备表的设备状态 ZDYBYDCZT-主电源备用电池状态 // 数据存表 EmsXfData xfData = new EmsXfData(); xfData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, xfData); + saveDeviceData(pointMatchList, obj, xfData, pointEnumMatchMap); xfData.setCreateBy("system"); xfData.setCreateTime(DateUtils.getNowDate()); @@ -277,11 +280,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理动环数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.DH.getCode()); //DH EmsDhData dhData = new EmsDhData(); - saveDeviceData(pointMatchList, obj, dhData); + saveDeviceData(pointMatchList, obj, dhData, pointEnumMatchMap); dhData.setDataUpdateTime(dateUpdateTime); dhData.setCreateBy("system"); @@ -311,6 +315,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池堆数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.STACK.getCode()); //BMS 电池簇 EmsBatteryStack dataStack = new EmsBatteryStack(); @@ -321,7 +326,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - saveDeviceData(pointMatchList, obj, dataStack); + saveDeviceData(pointMatchList, obj, dataStack, pointEnumMatchMap); dataStack.setCreateBy("system"); dataStack.setCreateTime(DateUtils.getNowDate()); @@ -533,7 +538,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } } - private void saveDeviceData(List pointMatchList, Map obj, Object entity) { + private void saveDeviceData(List pointMatchList, Map obj, + Object entity, Map> pointEnumMatchMap) { Map pointMatchMap = pointMatchList.stream() .collect(Collectors.toMap( data -> StringUtils.toCamelCase(data.getMatchField()), @@ -541,10 +547,21 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i (existing, replacement) -> replacement)); Field[] fields = entity.getClass().getDeclaredFields(); for (Field field : fields) { - if (pointMatchMap.containsKey(field.getName())) { + String fieldName = field.getName(); + if (pointMatchMap.containsKey(fieldName)) { field.setAccessible(true); try { - Object matchValue = obj.get(pointMatchMap.get(field.getName())); + Object matchValue = obj.get(pointMatchMap.get(fieldName)); + //匹配枚举值转换 + List pointEnumMatchList = pointEnumMatchMap.get(fieldName); + if (CollectionUtils.isNotEmpty(pointEnumMatchList)) { + Object finalMatchValue = matchValue; + Optional enumMatch = pointEnumMatchList.stream() + .filter(data -> data.getDataEnumCode().equals(finalMatchValue)).findFirst(); + if (enumMatch.isPresent()) { + matchValue = enumMatch.get().getEnumCode(); + } + } Class fieldType = field.getType(); if (String.class.equals(fieldType)) { matchValue = StringUtils.getString(matchValue); @@ -553,7 +570,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } else if (BigDecimal.class.equals(fieldType)) { matchValue = StringUtils.getBigDecimal(matchValue); } else if (Integer.class.equals(fieldType)) { - matchValue = MapUtils.getInteger(obj, pointMatchMap.get(field.getName())); + matchValue = MapUtils.getInteger(obj, pointMatchMap.get(fieldName)); } field.set(entity, matchValue); } catch (IllegalAccessException e) { @@ -573,11 +590,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池簇数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.CLUSTER.getCode()); String stackDeviceId = getStackDeviceId(deviceId); //BMS 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); - saveDeviceData(pointMatchList, obj, data); + saveDeviceData(pointMatchList, obj, data, pointEnumMatchMap); data.setDataUpdateTime(dataUpdateTime); data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 @@ -626,6 +644,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理单体电池数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.BATTERY.getCode()); List list = new ArrayList<>(); List dailyList = new ArrayList<>(); List minutesList = new ArrayList<>(); @@ -642,7 +661,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i batteryData.setDeviceId(recordId); batteryData.setBatteryCellId(recordId); - saveDeviceData(pointMatchList, fields, batteryData); + saveDeviceData(pointMatchList, fields, batteryData, pointEnumMatchMap); batteryData.setBatteryCluster(deviceId); batteryData.setBatteryPack(getStackDeviceId(deviceId)); @@ -706,11 +725,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理PCS数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.PCS.getCode()); //pcs EmsPcsData pcsData = new EmsPcsData(); - saveDeviceData(pointMatchList, obj, pcsData); + saveDeviceData(pointMatchList, obj, pcsData, pointEnumMatchMap); // 状态指示类 pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); @@ -756,6 +776,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理PCS支路数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.BRANCH.getCode()); //PCS支路 for (Map.Entry> record : records.entrySet()) { @@ -767,7 +788,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i data.setSiteId(siteId); data.setGridStatus(GridStatus.GRID.getCode()); - saveDeviceData(pointMatchList, fields, data); + saveDeviceData(pointMatchList, fields, data, pointEnumMatchMap); data.setBranchId(recordId); data.setCreateBy("system"); @@ -796,12 +817,13 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理LOAD总表数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.AMMETER.getCode()); EmsAmmeterData dataLoad = new EmsAmmeterData(); // 更新时间 dataLoad.setDataUpdateTime(dataUpdateTime); - saveDeviceData(pointMatchList, obj, dataLoad); + saveDeviceData(pointMatchList, obj, dataLoad, pointEnumMatchMap); dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); @@ -832,6 +854,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理LOAD总表数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.CLUSTER.getCode()); //BMSC 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); // 其他非 BigDecimal 字段 @@ -853,10 +876,10 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 获取redis获取最新的BMSD数据 Map stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD + siteId + "_" + stackDeviceId); data.setDeviceId(deviceId); - saveDeviceData(pointMatchList, obj, data); + saveDeviceData(pointMatchList, obj, data, pointEnumMatchMap); // 取堆里面数据 - saveDeviceData(pointMatchList, stackObj, data); + saveDeviceData(pointMatchList, stackObj, data, pointEnumMatchMap); emsBatteryClusterMapper.insertEmsBatteryCluster(data); redisCache.setCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + deviceId, data); @@ -929,6 +952,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理METE储能电表数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.AMMETER.getCode()); // 获取上次数据,便于后面计算差值均无则默认0 EmsAmmeterData lastAmmeterData = getLastAmmeterData(siteId, deviceId); @@ -937,7 +961,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 更新时间 dataMete.setDataUpdateTime(dataUpdateTime); - saveDeviceData(pointMatchList, obj, dataMete); + saveDeviceData(pointMatchList, obj, dataMete, pointEnumMatchMap); dataMete.setCreateBy("system"); dataMete.setCreateTime(DateUtils.getNowDate()); @@ -1396,11 +1420,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理中水冷却告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.PCS.getCode()); EmsPcsAlarmData pcsAlarmData = new EmsPcsAlarmData(); // 更新时间 pcsAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, pcsAlarmData); + saveDeviceData(pointMatchList, obj, pcsAlarmData, pointEnumMatchMap); pcsAlarmData.setCreateBy("system"); pcsAlarmData.setCreateTime(DateUtils.getNowDate()); @@ -1422,12 +1447,13 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池堆告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.STACK.getCode()); EmsStackAlarmData stackAlarmData = new EmsStackAlarmData(); // 更新时间 stackAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, stackAlarmData); + saveDeviceData(pointMatchList, obj, stackAlarmData, pointEnumMatchMap); stackAlarmData.setCreateBy("system"); stackAlarmData.setCreateTime(DateUtils.getNowDate()); @@ -1448,11 +1474,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池簇告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.CLUSTER.getCode()); EmsClusterAlarmData clusterAlarmData = new EmsClusterAlarmData(); // 更新时间 clusterAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, clusterAlarmData); + saveDeviceData(pointMatchList, obj, clusterAlarmData, pointEnumMatchMap); clusterAlarmData.setCreateBy("system"); clusterAlarmData.setCreateTime(DateUtils.getNowDate()); @@ -1474,12 +1501,13 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理中水冷却告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } + Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.COOLING.getCode()); EmsCoolingAlarmData coolingAlarmData = new EmsCoolingAlarmData(); // 更新时间 coolingAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, coolingAlarmData); + saveDeviceData(pointMatchList, obj, coolingAlarmData, pointEnumMatchMap); coolingAlarmData.setCreateBy("system"); coolingAlarmData.setCreateTime(DateUtils.getNowDate()); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index 0e9d660..1a92c07 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -28,10 +28,12 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import com.xzzn.common.utils.poi.ExcelUtil; +import com.xzzn.ems.domain.EmsPointEnumMatch; import com.xzzn.ems.domain.vo.DevicePointMatchExportVo; import com.xzzn.ems.domain.vo.DevicePointMatchVo; import com.xzzn.ems.domain.vo.ImportPointDataRequest; import com.xzzn.ems.enums.DeviceMatchTable; +import com.xzzn.ems.mapper.EmsPointEnumMatchMapper; import com.xzzn.ems.mapper.EmsPointMatchMapper; import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.service.IEmsPointMatchService; @@ -46,12 +48,14 @@ import javax.validation.Validator; * @date 2025-11-04 */ @Service -public class EmsPointMatchServiceImpl implements IEmsPointMatchService -{ +public class EmsPointMatchServiceImpl implements IEmsPointMatchService { private static final Logger log = LoggerFactory.getLogger(EmsPointMatchServiceImpl.class); + private static final String SEPARATOR = "#"; @Autowired private EmsPointMatchMapper emsPointMatchMapper; @Autowired + private EmsPointEnumMatchMapper emsPointEnumMatchMapper; + @Autowired protected Validator validator; @Autowired private RedisCache redisCache; @@ -63,13 +67,33 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService * @return 点位匹配 */ @Override - public List selectEmsPointMatchList(EmsPointMatch emsPointMatch) - { - return emsPointMatchMapper.selectEmsPointMatchExportList(emsPointMatch); + public List selectEmsPointMatchList(EmsPointMatch emsPointMatch) { + List devicePointMatchExportVos = emsPointMatchMapper.selectEmsPointMatchExportList(emsPointMatch); + if (CollectionUtils.isEmpty(devicePointMatchExportVos)) { + return devicePointMatchExportVos; + } + + for (DevicePointMatchExportVo devicePointMatch : devicePointMatchExportVos) { + List pointEnumMatchList = emsPointEnumMatchMapper.selectList(emsPointMatch.getSiteId(), + emsPointMatch.getDeviceCategory(), devicePointMatch.getMatchField()); + if (!CollectionUtils.isEmpty(pointEnumMatchList)) { + String enumName = pointEnumMatchList.stream().map(EmsPointEnumMatch::getEnumName).filter(StringUtils::isNotBlank).collect(Collectors.joining(SEPARATOR)); + String dataEnumCode = pointEnumMatchList.stream().map(EmsPointEnumMatch::getDataEnumCode).filter(StringUtils::isNotBlank).collect(Collectors.joining(SEPARATOR)); +// List dataEnumCode = pointEnumMatchList.stream().map(EmsPointEnumMatch::getDataEnumCode).collect(Collectors.toList()); + +// devicePointMatch.setMatchFieldEnum(StringUtils.join(enumName, SEPARATOR)); +// devicePointMatch.setDataEnum(StringUtils.join(dataEnumCode, SEPARATOR)); + devicePointMatch.setMatchFieldEnum(enumName); + devicePointMatch.setDataEnum(dataEnumCode); + } + } + + return devicePointMatchExportVos; } /** * 上传点位清单 + * * @param pointMatchList * @param isUpdateSupport * @param operName @@ -77,8 +101,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService */ @Override public String importPoint(List pointMatchList, boolean isUpdateSupport, String operName) { - if (StringUtils.isNull(pointMatchList) || pointMatchList.size() == 0) - { + if (StringUtils.isNull(pointMatchList) || pointMatchList.size() == 0) { throw new ServiceException("导入用户数据不能为空!"); } int successNum = 0; @@ -89,19 +112,19 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService try { // 验证点位是否存在 EmsPointMatch point = emsPointMatchMapper.getUniquePoint(pointMatch.getSiteId(), - pointMatch.getDeviceCategory(),pointMatch.getDataPoint()); + pointMatch.getDeviceCategory(), pointMatch.getDataPoint()); if (StringUtils.isNull(point)) { BeanValidators.validateWithException(validator, pointMatch); pointMatch.setCreateBy(operName); emsPointMatchMapper.insertEmsPointMatch(pointMatch); successNum++; - successMsg.append("
" + successNum + "、站点 " + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint()+ " 导入成功"); + successMsg.append("
" + successNum + "、站点 " + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint() + " 导入成功"); } else if (isUpdateSupport) { BeanValidators.validateWithException(validator, pointMatch); pointMatch.setUpdateBy(operName); emsPointMatchMapper.updateEmsPointMatch(pointMatch); successNum++; - successMsg.append("
" + successNum + "、站点 " + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint()+ " 更新成功"); + successMsg.append("
" + successNum + "、站点 " + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint() + " 更新成功"); } else { failureNum++; failureMsg.append("
" + failureNum + "、站点" + pointMatch.getSiteId() + "、点位 " + pointMatch.getDataPoint() + " 已存在"); @@ -123,6 +146,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService /** * 导入设备点位清单数据到数据库,并同步到Redis + * * @param request * @param operName * @return @@ -176,6 +200,9 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService savePoint.setId(dbPoint.getId()); emsPointMatchMapper.updateEmsPointMatch(savePoint); } + // 保存点位枚举映射关系 + savePointMatchEnum(pointMatch.getMatchFieldEnum(), pointMatch.getDataEnum(), savePoint); + } catch (Exception e) { log.info("点位清单导入失败:{}", e.getMessage()); throw new ServiceException("点位清单导入失败!"); @@ -206,11 +233,51 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService } private void syncToRedis(String siteId, String deviceCategory) { - // 同步到Redis + // 点位匹配数据同步到Redis String pointMatchKey = DevicePointMatchDataProcessor.getPointMacthCacheKey(siteId, deviceCategory); List pointMatchData = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceCategory); // log.info("同步点位匹配数据到Redis key:{} data:{}", pointMatchKey, pointMatchData); - redisCache.setCacheObject(pointMatchKey, pointMatchData); - log.info("点位匹配数据同步完成 data:{}", JSON.toJSONString(redisCache.getCacheObject(pointMatchKey))); + if (redisCache.hasKey(pointMatchKey)) { + redisCache.deleteObject(pointMatchKey); + } + redisCache.setCacheList(pointMatchKey, pointMatchData); + log.info("点位匹配数据同步完成 data:{}", JSON.toJSONString(redisCache.getCacheList(pointMatchKey))); + + // 点位枚举匹配数据同步到Redis + String pointEnumMatchKey = DevicePointMatchDataProcessor.getPointEnumMacthCacheKey(siteId, deviceCategory); + List pointEnumMatchList = emsPointEnumMatchMapper.selectList(siteId, deviceCategory, null); + if (!CollectionUtils.isEmpty(pointEnumMatchList)) { + if (redisCache.hasKey(pointEnumMatchKey)) { + redisCache.deleteObject(pointEnumMatchKey); + } + redisCache.setCacheList(pointEnumMatchKey, pointEnumMatchList); + log.info("点位枚举匹配数据同步完成 data:{}", JSON.toJSONString(redisCache.getCacheList(pointEnumMatchKey))); + } + + } + + private void savePointMatchEnum(String matchFieldEnum, String dataEnum, EmsPointMatch savePoint) { + if (StringUtils.isAllBlank(matchFieldEnum, dataEnum)) { + return; + } + List pointEnumMatchList = emsPointEnumMatchMapper.selectList(savePoint.getSiteId(), savePoint.getDeviceCategory(), savePoint.getMatchField()); + if (CollectionUtils.isEmpty(pointEnumMatchList)) { + return; + } + String[] matchFieldEnums = matchFieldEnum.split(SEPARATOR); + String[] dataEnums = dataEnum.split(SEPARATOR); + if (matchFieldEnums.length != dataEnums.length) { + return; + } + for (int i = 0; i < matchFieldEnums.length; i++) { + String enumName = matchFieldEnums[i]; + String dataEnumCode = dataEnums[i]; + pointEnumMatchList.forEach(pointEnumMatch -> { + if (pointEnumMatch.getEnumName().equals(enumName)) { + pointEnumMatch.setDataEnumCode(dataEnumCode); + emsPointEnumMatchMapper.updateDataEnumCodeById(pointEnumMatch); + } + }); + } } } diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java index 2b1c72c..6c5abe4 100644 --- a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java +++ b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java @@ -11,11 +11,13 @@ import com.xzzn.common.enums.PointType; import com.xzzn.common.utils.DataUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.EmsPointEnumMatch; import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.domain.vo.DevicePointMatchInfo; import com.xzzn.ems.domain.vo.StackStatisListVo; import com.xzzn.ems.enums.DeviceMatchTable; import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsPointEnumMatchMapper; import com.xzzn.ems.mapper.EmsPointMatchMapper; import java.lang.reflect.Field; @@ -25,6 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.function.Function; import java.util.stream.Collectors; import javax.annotation.PostConstruct; @@ -47,6 +50,8 @@ public class DevicePointMatchDataProcessor { private EmsDevicesSettingMapper emsDevicesSettingMapper; @Autowired private EmsPointMatchMapper emsPointMatchMapper; + @Autowired + private EmsPointEnumMatchMapper emsPointEnumMatchMapper; @Autowired private RedisCache redisCache; @@ -115,6 +120,25 @@ public class DevicePointMatchDataProcessor { return pointMatchList; } + public List getPointEnumMatchList(String siteId, String deviceCategory) { + List pointEnumMatchList = redisCache.getCacheList(getPointEnumMacthCacheKey(siteId, deviceCategory)); + + if (CollectionUtils.isEmpty(pointEnumMatchList)) { + pointEnumMatchList = emsPointEnumMatchMapper.selectList(siteId, deviceCategory, null); + } + + return pointEnumMatchList; + } + + public Map> getPointEnumMatchMap(String siteId, String deviceCategory) { + List pointEnumMatchList = getPointEnumMatchList(siteId, deviceCategory); + if (CollectionUtils.isEmpty(pointEnumMatchList)) { + return new HashMap<>(); + } + return pointEnumMatchList.stream() + .collect(Collectors.groupingBy(data -> StringUtils.toCamelCase(data.getMatchField()))); + } + public void saveDevicePointMatch(String siteId, String deviceId, DeviceMatchTable pointMatchType, String dataDevice) { // EmsDevicesSetting devicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); // if (devicesSetting == null) { @@ -194,4 +218,15 @@ public class DevicePointMatchDataProcessor { { return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId; } + + /** + * 设置点位枚举缓存key + * @param siteId + * @param deviceCategory + * @return 点位枚举缓存key + */ + public static String getPointEnumMacthCacheKey(String siteId, String deviceCategory) + { + return RedisKeyConstants.POINT_ENUM_MATCH + deviceCategory + "_" + siteId; + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointEnumMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointEnumMatchMapper.xml new file mode 100644 index 0000000..7ba0254 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsPointEnumMatchMapper.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + select id, match_field, site_id, device_category, enum_code, enum_name, enum_desc, data_enum_code, create_by, create_time, update_by, update_time, remark from ems_point_enum_match + + + + + + + + insert into ems_point_enum_match + + match_field, + site_id, + device_category, + enum_code, + enum_name, + enum_desc, + data_enum_code, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{matchField}, + #{siteId}, + #{deviceCategory}, + #{enumCode}, + #{enumName}, + #{enumDesc}, + #{dataEnumCode}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_point_enum_match + + match_field = #{matchField}, + site_id = #{siteId}, + device_category = #{deviceCategory}, + enum_code = #{enumCode}, + enum_name = #{enumName}, + enum_desc = #{enumDesc}, + data_enum_code = #{dataEnumCode}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + update ems_point_enum_match + set data_enum_code = #{dataEnumCode}, update_time = now() + where id = #{id} + + + + delete from ems_point_enum_match where id = #{id} + + + + delete from ems_point_enum_match where id in + + #{id} + + + + + + \ No newline at end of file -- 2.49.0 From 5f1e621da27ffc1e7ff9c8c6eb231a7ca22efb4f Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 9 Dec 2025 14:28:52 +0800 Subject: [PATCH 234/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E7=82=B9=E4=BD=8D=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=97=A5=E6=95=B0=E6=8D=AE=E9=87=87=E7=94=A8=E7=AE=B1?= =?UTF-8?q?=E7=BA=BF=E5=9B=BE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/DevicePointDataList.java | 6 + .../ems/domain/vo/GeneralQueryDataVo.java | 67 ++++++ .../xzzn/ems/mapper/EmsPointMatchMapper.java | 16 ++ .../service/impl/GeneralQueryServiceImpl.java | 190 +++++++++++++++++- .../mapper/ems/EmsPointMatchMapper.xml | 51 +++++ 5 files changed, 325 insertions(+), 5 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java index ac2f356..3d9d2f0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DevicePointDataList.java @@ -40,6 +40,12 @@ public class DevicePointDataList this.minDate = minDate; } + public DevicePointDataList(String deviceId, String parentDeviceId, List pointValueList) { + this.deviceId = deviceId; + this.parentDeviceId = parentDeviceId; + this.pointValueList = pointValueList; + } + public DevicePointDataList() { } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java index 81d67ff..0484094 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryDataVo.java @@ -14,6 +14,33 @@ public class GeneralQueryDataVo { private Object pointValue; private String parentDeviceId; + //箱线图数据 + /** 最小值(Minimum) */ + private BigDecimal min; + /** 第一四分位数(Q1) */ + private BigDecimal q1; + /** 中位数(Median/Q2) */ + private BigDecimal median; + /** 第三四分位数(Q3) */ + private BigDecimal q3; + /** 最大值(Maximum) */ + private BigDecimal max; + + public GeneralQueryDataVo() { + } + + public GeneralQueryDataVo(String siteId, String deviceId, String valueDate, String parentDeviceId, BigDecimal min, BigDecimal q1, BigDecimal median, BigDecimal q3, BigDecimal max) { + this.siteId = siteId; + this.deviceId = deviceId; + this.valueDate = valueDate; + this.parentDeviceId = parentDeviceId; + this.min = min; + this.q1 = q1; + this.median = median; + this.q3 = q3; + this.max = max; + } + public String getSiteId() { return siteId; } @@ -53,4 +80,44 @@ public class GeneralQueryDataVo { public void setParentDeviceId(String parentDeviceId) { this.parentDeviceId = parentDeviceId; } + + public BigDecimal getMin() { + return min; + } + + public void setMin(BigDecimal min) { + this.min = min; + } + + public BigDecimal getQ1() { + return q1; + } + + public void setQ1(BigDecimal q1) { + this.q1 = q1; + } + + public BigDecimal getMedian() { + return median; + } + + public void setMedian(BigDecimal median) { + this.median = median; + } + + public BigDecimal getQ3() { + return q3; + } + + public void setQ3(BigDecimal q3) { + this.q3 = q3; + } + + public BigDecimal getMax() { + return max; + } + + public void setMax(BigDecimal max) { + this.max = max; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index b799df3..c604e11 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -101,6 +101,15 @@ public interface EmsPointMatchMapper @Param("params") Map> params, @Param("clusterDeviceId")String clusterDeviceId); + // 根据条件查询箱线图数据-按天-单体电池特殊处理 + public List getBatteryPointDataForBoxPlot(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate")Date startDate, + @Param("endDate")Date endDate, + @Param("params") Map> params, + @Param("clusterDeviceId")String clusterDeviceId); + // 根据条件查询数据-按分钟-其他设备 public List getCommonPointDataByMinutes(@Param("siteIds")List siteIds, @Param("tableName")String tableName, @@ -122,6 +131,13 @@ public interface EmsPointMatchMapper @Param("startDate")Date startDate, @Param("endDate")Date endDate, @Param("deviceId")String deviceId); + // 根据条件查询箱线图数据-按天-其他设备 + public List getCommonPointDataForBoxPlot(@Param("siteIds")List siteIds, + @Param("tableName")String tableName, + @Param("tableField")String tableField, + @Param("startDate")Date startDate, + @Param("endDate")Date endDate, + @Param("deviceId")String deviceId); // 单个站点单个设备点位查询-除了电池簇其他设备使用 public List getSingleSiteDevicePoints(@Param("siteId")String siteId, diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index 6d99ba0..93c89da 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -1,5 +1,6 @@ package com.xzzn.ems.service.impl; +import com.sun.org.glassfish.external.statistics.Stats; import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsPointMatch; @@ -20,6 +21,8 @@ import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.stream.Collectors; +import javax.lang.model.util.ElementScanner6; + /** * 综合查询 服务层实现 * @@ -142,11 +145,18 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService dataVoList = emsPointMatchMapper.getCommonPointDataByHours(querySiteIds,tableName,tableField,startDate,endDate,deviceId); } else if (dataUnit == 3) { // 天:yyyy-MM-dd 00:00:00 endDate = DateUtils.adjustToEndOfDay(request.getEndDate()); - dataVoList = emsPointMatchMapper.getCommonPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,deviceId); + dataVoList = emsPointMatchMapper.getCommonPointDataForBoxPlot(querySiteIds,tableName,tableField,startDate,endDate,deviceId); + } + + if (dataUnit == 3) { + // 箱线图数据特殊处理 + result = dealCommonWithBoxPlotData(dataVoList, dataType); + } else { + // 曲线图数据特殊处理 + // 数据转换+计算曲线数据最大最小平均和差值 + result = convertCommonToResultList(dataVoList, dataType); } - // 数据转换+计算曲线数据最大最小平均和差值 - result = convertCommonToResultList(dataVoList, dataType); return result; } @@ -175,13 +185,113 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService } else if (dataUnit == 3) { // 天 endDate = DateUtils.adjustToEndOfDay(request.getEndDate()); tableName = "ems_battery_data_day"; - dataVoList = emsPointMatchMapper.getBatteryPointDataByDays(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap,clusterDeviceId); + dataVoList = emsPointMatchMapper.getBatteryPointDataForBoxPlot(querySiteIds,tableName,tableField,startDate,endDate,siteDeviceMap,clusterDeviceId); } // 数据转换 - result = convertBatteryToResultList(dataVoList,dataType); + if (dataUnit == 3) { + // 箱线图数据特殊处理 + result = dealBatteryWithBoxPlotData(dataVoList, dataType); + } else { + // 曲线图数据特殊处理 + // 数据转换+计算曲线数据最大最小平均和差值 + result = convertBatteryToResultList(dataVoList, dataType); + } return result; } + private List dealCommonWithBoxPlotData(List dataVoList, Long dataType) { + // 数据转换: 先按siteId分组,再按deviceId分组 + return dataVoList.stream() + // 第一层分组:按siteId分组,得到 + .collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId)) + .entrySet().stream() + .map(siteEntry -> { + String siteId = siteEntry.getKey(); + List siteAllData = siteEntry.getValue(); + + // 第二层分组:在当前站点下,按deviceId分组,得到 + List deviceList = siteAllData.stream() + .collect(Collectors.groupingBy(GeneralQueryDataVo::getDeviceId)) + .entrySet().stream() + .map(deviceEntry -> { + String deviceId = deviceEntry.getKey(); + List deviceDataList = deviceEntry.getValue(); + + // 第三层分组:在当前设备下,按时间分组,得到 <时间, 该时间段数据> + List dataList = deviceDataList.stream().sorted(Comparator.comparing(GeneralQueryDataVo::getValueDate)) + .collect(Collectors.groupingBy( + GeneralQueryDataVo::getValueDate, + TreeMap::new, + Collectors.toList())) + .entrySet().stream().map(timeEntry -> { + String valueDate = timeEntry.getKey(); + // 计算当前设备数据的统计值(最小值,第一四分位数,中位数,第三四分位数, 最大值) + List values = timeEntry.getValue().stream().map(data -> new BigDecimal(String.valueOf(data.getPointValue()))).collect(Collectors.toList()); + BoxPlotData data = calculateBoxPlotData(values); + return new GeneralQueryDataVo(siteId, deviceId, valueDate, null, data.min, data.q1, data.median, data.q3, data.max); + }).collect(Collectors.toList()); + + return new DevicePointDataList(deviceId, null, dataList); + }) + .collect(Collectors.toList()); + + return new GeneralQueryResponse(siteId, deviceList, dataType); + }) + .collect(Collectors.toList()); + } + + private List dealBatteryWithBoxPlotData(List dataVoList, Long dataType) { + // 先按siteId分组 + return dataVoList.stream() + .collect(Collectors.groupingBy(GeneralQueryDataVo::getSiteId)) + .entrySet().stream() + .map(siteEntry -> { + String siteId = siteEntry.getKey(); + List siteData = siteEntry.getValue(); + + // 2. 按(deviceId + parentDeviceId)组合分组,生成deviceList + List deviceList = siteData.stream() + // 分组键:deviceId + parentDeviceId(确保唯一设备) + .collect(Collectors.groupingBy(data -> + data.getDeviceId() + "_" + data.getParentDeviceId() + )) + .entrySet().stream() + .map(deviceEntry -> { + // 解析分组键,获取deviceId和parentDeviceId + String[] keyParts = deviceEntry.getKey().split("_"); + String deviceId = keyParts[0]; + String parentDeviceId = keyParts[1]; + + // 3. 第三层分组:在当前设备下,按时间分组,得到 <时间, 该时间段数据> + List deviceDataList = deviceEntry.getValue().stream() + .collect(Collectors.groupingBy( + GeneralQueryDataVo::getValueDate, + TreeMap::new, + Collectors.toList())) + .entrySet().stream().map(timeEntry -> { + String valueDate = timeEntry.getKey(); + + // 计算当前设备数据的统计值(最小值,第一四分位数,中位数,第三四分位数, 最大值) + List values = timeEntry.getValue().stream().map(data -> new BigDecimal(String.valueOf(data.getPointValue()))).collect(Collectors.toList()); + BoxPlotData data = calculateBoxPlotData(values); + return new GeneralQueryDataVo(siteId, deviceId, valueDate, parentDeviceId, data.min, data.q1, data.median, data.q3, data.max); + }).collect(Collectors.toList()); + + // 4. 构建DeviceItem + return new DevicePointDataList(deviceId, parentDeviceId, deviceDataList); + })// 关键排序步骤:先按deviceId升序,再按parentDeviceId升序 + .sorted( + Comparator.comparing(DevicePointDataList::getDeviceId) // 第一排序键:deviceId + .thenComparing(DevicePointDataList::getParentDeviceId) // 第二排序键:parentDeviceId + ) + .collect(Collectors.toList()); + + // 5. 构建SiteData + return new GeneralQueryResponse(siteId, deviceList, dataType); + }) + .collect(Collectors.toList()); + } + private List convertBatteryToResultList(List dataVoList, Long dataType) { // 先按siteId分组 return dataVoList.stream() @@ -492,6 +602,49 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService return minutes; } + public BoxPlotData calculateBoxPlotData(List values) { + if (values == null || values.isEmpty()) { + return null; + } + + // 排序 + Collections.sort(values); + + // 计算五个统计量 + BigDecimal min = values.get(0); + BigDecimal max = values.get(values.size() - 1); + BigDecimal median = calculateMedian(values); + BigDecimal q1 = calculateQuartile(values, new BigDecimal("0.25")); + BigDecimal q3 = calculateQuartile(values, new BigDecimal("0.75")); + + return new BoxPlotData(min, q1, median, q3, max); + } + + private BigDecimal calculateMedian(List values) { + int size = values.size(); + if (size % 2 == 0) { + return (values.get(size/2 - 1).add(values.get(size/2))).divide(new BigDecimal(2)); + } else { + return values.get(size/2); + } + } + + private BigDecimal calculateQuartile(List values, BigDecimal quartile) { + int size = values.size(); + BigDecimal pos = new BigDecimal(size - 1).multiply(quartile); + int lowerIndex = (int) Math.floor(pos.doubleValue()); + int upperIndex = (int) Math.ceil(pos.doubleValue()); + + if (lowerIndex == upperIndex) { + return values.get(lowerIndex); + } + + BigDecimal lowerValue = values.get(lowerIndex); + BigDecimal upperValue = values.get(upperIndex); +// return lowerValue + (upperValue - lowerValue) * (pos - lowerIndex); + return lowerValue.add(upperValue.subtract(lowerValue)).multiply((pos.subtract(new BigDecimal(lowerIndex)))); + } + /** * 内部辅助类:存储统计结果 */ @@ -527,4 +680,31 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService } } + /** + * 内部辅助类:存储箱线图统计结果 + */ + private static class BoxPlotData { + /** 最小值(Minimum) */ + private final BigDecimal min; + + /** 第一四分位数(Q1) */ + private final BigDecimal q1; + + /** 中位数(Median/Q2) */ + private final BigDecimal median; + + /** 第三四分位数(Q3) */ + private final BigDecimal q3; + + /** 最大值(Maximum) */ + private final BigDecimal max; + + public BoxPlotData(BigDecimal min, BigDecimal q1, BigDecimal median, BigDecimal q3, BigDecimal max) { + this.min = min; + this.q1 = q1; + this.median = median; + this.q3 = q3; + this.max = max; + } + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 29f9581..3219fa7 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -273,6 +273,30 @@ ORDER BY t.site_id, t.device_id, t.cluster_device_id, valueDate ASC + + + + + + + and data_update_time = #{dataUpdateTime} + and ems_status = #{emsStatus} + and bms1_soc = #{bms1Soc} + and bms2_soc = #{bms2Soc} + and bms3_soc = #{bms3Soc} + and bms4_soc = #{bms4Soc} + and pcs1_yggl = #{pcs1Yggl} + and pcs2_yggl = #{pcs2Yggl} + and pcs3_yggl = #{pcs3Yggl} + and pcs4_yggl = #{pcs4Yggl} + and ems_yggl = #{emsYggl} + and site_id = #{siteId} + and device_id = #{deviceId} + + + + + + + insert into ems_ems_data + + data_update_time, + ems_status, + bms1_soc, + bms2_soc, + bms3_soc, + bms4_soc, + pcs1_yggl, + pcs2_yggl, + pcs3_yggl, + pcs4_yggl, + ems_yggl, + site_id, + device_id, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{dataUpdateTime}, + #{emsStatus}, + #{bms1Soc}, + #{bms2Soc}, + #{bms3Soc}, + #{bms4Soc}, + #{pcs1Yggl}, + #{pcs2Yggl}, + #{pcs3Yggl}, + #{pcs4Yggl}, + #{emsYggl}, + #{siteId}, + #{deviceId}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_ems_data + + data_update_time = #{dataUpdateTime}, + ems_status = #{emsStatus}, + bms1_soc = #{bms1Soc}, + bms2_soc = #{bms2Soc}, + bms3_soc = #{bms3Soc}, + bms4_soc = #{bms4Soc}, + pcs1_yggl = #{pcs1Yggl}, + pcs2_yggl = #{pcs2Yggl}, + pcs3_yggl = #{pcs3Yggl}, + pcs4_yggl = #{pcs4Yggl}, + ems_yggl = #{emsYggl}, + site_id = #{siteId}, + device_id = #{deviceId}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_ems_data where id = #{id} + + + + delete from ems_ems_data where id in + + #{id} + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 3219fa7..6eb771b 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -518,5 +518,14 @@ and device_category = #{deviceCategory}
+ \ No newline at end of file -- 2.49.0 From 497e5bb8ca8d8a314ebf5f55b1c3f6a95c10af38 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 9 Dec 2025 16:58:52 +0800 Subject: [PATCH 236/336] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index 93c89da..649456c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -1,6 +1,5 @@ package com.xzzn.ems.service.impl; -import com.sun.org.glassfish.external.statistics.Stats; import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsPointMatch; -- 2.49.0 From 34888087867f83277dd1087f6bb99cc74ae2710a Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 9 Dec 2025 17:23:24 +0800 Subject: [PATCH 237/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E7=BB=BC=E5=90=88=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?-=E6=8C=89=E5=A4=A9=E6=9F=A5=E8=AF=A2=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=AE=B1=E7=BA=BF=E5=9B=BE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/vo/GeneralQueryResponse.java | 14 +++++++++++++- .../ems/service/impl/GeneralQueryServiceImpl.java | 8 ++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java index 1571ac8..99b440a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/GeneralQueryResponse.java @@ -17,10 +17,14 @@ public class GeneralQueryResponse { // 点位数据类型,1-瞬时值,2-累计值 private Long dataType; - public GeneralQueryResponse(String siteId, List deviceList, Long dataType) { + // 点位数据图表类型,1-曲线图,2-箱线图 + private Long chartType; + + public GeneralQueryResponse(String siteId, List deviceList, Long dataType, Long chartType) { this.siteId = siteId; this.deviceList = deviceList; this.dataType = dataType; + this.chartType = chartType; } public GeneralQueryResponse() { @@ -50,4 +54,12 @@ public class GeneralQueryResponse { public void setDataType(Long dataType) { this.dataType = dataType; } + + public Long getChartType() { + return chartType; + } + + public void setChartType(Long chartType) { + this.chartType = chartType; + } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java index 649456c..70b2170 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/GeneralQueryServiceImpl.java @@ -234,7 +234,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService }) .collect(Collectors.toList()); - return new GeneralQueryResponse(siteId, deviceList, dataType); + return new GeneralQueryResponse(siteId, deviceList, dataType, 2L); }) .collect(Collectors.toList()); } @@ -286,7 +286,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService .collect(Collectors.toList()); // 5. 构建SiteData - return new GeneralQueryResponse(siteId, deviceList, dataType); + return new GeneralQueryResponse(siteId, deviceList, dataType, 2L); }) .collect(Collectors.toList()); } @@ -340,7 +340,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService .collect(Collectors.toList()); // 5. 构建SiteData - return new GeneralQueryResponse(siteId, deviceList, dataType); + return new GeneralQueryResponse(siteId, deviceList, dataType, 1L); }) .collect(Collectors.toList()); } @@ -371,7 +371,7 @@ public class GeneralQueryServiceImpl implements IGeneralQueryService }) .collect(Collectors.toList()); - return new GeneralQueryResponse(siteId, deviceList, dataType); + return new GeneralQueryResponse(siteId, deviceList, dataType, 1L); }) .collect(Collectors.toList()); -- 2.49.0 From 73c668709ae6d531274132b76d29d68e76b1f68a Mon Sep 17 00:00:00 2001 From: zq Date: Thu, 11 Dec 2025 16:13:39 +0800 Subject: [PATCH 238/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E7=82=B9=E4=BD=8D=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AE=BE=E5=A4=87ID=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 8 ++++++ .../com/xzzn/ems/domain/EmsPointMatch.java | 13 ++++++++++ .../ems/domain/vo/ImportPointDataRequest.java | 11 ++++++++ .../xzzn/ems/mapper/EmsPointMatchMapper.java | 5 ++-- .../impl/DeviceDataProcessServiceImpl.java | 6 +++++ .../impl/EmsDeviceSettingServiceImpl.java | 26 ++++++++++++++----- .../impl/EmsPointMatchServiceImpl.java | 16 ++++++++---- .../utils/DevicePointMatchDataProcessor.java | 10 +++---- .../mapper/ems/EmsPointMatchMapper.xml | 15 ++++++++++- 9 files changed, 90 insertions(+), 20 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index c9d4a11..6d124f9 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -87,6 +87,11 @@ public class RedisKeyConstants */ public static final String ORIGINAL_MQTT_DATA = "MQTT_"; + /** + * 存放单个设备同步过来的告警点位原始数据-最晚一次数据 + */ + public static final String ORIGINAL_MQTT_DATA_ALARM = "MQTT_ALARM_"; + /** 存放订阅失败告警信息 */ public static final String TOPIC_FAILED_ALRAM_RECORD = "topic_failed_"; /** topic 内没有数据设备维度告警 */ @@ -110,4 +115,7 @@ public class RedisKeyConstants /** 每个设备最新数据-设置失效时间-判断是否正常同步数据 */ public static final String SYNC_DATA= "SYNC_DATA_"; + + /** 每个设备最新数据-设置失效时间-判断是否正常同步数据 */ + public static final String SYNC_DATA_ALARM = "SYNC_DATA_ALARM_"; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java index 3d80901..b12eb32 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPointMatch.java @@ -74,6 +74,10 @@ public class EmsPointMatch extends BaseEntity @Excel(name = "是否告警点位", readConverterExp = "0=否,1=是") private Integer isAlarm; + /** 设备唯一标识符 */ + @Excel(name = "设备唯一标识符") + private String deviceId; + public void setId(Long id) { this.id = id; @@ -220,6 +224,14 @@ public class EmsPointMatch extends BaseEntity this.isAlarm = isAlarm; } + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -243,6 +255,7 @@ public class EmsPointMatch extends BaseEntity .append("updateTime", getUpdateTime()) .append("remark", getRemark()) .append("isAlarm", getIsAlarm()) + .append("deviceId", getDeviceId()) .toString(); } } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java index 3406156..d5a6416 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ImportPointDataRequest.java @@ -17,6 +17,9 @@ public class ImportPointDataRequest { /** 站点id */ @NotBlank(message = "站点ID不能为空") private String siteId; + /** 设备id */ + @NotBlank(message = "设备ID不能为空") + private String deviceId; /** 设备类型 */ @NotBlank(message = "设备类型不能为空") private String deviceCategory; @@ -32,6 +35,14 @@ public class ImportPointDataRequest { this.siteId = siteId; } + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + public String getDeviceCategory() { return deviceCategory; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 3614287..e7b3795 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -141,6 +141,7 @@ public interface EmsPointMatchMapper // 单个站点单个设备点位查询-除了电池簇其他设备使用 public List getSingleSiteDevicePoints(@Param("siteId")String siteId, + @Param("deviceId")String deviceId, @Param("deviceCategory")String deviceCategory, @Param("pointName")String pointName, @Param("dataPoint")String dataPoint, @@ -161,9 +162,9 @@ public interface EmsPointMatchMapper // 根据站点,设备类别,点位,获取唯一数据 public EmsPointMatch getUniquePoint(@Param("siteId")String siteId, @Param("deviceCategory")String deviceCategory, @Param("dataPoint")String dataPoint); - EmsPointMatch getOnePointMatch(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory, @Param("dataPoint") String dataPoint); + EmsPointMatch getOnePointMatch(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory, @Param("dataPoint") String dataPoint); - List getDevicePointMatchList(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); + List getDevicePointMatchList(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory); List selectEmsPointMatchExportList(EmsPointMatch emsPointMatch); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index a7e08aa..65ca69f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -1405,6 +1405,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); log.info("deviceId:" + deviceId); + + // 存放mqtt原始每个设备最晚一次数据,便于后面点位获取数据 + redisCache.setCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA_ALARM + siteId + "_" + deviceId, obj); + // 存放每次同步数据,失效时间(同同步时间)-用于判断是否正常同步数据 + redisCache.setCacheObject(RedisKeyConstants.SYNC_DATA_ALARM + siteId + "_" + deviceId, obj, 1, TimeUnit.MINUTES); + String deviceCategory = ""; if (deviceId.contains(SiteDevice.ZSLQ.name())) { coolingAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); 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 3c27c12..465096c 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 @@ -152,9 +152,13 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService dataPointName,dataPoint,parentDeviceId,ipAddress,ipPort,isAlarm); } else { response = emsPointMatchMapper.getSingleSiteDevicePoints( - siteId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort,isAlarm); + siteId,deviceId,deviceCategory,dataPointName,dataPoint,ipAddress,ipPort,isAlarm); + String redisDataKey = RedisKeyConstants.ORIGINAL_MQTT_DATA; + if (PointType.YES.getCode().equals(isAlarm)) { + redisDataKey = RedisKeyConstants.ORIGINAL_MQTT_DATA_ALARM; + } // 从redis取最新数据 - JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + deviceId); + JSONObject mqttJson = redisCache.getCacheObject(redisDataKey + siteId + "_" + deviceId); if(mqttJson == null){ return response; } @@ -239,11 +243,15 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService private List specialDealWithBattery(String siteId, String deviceId, String deviceCategory, String dataPointName, String dataPoint, String parentDeviceId, String ipAddress, Integer ipPort, Integer isAlarm) { - List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceCategory, + List response = emsPointMatchMapper.getSingleSiteDevicePoints(siteId,deviceId,deviceCategory, dataPointName,dataPoint,ipAddress,ipPort,isAlarm); // 获取redis同步最新数据 JSONObject jsonObject = new JSONObject(); + String redisDataKey = RedisKeyConstants.ORIGINAL_MQTT_DATA; + if (PointType.YES.getCode().equals(isAlarm)) { + redisDataKey = RedisKeyConstants.ORIGINAL_MQTT_DATA_ALARM; + } if (SiteEnum.DDS.getCode().equals(siteId)) { // dds单体电池数据来源于BMSD EmsDevicesSetting clusterDevice = emsDevicesMapper.getDeviceBySiteAndDeviceId(parentDeviceId,siteId); @@ -251,10 +259,10 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService if (StringUtils.isEmpty(bmsdDeviceId)) { return response; } - jsonObject = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + bmsdDeviceId); + jsonObject = redisCache.getCacheObject(redisDataKey + siteId + "_" + bmsdDeviceId); } else if (SiteEnum.FX.getCode().equals(siteId)) { // fx单体电池数据来源于父类簇BMSC - jsonObject = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + parentDeviceId); + jsonObject = redisCache.getCacheObject(redisDataKey + siteId + "_" + parentDeviceId); } if (jsonObject != null) { // 填充数据 @@ -329,15 +337,19 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService JSONObject mergedData = new JSONObject(); + String redisDataKey = RedisKeyConstants.ORIGINAL_MQTT_DATA; + if (PointType.YES.getCode().equals(isAlarm)) { + redisDataKey = RedisKeyConstants.ORIGINAL_MQTT_DATA_ALARM; + } // 数据来源pcs - JSONObject pcsJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_PCS"); + JSONObject pcsJson = redisCache.getCacheObject(redisDataKey + siteId + "_PCS"); if (pcsJson != null) { JSONObject data = pcsJson.getJSONObject("Data"); mergedData.putAll(data); } // 根据deviceId获取父类bmsd - JSONObject bmsdJson = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_MQTT_DATA + siteId + "_" + bmsdDeviceId); + JSONObject bmsdJson = redisCache.getCacheObject(redisDataKey + siteId + "_" + bmsdDeviceId); if (bmsdJson != null) { JSONObject data = bmsdJson.getJSONObject("Data"); mergedData.putAll(data); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index 1a92c07..fd32959 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -51,6 +51,8 @@ import javax.validation.Validator; public class EmsPointMatchServiceImpl implements IEmsPointMatchService { private static final Logger log = LoggerFactory.getLogger(EmsPointMatchServiceImpl.class); private static final String SEPARATOR = "#"; + + private static final String SITE_ID = "DEFAULT"; @Autowired private EmsPointMatchMapper emsPointMatchMapper; @Autowired @@ -68,6 +70,9 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { */ @Override public List selectEmsPointMatchList(EmsPointMatch emsPointMatch) { + if (StringUtils.isBlank(emsPointMatch.getDeviceId())) { + emsPointMatch.setSiteId(SITE_ID); + } List devicePointMatchExportVos = emsPointMatchMapper.selectEmsPointMatchExportList(emsPointMatch); if (CollectionUtils.isEmpty(devicePointMatchExportVos)) { return devicePointMatchExportVos; @@ -171,6 +176,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { } String siteId = request.getSiteId(); + String deviceId = request.getDeviceId(); String deviceCategory = request.getDeviceCategory(); List errorList = new ArrayList<>(); for (DevicePointMatchVo pointMatch : pointMatchList) { @@ -193,7 +199,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { savePoint.setCreateBy(operName); savePoint.setUpdateBy(operName); // 验证点位是否存在 - EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceCategory, pointMatch.getDataPoint()); + EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceId, deviceCategory, pointMatch.getDataPoint()); if (Objects.isNull(dbPoint)) { emsPointMatchMapper.insertEmsPointMatch(savePoint); } else { @@ -209,7 +215,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { } } // 同步到Redis - syncToRedis(siteId, deviceCategory); + syncToRedis(siteId, deviceId, deviceCategory); return errorList; } @@ -232,10 +238,10 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { return false; } - private void syncToRedis(String siteId, String deviceCategory) { + private void syncToRedis(String siteId, String deviceId, String deviceCategory) { // 点位匹配数据同步到Redis - String pointMatchKey = DevicePointMatchDataProcessor.getPointMacthCacheKey(siteId, deviceCategory); - List pointMatchData = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceCategory); + String pointMatchKey = DevicePointMatchDataProcessor.getPointMacthCacheKey(siteId, deviceId, deviceCategory); + List pointMatchData = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceId, deviceCategory); // log.info("同步点位匹配数据到Redis key:{} data:{}", pointMatchKey, pointMatchData); if (redisCache.hasKey(pointMatchKey)) { redisCache.deleteObject(pointMatchKey); diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java index 6c5abe4..8a0add0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java +++ b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java @@ -104,9 +104,9 @@ public class DevicePointMatchDataProcessor { // log.info("未找到设备配置信息,siteId: " + siteId + ", deviceId: "+ deviceId); // return pointMatchList; // } - List pointMatchList = redisCache.getCacheList(getPointMacthCacheKey(siteId, deviceCategory)); + List pointMatchList = redisCache.getCacheList(getPointMacthCacheKey(siteId, deviceId, deviceCategory)); if (CollectionUtils.isEmpty(pointMatchList)) { - pointMatchList = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceCategory); + pointMatchList = emsPointMatchMapper.getDevicePointMatchList(siteId, deviceId, deviceCategory); } if (CollectionUtils.isNotEmpty(pointMatchList)) { Map> map = pointMatchList.stream().collect(Collectors.groupingBy(EmsPointMatch::getIsAlarm)); @@ -154,7 +154,7 @@ public class DevicePointMatchDataProcessor { try { devicePintointMtachInfo.forEach((key, value) -> { // 查询点位是否存在 - EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceCategory, value); + EmsPointMatch dbPoint = emsPointMatchMapper.getOnePointMatch(siteId, deviceId, deviceCategory, value); if (!Objects.isNull(dbPoint)) { return; } @@ -214,9 +214,9 @@ public class DevicePointMatchDataProcessor { * @param deviceCategory * @return 点位缓存key */ - public static String getPointMacthCacheKey(String siteId, String deviceCategory) + public static String getPointMacthCacheKey(String siteId, String deviceId, String deviceCategory) { - return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId; + return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId + "_" + deviceId; } /** diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 6eb771b..91eb980 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -25,10 +25,11 @@ +
- select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, is_alarm from ems_point_match + select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, is_alarm, device_id from ems_point_match where site_id = #{siteId} + and device_id = #{deviceId} and device_category = #{deviceCategory} and data_point = #{dataPoint} order by update_time desc @@ -499,6 +509,7 @@ @@ -515,6 +526,7 @@ ems_point_match and site_id = #{siteId} + and device_id = #{deviceId} and device_category = #{deviceCategory} @@ -525,6 +537,7 @@ ems_point_match where is_alarm = 1 and site_id = #{siteId} + and device_id = #{deviceId} and device_category = #{deviceCategory} -- 2.49.0 From 0e1c7f52f143a82688332a5f2c0c2b47dcb39432 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 12 Dec 2025 10:47:21 +0800 Subject: [PATCH 239/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E8=B0=83=E6=95=B4=E8=A1=A8ems=5Fdev?= =?UTF-8?q?ices=5Fsetting=E5=AD=97=E6=AE=B5running=5Fstatus=E4=B8=BAdevice?= =?UTF-8?q?=5Fstatus=EF=BC=8C=E4=B8=8E=E8=A1=A8ems=5Fpcs=5Fdata=E5=AD=97?= =?UTF-8?q?=E6=AE=B5device=5Fstatus=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 12 +++++ .../com/xzzn/quartz/task/ModbusPoller.java | 14 +++--- .../xzzn/ems/domain/EmsDevicesSetting.java | 12 ++--- .../ems/domain/vo/DeviceUpdateRequest.java | 46 +++++++++++++++++++ .../ems/service/IEmsDeviceSettingService.java | 3 ++ .../impl/EmsDeviceSettingServiceImpl.java | 6 +++ .../mapper/ems/EmsDevicesSettingMapper.xml | 12 ++--- 7 files changed, 86 insertions(+), 19 deletions(-) create mode 100644 ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java 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 3ba4110..3f46464 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 @@ -8,6 +8,7 @@ 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.PointDataRequest; import com.xzzn.ems.domain.vo.PointQueryResponse; import com.xzzn.ems.domain.vo.SiteDeviceListVo; @@ -21,6 +22,8 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; +import javax.validation.Valid; + /** * * 站点配置 @@ -177,4 +180,13 @@ public class EmsSiteConfigController extends BaseController{ { return success(iEmsDeviceSettingService.getDeviceListBySiteAndCategory(siteId, deviceCategory)); } + + /** + * PCS设备开关机 + */ + @PostMapping("/updateDeviceStatus") + public AjaxResult updateDeviceStatus(@Valid DeviceUpdateRequest request) + { + return success(iEmsDeviceSettingService.updateDeviceStatus(request)); + } } diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java index 3e121d0..2d1b063 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java @@ -51,7 +51,7 @@ public class ModbusPoller { public void pollAllDevices() { logger.info("开始执行Modbus设备轮询..."); EmsDevicesSetting selectEntity = new EmsDevicesSetting(); - selectEntity.setRunningStatus(DeviceRunningStatus.RUNNING.getCode()); + selectEntity.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); List activeDevices = deviceRepo.selectEmsDevicesSettingList(selectEntity); EmsDevicesSetting device = activeDevices.get(0); @@ -103,8 +103,8 @@ public class ModbusPoller { } // 设备轮询不到修改运行状态 - String beforeStatus = device.getRunningStatus(); - device.setRunningStatus(DeviceRunningStatus.SHUTDOWN.getCode()); + String beforeStatus = device.getDeviceStatus(); + device.setDeviceStatus(DeviceRunningStatus.SHUTDOWN.getCode()); emsDeviceSettingServiceImpl.updateDevice(device); // 轮询设备,设备状态变更日志 @@ -117,16 +117,16 @@ public class ModbusPoller { // 处理获取到的数据 private void processData(EmsDevicesSetting device, int[] data) throws MqttException { - String beforeStatus = device.getRunningStatus(); + String beforeStatus = device.getDeviceStatus(); Boolean error = true; if (data == null || data.length == 0) { logger.warn("设备{}返回空数据", device.getId()); // 设备读取不到-设置设备故障 - device.setRunningStatus(DeviceRunningStatus.FAULT.getCode()); + device.setDeviceStatus(DeviceRunningStatus.FAULT.getCode()); error = false; } else { // 恢复设备状态 - 运行 - device.setRunningStatus(DeviceRunningStatus.RUNNING.getCode()); + device.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); } emsDeviceSettingServiceImpl.updateDevice(device); // 轮询设备,设备状态变更日志 @@ -171,7 +171,7 @@ public class ModbusPoller { log.setSiteId(device.getSiteId()); log.setDeviceId(device.getDeviceId()); log.setBeforeStatus(beforeStatus); - log.setAfterStatus(device.getRunningStatus()); + log.setAfterStatus(device.getDeviceStatus()); log.setCreateBy("sys"); log.setCreateTime(new Date()); return log; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java index d2a350e..13a9d98 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java @@ -104,7 +104,7 @@ public class EmsDevicesSetting extends BaseEntity /** 设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ @Excel(name = "设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机") - private String runningStatus; + private String deviceStatus; /** 设备图像地址 */ @Excel(name = "设备图像地址") @@ -320,12 +320,12 @@ public class EmsDevicesSetting extends BaseEntity return deviceCategory; } - public String getRunningStatus() { - return runningStatus; + public String getDeviceStatus() { + return deviceStatus; } - public void setRunningStatus(String runningStatus) { - this.runningStatus = runningStatus; + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; } public void setPictureUrl(String pictureUrl) @@ -362,7 +362,7 @@ public class EmsDevicesSetting extends BaseEntity .append("deviceId", getDeviceId()) .append("parentId", getParentId()) .append("deviceCategory", getDeviceCategory()) - .append("runningStatus", getRunningStatus()) + .append("deviceStatus", getDeviceStatus()) .append("pictureUrl", getPictureUrl()) .toString(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java new file mode 100644 index 0000000..ba5db62 --- /dev/null +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java @@ -0,0 +1,46 @@ +package com.xzzn.ems.domain.vo; + +import javax.validation.constraints.NotBlank; + +/** + * 设备信息更新入参 + * + */ +public class DeviceUpdateRequest { + + /** 站点id */ + @NotBlank(message = "站点ID不能为空") + private String siteId; + + /** 设备id */ + @NotBlank(message = "设备ID不能为空") + private String deviceId; + + /** 设备状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ + private String deviceStatus; + + + public String getSiteId() { + return siteId; + } + + public void setSiteId(String siteId) { + this.siteId = siteId; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } +} 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 60aca5e..d38d27b 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 @@ -3,6 +3,7 @@ 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.PointDataRequest; import com.xzzn.ems.domain.vo.PointQueryResponse; @@ -33,4 +34,6 @@ public interface IEmsDeviceSettingService public Map> initDeviceInfo(); public List> getDeviceListBySiteAndCategory(String siteId, String deviceCategory); + + public boolean updateDeviceStatus(DeviceUpdateRequest request); } 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 465096c..1f8ca96 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 @@ -11,6 +11,7 @@ import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.vo.DeviceUpdateRequest; import com.xzzn.ems.domain.vo.PointDataRequest; import com.xzzn.ems.domain.vo.PointQueryResponse; import com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper; @@ -468,4 +469,9 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService public List> getDeviceListBySiteAndCategory(String siteId, String deviceCategory) { return emsDevicesMapper.getDeviceInfosBySiteIdAndCategory(siteId, deviceCategory); } + + @Override + public boolean updateDeviceStatus(DeviceUpdateRequest request) { + return false; + } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index fa6e930..574002f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -26,12 +26,12 @@ - +
- select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category, running_status, picture_url from ems_devices_setting + select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category,device_status, picture_url from ems_devices_setting @@ -90,7 +90,7 @@ device_id, parent_id, device_category, - running_status, + device_status, picture_url, @@ -114,7 +114,7 @@ #{deviceId}, #{parentId}, #{deviceCategory}, - #{runningStatus}, + #{deviceStatus}, #{pictureUrl}, @@ -142,7 +142,7 @@ device_id = #{deviceId}, parent_id = #{parentId}, device_category = #{deviceCategory}, - running_status = #{runningStatus}, + device_status = #{deviceStatus}, picture_url = #{pictureUrl}, where id = #{id} -- 2.49.0 From e73787ee8f4310db2c4b70066a3db6bd319637ff Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 12 Dec 2025 11:06:22 +0800 Subject: [PATCH 240/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E7=BB=9F=E4=B8=80PCS=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=B8=8E=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E8=AE=BE=E5=A4=87=E7=8A=B6=E6=80=81=E5=8F=96?= =?UTF-8?q?=E5=80=BC=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java | 10 +++++----- .../ems/service/impl/DeviceDataProcessServiceImpl.java | 6 ++++++ .../xzzn/ems/service/impl/SingleSiteServiceImpl.java | 1 + .../resources/mapper/ems/EmsDevicesSettingMapper.xml | 1 + .../main/resources/mapper/ems/EmsSiteSettingMapper.xml | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java index f1df91e..9d241f7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -16,7 +16,7 @@ public class SiteDeviceListVo { /** 设备类型 */ private String deviceType; /** 运行状态 */ - private String runningStatus; + private String deviceStatus; /** 设备类型 */ private String deviceCategory; /** 设备类型 */ @@ -78,12 +78,12 @@ public class SiteDeviceListVo { this.deviceType = deviceType; } - public String getRunningStatus() { - return runningStatus; + public String getDeviceStatus() { + return deviceStatus; } - public void setRunningStatus(String runningStatus) { - this.runningStatus = runningStatus; + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; } public String getDeviceCategory() { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 65ca69f..cf4cde7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -774,6 +774,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i emsPcsDataMapper.insertEmsPcsData(pcsData); redisCache.setCacheObject(RedisKeyConstants.PCS + siteId + "_" + deviceId, pcsData); + // 同步更新PCS设备状态 +// EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); +// emsDevicesSetting.setDeviceStatus(pcsData.getDeviceStatus()); +// emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); +// emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); + if (SiteEnum.FX.getCode().equals(siteId)) { //更新每日充放电数据 dealFXXDailyChargeDate(siteId, deviceId, pcsData); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index c3ecfd2..c81b63c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -438,6 +438,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // // 报警个数 // int alarmNum = emsAlarmRecordsMapper.getDeviceAlarmNum(siteId,pcsId); pcsDetailInfoVo.setAlarmNum(alarmNum); + pcsDetailInfoVo.setDeviceStatus(pcsDevice.get("deviceStatus") == null ? "" : pcsDevice.get("deviceStatus").toString()); pcsDetailInfoVoList.add(pcsDetailInfoVo); } diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 574002f..19dba5b 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -190,6 +190,7 @@ select DISTINCT t1.device_id as id, t1.device_name as deviceName, t1.communication_status as communicationStatus, + t1.device_status as deviceStatus, t1.parent_id as parentDeviceId, t2.device_name as parentDeviceName from ems_devices_setting t1 diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index 5d4f681..1d1d2ad 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -136,7 +136,7 @@ + \ No newline at end of file -- 2.49.0 From 85b370ea4ca4bb132e3c768bad82b7c8a0295360 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 12 Dec 2025 14:36:18 +0800 Subject: [PATCH 242/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E7=82=B9=E4=BD=8D=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E8=AE=BE=E5=A4=87ID=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/mapper/EmsPointMatchMapper.java | 2 +- .../service/impl/SingleSiteServiceImpl.java | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 2e08d80..47a6c9d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -169,7 +169,7 @@ public interface EmsPointMatchMapper List selectEmsPointMatchExportList(EmsPointMatch emsPointMatch); - int getDevicePointAlarmNum(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); + int getDevicePointAlarmNum(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory); EmsPointMatch selectDeviceStatusPoint(@Param("request") DeviceUpdateRequest request); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index c81b63c..81cc6ee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -415,8 +415,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List pcsDetailInfoVoList = new ArrayList<>(); if (!StringUtils.isEmpty(siteId)) { - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.PCS.getCode()); // 获取该设备下所有pcs的id List> pcsIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode()); @@ -437,6 +435,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList); // // 报警个数 // int alarmNum = emsAlarmRecordsMapper.getDeviceAlarmNum(siteId,pcsId); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, pcsId, DeviceCategory.PCS.getCode()); pcsDetailInfoVo.setAlarmNum(alarmNum); pcsDetailInfoVo.setDeviceStatus(pcsDevice.get("deviceStatus") == null ? "" : pcsDevice.get("deviceStatus").toString()); @@ -464,8 +464,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getBMSOverView(String siteId) { List bmsOverViewVoList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.STACK.getCode()); // 获取所有电池堆 if (!StringUtils.isEmpty(siteId)) { List> stackIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.STACK.getCode()); @@ -484,6 +482,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { batteryDataLists = getBMSClusterListInfo(siteId,stackId,null); bmsOverViewVo.setBatteryDataList(batteryDataLists); } + + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, stackId, DeviceCategory.STACK.getCode()); bmsOverViewVo.setAlarmNum(alarmNum); bmsOverViewVoList.add(bmsOverViewVo); } @@ -523,8 +524,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getBMSBatteryCluster(String siteId) { List bmsBatteryClusterVoList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.CLUSTER.getCode()); if (!StringUtils.isEmpty(siteId)) { // 获取所有设备下的电池簇id List> clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode()); @@ -543,6 +542,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { dealWithBatteryClusterData(clusterData,clusterDataList); bmsBatteryClusterVo.setBatteryDataList(clusterDataList); } + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, clusterId, DeviceCategory.CLUSTER.getCode()); bmsBatteryClusterVo.setAlarmNum(alarmNum); bmsBatteryClusterVoList.add(bmsBatteryClusterVo); } @@ -585,8 +586,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getCoolingDataList(String siteId) { List emsCoolingDataList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.COOLING.getCode()); List> deviceIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.COOLING.getCode()); for (Map deviceId : deviceIds) { CoolingDataViewVo dataViewVo = new CoolingDataViewVo(); @@ -596,6 +595,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { EmsCoolingData coolingData = redisCache.getCacheObject(RedisKeyConstants.COOLING + siteId + "_" + coolingId); if (coolingData != null) { BeanUtils.copyProperties(coolingData, dataViewVo); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, coolingId, DeviceCategory.COOLING.getCode()); dataViewVo.setAlarmNum(alarmNum); } @@ -678,8 +679,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (ammeterIdList == null || ammeterIdList.isEmpty()) { return ammeterResponse; } - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.AMMETER.getCode()); for (Map ammeterDevice : ammeterIdList) { String ammeterId = ammeterDevice.get("id").toString(); if (!ammeterDeviceIds.contains(ammeterId)) { @@ -687,6 +686,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } // 从redis取总表详细数据 EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, ammeterId, DeviceCategory.AMMETER.getCode()); AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); ammeterDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); @@ -773,8 +774,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getDhDataList(String siteId) { List emsDhDataList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.DH.getCode()); List> dhDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.DH.getCode()); for (Map dhDevice : dhDeviceList) { DhDataVo dhDataVo = new DhDataVo(); @@ -785,6 +784,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (dhData != null) { BeanUtils.copyProperties(dhData, dhDataVo); } + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, dhDeviceId, DeviceCategory.DH.getCode()); dhDataVo.setAlarmNum(alarmNum); emsDhDataList.add(dhDataVo); } @@ -801,8 +802,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List emsXfDataList = new ArrayList<>(); List> xfDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.XF.getCode()); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.XF.getCode()); for (Map xfDevice : xfDeviceList) { XfDataVo xfDataVo = new XfDataVo(); xfDataVo.setDeviceName(xfDevice.get("deviceName").toString()); @@ -812,6 +811,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (xfData != null) { BeanUtils.copyProperties(xfData, xfDataVo); xfDataVo.setDataUpdateTime(xfData.getDataTimestamp()); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, xfDeviceId, DeviceCategory.XF.getCode()); xfDataVo.setAlarmNum(alarmNum); } xfDataVo.setEmsCommunicationStatus(xfDevice.get("communicationStatus") == null ? "" : xfDevice.get("communicationStatus").toString()); @@ -825,8 +826,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List emsDataList = new ArrayList<>(); List> xfDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.EMS.getCode()); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.EMS.getCode()); + for (Map emsDevice : xfDeviceList) { EmsDataVo emsDataVo = new EmsDataVo(); emsDataVo.setDeviceName(emsDevice.get("deviceName").toString()); @@ -835,6 +835,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { EmsEmsData emsData = redisCache.getCacheObject(RedisKeyConstants.EMS + siteId + "_" + emsDeviceId); if (emsData != null) { BeanUtils.copyProperties(emsData, emsDataVo); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, emsDeviceId, DeviceCategory.EMS.getCode()); emsDataVo.setAlarmNum(alarmNum); } emsDataList.add(emsDataVo); -- 2.49.0 From d387612b07fad8c69db63faf3be89872d3821da9 Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 15 Dec 2025 10:55:40 +0800 Subject: [PATCH 243/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E8=AE=BE=E5=A4=87=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=91=8A=E8=AD=A6=E7=82=B9=E4=BD=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/common/enums/SiteDevice.java | 5 +++ .../xzzn/ems/mapper/EmsPointMatchMapper.java | 2 +- .../impl/DeviceDataProcessServiceImpl.java | 2 +- .../service/impl/SingleSiteServiceImpl.java | 34 ++++++++++--------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java b/ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java index 508213f..958f06a 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/SiteDevice.java @@ -50,6 +50,11 @@ public enum SiteDevice */ DH, + /** + * 消防 + */ + XF, + /** * 中水冷却 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java index 2e08d80..47a6c9d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointMatchMapper.java @@ -169,7 +169,7 @@ public interface EmsPointMatchMapper List selectEmsPointMatchExportList(EmsPointMatch emsPointMatch); - int getDevicePointAlarmNum(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); + int getDevicePointAlarmNum(@Param("siteId") String siteId, @Param("deviceId") String deviceId, @Param("deviceCategory") String deviceCategory); EmsPointMatch selectDeviceStatusPoint(@Param("request") DeviceUpdateRequest request); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index cf4cde7..5e11f20 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -179,7 +179,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i || deviceId.contains(SiteDevice.METE.name()) || deviceId.contains(SiteDevice.METE0.name())) { meteDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains("XF")) { + } else if (deviceId.contains(SiteDevice.XF.name())) { meteXFProcess(siteId, deviceId, jsonData, dataUpdateTime); } else if (deviceId.contains(SiteDevice.DH.name()) || deviceId.contains(SiteDevice.donghuan.name())) { dhDataProcess(siteId, deviceId, jsonData, dataUpdateTime); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index c81b63c..81cc6ee 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -415,8 +415,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List pcsDetailInfoVoList = new ArrayList<>(); if (!StringUtils.isEmpty(siteId)) { - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.PCS.getCode()); // 获取该设备下所有pcs的id List> pcsIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.PCS.getCode()); @@ -437,6 +435,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { pcsDetailInfoVo.setPcsBranchInfoList(pcsBranchInfoList); // // 报警个数 // int alarmNum = emsAlarmRecordsMapper.getDeviceAlarmNum(siteId,pcsId); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, pcsId, DeviceCategory.PCS.getCode()); pcsDetailInfoVo.setAlarmNum(alarmNum); pcsDetailInfoVo.setDeviceStatus(pcsDevice.get("deviceStatus") == null ? "" : pcsDevice.get("deviceStatus").toString()); @@ -464,8 +464,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getBMSOverView(String siteId) { List bmsOverViewVoList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.STACK.getCode()); // 获取所有电池堆 if (!StringUtils.isEmpty(siteId)) { List> stackIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.STACK.getCode()); @@ -484,6 +482,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { batteryDataLists = getBMSClusterListInfo(siteId,stackId,null); bmsOverViewVo.setBatteryDataList(batteryDataLists); } + + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, stackId, DeviceCategory.STACK.getCode()); bmsOverViewVo.setAlarmNum(alarmNum); bmsOverViewVoList.add(bmsOverViewVo); } @@ -523,8 +524,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getBMSBatteryCluster(String siteId) { List bmsBatteryClusterVoList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.CLUSTER.getCode()); if (!StringUtils.isEmpty(siteId)) { // 获取所有设备下的电池簇id List> clusterIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.CLUSTER.getCode()); @@ -543,6 +542,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { dealWithBatteryClusterData(clusterData,clusterDataList); bmsBatteryClusterVo.setBatteryDataList(clusterDataList); } + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, clusterId, DeviceCategory.CLUSTER.getCode()); bmsBatteryClusterVo.setAlarmNum(alarmNum); bmsBatteryClusterVoList.add(bmsBatteryClusterVo); } @@ -585,8 +586,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getCoolingDataList(String siteId) { List emsCoolingDataList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.COOLING.getCode()); List> deviceIds = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.COOLING.getCode()); for (Map deviceId : deviceIds) { CoolingDataViewVo dataViewVo = new CoolingDataViewVo(); @@ -596,6 +595,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { EmsCoolingData coolingData = redisCache.getCacheObject(RedisKeyConstants.COOLING + siteId + "_" + coolingId); if (coolingData != null) { BeanUtils.copyProperties(coolingData, dataViewVo); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, coolingId, DeviceCategory.COOLING.getCode()); dataViewVo.setAlarmNum(alarmNum); } @@ -678,8 +679,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (ammeterIdList == null || ammeterIdList.isEmpty()) { return ammeterResponse; } - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.AMMETER.getCode()); for (Map ammeterDevice : ammeterIdList) { String ammeterId = ammeterDevice.get("id").toString(); if (!ammeterDeviceIds.contains(ammeterId)) { @@ -687,6 +686,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } // 从redis取总表详细数据 EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, ammeterId, DeviceCategory.AMMETER.getCode()); AmmeterDataVo ammeterDataVo = new AmmeterDataVo(); ammeterDataVo.setDeviceName(ammeterDevice.get("deviceName").toString()); @@ -773,8 +774,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { public List getDhDataList(String siteId) { List emsDhDataList = new ArrayList<>(); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.DH.getCode()); List> dhDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.DH.getCode()); for (Map dhDevice : dhDeviceList) { DhDataVo dhDataVo = new DhDataVo(); @@ -785,6 +784,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (dhData != null) { BeanUtils.copyProperties(dhData, dhDataVo); } + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, dhDeviceId, DeviceCategory.DH.getCode()); dhDataVo.setAlarmNum(alarmNum); emsDhDataList.add(dhDataVo); } @@ -801,8 +802,6 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List emsXfDataList = new ArrayList<>(); List> xfDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.XF.getCode()); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.XF.getCode()); for (Map xfDevice : xfDeviceList) { XfDataVo xfDataVo = new XfDataVo(); xfDataVo.setDeviceName(xfDevice.get("deviceName").toString()); @@ -812,6 +811,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { if (xfData != null) { BeanUtils.copyProperties(xfData, xfDataVo); xfDataVo.setDataUpdateTime(xfData.getDataTimestamp()); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, xfDeviceId, DeviceCategory.XF.getCode()); xfDataVo.setAlarmNum(alarmNum); } xfDataVo.setEmsCommunicationStatus(xfDevice.get("communicationStatus") == null ? "" : xfDevice.get("communicationStatus").toString()); @@ -825,8 +826,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { List emsDataList = new ArrayList<>(); List> xfDeviceList = emsDevicesSettingMapper.getDeviceInfosBySiteIdAndCategory(siteId, DeviceCategory.EMS.getCode()); - // 告警设备个数 - int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, DeviceCategory.EMS.getCode()); + for (Map emsDevice : xfDeviceList) { EmsDataVo emsDataVo = new EmsDataVo(); emsDataVo.setDeviceName(emsDevice.get("deviceName").toString()); @@ -835,6 +835,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { EmsEmsData emsData = redisCache.getCacheObject(RedisKeyConstants.EMS + siteId + "_" + emsDeviceId); if (emsData != null) { BeanUtils.copyProperties(emsData, emsDataVo); + // 告警设备点位个数 + int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, emsDeviceId, DeviceCategory.EMS.getCode()); emsDataVo.setAlarmNum(alarmNum); } emsDataList.add(emsDataVo); -- 2.49.0 From 3611e444da86f79d79ff722d6779a80f6f436e11 Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 15 Dec 2025 11:07:14 +0800 Subject: [PATCH 244/336] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=84=8F=E8=A7=8120251120-=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=A2=9E=E5=8A=A0=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=B1=BB=E5=9E=8B=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/ems/EmsSiteConfigController.java | 7 ++++--- .../java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java | 2 +- .../java/com/xzzn/ems/service/IEmsSiteService.java | 2 +- .../com/xzzn/ems/service/impl/EmsSiteServiceImpl.java | 10 +++++----- .../main/resources/mapper/ems/EmsSiteSettingMapper.xml | 3 +++ 5 files changed, 14 insertions(+), 10 deletions(-) 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 41ec25b..b0bf2a4 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 @@ -54,10 +54,11 @@ public class EmsSiteConfigController extends BaseController{ * 获取设备列表-分页 */ @GetMapping("/getDeviceInfoList") - public TableDataInfo getDeviceInfoList(@RequestParam String siteId) + public TableDataInfo getDeviceInfoList(@RequestParam String siteId, + @RequestParam String deviceCategory) { startPage(); - List list = iEmsSiteService.getAllDeviceList(siteId); + List list = iEmsSiteService.getAllDeviceList(siteId, deviceCategory); return getDataTable(list); } @@ -76,7 +77,7 @@ public class EmsSiteConfigController extends BaseController{ @GetMapping("/getDeviceList") public AjaxResult getDeviceInfoList2(@RequestParam String siteId) { - return success(iEmsSiteService.getAllDeviceList(siteId)); + return success(iEmsSiteService.getAllDeviceList(siteId, null)); } /** diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java index f29e394..931ff3d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java @@ -89,7 +89,7 @@ public interface EmsSiteSettingMapper * 获取站点的设备列表 * @return */ - public List getAllSiteDeviceList(String siteId); + public List getAllSiteDeviceList(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); public List getAllSiteId(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index 11c8cda..ed853ac 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -25,7 +25,7 @@ public interface IEmsSiteService public List getAllSiteInfoList(String siteName, String startTime, String endTime); - public List getAllDeviceList(String siteId); + public List getAllDeviceList(String siteId, String deviceCategory); public List> getAllPcsInfo(String siteId); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index 9819c8c..ea6ccde 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -80,20 +80,20 @@ public class EmsSiteServiceImpl implements IEmsSiteService * @return */ @Override - public List getAllDeviceList(String siteId) { - List resultData = emsSiteMapper.getAllSiteDeviceList(siteId); + public List getAllDeviceList(String siteId, String deviceCategory) { + List resultData = emsSiteMapper.getAllSiteDeviceList(siteId, deviceCategory); if(resultData == null || resultData.size() == 0){ return resultData; } for (SiteDeviceListVo siteDeviceListVo : resultData) { String clusterId = siteDeviceListVo.getDeviceId(); - String deviceCategory = siteDeviceListVo.getDeviceCategory(); - if(DeviceCategory.CLUSTER.getCode().equals(deviceCategory)){ + String category = siteDeviceListVo.getDeviceCategory(); + if(DeviceCategory.CLUSTER.getCode().equals(category)){ // 获取该stack下面有多少单体电池 List batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); siteDeviceListVo.setBatteryNum(batteryDataList == null ? 0 : batteryDataList.size()); } - String categoryName = DeviceCategory.getInfoByCode(deviceCategory); + String categoryName = DeviceCategory.getInfoByCode(category); siteDeviceListVo.setCategoryName(categoryName); } return resultData; diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index 1d1d2ad..e2c5fd3 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -146,6 +146,9 @@ and es.site_id = #{siteId} + + and ed.device_category = #{deviceCategory} + @@ -45,6 +46,7 @@ and device_id = #{deviceId} and cluster_device_id = #{clusterDeviceId} and inter_resistance = #{interResistance} + and current = #{current} and day_time = #{dayTime} @@ -74,6 +76,7 @@ device_id, cluster_device_id, inter_resistance, + current, day_time, @@ -118,6 +121,7 @@ device_id = #{deviceId}, cluster_device_id = #{clusterDeviceId}, inter_resistance = #{interResistance}, + current = #{current}, day_time = #{dayTime}, where id = #{id} @@ -164,6 +168,7 @@ device_id, cluster_device_id, inter_resistance, + current, day_time ) VALUES @@ -184,6 +189,7 @@ #{item.deviceId}, #{item.clusterDeviceId}, #{item.interResistance}, + #{item.current}, #{item.dayTime} ) @@ -195,6 +201,7 @@ soc = IF(VALUES(temperature) > temperature, VALUES(soc), soc), soh = IF(VALUES(temperature) > temperature, VALUES(soh), soh), inter_resistance = IF(VALUES(temperature) > temperature, VALUES(inter_resistance), inter_resistance), + current = IF(VALUES(temperature) > temperature, VALUES(current), current), update_by = IF(VALUES(temperature) > temperature, VALUES(update_by), update_by), temperature = IF(VALUES(temperature) > temperature, VALUES(temperature), temperature) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 1d064cb..228acc2 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -64,10 +64,22 @@ + + + + - select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, remark, site_id, device_id, date_month, date_day, total_ac_charge_energy, total_ac_discharge_energy, ac_charge_active_power, ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, remote_control_status, sys_u_current, sys_v_current, sys_w_current, dw_frequency, u_temperature, v_temperature, w_temperature, module1_temp, module2_temp, module3_temp, module4_temp from ems_pcs_data + select id, data_update_time, work_status, grid_status, device_status, control_mode, total_active_power, daily_ac_charge_energy, + a_phase_voltage, a_phase_current, total_reactive_power, daily_ac_discharge_energy, b_phase_voltage, b_phase_current, + total_apparent_power, pcs_module_temperature, c_phase_voltage, c_phase_current, total_power_factor, pcs_environment_temperature, + ac_frequency, branch_status, discharge_status, dc_power, dc_voltage, dc_current, create_by, create_time, update_by, update_time, + remark, site_id, device_id, date_month, date_day, total_ac_charge_energy, total_ac_discharge_energy, ac_charge_active_power, + ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, + max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, + remote_control_status, sys_u_current, sys_v_current, sys_w_current, dw_frequency, u_temperature, v_temperature, w_temperature, + module1_temp, module2_temp, module3_temp, module4_temp, cluster1_active_power, cluster2_active_power, cluster3_active_power, cluster4_active_power from ems_pcs_data @@ -195,6 +211,10 @@ module2_temp, module3_temp, module4_temp, + cluster1_active_power, + cluster2_active_power, + cluster3_active_power, + cluster4_active_power, #{dataUpdateTime}, @@ -255,6 +275,10 @@ #{module2Temp}, #{module3Temp}, #{module4Temp}, + #{cluster1ActivePower}, + #{cluster2ActivePower}, + #{cluster3ActivePower}, + #{cluster4ActivePower}, @@ -319,6 +343,10 @@ module2_temp = #{module2Temp}, module3_temp = #{module3Temp}, module4_temp = #{module4Temp}, + cluster1_active_power = #{cluster1ActivePower}, + cluster2_active_power = #{cluster2ActivePower}, + cluster3_active_power = #{cluster3ActivePower}, + cluster4_active_power = #{cluster4ActivePower}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 682d2ad..a620dcc 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -541,12 +541,15 @@ and device_id = #{deviceId} and device_category = #{deviceCategory} - where site_id = #{request.siteId} and device_id = #{request.deviceId} and device_category = #{request.deviceCategory} - and match_field = 'device_status' + and match_field in + + #{matchField} + \ No newline at end of file diff --git a/pom.xml b/pom.xml index ad983de..5679ee0 100644 --- a/pom.xml +++ b/pom.xml @@ -171,6 +171,12 @@ j2mod 3.1.0 + + + com.infiniteautomation + modbus4j + 3.0.3 + io.github.resilience4j -- 2.49.0 From 245b3e22d6cfa359cf27a642341519047bf4e1a1 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 19 Dec 2025 11:50:11 +0800 Subject: [PATCH 250/336] =?UTF-8?q?PCS=E5=BC=80=E5=85=B3=E6=9C=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E9=80=9A=E8=BF=87modbus=E8=BF=9E=E6=8E=A5=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=8F=91=E9=80=81=E6=8E=A7=E5=88=B6=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/modbus/ModbusProcessor.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java index 3153a44..c504a23 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java +++ b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -70,15 +71,7 @@ public class ModbusProcessor { tags.forEach(tag -> { Map type = ModBusType.REGISTER_TYPE; int firstDigit = Integer.parseInt(tag.getAddress().substring(0, 1)); - int address = 0; - int addressLength = tag.getAddress().length(); - int exp = (int) Math.pow(10, addressLength-1); - if (firstDigit != 0){ - int digit = Integer.parseInt(tag.getAddress()); - address = digit % (exp); - }else { - address = Integer.parseInt(tag.getAddress()); - } + int address = convertAddress(tag.getAddress()); RegisterType registerType = type.get(firstDigit); logger.info("Register type: {}, address: {}, firstDigit: {}", registerType, tag.getAddress(), firstDigit); switch (registerType) { @@ -381,4 +374,19 @@ public class ModbusProcessor { ); } + /** 转换寄存器地址 */ + public static int convertAddress(String address) { + if (StringUtils.isBlank(address)) { + return 0; + } + int firstDigit = Integer.parseInt(address.substring(0, 1)); + int addressLength = address.length(); + int exp = (int) Math.pow(10, addressLength-1); + if (firstDigit != 0){ + int digit = Integer.parseInt(address); + return digit % (exp); + } else { + return Integer.parseInt(address); + } + } } -- 2.49.0 From 2cd40404311cbf1604489e5b1fcf3b389d5685a5 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 19 Dec 2025 15:04:04 +0800 Subject: [PATCH 251/336] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E9=9D=A2=E5=88=86=E9=A1=B5=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=AF=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ems/EmsSiteSettingMapper.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index e2c5fd3..6aa3e12 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -149,6 +149,7 @@ and ed.device_category = #{deviceCategory} + order by ed.device_id @@ -79,6 +82,9 @@ remark, is_alarm, device_id, + a, + k, + b, #{pointName}, @@ -101,6 +107,9 @@ #{remark}, #{isAlarm}, #{deviceId}, + #{a}, + #{k}, + #{b}, @@ -127,6 +136,9 @@ remark = #{remark}, is_alarm = #{isAlarm}, device_id = #{deviceId}, + a = #{a}, + k = #{k}, + b = #{b}, where id = #{id} @@ -522,7 +534,8 @@ data_point_name as dataPointName, data_unit as dataUnit, is_alarm as isAlarm, - ip_address as ipAddress + ip_address as ipAddress, + a, k, b from ems_point_match -- 2.49.0 From 944adf35035baef7d04b003db31b2ac8f1337a5f Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 09:50:27 +0800 Subject: [PATCH 254/336] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=91=E4=B8=8A-?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SingleSiteServiceImpl.java | 51 +++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index ed28195..bce963c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -7,24 +7,55 @@ import com.xzzn.common.enums.DeviceCategory; import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.EmsAmmeterData; +import com.xzzn.ems.domain.EmsBatteryCluster; +import com.xzzn.ems.domain.EmsBatteryData; +import com.xzzn.ems.domain.EmsBatteryStack; +import com.xzzn.ems.domain.EmsCoolingData; +import com.xzzn.ems.domain.EmsDhData; +import com.xzzn.ems.domain.EmsEmsData; +import com.xzzn.ems.domain.EmsPcsBranchData; +import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.domain.EmsXfData; import com.xzzn.ems.domain.vo.*; -import com.xzzn.ems.mapper.*; +import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; +import com.xzzn.ems.mapper.EmsAmmeterDataMapper; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; +import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; +import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper; +import com.xzzn.ems.mapper.EmsPcsDataMapper; +import com.xzzn.ems.mapper.EmsPointMatchMapper; +import com.xzzn.ems.mapper.EmsStrategyRunningMapper; +import com.xzzn.ems.mapper.EmsStrategyTempMapper; import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import com.xzzn.ems.service.ISingleSiteService; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + /** * 单点监控 服务层实现 */ @@ -920,9 +951,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { BigDecimal pvPower = powerStat != null ? powerStat.getPvPower() : BigDecimal.ZERO; BigDecimal storagePower = powerStat != null ? powerStat.getStoragePower() : BigDecimal.ZERO; BigDecimal gridPower = powerStat != null ? powerStat.getGridPower() : BigDecimal.ZERO; - BigDecimal avgSoh = stackStat != null ? stackStat.getAvgSoh().setScale(2,RoundingMode.HALF_UP) : BigDecimal.ZERO; - BigDecimal avgSoc = stackStat != null ? stackStat.getAvgSoc().setScale(2,RoundingMode.HALF_UP) : BigDecimal.ZERO; - BigDecimal avgTemp = stackStat != null ? stackStat.getAvgTemp().setScale(2,RoundingMode.HALF_UP) : BigDecimal.ZERO; + BigDecimal avgSoh = stackStat != null ? (stackStat.getAvgSoh() == null ? BigDecimal.ZERO : stackStat.getAvgSoh().setScale(2,RoundingMode.HALF_UP)) : BigDecimal.ZERO; + BigDecimal avgSoc = stackStat != null ? (stackStat.getAvgSoc() == null ? BigDecimal.ZERO : stackStat.getAvgSoc().setScale(2,RoundingMode.HALF_UP)) : BigDecimal.ZERO; + BigDecimal avgTemp = stackStat != null ? (stackStat.getAvgTemp() == null ? BigDecimal.ZERO : stackStat.getAvgTemp().setScale(2,RoundingMode.HALF_UP)) : BigDecimal.ZERO; // 假设完整构造参数(补充原代码中缺失的部分) return new PointDataResponse(date, pvPower, storagePower, BigDecimal.ZERO, gridPower, avgSoh, avgSoc, avgTemp); -- 2.49.0 From 21fe3af17ce4b16ec3b2ba0fc7ee808df11ca5b2 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 13:34:44 +0800 Subject: [PATCH 255/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E6=A6=82=E7=8E=87=E7=BB=9F=E8=AE=A1=EF=BC=9A=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=8C=89=E7=85=A7=E7=94=B5=E5=8A=A8=E6=89=80=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BB=8E=E5=82=A8=E8=83=BD=E7=94=B5=E8=A1=A8METE?= =?UTF-8?q?=E4=B8=AD=E5=8F=96=EF=BC=8C=E4=BB=8A=E6=97=A5=E6=80=BB=E6=95=B0?= =?UTF-8?q?=E6=8D=AE-=E6=98=A8=E6=97=A5=E6=80=BB=E6=95=B0=E6=8D=AE=3D?= =?UTF-8?q?=E4=BB=8A=E6=97=A5=E5=85=85=E6=94=BE=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDataProcessServiceImpl.java | 60 +++++++++++++++++-- .../impl/EmsStatsReportServiceImpl.java | 54 ++++++++++++----- 2 files changed, 93 insertions(+), 21 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 95e6ab3..5811a01 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -784,10 +784,10 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); // emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); - if (SiteEnum.FX.getCode().equals(siteId)) { - //更新每日充放电数据 - dealFXXDailyChargeDate(siteId, deviceId, pcsData); - } +// if (SiteEnum.FX.getCode().equals(siteId)) { +// //更新每日充放电数据 +// dealFXXDailyChargeDate(siteId, deviceId, pcsData); +// } } private void pcsBranchDataProcess(String siteId, String deviceId, String dataJson) { @@ -999,12 +999,15 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i redisCache.setCacheObject(RedisKeyConstants.AMMETER + siteId + "_" + deviceId, dataMete); - // 处理电表每日充放电数据 if (!deviceId.contains(SiteDevice.METEGF.name()) && !deviceId.contains(SiteDevice.METE0.name())) { + // 处理储能电表-METE每日充放电数据 + EmsAmmeterData yestData = dealDailyChargeDate(siteId, deviceId, dataMete); + + // 处理储能电表-METE每日数据(尖、峰、平、谷差值) if (SiteEnum.FX.getCode().equals(siteId)) { dealAmmeterDailyDate(siteId, dataMete, dataUpdateTime, lastAmmeterData); } else if (SiteEnum.DDS.getCode().equals(siteId)) { - dealDDSDailyChargeDate(siteId, dataMete, deviceId); + dealDailyEnergyData(siteId, dataMete, yestData); } } } @@ -1084,6 +1087,51 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i return emsDailyChargeData; } + private void dealDailyEnergyData(String siteId, EmsAmmeterData currentData, EmsAmmeterData yestData) { + // 初始化数据-尖峰平谷 + EmsDailyEnergyData energyData = initEnergyData(siteId); + // 计算尖峰平谷差值,更新表 + calcEnergyDiffAndRevenue(siteId, energyData, currentData, yestData); + energyData.setCalcTime(DateUtils.getNowDate()); + // 插入或更新电表每日差值数据表 + emsDailyEnergyDataMapper.insertOrUpdateData(energyData); + } + private EmsAmmeterData dealDailyChargeDate(String siteId, String deviceId, EmsAmmeterData currentData) { + // 初始化今日充放电 + BigDecimal dailyDisChargeDate = new BigDecimal(0); + BigDecimal dailyChargeDate = new BigDecimal(0); + + BigDecimal nowTotalDisChargeDate = currentData.getCurrentReverseActiveTotal(); + BigDecimal nowTotalChargeDate = currentData.getCurrentForwardActiveTotal(); + // 初始化当日数据-总的 + EmsDailyChargeData emsDailyChargeData = initDailyChargeData(siteId, deviceId, nowTotalChargeDate, nowTotalDisChargeDate); + // 获取redis存放昨日最晚数据 + String yestDate = DateUtils.getYesterdayDate(); + String yestDateRedisKey = RedisKeyConstants.AMMETER + siteId + "_" + deviceId + "_" + yestDate; + EmsAmmeterData yestData = redisCache.getCacheObject(yestDateRedisKey); + if (yestData == null) { + // redis没有这查电表总数据表取截止到昨日最新第一条数据 + yestData = emsAmmeterDataMapper.getYestLatestDate(siteId, deviceId, yestDate); + // 数据存redis-有效期1天 + redisCache.setCacheObject(yestDateRedisKey, yestData, Constants.DATE_VALID_TIME, TimeUnit.DAYS); + } + if (yestData != null) { + // 今日总数据-昨日总数据=今日充放电 + BigDecimal yestTotalDisChargeDate = yestData.getCurrentReverseActiveTotal(); + BigDecimal yestTotalChargeDate = yestData.getCurrentForwardActiveTotal(); + + dailyChargeDate = nowTotalChargeDate.subtract(yestTotalChargeDate); + dailyDisChargeDate = nowTotalDisChargeDate.subtract(yestTotalDisChargeDate); + emsDailyChargeData.setChargeData(dailyChargeDate); + emsDailyChargeData.setDischargeData(dailyDisChargeDate); + } + + // 插入或更新每日充放电数据表 + emsDailyChargeDataMapper.insertOrUpdateData(emsDailyChargeData); + + return yestData; + } + private void calcEnergyDiffAndRevenue(String siteId, EmsDailyEnergyData energyData, EmsAmmeterData currentData, EmsAmmeterData yestData) { // 获取当月电价 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 3393ada..0b6b5f3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -4,27 +4,51 @@ import com.xzzn.common.enums.CostType; import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsAmmeterData; -import com.xzzn.ems.domain.EmsEnergyPriceConfig; -import com.xzzn.ems.domain.vo.*; -import com.xzzn.ems.mapper.*; +import com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo; +import com.xzzn.ems.domain.vo.AmmeterStatisListVo; +import com.xzzn.ems.domain.vo.BatteryDataStatsListVo; +import com.xzzn.ems.domain.vo.ClusterStatisListVo; +import com.xzzn.ems.domain.vo.DateSearchRequest; +import com.xzzn.ems.domain.vo.ElectricDataInfoVo; +import com.xzzn.ems.domain.vo.EnergyPriceConfigVo; +import com.xzzn.ems.domain.vo.PCSCurveResponse; +import com.xzzn.ems.domain.vo.PcsStatisListVo; +import com.xzzn.ems.domain.vo.PowerStatisListVo; +import com.xzzn.ems.domain.vo.SiteMonitorDataVo; +import com.xzzn.ems.domain.vo.StackCurveResponse; +import com.xzzn.ems.domain.vo.StackStatisListVo; +import com.xzzn.ems.domain.vo.StatisAmmeterDateRequest; +import com.xzzn.ems.domain.vo.StatisClusterDateRequest; +import com.xzzn.ems.mapper.EmsAmmeterDataMapper; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; +import com.xzzn.ems.mapper.EmsBatteryDataDayMapper; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; +import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; +import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper; +import com.xzzn.ems.mapper.EmsPcsDataMapper; import com.xzzn.ems.service.IEmsStatsReportService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceUtils; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; -import java.util.*; -import java.util.function.Function; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + /** * 统计报表数据Service业务层处理 * @@ -88,13 +112,13 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService // 开始日期和结束日期同一天,展示 0-24 小时数据 if (DateUtils.isSameDay(startDate, endDate)){ electricDataInfoVo.setUnit("时"); - if ("021_DDS_01".equals(siteId)) { +// if ("021_DDS_01".equals(siteId)) { deviceId = "METE"; dataList = emsAmmeterDataMapper.getChargeDataByHour(siteId,deviceId,startDate); - } else if ("021_FXX_01".equals(siteId)) { - endDate = DateUtils.addDays(endDate, 1); - dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate); - } +// } else if ("021_FXX_01".equals(siteId)) { +// endDate = DateUtils.addDays(endDate, 1); +// dataList = emsPcsDataMapper.getPcsDataByHour(requestVo.getSiteId(), startDate, endDate); +// } } else if (DateUtils.differentDaysByMillisecond(endDate, startDate) >= 1 && DateUtils.differentDaysByMillisecond(endDate, startDate) < 30){ electricDataInfoVo.setUnit("日"); -- 2.49.0 From 289fbc4d3ae64ade21c6d2eb6cd958610882daed Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 14:09:17 +0800 Subject: [PATCH 256/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E5=8A=9F=E7=8E=87=E6=9B=B2=E7=BA=BF=EF=BC=9A=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E5=82=A8=E8=83=BD=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=8F=96=E5=80=BC=E5=AD=97=E6=AE=B5secondary=5Ftotal=5Factive?= =?UTF-8?q?=5Fpower=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=96total=5Factive=5Fpo?= =?UTF-8?q?wer=EF=BC=9B=E8=B4=9F=E8=8D=B7=E5=8A=9F=E7=8E=87=3D=E7=94=B5?= =?UTF-8?q?=E7=BD=91=E5=8A=9F=E7=8E=87+=E5=85=89=E4=BC=8F=E5=8A=9F?= =?UTF-8?q?=E7=8E=87-=E5=82=A8=E8=83=BD=E5=8A=9F=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/vo/PointDataResponse.java | 2 +- .../xzzn/ems/domain/vo/PowerStatisListVo.java | 2 +- .../impl/EmsStatsReportServiceImpl.java | 21 +++++++++++-------- .../mapper/ems/EmsAmmeterDataMapper.xml | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java index d8ca59d..392117b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PointDataResponse.java @@ -12,7 +12,7 @@ public class PointDataResponse{ private BigDecimal gridPower; /** 负载功率 */ private BigDecimal loadPower; - /** 储能功率-secondary_total_active_power(METE) */ + /** 储能功率-total_active_power(METE) */ private BigDecimal storagePower; /** 光伏功率-total_active_power(METEGT) */ private BigDecimal pvPower; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java index 5bd7671..f7a6b1c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/PowerStatisListVo.java @@ -22,7 +22,7 @@ public class PowerStatisListVo { private BigDecimal loadPower; /** - * 储能功率-secondary_total_active_power(METE) + * 储能功率-total_active_power(METE) */ private BigDecimal storagePower; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 0b6b5f3..2cf1a3e 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -577,15 +577,18 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService BigDecimal pvPower = powerStatisListVo.getPvPower() == null ? BigDecimal.ZERO : powerStatisListVo.getPvPower(); BigDecimal loadPower = new BigDecimal(0); - // 电动所:负荷功率=电网功率+光伏功率-储能功率 - if (SiteEnum.DDS.getCode().equals(siteId)){ - loadPower = gridPower.add(pvPower).subtract(storagePower); - powerStatisListVo.setLoadPower(loadPower); - } else if (SiteEnum.FX.getCode().equals(siteId)){ - // 奉贤:负荷功率=电网功率-储能功率; - loadPower = gridPower.subtract(storagePower); - powerStatisListVo.setLoadPower(loadPower); - } + // 负荷功率=电网功率+光伏功率-储能功率 + loadPower = gridPower.add(pvPower).subtract(storagePower); + powerStatisListVo.setLoadPower(loadPower); +// // 电动所:负荷功率=电网功率+光伏功率-储能功率 +// if (SiteEnum.DDS.getCode().equals(siteId)){ +// loadPower = gridPower.add(pvPower).subtract(storagePower); +// powerStatisListVo.setLoadPower(loadPower); +// } else if (SiteEnum.FX.getCode().equals(siteId)){ +// // 奉贤:负荷功率=电网功率-储能功率; +// loadPower = gridPower.subtract(storagePower); +// powerStatisListVo.setLoadPower(loadPower); +// } } } diff --git a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml index f679965..8b1c6e8 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAmmeterDataMapper.xml @@ -977,7 +977,7 @@ - MAX(CASE WHEN t.device_id = 'METE' THEN t.secondary_total_active_power END) AS storagePower, + MAX(CASE WHEN t.device_id = 'METE' THEN t.total_active_power END) AS storagePower, MAX(CASE WHEN t.device_id = 'LOAD' THEN t.total_active_power END) AS gridPower, MAX(CASE WHEN t.device_id = 'METEGF' THEN t.total_active_power END) AS pvPower -- 2.49.0 From d0bab53dee28eb004e874f87927b0954420ee2b7 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 14:43:17 +0800 Subject: [PATCH 257/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E6=94=B6=E7=9B=8A=E6=8A=A5=E8=A1=A8=EF=BC=9A=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E7=94=B5=E8=A1=A8=E5=B0=96=E3=80=81?= =?UTF-8?q?=E5=B3=B0=E3=80=81=E5=B9=B3=E3=80=81=E8=B0=B7=E5=B7=AE=E5=80=BC?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E4=B9=98=E4=BB=A5=E5=AF=B9=E5=BA=94=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=94=B5=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/AmmeterStatisListVo.java | 18 +++--- .../impl/EmsStatsReportServiceImpl.java | 57 ++++++------------- 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java index 405e144..d53917c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/AmmeterStatisListVo.java @@ -11,7 +11,7 @@ public class AmmeterStatisListVo { /** 类别 */ private String dataTime; - private String timePart; +// private String timePart; /** 组合有功-总 (kWh) */ private BigDecimal activeTotalKwh = BigDecimal.ZERO; @@ -53,14 +53,14 @@ public class AmmeterStatisListVo { public void setDataTime(String dataTime) { this.dataTime = dataTime; } - - public String getTimePart() { - return timePart; - } - - public void setTimePart(String timePart) { - this.timePart = timePart; - } +// +// public String getTimePart() { +// return timePart; +// } +// +// public void setTimePart(String timePart) { +// this.timePart = timePart; +// } public BigDecimal getActiveTotalKwh() { return activeTotalKwh; diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 2cf1a3e..d190306 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -1,7 +1,6 @@ package com.xzzn.ems.service.impl; import com.xzzn.common.enums.CostType; -import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.utils.DateUtils; import com.xzzn.ems.domain.EmsAmmeterData; import com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo; @@ -345,65 +344,41 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Override public List getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) { String siteId = requestVo.getSiteId(); - String startTime = DateUtils.getDayBeginString(requestVo.getStartTime()); - String endTime = DateUtils.getDayEndString(requestVo.getEndTime()); List resultList = new ArrayList<>(); - List dataList = new ArrayList<>(); //查询电价配置 List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(siteId, requestVo.getStartTime(), requestVo.getEndTime()); if (CollectionUtils.isEmpty(priceConfigList)){ return Collections.emptyList(); } //查询电表数据 - if (SiteEnum.FX.getCode().equals(siteId)) { - dataList = emsAmmeterDataMapper.selectHourlyAmmeterData(siteId, startTime, endTime); - } else { - // 其他站点暂时默认与电动所内部一致处理,按天查询数据 - dataList = emsAmmeterDataMapper.selectDailyAmmeterData(siteId, startTime, endTime); - } + List dataList = this.getAmmeterDataResult(requestVo); if (CollectionUtils.isEmpty(dataList)) { return Collections.emptyList(); } Map> priceConfigMap = priceConfigList.stream().collect(Collectors.groupingBy(EnergyPriceConfigVo::getYearMonth)); - Map> ammeterMap = dataList.stream().collect(Collectors.groupingBy(AmmeterStatisListVo::getDataTime)); - List dateList = generateTargetDates(requestVo.getStartTime(), requestVo.getEndTime()); - dateList.forEach(date -> { - String dateTime = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); - List priceConfigs = priceConfigMap.get(dateTime.substring(0, 7)); - List ammeterStatisListVos = ammeterMap.get(dateTime); - resultList.add(calculateDailyBill(siteId, dateTime, ammeterStatisListVos, priceConfigs)); + dataList.forEach(ammeter -> { + List priceConfigs = priceConfigMap.get(ammeter.getDataTime().substring(0, 7)); + resultList.add(calculateDailyBill(ammeter, priceConfigs)); }); return resultList; } - public static AmmeterRevenueStatisListVo calculateDailyBill(String siteId, String dateTime, List ammeterList, List priceList) { + public static AmmeterRevenueStatisListVo calculateDailyBill(AmmeterStatisListVo ammeter, List priceList) { AmmeterRevenueStatisListVo ammeterRevenue = new AmmeterRevenueStatisListVo(); - ammeterRevenue.setDataTime(dateTime); - if (CollectionUtils.isEmpty(ammeterList) || CollectionUtils.isEmpty(priceList)) { + ammeterRevenue.setDataTime(ammeter.getDataTime()); + if (CollectionUtils.isEmpty(priceList)) { return ammeterRevenue; } - if (SiteEnum.FX.getCode().equals(siteId)) { - for (AmmeterStatisListVo ammeter : ammeterList) { - for (EnergyPriceConfigVo priceConfig : priceList) { - if (isInTimeRange(priceConfig.getStartTime(), priceConfig.getEndTime(), ammeter.getTimePart())) { - calculateByCostType(ammeter, priceConfig, ammeterRevenue); - } - } - } - } else { - // 其他站点暂时默认与电动所内部一致处理,按天计算逻辑 - AmmeterStatisListVo ammeter = ammeterList.get(0); - EnergyPriceConfigVo price = priceList.get(0); - ammeterRevenue.setActivePeakPrice(ammeter.getActivePeakKwh().multiply(price.getPeak())); - ammeterRevenue.setActiveHighPrice(ammeter.getActiveHighKwh().multiply(price.getHigh())); - ammeterRevenue.setActiveFlatPrice(ammeter.getActiveFlatKwh().multiply(price.getFlat())); - ammeterRevenue.setActiveValleyPrice(ammeter.getActiveValleyKwh().multiply(price.getValley())); - ammeterRevenue.setReActivePeakPrice(ammeter.getReActivePeakKwh().multiply(price.getPeak())); - ammeterRevenue.setReActiveHighPrice(ammeter.getReActiveHighKwh().multiply(price.getHigh())); - ammeterRevenue.setReActiveFlatPrice(ammeter.getReActiveFlatKwh().multiply(price.getFlat())); - ammeterRevenue.setReActiveValleyPrice(ammeter.getReActiveValleyKwh().multiply(price.getValley())); - } + EnergyPriceConfigVo price = priceList.get(0); + ammeterRevenue.setActivePeakPrice(ammeter.getActivePeakKwh().multiply(price.getPeak())); + ammeterRevenue.setActiveHighPrice(ammeter.getActiveHighKwh().multiply(price.getHigh())); + ammeterRevenue.setActiveFlatPrice(ammeter.getActiveFlatKwh().multiply(price.getFlat())); + ammeterRevenue.setActiveValleyPrice(ammeter.getActiveValleyKwh().multiply(price.getValley())); + ammeterRevenue.setReActivePeakPrice(ammeter.getReActivePeakKwh().multiply(price.getPeak())); + ammeterRevenue.setReActiveHighPrice(ammeter.getReActiveHighKwh().multiply(price.getHigh())); + ammeterRevenue.setReActiveFlatPrice(ammeter.getReActiveFlatKwh().multiply(price.getFlat())); + ammeterRevenue.setReActiveValleyPrice(ammeter.getReActiveValleyKwh().multiply(price.getValley())); ammeterRevenue.setActiveTotalPrice(ammeterRevenue.getActivePeakPrice().add(ammeterRevenue.getActiveHighPrice()).add(ammeterRevenue.getActiveFlatPrice()).add(ammeterRevenue.getActiveValleyPrice())); ammeterRevenue.setReActiveTotalPrice(ammeterRevenue.getReActivePeakPrice().add(ammeterRevenue.getReActiveHighPrice()).add(ammeterRevenue.getReActiveFlatPrice()).add(ammeterRevenue.getReActiveValleyPrice())); return ammeterRevenue; -- 2.49.0 From eb6f44dd936cf8f664128892aa10cfade5974baf Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 14:58:43 +0800 Subject: [PATCH 258/336] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=94=B6=E7=9B=8A?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=88=86=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/EmsStatsReportServiceImpl.java | 10 +++--- .../utils/DevicePointMatchDataProcessor.java | 31 +++++++------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index d190306..d0135aa 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -345,16 +345,16 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService public List getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) { String siteId = requestVo.getSiteId(); List resultList = new ArrayList<>(); - //查询电价配置 - List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(siteId, requestVo.getStartTime(), requestVo.getEndTime()); - if (CollectionUtils.isEmpty(priceConfigList)){ - return Collections.emptyList(); - } //查询电表数据 List dataList = this.getAmmeterDataResult(requestVo); if (CollectionUtils.isEmpty(dataList)) { return Collections.emptyList(); } + //查询电价配置 + List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(siteId, requestVo.getStartTime(), requestVo.getEndTime()); + if (CollectionUtils.isEmpty(priceConfigList)){ + return Collections.emptyList(); + } Map> priceConfigMap = priceConfigList.stream().collect(Collectors.groupingBy(EnergyPriceConfigVo::getYearMonth)); dataList.forEach(ammeter -> { List priceConfigs = priceConfigMap.get(ammeter.getDataTime().substring(0, 7)); diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java index 5fabd12..64aa1d2 100644 --- a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java +++ b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java @@ -1,14 +1,10 @@ package com.xzzn.ems.utils; -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; import com.xzzn.common.annotation.Excel; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; - import com.xzzn.common.enums.PointType; -import com.xzzn.common.utils.DataUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsPointEnumMatch; import com.xzzn.ems.domain.EmsPointMatch; @@ -27,13 +23,10 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; - import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @Service @@ -56,18 +49,18 @@ public class DevicePointMatchDataProcessor { /** * 初始化加载设备匹配点位配置数据 */ - @PostConstruct - public void init() - { - try { - ClassPathResource classPathResource = new ClassPathResource("biz/configData/DevicePointMatch.json"); - String configJson = DataUtils.getJSONFromFile(classPathResource.getInputStream()); - devicePointMatchInfo = JSONObject.parseObject(configJson, DevicePointMatchInfo.class); - log.info("初始化设备匹配点位配置数据成功。"+ JSON.toJSONString(devicePointMatchInfo)); - } catch (Exception ex) { - log.error("OcrMedicalStdHandler 设置mapping数据异常。", ex); - } - } +// @PostConstruct +// public void init() +// { +// try { +// ClassPathResource classPathResource = new ClassPathResource("biz/configData/DevicePointMatch.json"); +// String configJson = DataUtils.getJSONFromFile(classPathResource.getInputStream()); +// devicePointMatchInfo = JSONObject.parseObject(configJson, DevicePointMatchInfo.class); +// log.info("初始化设备匹配点位配置数据成功。"+ JSON.toJSONString(devicePointMatchInfo)); +// } catch (Exception ex) { +// log.error("OcrMedicalStdHandler 设置mapping数据异常。", ex); +// } +// } /** * 获取字段注解信息 -- 2.49.0 From 4f43b043ac4644aae5f46d49ffdb50eda3bec1b1 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 15:43:53 +0800 Subject: [PATCH 259/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E6=94=B6=E7=9B=8A=E6=8A=A5=E8=A1=A8=EF=BC=9A=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E7=94=B5=E8=A1=A8=E5=B0=96=E3=80=81?= =?UTF-8?q?=E5=B3=B0=E3=80=81=E5=B9=B3=E3=80=81=E8=B0=B7=E5=B7=AE=E5=80=BC?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E4=B9=98=E4=BB=A5=E5=AF=B9=E5=BA=94=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=94=B5=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/mapper/EmsDailyEnergyDataMapper.java | 8 +++-- .../impl/EmsStatsReportServiceImpl.java | 20 ++++------- .../mapper/ems/EmsDailyEnergyDataMapper.xml | 36 +++++++++++++++++++ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java index eeac437..536f73d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsDailyEnergyDataMapper.java @@ -1,11 +1,13 @@ package com.xzzn.ems.mapper; +import com.xzzn.ems.domain.EmsDailyEnergyData; +import com.xzzn.ems.domain.vo.AmmeterRevenueStatisListVo; +import com.xzzn.ems.domain.vo.AmmeterStatisListVo; + import java.math.BigDecimal; import java.util.List; import java.util.Map; -import com.xzzn.ems.domain.EmsDailyEnergyData; -import com.xzzn.ems.domain.vo.AmmeterStatisListVo; import org.apache.ibatis.annotations.Param; /** @@ -74,4 +76,6 @@ public interface EmsDailyEnergyDataMapper public BigDecimal getLastTotalRevenue(String siteId); // fx-获取实时总收益和当日实时收益 public Map getRealTimeRevenue(String siteId); + + public List getRevenueDataBySiteId(@Param("siteId") String siteId, @Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index d0135aa..dd071a3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -343,22 +343,14 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService @Override public List getAmmeterRevenueDataResult(StatisAmmeterDateRequest requestVo) { - String siteId = requestVo.getSiteId(); - List resultList = new ArrayList<>(); - //查询电表数据 - List dataList = this.getAmmeterDataResult(requestVo); - if (CollectionUtils.isEmpty(dataList)) { + List resultList = emsDailyEnergyDataMapper.getRevenueDataBySiteId(requestVo.getSiteId(),requestVo.getStartTime(),requestVo.getEndTime()); + if (CollectionUtils.isEmpty(resultList)) { return Collections.emptyList(); } - //查询电价配置 - List priceConfigList = emsEnergyPriceConfigMapper.getConfigListByTimeFrame(siteId, requestVo.getStartTime(), requestVo.getEndTime()); - if (CollectionUtils.isEmpty(priceConfigList)){ - return Collections.emptyList(); - } - Map> priceConfigMap = priceConfigList.stream().collect(Collectors.groupingBy(EnergyPriceConfigVo::getYearMonth)); - dataList.forEach(ammeter -> { - List priceConfigs = priceConfigMap.get(ammeter.getDataTime().substring(0, 7)); - resultList.add(calculateDailyBill(ammeter, priceConfigs)); + //计算每天总收益 + resultList.forEach(ammeterRevenue -> { + ammeterRevenue.setActiveTotalPrice(ammeterRevenue.getActivePeakPrice().add(ammeterRevenue.getActiveHighPrice()).add(ammeterRevenue.getActiveFlatPrice()).add(ammeterRevenue.getActiveValleyPrice())); + ammeterRevenue.setReActiveTotalPrice(ammeterRevenue.getReActivePeakPrice().add(ammeterRevenue.getReActiveHighPrice()).add(ammeterRevenue.getReActiveFlatPrice()).add(ammeterRevenue.getReActiveValleyPrice())); }); return resultList; diff --git a/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml index d7a1782..f33854f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDailyEnergyDataMapper.xml @@ -232,4 +232,40 @@ where t.site_id = #{siteId} order by t.data_date desc limit 1 + + \ No newline at end of file -- 2.49.0 From 90e9b004b4827df6ad6fb9a6f1d738bbe5a7e373 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 23 Dec 2025 16:12:04 +0800 Subject: [PATCH 260/336] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=8A=A5=E8=A1=A8-?= =?UTF-8?q?=E7=94=B5=E8=A1=A8=E6=8A=A5=E8=A1=A8=EF=BC=9A=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=9C=AC=E6=AC=A1=E4=B8=8E=E4=B8=8A=E6=AC=A1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=B7=AE=E5=80=BC=EF=BC=8C=E7=B4=AF=E5=8A=A0=E5=88=B0=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E5=B0=96?= =?UTF-8?q?=E3=80=81=E5=B3=B0=E3=80=81=E5=B9=B3=E3=80=81=E8=B0=B7=E9=87=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/service/impl/DeviceDataProcessServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 5811a01..044e02b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -1004,11 +1004,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i EmsAmmeterData yestData = dealDailyChargeDate(siteId, deviceId, dataMete); // 处理储能电表-METE每日数据(尖、峰、平、谷差值) - if (SiteEnum.FX.getCode().equals(siteId)) { +// if (SiteEnum.FX.getCode().equals(siteId)) { dealAmmeterDailyDate(siteId, dataMete, dataUpdateTime, lastAmmeterData); - } else if (SiteEnum.DDS.getCode().equals(siteId)) { - dealDailyEnergyData(siteId, dataMete, yestData); - } +// } else if (SiteEnum.DDS.getCode().equals(siteId)) { +// dealDailyEnergyData(siteId, dataMete, yestData); +// } } } -- 2.49.0 From 18ff0100b9a6af99741fd68ce0b1ab804b1d256c Mon Sep 17 00:00:00 2001 From: zq Date: Wed, 24 Dec 2025 16:19:04 +0800 Subject: [PATCH 261/336] =?UTF-8?q?modbus=E8=AF=BB=E5=8F=96=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E8=AE=BE=E5=A4=87=E6=95=B0=E6=8D=AE=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/RedisKeyConstants.java | 4 + .../common/core/modbus/ModbusProcessor.java | 18 ++- .../com/xzzn/quartz/task/ModbusPoller.java | 136 ++++++++++++------ .../java/com/xzzn/quartz/util/CronUtils.java | 21 +++ .../ems/service/IEmsAlarmRecordsService.java | 5 +- .../impl/DeviceDataProcessServiceImpl.java | 46 +++++- .../impl/EmsAlarmRecordsServiceImpl.java | 32 ++++- 7 files changed, 201 insertions(+), 61 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java index 6d124f9..82c0a75 100644 --- a/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java +++ b/ems-common/src/main/java/com/xzzn/common/constant/RedisKeyConstants.java @@ -96,6 +96,10 @@ public class RedisKeyConstants public static final String TOPIC_FAILED_ALRAM_RECORD = "topic_failed_"; /** topic 内没有数据设备维度告警 */ public static final String TOPIC_EMPTY_ALARM_RECORD = "topic_empty_"; + /** modbus读取 没有数据设备维度告警 */ + public static final String MODBUS_EMPTY_ALARM_RECORD = "modbus_empty_"; + /** modbus读取 设备离线告警 */ + public static final String MODBUS_OFFLINE_ALARM_RECORD = "modbus_offline_"; /** 设备信息初始化 */ public static final String INIT_DEVICE_INFO = "init_device_info"; diff --git a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java index f68610b..4cf3c4d 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java +++ b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java @@ -170,14 +170,20 @@ public class ModbusProcessor { } } + public ModbusMaster borrowMaster(DeviceConfig config) throws Exception { + ModbusMaster master = connectionManager.borrowMaster(config); + // 设置了Modbus通信的超时时间为3000毫秒(3秒)。当主设备与从设备通信时,若在3秒内未收到响应,则认为通信超时并抛出异常。这有助于避免长时间等待无响应的设备。 + master.setTimeout(5000); + return master; + } public Map readDataFromDevice(DeviceConfig config, ModbusMaster master) { Map deviceData = new HashMap<>(); // ModbusMaster master = null; // 将master的声明提前 try { - master = connectionManager.borrowMaster(config); +// master = connectionManager.borrowMaster(config); // 设置了Modbus通信的超时时间为3000毫秒(3秒)。当主设备与从设备通信时,若在3秒内未收到响应,则认为通信超时并抛出异常。这有助于避免长时间等待无响应的设备。 - master.setTimeout(5000); +// master.setTimeout(5000); BatchResults results = readTagValues(master, config.getSlaveId(), config.getTags()); for (TagConfig tag : config.getTags()) { if (Objects.equals(tag.getDataType(), "FOUR_BYTE_FLOAT_DBCA")){ @@ -199,7 +205,7 @@ public class ModbusProcessor { // } } } catch (Exception e) { - logger.error("Failed to borrow connection or read from devices '{}'", config.getDeviceName(), e); + logger.error("Failed read from devices '{}'", config.getDeviceName(), e); } finally { // 关键:无论成功与否,都必须将连接归还到池中 @@ -207,8 +213,8 @@ public class ModbusProcessor { connectionManager.returnMaster(config, master); } } - String deviceNumber = config.getDeviceNumber(); - redisCache.setCacheObject(deviceNumber, deviceData); +// String deviceNumber = config.getDeviceNumber(); +// redisCache.setCacheObject(deviceNumber, deviceData); return deviceData; } @@ -341,7 +347,7 @@ public class ModbusProcessor { } } return results; - }catch (Exception e){ + } catch (Exception e){ logger.error("Failed to read master '{}'", slaveId, e); throw new Exception(e); } diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java index 83d9abc..6e54173 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java @@ -8,12 +8,18 @@ import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.modbus.ModbusProcessor; import com.xzzn.common.core.modbus.domain.DeviceConfig; import com.xzzn.common.core.redis.RedisCache; +import com.xzzn.common.enums.DeviceRunningStatus; import com.xzzn.common.utils.DateUtils; +import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.impl.DeviceDataProcessServiceImpl; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.quartz.config.ScheduledTask; +import com.xzzn.quartz.domain.SysJob; +import com.xzzn.quartz.service.ISysJobService; +import com.xzzn.quartz.util.CronUtils; import java.io.IOException; import java.nio.file.Files; @@ -24,6 +30,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -44,14 +52,19 @@ public class ModbusPoller { private final MqttLifecycleManager mqttLifecycleManager; private final ScheduledTask scheduledTask; private final ObjectMapper objectMapper = new ObjectMapper(); + private final Map deviceFailureCounts = new ConcurrentHashMap<>(); @Autowired private ModbusProcessor modbusProcessor; @Autowired private IEmsAlarmRecordsService iEmsAlarmRecordsService; @Autowired + private ISysJobService iSysJobService; + @Autowired private DeviceDataProcessServiceImpl deviceDataProcessServiceImpl; @Autowired + private EmsDevicesSettingMapper emsDevicesSettingMapper; + @Autowired private RedisCache redisCache; @Autowired private MqttPublisher mqttPublisher; @@ -101,16 +114,17 @@ public class ModbusPoller { } } + int interval = getScheduledTaskInterval(); // 为每个 host:port 启动一个任务 for (Map.Entry> entry : groupedConfigs.entrySet()) { String groupKey = entry.getKey(); List configs = entry.getValue(); // 取其中一个配置的时间间隔作为该组任务的执行周期 - long interval = configs.get(0).getTime(); +// long interval = configs.get(0).getTime(); scheduledTask.startTask(groupKey, () -> { for (DeviceConfig config : configs) { try { - scheduledStart(config, null); + scheduledStart(config); } catch (Exception e) { log.error("采集设备数据异常: {}", config.getDeviceName(), e); } @@ -119,52 +133,72 @@ public class ModbusPoller { } } - public void scheduledStart(DeviceConfig config, ModbusMaster master) { - try { - if (config.isEnabled()) { - log.info("Reading data from devices: {}", config.getDeviceName()); - Map data = modbusProcessor.readDataFromDevice(config, master); - // 在这里处理采集到的数据 - config.getTags().forEach(tag -> { - Object rawValue = data.get(tag.getKey()); - if (rawValue != null) { - float value = 0; - if (rawValue instanceof Number) { - value = ((Number) rawValue).floatValue(); // 安全地转换为 float - } else { - log.error("tag:{},无法将数据转换为数字: {}", tag.getKey(), rawValue); - } - value = tag.getA() * value * value + tag.getK() * value + tag.getB(); - - int intValue = (int) value; - if (tag.getBit() != null) { - log.info("tag:{},bit:{},value:{}", tag.getKey(), tag.getBit(), value); - String binary = Integer.toBinaryString(intValue); - data.put(tag.getKey(), binary); - } else { - data.put(tag.getKey(), value); - } - } else { - data.put(tag.getKey(), rawValue); - log.warn("tag:{},数据为空: {}", tag.getKey(), rawValue); - } - }); - log.info("Data from {}: {}", config.getDeviceName(), data); - String deviceNumber = config.getDeviceNumber(); - //处理数据并发送MQTT消息、保存Redis数据和数据入库 - processingData(data, deviceNumber); + public void scheduledStart(DeviceConfig config) { + if (config.isEnabled()) { + log.info("Reading data from devices: {}", config.getDeviceName()); + ModbusMaster master = null; + try { + master = modbusProcessor.borrowMaster(config); + } catch (Exception e) { + log.error("Failed to borrow connection '{}'", config.getDeviceName(), e); + // 处理设备连接失败的情况,更新设备状态为离线,添加报警记录 + addDeviceOfflineRecord(siteId, config.getDeviceNumber()); + return; } - } catch (Exception e) { - log.error("设备数据采集异常: {}", config.getDeviceName(), e); + Map data = modbusProcessor.readDataFromDevice(config, master); + // 在这里处理采集到的数据 + config.getTags().forEach(tag -> { + Object rawValue = data.get(tag.getKey()); + if (rawValue != null) { + float value = 0; + if (rawValue instanceof Number) { + value = ((Number) rawValue).floatValue(); // 安全地转换为 float + } else { + log.error("tag:{},无法将数据转换为数字: {}", tag.getKey(), rawValue); + } + value = tag.getA() * value * value + tag.getK() * value + tag.getB(); + + int intValue = (int) value; + if (tag.getBit() != null) { + log.info("tag:{},bit:{},value:{}", tag.getKey(), tag.getBit(), value); + String binary = Integer.toBinaryString(intValue); + data.put(tag.getKey(), binary); + } else { + data.put(tag.getKey(), value); + } + } else { + data.put(tag.getKey(), rawValue); + log.warn("tag:{},数据为空: {}", tag.getKey(), rawValue); + } + }); + log.info("Data from {}: {}", config.getDeviceName(), data); + String deviceNumber = config.getDeviceNumber(); + //处理数据并发送MQTT消息、保存Redis数据和数据入库 + processingData(data, deviceNumber); } } private void processingData(Map data, String deviceNumber) { if (data == null || data.size() == 0) { - // 添加设备告警 - iEmsAlarmRecordsService.addEmptyDataAlarmRecord(siteId, deviceNumber); + // 增加失败计数 + int failureCount = deviceFailureCounts.getOrDefault(deviceNumber, 0) + 1; + deviceFailureCounts.put(deviceNumber, failureCount); + + log.warn("设备 {} 数据读取失败,当前连续失败次数: {}", deviceNumber, failureCount); + + // 连续6次失败触发报警 + if (failureCount >= 6) { + addDeviceOfflineRecord(siteId, deviceNumber); + log.error("设备 {} 连续 {} 次未读取到数据,触发报警", deviceNumber, failureCount); + } return; } + + // 数据读取成功,重置计数器 + deviceFailureCounts.remove(deviceNumber); + updateDeviceStatus(siteId, deviceNumber, DeviceRunningStatus.RUNNING.getCode()); + + // 发送MQTT消息、保存Redis数据和数据入库 Long timestamp = System.currentTimeMillis(); JSONObject json = new JSONObject(); json.put("Data", data); @@ -201,4 +235,26 @@ public class ModbusPoller { deviceDataProcessServiceImpl.processingDeviceData(siteId, deviceNumber, JSON.toJSONString(data), DateUtils.convertUpdateTime(timestamp)); } + //处理设备连接失败的情况,更新设备状态为离线,添加报警记录 + private void addDeviceOfflineRecord(String siteId, String deviceNumber) { + updateDeviceStatus(siteId, deviceNumber, DeviceRunningStatus.OFFLINE.getCode()); + iEmsAlarmRecordsService.addDeviceOfflineRecord(siteId, deviceNumber); + } + + // 更新设备状态为在线或离线 + private void updateDeviceStatus(String siteId, String deviceNumber, String deviceStatus) { + EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceNumber, siteId); + if (emsDevicesSetting != null && !Objects.equals(emsDevicesSetting.getDeviceStatus(), deviceStatus)) { + emsDevicesSetting.setDeviceStatus(deviceStatus); + emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); + } + } + + private int getScheduledTaskInterval() { + SysJob query = new SysJob(); + query.setInvokeTarget("modbusPoller.pollAllDevices"); + List sysJobs = iSysJobService.selectJobList(query); + return Math.toIntExact(CronUtils.getNextExecutionIntervalMillis(sysJobs.get(0).getCronExpression())); + } + } \ No newline at end of file diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/util/CronUtils.java b/ems-quartz/src/main/java/com/xzzn/quartz/util/CronUtils.java index 052ed37..10b7764 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/util/CronUtils.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/util/CronUtils.java @@ -60,4 +60,25 @@ public class CronUtils throw new IllegalArgumentException(e.getMessage()); } } + + /** + * 返回当前时间到下一次执行时间间隔的毫秒 + */ + public static long getNextExecutionIntervalMillis(String cronExpression) + { + try + { + CronExpression cron = new CronExpression(cronExpression); + Date now = new Date(); + Date nextExecution = cron.getNextValidTimeAfter(now); + Date nextExecution2 = cron.getNextValidTimeAfter(nextExecution); + + return nextExecution2.getTime() - nextExecution.getTime(); + } + catch (ParseException e) + { + throw new IllegalArgumentException(e.getMessage()); + } + } + } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java index 38e66bf..b178467 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsAlarmRecordsService.java @@ -1,10 +1,11 @@ package com.xzzn.ems.service; -import java.util.List; import com.xzzn.ems.domain.EmsAlarmRecords; import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; +import java.util.List; + /** * 告警记录Service接口 * @@ -98,4 +99,6 @@ public interface IEmsAlarmRecordsService // 处理本地端同步的保护策略告警信息 public void dealSyncData(String content, String operateType); + + public void addDeviceOfflineRecord(String siteId, String deviceNumber); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 044e02b..0b842c8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -31,7 +31,25 @@ import com.xzzn.ems.domain.*; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import com.xzzn.ems.domain.vo.EnergyPriceVo; import com.xzzn.ems.enums.DeviceMatchTable; -import com.xzzn.ems.mapper.*; +import com.xzzn.ems.mapper.EmsAmmeterDataMapper; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper; +import com.xzzn.ems.mapper.EmsBatteryGroupMapper; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; +import com.xzzn.ems.mapper.EmsClusterAlarmDataMapper; +import com.xzzn.ems.mapper.EmsCoolingAlarmDataMapper; +import com.xzzn.ems.mapper.EmsCoolingDataMapper; +import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; +import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsDhDataMapper; +import com.xzzn.ems.mapper.EmsEmsDataMapper; +import com.xzzn.ems.mapper.EmsPcsAlarmDataMapper; +import com.xzzn.ems.mapper.EmsPcsBranchDataMapper; +import com.xzzn.ems.mapper.EmsPcsDataMapper; +import com.xzzn.ems.mapper.EmsStackAlarmDataMapper; +import com.xzzn.ems.mapper.EmsXfDataMapper; import com.xzzn.ems.service.IDeviceDataProcessService; import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IEmsDeviceSettingService; @@ -557,21 +575,31 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } } + /** + * + * @param pointMatchList 字段匹配规则列表 + * @param obj 原始数据Map + * @param entity 目标Java对象 + * @param pointEnumMatchMap 枚举匹配规则 + */ private void saveDeviceData(List pointMatchList, Map obj, Object entity, Map> pointEnumMatchMap) { Map pointMatchMap = pointMatchList.stream() .collect(Collectors.toMap( - data -> StringUtils.toCamelCase(data.getMatchField()), - EmsPointMatch::getDataPoint, - (existing, replacement) -> replacement)); + data -> StringUtils.toCamelCase(data.getMatchField()), // 源字段名转为驼峰 + EmsPointMatch::getDataPoint, // 获取目标点位名 + (existing, replacement) -> replacement)); // 处理重复键 Field[] fields = entity.getClass().getDeclaredFields(); for (Field field : fields) { String fieldName = field.getName(); if (pointMatchMap.containsKey(fieldName)) { - field.setAccessible(true); + // 处理匹配的字段名,并设置值 + field.setAccessible(true); // 允许访问私有字段 try { + // 1. 从原始数据中获取匹配值 Object matchValue = obj.get(pointMatchMap.get(fieldName)); - //匹配枚举值转换 + + // 2. 处理枚举值转换 List pointEnumMatchList = pointEnumMatchMap.get(fieldName); if (CollectionUtils.isNotEmpty(pointEnumMatchList)) { Object finalMatchValue = matchValue; @@ -581,6 +609,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i matchValue = enumMatch.get().getEnumCode(); } } + + // 3. 类型转换 Class fieldType = field.getType(); if (String.class.equals(fieldType)) { matchValue = StringUtils.getString(matchValue); @@ -591,6 +621,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } else if (Integer.class.equals(fieldType)) { matchValue = MapUtils.getInteger(obj, pointMatchMap.get(fieldName)); } + + // 4. 设置字段值 field.set(entity, matchValue); } catch (IllegalAccessException e) { log.warn("deviceDataProcess 设置字段值时出错", e); @@ -1001,7 +1033,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i if (!deviceId.contains(SiteDevice.METEGF.name()) && !deviceId.contains(SiteDevice.METE0.name())) { // 处理储能电表-METE每日充放电数据 - EmsAmmeterData yestData = dealDailyChargeDate(siteId, deviceId, dataMete); + dealDailyChargeDate(siteId, deviceId, dataMete); // 处理储能电表-METE每日数据(尖、峰、平、谷差值) // if (SiteEnum.FX.getCode().equals(siteId)) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index 0d37974..4fcedad 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -1,9 +1,5 @@ package com.xzzn.ems.service.impl; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - import com.alibaba.fastjson2.JSON; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.domain.entity.SysUser; @@ -14,17 +10,26 @@ import com.xzzn.common.enums.TicketStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsAlarmMatchData; +import com.xzzn.ems.domain.EmsAlarmRecords; import com.xzzn.ems.domain.EmsTicket; import com.xzzn.ems.domain.vo.AlarmRecordListRequestVo; import com.xzzn.ems.domain.vo.AlarmRecordListResponseVo; import com.xzzn.ems.mapper.EmsAlarmMatchDataMapper; +import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; import com.xzzn.ems.mapper.EmsTicketMapper; +import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.system.mapper.SysUserMapper; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.xzzn.ems.mapper.EmsAlarmRecordsMapper; -import com.xzzn.ems.domain.EmsAlarmRecords; -import com.xzzn.ems.service.IEmsAlarmRecordsService; /** * 告警记录Service业务层处理 @@ -308,5 +313,18 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService } } + @Override + public void addDeviceOfflineRecord(String siteId, String deviceId) { + EmsAlarmRecords emsAlarmRecords = redisCache.getCacheObject(RedisKeyConstants.MODBUS_OFFLINE_ALARM_RECORD + siteId + "_" + deviceId); + if (emsAlarmRecords != null) { + return; + } + emsAlarmRecords = createAlarmAtPcs(siteId, deviceId,"modbus连接设备失败", AlarmLevelStatus.EMERGENCY.getCode()); + emsAlarmRecordsMapper.insertEmsAlarmRecords(emsAlarmRecords); + + // 存redis-防止重复插入-有效期一天 + redisCache.setCacheObject(RedisKeyConstants.MODBUS_OFFLINE_ALARM_RECORD + siteId + "_" + deviceId, emsAlarmRecords,1, TimeUnit.DAYS); + } + } -- 2.49.0 From 56613e8f7031a2a9ed5ed72115f749d2ab4e0b9e Mon Sep 17 00:00:00 2001 From: zq Date: Thu, 25 Dec 2025 11:42:06 +0800 Subject: [PATCH 262/336] =?UTF-8?q?=E6=96=B0=E5=A2=9EPCS=E7=82=B9=E4=BD=8D?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E9=85=8D=E7=BD=AE-=E7=94=B5=E6=B1=A0?= =?UTF-8?q?=E7=B0=87=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/xzzn/ems/domain/EmsPcsData.java | 13 +++++++++++++ .../main/resources/mapper/ems/EmsPcsDataMapper.xml | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index ae79973..1d7b7c7 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -236,6 +236,10 @@ public class EmsPcsData extends BaseEntity @Excel(name = "4#模块IGBT最高温") private BigDecimal module4Temp; + /** 电池簇数 */ + @Excel(name = "电池簇数") + private Integer clusterNum; + /** 电池簇1PCS有功功率给定 */ @Excel(name = "电池簇1PCS有功功率给定") private BigDecimal cluster1ActivePower; @@ -792,6 +796,14 @@ public class EmsPcsData extends BaseEntity return module4Temp; } + public Integer getClusterNum() { + return clusterNum; + } + + public void setClusterNum(Integer clusterNum) { + this.clusterNum = clusterNum; + } + public BigDecimal getCluster1ActivePower() { return cluster1ActivePower; } @@ -886,6 +898,7 @@ public class EmsPcsData extends BaseEntity .append("module2Temp", getModule2Temp()) .append("module3Temp", getModule3Temp()) .append("module4Temp", getModule4Temp()) + .append("clusterNum", getClusterNum()) .append("cluster1ActivePower", getCluster1ActivePower()) .append("cluster2ActivePower", getCluster2ActivePower()) .append("cluster3ActivePower", getCluster3ActivePower()) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 228acc2..0510453 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -64,6 +64,7 @@ + @@ -79,7 +80,7 @@ ac_capacitive_reactive_power, ac_discharge_active_power, ac_inductive_reactive_power, max_capacitive_power_capacity, max_inductive_power_capacity, max_charge_power_capacity, max_discharge_power_capacity, ac_switch_status, dc_switch_status, remote_control_status, sys_u_current, sys_v_current, sys_w_current, dw_frequency, u_temperature, v_temperature, w_temperature, - module1_temp, module2_temp, module3_temp, module4_temp, cluster1_active_power, cluster2_active_power, cluster3_active_power, cluster4_active_power from ems_pcs_data + module1_temp, module2_temp, module3_temp, module4_temp, cluster_num, cluster1_active_power, cluster2_active_power, cluster3_active_power, cluster4_active_power from ems_pcs_data
where template_id = #{templateId} + order by start_time, end_time @@ -147,6 +148,7 @@ \ No newline at end of file -- 2.49.0 From 22415df926ea9d555d172892ff7712e6cdb08bf5 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 26 Dec 2025 10:58:46 +0800 Subject: [PATCH 264/336] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=9C=AA=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=9A=84=E6=95=85=E9=9A=9C=E5=91=8A=E8=AD=A6=EF=BC=8C?= =?UTF-8?q?=E7=AB=99=E7=82=B9=E9=A6=96=E9=A1=B5=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E2=80=9C=E8=AE=BE=E5=A4=87=E5=91=8A=E8=AD=A6=E2=80=9D=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index f1913fc..dfaf614 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -127,6 +127,7 @@ t.id from ems_alarm_records t INNER JOIN ems_devices_setting t2 on t.site_id = t2.site_id and t.device_id = t2.device_id where t.site_id = #{siteId} + and t.status != 1 + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyLogMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyLogMapper.xml new file mode 100644 index 0000000..485d5d2 --- /dev/null +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyLogMapper.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select id, strategy_id, template_id, site_id, device_id, start_time, end_time, charge_discharge_power, charge_status, execution_date, anti_reverse, create_by, create_time, update_by, update_time, remark from ems_strategy_log + + + + + + + + insert into ems_strategy_log + + strategy_id, + template_id, + site_id, + device_id, + start_time, + end_time, + charge_discharge_power, + charge_status, + execution_date, + anti_reverse, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{strategyId}, + #{templateId}, + #{siteId}, + #{deviceId}, + #{startTime}, + #{endTime}, + #{chargeDischargePower}, + #{chargeStatus}, + #{executionDate}, + #{antiReverse}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update ems_strategy_log + + strategy_id = #{strategyId}, + template_id = #{templateId}, + site_id = #{siteId}, + device_id = #{deviceId}, + start_time = #{startTime}, + end_time = #{endTime}, + charge_discharge_power = #{chargeDischargePower}, + charge_status = #{chargeStatus}, + execution_date = #{executionDate}, + anti_reverse = #{antiReverse}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from ems_strategy_log where id = #{id} + + + + delete from ems_strategy_log where id in + + #{id} + + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml index 157f534..3138f41 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyTimeConfigMapper.xml @@ -134,4 +134,10 @@ and strategy_id = #{strategyId} and month = #{month} + + \ No newline at end of file -- 2.49.0 From bac66aaddb1cdb67693f5cdd6c8587ef8d6218a5 Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 29 Dec 2025 17:45:53 +0800 Subject: [PATCH 266/336] =?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 -- 2.49.0 From 93ed334c0ef60d22e2f1bd746f81843972488360 Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 29 Dec 2025 18:07:30 +0800 Subject: [PATCH 267/336] =?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 --- .../impl/EmsDeviceSettingServiceImpl.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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 a9d4153..e28a1fe 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 @@ -86,7 +86,9 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService DevicesSettingVo devicesSettingVo = new DevicesSettingVo(); BeanUtils.copyProperties(emsDevicesSetting, devicesSettingVo); EmsPcsSetting pcsSetting = emsPcsSettingMapper.selectEmsPcsSettingByDeviceId(id); - devicesSettingVo.setPcsSetting(pcsSetting); + if (pcsSetting != null) { + devicesSettingVo.setPcsSetting(pcsSetting); + } return devicesSettingVo; } @@ -102,11 +104,13 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService return -1; } devicesSetting.setCreateTime(DateUtils.getNowDate()); - int id = emsDevicesMapper.insertEmsDevicesSetting(devicesSetting); + int result = emsDevicesMapper.insertEmsDevicesSetting(devicesSetting); EmsPcsSetting pcsSetting = devicesSetting.getPcsSetting(); - pcsSetting.setDeviceSettingId(devicesSetting.getId()); - emsPcsSettingMapper.insertEmsPcsSetting(pcsSetting); - return id; + if (pcsSetting != null) { + pcsSetting.setDeviceSettingId(devicesSetting.getId()); + emsPcsSettingMapper.insertEmsPcsSetting(pcsSetting); + } + return result; } /** @@ -136,7 +140,11 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService return -2; } devicesSetting.setUpdateTime(DateUtils.getNowDate()); - emsPcsSettingMapper.updateEmsPcsSetting(devicesSetting.getPcsSetting()); + EmsPcsSetting pcsSetting = devicesSetting.getPcsSetting(); + if (pcsSetting != null) { + pcsSetting.setUpdateTime(DateUtils.getNowDate()); + emsPcsSettingMapper.updateEmsPcsSetting(pcsSetting); + } return emsDevicesMapper.updateEmsDevicesSetting(devicesSetting); } -- 2.49.0 From 2c9cc1f1d4ef8106691a18d00d5199ed15ff6dbc Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 30 Dec 2025 14:36:11 +0800 Subject: [PATCH 268/336] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E8=BD=AE=E8=AF=A2=E6=94=BE=E7=94=B5=E9=80=BB=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/quartz/task/StrategyPoller.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 a8cd2b2..e45022d 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 @@ -259,14 +259,15 @@ public class StrategyPoller { for (EmsPointMatch pointMatch : pointMatchList) { WriteTagConfig writeTag = new WriteTagConfig(); writeTag.setAddress(pointMatch.getIpAddress()); - if (ChargeStatus.CHARGING.equals(chargeStatus)) { - writeTag.setValue(chargeDischargePower); - } else if (ChargeStatus.DISCHARGING.equals(chargeStatus)) { - writeTag.setValue(chargeDischargePower.negate()); - } else { - // 待机状态-电池簇PCS有功功率给定置0 - writeTag.setValue(chargeDischargePower); - } +// if (ChargeStatus.CHARGING.equals(chargeStatus)) { +// writeTag.setValue(chargeDischargePower); +// } else if (ChargeStatus.DISCHARGING.equals(chargeStatus)) { +// writeTag.setValue(chargeDischargePower); +// } else { +// // 待机状态-电池簇PCS有功功率给定置0 +// writeTag.setValue(chargeDischargePower); +// } + writeTag.setValue(chargeDischargePower); writeTags.add(writeTag); } return writeTags; -- 2.49.0 From e381ff86c877f511eee2e6d63a661715a2f776a5 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 30 Dec 2025 15:06:42 +0800 Subject: [PATCH 269/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=9B=91=E6=8E=A7-?= =?UTF-8?q?=E6=9D=AD=E5=B7=9E=E6=B9=BE=E7=94=B5=E8=A1=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/SingleSiteServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index bce963c..24add30 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -715,9 +715,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { } for (Map ammeterDevice : ammeterIdList) { String ammeterId = ammeterDevice.get("id").toString(); - if (!ammeterDeviceIds.contains(ammeterId)) { - continue; - } +// if (!ammeterDeviceIds.contains(ammeterId)) { +// continue; +// } // 从redis取总表详细数据 EmsAmmeterData ammeterData = redisCache.getCacheObject(RedisKeyConstants.AMMETER + siteId + "_" +ammeterId); // 告警设备点位个数 -- 2.49.0 From 552d471fde57d83857aeda52522167310867dc0b Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 30 Dec 2025 15:25:59 +0800 Subject: [PATCH 270/336] =?UTF-8?q?=E7=AD=96=E7=95=A5=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aspectj/StrategyRunningSyncAspect.java | 15 +++++++---- .../aspectj/StrategyTempSyncAspect.java | 25 +++++++++++++------ .../aspectj/StrategyTimeConfigSyncAspect.java | 24 ++++++++++++------ 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyRunningSyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyRunningSyncAspect.java index 3892603..4beb204 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyRunningSyncAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyRunningSyncAspect.java @@ -10,18 +10,23 @@ import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; import com.xzzn.ems.mapper.EmsStrategyRunningMapper; import com.xzzn.ems.mapper.MqttSyncLogMapper; import com.xzzn.framework.web.service.MqttPublisher; -import org.apache.juli.logging.Log; -import org.apache.juli.logging.LogFactory; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cglib.beans.BeanMap; import org.springframework.stereotype.Component; -import java.util.*; - /** * 策略运行切面同步 * 云端 - 本地 @@ -30,7 +35,7 @@ import java.util.*; @Component public class StrategyRunningSyncAspect { - private static final Log logger = LogFactory.getLog(StrategyRunningSyncAspect.class); + private static final Logger logger = LoggerFactory.getLogger(StrategyRunningSyncAspect.class); @Autowired private MqttPublisher mqttPublisher; diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java index d12b416..3714352 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java @@ -4,23 +4,34 @@ import com.alibaba.fastjson2.JSON; import com.fasterxml.jackson.databind.ObjectMapper; import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanUtils; -import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.EmsStrategy; +import com.xzzn.ems.domain.EmsStrategyRunning; +import com.xzzn.ems.domain.EmsStrategyTemp; +import com.xzzn.ems.domain.MqttSyncLog; import com.xzzn.ems.domain.vo.SyncStrategyTempVo; -import com.xzzn.ems.mapper.*; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.mapper.EmsStrategyMapper; +import com.xzzn.ems.mapper.EmsStrategyTempMapper; +import com.xzzn.ems.mapper.MqttSyncLogMapper; import com.xzzn.framework.web.service.MqttPublisher; -import org.apache.juli.logging.Log; -import org.apache.juli.logging.LogFactory; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cglib.beans.BeanMap; import org.springframework.stereotype.Component; -import java.util.*; - /** * 策略模板数据同步 * 云端 - 本地 @@ -29,7 +40,7 @@ import java.util.*; @Component public class StrategyTempSyncAspect { - private static final Log logger = LogFactory.getLog(StrategyTempSyncAspect.class); + private static final Logger logger = LoggerFactory.getLogger(StrategyTempSyncAspect.class); @Autowired private MqttPublisher mqttPublisher; diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java index 69f7e26..988e8b3 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTimeConfigSyncAspect.java @@ -3,22 +3,32 @@ package com.xzzn.framework.aspectj; import com.fasterxml.jackson.databind.ObjectMapper; import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanUtils; -import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.EmsStrategy; +import com.xzzn.ems.domain.EmsStrategyRunning; +import com.xzzn.ems.domain.EmsStrategyTimeConfig; +import com.xzzn.ems.domain.MqttSyncLog; import com.xzzn.ems.domain.vo.SyncStrategyTimeConfigVo; -import com.xzzn.ems.mapper.*; +import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; +import com.xzzn.ems.mapper.EmsStrategyMapper; +import com.xzzn.ems.mapper.EmsStrategyTempMapper; +import com.xzzn.ems.mapper.MqttSyncLogMapper; import com.xzzn.framework.web.service.MqttPublisher; -import org.apache.juli.logging.Log; -import org.apache.juli.logging.LogFactory; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cglib.beans.BeanMap; import org.springframework.stereotype.Component; -import java.util.*; - /** * 策略时间配置同步 * 云端 - 本地 @@ -27,7 +37,7 @@ import java.util.*; @Component public class StrategyTimeConfigSyncAspect { - private static final Log logger = LogFactory.getLog(StrategyTimeConfigSyncAspect.class); + private static final Logger logger = LoggerFactory.getLogger(StrategyTimeConfigSyncAspect.class); @Autowired private MqttPublisher mqttPublisher; -- 2.49.0 From 041c41822eb4ac6f2c4c9ddf551bbdc1755eb306 Mon Sep 17 00:00:00 2001 From: zq Date: Sun, 4 Jan 2026 09:00:10 +0800 Subject: [PATCH 271/336] =?UTF-8?q?PCS=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/domain/EmsPcsSetting.java | 14 ++++++++- .../xzzn/ems/mapper/EmsPcsSettingMapper.java | 2 ++ .../impl/EmsDeviceSettingServiceImpl.java | 9 ++++-- .../mapper/ems/EmsPcsSettingMapper.xml | 29 ++++++++++++++++++- 4 files changed, 50 insertions(+), 4 deletions(-) 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 index 0ab722e..2327f61 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsSetting.java @@ -29,6 +29,10 @@ public class EmsPcsSetting extends BaseEntity @Excel(name = "开关机地址") private String pointAddress; + /** 功率地址 */ + @Excel(name = "功率地址") + private String powerAddress; + /** 开机指令 */ @Excel(name = "开机指令") private String startCommand; @@ -73,7 +77,15 @@ public class EmsPcsSetting extends BaseEntity return deviceSettingId; } - public void setPointAddress(String pointAddress) + public String getPowerAddress() { + return powerAddress; + } + + public void setPowerAddress(String powerAddress) { + this.powerAddress = powerAddress; + } + + public void setPointAddress(String pointAddress) { this.pointAddress = pointAddress; } 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 index c9e6cdc..71b0e44 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsSettingMapper.java @@ -63,4 +63,6 @@ public interface EmsPcsSettingMapper public int deleteEmsPcsSettingByIds(Long[] ids); EmsPcsSetting selectEmsPcsSettingByDeviceId(@Param("deviceSettingId") Long deviceSettingId); + + void updateByDeviceSettingId(EmsPcsSetting pcsSetting); } 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 e28a1fe..c287ce4 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 @@ -142,8 +142,13 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService devicesSetting.setUpdateTime(DateUtils.getNowDate()); EmsPcsSetting pcsSetting = devicesSetting.getPcsSetting(); if (pcsSetting != null) { - pcsSetting.setUpdateTime(DateUtils.getNowDate()); - emsPcsSettingMapper.updateEmsPcsSetting(pcsSetting); + if (pcsSetting.getDeviceSettingId() == null) { + pcsSetting.setDeviceSettingId(devicesSetting.getId()); + emsPcsSettingMapper.insertEmsPcsSetting(pcsSetting); + } else { + pcsSetting.setUpdateTime(DateUtils.getNowDate()); + emsPcsSettingMapper.updateByDeviceSettingId(pcsSetting); + } } return emsDevicesMapper.updateEmsDevicesSetting(devicesSetting); } diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml index 2c26e91..287ab57 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsSettingMapper.xml @@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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 + select id, device_setting_id, point_address, power_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 @@ -139,11 +134,6 @@ and module2_temp = #{module2Temp} and module3_temp = #{module3Temp} and module4_temp = #{module4Temp} - and cluster_num = #{clusterNum} - and cluster1_active_power = #{cluster1ActivePower} - and cluster2_active_power = #{cluster2ActivePower} - and cluster3_active_power = #{cluster3ActivePower} - and cluster4_active_power = #{cluster4ActivePower} @@ -213,11 +203,6 @@ module2_temp, module3_temp, module4_temp, - cluster_num, - cluster1_active_power, - cluster2_active_power, - cluster3_active_power, - cluster4_active_power, #{dataUpdateTime}, @@ -278,11 +263,6 @@ #{module2Temp}, #{module3Temp}, #{module4Temp}, - #{clusterNum}, - #{cluster1ActivePower}, - #{cluster2ActivePower}, - #{cluster3ActivePower}, - #{cluster4ActivePower}, @@ -347,11 +327,6 @@ module2_temp = #{module2Temp}, module3_temp = #{module3Temp}, module4_temp = #{module4Temp}, - cluster_num = #{clusterNum}, - cluster1_active_power = #{cluster1ActivePower}, - cluster2_active_power = #{cluster2ActivePower}, - cluster3_active_power = #{cluster3ActivePower}, - cluster4_active_power = #{cluster4ActivePower}, where id = #{id} @@ -655,20 +630,4 @@ group by deviceId,dateDay,createDate,temp order by dateDay,createDate - \ No newline at end of file -- 2.49.0 From 6ed7a25819bfe2b7a7c70df45f846ee53c87378d Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 5 Jan 2026 16:25:46 +0800 Subject: [PATCH 276/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=87=E9=9D=A2?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/framework/config/ApplicationConfig.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ems-framework/src/main/java/com/xzzn/framework/config/ApplicationConfig.java b/ems-framework/src/main/java/com/xzzn/framework/config/ApplicationConfig.java index 7202f41..5248c05 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/config/ApplicationConfig.java +++ b/ems-framework/src/main/java/com/xzzn/framework/config/ApplicationConfig.java @@ -13,8 +13,9 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; * @author xzzn */ @Configuration -// 表示通过aop框架暴露该代理对象,AopContext能够访问 -@EnableAspectJAutoProxy(exposeProxy = true) +// proxyTargetClass = true表示使用cglib代理,false表示jdk动态代理 +// exposeProxy = true表示通过aop框架暴露该代理对象,AopContext能够访问 +@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true) // 指定要扫描的Mapper类的包的路径 @MapperScan("com.xzzn.**.mapper") public class ApplicationConfig -- 2.49.0 From 873119a1fff4a3503f9da2da1ed6f26defea294c Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 6 Jan 2026 10:25:08 +0800 Subject: [PATCH 277/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=B8=8A=E9=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A7=A3=E6=9E=90=E5=88=A4=E6=96=AD=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDataProcessServiceImpl.java | 72 ++++++++++++------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 0b842c8..dc92587 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -140,8 +140,6 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i @Autowired private IEmsEnergyPriceConfigService emsEnergyPriceConfigService; @Autowired - private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; - @Autowired private IEmsDeviceSettingService iEmsDeviceSettingService; @Autowired private DevicePointMatchDataProcessor devicePointMatchDataProcessor; @@ -185,34 +183,56 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } public void processingDeviceData(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { + // 判断设备类型,并调用对应的方法处理数据 + String deviceCategory = getDeviceCategory(siteId, deviceId); if (deviceId.contains(SiteDevice.BMSD.name())) { batteryStackDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - batteryGroupDataProcess(siteId, deviceId, jsonData); - batteryDataProcessFromBmsd(siteId, deviceId, jsonData, dataUpdateTime); + if (SiteEnum.DDS.getCode().equals(siteId)) { + batteryGroupDataProcess(siteId, deviceId, jsonData); + batteryDataProcessFromBmsd(siteId, deviceId, jsonData, dataUpdateTime); + } } else if (deviceId.contains(SiteDevice.BMSC.name())) { batteryClusterDataProcess(siteId, deviceId, jsonData, dataUpdateTime); batteryDataProcessFromBmsc(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.PCS.name())) { + } else if (deviceId.contains(SiteDevice.PCS.name()) + || DeviceCategory.PCS.getCode().equals(deviceCategory)) { pcsDataProcess(siteId, deviceId, jsonData, dataUpdateTime); pcsBranchDataProcess(siteId, deviceId, jsonData); - batteryClusterDataProcess(siteId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.LOAD.name())) { - loadDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.METEGF.name()) + if (SiteEnum.DDS.getCode().equals(siteId)) { + batteryClusterDataProcess(siteId, jsonData, dataUpdateTime); + } + } else if (deviceId.contains(SiteDevice.LOAD.name()) + || deviceId.contains(SiteDevice.METEGF.name()) || deviceId.contains(SiteDevice.METE.name()) - || deviceId.contains(SiteDevice.METE0.name())) { + || deviceId.contains(SiteDevice.METE0.name()) + || DeviceCategory.AMMETER.getCode().equals(deviceCategory)) { meteDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.XF.name())) { + } else if (deviceId.contains(SiteDevice.XF.name()) + || DeviceCategory.XF.getCode().equals(deviceCategory)) { meteXFProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.DH.name()) || deviceId.contains(SiteDevice.donghuan.name())) { + } else if (deviceId.contains(SiteDevice.DH.name()) + || deviceId.contains(SiteDevice.donghuan.name()) + || DeviceCategory.DH.getCode().equals(deviceCategory)) { dhDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.ZSLQ.name())) { + } else if (deviceId.contains(SiteDevice.ZSLQ.name()) + || DeviceCategory.COOLING.getCode().equals(deviceCategory)) { coolingDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.EMS.name())) { + } else if (deviceId.contains(SiteDevice.EMS.name()) + || DeviceCategory.EMS.getCode().equals(deviceCategory)) { emsDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else { + log.info("未找到匹配的设备类型,无法处理数据,siteId: " + siteId + ",deviceId: " + deviceId); } } + private String getDeviceCategory(String siteId, String deviceId) { + EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); + if (emsDevicesSetting != null) { + return emsDevicesSetting.getDeviceCategory(); + } + return ""; + } + private void emsDataProcess(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { //EMS Map obj = JSON.parseObject(jsonData, new TypeReference>() { @@ -379,9 +399,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } private void batteryGroupDataProcess(String siteId, String deviceId, String jsonData) { - if (!SiteEnum.DDS.getCode().equals(siteId)) { - return; - } +// if (!SiteEnum.DDS.getCode().equals(siteId)) { +// return; +// } //电池组 Map obj = JSON.parseObject(jsonData, new TypeReference>() { }); @@ -420,9 +440,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } private void batteryDataProcessFromBmsd(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { - if (!SiteEnum.DDS.getCode().equals(siteId)) { - return; - } +// if (!SiteEnum.DDS.getCode().equals(siteId)) { +// return; +// } //电池组 Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); @@ -896,9 +916,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } private void batteryClusterDataProcess(String siteId, String dataJson, Date dataUpdateTime) { - if (!SiteEnum.DDS.getCode().equals(siteId)) { - return; - } +// if (!SiteEnum.DDS.getCode().equals(siteId)) { +// return; +// } Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); @@ -1006,7 +1026,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 点位匹配数据 List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.AMMETER.getCode()); if (CollectionUtils.isEmpty(pointMatchList)) { - log.info("未找到匹配的点位数据,无法处理METE储能电表数据,siteId: " + siteId + ",deviceId: " + deviceId); + log.info("未找到匹配的点位数据,无法处理电表数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.AMMETER.getCode()); @@ -1031,7 +1051,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i redisCache.setCacheObject(RedisKeyConstants.AMMETER + siteId + "_" + deviceId, dataMete); - if (!deviceId.contains(SiteDevice.METEGF.name()) && !deviceId.contains(SiteDevice.METE0.name())) { + if (deviceId.equals(SiteDevice.METE.name())) { // 处理储能电表-METE每日充放电数据 dealDailyChargeDate(siteId, deviceId, dataMete); @@ -1390,7 +1410,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i Map realTimeRevenue = redisCache.getCacheObject(redisKey); if (realTimeRevenue == null) { // 查数据库 - realTimeRevenue = iEmsEnergyPriceConfigService.getDayRevenueMap(siteId); + realTimeRevenue = emsEnergyPriceConfigService.getDayRevenueMap(siteId); if (realTimeRevenue == null) { realTimeRevenue = new HashMap<>(); realTimeRevenue.put("totalRevenue", BigDecimal.ZERO); -- 2.49.0 From 4f3cd8c82b2d15ffea600c4f763380fd1cc0f367 Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 6 Jan 2026 10:26:39 +0800 Subject: [PATCH 278/336] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=BC=80=E5=A7=8B=E5=92=8C=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E8=A7=A3=E6=9E=90=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/EmsStrategyTempServiceImpl.java | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index 11703b6..d7a806f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -1,8 +1,5 @@ package com.xzzn.ems.service.impl; -import java.util.List; -import java.util.Map; - import com.alibaba.fastjson2.JSON; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; @@ -12,19 +9,27 @@ import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.common.utils.bean.BeanUtils; import com.xzzn.ems.domain.EmsStrategy; -import com.xzzn.ems.domain.EmsStrategyRunning; +import com.xzzn.ems.domain.EmsStrategyTemp; import com.xzzn.ems.domain.EmsStrategyTempTimeConfig; -import com.xzzn.ems.domain.vo.StrategyRunningVo; import com.xzzn.ems.domain.vo.StrategyTempConfigRequest; import com.xzzn.ems.domain.vo.SyncStrategyTempVo; import com.xzzn.ems.mapper.EmsStrategyCurveMapper; import com.xzzn.ems.mapper.EmsStrategyMapper; +import com.xzzn.ems.mapper.EmsStrategyTempMapper; import com.xzzn.ems.mapper.EmsStrategyTimeConfigMapper; +import com.xzzn.ems.service.IEmsStrategyTempService; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.List; +import java.util.Map; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.xzzn.ems.mapper.EmsStrategyTempMapper; -import com.xzzn.ems.domain.EmsStrategyTemp; -import com.xzzn.ems.service.IEmsStrategyTempService; import org.springframework.transaction.annotation.Transactional; /** @@ -147,6 +152,8 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService switch (operateType) { case "INSERT": SyncStrategyTempVo syncVo = JSON.parseObject(content, SyncStrategyTempVo.class); + //转换开始和结束时间 + convertStringToDate(content, syncVo); BeanUtils.copyProperties(syncVo, temp); // 先校验策略是否存在,不存在则插入 dealStrategyData(temp, syncVo); @@ -165,6 +172,26 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService } } + private void convertStringToDate(String content, SyncStrategyTempVo syncVo) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode rootNode = mapper.readTree(content); + String startTime = rootNode.path("startTime").asText(); + String endTime = rootNode.path("endTime").asText(); + if (startTime != null && !"null".equals(startTime)) { + syncVo.setStartTime(parseTimeStringToDate(startTime)); + } + if (endTime != null && !"null".equals(endTime)) { + syncVo.setEndTime(parseTimeStringToDate(endTime)); + } + } + + private Date parseTimeStringToDate(String timeStr) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime time = LocalTime.parse(timeStr, formatter); + LocalDateTime dateTime = LocalDateTime.of(LocalDate.now(), time); + return Date.from(dateTime.atZone(ZoneId.of("Asia/Shanghai")).toInstant()); + } + private void dealStrategyData(EmsStrategyTemp temp, SyncStrategyTempVo syncVo) { // 主策略 String mainStrategyName = syncVo.getStrategyName(); -- 2.49.0 From a4ac11e7d984288c253b0e951698412145cd83aa Mon Sep 17 00:00:00 2001 From: zq Date: Tue, 6 Jan 2026 11:27:20 +0800 Subject: [PATCH 279/336] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=AF=B9=E5=92=8C?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/framework/aspectj/StrategyTempSyncAspect.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java index 3714352..88ab79d 100644 --- a/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java +++ b/ems-framework/src/main/java/com/xzzn/framework/aspectj/StrategyTempSyncAspect.java @@ -58,7 +58,7 @@ public class StrategyTempSyncAspect { // 用ThreadLocal暂存删除前的对象 private ThreadLocal beforeDeleteThreadLocal = new ThreadLocal<>(); - @Before("execution(* com.xzzn.ems.mapper.EmsStrategyTempMapper.deleteEmsStrategyTempById(..)) && args(templateId)") + @Before("execution(* com.xzzn.ems.mapper.EmsStrategyTempMapper.deleteTempByTempId(..)) && args(templateId)") public void beforeDelete(JoinPoint joinPoint, String templateId) { // 查询删除前的数据-仅存一获取siteId List tempList = emsStrategyTempMapper.selectStrategyTempByTempId(templateId); @@ -67,7 +67,7 @@ public class StrategyTempSyncAspect { } } - @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyTempMapper.deleteEmsStrategyTempById(..)) && args(templateId)) ") + @Pointcut("(execution(* com.xzzn.ems.mapper.EmsStrategyTempMapper.deleteTempByTempId(..)) && args(templateId)) ") public void deletePointCut(String templateId) { logger.info("【删除策略模版切面】StrategyTempSyncAspect 被实例化"); } @@ -105,7 +105,7 @@ public class StrategyTempSyncAspect { } // 数据转换 SyncStrategyTempVo tempVo = convertEntity(insertEntity); - String content = objectMapper.writeValueAsString(tempVo); + String content = JSON.toJSONString(tempVo); message.setContent(content); // 发布到MQTT主题 -- 2.49.0 From 77a3b6e855b7550170dc7434a524be9213a0162f Mon Sep 17 00:00:00 2001 From: zq Date: Wed, 7 Jan 2026 11:27:02 +0800 Subject: [PATCH 280/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=92=8C=E5=B7=A5=E4=BD=9C=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8F=96=E5=80=BC=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 3 + .../common/core/modbus/ModbusProcessor.java | 3 +- .../common/enums/DeviceRunningStatus.java | 19 +----- .../com/xzzn/common/enums/WorkStatus.java | 2 +- .../com/xzzn/quartz/task/ModbusPoller.java | 2 +- .../xzzn/ems/domain/EmsBatteryCluster.java | 13 ++-- .../com/xzzn/ems/domain/EmsBatteryStack.java | 11 ++-- .../xzzn/ems/domain/EmsDevicesSetting.java | 10 +-- .../java/com/xzzn/ems/domain/EmsPcsData.java | 8 +-- .../ems/domain/vo/DeviceUpdateRequest.java | 13 ++-- .../impl/DDSDataProcessServiceImpl.java | 59 +++++++++++++---- .../impl/DeviceDataProcessServiceImpl.java | 11 ++-- .../impl/EmsDeviceSettingServiceImpl.java | 23 ++----- .../impl/EmsStrategyTempServiceImpl.java | 3 +- .../impl/FXXDataProcessServiceImpl.java | 65 ++++++++++++++----- 15 files changed, 147 insertions(+), 98 deletions(-) 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 342ad9e..8eb0b08 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 @@ -1,9 +1,11 @@ package com.xzzn.web.controller.ems; +import com.xzzn.common.annotation.Log; import com.xzzn.common.config.RuoYiConfig; import com.xzzn.common.core.controller.BaseController; import com.xzzn.common.core.domain.AjaxResult; import com.xzzn.common.core.page.TableDataInfo; +import com.xzzn.common.enums.BusinessType; import com.xzzn.common.utils.file.FileUploadUtils; import com.xzzn.common.utils.file.MimeTypeUtils; import com.xzzn.ems.domain.EmsSiteSetting; @@ -192,6 +194,7 @@ public class EmsSiteConfigController extends BaseController{ /** * PCS设备开关机 */ + @Log(title = "开关机", businessType = BusinessType.UPDATE) @PostMapping("/updateDeviceStatus") public AjaxResult updateDeviceStatus(@Valid @RequestBody DeviceUpdateRequest request) { diff --git a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java index 4cf3c4d..18d1378 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java +++ b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java @@ -80,7 +80,8 @@ public class ModbusProcessor { break; } case HOLDING_REGISTER: { - writeRegisterRequest(master, config.getSlaveId(), address, Integer.parseInt(String.valueOf(tag.getValue()))); + double doubleValue = Double.parseDouble(String.valueOf(tag.getValue())); + writeRegisterRequest(master, config.getSlaveId(), address, (int) doubleValue); break; } default: diff --git a/ems-common/src/main/java/com/xzzn/common/enums/DeviceRunningStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/DeviceRunningStatus.java index aa91496..299bcf1 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/DeviceRunningStatus.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/DeviceRunningStatus.java @@ -1,8 +1,5 @@ package com.xzzn.common.enums; -import java.util.Arrays; -import java.util.List; - /** * device-通信状态 * @@ -11,10 +8,7 @@ import java.util.List; public enum DeviceRunningStatus { OFFLINE("0", "离线"), - STANDBY("1", "待机") , - RUNNING("2", "运行"), - FAULT("3", "故障"), - SHUTDOWN("4", "停机"); + ONLINE("1", "在线"); private final String code; private final String info; @@ -35,15 +29,4 @@ public enum DeviceRunningStatus return info; } - /** 停机状态 */ - public static List getShutdownCodeList() - { - return Arrays.asList(SHUTDOWN.getCode()); - } - - /** 运行状态 */ - public static List getRunningCodeList() - { - return Arrays.asList(STANDBY.getCode(), RUNNING.getCode(), FAULT.getCode()); - } } diff --git a/ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java b/ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java index e16999f..155d915 100644 --- a/ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java +++ b/ems-common/src/main/java/com/xzzn/common/enums/WorkStatus.java @@ -7,7 +7,7 @@ package com.xzzn.common.enums; */ public enum WorkStatus { - NORMAL("0", "正常"), ABNORMAL("1", "异常"), STOP("2", "停止"); + NORMAL("0", "运行"), STOP("1", "停机"), ABNORMAL("2", "故障"); private final String code; private final String info; diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java index 6e54173..e534010 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java @@ -196,7 +196,7 @@ public class ModbusPoller { // 数据读取成功,重置计数器 deviceFailureCounts.remove(deviceNumber); - updateDeviceStatus(siteId, deviceNumber, DeviceRunningStatus.RUNNING.getCode()); + updateDeviceStatus(siteId, deviceNumber, DeviceRunningStatus.ONLINE.getCode()); // 发送MQTT消息、保存Redis数据和数据入库 Long timestamp = System.currentTimeMillis(); diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java index 2bc12c1..5ebe921 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryCluster.java @@ -1,14 +1,15 @@ package com.xzzn.ems.domain; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xzzn.common.annotation.Excel; +import com.xzzn.common.core.domain.BaseEntity; +import com.xzzn.common.utils.StringUtils; + import java.math.BigDecimal; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.xzzn.common.core.domain.BaseEntity; -import com.xzzn.common.utils.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.xzzn.common.annotation.Excel; /** * 电池簇数据对象 ems_battery_cluster @@ -28,8 +29,8 @@ public class EmsBatteryCluster extends BaseEntity @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date dataUpdateTime; - /** 工作状态:0-正常 1-异常 2-停止 */ - @Excel(name = "工作状态:0-正常 1-异常 2-停止") + /** 工作状态:0-运行 1-停机 2-故障 */ + @Excel(name = "工作状态:0-运行 1-停机 2-故障") private String workStatus; /** 与PCS通信状态:0-正常 1-通信中断 2-异常 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java index 3240398..c15d912 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsBatteryStack.java @@ -1,13 +1,14 @@ package com.xzzn.ems.domain; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xzzn.common.annotation.Excel; +import com.xzzn.common.core.domain.BaseEntity; + import java.math.BigDecimal; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; -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_battery_stack @@ -27,8 +28,8 @@ public class EmsBatteryStack extends BaseEntity @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date dataUpdateTime; - /** 工作状态:0-正常 1-异常 2-停止 */ - @Excel(name = "工作状态:0-正常 1-异常 2-停止") + /** 工作状态:0-运行 1-停机 2-故障 */ + @Excel(name = "工作状态:0-运行 1-停机 2-故障") private String workStatus; /** 与PCS通信状态:0-正常 1-通信中断 2-异常 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java index 13a9d98..17641c8 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java @@ -1,11 +1,13 @@ package com.xzzn.ems.domain; -import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +import com.xzzn.common.annotation.Excel; import com.xzzn.common.core.domain.BaseEntity; + +import java.util.Date; + import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.xzzn.common.annotation.Excel; /** * Modbus设备配置对象 ems_devices_setting @@ -102,8 +104,8 @@ public class EmsDevicesSetting extends BaseEntity @Excel(name = "设备类别,例如“STACK/CLUSTER/PCS等”") private String deviceCategory; - /** 设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ - @Excel(name = "设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机") + /** 设备运行状态:0-离线、1-在线 */ + @Excel(name = "设备运行状态:0-离线、1-在线") private String deviceStatus; /** 设备图像地址 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java index 0b654e0..bd39327 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsPcsData.java @@ -28,16 +28,16 @@ public class EmsPcsData extends BaseEntity @Excel(name = "数据更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date dataUpdateTime; - /** 工作状态:0-正常 1-异常 2-停止 */ - @Excel(name = "工作状态:0-正常 1-异常 2-停止") + /** 工作状态:0-运行 1-停机 2-故障 */ + @Excel(name = "工作状态:0-运行 1-停机 2-故障") private String workStatus; /** 并网状态:0-并网 1-未并网 */ @Excel(name = "并网状态:0-并网 1-未并网") private String gridStatus; - /** 设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ - @Excel(name = "设备运行状态:0-离线、1-待机、2-运行、3-故障、4-停机") + /** 设备运行状态:0-离线、1-在线 */ + @Excel(name = "设备运行状态:0-离线、1-在线") private String deviceStatus; /** 控制模式:0-远程 1-本地 */ diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java index 4e9ed94..24f582f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/DeviceUpdateRequest.java @@ -16,8 +16,9 @@ public class DeviceUpdateRequest { @NotBlank(message = "设备ID不能为空") private String deviceId; - /** 设备状态:0-离线、1-待机、2-运行、3-故障、4-停机 */ - private String deviceStatus; + /** 工作状态:0-运行 1-停机 2-故障 */ + @NotBlank(message = "工作状态状态不能为空") + private String workStatus; /** 设备类型 */ private String deviceCategory; @@ -38,12 +39,12 @@ public class DeviceUpdateRequest { this.deviceId = deviceId; } - public String getDeviceStatus() { - return deviceStatus; + public String getWorkStatus() { + return workStatus; } - public void setDeviceStatus(String deviceStatus) { - this.deviceStatus = deviceStatus; + public void setWorkStatus(String workStatus) { + this.workStatus = workStatus; } public String getDeviceCategory() { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java index 0e67719..ba48224 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DDSDataProcessServiceImpl.java @@ -9,33 +9,70 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.xzzn.common.constant.Constants; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; -import com.xzzn.common.enums.*; +import com.xzzn.common.enums.BranchStatus; +import com.xzzn.common.enums.ChargeStatus; +import com.xzzn.common.enums.CommunicationStatus; +import com.xzzn.common.enums.ControlModeStatus; +import com.xzzn.common.enums.DeviceRunningStatus; +import com.xzzn.common.enums.GridStatus; +import com.xzzn.common.enums.SwitchStatus; +import com.xzzn.common.enums.WorkStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.EmsAmmeterData; +import com.xzzn.ems.domain.EmsBatteryCluster; +import com.xzzn.ems.domain.EmsBatteryData; +import com.xzzn.ems.domain.EmsBatteryDataDailyLatest; +import com.xzzn.ems.domain.EmsBatteryDataMinutes; +import com.xzzn.ems.domain.EmsBatteryGroup; +import com.xzzn.ems.domain.EmsBatteryStack; +import com.xzzn.ems.domain.EmsDailyChargeData; +import com.xzzn.ems.domain.EmsDailyEnergyData; +import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.EmsDhData; +import com.xzzn.ems.domain.EmsPcsBranchData; +import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.domain.EmsXfData; import com.xzzn.ems.domain.vo.EnergyPriceVo; -import com.xzzn.ems.mapper.*; +import com.xzzn.ems.mapper.EmsAmmeterDataMapper; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper; +import com.xzzn.ems.mapper.EmsBatteryGroupMapper; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; +import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; +import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsDhDataMapper; +import com.xzzn.ems.mapper.EmsPcsBranchDataMapper; +import com.xzzn.ems.mapper.EmsPcsDataMapper; +import com.xzzn.ems.mapper.EmsXfDataMapper; import com.xzzn.ems.service.IDDSDataProcessService; import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IEmsDeviceSettingService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + @Service public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IDDSDataProcessService { private static final Log log = LogFactory.getLog(DDSDataProcessServiceImpl.class); @@ -633,7 +670,7 @@ public class DDSDataProcessServiceImpl extends AbstractBatteryDataProcessor impl pcsData.setDataUpdateTime(new Date()); pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); pcsData.setGridStatus(GridStatus.GRID.getCode()); - pcsData.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); + pcsData.setDeviceStatus(DeviceRunningStatus.ONLINE.getCode()); pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); // 电流 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index dc92587..0459534 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -23,7 +23,6 @@ import com.xzzn.common.enums.GridStatus; import com.xzzn.common.enums.SiteDevice; import com.xzzn.common.enums.SiteEnum; import com.xzzn.common.enums.SwitchStatus; -import com.xzzn.common.enums.WorkStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.MapUtils; import com.xzzn.common.utils.StringUtils; @@ -379,7 +378,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 其他非 BigDecimal 字段 dataStack.setDataUpdateTime(dataUpdateTime); - dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 +// dataStack.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); @@ -669,7 +668,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i saveDeviceData(pointMatchList, obj, data, pointEnumMatchMap); data.setDataUpdateTime(dataUpdateTime); - data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 +// data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setCreateBy("system"); @@ -812,9 +811,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 时间与状态类字段 pcsData.setDataUpdateTime(dataUpdateTime); - pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); +// pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); pcsData.setGridStatus(GridStatus.GRID.getCode()); - pcsData.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); + pcsData.setDeviceStatus(DeviceRunningStatus.ONLINE.getCode()); pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); // 系统管理字段 @@ -936,7 +935,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i EmsBatteryCluster data = new EmsBatteryCluster(); // 其他非 BigDecimal 字段 data.setDataUpdateTime(dataUpdateTime); - data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 +// data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 data.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); data.setCreateBy("system"); 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 d9f4cc2..cc19d4b 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 @@ -10,9 +10,9 @@ import com.xzzn.common.core.modbus.domain.DeviceConfig; import com.xzzn.common.core.modbus.domain.WriteTagConfig; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.DeviceCategory; -import com.xzzn.common.enums.DeviceRunningStatus; import com.xzzn.common.enums.PointType; import com.xzzn.common.enums.SiteEnum; +import com.xzzn.common.enums.WorkStatus; import com.xzzn.common.exception.ServiceException; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; @@ -528,25 +528,14 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService if (pcsSetting == null) { throw new ServiceException("未找到对应PCS配置信息"); } - if (DeviceRunningStatus.getShutdownCodeList().contains(request.getDeviceStatus())) { - // 开机逻辑 - device.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); - } else if (DeviceRunningStatus.getRunningCodeList().contains(request.getDeviceStatus())) { - // 关机逻辑 - device.setDeviceStatus(DeviceRunningStatus.SHUTDOWN.getCode()); - } else { - return false; - } // 调用Modbus向设备发送指令 DeviceConfig deviceConfig = getDeviceConfig(device); - deviceConfig.setWriteTags(getWriteTags(device.getDeviceStatus(), pcsSetting)); + deviceConfig.setWriteTags(getWriteTags(request.getWorkStatus(), pcsSetting)); log.info("设备控制指令发送数据: {}", JSON.toJSONString(deviceConfig)); boolean result = modbusProcessor.writeDataToDevice(deviceConfig); if (!result) { throw new ServiceException("设备控制指令发送失败"); } - device.setUpdatedAt(DateUtils.getNowDate()); - emsDevicesMapper.updateEmsDevicesSetting(device); return true; } @@ -563,19 +552,21 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService return deviceConfig; } - public List getWriteTags(String deviceStatus, EmsPcsSetting pcsSetting) { + public List getWriteTags(String workStatus, EmsPcsSetting pcsSetting) { List writeTags = new ArrayList<>(); BigDecimal power; WriteTagConfig writeTag = new WriteTagConfig(); writeTag.setAddress(pcsSetting.getPointAddress()); - if (DeviceRunningStatus.RUNNING.getCode().equals(deviceStatus)) { + if (WorkStatus.NORMAL.getCode().equals(workStatus)) { // 开机 writeTag.setValue(pcsSetting.getStartCommand()); power = pcsSetting.getStartPower(); - } else { + } else if (WorkStatus.STOP.getCode().equals(workStatus)) { // 关机 writeTag.setValue(pcsSetting.getStopCommand()); power = pcsSetting.getStopPower(); + } else { + throw new ServiceException("工作状态不合法"); } writeTags.add(writeTag); JSONArray array = JSON.parseArray(pcsSetting.getClusterPointAddress()); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java index d7a806f..640cc91 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStrategyTempServiceImpl.java @@ -173,8 +173,7 @@ public class EmsStrategyTempServiceImpl implements IEmsStrategyTempService } private void convertStringToDate(String content, SyncStrategyTempVo syncVo) throws JsonProcessingException { - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootNode = mapper.readTree(content); + JsonNode rootNode = objectMapper.readTree(content); String startTime = rootNode.path("startTime").asText(); String endTime = rootNode.path("endTime").asText(); if (startTime != null && !"null".equals(startTime)) { diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java index 8f9d2bd..e95ac48 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/FXXDataProcessServiceImpl.java @@ -9,42 +9,73 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; -import com.xzzn.common.enums.*; +import com.xzzn.common.enums.BranchStatus; +import com.xzzn.common.enums.ChargeStatus; +import com.xzzn.common.enums.CommunicationStatus; +import com.xzzn.common.enums.ControlModeStatus; +import com.xzzn.common.enums.DeviceRunningStatus; +import com.xzzn.common.enums.GridStatus; +import com.xzzn.common.enums.SwitchStatus; +import com.xzzn.common.enums.WorkStatus; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; -import com.xzzn.ems.domain.*; +import com.xzzn.ems.domain.EmsAmmeterData; +import com.xzzn.ems.domain.EmsBatteryCluster; +import com.xzzn.ems.domain.EmsBatteryData; +import com.xzzn.ems.domain.EmsBatteryDataDailyLatest; +import com.xzzn.ems.domain.EmsBatteryDataMinutes; +import com.xzzn.ems.domain.EmsBatteryStack; +import com.xzzn.ems.domain.EmsCoolingData; +import com.xzzn.ems.domain.EmsDailyChargeData; +import com.xzzn.ems.domain.EmsDailyEnergyData; +import com.xzzn.ems.domain.EmsDevicesSetting; +import com.xzzn.ems.domain.EmsDhData; +import com.xzzn.ems.domain.EmsPcsBranchData; +import com.xzzn.ems.domain.EmsPcsData; +import com.xzzn.ems.domain.EmsPointMatch; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import com.xzzn.ems.domain.vo.EnergyPriceVo; import com.xzzn.ems.enums.DeviceMatchTable; -import com.xzzn.ems.mapper.*; +import com.xzzn.ems.mapper.EmsAmmeterDataMapper; +import com.xzzn.ems.mapper.EmsBatteryClusterMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMapper; +import com.xzzn.ems.mapper.EmsBatteryDataMinutesMapper; +import com.xzzn.ems.mapper.EmsBatteryStackMapper; +import com.xzzn.ems.mapper.EmsCoolingDataMapper; +import com.xzzn.ems.mapper.EmsDailyChargeDataMapper; +import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; +import com.xzzn.ems.mapper.EmsDevicesSettingMapper; +import com.xzzn.ems.mapper.EmsDhDataMapper; +import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper; +import com.xzzn.ems.mapper.EmsPcsBranchDataMapper; +import com.xzzn.ems.mapper.EmsPcsDataMapper; import com.xzzn.ems.service.IEmsAlarmRecordsService; import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import com.xzzn.ems.service.IFXXDataProcessService; import com.xzzn.ems.utils.AbstractBatteryDataProcessor; import com.xzzn.ems.utils.DevicePointMatchDataProcessor; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.poi.ss.formula.functions.T; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.yaml.snakeyaml.introspector.PropertyUtils; - import java.lang.reflect.Field; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.function.Function; import java.util.stream.Collectors; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + @Service public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor implements IFXXDataProcessService { private static final Log log = LogFactory.getLog(FXXDataProcessServiceImpl.class); @@ -539,7 +570,7 @@ public class FXXDataProcessServiceImpl extends AbstractBatteryDataProcessor impl pcsData.setDataUpdateTime(dataUpdateTime); pcsData.setWorkStatus(WorkStatus.NORMAL.getCode()); pcsData.setGridStatus(GridStatus.GRID.getCode()); - pcsData.setDeviceStatus(DeviceRunningStatus.RUNNING.getCode()); + pcsData.setDeviceStatus(DeviceRunningStatus.ONLINE.getCode()); pcsData.setControlMode(ControlModeStatus.REMOTE.getCode()); // 系统管理字段 -- 2.49.0 From 566119f6928b2ac47cfa2b940e621892bbc6fb86 Mon Sep 17 00:00:00 2001 From: zq Date: Thu, 8 Jan 2026 15:33:54 +0800 Subject: [PATCH 281/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E6=95=B0=E6=8D=AE=E8=A7=A3=E6=9E=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDataProcessServiceImpl.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 0459534..661b395 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -1533,18 +1533,24 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } public String processingDeviceAlarmData(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { - String deviceCategory = ""; - if (deviceId.contains(SiteDevice.ZSLQ.name())) { + // 判断设备类型,并调用对应的方法处理数据 + String deviceCategory = getDeviceCategory(siteId, deviceId); + log.info("alarm siteId: {}, deviceId: {}siteId, category: {} ", siteId, deviceId, deviceCategory); + if (deviceId.contains(SiteDevice.ZSLQ.name()) + || DeviceCategory.COOLING.getCode().equals(deviceCategory)) { coolingAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.BMSD.name())) { - deviceCategory = DeviceCategory.STACK.getCode(); + } else if (deviceId.contains(SiteDevice.BMSD.name()) + || DeviceCategory.STACK.getCode().equals(deviceCategory)) { stackAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.BMSC.name())) { - deviceCategory = DeviceCategory.CLUSTER.getCode(); + } else if (deviceId.contains(SiteDevice.BMSC.name()) + || DeviceCategory.CLUSTER.getCode().equals(deviceCategory)) { clusterAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); - } else if (deviceId.contains(SiteDevice.PCS.name())) { - deviceCategory = DeviceCategory.PCS.getCode(); + } else if (deviceId.contains(SiteDevice.PCS.name()) + || DeviceCategory.PCS.getCode().equals(deviceCategory) ) { pcsAlarmDataProcess(siteId, deviceId, jsonData, dataUpdateTime); + } else { + log.info("未找到匹配的点位数据,无法处理设备告警数据,siteId: " + siteId + ",deviceId: " + deviceId); + return null; } return deviceCategory; -- 2.49.0 From 1eee07e040aab53d7fa47c2b233754083d8b0d3c Mon Sep 17 00:00:00 2001 From: zq Date: Thu, 8 Jan 2026 16:46:24 +0800 Subject: [PATCH 282/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=A1=A8=E6=96=B0=E5=A2=9Ework=5Fstatus=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/domain/EmsDevicesSetting.java | 12 ++++++++++ .../xzzn/ems/domain/vo/SiteDeviceListVo.java | 10 ++++++++ .../impl/DeviceDataProcessServiceImpl.java | 24 +++++++++++++++---- .../mapper/ems/EmsDevicesSettingMapper.xml | 7 +++++- .../mapper/ems/EmsSiteSettingMapper.xml | 2 +- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java index 17641c8..08db29f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/EmsDevicesSetting.java @@ -108,6 +108,10 @@ public class EmsDevicesSetting extends BaseEntity @Excel(name = "设备运行状态:0-离线、1-在线") private String deviceStatus; + /** 设备运行状态:0-离线、1-在线 */ + @Excel(name = "工作状态:0-运行 1-停机 2-故障") + private String workStatus; + /** 设备图像地址 */ @Excel(name = "设备图像地址") private String pictureUrl; @@ -330,6 +334,14 @@ public class EmsDevicesSetting extends BaseEntity this.deviceStatus = deviceStatus; } + public String getWorkStatus() { + return workStatus; + } + + public void setWorkStatus(String workStatus) { + this.workStatus = workStatus; + } + public void setPictureUrl(String pictureUrl) { this.pictureUrl = pictureUrl; diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java index 9d241f7..9de8512 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteDeviceListVo.java @@ -17,6 +17,8 @@ public class SiteDeviceListVo { private String deviceType; /** 运行状态 */ private String deviceStatus; + /** 工作状态 */ + private String workStatus; /** 设备类型 */ private String deviceCategory; /** 设备类型 */ @@ -86,6 +88,14 @@ public class SiteDeviceListVo { this.deviceStatus = deviceStatus; } + public String getWorkStatus() { + return workStatus; + } + + public void setWorkStatus(String workStatus) { + this.workStatus = workStatus; + } + public String getDeviceCategory() { return deviceCategory; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 661b395..aba83a0 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -395,6 +395,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i redisCache.setCacheObject(RedisKeyConstants.STACK + siteId + "_" + deviceId, dataStack); + // 同步更新设备工作状态 + saveDeviceWorkStatus(deviceId, siteId, dataStack.getWorkStatus()); } private void batteryGroupDataProcess(String siteId, String deviceId, String jsonData) { @@ -686,6 +688,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i redisCache.setCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + deviceId, data); + // 同步更新设备工作状态 + saveDeviceWorkStatus(deviceId, siteId, data.getWorkStatus()); } private String getStackDeviceId(String deviceId) { @@ -829,11 +833,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i emsPcsDataMapper.insertEmsPcsData(pcsData); redisCache.setCacheObject(RedisKeyConstants.PCS + siteId + "_" + deviceId, pcsData); - // 同步更新PCS设备状态 -// EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); -// emsDevicesSetting.setDeviceStatus(pcsData.getDeviceStatus()); -// emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); -// emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); + // 同步更新PCS设备工作状态 + saveDeviceWorkStatus(deviceId, siteId, pcsData.getWorkStatus()); // if (SiteEnum.FX.getCode().equals(siteId)) { // //更新每日充放电数据 @@ -960,10 +961,23 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i emsBatteryClusterMapper.insertEmsBatteryCluster(data); redisCache.setCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + deviceId, data); + // 同步更新设备工作状态 + saveDeviceWorkStatus(deviceId, siteId, data.getWorkStatus()); + } } + private void saveDeviceWorkStatus(String deviceId, String siteId, String workStatus) { + if (StringUtils.isBlank(workStatus)) { + return; + } + EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); + emsDevicesSetting.setWorkStatus(workStatus); + emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); + emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); + } + private String getDeviceParent(String siteId, String deviceId) { Map> map = redisCache.getCacheObject(RedisKeyConstants.INIT_DEVICE_INFO); if (map == null || map.isEmpty()) { diff --git a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml index 19dba5b..5557599 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsDevicesSettingMapper.xml @@ -27,11 +27,12 @@ + - select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category,device_status, picture_url from ems_devices_setting + select id, device_name, device_type, slave_id, timeout_ms, retries, ip_address, ip_port, serial_port, baud_rate, data_bits, stop_bits, parity, description, created_at, updated_at, site_id, communication_status, device_id, parent_id, device_category,device_status, picture_url,work_status from ems_devices_setting @@ -91,6 +93,7 @@ parent_id, device_category, device_status, + work_status, picture_url, @@ -115,6 +118,7 @@ #{parentId}, #{deviceCategory}, #{deviceStatus}, + #{workStatus}, #{pictureUrl}, @@ -143,6 +147,7 @@ parent_id = #{parentId}, device_category = #{deviceCategory}, device_status = #{deviceStatus}, + work_status = #{workStatus}, picture_url = #{pictureUrl}, where id = #{id} diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index 6aa3e12..086ed2e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -136,7 +136,7 @@ @@ -40,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and charge_status = #{chargeStatus} and execution_date = #{executionDate} and anti_reverse = #{antiReverse} + and power_down_type = #{powerDownType} order by create_time desc @@ -62,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" charge_status, execution_date, anti_reverse, + power_down_type, create_by, create_time, update_by, @@ -79,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{chargeStatus}, #{executionDate}, #{antiReverse}, + #{powerDownType}, #{createBy}, #{createTime}, #{updateBy}, @@ -100,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" charge_status = #{chargeStatus}, execution_date = #{executionDate}, anti_reverse = #{antiReverse}, + power_down_type = #{powerDownType}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, @@ -119,4 +124,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + \ No newline at end of file -- 2.49.0 From 685a2e8687e6b84302b5c22832f23877d566ffb6 Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 12 Jan 2026 13:26:40 +0800 Subject: [PATCH 286/336] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index aba83a0..34dffb5 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -973,7 +973,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i return; } EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); - emsDevicesSetting.setWorkStatus(workStatus); + emsDevicesSetting.setWorkStatus(String.valueOf(new BigDecimal(workStatus).longValue())); emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); } -- 2.49.0 From 3f4d3772b00deab48035b7ef83bce6e202794c3d Mon Sep 17 00:00:00 2001 From: zq Date: Mon, 12 Jan 2026 15:18:21 +0800 Subject: [PATCH 287/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E8=A7=A3=E6=9E=90=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDataProcessServiceImpl.java | 66 ++++++++++++++----- .../impl/EmsAlarmRecordsServiceImpl.java | 2 +- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 34dffb5..2636fae 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -1726,32 +1726,62 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 遍历数据map for (Map.Entry entry : obj.entrySet()) { + if (entry.getValue() == null) { + continue; + } String key = entry.getKey(); - Integer value = (Integer) entry.getValue(); + Long value = (Long) entry.getValue(); Boolean isCurrentAlarm = currentAlarmKeys.contains(key); - - // 值为 1且不在当前告警里面 - 新增告警 - if (value == 1 && !isCurrentAlarm) { - String matchRedisKey = category + "_" + key; - Object cacheObj = alarmInfoData.get(matchRedisKey); - if (cacheObj == null) { - // 处理空数据逻辑 - return; - } + String matchRedisKey = siteId + "_" + category + "_" + key; + // 默认告警值0是正常,1是异常 + Long alarmData = 1L; + Object cacheObj = alarmInfoData.get(matchRedisKey); + if (cacheObj != null) { + EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class); + alarmData = matchInfo.getAlarmData(); + } + // 处理告警 + if (value.equals(alarmData) && !isCurrentAlarm) { + // 上送值和匹配值相同,新增告警 EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class); EmsAlarmRecords emsAlarmRecord = convertAlarmRecord(siteId, deviceId, matchInfo); saveOrUpdateList.add(emsAlarmRecord); newAddRecordList.add(emsAlarmRecord); - } else if (value == 0 && isCurrentAlarm) {// 值为 0且在当前告警里面 - 更新告警已处理 - EmsAlarmRecords existingAlarm = needUpdateMap.get(key); - if (existingAlarm != null) { - existingAlarm.setStatus(AlarmStatus.DONE.getCode()); - existingAlarm.setUpdateTime(new Date()); - existingAlarm.setAlarmEndTime(new Date()); - saveOrUpdateList.add(existingAlarm); - toRemoveFromRedis.add(key); + } else { + if (isCurrentAlarm) { + // 在当前告警里面 - 更新告警已处理 + EmsAlarmRecords existingAlarm = needUpdateMap.get(key); + if (existingAlarm != null) { + existingAlarm.setStatus(AlarmStatus.DONE.getCode()); + existingAlarm.setUpdateTime(new Date()); + existingAlarm.setAlarmEndTime(new Date()); + saveOrUpdateList.add(existingAlarm); + toRemoveFromRedis.add(key); + } } } +// // 值为 1且不在当前告警里面 - 新增告警 +// if (value == 1 && !isCurrentAlarm) { +// String matchRedisKey = category + "_" + key; +// Object cacheObj = alarmInfoData.get(matchRedisKey); +// if (cacheObj == null) { +// // 处理空数据逻辑 +// return; +// } +// EmsAlarmMatchData matchInfo = JSON.toJavaObject(cacheObj, EmsAlarmMatchData.class); +// EmsAlarmRecords emsAlarmRecord = convertAlarmRecord(siteId, deviceId, matchInfo); +// saveOrUpdateList.add(emsAlarmRecord); +// newAddRecordList.add(emsAlarmRecord); +// } else if (value == 0 && isCurrentAlarm) {// 值为 0且在当前告警里面 - 更新告警已处理 +// EmsAlarmRecords existingAlarm = needUpdateMap.get(key); +// if (existingAlarm != null) { +// existingAlarm.setStatus(AlarmStatus.DONE.getCode()); +// existingAlarm.setUpdateTime(new Date()); +// existingAlarm.setAlarmEndTime(new Date()); +// saveOrUpdateList.add(existingAlarm); +// toRemoveFromRedis.add(key); +// } +// } } // 批量处理插入和更新操作 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java index 4fcedad..92687b1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsAlarmRecordsServiceImpl.java @@ -265,7 +265,7 @@ public class EmsAlarmRecordsServiceImpl implements IEmsAlarmRecordsService List alarmPointList = emsAlarmMatchDataMapper.selectEmsAlarmMatchDataList(null); Map resultMap = alarmPointList.stream() .collect(Collectors.toMap( - data->data.getDeviceCategory()+"_"+data.getPoint(), + data->data.getSiteId()+"_"+data.getDeviceCategory()+"_"+data.getPoint(), data->data, (existing, replacement) -> replacement )); -- 2.49.0 From 9aa7dd9d18a82c94bcc4d94d2b9b435351b3288d Mon Sep 17 00:00:00 2001 From: zq Date: Thu, 15 Jan 2026 14:45:28 +0800 Subject: [PATCH 288/336] =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 1 + .../controller/ems/MqttMessageController.java | 17 +++- .../common/core/modbus/ModbusProcessor.java | 30 +++++-- .../com/xzzn/quartz/task/ModbusPoller.java | 16 ++-- .../com/xzzn/quartz/task/StrategyPoller.java | 85 +++++++++++++------ .../ems/domain/vo/ProtectionSettingVo.java | 11 +++ .../ems/mapper/EmsPointEnumMatchMapper.java | 4 +- .../impl/DeviceDataProcessServiceImpl.java | 10 +-- .../impl/EmsPointMatchServiceImpl.java | 20 ++++- .../mapper/ems/EmsStrategyLogMapper.xml | 10 +-- 10 files changed, 145 insertions(+), 59 deletions(-) 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 5e512e3..d4104b0 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 @@ -194,6 +194,7 @@ public class EmsSiteConfigController extends BaseController{ /** * PCS设备开关机 */ +// @PreAuthorize("@ss.hasPermi('system:device:onAndOff')") @Log(title = "开关机", businessType = BusinessType.UPDATE) @PostMapping("/updateDeviceStatus") public AjaxResult updateDeviceStatus(@Valid @RequestBody DeviceUpdateRequest request) diff --git a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java index 2c06e49..ecf1090 100644 --- a/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java +++ b/ems-admin/src/main/java/com/xzzn/web/controller/ems/MqttMessageController.java @@ -6,10 +6,21 @@ import com.xzzn.common.enums.TopicHandleType; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsMqttTopicConfig; import com.xzzn.ems.mapper.EmsMqttTopicConfigMapper; -import com.xzzn.ems.service.*; +import com.xzzn.ems.service.IDDSDataProcessService; +import com.xzzn.ems.service.IDeviceDataProcessService; +import com.xzzn.ems.service.IEmsMqttMessageService; +import com.xzzn.ems.service.IEmsStrategyService; +import com.xzzn.ems.service.IFXXAlarmDataProcessService; +import com.xzzn.ems.service.IFXXDataProcessService; +import com.xzzn.ems.service.IMqttSyncLogService; import com.xzzn.framework.manager.MqttLifecycleManager; import com.xzzn.framework.web.service.MqttPublisher; import com.xzzn.framework.web.service.MqttSubscriber; + +import java.util.List; + +import javax.annotation.PostConstruct; + import org.apache.commons.collections4.CollectionUtils; import org.eclipse.paho.client.mqttv3.IMqttMessageListener; import org.eclipse.paho.client.mqttv3.MqttException; @@ -19,9 +30,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import javax.annotation.PostConstruct; -import java.util.List; - @Service public class MqttMessageController implements MqttPublisher, MqttSubscriber { @@ -170,6 +178,7 @@ public class MqttMessageController implements MqttPublisher, MqttSubscriber { emsMqttMessageService.insertMqttOriginalMessage(topic, payload); } catch (Exception e) { + e.printStackTrace(); log.error("Failed to process device alarm data message: " + e.getMessage(), e); } diff --git a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java index 18d1378..a096002 100644 --- a/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java +++ b/ems-common/src/main/java/com/xzzn/common/core/modbus/ModbusProcessor.java @@ -1,5 +1,6 @@ package com.xzzn.common.core.modbus; +import com.alibaba.fastjson2.JSON; import com.serotonin.modbus4j.BatchRead; import com.serotonin.modbus4j.BatchResults; import com.serotonin.modbus4j.ModbusMaster; @@ -22,6 +23,7 @@ import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.enums.ModBusType; import com.xzzn.common.enums.RegisterType; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -47,6 +49,7 @@ public class ModbusProcessor { private Modbus4jConnectionManager connectionManager; public boolean writeDataToDevice(DeviceConfig config) { + logger.info("writeDataToDevice: {}", JSON.toJSONString(config)); ModbusMaster master = null; boolean result = true; try { @@ -80,7 +83,12 @@ public class ModbusProcessor { break; } case HOLDING_REGISTER: { - double doubleValue = Double.parseDouble(String.valueOf(tag.getValue())); + Number value = Double.parseDouble(String.valueOf(tag.getValue())); + double doubleValue = value.doubleValue(); + // 检查是否在16位有符号整数范围内 + if (doubleValue < -32768 || doubleValue > 32767) { + logger.warn("Value {} out of range for 16-bit signed register at address {}", doubleValue, address); + } writeRegisterRequest(master, config.getSlaveId(), address, (int) doubleValue); break; } @@ -161,7 +169,7 @@ public class ModbusProcessor { public static void setRegisterValue(ModbusMaster master, int slaveId, int address, int value) { // 写入单个保持寄存器(从站, 地址, 16位整数) - BaseLocator holdingLocator = BaseLocator.holdingRegister(slaveId, address, DataType.TWO_BYTE_INT_UNSIGNED); + BaseLocator holdingLocator = BaseLocator.holdingRegister(slaveId, address, DataType.TWO_BYTE_INT_SIGNED); try { // 写入整数值到保持寄存器 master.setValue(holdingLocator, value); @@ -174,7 +182,7 @@ public class ModbusProcessor { public ModbusMaster borrowMaster(DeviceConfig config) throws Exception { ModbusMaster master = connectionManager.borrowMaster(config); // 设置了Modbus通信的超时时间为3000毫秒(3秒)。当主设备与从设备通信时,若在3秒内未收到响应,则认为通信超时并抛出异常。这有助于避免长时间等待无响应的设备。 - master.setTimeout(5000); + master.setTimeout(10000); return master; } @@ -339,14 +347,22 @@ public class ModbusProcessor { }); BatchResults results = master.send(batch); - for (TagConfig tag : tags){ - if (tag.getBit()!=null){ - logger.info("批处理读取寄存器成功: {}",tag.getAddress() +"(" + tag.getBit() + "):" + results.getValue(tag.getKey())); + List logInfoList = new ArrayList<>(); + for (TagConfig tag : tags){ + StringBuilder logInfo = new StringBuilder(); + logInfo.append(tag.getAddress()); + if (tag.getBit()!=null){ +// logger.info("批处理读取寄存器成功: {}",tag.getAddress() +"(" + tag.getBit() + "):" + results.getValue(tag.getKey())); + logInfo.append("(" + tag.getBit() + "):"); }else { - logger.info("批处理读取寄存器成功: {}",tag.getAddress() + ":" + results.getValue(tag.getKey())); +// logger.info("批处理读取寄存器成功: {}",tag.getAddress() + ":" + results.getValue(tag.getKey())); + logInfo.append(":"); } + logInfo.append(results.getValue(tag.getKey())); + logInfoList.add(logInfo.toString()); } + logger.info("批处理读取寄存器成功: {}", JSON.toJSONString(logInfoList)); return results; } catch (Exception e){ logger.error("Failed to read master '{}'", slaveId, e); diff --git a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java index e534010..43f4db0 100644 --- a/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java +++ b/ems-quartz/src/main/java/com/xzzn/quartz/task/ModbusPoller.java @@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; /** * 轮询设备-通过modbus协议读取数据 @@ -145,8 +146,9 @@ public class ModbusPoller { addDeviceOfflineRecord(siteId, config.getDeviceNumber()); return; } + List rawValuEmptyList = new ArrayList<>(); Map data = modbusProcessor.readDataFromDevice(config, master); - // 在这里处理采集到的数据 + // 在这里处理采集到的数据空 config.getTags().forEach(tag -> { Object rawValue = data.get(tag.getKey()); if (rawValue != null) { @@ -167,10 +169,14 @@ public class ModbusPoller { data.put(tag.getKey(), value); } } else { - data.put(tag.getKey(), rawValue); - log.warn("tag:{},数据为空: {}", tag.getKey(), rawValue); +// data.put(tag.getKey(), rawValue); +// log.warn("tag:{},数据为空: {}", tag.getKey(), rawValue); + rawValuEmptyList.add("tag: " + tag.getKey() + ",数据为空: " + rawValue); } }); + if (!rawValuEmptyList.isEmpty()) { + log.warn("设备 {} 数据为空: {}", config.getDeviceName(), JSON.toJSONString(rawValuEmptyList)); + } log.info("Data from {}: {}", config.getDeviceName(), data); String deviceNumber = config.getDeviceNumber(); //处理数据并发送MQTT消息、保存Redis数据和数据入库 @@ -179,7 +185,7 @@ public class ModbusPoller { } private void processingData(Map data, String deviceNumber) { - if (data == null || data.size() == 0) { + if (CollectionUtils.isEmpty(data)) { // 增加失败计数 int failureCount = deviceFailureCounts.getOrDefault(deviceNumber, 0) + 1; deviceFailureCounts.put(deviceNumber, failureCount); @@ -213,7 +219,7 @@ public class ModbusPoller { try { mqttPublisher.publish(topic, Collections.singletonList(json).toString(), 0); } catch (MqttException e) { - log.error("MQTT消息发布失败: {}", json.toJSONString(), e); + log.error("MQTT消息发布失败: {}, reason code: {}", json.toJSONString(), e.getReasonCode() ,e); } log.info("已发送数据: {}", json.toJSONString()); } 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 8c5163e..4fd3f71 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 @@ -40,6 +40,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; @@ -51,6 +52,8 @@ import org.springframework.stereotype.Component; public class StrategyPoller { private static final Logger logger = LoggerFactory.getLogger(StrategyPoller.class); + private static final ConcurrentHashMap strategyLocks = new ConcurrentHashMap<>(); + // SOC 上下限值,默认为0%-100% private static final BigDecimal SOC_DOWN = new BigDecimal(0); private static final BigDecimal SOC_UP = new BigDecimal(100); @@ -86,16 +89,23 @@ public class StrategyPoller { logger.info("开始执行运行策略数据轮询..."); List strategyRunningVoList = emsStrategyRunningMapper.getPendingPollerStrategy(null); strategyRunningVoList.forEach(strategyVo -> { - try { - CompletableFuture.runAsync(() -> { - processData(strategyVo); - }) - .exceptionally(e -> { - logger.error("运行策略{}轮询异常", strategyVo.getId(), e); - return null; - }); - } catch (Exception e) { - logger.error("运行策略{}任务失败", strategyVo.getId(), e); + Long strategyId = strategyVo.getId(); + if (strategyLocks.putIfAbsent(strategyId, true) == null) { + try { + CompletableFuture.runAsync(() -> { + processData(strategyVo); + }) + .exceptionally(e -> { + logger.error("运行策略{}轮询异常", strategyVo.getId(), e); + return null; + }) + .thenRun(() -> strategyLocks.remove(strategyId)); + } catch (Exception e) { + logger.error("运行策略{}任务失败", strategyVo.getId(), e); + strategyLocks.remove(strategyId); + } + } else { + logger.info("策略{}已在处理中,跳过重复执行", strategyId); } }); } @@ -159,7 +169,7 @@ public class StrategyPoller { logger.info("当前站点: {} 未配置PCS设备", siteId); continue; } - // 判断SOC上限和下限是否在范围内 + // 判断SOC上下限 if (isSocInRange(emsStrategyTemp)) { BigDecimal avgChargeDischargePower = emsStrategyTemp.getChargeDischargePower().divide(new BigDecimal(pcsDeviceList.size())); for (EmsDevicesSetting pcsDevice : pcsDeviceList) { @@ -168,8 +178,8 @@ public class StrategyPoller { logger.info("当前站点: {}, PCS设备: {} 未获取电池簇数量", siteId, pcsDevice.getDeviceId()); continue; } - // 平均功率值,根据电池簇数量进行平均分配 - avgChargeDischargePower = avgChargeDischargePower.divide(new BigDecimal(pcsSetting.getClusterNum())); + // 功率默认放大10倍,平均功率值,根据电池簇数量进行平均分配 + avgChargeDischargePower = avgChargeDischargePower.multiply(new BigDecimal(10)).divide(new BigDecimal(pcsSetting.getClusterNum())); // 根据充电状态,处理数据 if (ChargeStatus.CHARGING.getCode().equals(emsStrategyTemp.getChargeStatus())) { // 发送Modbus命令控制设备-充电 @@ -189,7 +199,7 @@ public class StrategyPoller { powerDownType = lastStrategyLog.getPowerDownType(); } - // 查询电网电表的正向有功功率 + // 查询电网电表的正向有功功率,36kW-50kW范围内,稳定运行,低于36kW,降功率,高于50kW,增加功率 EmsAmmeterData emsAmmeterData = emsAmmeterDataMapper.getLastData(emsStrategyTemp.getSiteId(), SiteDevice.LOAD.name()); if (emsAmmeterData == null || emsAmmeterData.getTotalActivePower() == null) { logger.info("当前站点: {}, 未获取到最新电表数据", emsStrategyTemp.getSiteId()); @@ -202,8 +212,8 @@ public class StrategyPoller { chargeDischargePower = chargeDischargePower.subtract(power); powerDownType = 0; } else { - // 判断是否需要增加功率 - if (powerDownType != null && emsAmmeterData.getTotalActivePower().compareTo(ANTI_REVERSE_UP) < 0) { + // 判断是否需要增加功率, + if (powerDownType != null && emsAmmeterData.getTotalActivePower().compareTo(ANTI_REVERSE_UP) > 0) { if (chargeDischargePower.compareTo(avgChargeDischargePower) == 0) { // 功率增加到平均值则停止 continue; @@ -364,13 +374,19 @@ public class StrategyPoller { String siteId = pcsDevice.getSiteId(); String deviceId = pcsDevice.getDeviceId(); List strategyLogList = getStrategyLog(deviceId, chargeStatus.getCode(), emsStrategyTemp, needAntiReverseFlow); - if (CollectionUtils.isNotEmpty(strategyLogList) && (!ChargeStatus.DISCHARGING.equals(chargeStatus) || !needAntiReverseFlow)) { - logger.info("当前站点: {}, PCS设备: {} 当前时间段已存在策略执行记录,不再重复执行", siteId, deviceId); - continue; + if (CollectionUtils.isNotEmpty(strategyLogList)) { + boolean isExist = true; + if (ChargeStatus.DISCHARGING.equals(chargeStatus) && needAntiReverseFlow) { + isExist = false; + } + if (isExist) { + logger.info("当前站点: {}, PCS设备: {} 当前时间段已存在策略执行记录,不再重复执行", siteId, deviceId); + continue; + } } // 每次操作先判断设备工作状态 - if (WorkStatus.ABNORMAL.getCode().equals(pcsDevice.getWorkStatus())) { + if (StringUtils.isEmpty(pcsDevice.getWorkStatus()) || WorkStatus.ABNORMAL.getCode().equals(pcsDevice.getWorkStatus())) { // 设备故障,不发送指令 continue; } else if (WorkStatus.STOP.getCode().equals(pcsDevice.getWorkStatus())) { @@ -381,6 +397,7 @@ public class StrategyPoller { } else { // 充、放电,则先开机设备 switchDevice(pcsDevice, pcsSetting, WorkStatus.NORMAL); + continue; } } @@ -391,10 +408,11 @@ public class StrategyPoller { boolean result = modbusProcessor.writeDataToDevice(deviceConfig); if (!result) { logger.info("当前站点: {}, PCS设备: {} modbus控制设备{}指令发送失败", siteId, deviceId, chargeStatus.getInfo()); - } - if (ChargeStatus.STANDBY.equals(chargeStatus)) { - // 待机,先写功率值,再关机 - switchDevice(pcsDevice, pcsSetting, WorkStatus.STOP); + } else { + if (ChargeStatus.STANDBY.equals(chargeStatus)) { + // 待机,先写功率值,再关机 + switchDevice(pcsDevice, pcsSetting, WorkStatus.STOP); + } } // 记录策略执行日志 saveStrategyLog(deviceId, chargeDischargePower, chargeStatus.getCode(), emsStrategyTemp, needAntiReverseFlow, powerDownType); @@ -406,7 +424,7 @@ public class StrategyPoller { String siteId = pcsDevice.getSiteId(); String deviceId = pcsDevice.getDeviceId(); pcsDevice.setWorkStatus(workStatus.getCode()); - DeviceConfig deviceConfig = getDeviceConfig(siteId, deviceId, pcsDevice, pcsSetting , null, 0); + DeviceConfig deviceConfig = getDeviceConfig(siteId, deviceId, pcsDevice, pcsSetting , null, 1); if (deviceConfig == null) { return; } @@ -428,7 +446,7 @@ public class StrategyPoller { return now.equals(startLocalTime) || (now.isAfter(startLocalTime) && now.isBefore(endLocalTime)); } - // 判断SOC上限和下限是否在范围内 + // 判断SOC上限和下限 private boolean isSocInRange(EmsStrategyTemp emsStrategyTemp) { BigDecimal socDown = SOC_DOWN; BigDecimal socUp = SOC_UP; @@ -438,9 +456,20 @@ public class StrategyPoller { } // 查询电池堆(BMSD) SOC EmsBatteryStack emsBatteryStack = emsBatteryStackMapper.getSiteSumStackInfo(emsStrategyTemp.getSiteId()); - if (emsBatteryStack != null && emsBatteryStack.getStackSoc() != null) { - return emsBatteryStack.getStackSoc().compareTo(socDown) > 0 && emsBatteryStack.getStackSoc().compareTo(socUp) < 0; + if (emsBatteryStack == null || emsBatteryStack.getStackSoc() == null) { + return true; } + + // 充电阶段判断SOC上限值 + if (ChargeStatus.CHARGING.getCode().equals(emsStrategyTemp.getChargeStatus()) && emsBatteryStack.getStackSoc().compareTo(socUp) >= 0) { + return false; + } + + // 放电阶段判断SOC下限值 + if (ChargeStatus.DISCHARGING.getCode().equals(emsStrategyTemp.getChargeStatus()) && emsBatteryStack.getStackSoc().compareTo(socDown) <= 0) { + return false; + } + return true; } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java index 229b60b..0105255 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/ProtectionSettingVo.java @@ -9,6 +9,9 @@ public class ProtectionSettingVo { /** 设备 */ private String deviceId; + /** 设备名称 */ + private String deviceName; + /** 点位 */ private String point; @@ -44,6 +47,14 @@ public class ProtectionSettingVo { this.deviceId = deviceId; } + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(String deviceName) { + this.deviceName = deviceName; + } + public String getPoint() { return point; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java index 7b6a7f3..f517c59 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPointEnumMatchMapper.java @@ -65,6 +65,6 @@ public interface EmsPointEnumMatchMapper public int deleteEmsPointEnumMatchByIds(Long[] ids); public List selectList(@Param("siteId") String siteId, - @Param("deviceCategory") String deviceCategory, - @Param("matchField") String matchField); + @Param("deviceCategory") String deviceCategory, + @Param("matchField") String matchField); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 2636fae..7e78490 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -622,8 +622,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 2. 处理枚举值转换 List pointEnumMatchList = pointEnumMatchMap.get(fieldName); - if (CollectionUtils.isNotEmpty(pointEnumMatchList)) { - Object finalMatchValue = matchValue; + if (CollectionUtils.isNotEmpty(pointEnumMatchList) && matchValue != null) { + String finalMatchValue = String.valueOf(matchValue).replace(".0", ""); Optional enumMatch = pointEnumMatchList.stream() .filter(data -> data.getDataEnumCode().equals(finalMatchValue)).findFirst(); if (enumMatch.isPresent()) { @@ -928,7 +928,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 点位匹配数据 List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, deviceId, DeviceMatchTable.CLUSTER.getCode()); if (CollectionUtils.isEmpty(pointMatchList)) { - log.info("未找到匹配的点位数据,无法处理LOAD总表数据,siteId: " + siteId + ",deviceId: " + deviceId); + log.info("未找到匹配的点位数据,无法处理电池簇数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.CLUSTER.getCode()); @@ -969,11 +969,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } private void saveDeviceWorkStatus(String deviceId, String siteId, String workStatus) { - if (StringUtils.isBlank(workStatus)) { + if (StringUtils.isEmpty(workStatus)) { return; } EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); - emsDevicesSetting.setWorkStatus(String.valueOf(new BigDecimal(workStatus).longValue())); + emsDevicesSetting.setWorkStatus(workStatus); emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); emsDevicesSettingMapper.updateEmsDevicesSetting(emsDevicesSetting); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java index 4d36540..22231a3 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsPointMatchServiceImpl.java @@ -250,7 +250,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { String pointEnumMatchKey = DevicePointMatchDataProcessor.getPointEnumMacthCacheKey(siteId, deviceCategory); List pointEnumMatchList = emsPointEnumMatchMapper.selectList(siteId, deviceCategory, null); if (!CollectionUtils.isEmpty(pointEnumMatchList)) { - if (redisCache.hasKey(pointEnumMatchKey)) { + if (Boolean.TRUE.equals(redisCache.hasKey(pointEnumMatchKey))) { redisCache.deleteObject(pointEnumMatchKey); } redisCache.setCacheList(pointEnumMatchKey, pointEnumMatchList); @@ -263,8 +263,14 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { if (StringUtils.isAllBlank(matchFieldEnum, dataEnum)) { return; } - List pointEnumMatchList = emsPointEnumMatchMapper.selectList(savePoint.getSiteId(), savePoint.getDeviceCategory(), savePoint.getMatchField()); + String siteId = savePoint.getSiteId(); + List pointEnumMatchList = emsPointEnumMatchMapper.selectList(siteId, savePoint.getDeviceCategory(), savePoint.getMatchField()); if (CollectionUtils.isEmpty(pointEnumMatchList)) { + siteId = SITE_ID; + pointEnumMatchList = emsPointEnumMatchMapper.selectList(siteId, savePoint.getDeviceCategory(), savePoint.getMatchField()); + } + if (CollectionUtils.isEmpty(pointEnumMatchList)) { + log.info("未查询到点位点位枚举匹配数据"); return; } String[] matchFieldEnums = matchFieldEnum.split(SEPARATOR); @@ -272,13 +278,21 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService { if (matchFieldEnums.length != dataEnums.length) { return; } + String finalSiteId = siteId; for (int i = 0; i < matchFieldEnums.length; i++) { String enumName = matchFieldEnums[i]; String dataEnumCode = dataEnums[i]; pointEnumMatchList.forEach(pointEnumMatch -> { if (pointEnumMatch.getEnumName().equals(enumName)) { pointEnumMatch.setDataEnumCode(dataEnumCode); - emsPointEnumMatchMapper.updateDataEnumCodeById(pointEnumMatch); + if (SITE_ID.equals(finalSiteId)) { + EmsPointEnumMatch insertPointEnumMatch = new EmsPointEnumMatch(); + BeanUtils.copyProperties(pointEnumMatch, insertPointEnumMatch); + insertPointEnumMatch.setSiteId(savePoint.getSiteId()); + emsPointEnumMatchMapper.insertEmsPointEnumMatch(insertPointEnumMatch); + } else { + emsPointEnumMatchMapper.updateDataEnumCodeById(pointEnumMatch); + } } }); } diff --git a/ems-system/src/main/resources/mapper/ems/EmsStrategyLogMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsStrategyLogMapper.xml index bcf1e0f..c78bdca 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsStrategyLogMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsStrategyLogMapper.xml @@ -35,11 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and template_id = #{templateId} and site_id = #{siteId} and device_id = #{deviceId} - and start_time = #{startTime} - and end_time = #{endTime} + and date_format(start_time, '%H:%i:%s') = date_format(#{startTime}, '%H:%i:%s') + and date_format(end_time, '%H:%i:%s') = date_format(#{endTime}, '%H:%i:%s') and charge_discharge_power = #{chargeDischargePower} and charge_status = #{chargeStatus} - and execution_date = #{executionDate} + and execution_date = date_format(#{executionDate}, '%Y-%m-%d') and anti_reverse = #{antiReverse} and power_down_type = #{powerDownType} @@ -132,8 +132,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and template_id = #{templateId} and site_id = #{siteId} and device_id = #{deviceId} - and start_time = #{startTime} - and end_time = #{endTime} + and start_time = date_format(#{startTime}, '%H:%i:%s') + and end_time = date_format(#{endTime}, '%H:%i:%s') and charge_discharge_power = #{chargeDischargePower} and charge_status = #{chargeStatus} and execution_date = #{executionDate} -- 2.49.0 From f05ba30f1486bf928dda7f623013b36acffaef71 Mon Sep 17 00:00:00 2001 From: zq Date: Thu, 15 Jan 2026 15:21:26 +0800 Subject: [PATCH 289/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=9B=91=E6=8E=A7-PCS=E5=AE=9E=E6=97=B6=E6=9C=89=E5=8A=9F?= =?UTF-8?q?=E5=8A=9F=E7=8E=87=E4=B8=8E=E6=80=BB=E4=BA=A4=E6=B5=81=E6=9C=89?= =?UTF-8?q?=E5=8A=9F=E5=8A=9F=E7=8E=87=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/ems/EmsPcsDataMapper.xml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index b6f0bba..ecdedb8 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -382,12 +382,14 @@ select t.data_date as dataTime, - t.peak_charge_diff * pc.peak as activePeakPrice, - t.peak_discharge_diff * pc.peak as reActivePeakPrice, - t.high_charge_diff * pc.high as activeHighPrice, - t.high_discharge_diff * pc.high as reActiveHighPrice, - t.flat_charge_diff * pc.flat as activeFlatPrice, - t.flat_discharge_diff * pc.flat as reActiveFlatPrice, - t.valley_charge_diff * pc.valley as activeValleyPrice, - t.valley_discharge_diff * pc.valley as reActiveValleyPrice + ROUND(t.peak_charge_diff * pc.peak, 3) as activePeakPrice, + ROUND(t.peak_discharge_diff * pc.peak, 3) as reActivePeakPrice, + ROUND(t.high_charge_diff * pc.high, 3) as activeHighPrice, + ROUND(t.high_discharge_diff * pc.high, 3) as reActiveHighPrice, + ROUND(t.flat_charge_diff * pc.flat, 3) as activeFlatPrice, + ROUND(t.flat_discharge_diff * pc.flat, 3) as reActiveFlatPrice, + ROUND(t.valley_charge_diff * pc.valley, 3) as activeValleyPrice, + ROUND(t.valley_discharge_diff * pc.valley, 3) as reActiveValleyPrice from ems_daily_energy_data t left join ( select -- 2.49.0 From 46ea4acc2c8f4bc100240221c578613f396eec70 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Thu, 22 Jan 2026 15:08:39 +0800 Subject: [PATCH 303/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=8D=E5=B1=95=E7=A4=BAdisplay=5Fflg=3D1=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/EmsSiteConfigController.java | 3 ++- .../xzzn/ems/mapper/EmsSiteSettingMapper.java | 3 +++ .../com/xzzn/ems/service/IEmsSiteService.java | 2 ++ .../ems/service/impl/EmsSiteServiceImpl.java | 25 +++++++++++++++++++ .../mapper/ems/EmsSiteSettingMapper.xml | 18 +++++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) 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 d4104b0..aec2ad4 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 @@ -67,7 +67,8 @@ public class EmsSiteConfigController extends BaseController{ @RequestParam(value = "deviceCategory", required = false) String deviceCategory) { startPage(); - List list = iEmsSiteService.getAllDeviceList(siteId, deviceCategory); + List list = iEmsSiteService.getAllDeviceListNoDisp(siteId, deviceCategory); + return getDataTable(list); } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java index 931ff3d..5507928 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsSiteSettingMapper.java @@ -91,5 +91,8 @@ public interface EmsSiteSettingMapper */ public List getAllSiteDeviceList(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); + + public List getAllSiteDeviceListNoDisp(@Param("siteId") String siteId, @Param("deviceCategory") String deviceCategory); + public List getAllSiteId(); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java index ed853ac..298266f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/IEmsSiteService.java @@ -27,6 +27,8 @@ public interface IEmsSiteService public List getAllDeviceList(String siteId, String deviceCategory); + public List getAllDeviceListNoDisp(String siteId, String deviceCategory); + public List> getAllPcsInfo(String siteId); public List> getParentCategoryDeviceId(String siteId, String deviceCategory); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java index ea6ccde..1abb914 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsSiteServiceImpl.java @@ -99,6 +99,31 @@ public class EmsSiteServiceImpl implements IEmsSiteService return resultData; } + /** + * 获取设备列表 + * + * @param siteId + * @return + */ + @Override + public List getAllDeviceListNoDisp(String siteId, String deviceCategory) { + List resultData = emsSiteMapper.getAllSiteDeviceListNoDisp(siteId, deviceCategory); + if(resultData == null || resultData.size() == 0){ + return resultData; + } + for (SiteDeviceListVo siteDeviceListVo : resultData) { + String clusterId = siteDeviceListVo.getDeviceId(); + String category = siteDeviceListVo.getDeviceCategory(); + if(DeviceCategory.CLUSTER.getCode().equals(category)){ + // 获取该stack下面有多少单体电池 + List batteryDataList = redisCache.getCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); + siteDeviceListVo.setBatteryNum(batteryDataList == null ? 0 : batteryDataList.size()); + } + String categoryName = DeviceCategory.getInfoByCode(category); + siteDeviceListVo.setCategoryName(categoryName); + } + return resultData; + } /** * 根据site_id获取所有pcs * @param siteId diff --git a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml index 086ed2e..c7e0fa9 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsSiteSettingMapper.xml @@ -152,6 +152,24 @@ order by ed.device_id + -- 2.49.0 From 7f025be41b2a4fbbab0616ed16f36947fb7758bd Mon Sep 17 00:00:00 2001 From: zq Date: Thu, 22 Jan 2026 15:40:29 +0800 Subject: [PATCH 304/336] =?UTF-8?q?=E7=AB=99=E7=82=B9=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B1=95=E7=A4=BA=E5=AD=97=E6=AE=B5=EF=BC=9A?= =?UTF-8?q?=E6=98=A8=E6=97=A5=E5=85=85=E7=94=B5=E9=87=8F=E3=80=81=E6=98=A8?= =?UTF-8?q?=E6=97=A5=E6=94=BE=E7=94=B5=E9=87=8F=E3=80=81=E6=98=A8=E6=97=A5?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=94=B6=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/common/utils/DateUtils.java | 2 +- .../xzzn/ems/domain/vo/SiteMonitorHomeVo.java | 39 +++++++++++++++++++ .../impl/EmsEnergyPriceConfigServiceImpl.java | 35 +++++++++++------ .../service/impl/SingleSiteServiceImpl.java | 8 ++++ 4 files changed, 72 insertions(+), 12 deletions(-) diff --git a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java index 29725be..bfcd82d 100644 --- a/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java +++ b/ems-common/src/main/java/com/xzzn/common/utils/DateUtils.java @@ -416,7 +416,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils // 减去一天得到昨天 LocalDate yesterday = today.minusDays(1); // 定义日期格式化器 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYYMMDD); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YYYY_MM_DD); // 格式化并返回 return yesterday.format(formatter); } diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java index d7bcc6a..55dba0d 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/SiteMonitorHomeVo.java @@ -20,6 +20,16 @@ public class SiteMonitorHomeVo { */ private BigDecimal dayDisChargedCap; + /** + * 昨日充电量 + */ + private BigDecimal yesterdayChargedCap; + + /** + * 昨日放电量 + */ + private BigDecimal yesterdayDisChargedCap; + /** * 总充电量 */ @@ -75,6 +85,11 @@ public class SiteMonitorHomeVo { */ private BigDecimal dayRevenue; + /** + * 昨日实时收入 + */ + private BigDecimal yesterdayRevenue; + public BigDecimal getTotalRevenue() { return totalRevenue; } @@ -91,6 +106,14 @@ public class SiteMonitorHomeVo { this.dayRevenue = dayRevenue; } + public BigDecimal getYesterdayRevenue() { + return yesterdayRevenue; + } + + public void setYesterdayRevenue(BigDecimal yesterdayRevenue) { + this.yesterdayRevenue = yesterdayRevenue; + } + public BigDecimal getDayChargedCap() { return dayChargedCap; } @@ -107,6 +130,22 @@ public class SiteMonitorHomeVo { this.dayDisChargedCap = dayDisChargedCap; } + public BigDecimal getYesterdayChargedCap() { + return yesterdayChargedCap; + } + + public void setYesterdayChargedCap(BigDecimal yesterdayChargedCap) { + this.yesterdayChargedCap = yesterdayChargedCap; + } + + public BigDecimal getYesterdayDisChargedCap() { + return yesterdayDisChargedCap; + } + + public void setYesterdayDisChargedCap(BigDecimal yesterdayDisChargedCap) { + this.yesterdayDisChargedCap = yesterdayDisChargedCap; + } + public BigDecimal getTotalChargedCap() { return totalChargedCap; } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java index f6b179c..682282a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsEnergyPriceConfigServiceImpl.java @@ -1,29 +1,33 @@ package com.xzzn.ems.service.impl; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.time.LocalDate; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - import com.xzzn.common.constant.RedisKeyConstants; import com.xzzn.common.core.redis.RedisCache; import com.xzzn.common.utils.DateUtils; import com.xzzn.common.utils.StringUtils; import com.xzzn.ems.domain.EmsDailyEnergyData; +import com.xzzn.ems.domain.EmsEnergyPriceConfig; import com.xzzn.ems.domain.EmsPriceTimeConfig; import com.xzzn.ems.domain.vo.EnergyPriceTimeRange; import com.xzzn.ems.domain.vo.EnergyPriceVo; import com.xzzn.ems.mapper.EmsDailyEnergyDataMapper; +import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper; import com.xzzn.ems.mapper.EmsPriceTimeConfigMapper; -import com.xzzn.ems.mapper.EmsSiteSettingMapper; +import com.xzzn.ems.service.IEmsEnergyPriceConfigService; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.xzzn.ems.mapper.EmsEnergyPriceConfigMapper; -import com.xzzn.ems.domain.EmsEnergyPriceConfig; -import com.xzzn.ems.service.IEmsEnergyPriceConfigService; /** * 电价配置Service业务层处理 @@ -274,6 +278,14 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer // 默认0 BigDecimal totalRevenue = BigDecimal.ZERO; BigDecimal dayRevenue = BigDecimal.ZERO; + BigDecimal yesterdayRevenue = BigDecimal.ZERO; + // 获取昨日数据 + String yesterday = DateUtils.getYesterdayDayString(); + EmsDailyEnergyData yesterdayData = emsDailyEnergyDataMapper.getDataByDate(siteId, yesterday); + if (yesterdayData != null) { + yesterdayRevenue = yesterdayData.getDayRevenue() == null ? BigDecimal.ZERO : yesterdayData.getDayRevenue(); + } + // 当日实时数据 String today = DateUtils.getDate(); EmsDailyEnergyData todayData = emsDailyEnergyDataMapper.getDataByDate(siteId,today); @@ -304,6 +316,7 @@ public class EmsEnergyPriceConfigServiceImpl implements IEmsEnergyPriceConfigSer } currentDayRevenue.put("totalRevenue", totalRevenue); currentDayRevenue.put("dayRevenue", dayRevenue); + currentDayRevenue.put("yesterdayRevenue", yesterdayRevenue); return currentDayRevenue; } } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 645a698..b758498 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -122,6 +122,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { dayRevenueMap.get("totalRevenue") == null ? BigDecimal.ZERO : dayRevenueMap.get("totalRevenue")); siteMonitorHomeVo.setDayRevenue( dayRevenueMap.get("dayRevenue") == null ? BigDecimal.ZERO :dayRevenueMap.get("dayRevenue")); + siteMonitorHomeVo.setYesterdayRevenue( + dayRevenueMap.get("yesterdayRevenue") == null ? BigDecimal.ZERO :dayRevenueMap.get("yesterdayRevenue")); // 实时告警数据 名称+状态+告警内容 List siteMonitorHomeAlarmVo = emsAlarmRecordsMapper.getAlarmRecordsBySiteId(siteId); @@ -152,6 +154,12 @@ public class SingleSiteServiceImpl implements ISingleSiteService { siteMonitorHomeVo.setDayChargedCap(sitePcsData.getChargedCap()); siteMonitorHomeVo.setDayDisChargedCap(sitePcsData.getDisChargedCap()); } + // 获取昨日充电量+放电量 + if (DateUtils.getYesterdayDayString().equals(pcsDate)) { + siteMonitorHomeVo.setYesterdayChargedCap(sitePcsData.getChargedCap()); + siteMonitorHomeVo.setYesterdayDisChargedCap(sitePcsData.getDisChargedCap()); + } + } // 储能可用电量 BigDecimal energyStorageAvailElec = siteMonitorHomeVo.getTotalDischargedCap().subtract(siteMonitorHomeVo.getTotalChargedCap()); -- 2.49.0 From f592b709a7ed9b87d7e97ee776269a324929b088 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Thu, 22 Jan 2026 16:06:52 +0800 Subject: [PATCH 305/336] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index ecdedb8..d428739 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -398,7 +398,7 @@ AND latest.max_update_time = t.data_update_time AND t.site_id = #{siteId} ) AS pd - WHERE rn = 1; + WHERE rn = 1 @@ -44,6 +45,7 @@ and device_id = #{deviceId} and cluster_device_id = #{clusterDeviceId} and inter_resistance = #{interResistance} + and current = #{current} @@ -72,6 +74,7 @@ device_id, cluster_device_id, inter_resistance, + current, #{batteryPack}, @@ -91,6 +94,7 @@ #{deviceId}, #{clusterDeviceId}, #{interResistance}, + #{current}, @@ -114,6 +118,7 @@ device_id = #{deviceId}, cluster_device_id = #{clusterDeviceId}, inter_resistance = #{interResistance}, + current = #{current}, where id = #{id} @@ -214,7 +219,7 @@ #{item.batteryPack}, #{item.batteryCluster}, #{item.batteryCellId}, #{item.voltage}, #{item.temperature}, #{item.soc}, #{item.soh}, #{item.dataTimestamp}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, - #{item.remark}, #{item.siteId}, #{item.deviceId}, #{item.clusterDeviceId},#{item.interResistance} + #{item.remark}, #{item.siteId}, #{item.deviceId}, #{item.clusterDeviceId},#{item.interResistance},#{item.current} ) -- 2.49.0 From 768dd0beadab8bb4a05ac4ddd3c636a98e107fd5 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 23 Jan 2026 15:29:44 +0800 Subject: [PATCH 310/336] =?UTF-8?q?=E7=94=B5=E8=A1=A8=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=85=B6=E4=BB=96=E7=B1=BB=E5=9E=8B=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=80=BC=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index b758498..15f6a75 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -746,7 +746,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private void dealAmmeterData(EmsAmmeterData ammeterData, AmmeterDataVo ammeterDataVo) { if (ammeterData != null) { - ammeterDataVo.setActivePower(ammeterData.getTotalActivePower()); + ammeterDataVo.setActivePower(ammeterData.getTotalActivePower() == null ? ammeterData.getPower() : ammeterData.getTotalActivePower()); ammeterDataVo.setReactivePower(ammeterData.getTotalReactivePower()); ammeterDataVo.setForwardActive(ammeterData.getCurrentForwardActiveTotal()); ammeterDataVo.setForwardReactive(ammeterData.getCurrentForwardReactiveTotal()); -- 2.49.0 From c0070162247fd610af0ff2a65245c81fb079ade1 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 23 Jan 2026 15:30:07 +0800 Subject: [PATCH 311/336] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8C=89=E6=97=B6=E9=97=B4=E5=80=92=E5=BA=8F=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml index dfaf614..5450ba4 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsAlarmRecordsMapper.xml @@ -176,6 +176,7 @@ AND (date_format(t.alarm_start_time,'%Y%m%d') BETWEEN date_format(#{alarmStartTime},'%Y%m%d') and date_format(#{alarmEndTime},'%Y%m%d') or date_format(t.alarm_end_time,'%Y%m%d') BETWEEN date_format(#{alarmStartTime},'%Y%m%d') and date_format(#{alarmEndTime},'%Y%m%d') )
+ order by t.alarm_start_time desc -- 2.49.0 From b3f7ca7a816a1deeed975fa53edb494e68475e2e Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 23 Jan 2026 19:11:13 +0800 Subject: [PATCH 313/336] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=9B=91=E6=8E=A7-?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E8=BF=90=E8=A1=8C=E9=A1=B5=E9=9D=A2=E6=9B=B2?= =?UTF-8?q?=E7=BA=BF=E6=8C=89=E7=85=A7=E6=AF=8F=E5=88=86=E9=92=9F=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ems/domain/vo/EnergyStoragePowVo.java | 11 ++- .../com/xzzn/ems/mapper/EmsPcsDataMapper.java | 2 + .../service/impl/SingleSiteServiceImpl.java | 45 +++++++----- .../mapper/ems/EmsBatteryClusterMapper.xml | 33 ++++++--- .../mapper/ems/EmsBatteryStackMapper.xml | 63 ++++++++++------ .../resources/mapper/ems/EmsPcsDataMapper.xml | 73 ++++++++++++++----- 6 files changed, 153 insertions(+), 74 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java index 0512662..16c3162 100644 --- a/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java +++ b/ems-system/src/main/java/com/xzzn/ems/domain/vo/EnergyStoragePowVo.java @@ -1,7 +1,6 @@ package com.xzzn.ems.domain.vo; import java.math.BigDecimal; -import java.util.Date; /** * 实时运行-有功无功功率数据 @@ -31,6 +30,8 @@ public class EnergyStoragePowVo { private String deviceId; + private String groupTime; + public String getDeviceId() { return deviceId; } @@ -67,6 +68,14 @@ public class EnergyStoragePowVo { this.dateDay = dateDay; } + public String getGroupTime() { + return groupTime; + } + + public void setGroupTime(String groupTime) { + this.groupTime = groupTime; + } + public void setPcsTotalReactivePower(BigDecimal pcsTotalReactivePower) { this.pcsTotalReactivePower = pcsTotalReactivePower; } diff --git a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java index bd9ccf6..4c33796 100644 --- a/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java +++ b/ems-system/src/main/java/com/xzzn/ems/mapper/EmsPcsDataMapper.java @@ -140,4 +140,6 @@ public interface EmsPcsDataMapper public List getFXMaxTemp(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); // 实时运行-dds-pcs最高温度 public List getDDSMaxTemp(@Param("siteId")String siteId, @Param("startDate")Date startDate, @Param("endDate")Date endDate); + + List getPcsMaxTemp(@Param("siteId") String siteId, @Param("startDate") Date startDate, @Param("endDate") Date endDate); } diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 15f6a75..4041379 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -238,13 +238,13 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return pcdData; }).collect(Collectors.toList()); -// // 生成时间列表(每分钟一个) -// List targetMinutes = new ArrayList<>(60); -// LocalDateTime startDate = DateUtils.toLocalDateTime(yesterday).truncatedTo(ChronoUnit.DAYS); -// LocalDateTime endDate = DateUtils.toLocalDateTime(today); -// while (startDate.isBefore(endDate)) { -// targetMinutes.add(startDate); -// startDate = startDate.plusMinutes(1); // 递增1分钟 +// // 生成时间列表(每5分钟一个) +// List targetMinutes = new ArrayList<>(12); +// LocalDateTime startLocalDate = DateUtils.toLocalDateTime(startDate).truncatedTo(ChronoUnit.DAYS); +// LocalDateTime endLocalDate = DateUtils.toLocalDateTime(endDate).with(LocalDateTime.now().toLocalTime()); +// while (startLocalDate.isBefore(endLocalDate)) { +// targetMinutes.add(startLocalDate); +// startLocalDate = startLocalDate.plusMinutes(5); // 递增5分钟 // } // // 根据时间列表填充数据 // pcsPowerList = fullFillData(pcsPowerList, targetMinutes); @@ -254,6 +254,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { return siteMonitorRuningInfoVo; } + private List fullFillData(List pcsPowerList, List targetMinutes) { List resultList = new ArrayList<>(); @@ -269,7 +270,7 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 将数据转Map便于后续根据时间获取 dataMap = powerList.stream().collect( Collectors.toMap( - data -> data.getCreateDate(), + data -> data.getGroupTime(), data -> data, (existing, replacement) -> replacement )); @@ -293,7 +294,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { currentData.setDeviceId(deviceId); } lastData = currentData; - currentData.setCreateDate(currentDate.substring(11)); +// currentData.setCreateDate(currentDate.substring(11)); + currentData.setCreateDate(currentData.getCreateDate()); resultPowerList.add(currentData); } pcsResultPower.setDeviceId(deviceId); @@ -316,12 +318,12 @@ public class SingleSiteServiceImpl implements ISingleSiteService { Date startDate = request.getStartDate(); Date endDate = request.getEndDate(); //PCS最高温度list - List pcsMaxTempVos = new ArrayList<>(); - if (SiteEnum.FX.getCode().equals(siteId)) { - pcsMaxTempVos = emsPcsDataMapper.getFXMaxTemp(siteId, startDate, endDate); - } else if (SiteEnum.DDS.getCode().equals(siteId)) { - pcsMaxTempVos = emsPcsDataMapper.getDDSMaxTemp(siteId, startDate, endDate); - } + List pcsMaxTempVos = emsPcsDataMapper.getPcsMaxTemp(siteId, startDate, endDate); +// if (SiteEnum.FX.getCode().equals(siteId)) { +// pcsMaxTempVos = emsPcsDataMapper.getFXMaxTemp(siteId, startDate, endDate); +// } else if (SiteEnum.DDS.getCode().equals(siteId)) { +// pcsMaxTempVos = emsPcsDataMapper.getDDSMaxTemp(siteId, startDate, endDate); +// } // List -> 按pcs的deviceId分组转成List if (!CollectionUtils.isEmpty(pcsMaxTempVos)) { @@ -427,13 +429,18 @@ public class SingleSiteServiceImpl implements ISingleSiteService { String siteId = request.getSiteId(); Date startDate = request.getStartDate(); Date endDate = request.getEndDate(); - //电池平均温度list + //电池平均温度list,优先从电池堆取,电池堆没有的话再从电池簇取 List batteryAveTempList = new ArrayList<>(); - if (SiteEnum.FX.getCode().equals(siteId)) { + batteryAveTempList = emsBatteryStackMapper.getBatteryAveTempList(siteId, startDate, endDate); + // 电池堆暂无数据,从电池簇取 + if (CollectionUtils.isEmpty(batteryAveTempList)) { batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, startDate, endDate); - } else if (SiteEnum.DDS.getCode().equals(siteId)) { - batteryAveTempList = emsBatteryStackMapper.getBatteryAveTempList(siteId, startDate, endDate); } +// if (SiteEnum.FX.getCode().equals(siteId)) { +// batteryAveTempList = emsBatteryClusterMapper.getBatteryAveTempList(siteId, startDate, endDate); +// } else if (SiteEnum.DDS.getCode().equals(siteId)) { +// batteryAveTempList = emsBatteryStackMapper.getBatteryAveTempList(siteId, startDate, endDate); +// } siteMonitorRuningInfoVo.setBatteryAveTempList(batteryAveTempList); // if (!StringUtils.isEmpty(siteId)) { // // 时间暂定今日+昨日 diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index e64219f..d1e2464 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -331,18 +331,27 @@ diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index d6b8d72..647deaf 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -351,18 +351,27 @@ @@ -501,15 +510,25 @@ \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index db832e3..12cd76f 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -469,30 +469,30 @@ order by ammeterDate desc - WITH ranked AS ( - SELECT - *, - ROW_NUMBER() OVER(PARTITION BY device_id , DATE_FORMAT(data_update_time, '%Y-%m-%d %H:%i') ORDER BY data_update_time DESC) as rn - FROM - ems_pcs_data - where site_id = #{siteId} - and data_update_time >= #{startDate} - AND data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) + SELECT + *, + date_format(data_update_time, '%Y-%m-%d %H:00:00') + INTERVAL FLOOR(MINUTE(data_update_time) / 5) * 5 MINUTE AS group_time, + ROW_NUMBER() OVER (PARTITION BY device_id, date_format(data_update_time, '%Y-%m-%d %H:00:00'), FLOOR(MINUTE(data_update_time) / 5) ORDER BY data_update_time) as rn + FROM + ems_pcs_data + where site_id = #{siteId} + and data_update_time >= #{startDate} + and data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY) ) - select - site_id, - device_id as deviceId, - total_active_power as pcsTotalActPower, - total_reactive_power as pcsTotalReactivePower, - DATE_FORMAT(create_time, '%Y-%m-%d') as dateDay, - DATE_FORMAT(data_update_time, '%H:%i:00') as createDate - from + SELECT + site_id, + device_id as deviceId, + total_active_power as pcsTotalActPower, + total_reactive_power as pcsTotalReactivePower, + DATE_FORMAT(group_time, '%Y-%m-%d') as dateDay, + DATE_FORMAT(group_time, '%H:%i:00') as createDate, + group_time as groupTime + FROM ranked - where + WHERE rn = 1 - GROUP BY site_id, deviceId,pcsTotalActPower,pcsTotalReactivePower,dateDay,createDate - ORDER BY dateDay,createDate + + \ No newline at end of file -- 2.49.0 From 194429af2d7028115373350f23803340e479ebb1 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 23 Jan 2026 19:29:24 +0800 Subject: [PATCH 314/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java | 3 +++ .../com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index dbf3de8..ce08e73 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -605,6 +605,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i */ private void saveDeviceData(List pointMatchList, Map obj, Object entity, Map> pointEnumMatchMap) { + if (null == obj || obj.isEmpty()) { + return; + } Map pointMatchMap = pointMatchList.stream() .collect(Collectors.toMap( data -> StringUtils.toCamelCase(data.getMatchField()), // 源字段名转为驼峰 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java index 5105ca1..21b523f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/EmsStatsReportServiceImpl.java @@ -351,7 +351,7 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService resultList.forEach(ammeterRevenue -> { ammeterRevenue.setActiveTotalPrice(ammeterRevenue.getActivePeakPrice().add(ammeterRevenue.getActiveHighPrice()).add(ammeterRevenue.getActiveFlatPrice()).add(ammeterRevenue.getActiveValleyPrice())); ammeterRevenue.setReActiveTotalPrice(ammeterRevenue.getReActivePeakPrice().add(ammeterRevenue.getReActiveHighPrice()).add(ammeterRevenue.getReActiveFlatPrice()).add(ammeterRevenue.getReActiveValleyPrice())); - ammeterRevenue.setActualRevenue(ammeterRevenue.getReActiveFlatPrice().subtract(ammeterRevenue.getActiveTotalPrice())); + ammeterRevenue.setActualRevenue(ammeterRevenue.getReActiveTotalPrice().subtract(ammeterRevenue.getActiveTotalPrice())); }); return resultList; -- 2.49.0 From 084201bb587af659b6610998bc84956b6a8aa1a7 Mon Sep 17 00:00:00 2001 From: zq Date: Fri, 23 Jan 2026 19:43:48 +0800 Subject: [PATCH 315/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ems/EmsPointMatchMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index 77af028..ef966be 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -191,7 +191,7 @@ and t.device_category = #{deviceCategory}
- and t.point_name = #{pointName} + and t.point_name like concat('%', #{pointName}, '%') -- 2.49.0 From 5f7604d36b0cabd20b064ae413c05adf7c3f0446 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Fri, 23 Jan 2026 20:16:05 +0800 Subject: [PATCH 316/336] =?UTF-8?q?=E5=8A=A0=E4=BA=86=E6=97=A5=E5=BF=97?= =?UTF-8?q?=EF=BC=8Cdevice=5Fid=E6=94=B9=E6=88=90=20device=5Fid+cluster=5F?= =?UTF-8?q?id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDataProcessServiceImpl.java | 107 ++++++++++++++---- 1 file changed, 88 insertions(+), 19 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index ce08e73..3af54d1 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -153,7 +153,10 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i @Override public void handleDeviceData(String message, String siteId) { + log.info("=== handleDeviceData 开始 === siteId:{}, message length:{}", siteId, message != null ? message.length() : 0); + JSONArray arraylist = JSONArray.parseArray(message); + log.info("解析到{}条设备数据", arraylist.size()); for (int i = 0; i < arraylist.size(); i++) { JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); @@ -163,10 +166,13 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i Long timestamp = obj.getLong("timestamp"); Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); - log.info("deviceId:" + deviceId); + log.info("处理第{}条设备数据 - deviceId:{}, timestamp:{}, dataUpdateTime:{}, jsonData length:{}", + i + 1, deviceId, timestamp, dataUpdateTime, jsonData != null ? jsonData.length() : 0); + boolean isEmpty = checkJsonDataEmpty(jsonData); if (isEmpty) { // 添加设备告警 + log.warn("设备数据为空 - deviceId:{}", deviceId); iEmsAlarmRecordsService.addEmptyDataAlarmRecord(siteId, deviceId); return; } @@ -184,11 +190,17 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i public void processingDeviceData(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { // 判断设备类型,并调用对应的方法处理数据 String deviceCategory = getDeviceCategory(siteId, deviceId); + log.info("processingDeviceData - siteId:{}, deviceId:{}, deviceCategory:{}", siteId, deviceId, deviceCategory); + if (deviceId.contains(SiteDevice.BMSD.name())) { + log.info("设备类型是BMSD"); batteryStackDataProcess(siteId, deviceId, jsonData, dataUpdateTime); if (SiteEnum.DDS.getCode().equals(siteId)) { + log.info("siteId是DDS,调用batteryGroupDataProcess和batteryDataProcessFromBmsd"); batteryGroupDataProcess(siteId, deviceId, jsonData); batteryDataProcessFromBmsd(siteId, deviceId, jsonData, dataUpdateTime); + } else { + log.info("siteId不是DDS (期望:{}, 实际:{}),跳过batteryDataProcessFromBmsd", SiteEnum.DDS.getCode(), siteId); } } else if (deviceId.contains(SiteDevice.BMSC.name())) { batteryClusterDataProcess(siteId, deviceId, jsonData, dataUpdateTime); @@ -441,12 +453,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } private void batteryDataProcessFromBmsd(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { -// if (!SiteEnum.DDS.getCode().equals(siteId)) { -// return; -// } - //电池组 + log.info("=== batteryDataProcessFromBmsd 开始 === siteId:{}, deviceId:{}", siteId, deviceId); + Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); + log.info("解析后的数据键数量:{}", obj.size()); + List dataList = new ArrayList<>(); // 前一个小时 @@ -459,32 +471,51 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i Map minutesMap = new HashMap<>(); String clusterId = getClusterDeviceIdByParentDeviceId(siteId, deviceId); + log.info("clusterId:{}", clusterId); + + int dtdcCount = 0; + int matchedCount = 0; + for (Map.Entry entry : obj.entrySet()) { String key = entry.getKey(); if (key.startsWith("DTDC")) { + dtdcCount++; Matcher matcher = DTDC_PATTERN.matcher(key); if (matcher.matches()) { + matchedCount++; String batteryCellId = matcher.group(1); String property = matcher.group(2); + Object value = entry.getValue(); - EmsBatteryData data = dataMap.getOrDefault(batteryCellId, new EmsBatteryData()); - if (StringUtils.isNotEmpty(batteryCellId)) { - data.setDataTimestamp(dataUpdateTime); - data.setBatteryPack(deviceId); - data.setBatteryCluster(clusterId); - data.setClusterDeviceId(clusterId); - data.setBatteryCellId(batteryCellId); - data.setSiteId(siteId); - data.setDeviceId(batteryCellId); - data.setCreateBy("system"); - data.setCreateTime(DateUtils.getNowDate()); - data.setUpdateBy("system"); - data.setUpdateTime(DateUtils.getNowDate()); + log.info("匹配到DTDC数据 - key:{}, batteryCellId:{}, property:{}, value:{}, value type:{}", + key, batteryCellId, property, value, value != null ? value.getClass().getName() : "null"); + + EmsBatteryData data = dataMap.get(batteryCellId); + boolean isNew = (data == null); + if (isNew) { + data = new EmsBatteryData(); + if (StringUtils.isNotEmpty(batteryCellId)) { + data.setDataTimestamp(dataUpdateTime); + data.setBatteryPack(deviceId); + data.setBatteryCluster(clusterId); + data.setClusterDeviceId(clusterId); + data.setBatteryCellId(batteryCellId); + data.setSiteId(siteId); + data.setDeviceId(batteryCellId+clusterId); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); + } + dataMap.put(batteryCellId, data); + log.info("创建新的电池数据对象 - batteryCellId:{}", batteryCellId); + } else { + log.info("使用已有的电池数据对象 - batteryCellId:{}", batteryCellId); } + // 根据后缀设置对应属性 setDTDCPropertyValue(data, property, entry.getValue()); - dataMap.put(batteryCellId, data); // 每日最新数据:按batteryCellId去重 EmsBatteryDataDailyLatest daily = dailyMap.getOrDefault(batteryCellId, new EmsBatteryDataDailyLatest()); @@ -499,9 +530,23 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } } } + + log.info("=== DTDC数据处理完成 === DTDC键数量:{}, 成功匹配数量:{}, 最终电池数据数量:{}", + dtdcCount, matchedCount, dataMap.size()); + if (!CollectionUtils.sizeIsEmpty(dataMap)) { dataList = new ArrayList<>(dataMap.values()); + + // 打印前5条数据用于调试 + int printCount = Math.min(5, dataList.size()); + for (int i = 0; i < printCount; i++) { + EmsBatteryData data = dataList.get(i); + log.info("准备插入的第{}条数据 - batteryCellId:{}, voltage:{}, temperature:{}, interResistance:{}", + i + 1, data.getBatteryCellId(), data.getVoltage(), data.getTemperature(), data.getInterResistance()); + } + emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList)); + log.info("成功插入{}条电池数据", dataList.size()); redisCache.deleteList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); redisCache.setCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId, dataList); @@ -549,20 +594,44 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i private void setDTDCPropertyValue(EmsBatteryData data, String property, Object value) { BigDecimal numberValue = null; + + log.info("setDTDCPropertyValue 开始 - property:{}, value:{}, value type:{}", + property, value, value != null ? value.getClass().getName() : "null"); + if (value instanceof Number) { numberValue = new BigDecimal(value.toString()); + log.info("值是Number类型,转换为BigDecimal: {}", numberValue); + } else if (value != null) { + log.warn("值不是Number类型,尝试从字符串转换。Value: {}, type: {}", value, value.getClass().getName()); + try { + numberValue = new BigDecimal(value.toString()); + log.info("成功从字符串转换为BigDecimal: {}", numberValue); + } catch (Exception e) { + log.error("无法将值转换为BigDecimal: {}", value, e); + } + } else { + log.warn("值为null"); } + switch (property) { case "DY": data.setVoltage(numberValue); + log.info("设置 voltage: {}", numberValue); break; case "WD": data.setTemperature(numberValue); + log.info("设置 temperature: {}", numberValue); break; case "NZ": data.setInterResistance(numberValue); + log.info("设置 interResistance: {}", numberValue); break; + default: + log.warn("未知的属性类型: {}", property); } + + log.info("setDTDCPropertyValue 结束 - 当前对象状态 voltage:{}, temperature:{}, interResistance:{}", + data.getVoltage(), data.getTemperature(), data.getInterResistance()); } //根据属性名设置对应的值 -- 2.49.0 From 034c682864f82128ccb401996f1d1d088d53fe4a Mon Sep 17 00:00:00 2001 From: dashixiong Date: Fri, 23 Jan 2026 21:05:07 +0800 Subject: [PATCH 317/336] =?UTF-8?q?batteryDataProcessFromBmsc=E6=96=B9?= =?UTF-8?q?=E6=B3=95device=5Fid=E6=94=B9=E6=88=90=20device=5Fid+cluster=5F?= =?UTF-8?q?id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 3af54d1..70593bd 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -805,7 +805,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } EmsBatteryData batteryData = new EmsBatteryData(); - batteryData.setDeviceId(recordId); + batteryData.setDeviceId(recordId+deviceId); batteryData.setBatteryCellId(recordId); saveDeviceData(pointMatchList, fields, batteryData, pointEnumMatchMap); -- 2.49.0 From c518b9bcaef85983e424d8542f220ec41916c367 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Fri, 23 Jan 2026 23:09:31 +0800 Subject: [PATCH 318/336] =?UTF-8?q?mqtt=E8=BD=AC=E7=A7=BB=E5=88=B0?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=EF=BC=8C=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E7=94=B1=E7=94=B5=E5=8A=A8=E6=89=80=E7=9A=84=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=20mqtt=20=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ems-admin/src/main/resources/application-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-admin/src/main/resources/application-prod.yml b/ems-admin/src/main/resources/application-prod.yml index fee9ed4..3c97d98 100644 --- a/ems-admin/src/main/resources/application-prod.yml +++ b/ems-admin/src/main/resources/application-prod.yml @@ -187,7 +187,7 @@ xss: urlPatterns: /system/*,/monitor/*,/tool/* mqtt: - broker.url: tcp://121.5.164.6:1883 + broker.url: tcp://122.51.194.184:1883 client.id: ems-cloud username: dmbroker password: qwer1234 -- 2.49.0 From 83fae710fbdd66cc7e7ea6b4e3cd6f08db6a5364 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Fri, 23 Jan 2026 23:46:46 +0800 Subject: [PATCH 319/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=8F=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index 70593bd..c53640b 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -155,7 +155,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i public void handleDeviceData(String message, String siteId) { log.info("=== handleDeviceData 开始 === siteId:{}, message length:{}", siteId, message != null ? message.length() : 0); - JSONArray arraylist = JSONArray.parseArray(message); + JSONArray arraylist = (JSONArray) JSON.parse(message); log.info("解析到{}条设备数据", arraylist.size()); for (int i = 0; i < arraylist.size(); i++) { -- 2.49.0 From 6ae912666256b702fbb30085c23ee702aba94359 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Sat, 24 Jan 2026 00:20:27 +0800 Subject: [PATCH 320/336] =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E5=88=B0=2019?= =?UTF-8?q?=EF=BC=9A29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDataProcessServiceImpl.java | 111 ++++-------------- 1 file changed, 21 insertions(+), 90 deletions(-) diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index c53640b..ce08e73 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -153,10 +153,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i @Override public void handleDeviceData(String message, String siteId) { - log.info("=== handleDeviceData 开始 === siteId:{}, message length:{}", siteId, message != null ? message.length() : 0); - - JSONArray arraylist = (JSONArray) JSON.parse(message); - log.info("解析到{}条设备数据", arraylist.size()); + JSONArray arraylist = JSONArray.parseArray(message); for (int i = 0; i < arraylist.size(); i++) { JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); @@ -166,13 +163,10 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i Long timestamp = obj.getLong("timestamp"); Date dataUpdateTime = DateUtils.convertUpdateTime(timestamp); - log.info("处理第{}条设备数据 - deviceId:{}, timestamp:{}, dataUpdateTime:{}, jsonData length:{}", - i + 1, deviceId, timestamp, dataUpdateTime, jsonData != null ? jsonData.length() : 0); - + log.info("deviceId:" + deviceId); boolean isEmpty = checkJsonDataEmpty(jsonData); if (isEmpty) { // 添加设备告警 - log.warn("设备数据为空 - deviceId:{}", deviceId); iEmsAlarmRecordsService.addEmptyDataAlarmRecord(siteId, deviceId); return; } @@ -190,17 +184,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i public void processingDeviceData(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { // 判断设备类型,并调用对应的方法处理数据 String deviceCategory = getDeviceCategory(siteId, deviceId); - log.info("processingDeviceData - siteId:{}, deviceId:{}, deviceCategory:{}", siteId, deviceId, deviceCategory); - if (deviceId.contains(SiteDevice.BMSD.name())) { - log.info("设备类型是BMSD"); batteryStackDataProcess(siteId, deviceId, jsonData, dataUpdateTime); if (SiteEnum.DDS.getCode().equals(siteId)) { - log.info("siteId是DDS,调用batteryGroupDataProcess和batteryDataProcessFromBmsd"); batteryGroupDataProcess(siteId, deviceId, jsonData); batteryDataProcessFromBmsd(siteId, deviceId, jsonData, dataUpdateTime); - } else { - log.info("siteId不是DDS (期望:{}, 实际:{}),跳过batteryDataProcessFromBmsd", SiteEnum.DDS.getCode(), siteId); } } else if (deviceId.contains(SiteDevice.BMSC.name())) { batteryClusterDataProcess(siteId, deviceId, jsonData, dataUpdateTime); @@ -453,12 +441,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } private void batteryDataProcessFromBmsd(String siteId, String deviceId, String dataJson, Date dataUpdateTime) { - log.info("=== batteryDataProcessFromBmsd 开始 === siteId:{}, deviceId:{}", siteId, deviceId); - +// if (!SiteEnum.DDS.getCode().equals(siteId)) { +// return; +// } + //电池组 Map obj = JSON.parseObject(dataJson, new TypeReference>() { }); - log.info("解析后的数据键数量:{}", obj.size()); - List dataList = new ArrayList<>(); // 前一个小时 @@ -471,51 +459,32 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i Map minutesMap = new HashMap<>(); String clusterId = getClusterDeviceIdByParentDeviceId(siteId, deviceId); - log.info("clusterId:{}", clusterId); - - int dtdcCount = 0; - int matchedCount = 0; - for (Map.Entry entry : obj.entrySet()) { String key = entry.getKey(); if (key.startsWith("DTDC")) { - dtdcCount++; Matcher matcher = DTDC_PATTERN.matcher(key); if (matcher.matches()) { - matchedCount++; String batteryCellId = matcher.group(1); String property = matcher.group(2); - Object value = entry.getValue(); - log.info("匹配到DTDC数据 - key:{}, batteryCellId:{}, property:{}, value:{}, value type:{}", - key, batteryCellId, property, value, value != null ? value.getClass().getName() : "null"); - - EmsBatteryData data = dataMap.get(batteryCellId); - boolean isNew = (data == null); - if (isNew) { - data = new EmsBatteryData(); - if (StringUtils.isNotEmpty(batteryCellId)) { - data.setDataTimestamp(dataUpdateTime); - data.setBatteryPack(deviceId); - data.setBatteryCluster(clusterId); - data.setClusterDeviceId(clusterId); - data.setBatteryCellId(batteryCellId); - data.setSiteId(siteId); - data.setDeviceId(batteryCellId+clusterId); - data.setCreateBy("system"); - data.setCreateTime(DateUtils.getNowDate()); - data.setUpdateBy("system"); - data.setUpdateTime(DateUtils.getNowDate()); - } - dataMap.put(batteryCellId, data); - log.info("创建新的电池数据对象 - batteryCellId:{}", batteryCellId); - } else { - log.info("使用已有的电池数据对象 - batteryCellId:{}", batteryCellId); + EmsBatteryData data = dataMap.getOrDefault(batteryCellId, new EmsBatteryData()); + if (StringUtils.isNotEmpty(batteryCellId)) { + data.setDataTimestamp(dataUpdateTime); + data.setBatteryPack(deviceId); + data.setBatteryCluster(clusterId); + data.setClusterDeviceId(clusterId); + data.setBatteryCellId(batteryCellId); + data.setSiteId(siteId); + data.setDeviceId(batteryCellId); + data.setCreateBy("system"); + data.setCreateTime(DateUtils.getNowDate()); + data.setUpdateBy("system"); + data.setUpdateTime(DateUtils.getNowDate()); } - // 根据后缀设置对应属性 setDTDCPropertyValue(data, property, entry.getValue()); + dataMap.put(batteryCellId, data); // 每日最新数据:按batteryCellId去重 EmsBatteryDataDailyLatest daily = dailyMap.getOrDefault(batteryCellId, new EmsBatteryDataDailyLatest()); @@ -530,23 +499,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } } } - - log.info("=== DTDC数据处理完成 === DTDC键数量:{}, 成功匹配数量:{}, 最终电池数据数量:{}", - dtdcCount, matchedCount, dataMap.size()); - if (!CollectionUtils.sizeIsEmpty(dataMap)) { dataList = new ArrayList<>(dataMap.values()); - - // 打印前5条数据用于调试 - int printCount = Math.min(5, dataList.size()); - for (int i = 0; i < printCount; i++) { - EmsBatteryData data = dataList.get(i); - log.info("准备插入的第{}条数据 - batteryCellId:{}, voltage:{}, temperature:{}, interResistance:{}", - i + 1, data.getBatteryCellId(), data.getVoltage(), data.getTemperature(), data.getInterResistance()); - } - emsBatteryDataMapper.insertEmsBatteryDataList(new ArrayList<>(dataList)); - log.info("成功插入{}条电池数据", dataList.size()); redisCache.deleteList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId); redisCache.setCacheList(RedisKeyConstants.BATTERY + siteId + "_" + clusterId, dataList); @@ -594,44 +549,20 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i private void setDTDCPropertyValue(EmsBatteryData data, String property, Object value) { BigDecimal numberValue = null; - - log.info("setDTDCPropertyValue 开始 - property:{}, value:{}, value type:{}", - property, value, value != null ? value.getClass().getName() : "null"); - if (value instanceof Number) { numberValue = new BigDecimal(value.toString()); - log.info("值是Number类型,转换为BigDecimal: {}", numberValue); - } else if (value != null) { - log.warn("值不是Number类型,尝试从字符串转换。Value: {}, type: {}", value, value.getClass().getName()); - try { - numberValue = new BigDecimal(value.toString()); - log.info("成功从字符串转换为BigDecimal: {}", numberValue); - } catch (Exception e) { - log.error("无法将值转换为BigDecimal: {}", value, e); - } - } else { - log.warn("值为null"); } - switch (property) { case "DY": data.setVoltage(numberValue); - log.info("设置 voltage: {}", numberValue); break; case "WD": data.setTemperature(numberValue); - log.info("设置 temperature: {}", numberValue); break; case "NZ": data.setInterResistance(numberValue); - log.info("设置 interResistance: {}", numberValue); break; - default: - log.warn("未知的属性类型: {}", property); } - - log.info("setDTDCPropertyValue 结束 - 当前对象状态 voltage:{}, temperature:{}, interResistance:{}", - data.getVoltage(), data.getTemperature(), data.getInterResistance()); } //根据属性名设置对应的值 @@ -805,7 +736,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } EmsBatteryData batteryData = new EmsBatteryData(); - batteryData.setDeviceId(recordId+deviceId); + batteryData.setDeviceId(recordId); batteryData.setBatteryCellId(recordId); saveDeviceData(pointMatchList, fields, batteryData, pointEnumMatchMap); -- 2.49.0 From dd060b0abfde0f8829cfeaa816d14e7a8bddd0a2 Mon Sep 17 00:00:00 2001 From: zq Date: Sat, 24 Jan 2026 20:51:16 +0800 Subject: [PATCH 321/336] =?UTF-8?q?=E5=8D=95=E4=BD=93=E7=94=B5=E6=B1=A0?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=95=B0=E6=8D=AE=E6=94=B9=E5=8A=A8=EF=BC=9B?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E5=80=BC=E5=8C=B9=E9=85=8D=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-prod.yml | 2 +- .../impl/DeviceDataProcessServiceImpl.java | 121 ++++++++++-------- .../service/impl/SingleSiteServiceImpl.java | 30 +++++ .../utils/DevicePointMatchDataProcessor.java | 53 +++++++- .../mapper/ems/EmsBatteryDataMapper.xml | 2 +- .../mapper/ems/EmsPointMatchMapper.xml | 9 +- 6 files changed, 156 insertions(+), 61 deletions(-) diff --git a/ems-admin/src/main/resources/application-prod.yml b/ems-admin/src/main/resources/application-prod.yml index 3c97d98..fee9ed4 100644 --- a/ems-admin/src/main/resources/application-prod.yml +++ b/ems-admin/src/main/resources/application-prod.yml @@ -187,7 +187,7 @@ xss: urlPatterns: /system/*,/monitor/*,/tool/* mqtt: - broker.url: tcp://122.51.194.184:1883 + broker.url: tcp://121.5.164.6:1883 client.id: ems-cloud username: dmbroker password: qwer1234 diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java index ce08e73..a52209a 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/DeviceDataProcessServiceImpl.java @@ -2,6 +2,7 @@ package com.xzzn.ems.service.impl; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONException; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; import com.fasterxml.jackson.core.JsonProcessingException; @@ -70,7 +71,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; @@ -153,7 +153,9 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i @Override public void handleDeviceData(String message, String siteId) { - JSONArray arraylist = JSONArray.parseArray(message); + JSONArray arraylist = parseJsonData(message); + if (arraylist == null) return; + // 过滤掉空数据(空数据不处理,直接返回 for (int i = 0; i < arraylist.size(); i++) { JSONObject obj = JSONObject.parseObject(arraylist.get(i).toString()); @@ -181,6 +183,21 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i } } + private JSONArray parseJsonData(String message) { + try { + JSONObject object = JSONObject.parseObject(message); + return object.getJSONArray("payload"); + } catch (JSONException e) { + log.info("mqtt message is not a json object: " + e.getMessage()); + try { + return JSONArray.parseArray(message); + } catch (Exception arrayException) { + log.info("mqtt message is not a json array: " + e.getMessage()); + } + } + return null; + } + public void processingDeviceData(String siteId, String deviceId, String jsonData, Date dataUpdateTime) { // 判断设备类型,并调用对应的方法处理数据 String deviceCategory = getDeviceCategory(siteId, deviceId); @@ -242,11 +259,10 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理EMS数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.EMS.getCode()); EmsEmsData emsData = new EmsEmsData(); - saveDeviceData(pointMatchList, obj, emsData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, emsData); emsData.setDataUpdateTime(dataUpdateTime); emsData.setCreateBy("system"); @@ -271,11 +287,10 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理中水冷却数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.COOLING.getCode()); EmsCoolingData coolingData = new EmsCoolingData(); - saveDeviceData(pointMatchList, obj, coolingData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, coolingData); coolingData.setDataUpdateTime(dataUpdateTime); coolingData.setCreateBy("system"); @@ -301,14 +316,13 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理消防数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.XF.getCode()); // 暂时只更新设备表的设备状态 ZDYBYDCZT-主电源备用电池状态 // 数据存表 EmsXfData xfData = new EmsXfData(); xfData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, xfData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, xfData); xfData.setCreateBy("system"); xfData.setCreateTime(DateUtils.getNowDate()); @@ -336,12 +350,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理动环数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.DH.getCode()); //DH EmsDhData dhData = new EmsDhData(); - saveDeviceData(pointMatchList, obj, dhData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, dhData); dhData.setDataUpdateTime(dateUpdateTime); dhData.setCreateBy("system"); @@ -371,7 +384,6 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池堆数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.STACK.getCode()); //BMS 电池簇 EmsBatteryStack dataStack = new EmsBatteryStack(); @@ -382,7 +394,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i dataStack.setPcsCommunicationStatus(CommunicationStatus.OK.getCode()); dataStack.setEmsCommunicationStatus(CommunicationStatus.OK.getCode()); - saveDeviceData(pointMatchList, obj, dataStack, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, dataStack); dataStack.setCreateBy("system"); dataStack.setCreateTime(DateUtils.getNowDate()); @@ -396,7 +408,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i redisCache.setCacheObject(RedisKeyConstants.STACK + siteId + "_" + deviceId, dataStack); // 同步更新设备工作状态 - saveDeviceWorkStatus(deviceId, siteId, dataStack.getWorkStatus()); + saveDeviceWorkStatus(siteId, deviceId, DeviceMatchTable.STACK.getCode(), dataStack.getWorkStatus()); } private void batteryGroupDataProcess(String siteId, String deviceId, String jsonData) { @@ -601,10 +613,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i * @param pointMatchList 字段匹配规则列表 * @param obj 原始数据Map * @param entity 目标Java对象 - * @param pointEnumMatchMap 枚举匹配规则 */ - private void saveDeviceData(List pointMatchList, Map obj, - Object entity, Map> pointEnumMatchMap) { + private void saveDeviceData(List pointMatchList, Map obj, Object entity) { if (null == obj || obj.isEmpty()) { return; } @@ -623,18 +633,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 1. 从原始数据中获取匹配值 Object matchValue = obj.get(pointMatchMap.get(fieldName)); - // 2. 处理枚举值转换 - List pointEnumMatchList = pointEnumMatchMap.get(fieldName); - if (CollectionUtils.isNotEmpty(pointEnumMatchList) && matchValue != null) { - String finalMatchValue = String.valueOf(matchValue).replace(".0", ""); - Optional enumMatch = pointEnumMatchList.stream() - .filter(data -> data.getDataEnumCode().equals(finalMatchValue)).findFirst(); - if (enumMatch.isPresent()) { - matchValue = enumMatch.get().getEnumCode(); - } - } - - // 3. 类型转换 + // 2. 类型转换 Class fieldType = field.getType(); if (String.class.equals(fieldType)) { matchValue = StringUtils.getString(matchValue); @@ -665,12 +664,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池簇数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.CLUSTER.getCode()); - String stackDeviceId = getStackDeviceId(deviceId); + String stackDeviceId = getStackDeviceId(deviceId); //BMS 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); - saveDeviceData(pointMatchList, obj, data, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, data); data.setDataUpdateTime(dataUpdateTime); // data.setWorkStatus(WorkStatus.NORMAL.getCode()); // 或其他默认值 @@ -692,7 +690,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i redisCache.setCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + deviceId, data); // 同步更新设备工作状态 - saveDeviceWorkStatus(deviceId, siteId, data.getWorkStatus()); + saveDeviceWorkStatus(siteId, deviceId, DeviceMatchTable.CLUSTER.getCode(), data.getWorkStatus()); } private String getStackDeviceId(String deviceId) { @@ -715,7 +713,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i //单体电池 Map> records = processData(JSON.parseObject(dataJson, new TypeReference>() { })); - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.BATTERY.getCode()); + log.info("站点:{},单体电池数据:{}", siteId, records); List list = new ArrayList<>(); List dailyList = new ArrayList<>(); List minutesList = new ArrayList<>(); @@ -730,6 +728,15 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i String batteryDeviceId = recordId + deviceId; // 点位匹配数据 List pointMatchList = devicePointMatchDataProcessor.getDevicePointMatch(siteId, batteryDeviceId, DeviceMatchTable.BATTERY.getCode()); + if (CollectionUtils.isEmpty(pointMatchList)) { + pointMatchList = devicePointMatchDataProcessor.getDeviceDefaultPointMatch(siteId, DeviceMatchTable.BATTERY.getCode()); + } else { + Map newFields = new HashMap<>(); + for (Map.Entry entry : fields.entrySet()) { + newFields.put(entry.getKey() + recordId, entry.getValue()); + } + fields = newFields; + } if (CollectionUtils.isEmpty(pointMatchList)) { log.info("未找到匹配的点位数据,无法处理单体电池数据,siteId: " + siteId + ",deviceId: " + batteryDeviceId); return; @@ -739,7 +746,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i batteryData.setDeviceId(recordId); batteryData.setBatteryCellId(recordId); - saveDeviceData(pointMatchList, fields, batteryData, pointEnumMatchMap); + saveDeviceData(pointMatchList, fields, batteryData); batteryData.setBatteryCluster(deviceId); batteryData.setBatteryPack(getStackDeviceId(deviceId)); @@ -803,12 +810,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理PCS数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.PCS.getCode()); //pcs EmsPcsData pcsData = new EmsPcsData(); - saveDeviceData(pointMatchList, obj, pcsData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, pcsData); // 状态指示类 pcsData.setBranchStatus(BranchStatus.NORMAL.getCode()); @@ -838,7 +844,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i redisCache.setCacheObject(RedisKeyConstants.PCS + siteId + "_" + deviceId, pcsData); // 同步更新PCS设备工作状态 - saveDeviceWorkStatus(deviceId, siteId, pcsData.getWorkStatus()); + saveDeviceWorkStatus(siteId, deviceId, DeviceMatchTable.PCS.getCode(), pcsData.getWorkStatus()); // if (SiteEnum.FX.getCode().equals(siteId)) { // //更新每日充放电数据 @@ -857,7 +863,6 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理PCS支路数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.BRANCH.getCode()); //PCS支路 for (Map.Entry> record : records.entrySet()) { @@ -869,7 +874,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i data.setSiteId(siteId); data.setGridStatus(GridStatus.GRID.getCode()); - saveDeviceData(pointMatchList, fields, data, pointEnumMatchMap); + saveDeviceData(pointMatchList, fields, data); data.setBranchId(recordId); data.setCreateBy("system"); @@ -898,13 +903,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理LOAD总表数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.AMMETER.getCode()); EmsAmmeterData dataLoad = new EmsAmmeterData(); // 更新时间 dataLoad.setDataUpdateTime(dataUpdateTime); - saveDeviceData(pointMatchList, obj, dataLoad, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, dataLoad); dataLoad.setCreateBy("system"); dataLoad.setCreateTime(DateUtils.getNowDate()); @@ -935,7 +939,6 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池簇数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.CLUSTER.getCode()); //BMSC 电池簇 EmsBatteryCluster data = new EmsBatteryCluster(); // 其他非 BigDecimal 字段 @@ -957,25 +960,36 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 获取redis获取最新的BMSD数据 Map stackObj = redisCache.getCacheObject(RedisKeyConstants.ORIGINAL_BMSD + siteId + "_" + stackDeviceId); data.setDeviceId(deviceId); - saveDeviceData(pointMatchList, obj, data, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, data); // 取堆里面数据 - saveDeviceData(pointMatchList, stackObj, data, pointEnumMatchMap); + saveDeviceData(pointMatchList, stackObj, data); emsBatteryClusterMapper.insertEmsBatteryCluster(data); redisCache.setCacheObject(RedisKeyConstants.CLUSTER + siteId + "_" + deviceId, data); // 同步更新设备工作状态 - saveDeviceWorkStatus(deviceId, siteId, data.getWorkStatus()); + saveDeviceWorkStatus(siteId, deviceId, DeviceMatchTable.CLUSTER.getCode(), data.getWorkStatus()); } } - private void saveDeviceWorkStatus(String deviceId, String siteId, String workStatus) { + private void saveDeviceWorkStatus(String siteId, String deviceId, String deviceCategory, String workStatus) { if (StringUtils.isEmpty(workStatus)) { return; } +// Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, deviceCategory); +// // 枚举值转换 +// List pointEnumMatchList = pointEnumMatchMap.get("workStatus"); +// if (CollectionUtils.isNotEmpty(pointEnumMatchList) && workStatus != null) { +// String finalMatchValue = workStatus.replace(".0", ""); +// Optional enumMatch = pointEnumMatchList.stream() +// .filter(data -> data.getDataEnumCode().equals(finalMatchValue)).findFirst(); +// if (enumMatch.isPresent()) { +// workStatus = enumMatch.get().getEnumCode(); +// } +// } EmsDevicesSetting emsDevicesSetting = emsDevicesSettingMapper.getDeviceBySiteAndDeviceId(deviceId, siteId); emsDevicesSetting.setWorkStatus(workStatus); emsDevicesSetting.setUpdatedAt(DateUtils.getNowDate()); @@ -1046,7 +1060,6 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电表数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.AMMETER.getCode()); // 获取上次数据,便于后面计算差值均无则默认0 EmsAmmeterData lastAmmeterData = getLastAmmeterData(siteId, deviceId); @@ -1055,7 +1068,7 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i // 更新时间 dataMete.setDataUpdateTime(dataUpdateTime); - saveDeviceData(pointMatchList, obj, dataMete, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, dataMete); dataMete.setCreateBy("system"); dataMete.setCreateTime(DateUtils.getNowDate()); @@ -1584,12 +1597,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理中水冷却告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.PCS.getCode()); EmsPcsAlarmData pcsAlarmData = new EmsPcsAlarmData(); // 更新时间 pcsAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, pcsAlarmData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, pcsAlarmData); pcsAlarmData.setCreateBy("system"); pcsAlarmData.setCreateTime(DateUtils.getNowDate()); @@ -1611,13 +1623,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池堆告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.STACK.getCode()); EmsStackAlarmData stackAlarmData = new EmsStackAlarmData(); // 更新时间 stackAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, stackAlarmData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, stackAlarmData); stackAlarmData.setCreateBy("system"); stackAlarmData.setCreateTime(DateUtils.getNowDate()); @@ -1638,12 +1649,11 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理电池簇告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.CLUSTER.getCode()); EmsClusterAlarmData clusterAlarmData = new EmsClusterAlarmData(); // 更新时间 clusterAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, clusterAlarmData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, clusterAlarmData); clusterAlarmData.setCreateBy("system"); clusterAlarmData.setCreateTime(DateUtils.getNowDate()); @@ -1665,13 +1675,12 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i log.info("未找到匹配的点位数据,无法处理中水冷却告警数据,siteId: " + siteId + ",deviceId: " + deviceId); return; } - Map> pointEnumMatchMap = devicePointMatchDataProcessor.getPointEnumMatchMap(siteId, DeviceMatchTable.COOLING.getCode()); EmsCoolingAlarmData coolingAlarmData = new EmsCoolingAlarmData(); // 更新时间 coolingAlarmData.setDataTimestamp(dataUpdateTime); - saveDeviceData(pointMatchList, obj, coolingAlarmData, pointEnumMatchMap); + saveDeviceData(pointMatchList, obj, coolingAlarmData); coolingAlarmData.setCreateBy("system"); coolingAlarmData.setCreateTime(DateUtils.getNowDate()); diff --git a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java index 4041379..bff693f 100644 --- a/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java +++ b/ems-system/src/main/java/com/xzzn/ems/service/impl/SingleSiteServiceImpl.java @@ -33,6 +33,7 @@ import com.xzzn.ems.mapper.EmsStrategyRunningMapper; import com.xzzn.ems.mapper.EmsStrategyTempMapper; import com.xzzn.ems.service.IEmsEnergyPriceConfigService; import com.xzzn.ems.service.ISingleSiteService; +import com.xzzn.ems.utils.DevicePointMatchDataProcessor; import java.math.BigDecimal; import java.math.RoundingMode; @@ -101,6 +102,8 @@ public class SingleSiteServiceImpl implements ISingleSiteService { private EmsEnergyPriceConfigMapper emsEnergyPriceConfigMapper; @Autowired private IEmsEnergyPriceConfigService iEmsEnergyPriceConfigService; + @Autowired + private DevicePointMatchDataProcessor devicePointMatchDataProcessor; @Override public SiteMonitorHomeVo getSiteMonitorDataVo(String siteId) { @@ -489,6 +492,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService { pcsDetailInfoVo.setAlarmNum(alarmNum); pcsDetailInfoVo.setDeviceStatus(pcsDevice.get("deviceStatus") == null ? "" : pcsDevice.get("deviceStatus").toString()); + // 处理枚举匹配字段 + devicePointMatchDataProcessor.convertFieldValueToEnumMatch(siteId, DeviceCategory.PCS.getCode(), pcsDetailInfoVo); + pcsDetailInfoVoList.add(pcsDetailInfoVo); } } @@ -535,6 +541,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 告警设备点位个数 int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, stackId, DeviceCategory.STACK.getCode()); bmsOverViewVo.setAlarmNum(alarmNum); + + // 处理枚举匹配字段 + devicePointMatchDataProcessor.convertFieldValueToEnumMatch(siteId, DeviceCategory.STACK.getCode(), bmsOverViewVo); + bmsOverViewVoList.add(bmsOverViewVo); } } @@ -594,6 +604,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 告警设备点位个数 int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, clusterId, DeviceCategory.CLUSTER.getCode()); bmsBatteryClusterVo.setAlarmNum(alarmNum); + + // 处理枚举匹配字段 + devicePointMatchDataProcessor.convertFieldValueToEnumMatch(siteId, DeviceCategory.CLUSTER.getCode(), bmsBatteryClusterVo); + bmsBatteryClusterVoList.add(bmsBatteryClusterVo); } } @@ -746,6 +760,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { ammeterDataVo.setAlarmNum(alarmNum); // 设置表数据 dealAmmeterData(ammeterData,ammeterDataVo); + + // 处理枚举匹配字段 + devicePointMatchDataProcessor.convertFieldValueToEnumMatch(siteId, DeviceCategory.AMMETER.getCode(), ammeterDataVo); + ammeterResponse.add(ammeterDataVo); } return ammeterResponse; @@ -836,6 +854,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { // 告警设备点位个数 int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, dhDeviceId, DeviceCategory.DH.getCode()); dhDataVo.setAlarmNum(alarmNum); + + // 处理枚举匹配字段 + devicePointMatchDataProcessor.convertFieldValueToEnumMatch(siteId, DeviceCategory.DH.getCode(), dhDataVo); + emsDhDataList.add(dhDataVo); } return emsDhDataList; @@ -865,6 +887,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { xfDataVo.setAlarmNum(alarmNum); } xfDataVo.setEmsCommunicationStatus(xfDevice.get("communicationStatus") == null ? "" : xfDevice.get("communicationStatus").toString()); + + // 处理枚举匹配字段 + devicePointMatchDataProcessor.convertFieldValueToEnumMatch(siteId, DeviceCategory.XF.getCode(), xfData); + emsXfDataList.add(xfDataVo); } return emsXfDataList; @@ -888,6 +914,10 @@ public class SingleSiteServiceImpl implements ISingleSiteService { int alarmNum = emsPointMatchMapper.getDevicePointAlarmNum(siteId, emsDeviceId, DeviceCategory.EMS.getCode()); emsDataVo.setAlarmNum(alarmNum); } + + // 处理枚举匹配字段 + devicePointMatchDataProcessor.convertFieldValueToEnumMatch(siteId, DeviceCategory.EMS.getCode(), emsDataVo); + emsDataList.add(emsDataVo); } return emsDataList; diff --git a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java index 64aa1d2..a34ff2c 100644 --- a/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java +++ b/ems-system/src/main/java/com/xzzn/ems/utils/DevicePointMatchDataProcessor.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; @@ -79,6 +80,14 @@ public class DevicePointMatchDataProcessor { return null; } + public List getDeviceDefaultPointMatch(String siteId, String deviceCategory) { + List pointMatchList = redisCache.getCacheList(getPointMacthCacheKey(siteId, null, deviceCategory)); + if (CollectionUtils.isEmpty(pointMatchList)) { + pointMatchList = emsPointMatchMapper.getDevicePointMatchList(siteId, null, deviceCategory); + } + return pointMatchList; + } + public List getDevicePointMatch(String siteId, String deviceId, String deviceCategory) { return getDevicePointMatch(siteId, deviceId, deviceCategory, false); } @@ -206,7 +215,11 @@ public class DevicePointMatchDataProcessor { */ public static String getPointMacthCacheKey(String siteId, String deviceId, String deviceCategory) { - return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId + "_" + deviceId; + if (StringUtils.isEmpty(deviceId)) { + return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId; + } else { + return RedisKeyConstants.POINT_MATCH + deviceCategory + "_" + siteId + "_" + deviceId; + } } /** @@ -219,4 +232,42 @@ public class DevicePointMatchDataProcessor { { return RedisKeyConstants.POINT_ENUM_MATCH + deviceCategory + "_" + siteId; } + + /** + * 转换字段值为配置枚举值 + */ + public void convertFieldValueToEnumMatch(String siteId, String deviceCategory, Object entity) { + + Map> pointEnumMatchMap = this.getPointEnumMatchMap(siteId, deviceCategory); + Field[] fields = entity.getClass().getDeclaredFields(); + for (Field field : fields) { + String fieldName = field.getName(); + if (pointEnumMatchMap.containsKey(fieldName)) { + // 处理匹配的字段名,并设置值 + field.setAccessible(true); // 允许访问私有字段 + try { + // 从原始数据中获取匹配值 + Object matchValue = field.get(entity); + List pointEnumMatchList = pointEnumMatchMap.get(fieldName); + if (CollectionUtils.isNotEmpty(pointEnumMatchList) && matchValue != null) { + String finalMatchValue = String.valueOf(matchValue).replace(".0", ""); + Optional enumMatch = pointEnumMatchList.stream() + .filter(data -> data.getDataEnumCode().equals(finalMatchValue)).findFirst(); + if (enumMatch.isPresent()) { + matchValue = enumMatch.get().getEnumCode(); + } + } + if (matchValue == null) { + continue; + } + + // 设置字段值 + field.set(entity, matchValue); + } catch (IllegalAccessException e) { + log.warn("convertFieldValueToEnumMatch 设置字段值时出错", e); + } + } + } + } + } diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml index 5776967..8794f26 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryDataMapper.xml @@ -212,7 +212,7 @@ battery_pack, battery_cluster, battery_cell_id, voltage, temperature, soc, soh, data_timestamp, create_by, create_time, update_by, update_time, - remark, site_id, device_id, cluster_device_id, inter_resistance + remark, site_id, device_id, cluster_device_id, inter_resistance, current ) VALUES ( diff --git a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml index ef966be..6abab7a 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPointMatchMapper.xml @@ -522,8 +522,13 @@ + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index d1e2464..0eced41 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -428,4 +428,23 @@ GROUP BY statisDate ORDER BY statisDate + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 647deaf..2313431 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -509,6 +509,27 @@ ORDER BY statisDate + + \ No newline at end of file diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml index 0eced41..7dc50c5 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryClusterMapper.xml @@ -433,8 +433,9 @@ WITH ranked AS ( SELECT *, - date_format(p.update_time, '%Y-%m-%d %H:00:00') + INTERVAL FLOOR(MINUTE(p.update_time) / 5) * 5 MINUTE AS group_time, - ROW_NUMBER() OVER (PARTITION BY p.device_id, date_format(p.update_time, '%Y-%m-%d %H:00:00'), FLOOR(MINUTE(p.update_time) / 5) ORDER BY p.update_time) as rn + DATE_FORMAT(DATE_ADD(DATE_FORMAT(p.update_time, '%Y-%m-%d %H:00:00'), INTERVAL CEIL(MINUTE(p.update_time) / 5) * 5 MINUTE) + , '%Y-%m-%d %H:%i:%s') AS group_time, + ROW_NUMBER() OVER (PARTITION BY p.device_id, date_format(p.update_time, '%Y-%m-%d %H:00:00'), CEIL(MINUTE(p.update_time) / 5) ORDER BY p.data_update_time DESC) as rn FROM ems_battery_cluster p diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index 2313431..bd83e2e 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -513,8 +513,9 @@ WITH ranked AS ( SELECT *, - date_format(p.update_time, '%Y-%m-%d %H:00:00') + INTERVAL FLOOR(MINUTE(p.update_time) / 5) * 5 MINUTE AS group_time, - ROW_NUMBER() OVER (PARTITION BY p.device_id, date_format(p.update_time, '%Y-%m-%d %H:00:00'), FLOOR(MINUTE(p.update_time) / 5) ORDER BY p.update_time) as rn + DATE_FORMAT(DATE_ADD(DATE_FORMAT(p.update_time, '%Y-%m-%d %H:00:00'), INTERVAL CEIL(MINUTE(p.update_time) / 5) * 5 MINUTE) + , '%Y-%m-%d %H:%i:%s') AS group_time, + ROW_NUMBER() OVER (PARTITION BY p.device_id, date_format(p.update_time, '%Y-%m-%d %H:00:00'), CEIL(MINUTE(p.update_time) / 5) ORDER BY p.data_update_time DESC) as rn FROM ems_battery_stack p diff --git a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml index 12cd76f..52e50e6 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsPcsDataMapper.xml @@ -599,6 +599,26 @@ order by statisDate desc + + + + @@ -423,6 +427,7 @@ t.data_point as dataPoint, t.data_point_name as dataPointName, t.data_device as dataDevice, + t.match_field as matchField, t.need_diff_device_id as isNeedDeviceId, t.data_unit as dataUnit, t.ip_address as ipAddress, @@ -459,6 +464,7 @@ SELECT tmp.pointName, tmp.dataPoint, tmp.dataDevice, + tmp.matchField, tmp.dataPointName, tmp.dataUnit, tmp.ipAddress, @@ -469,6 +475,7 @@ when t.need_diff_device_id = 1 and t.data_device = 'BMSD' then concat(#{parentDeviceId}, t.data_point) else t.data_point end as dataPoint, t.data_point_name as dataPointName, + t.match_field as matchField, t.data_device as dataDevice, t.data_unit as dataUnit, t.ip_address as ipAddress, -- 2.49.0 From 6545b4f94778f414394d2eab366e79c51b8fc93b Mon Sep 17 00:00:00 2001 From: zq Date: Wed, 28 Jan 2026 19:26:15 +0800 Subject: [PATCH 336/336] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ems/EmsBatteryStackMapper.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml index aa7691f..3a3b74c 100644 --- a/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml +++ b/ems-system/src/main/resources/mapper/ems/EmsBatteryStackMapper.xml @@ -544,6 +544,7 @@ ) SELECT t.site_id, + t.device_id as deviceId, DATE_FORMAT(t.group_time, '%Y-%m-%d %H:%i:%s') as statisDate, FROM -- 2.49.0