Compare commits
2 Commits
dev
...
prod_20251
| Author | SHA1 | Date |
|---|---|---|
|
|
10c23f3f5b | 4 months ago |
|
|
9420aa3ac4 | 4 months ago |
129 changed files with 958 additions and 7044 deletions
@ -1,49 +0,0 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator; |
||||
import com.fasterxml.jackson.core.JsonParser; |
||||
import com.fasterxml.jackson.databind.DeserializationContext; |
||||
import com.fasterxml.jackson.databind.DeserializationFeature; |
||||
import com.fasterxml.jackson.databind.JsonDeserializer; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.fasterxml.jackson.databind.module.SimpleModule; |
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; |
||||
import com.mh.user.model.MyBigDecimalDeserializer; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import java.io.IOException; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 避免使用科学计数算法 |
||||
* @date 2026-01-07 14:37:11 |
||||
*/ |
||||
@Configuration |
||||
public class MyJacksonConfig { |
||||
|
||||
@Bean("customObjectMapper") |
||||
public ObjectMapper customObjectMapper() { |
||||
ObjectMapper mapper = new ObjectMapper(); |
||||
|
||||
// 注册 JavaTimeModule
|
||||
mapper.registerModule(new JavaTimeModule()); |
||||
|
||||
// 启用 BigDecimal 作为普通格式输出(避免科学计数法)
|
||||
mapper.enable(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN); |
||||
|
||||
// 注册自定义反序列化器
|
||||
SimpleModule module = new SimpleModule(); |
||||
module.addDeserializer(BigDecimal.class, new MyBigDecimalDeserializer()); |
||||
mapper.registerModule(module); |
||||
|
||||
// 启用 BigDecimal 处理浮点数
|
||||
mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); |
||||
|
||||
return mapper; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,62 @@
|
||||
package com.mh.user.config.mqtt; |
||||
|
||||
import com.mh.user.config.MHConfig; |
||||
import com.mh.user.constants.ChannelName; |
||||
import com.mh.user.constants.TopicEnum; |
||||
import com.mh.user.utils.SpringBeanUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.integration.annotation.Router; |
||||
import org.springframework.integration.mqtt.support.MqttHeaders; |
||||
import org.springframework.integration.router.AbstractMessageRouter; |
||||
import org.springframework.messaging.Message; |
||||
import org.springframework.messaging.MessageChannel; |
||||
import org.springframework.messaging.MessageHeaders; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.Collections; |
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 入站消息路由分发中心 |
||||
* @date 2024-10-29 17:04:17 |
||||
*/ |
||||
@Slf4j |
||||
@Component |
||||
public class InboundMessageRouter extends AbstractMessageRouter { |
||||
|
||||
/** 系统基础配置 */ |
||||
@Autowired |
||||
private MHConfig mHConfig; |
||||
|
||||
/** |
||||
* 目前只需要这个方式,后期在拓展使用IntegrationFlow方式 |
||||
* @param message |
||||
* @return |
||||
*/ |
||||
@Router(inputChannel = ChannelName.INBOUND) |
||||
@Override |
||||
protected Collection<MessageChannel> determineTargetChannels(Message<?> message) { |
||||
MessageHeaders headers = message.getHeaders(); |
||||
String topic = Objects.requireNonNull(headers.get(MqttHeaders.RECEIVED_TOPIC)).toString(); |
||||
// byte[] payload = (byte[]) message.getPayload();
|
||||
// log.info("从当前主题 topic: {}, 接收到的消息:{}", topic, new String(payload));
|
||||
// 判断当前主题是否是当前项目的,温湿度目前写死的
|
||||
if (!topic.startsWith(mHConfig.getName()) && !topic.contains("/temp")) { |
||||
log.info("当前主题 topic: {} 不是当前项目的,直接丢弃", topic); |
||||
return Collections.singleton((MessageChannel) SpringBeanUtil.getBean(ChannelName.DEFAULT_BOUND)); |
||||
} |
||||
// 找到对应的主题消息通道
|
||||
if (topic.contains("/temp")) { |
||||
return Collections.singleton((MessageChannel) SpringBeanUtil.getBean(ChannelName.EVENTS_UPLOAD_INBOUND)); |
||||
} else { |
||||
TopicEnum topicEnum = TopicEnum.find(mHConfig.getName() + "/", topic); |
||||
MessageChannel bean = (MessageChannel) SpringBeanUtil.getBean(topicEnum.getBeanName()); |
||||
return Collections.singleton(bean); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,99 @@
|
||||
package com.mh.user.config.mqtt; |
||||
|
||||
import com.mh.user.constants.MqttClientOptions; |
||||
import com.mh.user.constants.MqttProtocolEnum; |
||||
import com.mh.user.constants.MqttUseEnum; |
||||
import lombok.Data; |
||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory; |
||||
import org.springframework.integration.mqtt.core.MqttPahoClientFactory; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description mqtt连接配置 |
||||
* @date 2024-10-29 14:44:51 |
||||
*/ |
||||
@Configuration |
||||
@Data |
||||
@ConfigurationProperties |
||||
public class MqttConfig { |
||||
|
||||
private static Map<MqttUseEnum, MqttClientOptions> mqttSpring; |
||||
|
||||
public void setMqttSpring(Map<MqttUseEnum, MqttClientOptions> mqtt) { |
||||
MqttConfig.mqttSpring = mqtt; |
||||
} |
||||
|
||||
/** |
||||
* 获取mqtt基本配置 |
||||
* @return |
||||
*/ |
||||
static MqttClientOptions getBasicMqttClientOptions() { |
||||
if (!mqttSpring.containsKey(MqttUseEnum.BASIC)) { |
||||
throw new Error("请先配置MQTT的基本连接参数,否则无法启动项目"); |
||||
} |
||||
return mqttSpring.get(MqttUseEnum.BASIC); |
||||
} |
||||
|
||||
/** |
||||
* 拼接获取对应mqtt的连接地址 |
||||
* @param options |
||||
* @return |
||||
*/ |
||||
public static String getMqttAddress(MqttClientOptions options) { |
||||
StringBuilder addr = new StringBuilder(); |
||||
addr.append(options.getProtocol().getProtocolAddr()) |
||||
.append(options.getHost().trim()) |
||||
.append(":") |
||||
.append(options.getPort()); |
||||
if ((options.getProtocol() == MqttProtocolEnum.WS || options.getProtocol() == MqttProtocolEnum.WSS) |
||||
&& StringUtils.hasText(options.getPath())) { |
||||
addr.append(options.getPath()); |
||||
} |
||||
return addr.toString(); |
||||
} |
||||
|
||||
public static String getBasicMqttAddress() { |
||||
return getMqttAddress(getBasicMqttClientOptions()); |
||||
} |
||||
|
||||
/** |
||||
* 获取连接参数,注入到spring中 |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
public MqttConnectOptions mqttConnectionOptions() { |
||||
|
||||
MqttConnectOptions mqttConnectOptions = new MqttConnectOptions(); |
||||
|
||||
MqttClientOptions customizeOptions = getBasicMqttClientOptions(); |
||||
String basicMqttAddress = getBasicMqttAddress(); |
||||
mqttConnectOptions.setServerURIs(new String[]{basicMqttAddress}); |
||||
mqttConnectOptions.setUserName(StringUtils.hasText(customizeOptions.getUsername()) ? |
||||
customizeOptions.getUsername() : ""); |
||||
mqttConnectOptions.setPassword(StringUtils.hasText(customizeOptions.getPassword()) ? |
||||
customizeOptions.getPassword().toCharArray() : new char[0]); |
||||
// 直接进行自动连接
|
||||
mqttConnectOptions.setAutomaticReconnect(true); |
||||
// 时间间隔时间10s
|
||||
mqttConnectOptions.setKeepAliveInterval(10); |
||||
|
||||
return mqttConnectOptions; |
||||
} |
||||
|
||||
@Bean |
||||
public MqttPahoClientFactory mqttClientFactory() { |
||||
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory(); |
||||
factory.setConnectionOptions(mqttConnectionOptions()); |
||||
return factory; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,91 @@
|
||||
package com.mh.user.config.mqtt; |
||||
|
||||
import com.mh.user.constants.ChannelName; |
||||
import com.mh.user.constants.MqttClientOptions; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.integration.annotation.IntegrationComponentScan; |
||||
import org.springframework.integration.annotation.ServiceActivator; |
||||
import org.springframework.integration.endpoint.MessageProducerSupport; |
||||
import org.springframework.integration.mqtt.core.MqttPahoClientFactory; |
||||
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter; |
||||
import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter; |
||||
import org.springframework.integration.mqtt.support.MqttHeaders; |
||||
import org.springframework.messaging.MessageChannel; |
||||
import org.springframework.messaging.MessageHandler; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 入站配置 |
||||
* @date 2024-10-29 16:22:10 |
||||
*/ |
||||
@Slf4j |
||||
@Configuration |
||||
@IntegrationComponentScan |
||||
public class MqttInboundConfig { |
||||
|
||||
@Autowired |
||||
private MqttPahoClientFactory mqttClientFactory; |
||||
|
||||
@Resource(name = ChannelName.INBOUND) |
||||
private MessageChannel inboundChannel; |
||||
|
||||
private String clientId; |
||||
|
||||
/** |
||||
* 入站适配器 |
||||
* @return |
||||
*/ |
||||
@Bean(name = "adapter") |
||||
public MessageProducerSupport mqttInbound() { |
||||
MqttClientOptions options = MqttConfig.getBasicMqttClientOptions(); |
||||
// 此处初始化的时候,默认订阅了配置文件中已经写好的topic
|
||||
// 如果需要订阅多个,可以自己手动订阅,会写一个addTopic()进行添加订阅
|
||||
clientId = options.getClientId() + "_consumer_" + System.currentTimeMillis(); |
||||
MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter( |
||||
clientId, |
||||
mqttClientFactory, |
||||
options.getInboundTopic().split(",")); |
||||
// System.out.println("每一次都会入站适配器吗?"+clientId);
|
||||
DefaultPahoMessageConverter converter = new DefaultPahoMessageConverter(); |
||||
// 统一是字节处理
|
||||
converter.setPayloadAsBytes(true); |
||||
// 设置消息转换器
|
||||
adapter.setConverter(converter); |
||||
// 设置qos(quality of service)
|
||||
// 0:最多一次传输(消息会丢失),
|
||||
// 1:至少一次传输(消息会重复),
|
||||
// 2:只有当消息发送成功时才确认(消息不回丢,但延迟高)。
|
||||
adapter.setQos(0); |
||||
// 设置在接收已经订阅的主题信息后,发送给哪个通道,具体的发送方法需要翻上层的抽象类
|
||||
adapter.setOutputChannel(inboundChannel); |
||||
return adapter; |
||||
} |
||||
|
||||
/** |
||||
* 默认声明一个消息处理器,用于处理无效的消息 |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
@ServiceActivator(inputChannel = ChannelName.DEFAULT_BOUND) |
||||
public MessageHandler handler() { |
||||
return message -> { |
||||
log.info("The default channel does not handle messages." + |
||||
"\nTopic: {}" + |
||||
"\nPayload: {}", |
||||
message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC), |
||||
message.getPayload()); |
||||
}; |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return clientId; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,55 @@
|
||||
package com.mh.user.config.mqtt; |
||||
|
||||
import com.mh.user.constants.ChannelName; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.integration.channel.DirectChannel; |
||||
import org.springframework.messaging.MessageChannel; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 声明所有通道的定义类 |
||||
* @date 2024-10-29 16:23:32 |
||||
*/ |
||||
@Slf4j |
||||
@Configuration |
||||
public class MqttMessageChannel { |
||||
|
||||
@Bean(name = ChannelName.OUTBOUND) |
||||
public MessageChannel outboundChannel() { |
||||
return new DirectChannel(); |
||||
} |
||||
|
||||
@Bean(name = ChannelName.INBOUND) |
||||
public MessageChannel inboundChannel() { |
||||
return new DirectChannel(); |
||||
} |
||||
|
||||
/** |
||||
* 事件主动上报通道 |
||||
* @return |
||||
*/ |
||||
@Bean(name = ChannelName.EVENTS_UPLOAD_INBOUND) |
||||
public MessageChannel eventsUploadInbound() { |
||||
return new DirectChannel(); |
||||
} |
||||
|
||||
@Bean(name = ChannelName.EVENTS_COLLECTION_INBOUND) |
||||
public MessageChannel eventsCollectionInbound() { |
||||
return new DirectChannel(); |
||||
} |
||||
|
||||
@Bean(name = ChannelName.EVENTS_CONTROL_INBOUND) |
||||
public MessageChannel eventsControlInbound() { |
||||
return new DirectChannel(); |
||||
} |
||||
|
||||
@Bean(name = ChannelName.EVENTS_SEND_INBOUND) |
||||
public MessageChannel eventsSendInbound() { |
||||
return new DirectChannel(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,51 @@
|
||||
package com.mh.user.config.mqtt; |
||||
|
||||
import com.mh.user.constants.ChannelName; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.integration.annotation.IntegrationComponentScan; |
||||
import org.springframework.integration.annotation.ServiceActivator; |
||||
import org.springframework.integration.mqtt.core.MqttPahoClientFactory; |
||||
import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler; |
||||
import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter; |
||||
import org.springframework.messaging.MessageHandler; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 入站配置 |
||||
* @date 2024-10-29 16:22:10 |
||||
*/ |
||||
@Slf4j |
||||
@Configuration |
||||
@IntegrationComponentScan |
||||
public class MqttOutboundConfig { |
||||
|
||||
@Autowired |
||||
private MqttPahoClientFactory mqttClientFactory; |
||||
|
||||
/** |
||||
* 默认声明一个出站处理器,用于处理无效的消息 |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
@ServiceActivator(inputChannel = ChannelName.OUTBOUND) |
||||
public MessageHandler mqttOutbound() { |
||||
MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler( |
||||
MqttConfig.getBasicMqttClientOptions().getClientId() + "_producer_" + System.currentTimeMillis(), |
||||
mqttClientFactory); |
||||
DefaultPahoMessageConverter converter = new DefaultPahoMessageConverter(); |
||||
// use byte types uniformly
|
||||
converter.setPayloadAsBytes(true); |
||||
|
||||
messageHandler.setAsync(true); |
||||
messageHandler.setDefaultQos(0); |
||||
messageHandler.setConverter(converter); |
||||
return messageHandler; |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,71 +0,0 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.common.utils.StringUtils; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.CollectionParamsManageEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.model.DeviceModel; |
||||
import com.mh.user.service.*; |
||||
import org.apache.poi.hssf.usermodel.HSSFCell; |
||||
import org.apache.poi.hssf.usermodel.HSSFSheet; |
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
||||
import org.apache.poi.ss.usermodel.CellType; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* 基表参数信息管理 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("cpm") |
||||
public class CollectionParamsManageController { |
||||
|
||||
@Autowired |
||||
private CollectionParamsManageService collectionParamsManageService; |
||||
|
||||
//保存
|
||||
@SysLogger(title="基表采集信息",optDesc = "保存基表采集参数信息") |
||||
@PostMapping(value="/save") |
||||
public HttpResult saveDevice(@RequestBody CollectionParamsManageEntity collectionParamsManageEntity) { |
||||
return HttpResult.ok(collectionParamsManageService.insertCPM(collectionParamsManageEntity)); |
||||
} |
||||
|
||||
//修改
|
||||
@SysLogger(title="基表采集参数信息",optDesc = "修改基表采集参数信息") |
||||
@PostMapping(value="/update") |
||||
public HttpResult updateDevice(@RequestBody CollectionParamsManageEntity collectionParamsManageEntity) { |
||||
return HttpResult.ok(collectionParamsManageService.updateCPM(collectionParamsManageEntity)); |
||||
} |
||||
|
||||
// 删除多
|
||||
@PostMapping(value="/deletes") |
||||
public HttpResult deleteDevices(@RequestBody String[] ids) { |
||||
return HttpResult.ok(collectionParamsManageService.deleteByIds(ids)); |
||||
} |
||||
|
||||
// 按条件查询
|
||||
@SysLogger(title="基表采集信息",optDesc = "按条件查询基表采集参数信息") |
||||
@PostMapping(value="/query") |
||||
public HttpResult queryDevice( @RequestParam(value = "deviceInstallId", required = false)String deviceInstallId, |
||||
@RequestParam(value = "buildingId", required = false)String buildingId, |
||||
@RequestParam(value = "otherName", required = false)String otherName, |
||||
@RequestParam(value = "page", required=true)Integer page, |
||||
@RequestParam(value = "limit", required=true)Integer limit) { |
||||
try{ |
||||
int count=collectionParamsManageService.selectCPMListCount(buildingId, deviceInstallId,otherName, page, limit); |
||||
List<CollectionParamsManageEntity> records=collectionParamsManageService.selectCPMList(buildingId, deviceInstallId,otherName, page, limit); |
||||
return HttpResult.ok(count,records); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -1,52 +0,0 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.dto.HotWaterControlDTO; |
||||
import com.mh.user.dto.HotWaterNowDataDTO; |
||||
import com.mh.user.service.CollectionParamsManageService; |
||||
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; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 热水监控 |
||||
* @date 2025-12-16 16:02:20 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/device/hotWater") |
||||
public class HotWaterMonitorController { |
||||
|
||||
@Autowired |
||||
private CollectionParamsManageService collectionParamsManageService; |
||||
|
||||
/** |
||||
* 获取生活热水监控热泵信息 |
||||
* @param buildingId |
||||
* @return |
||||
*/ |
||||
@GetMapping("/monitorList") |
||||
public HttpResult monitorList(@RequestParam("buildingId") String buildingId) { |
||||
List<HotWaterNowDataDTO> list = collectionParamsManageService.monitorList(buildingId); |
||||
return HttpResult. ok(list); |
||||
} |
||||
|
||||
/** |
||||
* 获取生活热水监控操作信息内容 |
||||
* @param buildingId |
||||
* @return |
||||
*/ |
||||
@GetMapping("/operateList") |
||||
public HttpResult operateList(@RequestParam("buildingId") String buildingId) { |
||||
List<HotWaterControlDTO> list = collectionParamsManageService.operateList(buildingId); |
||||
return HttpResult.ok(list); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,179 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 回水泵热泵控制界面VO |
||||
* @date 2025-03-14 09:00:37 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterBackPumpControlVO { |
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
private int orderNum; |
||||
|
||||
// 定时_时开1
|
||||
private int oneHourTimeOpenSetOne; |
||||
private String oneHourTimeOpenSetOneId; |
||||
|
||||
// 定时_分开1
|
||||
private int oneMinTimeOpenSetOne; |
||||
private String oneMinTimeOpenSetOneId; |
||||
|
||||
// 定时_时关1
|
||||
private int oneHourTimeCloseSetOne; |
||||
private String oneHourTimeCloseSetOneId; |
||||
|
||||
// 定时_分关1
|
||||
private int oneMinTimeCloseSetOne; |
||||
private String oneMinTimeCloseSetOneId; |
||||
|
||||
// 定时_时分开1
|
||||
private String oneHourMinTimeOpenSetOneStr; |
||||
// 定时_时分关1
|
||||
private String oneHourMinTimeCloseSetOneStr; |
||||
|
||||
// 定时_时开2
|
||||
private int oneHourTimeOpenSetTwo; |
||||
private String oneHourTimeOpenSetTwoId; |
||||
|
||||
// 定时_分开2
|
||||
private int oneMinTimeOpenSetTwo; |
||||
private String oneMinTimeOpenSetTwoId; |
||||
|
||||
// 定时_时关2
|
||||
private int oneHourTimeCloseSetTwo; |
||||
private String oneHourTimeCloseSetTwoId; |
||||
|
||||
// 定时_分关2
|
||||
private int oneMinTimeCloseSetTwo; |
||||
private String oneMinTimeCloseSetTwoId; |
||||
|
||||
// 定时_时分开2
|
||||
private String oneHourMinTimeOpenSetTwoStr; |
||||
// 定时_时分关2
|
||||
private String oneHourMinTimeCloseSetTwoStr; |
||||
|
||||
// 定时_时开3
|
||||
private int oneHourTimeOpenSetThree; |
||||
private String oneHourTimeOpenSetThreeId; |
||||
|
||||
// 定时_分开3
|
||||
private int oneMinTimeOpenSetThree; |
||||
private String oneMinTimeOpenSetThreeId; |
||||
|
||||
// 定时_时关3
|
||||
private int oneHourTimeCloseSetThree; |
||||
private String oneHourTimeCloseSetThreeId; |
||||
|
||||
// 定时_分关3
|
||||
private int oneMinTimeCloseSetThree; |
||||
private String oneMinTimeCloseSetThreeId; |
||||
|
||||
// 定时_时分开3
|
||||
private String oneHourMinTimeOpenSetThreeStr; |
||||
// 定时_时分关3
|
||||
private String oneHourMinTimeCloseSetThreeStr; |
||||
|
||||
// 开延时
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private int openDelayTime; |
||||
private String openDelayTimeId; |
||||
|
||||
// 温度设置
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal tempSet; |
||||
private String tempSetId; |
||||
|
||||
// 累计运行时间
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal runTime; |
||||
private String runTimeId; |
||||
|
||||
// 运行状态
|
||||
private int runState; |
||||
private String runStateId; |
||||
|
||||
// 启停控制
|
||||
private int startStopControl; |
||||
private String startStopControlId; |
||||
|
||||
// 故障
|
||||
private int fault; |
||||
private String faultId; |
||||
|
||||
// 一键启动
|
||||
private int startOneKey; |
||||
private String startOneKeyId; |
||||
|
||||
// 手自动切换
|
||||
private int manualAutoSwitch; |
||||
private String manualAutoSwitchId; |
||||
|
||||
// 选择两台回水泵启动
|
||||
private int twoPumpStart; |
||||
private String twoPumpStartId; |
||||
|
||||
// 温度设置上限
|
||||
private BigDecimal tempSetUpperLimit; |
||||
private String tempSetUpperLimitId; |
||||
|
||||
// 温度设置下限
|
||||
private BigDecimal tempSetLowerLimit; |
||||
private String tempSetLowerLimitId; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterBackPumpControlVO.class.getSimpleName() + "[", "]") |
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("orderNum=" + orderNum) |
||||
.add("oneHourTimeOpenSetOne=" + oneHourTimeOpenSetOne) |
||||
.add("oneHourTimeOpenSetOneId='" + oneHourTimeOpenSetOneId + "'") |
||||
.add("oneMinTimeOpenSetOne=" + oneMinTimeOpenSetOne) |
||||
.add("oneMinTimeOpenSetOneId='" + oneMinTimeOpenSetOneId + "'") |
||||
.add("oneHourTimeCloseSetOne=" + oneHourTimeCloseSetOne) |
||||
.add("oneHourTimeCloseSetOneId='" + oneHourTimeCloseSetOneId + "'") |
||||
.add("oneMinTimeCloseSetOne=" + oneMinTimeCloseSetOne) |
||||
.add("oneMinTimeCloseSetOneId='" + oneMinTimeCloseSetOneId + "'") |
||||
.add("oneHourTimeOpenSetTwo=" + oneHourTimeOpenSetTwo) |
||||
.add("oneHourTimeOpenSetTwoId='" + oneHourTimeOpenSetTwoId + "'") |
||||
.add("oneMinTimeOpenSetTwo=" + oneMinTimeOpenSetTwo) |
||||
.add("oneMinTimeOpenSetTwoId='" + oneMinTimeOpenSetTwoId + "'") |
||||
.add("oneHourTimeCloseSetTwo=" + oneHourTimeCloseSetTwo) |
||||
.add("oneHourTimeCloseSetTwoId='" + oneHourTimeCloseSetTwoId + "'") |
||||
.add("oneMinTimeCloseSetTwo=" + oneMinTimeCloseSetTwo) |
||||
.add("oneMinTimeCloseSetTwoId='" + oneMinTimeCloseSetTwoId + "'") |
||||
.add("oneHourTimeOpenSetThree=" + oneHourTimeOpenSetThree) |
||||
.add("oneHourTimeOpenSetThreeId='" + oneHourTimeOpenSetThreeId + "'") |
||||
.add("oneMinTimeOpenSetThree=" + oneMinTimeOpenSetThree) |
||||
.add("oneMinTimeOpenSetThreeId='" + oneMinTimeOpenSetThreeId + "'") |
||||
.add("oneHourTimeCloseSetThree=" + oneHourTimeCloseSetThree) |
||||
.add("oneHourTimeCloseSetThreeId='" + oneHourTimeCloseSetThreeId + "'") |
||||
.add("openDelayTime=" + openDelayTime) |
||||
.add("openDelayTimeId='" + openDelayTimeId + "'") |
||||
.add("tempSet=" + tempSet) |
||||
.add("tempSetId='" + tempSetId + "'") |
||||
.add("runTime=" + runTime) |
||||
.add("runTimeId='" + runTimeId + "'") |
||||
.add("runState=" + runState) |
||||
.add("runStateId='" + runStateId + "'") |
||||
.add("startStopControl=" + startStopControl) |
||||
.add("startStopControlId='" + startStopControlId + "'") |
||||
.add("fault=" + fault) |
||||
.add("faultId='" + faultId + "'") |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,118 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 热泵控制界面VO |
||||
* @date 2025-03-14 09:00:37 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterCircuitPumpControlVO { |
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
private int orderNum; |
||||
|
||||
// 定时_时开1
|
||||
private int oneHourTimeOpenSetOne; |
||||
private String oneHourTimeOpenSetOneId; |
||||
|
||||
// 定时_分开1
|
||||
private int oneMinTimeOpenSetOne; |
||||
private String oneMinTimeOpenSetOneId; |
||||
|
||||
// 定时_时分开1
|
||||
private String oneHourMinTimeOpenSetOneStr; |
||||
|
||||
// 定时_时关1
|
||||
private int oneHourTimeCloseSetOne; |
||||
private String oneHourTimeCloseSetOneId; |
||||
|
||||
// 定时_分关1
|
||||
private int oneMinTimeCloseSetOne; |
||||
private String oneMinTimeCloseSetOneId; |
||||
|
||||
// 定时_时分关1
|
||||
private String oneHourMinTimeCloseSetOneStr; |
||||
|
||||
// 开延时
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private int openDelayTime; |
||||
private String openDelayTimeId; |
||||
|
||||
// 温差
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal tempDiff; |
||||
private String tempDiffId; |
||||
|
||||
// 温差设置
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal tempDiffSet; |
||||
private String tempDiffSetId; |
||||
|
||||
// 累计运行时间
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal runTime; |
||||
private String runTimeId; |
||||
|
||||
// 运行状态
|
||||
private int runState; |
||||
private String runStateId; |
||||
|
||||
// 启停控制
|
||||
private int startStopControl; |
||||
private String startStopControlId; |
||||
|
||||
// 故障
|
||||
private int fault; |
||||
private String faultId; |
||||
|
||||
// 一键启动
|
||||
private int startOneKey; |
||||
private String startOneKeyId; |
||||
|
||||
// 手自动切换
|
||||
private int manualAutoSwitch; |
||||
private String manualAutoSwitchId; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterCircuitPumpControlVO.class.getSimpleName() + "[", "]") |
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("orderNum=" + orderNum) |
||||
.add("oneHourTimeOpenSetOne=" + oneHourTimeOpenSetOne) |
||||
.add("oneHourTimeOpenSetOneId='" + oneHourTimeOpenSetOneId + "'") |
||||
.add("oneMinTimeOpenSetOne=" + oneMinTimeOpenSetOne) |
||||
.add("oneMinTimeOpenSetOneId='" + oneMinTimeOpenSetOneId + "'") |
||||
.add("oneHourTimeCloseSetOne=" + oneHourTimeCloseSetOne) |
||||
.add("oneHourTimeCloseSetOneId='" + oneHourTimeCloseSetOneId + "'") |
||||
.add("oneMinTimeCloseSetOne=" + oneMinTimeCloseSetOne) |
||||
.add("oneMinTimeCloseSetOneId='" + oneMinTimeCloseSetOneId + "'") |
||||
.add("tempDiff=" + tempDiff) |
||||
.add("tempDiffId='" + tempDiffId + "'") |
||||
.add("tempDiffSet=" + tempDiffSet) |
||||
.add("tempDiffSetId='" + tempDiffSetId + "'") |
||||
.add("runTime=" + runTime) |
||||
.add("runTimeId='" + runTimeId + "'") |
||||
.add("runState=" + runState) |
||||
.add("runStateId='" + runStateId + "'") |
||||
.add("startStopControl=" + startStopControl) |
||||
.add("startStopControlId='" + startStopControlId + "'") |
||||
.add("fault=" + fault) |
||||
.add("faultId='" + faultId + "'") |
||||
.toString(); |
||||
} |
||||
|
||||
} |
||||
@ -1,38 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.apache.poi.ss.formula.functions.T; |
||||
|
||||
import java.util.List; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 生活热水监控dto |
||||
* @date 2025-03-14 09:13:19 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterControlDTO { |
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
private int orderNum; |
||||
|
||||
private List<?> children; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterControlDTO.class.getSimpleName() + "[", "]") |
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("orderNum=" + orderNum) |
||||
.add("children=" + children) |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,79 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 生活热水监控需要的列表信息 |
||||
* @date 2025-03-14 09:07:46 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterControlListVO { |
||||
|
||||
private String cpmId; |
||||
|
||||
private String buildingId; |
||||
|
||||
private String buildingName; |
||||
|
||||
private String deviceType; |
||||
|
||||
private String deviceId; |
||||
|
||||
private String deviceName; |
||||
|
||||
private BigDecimal curValue; |
||||
|
||||
private Date curTime; |
||||
|
||||
private String paramTypeId; |
||||
|
||||
private String otherName; |
||||
|
||||
private int dtOrderNum; |
||||
|
||||
private int dlOrderNum; |
||||
|
||||
private int ctOrderNum; |
||||
|
||||
private int digits; |
||||
|
||||
public BigDecimal getCurValue() { |
||||
return curValue; |
||||
} |
||||
|
||||
public void setCurValue(BigDecimal curValue) { |
||||
if (curValue!= null) { |
||||
// 保留两位小数
|
||||
curValue = curValue.setScale(2, BigDecimal.ROUND_HALF_UP); |
||||
} |
||||
this.curValue = curValue; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterControlListVO.class.getSimpleName() + "[", "]") |
||||
.add("cpmId='" + cpmId + "'") |
||||
.add("buildingId='" + buildingId + "'") |
||||
.add("buildingName='" + buildingName + "'") |
||||
.add("deviceType='" + deviceType + "'") |
||||
.add("deviceId='" + deviceId + "'") |
||||
.add("deviceName='" + deviceName + "'") |
||||
.add("curValue=" + curValue) |
||||
.add("curTime=" + curTime) |
||||
.add("paramTypeId='" + paramTypeId + "'") |
||||
.add("otherName='" + otherName + "'") |
||||
.add("dtOrderNum=" + dtOrderNum) |
||||
.add("dlOrderNum=" + dlOrderNum) |
||||
.add("ctOrderNum=" + ctOrderNum) |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,186 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 生活热水系统控制界面VO |
||||
* @date 2025-03-14 09:00:37 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterControlVO { |
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
// 运行状态 1d
|
||||
private int runningStatus; |
||||
private String runningStatusId; |
||||
|
||||
// 启停控制 2
|
||||
private int switchStatus; |
||||
private String switchStatusId; |
||||
|
||||
// 频率设置 3
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal frequencySet; |
||||
private String frequencySetId; |
||||
|
||||
// 频率 4
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal frequency; |
||||
private String frequencyId; |
||||
|
||||
// 故障状态 5
|
||||
private int alarmStatus; |
||||
private String alarmStatusId; |
||||
|
||||
// 手动自动切换 6
|
||||
private int handAutomaticSwitch; |
||||
private String handAutomaticSwitchId; |
||||
|
||||
// 开控制 8
|
||||
private int openSwitch; |
||||
private String openSwitchId; |
||||
|
||||
// 关控制 9
|
||||
private int closeSwitch; |
||||
private String closeSwitchId; |
||||
|
||||
// 水位设置 10
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0") |
||||
private BigDecimal waterLevelSet; |
||||
private String waterLevelSetId; |
||||
|
||||
// 水位 11
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0") |
||||
private BigDecimal waterLevel; |
||||
private String waterLevelId; |
||||
|
||||
// 温度 12
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal temp; |
||||
private String tempId; |
||||
|
||||
// 压力 13
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal pressure; |
||||
private String pressureId; |
||||
|
||||
// 温度设置 14
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal tempSet; |
||||
private String tempSetId; |
||||
|
||||
// 压力设置 15
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal pressureSet; |
||||
private String pressureSetId; |
||||
|
||||
// 延时时间设置 34
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal delayTimeSet; |
||||
private String delayTimeSetId; |
||||
|
||||
// 差值设置 35
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal diffValueSet; |
||||
private String diffValueSetId; |
||||
|
||||
// 计数器设置 36
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal counterSet; |
||||
private String counterSetId; |
||||
|
||||
// 切换时间设置 37
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal switchTimeSet; |
||||
private String switchTimeSetId; |
||||
|
||||
// 故障复位状态 38
|
||||
private int faultResetStatus; |
||||
private String faultResetStatusId; |
||||
|
||||
// 急停状态 39
|
||||
private int emergencyStopStatus; |
||||
private String emergencyStopStatusId; |
||||
|
||||
// 最低设置值 44
|
||||
private int minSet; |
||||
private String minSetId; |
||||
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
private Date curTime; |
||||
|
||||
private int orderNum; |
||||
|
||||
public void setCounterSet(BigDecimal counterSet) { |
||||
if (counterSet != null) { |
||||
counterSet = counterSet.setScale(0, BigDecimal.ROUND_HALF_UP); |
||||
} |
||||
this.counterSet = counterSet; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterControlVO.class.getSimpleName() + "[", "]") |
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("runningStatus=" + runningStatus) |
||||
.add("runningStatusId='" + runningStatusId + "'") |
||||
.add("switchStatus=" + switchStatus) |
||||
.add("switchStatusId='" + switchStatusId + "'") |
||||
.add("frequencySet=" + frequencySet) |
||||
.add("frequencySetId='" + frequencySetId + "'") |
||||
.add("frequency=" + frequency) |
||||
.add("frequencyId='" + frequencyId + "'") |
||||
.add("alarmStatus=" + alarmStatus) |
||||
.add("alarmStatusId='" + alarmStatusId + "'") |
||||
.add("handAutomaticSwitch=" + handAutomaticSwitch) |
||||
.add("handAutomaticSwitchId='" + handAutomaticSwitchId + "'") |
||||
.add("openSwitch=" + openSwitch) |
||||
.add("openSwitchId='" + openSwitchId + "'") |
||||
.add("closeSwitch=" + closeSwitch) |
||||
.add("closeSwitchId='" + closeSwitchId + "'") |
||||
.add("waterLevelSet=" + waterLevelSet) |
||||
.add("waterLevelSetId='" + waterLevelSetId + "'") |
||||
.add("waterLevel=" + waterLevel) |
||||
.add("waterLevelId='" + waterLevelId + "'") |
||||
.add("temp=" + temp) |
||||
.add("tempId='" + tempId + "'") |
||||
.add("pressure=" + pressure) |
||||
.add("pressureId='" + pressureId + "'") |
||||
.add("tempSet=" + tempSet) |
||||
.add("tempSetId='" + tempSetId + "'") |
||||
.add("pressureSet=" + pressureSet) |
||||
.add("pressureSetId='" + pressureSetId + "'") |
||||
.add("delayTimeSet=" + delayTimeSet) |
||||
.add("delayTimeSetId='" + delayTimeSetId + "'") |
||||
.add("diffValueSet=" + diffValueSet) |
||||
.add("diffValueSetId='" + diffValueSetId + "'") |
||||
.add("counterSet=" + counterSet) |
||||
.add("counterSetId='" + counterSetId + "'") |
||||
.add("switchTimeSet=" + switchTimeSet) |
||||
.add("switchTimeSetId='" + switchTimeSetId + "'") |
||||
.add("faultResetStatus=" + faultResetStatus) |
||||
.add("faultResetStatusId='" + faultResetStatusId + "'") |
||||
.add("emergencyStopStatus=" + emergencyStopStatus) |
||||
.add("emergencyStopStatusId='" + emergencyStopStatusId + "'") |
||||
.add("minSet=" + minSet) |
||||
.add("minSetId='" + minSetId + "'") |
||||
.add("curTime=" + curTime) |
||||
.add("orderNum=" + orderNum) |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,71 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 设备校准控制界面VO |
||||
* @date 2025-03-14 09:00:37 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterDeviceCalibrationControlVO { |
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
private int orderNum; |
||||
|
||||
// 校准值
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal calibrationValue; |
||||
private String calibrationValueId; |
||||
|
||||
// 工程量最低值
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal engineeringMinValue; |
||||
private String engineeringMinValueId; |
||||
|
||||
// 工程量最高值
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal engineeringMaxValue; |
||||
private String engineeringMaxValueId; |
||||
|
||||
// 数字量最低值
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal digitalMinValue; |
||||
private String digitalMinValueId; |
||||
|
||||
// 数字量最高值
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal digitalMaxValue; |
||||
private String digitalMaxValueId; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterDeviceCalibrationControlVO.class.getSimpleName() + "[", "]") |
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("orderNum=" + orderNum) |
||||
.add("calibrationValue=" + calibrationValue) |
||||
.add("calibrationValueId='" + calibrationValueId + "'") |
||||
.add("engineeringMinValue=" + engineeringMinValue) |
||||
.add("engineeringMinValueId='" + engineeringMinValueId + "'") |
||||
.add("engineeringMaxValue=" + engineeringMaxValue) |
||||
.add("engineeringMaxValueId='" + engineeringMaxValueId + "'") |
||||
.add("digitalMinValue=" + digitalMinValue) |
||||
.add("digitalMinValueId='" + digitalMinValueId + "'") |
||||
.add("digitalMaxValue=" + digitalMaxValue) |
||||
.add("digitalMaxValueId='" + digitalMaxValueId + "'") |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,69 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 生活热水系统控制界面VO |
||||
* @date 2025-03-14 09:00:37 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterDeviceControlVO { |
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
private int orderNum; |
||||
|
||||
// 累计读数
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING) |
||||
private BigDecimal totalReading; |
||||
private String totalReadingId; |
||||
|
||||
// 当前时间
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
private Date currentTime; |
||||
private String currentTimeId; |
||||
|
||||
/** |
||||
* 通讯失败 |
||||
*/ |
||||
private int communicationFailure; |
||||
private String communicationFailureId; |
||||
|
||||
/** |
||||
* 通讯失败次数 |
||||
* @return |
||||
*/ |
||||
private int communicationFailureCount; |
||||
private String communicationFailureCountId; |
||||
|
||||
/** |
||||
* modbus 复位 |
||||
*/ |
||||
private int reset; |
||||
private String resetId; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterDeviceControlVO.class.getSimpleName() + "[", "]") |
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("orderNum=" + orderNum) |
||||
.add("totalReading=" + totalReading) |
||||
.add("totalReadingId='" + totalReadingId + "'") |
||||
.add("currentTime=" + currentTime) |
||||
.add("currentTimeId='" + currentTimeId + "'") |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,316 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 热泵控制界面VO |
||||
* @date 2025-03-14 09:00:37 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterHotPumpControlVO { // 去掉pump后的类名
|
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
private int orderNum; |
||||
|
||||
// 热泵12定时_时开1
|
||||
private int oneHourTimeOpenSetOne; |
||||
private String oneHourTimeOpenSetOneId; |
||||
|
||||
// 热泵12定时_分开1 (新增分钟设置)
|
||||
private int oneMinTimeOpenSetOne; |
||||
private String oneMinTimeOpenSetOneId; |
||||
|
||||
// 定时_时分开1
|
||||
private String oneHourMinTimeOpenSetOneStr; |
||||
|
||||
// 热泵12定时_时关1
|
||||
private int oneHourTimeCloseSetOne; |
||||
private String oneHourTimeCloseSetOneId; |
||||
|
||||
// 热泵12定时_分关1 (新增分钟设置)
|
||||
private int oneMinTimeCloseSetOne; |
||||
private String oneMinTimeCloseSetOneId; |
||||
|
||||
// 定时_时分关1
|
||||
private String oneHourMinTimeCloseSetOneStr; |
||||
|
||||
// 热泵12定时_时开2
|
||||
private int oneHourTimeOpenSetTwo; |
||||
private String oneHourTimeOpenSetTwoId; |
||||
|
||||
// 热泵12定时_分开2 (新增分钟设置)
|
||||
private int oneMinTimeOpenSetTwo; |
||||
private String oneMinTimeOpenSetTwoId; |
||||
|
||||
// 定时_时分开2
|
||||
private String oneHourMinTimeOpenSetTwoStr; |
||||
|
||||
// 热泵12定时_时关2
|
||||
private int oneHourTimeCloseSetTwo; |
||||
private String oneHourTimeCloseSetTwoId; |
||||
|
||||
// 热泵12定时_分关2 (新增分钟设置)
|
||||
private int oneMinTimeCloseSetTwo; |
||||
private String oneMinTimeCloseSetTwoId; |
||||
|
||||
// 定时_时分关2
|
||||
private String oneHourMinTimeCloseSetTwoStr; |
||||
|
||||
// 热泵12定时_时开3
|
||||
private int oneHourTimeOpenSetThree; |
||||
private String oneHourTimeOpenSetThreeId; |
||||
|
||||
// 热泵12定时_分开3 (新增分钟设置)
|
||||
private int oneMinTimeOpenSetThree; |
||||
private String oneMinTimeOpenSetThreeId; |
||||
|
||||
// 定时_时分开3
|
||||
private String oneHourMinTimeOpenSetThreeStr; |
||||
|
||||
// 热泵12定时_时关3
|
||||
private int oneHourTimeCloseSetThree; |
||||
private String oneHourTimeCloseSetThreeId; |
||||
|
||||
// 热泵12定时_分关3 (新增分钟设置)
|
||||
private int oneMinTimeCloseSetThree; |
||||
private String oneMinTimeCloseSetThreeId; |
||||
|
||||
// 定时_时分关3
|
||||
private String oneHourMinTimeCloseSetThreeStr; |
||||
|
||||
// 热泵34定时_时开1
|
||||
private int twoHourTimeOpenSetOne; |
||||
private String twoHourTimeOpenSetOneId; |
||||
|
||||
// 热泵34定时_分开1 (新增分钟设置)
|
||||
private int twoMinTimeOpenSetOne; |
||||
private String twoMinTimeOpenSetOneId; |
||||
|
||||
// 定时_时分开1
|
||||
private String twoHourMinTimeOpenSetOneStr; |
||||
|
||||
// 热泵34定时_时关1
|
||||
private int twoHourTimeCloseSetOne; |
||||
private String twoHourTimeCloseSetOneId; |
||||
|
||||
// 热泵34定时_分关1 (新增分钟设置)
|
||||
private int twoMinTimeCloseSetOne; |
||||
private String twoMinTimeCloseSetOneId; |
||||
|
||||
// 定时_时分关1
|
||||
private String twoHourMinTimeCloseSetOneStr; |
||||
|
||||
// 热泵34定时_时开2
|
||||
private int twoHourTimeOpenSetTwo; |
||||
private String twoHourTimeOpenSetTwoId; |
||||
|
||||
// 热泵34定时_分开2 (新增分钟设置)
|
||||
private int twoMinTimeOpenSetTwo; |
||||
private String twoMinTimeOpenSetTwoId; |
||||
|
||||
// 定时_时分开2
|
||||
private String twoHourMinTimeOpenSetTwoStr; |
||||
|
||||
// 热泵34定时_时关2
|
||||
private int twoHourTimeCloseSetTwo; |
||||
private String twoHourTimeCloseSetTwoId; |
||||
|
||||
// 热泵34定时_分关2 (新增分钟设置)
|
||||
private int twoMinTimeCloseSetTwo; |
||||
private String twoMinTimeCloseSetTwoId; |
||||
|
||||
// 定时_时分关2
|
||||
private String twoHourMinTimeCloseSetTwoStr; |
||||
|
||||
// 热泵34定时_时开3
|
||||
private int twoHourTimeOpenSetThree; |
||||
private String twoHourTimeOpenSetThreeId; |
||||
|
||||
// 热泵34定时_分开3 (新增分钟设置)
|
||||
private int twoMinTimeOpenSetThree; |
||||
private String twoMinTimeOpenSetThreeId; |
||||
|
||||
// 定时_时分开3
|
||||
private String twoHourMinTimeOpenSetThreeStr; |
||||
|
||||
// 热泵34定时_时关3
|
||||
private int twoHourTimeCloseSetThree; |
||||
private String twoHourTimeCloseSetThreeId; |
||||
|
||||
// 热泵34定时_分关3 (新增分钟设置)
|
||||
private int twoMinTimeCloseSetThree; |
||||
private String twoMinTimeCloseSetThreeId; |
||||
|
||||
// 定时_时分关3
|
||||
private String twoHourMinTimeCloseSetThreeStr; |
||||
|
||||
// 热泵_开机 -> 去掉pump前缀
|
||||
private String start; |
||||
private String startId; |
||||
|
||||
// 热泵_关机 -> 去掉pump前缀
|
||||
private String stop; |
||||
private String stopId; |
||||
|
||||
// 热泵_运行状态 -> 去掉pump前缀
|
||||
private int runState; |
||||
private String runStateId; |
||||
|
||||
// 热泵_启停控制 -> 去掉pump前缀
|
||||
private int startStopControl; |
||||
private String startStopControlId; |
||||
|
||||
// 热泵_手自动切换 -> 去掉pump前缀
|
||||
private int manualAutoSwitch; |
||||
private String manualAutoSwitchId; |
||||
|
||||
// 热泵_12启停控制
|
||||
private int startStopControlOne; |
||||
private String startStopControlOneId; |
||||
|
||||
// 热泵_34启停控制
|
||||
private int startStopControlTwo; |
||||
private String startStopControlTwoId; |
||||
// 热泵_12手自动切换
|
||||
private int manualAutoSwitchOne; |
||||
private String manualAutoSwitchOneId; |
||||
|
||||
// 热泵_34手自动切换
|
||||
private int manualAutoSwitchTwo; |
||||
private String manualAutoSwitchTwoId; |
||||
|
||||
|
||||
// 热泵_设定温度 -> 去掉pump前缀
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal setTemp; |
||||
private String setTempId; |
||||
|
||||
// 热泵_水箱温度 -> 去掉pump前缀
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal tankTemp; |
||||
private String tankTempId; |
||||
|
||||
// 热泵累计运行时间 -> 去掉pump前缀
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal runTime; |
||||
private String runTimeId; |
||||
|
||||
// 热泵_出水温度 -> 去掉pump前缀
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal outWaterTemp; |
||||
private String outWaterTempId; |
||||
|
||||
// 热泵_进水温度 -> 去掉pump前缀
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal inWaterTemp; |
||||
private String inWaterTempId; |
||||
|
||||
// 热泵_故障 -> 去掉pump前缀
|
||||
private int fault; |
||||
|
||||
/** |
||||
* 通讯失败 |
||||
*/ |
||||
private int communicationFailure; |
||||
private String communicationFailureId; |
||||
|
||||
/** |
||||
* 通讯失败次数 |
||||
* @return |
||||
*/ |
||||
private int communicationFailureCount; |
||||
private String communicationFailureCountId; |
||||
|
||||
/** |
||||
* modbus 复位 |
||||
*/ |
||||
private int reset; |
||||
private String resetId; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterHotPumpControlVO.class.getSimpleName() + "[", "]") // 更新类名引用
|
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("oneHourTimeOpenSetOne=" + oneHourTimeOpenSetOne) |
||||
.add("oneHourTimeOpenSetOneId='" + oneHourTimeOpenSetOneId + "'") |
||||
.add("oneMinTimeOpenSetOne=" + oneMinTimeOpenSetOne) // 新增分钟字段
|
||||
.add("oneMinTimeOpenSetOneId='" + oneMinTimeOpenSetOneId + "'") // 新增分钟字段
|
||||
.add("oneHourTimeCloseSetOne=" + oneHourTimeCloseSetOne) |
||||
.add("oneHourTimeCloseSetOneId='" + oneHourTimeCloseSetOneId + "'") |
||||
.add("oneMinTimeCloseSetOne=" + oneMinTimeCloseSetOne) // 新增分钟字段
|
||||
.add("oneMinTimeCloseSetOneId='" + oneMinTimeCloseSetOneId + "'") // 新增分钟字段
|
||||
.add("oneHourTimeOpenSetTwo=" + oneHourTimeOpenSetTwo) |
||||
.add("oneHourTimeOpenSetTwoId='" + oneHourTimeOpenSetTwoId + "'") |
||||
.add("oneMinTimeOpenSetTwo=" + oneMinTimeOpenSetTwo) // 新增分钟字段
|
||||
.add("oneMinTimeOpenSetTwoId='" + oneMinTimeOpenSetTwoId + "'") // 新增分钟字段
|
||||
.add("oneHourTimeCloseSetTwo=" + oneHourTimeCloseSetTwo) |
||||
.add("oneHourTimeCloseSetTwoId='" + oneHourTimeCloseSetTwoId + "'") |
||||
.add("oneMinTimeCloseSetTwo=" + oneMinTimeCloseSetTwo) // 新增分钟字段
|
||||
.add("oneMinTimeCloseSetTwoId='" + oneMinTimeCloseSetTwoId + "'") // 新增分钟字段
|
||||
.add("oneHourTimeOpenSetThree=" + oneHourTimeOpenSetThree) |
||||
.add("oneHourTimeOpenSetThreeId='" + oneHourTimeOpenSetThreeId + "'") |
||||
.add("oneMinTimeOpenSetThree=" + oneMinTimeOpenSetThree) // 新增分钟字段
|
||||
.add("oneMinTimeOpenSetThreeId='" + oneMinTimeOpenSetThreeId + "'") // 新增分钟字段
|
||||
.add("oneHourTimeCloseSetThree=" + oneHourTimeCloseSetThree) |
||||
.add("oneHourTimeCloseSetThreeId='" + oneHourTimeCloseSetThreeId + "'") |
||||
.add("oneMinTimeCloseSetThree=" + oneMinTimeCloseSetThree) // 新增分钟字段
|
||||
.add("oneMinTimeCloseSetThreeId='" + oneMinTimeCloseSetThreeId + "'") // 新增分钟字段
|
||||
.add("twoHourTimeOpenSetOne=" + twoHourTimeOpenSetOne) |
||||
.add("twoHourTimeOpenSetOneId='" + twoHourTimeOpenSetOneId + "'") |
||||
.add("twoMinTimeOpenSetOne=" + twoMinTimeOpenSetOne) // 新增分钟字段
|
||||
.add("twoMinTimeOpenSetOneId='" + twoMinTimeOpenSetOneId + "'") // 新增分钟字段
|
||||
.add("twoHourTimeCloseSetOne=" + twoHourTimeCloseSetOne) |
||||
.add("twoHourTimeCloseSetOneId='" + twoHourTimeCloseSetOneId + "'") |
||||
.add("twoMinTimeCloseSetOne=" + twoMinTimeCloseSetOne) // 新增分钟字段
|
||||
.add("twoMinTimeCloseSetOneId='" + twoMinTimeCloseSetOneId + "'") // 新增分钟字段
|
||||
.add("twoHourTimeOpenSetTwo=" + twoHourTimeOpenSetTwo) |
||||
.add("twoHourTimeOpenSetTwoId='" + twoHourTimeOpenSetTwoId + "'") |
||||
.add("twoMinTimeOpenSetTwo=" + twoMinTimeOpenSetTwo) // 新增分钟字段
|
||||
.add("twoMinTimeOpenSetTwoId='" + twoMinTimeOpenSetTwoId + "'") // 新增分钟字段
|
||||
.add("twoHourTimeCloseSetTwo=" + twoHourTimeCloseSetTwo) |
||||
.add("twoHourTimeCloseSetTwoId='" + twoHourTimeCloseSetTwoId + "'") |
||||
.add("twoMinTimeCloseSetTwo=" + twoMinTimeCloseSetTwo) // 新增分钟字段
|
||||
.add("twoMinTimeCloseSetTwoId='" + twoMinTimeCloseSetTwoId + "'") // 新增分钟字段
|
||||
.add("twoHourTimeOpenSetThree=" + twoHourTimeOpenSetThree) |
||||
.add("twoHourTimeOpenSetThreeId='" + twoHourTimeOpenSetThreeId + "'") |
||||
.add("twoMinTimeOpenSetThree=" + twoMinTimeOpenSetThree) // 新增分钟字段
|
||||
.add("twoMinTimeOpenSetThreeId='" + twoMinTimeOpenSetThreeId + "'") // 新增分钟字段
|
||||
.add("twoHourTimeCloseSetThree=" + twoHourTimeCloseSetThree) |
||||
.add("twoHourTimeCloseSetThreeId='" + twoHourTimeCloseSetThreeId + "'") |
||||
.add("twoMinTimeCloseSetThree=" + twoMinTimeCloseSetThree) // 新增分钟字段
|
||||
.add("twoMinTimeCloseSetThreeId='" + twoMinTimeCloseSetThreeId + "'") // 新增分钟字段
|
||||
.add("start='" + start + "'") |
||||
.add("startId='" + startId + "'") |
||||
.add("stop='" + stop + "'") |
||||
.add("stopId='" + stopId + "'") |
||||
.add("runState='" + runState + "'") |
||||
.add("runStateId='" + runStateId + "'") |
||||
.add("startStopControl='" + startStopControl + "'") |
||||
.add("startStopControlId='" + startStopControlId + "'") |
||||
.add("setTemp=" + setTemp) |
||||
.add("setTempId='" + setTempId + "'") |
||||
.add("tankTemp=" + tankTemp) |
||||
.add("tankTempId='" + tankTempId + "'") |
||||
.add("runTime=" + runTime) |
||||
.add("runTimeId='" + runTimeId + "'") |
||||
.add("outWaterTemp=" + outWaterTemp) |
||||
.add("outWaterTempId='" + outWaterTempId + "'") |
||||
.add("inWaterTemp=" + inWaterTemp) |
||||
.add("inWaterTempId='" + inWaterTempId + "'") |
||||
.add("fault=" + fault) |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,63 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 热水实时监控列表数据 |
||||
* @date 2025-03-10 15:43:36 |
||||
*/ |
||||
@Data |
||||
public class HotWaterNowDataDTO { |
||||
|
||||
private String id; |
||||
private String curDate; //日期
|
||||
private String buildingId; //楼栋编号
|
||||
private String buildingName; //楼栋名称
|
||||
private String pumpId; //热泵编号
|
||||
private String pumpName; //热泵名称
|
||||
private String tempSet; //水温设定
|
||||
private String waterTemp; //水箱水温
|
||||
private String runState; //运行状态
|
||||
private String isFault; //是否故障
|
||||
private String levelSet1; //水位设置
|
||||
private String levelSet2; //水位设置
|
||||
private String waterLevel1; //实际水位
|
||||
private String waterLevel2; //实际水位
|
||||
private String tankId; //水箱编号
|
||||
private String tankName; //水箱名称
|
||||
private String envTemp; //环境温度
|
||||
|
||||
private String upWaterState1; // 供水1泵状态
|
||||
|
||||
private String freq1; // 供水频率1
|
||||
|
||||
private String upWaterState2; // 供水2泵状态
|
||||
|
||||
private String freq2; // 供水频率2
|
||||
|
||||
private String upWaterState3; // 供水3泵状态
|
||||
|
||||
private String freq3; // 供水频率3
|
||||
|
||||
private String upWaterState4; // 供水4泵状态
|
||||
|
||||
private String freq4; // 供水频率4
|
||||
|
||||
private String useWaterState; // 补水状态
|
||||
|
||||
private String backWaterState; // 回水状态1
|
||||
|
||||
private String backWaterState2; // 回水状态2
|
||||
|
||||
private String pressure; // 压力
|
||||
|
||||
private String circulateState; // 循环泵状态1
|
||||
|
||||
private String circulateState2; // 循环泵状态2
|
||||
|
||||
private int orderNum; |
||||
|
||||
} |
||||
@ -1,151 +0,0 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 生活热水系统控制界面VO |
||||
* @date 2025-03-14 09:00:37 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class HotWaterSystemControlVO { |
||||
|
||||
private String id; |
||||
|
||||
private String name; |
||||
|
||||
// 启用时间写入 1
|
||||
private int timeSet; |
||||
private String timeSetId; |
||||
|
||||
// 水箱温度 2
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal tankTemp; |
||||
private String tankTempId; |
||||
|
||||
// 太阳能温度 3
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal solarTemp; |
||||
private String solarTempId; |
||||
|
||||
// 回水温度 4
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal inTemp; |
||||
private String inTempId; |
||||
|
||||
// 压力 4
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") |
||||
private BigDecimal pressure; |
||||
private String pressureId; |
||||
|
||||
// PLC 时间
|
||||
private String plcTime; |
||||
// 秒_读 6
|
||||
private int scTimeRead; |
||||
private String scTimeReadId; |
||||
|
||||
// 分_读 8
|
||||
private int minTimeRead; |
||||
private String minTimeReadId; |
||||
|
||||
// 时_读 9
|
||||
private int hourTimeRead; |
||||
private String hourTimeReadId; |
||||
|
||||
// 日_读 9
|
||||
private int dayTimeRead; |
||||
private String dayTimeReadId; |
||||
|
||||
// 月_读 10
|
||||
private int monthTimeRead; |
||||
private String monthTimeReadId; |
||||
|
||||
// 年_读 11
|
||||
private int yearTimeRead; |
||||
private String yearTimeReadId; |
||||
|
||||
// 秒_写 6
|
||||
private int scTimeSet; |
||||
private String scTimeSetId; |
||||
|
||||
// 分_写 8
|
||||
private int minTimeSet; |
||||
private String minTimeSetId; |
||||
|
||||
// 时_写 9
|
||||
private int hourTimeSet; |
||||
private String hourTimeSetId; |
||||
|
||||
// 日_写 9
|
||||
private int dayTimeSet; |
||||
private String dayTimeSetId; |
||||
|
||||
// 月_写 10
|
||||
private int monthTimeSet; |
||||
private String monthTimeSetId; |
||||
|
||||
// 年_写 11
|
||||
private int yearTimeSet; |
||||
private String yearTimeSetId; |
||||
|
||||
private int orderNum; |
||||
|
||||
/** |
||||
* modbus 复位 |
||||
*/ |
||||
private int reset; |
||||
private String resetId; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", HotWaterSystemControlVO.class.getSimpleName() + "[", "]") |
||||
.add("id='" + id + "'") |
||||
.add("name='" + name + "'") |
||||
.add("timeSet=" + timeSet) |
||||
.add("timeSetId='" + timeSetId + "'") |
||||
.add("tankTemp=" + tankTemp) |
||||
.add("tankTempId='" + tankTempId + "'") |
||||
.add("solarTemp=" + solarTemp) |
||||
.add("solarTempId='" + solarTempId + "'") |
||||
.add("inTemp=" + inTemp) |
||||
.add("inTempId='" + inTempId + "'") |
||||
.add("pressure=" + pressure) |
||||
.add("pressureId='" + pressureId + "'") |
||||
.add("plcTime='" + plcTime + "'") |
||||
.add("scTimeRead=" + scTimeRead) |
||||
.add("scTimeReadId='" + scTimeReadId + "'") |
||||
.add("minTimeRead=" + minTimeRead) |
||||
.add("minTimeReadId='" + minTimeReadId + "'") |
||||
.add("hourTimeRead=" + hourTimeRead) |
||||
.add("hourTimeReadId='" + hourTimeReadId + "'") |
||||
.add("dayTimeRead=" + dayTimeRead) |
||||
.add("dayTimeReadId='" + dayTimeReadId + "'") |
||||
.add("monthTimeRead=" + monthTimeRead) |
||||
.add("monthTimeReadId='" + monthTimeReadId + "'") |
||||
.add("yearTimeRead=" + yearTimeRead) |
||||
.add("yearTimeReadId='" + yearTimeReadId + "'") |
||||
.add("scTimeSet=" + scTimeSet) |
||||
.add("scTimeSetId='" + scTimeSetId + "'") |
||||
.add("minTimeSet=" + minTimeSet) |
||||
.add("minTimeSetId='" + minTimeSetId + "'") |
||||
.add("hourTimeSet=" + hourTimeSet) |
||||
.add("hourTimeSetId='" + hourTimeSetId + "'") |
||||
.add("dayTimeSet=" + dayTimeSet) |
||||
.add("dayTimeSetId='" + dayTimeSetId + "'") |
||||
.add("monthTimeSet=" + monthTimeSet) |
||||
.add("monthTimeSetId='" + monthTimeSetId + "'") |
||||
.add("yearTimeSet=" + yearTimeSet) |
||||
.add("yearTimeSetId='" + yearTimeSetId + "'") |
||||
.add("orderNum=" + orderNum) |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,108 +0,0 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.io.Serializable; |
||||
import java.math.BigDecimal; |
||||
import java.time.LocalDateTime; |
||||
import java.util.Date; |
||||
import java.util.StringJoiner; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 采集参数实体类 |
||||
* @date 2025-12-10 10:53:33 |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
public class CollectionParamsManageEntity implements Serializable { |
||||
|
||||
static final long serialVersionUID = 42L; |
||||
|
||||
private Long id; |
||||
|
||||
/** 当前时间 */ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date createTime; |
||||
|
||||
/** 当前时间 */ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date updateTime; |
||||
private Long buildingId; |
||||
/** 设备id */ |
||||
private Long deviceInstallId; |
||||
/** 寄存器地址 */ |
||||
private String registerAddr; |
||||
/** 功能码 */ |
||||
private String funcCode; |
||||
/** 倍率 */ |
||||
private Integer mtRatio; |
||||
/** 初始值 */ |
||||
private BigDecimal mtInitValue; |
||||
/** 小数点 */ |
||||
private Integer digits; |
||||
/** 数据类型 */ |
||||
private Integer dataType; |
||||
/** 当前值 */ |
||||
private BigDecimal curValue; |
||||
/** 当前时间 */ |
||||
/** 当前时间 */ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date curTime; |
||||
/** 是否是总表 (0: 是, 1: 否) */ |
||||
private Integer mtIsSum; |
||||
/** 单位 */ |
||||
private String unit; |
||||
/** 排序 */ |
||||
private Long orderNum; |
||||
/** 备注 */ |
||||
private String remark; |
||||
/** 读取的寄存器大小 */ |
||||
private Integer registerSize; |
||||
/** 是否使用 */ |
||||
private Integer isUse; |
||||
/** 别名:mqtt上传名,唯一值 */ |
||||
private String otherName; |
||||
/** 40,累计值,140瞬时值 */ |
||||
private Integer grade; |
||||
/** 参数id */ |
||||
private Integer paramTypeId; |
||||
/** 遥测、遥信数据类型 */ |
||||
private Integer collectionType; |
||||
/** 上报质量 */ |
||||
private String quality; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new StringJoiner(", ", CollectionParamsManageEntity.class.getSimpleName() + "[", "]") |
||||
.add("deviceInstallId=" + deviceInstallId) |
||||
.add("registerAddr='" + registerAddr + "'") |
||||
.add("funcCode='" + funcCode + "'") |
||||
.add("mtRatio=" + mtRatio) |
||||
.add("mtInitValue=" + mtInitValue) |
||||
.add("digits=" + digits) |
||||
.add("dataType=" + dataType) |
||||
.add("curValue=" + curValue) |
||||
.add("curTime=" + curTime) |
||||
.add("mtIsSum=" + mtIsSum) |
||||
.add("unit='" + unit + "'") |
||||
.add("orderNum=" + orderNum) |
||||
.add("remark='" + remark + "'") |
||||
.add("registerSize=" + registerSize) |
||||
.add("isUse=" + isUse) |
||||
.add("otherName='" + otherName + "'") |
||||
.add("grade=" + grade) |
||||
.add("paramTypeId=" + paramTypeId) |
||||
.add("collectionType=" + collectionType) |
||||
.add("quality='" + quality + "'") |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -1,38 +0,0 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @Author: ljf |
||||
* @Date: 2018/10/15 14:30 |
||||
* @Version 1.0 |
||||
* 水压数据 |
||||
*/ |
||||
|
||||
@Data |
||||
public class WaterPressureEntity { |
||||
|
||||
private Date curDate; |
||||
private String buildingID; |
||||
private String buildingName; |
||||
private String deviceAddr; |
||||
private String deviceName; |
||||
private String pressure00; |
||||
private String pressure02; |
||||
private String pressure06; |
||||
private String pressure08; |
||||
private String pressure11; |
||||
private String pressure13; |
||||
private String pressure14; |
||||
private String pressure15; |
||||
private String pressure16; |
||||
private String pressure17; |
||||
private String pressure18; |
||||
private String pressure19; |
||||
private String pressure20; |
||||
private String pressure21; |
||||
private String pressure22; |
||||
private String pressure23; |
||||
} |
||||
@ -1,51 +0,0 @@
|
||||
package com.mh.user.factory; |
||||
|
||||
import com.mh.user.entity.CollectionParamsManageEntity; |
||||
import com.mh.user.entity.DeviceCodeParamEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.strategy.DeviceStrategy; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 系统参数 |
||||
* @date 2024-03-18 16:53:35 |
||||
*/ |
||||
public class SystemParams implements Device { |
||||
|
||||
private DeviceStrategy strategy; |
||||
|
||||
private static class SingletonHolder { |
||||
private static final SystemParams INSTANCE = new SystemParams(); |
||||
} |
||||
|
||||
private SystemParams() { |
||||
// 防止外部直接实例化
|
||||
} |
||||
|
||||
public static SystemParams getInstance() { |
||||
return SystemParams.SingletonHolder.INSTANCE; |
||||
} |
||||
|
||||
@Override |
||||
public void setStrategy(DeviceStrategy strategy) { |
||||
this.strategy = strategy; |
||||
} |
||||
|
||||
@Override |
||||
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
||||
return strategy.createOrders(deviceCodeParamEntity); |
||||
} |
||||
|
||||
@Override |
||||
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
||||
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
||||
} |
||||
|
||||
@Override |
||||
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
||||
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
||||
} |
||||
|
||||
} |
||||
@ -1,329 +0,0 @@
|
||||
package com.mh.user.mapper; |
||||
|
||||
import com.mh.user.dto.HotWaterControlListVO; |
||||
import com.mh.user.entity.CollectionParamsManageEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.model.SanShiFengDatas; |
||||
import org.apache.ibatis.annotations.*; |
||||
import tk.mybatis.mapper.common.BaseMapper; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 采集参数设备mapper类 |
||||
* @date 2025-12-10 11:31:42 |
||||
*/ |
||||
@Mapper |
||||
public interface CollectionParamsManageMapper extends BaseMapper<CollectionParamsManageEntity> { |
||||
|
||||
@Select("<script>" + |
||||
"SELECT * FROM (" + |
||||
"SELECT cpm.*, ROW_NUMBER() OVER (ORDER BY cpm.device_install_id) AS row_num " + |
||||
"FROM collection_params_manage cpm join device_install di on cpm.device_install_id = di.id where 1=1" + |
||||
"<if test='deviceInstallId != null and deviceInstallId != \"\"'>" + |
||||
"AND cpm.device_install_id = #{deviceInstallId} " + |
||||
"</if>" + |
||||
"<if test='buildingId != null and buildingId != \"\"'>" + |
||||
"AND di.building_id = #{buildingId} " + |
||||
"</if>" + |
||||
"<if test='otherName != null and otherName != \"\"'>" + |
||||
"AND cpm.other_name LIKE CONCAT('%', #{otherName}, '%') " + |
||||
"</if>" + |
||||
") AS t WHERE t.row_num BETWEEN (#{pageNum}-1)*#{pageSize} AND #{pageNum}*#{pageSize}" + |
||||
"</script>") |
||||
@Results({ |
||||
@Result(column = "id", property = "id"), |
||||
@Result(column = "create_time", property = "createTime"), |
||||
@Result(column = "update_time", property = "updateTime"), |
||||
@Result(column = "device_install_id", property = "deviceInstallId"), |
||||
@Result(column = "register_addr", property = "registerAddr"), |
||||
@Result(column = "func_code", property = "funcCode"), |
||||
@Result(column = "mt_ratio", property = "mtRatio"), |
||||
@Result(column = "mt_init_value", property = "mtInitValue"), |
||||
@Result(column = "digits", property = "digits"), |
||||
@Result(column = "data_type", property = "dataType"), |
||||
@Result(column = "cur_value", property = "curValue"), |
||||
@Result(column = "cur_time", property = "curTime"), |
||||
@Result(column = "mt_is_sum", property = "mtIsSum"), |
||||
@Result(column = "unit", property = "unit"), |
||||
@Result(column = "order_num", property = "orderNum"), |
||||
@Result(column = "remark", property = "remark"), |
||||
@Result(column = "register_size", property = "registerSize"), |
||||
@Result(column = "is_use", property = "isUse"), |
||||
@Result(column = "other_name", property = "otherName"), |
||||
@Result(column = "grade", property = "grade"), |
||||
@Result(column = "param_type_id", property = "paramTypeId"), |
||||
@Result(column = "collection_type", property = "collectionType"), |
||||
@Result(column = "quality", property = "quality") |
||||
}) |
||||
List<CollectionParamsManageEntity> selectCPMList(String buildingId,String deviceInstallId, String otherName, Integer pageNum, Integer pageSize); |
||||
|
||||
@Select("<script>" + |
||||
"SELECT count(1) " + |
||||
"FROM collection_params_manage cpm join device_install di on cpm.device_install_id = di.id where 1=1" + |
||||
"<if test='deviceInstallId != null and deviceInstallId != \"\"'>" + |
||||
"AND cpm.device_install_id = #{deviceInstallId} " + |
||||
"</if>" + |
||||
"<if test='buildingId != null and buildingId != \"\"'>" + |
||||
"AND di.building_id = #{buildingId} " + |
||||
"</if>" + |
||||
"<if test='otherName != null and otherName != \"\"'>" + |
||||
"AND cpm.other_name LIKE CONCAT('%', #{otherName}, '%') " + |
||||
"</if>" + |
||||
"</script>") |
||||
int selectCPMListCount(String buildingId, String deviceInstallId, String otherName, Integer pageNum, Integer pageSize); |
||||
|
||||
@Select("select count(1) from collection_params_manage where other_name = #{otherName} ") |
||||
int selectCountByOtherName(String otherName); |
||||
|
||||
@Update("update collection_params_manage set cur_value = #{value}, cur_time = #{time}, quality = #{quality} where other_name = #{name} and building_id = #{buildingId}") |
||||
void updateCPMByOtherName(String name, BigDecimal value, String time, String quality, String buildingId); |
||||
|
||||
@Update("<script>" + |
||||
"WITH BatchData AS (" + |
||||
"<foreach collection='batch' item='item' separator='UNION ALL'>" + |
||||
"SELECT #{item.name} AS other_name, #{item.value} AS cur_value" + |
||||
"</foreach>" + |
||||
") " + |
||||
"MERGE collection_params_manage AS target " + |
||||
"USING BatchData AS source " + |
||||
"ON (target.other_name = source.other_name AND target.building_id = #{buildingId}) " + |
||||
"WHEN MATCHED THEN " + |
||||
" UPDATE SET " + |
||||
" cur_value = source.cur_value, " + |
||||
" cur_time = #{time}, " + |
||||
" quality = #{quality};" + |
||||
"</script>") |
||||
void updateBatchCPMByOtherName(@Param("batch") List<SanShiFengDatas> batch, |
||||
@Param("time") String time, |
||||
@Param("quality") String quality, |
||||
@Param("buildingId") String buildingId); |
||||
|
||||
|
||||
@Select("select top 1 * from collection_params_manage where other_name = #{name} and building_id = #{buildingId} ") |
||||
@Results({ |
||||
@Result(column = "id", property = "id"), |
||||
@Result(column = "create_time", property = "createTime"), |
||||
@Result(column = "update_time", property = "updateTime"), |
||||
@Result(column = "device_install_id", property = "deviceInstallId"), |
||||
@Result(column = "register_addr", property = "registerAddr"), |
||||
@Result(column = "func_code", property = "funcCode"), |
||||
@Result(column = "mt_ratio", property = "mtRatio"), |
||||
@Result(column = "mt_init_value", property = "mtInitValue"), |
||||
@Result(column = "digits", property = "digits"), |
||||
@Result(column = "data_type", property = "dataType"), |
||||
@Result(column = "cur_value", property = "curValue"), |
||||
@Result(column = "cur_time", property = "curTime"), |
||||
@Result(column = "mt_is_sum", property = "mtIsSum"), |
||||
@Result(column = "unit", property = "unit"), |
||||
@Result(column = "order_num", property = "orderNum"), |
||||
@Result(column = "remark", property = "remark"), |
||||
@Result(column = "register_size", property = "registerSize"), |
||||
@Result(column = "is_use", property = "isUse"), |
||||
@Result(column = "other_name", property = "otherName"), |
||||
@Result(column = "grade", property = "grade"), |
||||
@Result(column = "param_type_id", property = "paramTypeId"), |
||||
@Result(column = "collection_type", property = "collectionType"), |
||||
@Result(column = "quality", property = "quality") |
||||
}) |
||||
CollectionParamsManageEntity selectDeviceInstallByOtherName(String name, String buildingId); |
||||
|
||||
@Insert("insert into collection_params_manage(" + |
||||
"device_install_id, register_addr, func_code, mt_ratio, mt_init_value, digits, data_type, " + |
||||
"mt_is_sum, unit, order_num, remark, register_size, is_use, " + |
||||
"other_name, grade, param_type_id, collection_type, quality, create_time, building_id, cur_value, cur_time) " + |
||||
"values(#{deviceInstallId}, #{registerAddr}, #{funcCode}, #{mtRatio}, #{mtInitValue}, " + |
||||
"#{digits}, #{dataType}, #{mtIsSum}, #{unit}, #{orderNum}, " + |
||||
"#{remark}, #{registerSize}, #{isUse}, #{otherName}, #{grade}, #{paramTypeId}, " + |
||||
"#{collectionType}, #{quality}, getdate(), #{buildingId}, #{curValue}, #{curTime})") |
||||
void insertCPM(CollectionParamsManageEntity cpmEntity); |
||||
|
||||
@Update("<script>" + |
||||
"update collection_params_manage " + |
||||
"<set>" + |
||||
"<if test='deviceInstallId != null'>device_install_id = #{deviceInstallId},</if>" + |
||||
"<if test='registerAddr != null'>register_addr = #{registerAddr},</if>" + |
||||
"<if test='funcCode != null'>func_code = #{funcCode},</if>" + |
||||
"<if test='mtRatio != null'>mt_ratio = #{mtRatio},</if>" + |
||||
"<if test='mtInitValue != null'>mt_init_value = #{mtInitValue},</if>" + |
||||
"<if test='digits != null'>digits = #{digits},</if>" + |
||||
"<if test='dataType != null'>data_type = #{dataType},</if>" + |
||||
"<if test='curValue != null'>cur_value = #{curValue},</if>" + |
||||
"<if test='curTime != null'>cur_time = #{curTime},</if>" + |
||||
"<if test='mtIsSum != null'>mt_is_sum = #{mtIsSum},</if>" + |
||||
"<if test='unit != null'>unit = #{unit},</if>" + |
||||
"<if test='orderNum != null'>order_num = #{orderNum},</if>" + |
||||
"<if test='remark != null'>remark = #{remark},</if>" + |
||||
"<if test='registerSize != null'>register_size = #{registerSize},</if>" + |
||||
"<if test='isUse != null'>is_use = #{isUse},</if>" + |
||||
"<if test='otherName != null'>other_name = #{otherName},</if>" + |
||||
"<if test='grade != null'>grade = #{grade},</if>" + |
||||
"<if test='paramTypeId != null'>param_type_id = #{paramTypeId},</if>" + |
||||
"<if test='collectionType != null'>collection_type = #{collectionType},</if>" + |
||||
"<if test='quality != null'>quality = #{quality},</if>" + |
||||
"<if test='buildingId != null'>building_id = #{buildingId},</if>" + |
||||
" update_time = getdate() " + |
||||
"</set>" + |
||||
"where id = #{id}" + |
||||
"</script>") |
||||
void updateById(CollectionParamsManageEntity cpmEntity); |
||||
|
||||
@Delete("delete from collection_params_manage where id = #{msId}") |
||||
void deleteById(String msId); |
||||
|
||||
@Select("SELECT " + |
||||
" cpm.id as cpm_id, " + |
||||
" di.building_id, " + |
||||
" di.building_name, " + |
||||
" di.device_type, " + |
||||
" di.id as device_id, " + |
||||
" di.device_name, " + |
||||
" cpm.other_name, " + |
||||
" COALESCE(cpm.cur_value, 0) as cur_value, " + |
||||
" cpm.cur_time, " + |
||||
" cpm.param_type_id, " + |
||||
" cpm.digits, " + |
||||
" ct.order_num AS ct_order_num, " + |
||||
" di.order_num AS dl_order_num " + |
||||
"FROM " + |
||||
" device_install di " + |
||||
" JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + |
||||
" JOIN code_table ct ON ct.des = di.device_type " + |
||||
" AND di.building_id = #{buildingId} " + |
||||
" AND ct.name = 'deviceType' " + |
||||
"ORDER BY " + |
||||
" ct.order_num, " + |
||||
" di.order_num ") |
||||
@Results({ |
||||
@Result(column = "cpm_id", property = "cpmId"), |
||||
@Result(column = "building_id", property = "buildingId"), |
||||
@Result(column = "building_name", property = "buildingName"), |
||||
@Result(column = "device_type", property = "deviceType"), |
||||
@Result(column = "device_id", property = "deviceId"), |
||||
@Result(column = "device_name", property = "deviceName"), |
||||
@Result(column = "other_name", property = "otherName"), |
||||
@Result(column = "cur_value", property = "curValue"), |
||||
@Result(column = "cur_time", property = "curTime"), |
||||
@Result(column = "param_type_id", property = "paramTypeId"), |
||||
@Result(column = "digits", property = "digits"), |
||||
@Result(column = "ct_order_num", property = "ctOrderNum"), |
||||
@Result(column = "dl_order_num", property = "dlOrderNum") |
||||
}) |
||||
List<HotWaterControlListVO> selectHotWaterByBuildingId(String buildingId); |
||||
|
||||
@Select("SELECT " + |
||||
" top 1 gm.community_type " + |
||||
"FROM " + |
||||
" device_install di " + |
||||
" JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + |
||||
" JOIN gateway_manage gm ON di.data_com = gm.data_com " + |
||||
" AND cpm.id = #{cpmId} ") |
||||
String selectCommunicationType(String cpmId); |
||||
|
||||
@Select("SELECT " + |
||||
" top 1 gm.sn " + |
||||
"FROM " + |
||||
" device_install di " + |
||||
" JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + |
||||
" JOIN gateway_manage gm ON di.data_com = gm.data_com " + |
||||
" AND cpm.id = #{cpmId} ") |
||||
String selectSn(String cpmId); |
||||
|
||||
@Select("SELECT " + |
||||
" top 1 gm.gateway_name " + |
||||
"FROM " + |
||||
" device_install di " + |
||||
" JOIN collection_params_manage cpm ON di.id = cpm.device_install_id " + |
||||
" JOIN gateway_manage gm ON di.data_com = gm.data_com " + |
||||
" AND cpm.id = #{cpmId} ") |
||||
String selectPlcName(String cpmId); |
||||
|
||||
@Select("select top 1 * from collection_params_manage where id = #{id}") |
||||
@Results({ |
||||
@Result(column = "id", property = "id"), |
||||
@Result(column = "create_time", property = "createTime"), |
||||
@Result(column = "update_time", property = "updateTime"), |
||||
@Result(column = "device_install_id", property = "deviceInstallId"), |
||||
@Result(column = "register_addr", property = "registerAddr"), |
||||
@Result(column = "func_code", property = "funcCode"), |
||||
@Result(column = "mt_ratio", property = "mtRatio"), |
||||
@Result(column = "mt_init_value", property = "mtInitValue"), |
||||
@Result(column = "digits", property = "digits"), |
||||
@Result(column = "data_type", property = "dataType"), |
||||
@Result(column = "cur_value", property = "curValue"), |
||||
@Result(column = "cur_time", property = "curTime"), |
||||
@Result(column = "mt_is_sum", property = "mtIsSum"), |
||||
@Result(column = "unit", property = "unit"), |
||||
@Result(column = "order_num", property = "orderNum"), |
||||
@Result(column = "remark", property = "remark"), |
||||
@Result(column = "register_size", property = "registerSize"), |
||||
@Result(column = "is_use", property = "isUse"), |
||||
@Result(column = "other_name", property = "otherName"), |
||||
@Result(column = "grade", property = "grade"), |
||||
@Result(column = "param_type_id", property = "paramTypeId"), |
||||
@Result(column = "collection_type", property = "collectionType"), |
||||
@Result(column = "quality", property = "quality") |
||||
}) |
||||
CollectionParamsManageEntity selectById(String id); |
||||
|
||||
@Select("select top 1 * from collection_params_manage where device_install_id = #{deviceInstallId} and param_type_id = #{paramTypeId}") |
||||
@Results({ |
||||
@Result(column = "id", property = "id"), |
||||
@Result(column = "create_time", property = "createTime"), |
||||
@Result(column = "update_time", property = "updateTime"), |
||||
@Result(column = "device_install_id", property = "deviceInstallId"), |
||||
@Result(column = "register_addr", property = "registerAddr"), |
||||
@Result(column = "func_code", property = "funcCode"), |
||||
@Result(column = "mt_ratio", property = "mtRatio"), |
||||
@Result(column = "mt_init_value", property = "mtInitValue"), |
||||
@Result(column = "digits", property = "digits"), |
||||
@Result(column = "data_type", property = "dataType"), |
||||
@Result(column = "cur_value", property = "curValue"), |
||||
@Result(column = "cur_time", property = "curTime"), |
||||
@Result(column = "mt_is_sum", property = "mtIsSum"), |
||||
@Result(column = "unit", property = "unit"), |
||||
@Result(column = "order_num", property = "orderNum"), |
||||
@Result(column = "remark", property = "remark"), |
||||
@Result(column = "register_size", property = "registerSize"), |
||||
@Result(column = "is_use", property = "isUse"), |
||||
@Result(column = "other_name", property = "otherName"), |
||||
@Result(column = "grade", property = "grade"), |
||||
@Result(column = "param_type_id", property = "paramTypeId"), |
||||
@Result(column = "collection_type", property = "collectionType"), |
||||
@Result(column = "quality", property = "quality") |
||||
}) |
||||
CollectionParamsManageEntity selectByDeviceIdAndParamTypeId(Long deviceInstallId, String paramTypeId); |
||||
|
||||
@Select("select * from collection_params_manage order by create_time desc") |
||||
@Results({ |
||||
@Result(column = "id", property = "id"), |
||||
@Result(column = "create_time", property = "createTime"), |
||||
@Result(column = "update_time", property = "updateTime"), |
||||
@Result(column = "device_install_id", property = "deviceInstallId"), |
||||
@Result(column = "register_addr", property = "registerAddr"), |
||||
@Result(column = "func_code", property = "funcCode"), |
||||
@Result(column = "mt_ratio", property = "mtRatio"), |
||||
@Result(column = "mt_init_value", property = "mtInitValue"), |
||||
@Result(column = "digits", property = "digits"), |
||||
@Result(column = "data_type", property = "dataType"), |
||||
@Result(column = "cur_value", property = "curValue"), |
||||
@Result(column = "cur_time", property = "curTime"), |
||||
@Result(column = "mt_is_sum", property = "mtIsSum"), |
||||
@Result(column = "unit", property = "unit"), |
||||
@Result(column = "order_num", property = "orderNum"), |
||||
@Result(column = "remark", property = "remark"), |
||||
@Result(column = "register_size", property = "registerSize"), |
||||
@Result(column = "is_use", property = "isUse"), |
||||
@Result(column = "other_name", property = "otherName"), |
||||
@Result(column = "grade", property = "grade"), |
||||
@Result(column = "param_type_id", property = "paramTypeId"), |
||||
@Result(column = "collection_type", property = "collectionType"), |
||||
@Result(column = "quality", property = "quality"), |
||||
@Result(column = "building_id", property = "buildingId") |
||||
}) |
||||
List<CollectionParamsManageEntity> selectAllCPMList(); |
||||
} |
||||
@ -1,34 +0,0 @@
|
||||
package com.mh.user.model; |
||||
|
||||
import com.fasterxml.jackson.core.JsonParser; |
||||
import com.fasterxml.jackson.databind.DeserializationContext; |
||||
import com.fasterxml.jackson.databind.JsonDeserializer; |
||||
|
||||
import java.io.IOException; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 格式化 |
||||
* @date 2026-01-07 14:20:36 |
||||
*/ |
||||
public class MyBigDecimalDeserializer extends JsonDeserializer<BigDecimal> { |
||||
|
||||
@Override |
||||
public BigDecimal deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { |
||||
String value = p.getValueAsString(); |
||||
if (value == null || value.trim().isEmpty()) { |
||||
return BigDecimal.ZERO; |
||||
} |
||||
|
||||
try { |
||||
// 直接使用字符串构造BigDecimal,能正确处理科学计数法
|
||||
return new BigDecimal(value); |
||||
} catch (NumberFormatException e) { |
||||
// 如果转换失败,返回0
|
||||
return BigDecimal.ZERO; |
||||
} |
||||
} |
||||
} |
||||
@ -1,36 +1,30 @@
|
||||
package com.mh.user.model; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 三石峰数据体 |
||||
* @description 研华数据体 |
||||
* @date 2025-01-22 14:47:25 |
||||
*/ |
||||
@Data |
||||
public class SanShiFengDatas { |
||||
public class SanShiFengDatas<T extends Number> { |
||||
|
||||
/** |
||||
* 对应研华的标签值 |
||||
*/ |
||||
private String name; |
||||
private String tag; |
||||
|
||||
/** |
||||
* 上报值 |
||||
*/ |
||||
// 使用自定义反序列化器处理科学计数法
|
||||
@JsonDeserialize(using = MyBigDecimalDeserializer.class) |
||||
@JsonFormat(shape = JsonFormat.Shape.STRING) // 以字符串形式输出,避免科学计数法
|
||||
private BigDecimal value; |
||||
// /**
|
||||
// * 质量值
|
||||
// */
|
||||
// private T quality;
|
||||
private T value; |
||||
|
||||
/** |
||||
* 质量值 |
||||
*/ |
||||
private T quality; |
||||
|
||||
} |
||||
|
||||
@ -1,33 +0,0 @@
|
||||
package com.mh.user.model; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 三石峰数据体 |
||||
* @date 2025-01-22 14:47:25 |
||||
*/ |
||||
@Data |
||||
public class SanShiFengStrDatas { |
||||
|
||||
/** |
||||
* 对应研华的标签值 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 上报值 |
||||
*/ |
||||
// 使用自定义反序列化器处理科学计数法
|
||||
private String value; |
||||
// /**
|
||||
// * 质量值
|
||||
// */
|
||||
// private T quality;
|
||||
|
||||
} |
||||
@ -1,56 +0,0 @@
|
||||
package com.mh.user.service; |
||||
|
||||
import com.mh.user.dto.EnergyPreTopDataDTO; |
||||
import com.mh.user.entity.HistoryDataPre; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 预测历史数据服务类 |
||||
* @date 2024-05-09 10:02:54 |
||||
*/ |
||||
public interface AdvancedHistoryDataPreService { |
||||
|
||||
/** |
||||
* 获取训练数据 |
||||
* @param buildingId |
||||
* @throws Exception |
||||
*/ |
||||
void startTrainData(String buildingId) throws Exception; |
||||
|
||||
/** |
||||
* 开始预测数据 |
||||
* @param buildingId |
||||
* @param curDate |
||||
* @throws Exception |
||||
*/ |
||||
void startPredictData(String buildingId, String curDate) throws Exception; |
||||
|
||||
/** |
||||
* 获取每栋楼的数据 |
||||
* @param buildingId |
||||
* @param curDate |
||||
* @return |
||||
*/ |
||||
List<HistoryDataPre> getRecentData(String buildingId, String curDate); |
||||
|
||||
/** |
||||
* 获取预测数据 |
||||
* @param buildingId |
||||
* @param beginDate |
||||
* @param endDate |
||||
* @param type |
||||
* @return |
||||
*/ |
||||
List<HashMap<String, Object>> getEnergyPre(String buildingId, String beginDate, String endDate, String type); |
||||
|
||||
List<EnergyPreTopDataDTO> getTopData(String buildingId, String type); |
||||
|
||||
public void asyncPredict(String buildingId, String curDate); |
||||
|
||||
public void batchPredict(List<String> buildingIds, String curDate); |
||||
} |
||||
@ -1,44 +0,0 @@
|
||||
package com.mh.user.service; |
||||
|
||||
import com.mh.user.dto.HotWaterControlDTO; |
||||
import com.mh.user.dto.HotWaterNowDataDTO; |
||||
import com.mh.user.entity.CollectionParamsManageEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.model.SanShiFengDatas; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 采集参数管理 |
||||
* @date 2025-02-14 13:58:37 |
||||
*/ |
||||
public interface CollectionParamsManageService { |
||||
|
||||
List<CollectionParamsManageEntity> selectCPMList(String buildingId, String deviceInstallId, String otherName, Integer pageNum, Integer pageSize); |
||||
|
||||
int selectCPMListCount(String buildingId, String deviceInstallId, String otherName, Integer pageNum, Integer pageSize); |
||||
|
||||
CollectionParamsManageEntity selectById(String msId); |
||||
|
||||
String insertCPM(CollectionParamsManageEntity mqttSubscription); |
||||
|
||||
String updateCPM(CollectionParamsManageEntity mqttSubscription); |
||||
|
||||
int deleteByIds(String[] msIds); |
||||
|
||||
void updateCPMByOtherName(String name, BigDecimal value, String time, String buildingId); |
||||
|
||||
CollectionParamsManageEntity selectDeviceInstallByOtherName(String name, String buildingId); |
||||
|
||||
List<HotWaterNowDataDTO> monitorList(String buildingId); |
||||
|
||||
List<HotWaterControlDTO> operateList(String floorId); |
||||
|
||||
void getBatchUpdateCollectionParams(List<SanShiFengDatas> batch, String sn, String plcName, String projectName, String time, String buildingId); |
||||
|
||||
List<CollectionParamsManageEntity> selectAllCPMList(); |
||||
} |
||||
@ -1,611 +0,0 @@
|
||||
package com.mh.user.service.impl; |
||||
|
||||
import com.alibaba.fastjson2.JSON; |
||||
import com.alibaba.fastjson2.JSONArray; |
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.github.benmanes.caffeine.cache.Cache; |
||||
import com.mh.algorithm.bpnn.BPModel; |
||||
import com.mh.algorithm.bpnn.BPNeuralNetworkFactory; |
||||
import com.mh.algorithm.bpnn.BPParameter; |
||||
import com.mh.algorithm.matrix.Matrix; |
||||
import com.mh.algorithm.utils.CsvInfo; |
||||
import com.mh.algorithm.utils.SerializationUtil; |
||||
import com.mh.common.utils.StringUtils; |
||||
import com.mh.user.dto.EnergyPreEchartDataDTO; |
||||
import com.mh.user.dto.EnergyPreTopDataDTO; |
||||
import com.mh.user.entity.HistoryDataPre; |
||||
import com.mh.user.entity.SysParamEntity; |
||||
import com.mh.user.job.GetWeatherInfoJob; |
||||
import com.mh.user.mapper.HistoryDataPreMapper; |
||||
import com.mh.user.service.AdvancedHistoryDataPreService; |
||||
import com.mh.user.service.HistoryDataPreService; |
||||
import com.mh.user.service.SysParamService; |
||||
import com.mh.user.utils.DateUtil; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Qualifier; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.math.RoundingMode; |
||||
import java.time.LocalDate; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.*; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 2.0 |
||||
* @project CHWS |
||||
* @description 改进的预测历史数据服务实现类 |
||||
* 采用增强型 BP 神经网络 + 时间序列特征 |
||||
* 输入特征:天气 (2) + 人数 (1) + 历史用水 (3) + 历史用电 (3) + 历史水位 (3) = 12 个输入 |
||||
* 输出:用水预测 + 用电预测 + 水位预测 = 3 个输出 |
||||
* @date 2026-03-17 |
||||
*/ |
||||
@Service |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public class AdvancedHistoryDataPreServiceImpl implements AdvancedHistoryDataPreService { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AdvancedHistoryDataPreServiceImpl.class); |
||||
|
||||
@Resource |
||||
private HistoryDataPreMapper historyDataPreMapper; |
||||
|
||||
@Resource |
||||
@Qualifier("caffeineCache") |
||||
private Cache caffeineCache; |
||||
|
||||
@Resource |
||||
private SysParamService sysParamService; |
||||
|
||||
@Resource |
||||
private GetWeatherInfoJob getWeatherInfoJob; |
||||
|
||||
// 使用 ConcurrentHashMap 保证线程安全,缓存已训练的 BP 模型
|
||||
private final ConcurrentHashMap<String, BPModel> bpModelCache = new ConcurrentHashMap<>(); |
||||
|
||||
// 异步预测线程池
|
||||
private ExecutorService predictionExecutor; |
||||
|
||||
// 模型配置参数
|
||||
private static final int INPUT_NEURON_COUNT = 12; // 12 个输入特征
|
||||
private static final int HIDDEN_NEURON_COUNT = 8; // 8 个隐藏层神经元
|
||||
private static final int OUTPUT_NEURON_COUNT = 3; // 3 个输出
|
||||
private static final double LEARNING_RATE = 0.1; // 学习率
|
||||
private static final double MOMENTUM_FACTOR = 0.3; // 动量因子
|
||||
private static final double PRECISION = 0.001; // 精度
|
||||
private static final int MAX_TIMES = 30000; // 最大训练次数
|
||||
|
||||
// 数据合理性阈值
|
||||
private static final BigDecimal MAX_WATER_VALUE = new BigDecimal("1000"); // 最大用水量阈值
|
||||
private static final BigDecimal MAX_ELECT_VALUE = new BigDecimal("2000"); // 最大用电量阈值
|
||||
private static final BigDecimal MAX_CHANGE_RATIO = new BigDecimal("3"); // 最大变化倍数
|
||||
private static final BigDecimal MIN_CHANGE_RATIO = new BigDecimal("0.3"); // 最小变化倍数 (防止突然降到很低)
|
||||
private static final BigDecimal WATER_LEVEL_MAX_CHANGE = new BigDecimal("1.5"); // 水位最大变化 1.5 倍
|
||||
private static final BigDecimal WATER_LEVEL_MIN_CHANGE = new BigDecimal("0.5"); // 水位最小变化 0.5 倍
|
||||
|
||||
@PostConstruct |
||||
public void init() { |
||||
// 初始化异步预测线程池(核心线程数为 CPU 核心数)
|
||||
int cpuCores = Runtime.getRuntime().availableProcessors(); |
||||
predictionExecutor = Executors.newFixedThreadPool(cpuCores); |
||||
log.info("高级预测服务初始化完成,线程池大小:{}, 模型结构:{}-{}-{}", |
||||
cpuCores, INPUT_NEURON_COUNT, HIDDEN_NEURON_COUNT, OUTPUT_NEURON_COUNT); |
||||
} |
||||
|
||||
/** |
||||
* 构建增强的输入特征向量 |
||||
* 包含:天气特征 + 人数 + 历史用水趋势 + 历史用电趋势 + 历史水位趋势 |
||||
* |
||||
* @param currentData 当前数据 |
||||
* @param historicalData 历史数据列表(最近 N 天) |
||||
* @return 增强的特征数组 |
||||
*/ |
||||
private String[] buildEnhancedFeatures(HistoryDataPre currentData, List<HistoryDataPre> historicalData) { |
||||
List<String> features = new ArrayList<>(); |
||||
|
||||
// 1. 天气特征(2 个)
|
||||
features.add(String.valueOf(currentData.getEnvMinTemp())); |
||||
features.add(String.valueOf(currentData.getEnvMaxTemp())); |
||||
|
||||
// 2. 人数特征(1 个)
|
||||
features.add(String.valueOf(currentData.getPeopleNum())); |
||||
|
||||
// 3. 历史用水趋势(3 个):昨天、前天、大前天
|
||||
features.add(getHistoricalValue(historicalData, 0, "water")); |
||||
features.add(getHistoricalValue(historicalData, 1, "water")); |
||||
features.add(getHistoricalValue(historicalData, 2, "water")); |
||||
|
||||
// 4. 历史用电趋势(3 个)
|
||||
features.add(getHistoricalValue(historicalData, 0, "elect")); |
||||
features.add(getHistoricalValue(historicalData, 1, "elect")); |
||||
features.add(getHistoricalValue(historicalData, 2, "elect")); |
||||
|
||||
// 5. 历史水位趋势(3 个)
|
||||
features.add(getHistoricalValue(historicalData, 0, "waterLevel")); |
||||
features.add(getHistoricalValue(historicalData, 1, "waterLevel")); |
||||
features.add(getHistoricalValue(historicalData, 2, "waterLevel")); |
||||
|
||||
return features.toArray(new String[0]); |
||||
} |
||||
|
||||
/** |
||||
* 获取历史数据值 |
||||
*/ |
||||
private String getHistoricalValue(List<HistoryDataPre> historicalData, int daysAgo, String type) { |
||||
if (historicalData == null || daysAgo >= historicalData.size()) { |
||||
return "0"; |
||||
} |
||||
HistoryDataPre data = historicalData.get(daysAgo); |
||||
switch (type) { |
||||
case "water": |
||||
return data.getWaterValue() != null ? data.getWaterValue().toString() : "0"; |
||||
case "elect": |
||||
return data.getElectValue() != null ? data.getElectValue().toString() : "0"; |
||||
case "waterLevel": |
||||
return data.getWaterLevel() != null ? data.getWaterLevel().toString() : "0"; |
||||
default: |
||||
return "0"; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 检测并过滤异常数据 |
||||
* 剔除明显不合理的训练样本 |
||||
*/ |
||||
private boolean isValidTrainingData(HistoryDataPre data) { |
||||
if (data == null) { |
||||
return false; |
||||
} |
||||
|
||||
// 检查用水量是否合理
|
||||
if (data.getWaterValue() != null && data.getWaterValue().compareTo(MAX_WATER_VALUE) > 0) { |
||||
log.warn("检测到异常用水量:{}, 已过滤", data.getWaterValue()); |
||||
return false; |
||||
} |
||||
|
||||
// 检查用电量是否合理
|
||||
if (data.getElectValue() != null && data.getElectValue().compareTo(MAX_ELECT_VALUE) > 0) { |
||||
log.warn("检测到异常用电量:{}, 已过滤", data.getElectValue()); |
||||
return false; |
||||
} |
||||
|
||||
// 检查水位是否合理 (0-100)
|
||||
if (data.getWaterLevel() != null && |
||||
(data.getWaterLevel().compareTo(BigDecimal.ZERO) < 0 || |
||||
data.getWaterLevel().compareTo(new BigDecimal("100")) > 0)) { |
||||
log.warn("检测到异常水位:{}, 已过滤", data.getWaterLevel()); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 计算历史平均值(前 3 天) |
||||
*/ |
||||
private BigDecimal calculateHistoricalAverage(List<HistoryDataPre> historicalData, String type) { |
||||
if (historicalData == null || historicalData.isEmpty()) { |
||||
return BigDecimal.ZERO; |
||||
} |
||||
|
||||
BigDecimal sum = BigDecimal.ZERO; |
||||
int count = 0; |
||||
|
||||
for (int i = 0; i < Math.min(3, historicalData.size()); i++) { |
||||
BigDecimal value = null; |
||||
switch (type) { |
||||
case "water": |
||||
value = historicalData.get(i).getWaterValue(); |
||||
break; |
||||
case "elect": |
||||
value = historicalData.get(i).getElectValue(); |
||||
break; |
||||
case "waterLevel": |
||||
value = historicalData.get(i).getWaterLevel(); |
||||
break; |
||||
} |
||||
|
||||
if (value != null) { |
||||
sum = sum.add(value); |
||||
count++; |
||||
} |
||||
} |
||||
|
||||
return count > 0 ? sum.divide(BigDecimal.valueOf(count), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO; |
||||
} |
||||
|
||||
@Override |
||||
public void startTrainData(String buildingId) throws Exception { |
||||
long startTime = System.currentTimeMillis(); |
||||
log.info("开始训练建筑 {} 的高级预测模型", buildingId); |
||||
|
||||
// 获取更多的训练数据(至少需要 INPUT_NEURON_COUNT 条数据)
|
||||
List<HistoryDataPre> trainData = historyDataPreMapper.getTrainData(buildingId); |
||||
if (trainData == null || trainData.size() < INPUT_NEURON_COUNT) { |
||||
log.warn("建筑 {} 的训练数据不足(需要至少{}条,实际{}条),无法训练", |
||||
buildingId, INPUT_NEURON_COUNT, trainData == null ? 0 : trainData.size()); |
||||
return; |
||||
} |
||||
|
||||
// 构建增强的训练数据集
|
||||
List<String[]> enhancedTrainData = new ArrayList<>(); |
||||
for (int i = 0; i < trainData.size(); i++) { |
||||
HistoryDataPre current = trainData.get(i); |
||||
|
||||
// 检测并过滤异常数据
|
||||
if (!isValidTrainingData(current)) { |
||||
log.info("跳过异常训练样本:日期={}, 水={}, 电={}, 水位={}", |
||||
current.getCurDate(), current.getWaterValue(), |
||||
current.getElectValue(), current.getWaterLevel()); |
||||
continue; |
||||
} |
||||
|
||||
// 获取前 N 天的历史数据作为特征
|
||||
List<HistoryDataPre> historicalData = new ArrayList<>(); |
||||
for (int j = 1; j <= 3 && (i - j) >= 0; j++) { |
||||
// 也要检查历史数据是否异常
|
||||
if (isValidTrainingData(trainData.get(i - j))) { |
||||
historicalData.add(trainData.get(i - j)); |
||||
} |
||||
} |
||||
|
||||
// 如果历史数据不足 3 条,跳过该样本
|
||||
if (historicalData.size() < 3) { |
||||
continue; |
||||
} |
||||
|
||||
// 构建输入特征(12 维)
|
||||
String[] features = buildEnhancedFeatures(current, historicalData); |
||||
|
||||
// 构建输出标签(3 维):实际用水、用电、水位
|
||||
String[] labels = new String[]{ |
||||
String.valueOf(current.getWaterValue()), |
||||
String.valueOf(current.getElectValue()), |
||||
String.valueOf(current.getWaterLevel()) |
||||
}; |
||||
|
||||
// 合并特征和标签
|
||||
String[] record = new String[INPUT_NEURON_COUNT + OUTPUT_NEURON_COUNT]; |
||||
System.arraycopy(features, 0, record, 0, INPUT_NEURON_COUNT); |
||||
System.arraycopy(labels, 0, record, INPUT_NEURON_COUNT, OUTPUT_NEURON_COUNT); |
||||
|
||||
enhancedTrainData.add(record); |
||||
} |
||||
|
||||
if (enhancedTrainData.size() < INPUT_NEURON_COUNT) { |
||||
log.warn("建筑 {} 的增强训练数据不足,无法训练", buildingId); |
||||
return; |
||||
} |
||||
|
||||
// 创建训练集矩阵
|
||||
CsvInfo csvInfo = new CsvInfo(); |
||||
csvInfo.setCsvFileList(new ArrayList<>(enhancedTrainData)); |
||||
Matrix trainSet = csvInfo.toMatrix(); |
||||
|
||||
// 创建 BPNN 工厂对象
|
||||
BPNeuralNetworkFactory factory = new BPNeuralNetworkFactory(); |
||||
|
||||
// 创建优化的 BP 参数对象
|
||||
BPParameter bpParameter = new BPParameter(); |
||||
bpParameter.setInputLayerNeuronCount(INPUT_NEURON_COUNT); |
||||
bpParameter.setHiddenLayerNeuronCount(HIDDEN_NEURON_COUNT); |
||||
bpParameter.setOutputLayerNeuronCount(OUTPUT_NEURON_COUNT); |
||||
bpParameter.setStep(LEARNING_RATE); |
||||
bpParameter.setMomentumFactor(MOMENTUM_FACTOR); |
||||
bpParameter.setPrecision(PRECISION); |
||||
bpParameter.setMaxTimes(MAX_TIMES); |
||||
|
||||
// 训练 BP 神经网络
|
||||
BPModel bpModel = factory.trainBP(bpParameter, trainSet); |
||||
|
||||
// 将 BPModel 序列化到本地
|
||||
SerializationUtil.serialize(bpModel, buildingId + "_advanced_pre_data"); |
||||
|
||||
// 同时更新缓存
|
||||
bpModelCache.put(buildingId + "_advanced_pre_data", bpModel); |
||||
|
||||
long endTime = System.currentTimeMillis(); |
||||
log.info("建筑 {} 的高级模型训练完成,耗时:{}ms,循环次数:{},误差:{}, 训练样本数:{}", |
||||
buildingId, (endTime - startTime), bpModel.getTimes(), bpModel.getError(), enhancedTrainData.size()); |
||||
} |
||||
|
||||
@Override |
||||
public void startPredictData(String buildingId, String curDate) throws Exception { |
||||
long startTime = System.currentTimeMillis(); |
||||
log.debug("开始预测建筑 {} 的数据,日期:{}", buildingId, curDate); |
||||
|
||||
// 1. 从缓存获取 BP 模型
|
||||
BPModel bpModel = bpModelCache.get(buildingId + "_advanced_pre_data"); |
||||
if (bpModel == null) { |
||||
log.debug("缓存未命中,从文件加载模型:{}", buildingId); |
||||
bpModel = (BPModel) SerializationUtil.deSerialization(buildingId + "_advanced_pre_data"); |
||||
if (bpModel != null) { |
||||
bpModelCache.put(buildingId + "_advanced_pre_data", bpModel); |
||||
log.info("成功加载建筑 {} 的高级模型到缓存", buildingId); |
||||
} else { |
||||
log.warn("模型不存在,开始训练建筑 {} 的模型", buildingId); |
||||
startTrainData(buildingId); |
||||
bpModel = (BPModel) SerializationUtil.deSerialization(buildingId + "_advanced_pre_data"); |
||||
if (bpModel != null) { |
||||
bpModelCache.put(buildingId + "_advanced_pre_data", bpModel); |
||||
} else { |
||||
log.error("建筑 {} 的模型训练失败", buildingId); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// 2. 获取天气数据
|
||||
String envMinTemp = "16.50"; |
||||
String envMaxTemp = "26.00"; |
||||
try { |
||||
SysParamEntity sysParam = sysParamService.selectSysParam(); |
||||
Object weather = caffeineCache.getIfPresent(sysParam.getProArea()); |
||||
if (weather == null) { |
||||
getWeatherInfoJob.getWeatherInfo(); |
||||
weather = caffeineCache.getIfPresent(sysParam.getProArea()); |
||||
} |
||||
if (weather != null) { |
||||
JSONObject jsonObject = JSON.parseObject((String) weather); |
||||
if (jsonObject != null) { |
||||
JSONArray jsonArray = jsonObject.getJSONArray("forecasts").getJSONObject(0).getJSONArray("casts"); |
||||
for (int i = 0; i < jsonArray.size(); i++) { |
||||
JSONObject jsonObject1 = jsonArray.getJSONObject(i); |
||||
if (jsonObject1.getString("date").equals(curDate)) { |
||||
envMinTemp = jsonObject1.getString("nighttemp"); |
||||
envMaxTemp = jsonObject1.getString("daytemp"); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
log.warn("获取天气数据失败,使用默认值", e); |
||||
} |
||||
|
||||
// 3. 获取当前数据和历史数据
|
||||
HistoryDataPre curHistoryData = historyDataPreMapper.selectCurData(buildingId, curDate); |
||||
if (curHistoryData == null) { |
||||
log.warn("建筑 {} 在日期 {} 没有当前数据,无法预测", buildingId, curDate); |
||||
return; |
||||
} |
||||
|
||||
// 4. 检查并插入数据(优化:先查再决定是否需要插入)
|
||||
HistoryDataPre historyDataPre = historyDataPreMapper.selectOneData(buildingId, curDate); |
||||
if (historyDataPre == null) { |
||||
curHistoryData.setEnvMaxTemp(new BigDecimal(envMaxTemp)); |
||||
curHistoryData.setEnvMinTemp(new BigDecimal(envMinTemp)); |
||||
historyDataPreMapper.insertData(curHistoryData); |
||||
log.debug("插入建筑 {} 的新数据", buildingId); |
||||
// 重新查询获取完整数据
|
||||
historyDataPre = historyDataPreMapper.selectOneData(buildingId, curDate); |
||||
} |
||||
|
||||
// curDate再减去5天
|
||||
String lastDate = DateUtil.getNextDay(curDate, -5, "yyyy-MM-dd"); |
||||
// 获取最近 5 天的历史数据用于构建时间序列特征
|
||||
List<HistoryDataPre> recentHistoryData = historyDataPreMapper.getLastRecentData(buildingId, curDate, lastDate); |
||||
if (recentHistoryData == null || recentHistoryData.size() < 3) { |
||||
log.warn("建筑 {} 的历史数据不足,无法进行高级预测", buildingId); |
||||
return; |
||||
} |
||||
|
||||
// 4. 构建增强的输入特征
|
||||
String[] features = buildEnhancedFeatures(curHistoryData, recentHistoryData); |
||||
|
||||
CsvInfo csvInfo = new CsvInfo(); |
||||
ArrayList<String[]> list = new ArrayList<>(); |
||||
list.add(features); |
||||
csvInfo.setCsvFileList(list); |
||||
Matrix inputData = csvInfo.toMatrix(); |
||||
|
||||
// 5. 使用缓存的模型进行预测
|
||||
BPNeuralNetworkFactory factory = new BPNeuralNetworkFactory(); |
||||
Matrix result = factory.computeBP(bpModel, inputData); |
||||
|
||||
// 6. 构建预测结果
|
||||
HistoryDataPre preHistoryData = new HistoryDataPre(); |
||||
preHistoryData.setId(historyDataPre.getId()); |
||||
preHistoryData.setBuildingId(buildingId); |
||||
|
||||
if (result.getMatrixRowCount() > 0) { |
||||
BigDecimal waterValuePreRaw = evaluateAndReturnBigDecimal(String.valueOf(result.getValOfIdx(0, 0))); |
||||
BigDecimal electValuePreRaw = evaluateAndReturnBigDecimal(String.valueOf(result.getValOfIdx(0, 1))); |
||||
BigDecimal waterLevelPreRaw = evaluateAndReturnBigDecimal(String.valueOf(result.getValOfIdx(0, 2))); |
||||
|
||||
log.info("建筑 {} BP 神经网络原始输出 -> 用水:{}, 用电:{}, 水位:{}", |
||||
buildingId, waterValuePreRaw, electValuePreRaw, waterLevelPreRaw); |
||||
|
||||
// 计算历史平均值用于合理性校验
|
||||
BigDecimal avgWaterValue = calculateHistoricalAverage(recentHistoryData, "water"); |
||||
BigDecimal avgElectValue = calculateHistoricalAverage(recentHistoryData, "elect"); |
||||
BigDecimal avgWaterLevel = calculateHistoricalAverage(recentHistoryData, "waterLevel"); |
||||
|
||||
log.info("建筑 {} 历史平均参考值 -> 用水:{}, 用电:{}, 水位:{}", |
||||
buildingId, avgWaterValue, avgElectValue, avgWaterLevel); |
||||
|
||||
// 获取前一天的实际值
|
||||
BigDecimal yesterdayWaterValue = recentHistoryData.size() > 0 ? |
||||
recentHistoryData.get(0).getWaterValue() : BigDecimal.ZERO; |
||||
BigDecimal yesterdayElectValue = recentHistoryData.size() > 0 ? |
||||
recentHistoryData.get(0).getElectValue() : BigDecimal.ZERO; |
||||
BigDecimal yesterdayWaterLevel = recentHistoryData.size() > 0 ? |
||||
recentHistoryData.get(0).getWaterLevel() : BigDecimal.ZERO; |
||||
|
||||
log.info("建筑 {} 昨日实际值 -> 用水:{}, 用电:{}, 水位:{}", |
||||
buildingId, yesterdayWaterValue, yesterdayElectValue, yesterdayWaterLevel); |
||||
|
||||
// 1. 用水量合理性校验
|
||||
BigDecimal waterValuePre = waterValuePreRaw; |
||||
if (yesterdayWaterValue.compareTo(BigDecimal.ZERO) > 0) { |
||||
BigDecimal changeRatio = waterValuePre.divide(yesterdayWaterValue, 2, RoundingMode.HALF_UP); |
||||
log.info("建筑 {} 用水量变化倍数:{}", buildingId, changeRatio); |
||||
if (changeRatio.compareTo(MAX_CHANGE_RATIO) > 0 || changeRatio.compareTo(MIN_CHANGE_RATIO) < 0) { |
||||
log.warn("预测用水量异常:预测值={}, 昨日值={}, 变化倍数={}, 使用历史平均值修正", |
||||
waterValuePre, yesterdayWaterValue, changeRatio); |
||||
// 使用历史平均值和昨日值的加权平均
|
||||
waterValuePre = avgWaterValue.multiply(BigDecimal.valueOf(0.4)) |
||||
.add(yesterdayWaterValue.multiply(BigDecimal.valueOf(0.6))); |
||||
log.info("修正后用水量:{}", waterValuePre); |
||||
} |
||||
} |
||||
|
||||
// 2. 用电量合理性校验
|
||||
BigDecimal electValuePre = electValuePreRaw; |
||||
if (yesterdayElectValue.compareTo(BigDecimal.ZERO) > 0) { |
||||
BigDecimal changeRatio = electValuePre.divide(yesterdayElectValue, 2, RoundingMode.HALF_UP); |
||||
log.info("建筑 {} 用电量变化倍数:{}", buildingId, changeRatio); |
||||
if (changeRatio.compareTo(MAX_CHANGE_RATIO) > 0 || changeRatio.compareTo(MIN_CHANGE_RATIO) < 0) { |
||||
log.warn("预测用电量异常:预测值={}, 昨日值={}, 变化倍数={}, 使用历史平均值修正", |
||||
electValuePre, yesterdayElectValue, changeRatio); |
||||
electValuePre = avgElectValue.multiply(BigDecimal.valueOf(0.4)) |
||||
.add(yesterdayElectValue.multiply(BigDecimal.valueOf(0.6))); |
||||
log.info("修正后用电量:{}", electValuePre); |
||||
} |
||||
} |
||||
|
||||
// 3. 水位合理性校验
|
||||
BigDecimal waterLevelPre = waterLevelPreRaw; |
||||
if (yesterdayWaterLevel.compareTo(BigDecimal.ZERO) > 0) { |
||||
BigDecimal changeRatio = waterLevelPre.divide(yesterdayWaterLevel, 2, RoundingMode.HALF_UP); |
||||
log.info("建筑 {} 水位变化倍数:{}", buildingId, changeRatio); |
||||
// 水位变化不能超过 50% 或者低于 30%
|
||||
if (changeRatio.compareTo(WATER_LEVEL_MAX_CHANGE) > 0 || changeRatio.compareTo(WATER_LEVEL_MIN_CHANGE) < 0) { |
||||
log.warn("预测水位异常:预测值={}, 昨日值={}, 变化倍数={}, 使用历史平均值修正", |
||||
waterLevelPre, yesterdayWaterLevel, changeRatio); |
||||
waterLevelPre = avgWaterLevel.multiply(BigDecimal.valueOf(0.4)) |
||||
.add(yesterdayWaterLevel.multiply(BigDecimal.valueOf(0.6))); |
||||
log.info("修正后水位:{}", waterLevelPre); |
||||
} |
||||
} |
||||
// 确保水位在 0-100 之间
|
||||
waterLevelPre = waterLevelPre.compareTo(BigDecimal.valueOf(100)) > 0 |
||||
? BigDecimal.valueOf(100) |
||||
: waterLevelPre.compareTo(BigDecimal.ZERO) < 0 |
||||
? BigDecimal.ZERO |
||||
: waterLevelPre; |
||||
|
||||
preHistoryData.setWaterValuePre(waterValuePre.setScale(2, RoundingMode.HALF_UP)); |
||||
preHistoryData.setElectValuePre(electValuePre.setScale(2, RoundingMode.HALF_UP)); |
||||
preHistoryData.setWaterLevelPre(waterLevelPre.setScale(2, RoundingMode.HALF_UP)); |
||||
} |
||||
|
||||
preHistoryData.setWaterValue(curHistoryData.getWaterValue()); |
||||
preHistoryData.setElectValue(curHistoryData.getElectValue()); |
||||
preHistoryData.setWaterLevel(curHistoryData.getWaterLevel()); |
||||
|
||||
// 7. 更新预测值
|
||||
historyDataPreMapper.updateById(preHistoryData); |
||||
|
||||
long endTime = System.currentTimeMillis(); |
||||
log.info("建筑 {} 的高级预测完成,耗时:{}ms", buildingId, (endTime - startTime)); |
||||
log.info("建筑 {} 预测详情 -> 用水:{}(昨日:{}), 用电:{}(昨日:{}), 水位:{}(昨日:{})", |
||||
buildingId, |
||||
preHistoryData.getWaterValuePre(), curHistoryData.getWaterValue(), |
||||
preHistoryData.getElectValuePre(), curHistoryData.getElectValue(), |
||||
preHistoryData.getWaterLevelPre(), curHistoryData.getWaterLevel()); |
||||
} |
||||
|
||||
/** |
||||
* 判断输入的字符串转换的 BigDecimal 是否小于或等于 0,返回 BigDecimal.ZERO。 |
||||
* 如果小于或等于 0,返回输入的 BigDecimal;如果大于 0,然后返回相应的 BigDecimal 值。 |
||||
*/ |
||||
public static BigDecimal evaluateAndReturnBigDecimal(String recordValue) { |
||||
if (recordValue == null || recordValue.trim().isEmpty()) { |
||||
return BigDecimal.ZERO; |
||||
} |
||||
try { |
||||
BigDecimal value = new BigDecimal(recordValue); |
||||
if (value.compareTo(BigDecimal.ZERO) >= 0) { |
||||
return value.setScale(2, RoundingMode.HALF_UP); |
||||
} else { |
||||
return BigDecimal.ZERO; |
||||
} |
||||
} catch (NumberFormatException e) { |
||||
return BigDecimal.ZERO; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public List<HistoryDataPre> getRecentData(String buildingId, String curDate) { |
||||
return historyDataPreMapper.getRecentData(buildingId, curDate); |
||||
} |
||||
|
||||
@Override |
||||
public List<HashMap<String, Object>> getEnergyPre(String buildingId, String beginDate, String endDate, String type) { |
||||
if (StringUtils.isBlank(beginDate) || StringUtils.isBlank(endDate)) { |
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
||||
LocalDate now = LocalDate.now(); |
||||
LocalDate startDate = now.minusDays(30); |
||||
beginDate = startDate.format(formatter); |
||||
endDate = now.format(formatter); |
||||
} |
||||
if (StringUtils.isBlank(buildingId) || StringUtils.isBlank(type)) { |
||||
return null; |
||||
} |
||||
List<EnergyPreEchartDataDTO> energyPre = historyDataPreMapper.getEnergyPre(buildingId, beginDate, endDate, type); |
||||
if (energyPre.isEmpty()) { |
||||
return null; |
||||
} |
||||
String[] curDate = energyPre.stream().map(EnergyPreEchartDataDTO::getCurDate).toArray(String[]::new); |
||||
String[] curData = energyPre.stream().map(EnergyPreEchartDataDTO::getCurData).toArray(String[]::new); |
||||
String[] preData = energyPre.stream().map(EnergyPreEchartDataDTO::getPreData).toArray(String[]::new); |
||||
String[] errorData = energyPre.stream().map(EnergyPreEchartDataDTO::getErrorData).toArray(String[]::new); |
||||
|
||||
List<HashMap<String, Object>> resultList = new ArrayList<>(); |
||||
HashMap<String, Object> resultHashMap = new HashMap<>(); |
||||
resultHashMap.put("curDate", curDate); |
||||
resultHashMap.put("curData", curData); |
||||
resultHashMap.put("preData", preData); |
||||
resultHashMap.put("errorData", errorData); |
||||
resultList.add(resultHashMap); |
||||
return resultList; |
||||
} |
||||
|
||||
@Override |
||||
public List<EnergyPreTopDataDTO> getTopData(String buildingId, String type) { |
||||
return historyDataPreMapper.getTopData(buildingId, type); |
||||
} |
||||
|
||||
/** |
||||
* 异步预测方法 |
||||
*/ |
||||
@Override |
||||
public void asyncPredict(String buildingId, String curDate) { |
||||
predictionExecutor.submit(() -> { |
||||
try { |
||||
startPredictData(buildingId, curDate); |
||||
} catch (Exception e) { |
||||
log.error("异步预测失败,buildingId: {}, curDate: {}", buildingId, curDate, e); |
||||
} |
||||
}); |
||||
log.info("已提交预测任务到线程池,buildingId: {}, curDate: {}", buildingId, curDate); |
||||
} |
||||
|
||||
/** |
||||
* 批量预测 |
||||
*/ |
||||
@Override |
||||
public void batchPredict(List<String> buildingIds, String curDate) { |
||||
log.info("开始批量预测,建筑数量:{}, 日期:{}", buildingIds.size(), curDate); |
||||
long startTime = System.currentTimeMillis(); |
||||
|
||||
for (String buildingId : buildingIds) { |
||||
try { |
||||
startPredictData(buildingId, curDate); |
||||
} catch (Exception e) { |
||||
log.error("建筑 {} 预测失败", buildingId, e); |
||||
} |
||||
} |
||||
|
||||
long endTime = System.currentTimeMillis(); |
||||
log.info("批量预测完成,总耗时:{}ms", (endTime - startTime)); |
||||
} |
||||
} |
||||
@ -1,887 +0,0 @@
|
||||
package com.mh.user.service.impl; |
||||
|
||||
import com.mh.common.utils.StringUtils; |
||||
import com.mh.user.constants.Constant; |
||||
import com.mh.user.dto.*; |
||||
import com.mh.user.entity.CollectionParamsManageEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.mapper.CollectionParamsManageMapper; |
||||
import com.mh.user.model.SanShiFengDatas; |
||||
import com.mh.user.service.CollectionParamsManageService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.math.RoundingMode; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 采集参数设备实现类 |
||||
* @date 2025-12-10 11:30:54 |
||||
*/ |
||||
@Slf4j |
||||
@Service |
||||
public class CollectionParamsManageServiceImpl implements CollectionParamsManageService { |
||||
|
||||
private final CollectionParamsManageMapper collectionParamsManageMapper; |
||||
|
||||
public CollectionParamsManageServiceImpl(CollectionParamsManageMapper collectionParamsManageMapper) { |
||||
this.collectionParamsManageMapper = collectionParamsManageMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<HotWaterNowDataDTO> monitorList(String buildingId) { |
||||
// 查询nowData表中数据
|
||||
return Collections.emptyList(); |
||||
} |
||||
|
||||
@Override |
||||
public List<HotWaterControlDTO> operateList(String floorId) { |
||||
List<HotWaterControlListVO> hotWaterControlListVOS = collectionParamsManageMapper.selectHotWaterByBuildingId(floorId); |
||||
if (hotWaterControlListVOS.isEmpty()) { |
||||
return Collections.emptyList(); |
||||
} |
||||
|
||||
return hotWaterControlListVOS.stream() |
||||
.collect(Collectors.groupingBy(HotWaterControlListVO::getDeviceType)) |
||||
.entrySet().stream() |
||||
.map(this::convertToHotWaterControlDTO) |
||||
.sorted(Comparator.comparingInt(HotWaterControlDTO::getOrderNum)) |
||||
.collect(Collectors.toList()); |
||||
} |
||||
|
||||
private HotWaterControlDTO convertToHotWaterControlDTO(Map.Entry<String, List<HotWaterControlListVO>> houseEntry) { |
||||
HotWaterControlDTO dto = new HotWaterControlDTO(); |
||||
dto.setId(houseEntry.getKey()); |
||||
dto.setName(houseEntry.getValue().get(0).getDeviceType()); |
||||
dto.setOrderNum(houseEntry.getValue().get(0).getCtOrderNum()); |
||||
|
||||
// 不需要强制转换,直接使用Object类型
|
||||
List<Object> children = houseEntry.getValue().stream() |
||||
.collect(Collectors.groupingBy(HotWaterControlListVO::getDeviceId)) |
||||
.entrySet().stream() |
||||
.map(dlEntry -> createDeviceVO(dlEntry, dto)) |
||||
.sorted((obj1, obj2) -> { |
||||
// 根据实际对象类型获取orderNum进行排序
|
||||
int order1 = getOrderNumFromObject(obj1); |
||||
int order2 = getOrderNumFromObject(obj2); |
||||
return Integer.compare(order1, order2); |
||||
}) |
||||
.collect(Collectors.toList()); |
||||
|
||||
dto.setChildren(children); |
||||
return dto; |
||||
} |
||||
|
||||
// 辅助方法:从不同的VO对象中获取orderNum
|
||||
private int getOrderNumFromObject(Object obj) { |
||||
try { |
||||
if (obj != null) { |
||||
// 使用反射获取orderNum字段
|
||||
java.lang.reflect.Method getOrderNumMethod = obj.getClass().getMethod("getOrderNum"); |
||||
return (int) getOrderNumMethod.invoke(obj); |
||||
} |
||||
} catch (Exception e) { |
||||
// 如果发生异常,默认返回0
|
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
|
||||
private Object createDeviceVO(Map.Entry<String, List<HotWaterControlListVO>> dlEntry, HotWaterControlDTO parentDto) { |
||||
List<HotWaterControlListVO> dlItems = dlEntry.getValue(); |
||||
String deviceTypeName = parentDto.getName(); |
||||
|
||||
switch (deviceTypeName) { |
||||
case "系统": |
||||
return createSystemControlVO(dlEntry, dlItems, parentDto); |
||||
case "热泵": |
||||
return createHotPumpControlVO(dlEntry, dlItems, parentDto); |
||||
case "循环泵": |
||||
return createCircuitPumpControlVO(dlEntry, dlItems, parentDto); |
||||
case "回水泵": |
||||
return createBackPumpControlVO(dlEntry, dlItems, parentDto); |
||||
case "设备校准": |
||||
return createDeviceCalibrationControlVO(dlEntry, dlItems, parentDto); |
||||
case "电表": |
||||
case "水表": |
||||
return createDeviceControlVO(dlEntry, dlItems, parentDto); |
||||
default: |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
private HotWaterSystemControlVO createSystemControlVO( |
||||
Map.Entry<String, List<HotWaterControlListVO>> dlEntry, |
||||
List<HotWaterControlListVO> dlItems, |
||||
HotWaterControlDTO parentDto) { |
||||
|
||||
HotWaterSystemControlVO vo = new HotWaterSystemControlVO(); |
||||
setupBasicDeviceInfo(vo, dlEntry, dlItems, parentDto); |
||||
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "1": |
||||
// 时间写入控制
|
||||
vo.setTimeSet(item.getCurValue().intValue()); |
||||
vo.setTimeSetId(item.getCpmId()); |
||||
break; |
||||
case "5": |
||||
// 压力
|
||||
vo.setPressure(item.getCurValue()); |
||||
vo.setPressureId(item.getCpmId()); |
||||
break; |
||||
case "6": |
||||
case "12": |
||||
// 回水温度
|
||||
vo.setInTemp(item.getCurValue()); |
||||
vo.setInTempId(item.getCpmId()); |
||||
break; |
||||
case "10": |
||||
// 水箱温度
|
||||
vo.setTankTemp(item.getCurValue()); |
||||
vo.setTankTempId(item.getCpmId()); |
||||
break; |
||||
case "20": |
||||
// 太阳能温度
|
||||
vo.setSolarTemp(item.getCurValue()); |
||||
vo.setSolarTempId(item.getCpmId()); |
||||
break; |
||||
case "15": |
||||
// 时间
|
||||
handleSystemTimeParameters(vo, item); |
||||
break; |
||||
case "28": |
||||
// modbus 重置复位
|
||||
vo.setReset(item.getCurValue().intValue()); |
||||
vo.setResetId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
// 开始组装时间,写入plcTime
|
||||
vo.setPlcTime(getPlcTime(vo)); |
||||
return vo; |
||||
} |
||||
|
||||
private String getPlcTime(HotWaterSystemControlVO vo) { |
||||
return String.format("%04d-%02d-%02d %02d:%02d:%02d", |
||||
vo.getYearTimeRead(), vo.getMonthTimeRead(), vo.getDayTimeRead(), |
||||
vo.getHourTimeRead(), vo.getMinTimeRead(), vo.getScTimeRead()); |
||||
} |
||||
|
||||
private void handleSystemTimeParameters(HotWaterSystemControlVO vo, HotWaterControlListVO item) { |
||||
String otherName = item.getOtherName(); |
||||
int value = item.getCurValue().intValue(); |
||||
String cpmId = item.getCpmId(); |
||||
|
||||
switch (otherName) { |
||||
case "年_读": |
||||
vo.setYearTimeRead(Integer.parseInt("20" + value)); |
||||
vo.setYearTimeReadId(cpmId); |
||||
break; |
||||
case "月_读": |
||||
vo.setMonthTimeRead(value); |
||||
vo.setMonthTimeReadId(cpmId); |
||||
break; |
||||
case "日_读": |
||||
vo.setDayTimeRead(value); |
||||
vo.setDayTimeReadId(cpmId); |
||||
break; |
||||
case "时_读": |
||||
vo.setHourTimeRead(value); |
||||
vo.setHourTimeReadId(cpmId); |
||||
break; |
||||
case "分_读": |
||||
vo.setMinTimeRead(value); |
||||
vo.setMinTimeReadId(cpmId); |
||||
break; |
||||
case "秒_读": |
||||
vo.setScTimeRead(value); |
||||
vo.setScTimeReadId(cpmId); |
||||
break; |
||||
case "秒_写": |
||||
vo.setScTimeSet(value); |
||||
vo.setScTimeSetId(cpmId); |
||||
break; |
||||
case "年_写": |
||||
vo.setYearTimeSet(Integer.parseInt("20" + value)); |
||||
vo.setYearTimeSetId(cpmId); |
||||
break; |
||||
case "月_写": |
||||
vo.setMonthTimeSet(value); |
||||
vo.setMonthTimeSetId(cpmId); |
||||
break; |
||||
case "日_写": |
||||
vo.setDayTimeSet(value); |
||||
vo.setDayTimeSetId(cpmId); |
||||
break; |
||||
case "时_写": |
||||
vo.setHourTimeSet(value); |
||||
vo.setHourTimeSetId(cpmId); |
||||
break; |
||||
case "分_写": |
||||
vo.setMinTimeSet(value); |
||||
vo.setMinTimeSetId(cpmId); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
private HotWaterHotPumpControlVO createHotPumpControlVO( |
||||
Map.Entry<String, List<HotWaterControlListVO>> dlEntry, |
||||
List<HotWaterControlListVO> dlItems, |
||||
HotWaterControlDTO parentDto) { |
||||
|
||||
HotWaterHotPumpControlVO hotPumpVo = new HotWaterHotPumpControlVO(); |
||||
setupBasicDeviceInfo(hotPumpVo, dlEntry, dlItems, parentDto); |
||||
|
||||
// 判断故障状态
|
||||
if (dlItems.stream().anyMatch(item -> |
||||
"3".equals(item.getParamTypeId()) && "1".equals(item.getCurValue().toString()))) { |
||||
hotPumpVo.setFault(1); |
||||
} |
||||
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "4": |
||||
// 时控
|
||||
handleHotPumpTimeParameters(hotPumpVo, item); |
||||
break; |
||||
case "1": |
||||
// 启停控制
|
||||
if (item.getOtherName().contains("12") || item.getOtherName().contains("13")) { |
||||
hotPumpVo.setStartStopControlOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setStartStopControlOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34") || item.getOtherName().contains("24")) { |
||||
hotPumpVo.setStartStopControlTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setStartStopControlTwoId(item.getCpmId()); |
||||
} else { |
||||
hotPumpVo.setStartStopControl(item.getCurValue().intValue()); |
||||
hotPumpVo.setStartStopControlId(item.getCpmId()); |
||||
} |
||||
break; |
||||
case "2": |
||||
// 运行状态
|
||||
hotPumpVo.setRunState(item.getCurValue().intValue()); |
||||
hotPumpVo.setRunStateId(item.getCpmId()); |
||||
break; |
||||
case "10": |
||||
// 水箱温度
|
||||
hotPumpVo.setTankTemp(item.getCurValue()); |
||||
hotPumpVo.setTankTempId(item.getCpmId()); |
||||
break; |
||||
case "11": |
||||
// 出水温度
|
||||
hotPumpVo.setOutWaterTemp(item.getCurValue()); |
||||
hotPumpVo.setOutWaterTempId(item.getCpmId()); |
||||
break; |
||||
case "12": |
||||
/// 回水温度
|
||||
hotPumpVo.setInWaterTemp(item.getCurValue()); |
||||
hotPumpVo.setInWaterTempId(item.getCpmId()); |
||||
break; |
||||
case "16": |
||||
// 累积运行时间
|
||||
hotPumpVo.setRunTime(item.getCurValue()); |
||||
hotPumpVo.setRunTimeId(item.getCpmId()); |
||||
break; |
||||
case "17": |
||||
// 开
|
||||
hotPumpVo.setStart(item.getCurValue().toString()); |
||||
hotPumpVo.setStartId(item.getCpmId()); |
||||
break; |
||||
case "18": |
||||
// 关
|
||||
hotPumpVo.setStop(item.getCurValue().toString()); |
||||
hotPumpVo.setStopId(item.getCpmId()); |
||||
break; |
||||
case "7": |
||||
// 温度设定
|
||||
hotPumpVo.setSetTemp(item.getCurValue()); |
||||
hotPumpVo.setSetTempId(item.getCpmId()); |
||||
break; |
||||
case "22": |
||||
// 手自动切换
|
||||
if (item.getOtherName().contains("12") || item.getOtherName().contains("13")) { |
||||
hotPumpVo.setManualAutoSwitchOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setManualAutoSwitchOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34") || item.getOtherName().contains("24")) { |
||||
hotPumpVo.setManualAutoSwitchTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setManualAutoSwitchTwoId(item.getCpmId()); |
||||
} else { |
||||
hotPumpVo.setManualAutoSwitch(item.getCurValue().intValue()); |
||||
hotPumpVo.setManualAutoSwitchId(item.getCpmId()); |
||||
} |
||||
break; |
||||
case "28": |
||||
// 通讯失败复位
|
||||
hotPumpVo.setReset(item.getCurValue().intValue()); |
||||
hotPumpVo.setResetId(item.getCpmId()); |
||||
break; |
||||
case "29": |
||||
// 通讯失败
|
||||
hotPumpVo.setCommunicationFailure(item.getCurValue().intValue()); |
||||
hotPumpVo.setCommunicationFailureId(item.getCpmId()); |
||||
break; |
||||
case "30": |
||||
// 通讯失败次数
|
||||
hotPumpVo.setCommunicationFailureCount(item.getCurValue().intValue()); |
||||
hotPumpVo.setCommunicationFailureCountId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
// 开始拼接时间,写入oneHourMinTimeOpenSetOneStr等时间参数
|
||||
if (hotPumpVo.getOneHourTimeOpenSetOneId() != null && hotPumpVo.getOneMinTimeCloseSetOneId() != null) { |
||||
hotPumpVo.setOneHourMinTimeOpenSetOneStr(String.format("%02d:%02d", hotPumpVo.getOneHourTimeOpenSetOne(), hotPumpVo.getOneMinTimeOpenSetOne())); |
||||
hotPumpVo.setOneHourMinTimeCloseSetOneStr(String.format("%02d:%02d", hotPumpVo.getOneHourTimeCloseSetOne(), hotPumpVo.getOneMinTimeCloseSetOne())); |
||||
} |
||||
if (hotPumpVo.getTwoHourTimeOpenSetOneId() != null && hotPumpVo.getTwoMinTimeCloseSetOneId() != null) { |
||||
hotPumpVo.setTwoHourMinTimeOpenSetOneStr(String.format("%02d:%02d", hotPumpVo.getTwoHourTimeOpenSetOne(), hotPumpVo.getTwoMinTimeOpenSetOne())); |
||||
hotPumpVo.setTwoHourMinTimeCloseSetOneStr(String.format("%02d:%02d", hotPumpVo.getTwoHourTimeCloseSetOne(), hotPumpVo.getTwoMinTimeCloseSetOne())); |
||||
} |
||||
if (hotPumpVo.getOneHourTimeOpenSetTwoId() != null && hotPumpVo.getOneMinTimeCloseSetTwoId() != null) { |
||||
hotPumpVo.setOneHourMinTimeOpenSetTwoStr(String.format("%02d:%02d", hotPumpVo.getOneHourTimeOpenSetTwo(), hotPumpVo.getOneMinTimeOpenSetTwo())); |
||||
hotPumpVo.setOneHourMinTimeCloseSetTwoStr(String.format("%02d:%02d", hotPumpVo.getOneHourTimeCloseSetTwo(), hotPumpVo.getOneMinTimeCloseSetTwo())); |
||||
} |
||||
if (hotPumpVo.getTwoHourTimeOpenSetTwoId() != null && hotPumpVo.getTwoMinTimeCloseSetTwoId() != null) { |
||||
hotPumpVo.setTwoHourMinTimeOpenSetTwoStr(String.format("%02d:%02d", hotPumpVo.getTwoHourTimeOpenSetTwo(), hotPumpVo.getTwoMinTimeOpenSetTwo())); |
||||
hotPumpVo.setTwoHourMinTimeCloseSetTwoStr(String.format("%02d:%02d", hotPumpVo.getTwoHourTimeCloseSetTwo(), hotPumpVo.getTwoMinTimeCloseSetTwo())); |
||||
} |
||||
if (hotPumpVo.getOneHourTimeOpenSetThreeId() != null && hotPumpVo.getOneMinTimeCloseSetThreeId() != null) { |
||||
hotPumpVo.setOneHourMinTimeOpenSetThreeStr(String.format("%02d:%02d", hotPumpVo.getOneHourTimeOpenSetThree(), hotPumpVo.getOneMinTimeOpenSetThree())); |
||||
hotPumpVo.setOneHourMinTimeCloseSetThreeStr(String.format("%02d:%02d", hotPumpVo.getOneHourTimeCloseSetThree(), hotPumpVo.getOneMinTimeCloseSetThree())); |
||||
} |
||||
if (hotPumpVo.getTwoHourTimeOpenSetThreeId() != null && hotPumpVo.getTwoMinTimeCloseSetThreeId() != null) { |
||||
hotPumpVo.setTwoHourMinTimeOpenSetThreeStr(String.format("%02d:%02d", hotPumpVo.getTwoHourTimeOpenSetThree(), hotPumpVo.getTwoMinTimeOpenSetThree())); |
||||
hotPumpVo.setTwoHourMinTimeCloseSetThreeStr(String.format("%02d:%02d", hotPumpVo.getTwoHourTimeCloseSetThree(), hotPumpVo.getTwoMinTimeCloseSetThree())); |
||||
} |
||||
return hotPumpVo; |
||||
} |
||||
|
||||
private void handleHotPumpTimeParameters(HotWaterHotPumpControlVO hotPumpVo, HotWaterControlListVO item) { |
||||
String otherName = item.getOtherName(); |
||||
int value = item.getCurValue().intValue(); |
||||
String cpmId = item.getCpmId(); |
||||
|
||||
// 12定时组
|
||||
if (otherName.contains("12定时_时开1")) { |
||||
hotPumpVo.setOneHourTimeOpenSetOne(value); |
||||
hotPumpVo.setOneHourTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("12定时_时关1")) { |
||||
hotPumpVo.setOneHourTimeCloseSetOne(value); |
||||
hotPumpVo.setOneHourTimeCloseSetOneId(cpmId); |
||||
} else if (otherName.contains("12定时_时开2")) { |
||||
hotPumpVo.setOneHourTimeOpenSetTwo(value); |
||||
hotPumpVo.setOneHourTimeOpenSetTwoId(cpmId); |
||||
} else if (otherName.contains("12定时_时关2")) { |
||||
hotPumpVo.setOneHourTimeCloseSetTwo(value); |
||||
hotPumpVo.setOneHourTimeCloseSetTwoId(cpmId); |
||||
} else if (otherName.contains("12定时_时开3")) { |
||||
hotPumpVo.setOneHourTimeOpenSetThree(value); |
||||
hotPumpVo.setOneHourTimeOpenSetThreeId(cpmId); |
||||
} else if (otherName.contains("12定时_时关3")) { |
||||
hotPumpVo.setOneHourTimeCloseSetThree(value); |
||||
hotPumpVo.setOneHourTimeCloseSetThreeId(cpmId); |
||||
} else if (otherName.contains("12定时_分开1")) { |
||||
hotPumpVo.setOneMinTimeOpenSetOne(value); |
||||
hotPumpVo.setOneMinTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("12定时_分关1")) { |
||||
hotPumpVo.setOneMinTimeCloseSetOne(value); |
||||
hotPumpVo.setOneMinTimeCloseSetOneId(cpmId); |
||||
} else if (otherName.contains("12定时_分开2")) { |
||||
hotPumpVo.setOneMinTimeOpenSetTwo(value); |
||||
hotPumpVo.setOneMinTimeOpenSetTwoId(cpmId); |
||||
} else if (otherName.contains("12定时_分关2")) { |
||||
hotPumpVo.setOneMinTimeCloseSetTwo(value); |
||||
hotPumpVo.setOneMinTimeCloseSetTwoId(cpmId); |
||||
} else if (otherName.contains("12定时_分开3")) { |
||||
hotPumpVo.setOneMinTimeOpenSetThree(value); |
||||
hotPumpVo.setOneMinTimeOpenSetThreeId(cpmId); |
||||
} else if (otherName.contains("12定时_分关3")) { |
||||
hotPumpVo.setOneMinTimeCloseSetThree(value); |
||||
hotPumpVo.setOneMinTimeCloseSetThreeId(cpmId); |
||||
} |
||||
// 34定时组
|
||||
else if (otherName.contains("34定时_时开1")) { |
||||
hotPumpVo.setTwoHourTimeOpenSetOne(value); |
||||
hotPumpVo.setTwoHourTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("34定时_时关1")) { |
||||
hotPumpVo.setTwoHourTimeCloseSetOne(value); |
||||
hotPumpVo.setTwoHourTimeCloseSetOneId(cpmId); |
||||
} else if (otherName.contains("34定时_时开2")) { |
||||
hotPumpVo.setTwoHourTimeOpenSetTwo(value); |
||||
hotPumpVo.setTwoHourTimeOpenSetTwoId(cpmId); |
||||
} else if (otherName.contains("34定时_时关2")) { |
||||
hotPumpVo.setTwoHourTimeCloseSetTwo(value); |
||||
hotPumpVo.setTwoHourTimeCloseSetTwoId(cpmId); |
||||
} else if (otherName.contains("34定时_时开3")) { |
||||
hotPumpVo.setTwoHourTimeOpenSetThree(value); |
||||
hotPumpVo.setTwoHourTimeOpenSetThreeId(cpmId); |
||||
} else if (otherName.contains("34定时_时关3")) { |
||||
hotPumpVo.setTwoHourTimeCloseSetThree(value); |
||||
hotPumpVo.setTwoHourTimeCloseSetThreeId(cpmId); |
||||
} else if (otherName.contains("34定时_分开1")) { |
||||
hotPumpVo.setTwoMinTimeOpenSetOne(value); |
||||
hotPumpVo.setTwoMinTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("34定时_分关1")) { |
||||
hotPumpVo.setTwoMinTimeCloseSetOne(value); |
||||
hotPumpVo.setTwoMinTimeCloseSetOneId(cpmId); |
||||
} else if (otherName.contains("34定时_分开2")) { |
||||
hotPumpVo.setTwoMinTimeOpenSetTwo(value); |
||||
hotPumpVo.setTwoMinTimeOpenSetTwoId(cpmId); |
||||
} else if (otherName.contains("34定时_分关2")) { |
||||
hotPumpVo.setTwoMinTimeCloseSetTwo(value); |
||||
hotPumpVo.setTwoMinTimeCloseSetTwoId(cpmId); |
||||
} else if (otherName.contains("34定时_分开3")) { |
||||
hotPumpVo.setTwoMinTimeOpenSetThree(value); |
||||
hotPumpVo.setTwoMinTimeOpenSetThreeId(cpmId); |
||||
} else if (otherName.contains("34定时_分关3")) { |
||||
hotPumpVo.setTwoMinTimeCloseSetThree(value); |
||||
hotPumpVo.setTwoMinTimeCloseSetThreeId(cpmId); |
||||
} |
||||
} |
||||
|
||||
private HotWaterCircuitPumpControlVO createCircuitPumpControlVO( |
||||
Map.Entry<String, List<HotWaterControlListVO>> dlEntry, |
||||
List<HotWaterControlListVO> dlItems, |
||||
HotWaterControlDTO parentDto) { |
||||
|
||||
HotWaterCircuitPumpControlVO circuitPumpVo = new HotWaterCircuitPumpControlVO(); |
||||
setupBasicDeviceInfo(circuitPumpVo, dlEntry, dlItems, parentDto); |
||||
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "1": |
||||
// 启停控制
|
||||
circuitPumpVo.setStartStopControl(item.getCurValue().intValue()); |
||||
circuitPumpVo.setStartStopControlId(item.getCpmId()); |
||||
break; |
||||
case "2": |
||||
// 运行状态
|
||||
circuitPumpVo.setRunState(item.getCurValue().intValue()); |
||||
circuitPumpVo.setRunStateId(item.getCpmId()); |
||||
break; |
||||
case "3": |
||||
// 故障状态
|
||||
circuitPumpVo.setFault(item.getCurValue().intValue()); |
||||
circuitPumpVo.setFaultId(item.getCpmId()); |
||||
break; |
||||
case "4": |
||||
// 时控
|
||||
handleCircuitPumpTimeParameters(circuitPumpVo, item); |
||||
break; |
||||
case "8": |
||||
// 温差
|
||||
circuitPumpVo.setTempDiff(item.getCurValue()); |
||||
circuitPumpVo.setTempDiffId(item.getCpmId()); |
||||
break; |
||||
case "9": |
||||
// 温差设置
|
||||
circuitPumpVo.setTempDiffSet(item.getCurValue()); |
||||
circuitPumpVo.setTempDiffSetId(item.getCpmId()); |
||||
break; |
||||
case "15": |
||||
// 开延时时间
|
||||
circuitPumpVo.setOpenDelayTime(item.getCurValue().intValue()); |
||||
circuitPumpVo.setOpenDelayTimeId(item.getCpmId()); |
||||
break; |
||||
case "16": |
||||
// 累计运行时间
|
||||
if (item.getOtherName().contains("小时")) { |
||||
circuitPumpVo.setRunTime(item.getCurValue()); |
||||
circuitPumpVo.setRunTimeId(item.getCpmId()); |
||||
} |
||||
break; |
||||
case "21": |
||||
// 一键启动
|
||||
circuitPumpVo.setStartOneKey(item.getCurValue().intValue()); |
||||
circuitPumpVo.setStartOneKeyId(item.getCpmId()); |
||||
break; |
||||
case "22": |
||||
// 手动自动切换
|
||||
circuitPumpVo.setManualAutoSwitch(item.getCurValue().intValue()); |
||||
circuitPumpVo.setManualAutoSwitchId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
if (circuitPumpVo.getOneHourTimeOpenSetOneId() != null |
||||
&& circuitPumpVo.getOneHourTimeCloseSetOneId() != null |
||||
&& circuitPumpVo.getOneMinTimeOpenSetOneId() != null |
||||
&& circuitPumpVo.getOneMinTimeCloseSetOneId() != null) { |
||||
// 设置时分开写入oneHourMinTimeOpenSetOneStr,oneHourMinTimeCloseSetOneStr
|
||||
circuitPumpVo.setOneHourMinTimeOpenSetOneStr(String.format("%02d:%02d", circuitPumpVo.getOneHourTimeOpenSetOne(), circuitPumpVo.getOneMinTimeOpenSetOne())); |
||||
circuitPumpVo.setOneHourMinTimeCloseSetOneStr(String.format("%02d:%02d", circuitPumpVo.getOneHourTimeCloseSetOne(), circuitPumpVo.getOneMinTimeCloseSetOne())); |
||||
} |
||||
return circuitPumpVo; |
||||
} |
||||
|
||||
private void handleCircuitPumpTimeParameters(HotWaterCircuitPumpControlVO circuitPumpVo, HotWaterControlListVO item) { |
||||
String otherName = item.getOtherName(); |
||||
int value = item.getCurValue().intValue(); |
||||
String cpmId = item.getCpmId(); |
||||
|
||||
if (otherName.contains("定时_时开1")) { |
||||
circuitPumpVo.setOneHourTimeOpenSetOne(value); |
||||
circuitPumpVo.setOneHourTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("定时_时关1")) { |
||||
circuitPumpVo.setOneHourTimeCloseSetOne(value); |
||||
circuitPumpVo.setOneHourTimeCloseSetOneId(cpmId); |
||||
} else if (otherName.contains("定时_分开1")) { |
||||
circuitPumpVo.setOneMinTimeOpenSetOne(value); |
||||
circuitPumpVo.setOneMinTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("定时_分关1")) { |
||||
circuitPumpVo.setOneMinTimeCloseSetOne(value); |
||||
circuitPumpVo.setOneMinTimeCloseSetOneId(cpmId); |
||||
} |
||||
} |
||||
|
||||
private HotWaterBackPumpControlVO createBackPumpControlVO( |
||||
Map.Entry<String, List<HotWaterControlListVO>> dlEntry, |
||||
List<HotWaterControlListVO> dlItems, |
||||
HotWaterControlDTO parentDto) { |
||||
|
||||
HotWaterBackPumpControlVO backPumpVo = new HotWaterBackPumpControlVO(); |
||||
setupBasicDeviceInfo(backPumpVo, dlEntry, dlItems, parentDto); |
||||
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "1": |
||||
// 启停控制
|
||||
backPumpVo.setStartStopControl(item.getCurValue().intValue()); |
||||
backPumpVo.setStartStopControlId(item.getCpmId()); |
||||
break; |
||||
case "2": |
||||
// 运行状态
|
||||
backPumpVo.setRunState(item.getCurValue().intValue()); |
||||
backPumpVo.setRunStateId(item.getCpmId()); |
||||
break; |
||||
case "3": |
||||
// 故障状态
|
||||
backPumpVo.setFault(item.getCurValue().intValue()); |
||||
backPumpVo.setFaultId(item.getCpmId()); |
||||
break; |
||||
case "4": |
||||
// 时控
|
||||
handleBackPumpTimeParameters(backPumpVo, item); |
||||
break; |
||||
case "7": |
||||
// 温度设置
|
||||
backPumpVo.setTempSet(item.getCurValue()); |
||||
backPumpVo.setTempSetId(item.getCpmId()); |
||||
break; |
||||
case "15": |
||||
// 时间
|
||||
backPumpVo.setOpenDelayTime(item.getCurValue().intValue()); |
||||
backPumpVo.setOpenDelayTimeId(item.getCpmId()); |
||||
break; |
||||
case "16": |
||||
// 累积运行时间
|
||||
if (item.getOtherName().contains("小时")) { |
||||
backPumpVo.setRunTime(item.getCurValue()); |
||||
backPumpVo.setRunTimeId(item.getCpmId()); |
||||
} |
||||
break; |
||||
case "21": |
||||
// 一键启动
|
||||
backPumpVo.setStartOneKey(item.getCurValue().intValue()); |
||||
backPumpVo.setStartOneKeyId(item.getCpmId()); |
||||
break; |
||||
case "22": |
||||
// 手动自动切换
|
||||
backPumpVo.setManualAutoSwitch(item.getCurValue().intValue()); |
||||
backPumpVo.setManualAutoSwitchId(item.getCpmId()); |
||||
break; |
||||
case "25": |
||||
// 两台回水泵启动
|
||||
backPumpVo.setTwoPumpStart(item.getCurValue().intValue()); |
||||
backPumpVo.setTwoPumpStartId(item.getCpmId()); |
||||
break; |
||||
case "26": |
||||
// 温度上限
|
||||
backPumpVo.setTempSetUpperLimit(item.getCurValue()); |
||||
backPumpVo.setTempSetUpperLimitId(item.getCpmId()); |
||||
break; |
||||
case "27": |
||||
// 温度下限
|
||||
backPumpVo.setTempSetLowerLimit(item.getCurValue()); |
||||
backPumpVo.setTempSetLowerLimitId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
if (backPumpVo.getOneHourTimeOpenSetOneId() != null |
||||
&& backPumpVo.getOneHourTimeCloseSetOneId() != null |
||||
&& backPumpVo.getOneMinTimeOpenSetOneId() != null |
||||
&& backPumpVo.getOneMinTimeCloseSetOneId() != null) { |
||||
// 设置时分开写入oneHourMinTimeOpenSetOneStr,oneHourMinTimeCloseSetOneStr
|
||||
backPumpVo.setOneHourMinTimeOpenSetOneStr(String.format("%02d:%02d", backPumpVo.getOneHourTimeOpenSetOne(), backPumpVo.getOneMinTimeOpenSetOne())); |
||||
backPumpVo.setOneHourMinTimeCloseSetOneStr(String.format("%02d:%02d", backPumpVo.getOneHourTimeCloseSetOne(), backPumpVo.getOneMinTimeCloseSetOne())); |
||||
} |
||||
if (backPumpVo.getOneHourTimeOpenSetTwoId() != null |
||||
&& backPumpVo.getOneHourTimeCloseSetTwoId() != null |
||||
&& backPumpVo.getOneMinTimeOpenSetTwoId() != null |
||||
&& backPumpVo.getOneMinTimeCloseSetTwoId() != null) { |
||||
// 获取时分开写入oneHourMinTimeOpenSetTwoStr,oneHourMinTimeCloseSetTwoStr
|
||||
backPumpVo.setOneHourMinTimeOpenSetTwoStr(String.format("%02d:%02d", backPumpVo.getOneHourTimeOpenSetTwo(), backPumpVo.getOneMinTimeOpenSetTwo())); |
||||
backPumpVo.setOneHourMinTimeCloseSetTwoStr(String.format("%02d:%02d", backPumpVo.getOneHourTimeCloseSetTwo(), backPumpVo.getOneMinTimeCloseSetTwo())); |
||||
} |
||||
if (backPumpVo.getOneHourTimeOpenSetThreeId() != null |
||||
&& backPumpVo.getOneHourTimeCloseSetThreeId() != null |
||||
&& backPumpVo.getOneMinTimeOpenSetThreeId() != null |
||||
&& backPumpVo.getOneMinTimeCloseSetThreeId() != null) { |
||||
// 获取时分开写入oneHourMinTimeOpenSetThreeStr,oneHourMinTimeCloseSetThreeStr
|
||||
backPumpVo.setOneHourMinTimeOpenSetThreeStr(String.format("%02d:%02d", backPumpVo.getOneHourTimeOpenSetThree(), backPumpVo.getOneMinTimeOpenSetThree())); |
||||
backPumpVo.setOneHourMinTimeCloseSetThreeStr(String.format("%02d:%02d", backPumpVo.getOneHourTimeCloseSetThree(), backPumpVo.getOneMinTimeCloseSetThree())); |
||||
} |
||||
return backPumpVo; |
||||
} |
||||
|
||||
private void handleBackPumpTimeParameters(HotWaterBackPumpControlVO backPumpVo, HotWaterControlListVO item) { |
||||
String otherName = item.getOtherName(); |
||||
int value = item.getCurValue().intValue(); |
||||
String cpmId = item.getCpmId(); |
||||
|
||||
if (otherName.contains("定时_时开1")) { |
||||
backPumpVo.setOneHourTimeOpenSetOne(value); |
||||
backPumpVo.setOneHourTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("定时_时关1")) { |
||||
backPumpVo.setOneHourTimeCloseSetOne(value); |
||||
backPumpVo.setOneHourTimeCloseSetOneId(cpmId); |
||||
} else if (otherName.contains("定时_分开1")) { |
||||
backPumpVo.setOneMinTimeOpenSetOne(value); |
||||
backPumpVo.setOneMinTimeOpenSetOneId(cpmId); |
||||
} else if (otherName.contains("定时_分关1")) { |
||||
backPumpVo.setOneMinTimeCloseSetOne(value); |
||||
backPumpVo.setOneMinTimeCloseSetOneId(cpmId); |
||||
} else if (otherName.contains("定时_时开2")) { |
||||
backPumpVo.setOneHourTimeOpenSetTwo(value); |
||||
backPumpVo.setOneHourTimeOpenSetTwoId(cpmId); |
||||
} else if (otherName.contains("定时_时关2")) { |
||||
backPumpVo.setOneHourTimeCloseSetTwo(value); |
||||
backPumpVo.setOneHourTimeCloseSetTwoId(cpmId); |
||||
} else if (otherName.contains("定时_分开2")) { |
||||
backPumpVo.setOneMinTimeOpenSetTwo(value); |
||||
backPumpVo.setOneMinTimeOpenSetTwoId(cpmId); |
||||
} else if (otherName.contains("定时_分关2")) { |
||||
backPumpVo.setOneMinTimeCloseSetTwo(value); |
||||
backPumpVo.setOneMinTimeCloseSetTwoId(cpmId); |
||||
} else if (otherName.contains("定时_时开3")) { |
||||
backPumpVo.setOneHourTimeOpenSetThree(value); |
||||
backPumpVo.setOneHourTimeOpenSetThreeId(cpmId); |
||||
} else if (otherName.contains("定时_时关3")) { |
||||
backPumpVo.setOneHourTimeCloseSetThree(value); |
||||
backPumpVo.setOneHourTimeCloseSetThreeId(cpmId); |
||||
} else if (otherName.contains("定时_分开3")) { |
||||
backPumpVo.setOneMinTimeOpenSetThree(value); |
||||
backPumpVo.setOneMinTimeOpenSetThreeId(cpmId); |
||||
} else if (otherName.contains("定时_分关3")) { |
||||
backPumpVo.setOneMinTimeCloseSetThree(value); |
||||
backPumpVo.setOneMinTimeCloseSetThreeId(cpmId); |
||||
} |
||||
} |
||||
|
||||
private HotWaterDeviceCalibrationControlVO createDeviceCalibrationControlVO( |
||||
Map.Entry<String, List<HotWaterControlListVO>> dlEntry, |
||||
List<HotWaterControlListVO> dlItems, |
||||
HotWaterControlDTO parentDto) { |
||||
|
||||
HotWaterDeviceCalibrationControlVO deviceCalibrationVo = new HotWaterDeviceCalibrationControlVO(); |
||||
setupBasicDeviceInfo(deviceCalibrationVo, dlEntry, dlItems, parentDto); |
||||
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "0": |
||||
// 上下限
|
||||
handleCalibrationParameters(deviceCalibrationVo, item); |
||||
break; |
||||
case "19": |
||||
// 校准值
|
||||
deviceCalibrationVo.setCalibrationValue(item.getCurValue()); |
||||
deviceCalibrationVo.setCalibrationValueId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
|
||||
return deviceCalibrationVo; |
||||
} |
||||
|
||||
private void handleCalibrationParameters(HotWaterDeviceCalibrationControlVO deviceCalibrationVo, HotWaterControlListVO item) { |
||||
String otherName = item.getOtherName(); |
||||
BigDecimal value = item.getCurValue(); |
||||
String cpmId = item.getCpmId(); |
||||
|
||||
if (otherName.contains("工程量上限")) { |
||||
deviceCalibrationVo.setEngineeringMaxValue(value); |
||||
deviceCalibrationVo.setEngineeringMaxValueId(cpmId); |
||||
} else if (otherName.contains("工程量下限")) { |
||||
deviceCalibrationVo.setEngineeringMinValue(value); |
||||
deviceCalibrationVo.setEngineeringMinValueId(cpmId); |
||||
} else if (otherName.contains("数字量上限")) { |
||||
deviceCalibrationVo.setDigitalMaxValue(value); |
||||
deviceCalibrationVo.setDigitalMaxValueId(cpmId); |
||||
} else if (otherName.contains("数字量下限")) { |
||||
deviceCalibrationVo.setDigitalMinValue(value); |
||||
deviceCalibrationVo.setDigitalMinValueId(cpmId); |
||||
} |
||||
} |
||||
|
||||
private HotWaterDeviceControlVO createDeviceControlVO( |
||||
Map.Entry<String, List<HotWaterControlListVO>> dlEntry, |
||||
List<HotWaterControlListVO> dlItems, |
||||
HotWaterControlDTO parentDto) { |
||||
|
||||
HotWaterDeviceControlVO meterVo = new HotWaterDeviceControlVO(); |
||||
setupBasicDeviceInfo(meterVo, dlEntry, dlItems, parentDto); |
||||
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "13": |
||||
case "14": |
||||
// 水电表读数
|
||||
// 获取保留小数位
|
||||
// 获取保留小数位
|
||||
int digits = item.getDigits(); |
||||
// 10的n次方
|
||||
BigDecimal power = BigDecimal.ONE.scaleByPowerOfTen(digits); |
||||
|
||||
BigDecimal originalValue = item.getCurValue(); |
||||
|
||||
// 将数值按指定小数位数格式化
|
||||
BigDecimal formattedValue = originalValue.divide(power, 2, RoundingMode.HALF_UP); |
||||
item.setCurValue(formattedValue); |
||||
|
||||
meterVo.setTotalReading(item.getCurValue()); |
||||
meterVo.setTotalReadingId(item.getCpmId()); |
||||
meterVo.setCurrentTime(item.getCurTime()); |
||||
meterVo.setCurrentTimeId(item.getCpmId()); |
||||
break; |
||||
case "29": |
||||
// 水电表通讯故障
|
||||
meterVo.setCommunicationFailure(item.getCurValue().intValue()); |
||||
meterVo.setCommunicationFailureId(item.getCpmId()); |
||||
break; |
||||
case "30": |
||||
// 水电表通讯故障计数
|
||||
meterVo.setCommunicationFailureCount(item.getCurValue().intValue()); |
||||
meterVo.setCommunicationFailureCountId(item.getCpmId()); |
||||
break; |
||||
case "28": |
||||
// 水电表通信故障复位
|
||||
meterVo.setReset(item.getCurValue().intValue()); |
||||
meterVo.setResetId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
|
||||
return meterVo; |
||||
} |
||||
|
||||
private void setupBasicDeviceInfo(Object vo, Map.Entry<String, List<HotWaterControlListVO>> dlEntry, |
||||
List<HotWaterControlListVO> dlItems, HotWaterControlDTO parentDto) { |
||||
// 使用反射设置基本属性
|
||||
try { |
||||
vo.getClass().getMethod("setId", String.class).invoke(vo, dlEntry.getKey()); |
||||
vo.getClass().getMethod("setOrderNum", int.class).invoke(vo, dlItems.get(0).getDlOrderNum()); |
||||
|
||||
String deviceName = StringUtils.isBlank(dlItems.get(0).getDeviceName()) ? |
||||
parentDto.getName() : dlItems.get(0).getDeviceName(); |
||||
vo.getClass().getMethod("setName", String.class).invoke(vo, deviceName); |
||||
} catch (Exception e) { |
||||
// 忽略反射异常
|
||||
} |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public CollectionParamsManageEntity selectDeviceInstallByOtherName(String name, String buildingId) { |
||||
return collectionParamsManageMapper.selectDeviceInstallByOtherName(name, buildingId); |
||||
} |
||||
|
||||
@Override |
||||
public void updateCPMByOtherName(String name, BigDecimal value, String time, String buildingId) { |
||||
try { |
||||
collectionParamsManageMapper.updateCPMByOtherName(name, value, time, "0", buildingId); |
||||
} catch (Exception e) { |
||||
collectionParamsManageMapper.updateCPMByOtherName(name, new BigDecimal(0), time, "-1", buildingId); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void getBatchUpdateCollectionParams(List<SanShiFengDatas> batch, String sn, String plcName, String projectName, String time, String buildingId) { |
||||
try { |
||||
collectionParamsManageMapper.updateBatchCPMByOtherName(batch, time, "0", buildingId); |
||||
} catch (Exception e) { |
||||
log.error("批量更新参数失败", e); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public List<CollectionParamsManageEntity> selectCPMList(String buildingId, String deviceInstallId, String otherName, Integer pageNum, Integer pageSize) { |
||||
return collectionParamsManageMapper.selectCPMList(buildingId, deviceInstallId, otherName, pageNum, pageSize); |
||||
} |
||||
|
||||
@Override |
||||
public int selectCPMListCount(String buildingId, String deviceInstallId, String otherName, Integer pageNum, Integer pageSize) { |
||||
return collectionParamsManageMapper.selectCPMListCount(buildingId, deviceInstallId, otherName, pageNum, pageSize); |
||||
} |
||||
|
||||
@Override |
||||
public CollectionParamsManageEntity selectById(String msId) { |
||||
return collectionParamsManageMapper.selectByPrimaryKey(msId); |
||||
} |
||||
|
||||
@Override |
||||
public String insertCPM(CollectionParamsManageEntity cpmEntity) { |
||||
// 判断是否存在otherName
|
||||
if (collectionParamsManageMapper.selectCountByOtherName(cpmEntity.getOtherName()) > 0) { |
||||
return "存在相同参数名称"; |
||||
} |
||||
if (null == cpmEntity.getCurTime()) { |
||||
cpmEntity.setCurTime(new Date()); |
||||
} |
||||
collectionParamsManageMapper.insertCPM(cpmEntity); |
||||
return Constant.SUCCESS; |
||||
} |
||||
|
||||
@Override |
||||
public String updateCPM(CollectionParamsManageEntity cpmEntity) { |
||||
// 判断是否存在otherName
|
||||
// if (collectionParamsManageMapper.selectCountByOtherName(cpmEntity.getOtherName()) > 0) {
|
||||
// return "存在相同参数名称";
|
||||
// }
|
||||
collectionParamsManageMapper.updateById(cpmEntity); |
||||
return Constant.SUCCESS; |
||||
} |
||||
|
||||
@Override |
||||
public int deleteByIds(String[] msIds) { |
||||
if (msIds != null && msIds.length > 0) { |
||||
for (String msId : msIds) { |
||||
collectionParamsManageMapper.deleteById(msId); |
||||
} |
||||
return msIds.length; |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public List<CollectionParamsManageEntity> selectAllCPMList() { |
||||
return collectionParamsManageMapper.selectAllCPMList(); |
||||
} |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue