Compare commits
4 Commits
prod_20251
...
dev
| Author | SHA1 | Date |
|---|---|---|
|
|
766b576477 | 6 hours ago |
|
|
097a9e6c81 | 4 days ago |
|
|
62c8a6fc87 | 1 week ago |
|
|
c04d960ad3 | 1 week ago |
89 changed files with 4524 additions and 73 deletions
@ -0,0 +1,122 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* 读取项目相关配置 |
||||
* |
||||
* @author mh |
||||
*/ |
||||
@Component |
||||
@ConfigurationProperties(prefix = "mh") |
||||
public class MHConfig |
||||
{ |
||||
/** 项目名称 */ |
||||
private String name; |
||||
|
||||
/** 版本 */ |
||||
private String version; |
||||
|
||||
/** 版权年份 */ |
||||
private String copyrightYear; |
||||
|
||||
/** 上传路径 */ |
||||
private static String profile; |
||||
|
||||
/** 获取地址开关 */ |
||||
private static boolean addressEnabled; |
||||
|
||||
/** 验证码类型 */ |
||||
private static String captchaType; |
||||
|
||||
public String getName() |
||||
{ |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) |
||||
{ |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getVersion() |
||||
{ |
||||
return version; |
||||
} |
||||
|
||||
public void setVersion(String version) |
||||
{ |
||||
this.version = version; |
||||
} |
||||
|
||||
public String getCopyrightYear() |
||||
{ |
||||
return copyrightYear; |
||||
} |
||||
|
||||
public void setCopyrightYear(String copyrightYear) |
||||
{ |
||||
this.copyrightYear = copyrightYear; |
||||
} |
||||
|
||||
public static String getProfile() |
||||
{ |
||||
return profile; |
||||
} |
||||
|
||||
public void setProfile(String profile) |
||||
{ |
||||
MHConfig.profile = profile; |
||||
} |
||||
|
||||
public static boolean isAddressEnabled() |
||||
{ |
||||
return addressEnabled; |
||||
} |
||||
|
||||
public void setAddressEnabled(boolean addressEnabled) |
||||
{ |
||||
MHConfig.addressEnabled = addressEnabled; |
||||
} |
||||
|
||||
public static String getCaptchaType() { |
||||
return captchaType; |
||||
} |
||||
|
||||
public void setCaptchaType(String captchaType) { |
||||
MHConfig.captchaType = captchaType; |
||||
} |
||||
|
||||
/** |
||||
* 获取导入上传路径 |
||||
*/ |
||||
public static String getImportPath() |
||||
{ |
||||
return getProfile() + "/import"; |
||||
} |
||||
|
||||
/** |
||||
* 获取头像上传路径 |
||||
*/ |
||||
public static String getAvatarPath() |
||||
{ |
||||
return getProfile() + "/avatar"; |
||||
} |
||||
|
||||
/** |
||||
* 获取下载路径 |
||||
*/ |
||||
public static String getDownloadPath() |
||||
{ |
||||
return getProfile() + "/download/"; |
||||
} |
||||
|
||||
/** |
||||
* 获取上传路径 |
||||
*/ |
||||
public static String getUploadPath() |
||||
{ |
||||
return getProfile() + "/upload"; |
||||
} |
||||
} |
||||
@ -0,0 +1,59 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 声明所有通道 |
||||
* @date 2024-10-29 16:04:19 |
||||
*/ |
||||
public class ChannelName { |
||||
|
||||
/** |
||||
* 默认通道名称(防止出错) |
||||
*/ |
||||
public static final String DEFAULT_BOUND = "default_bound"; |
||||
|
||||
/** |
||||
* 主动上报入站 |
||||
*/ |
||||
public static final String INBOUND = "inbound"; |
||||
|
||||
/** |
||||
* 出站 |
||||
*/ |
||||
public static final String OUTBOUND = "outbound"; |
||||
|
||||
|
||||
/** |
||||
* 入站主动上报 |
||||
*/ |
||||
public static final String EVENTS_UPLOAD_INBOUND = "events_upload_inbound"; |
||||
|
||||
/** |
||||
* 入站主动采集 |
||||
*/ |
||||
public static final String EVENTS_COLLECTION_INBOUND = "events_collection_inbound"; |
||||
|
||||
/** |
||||
* 入站主动控制 |
||||
*/ |
||||
public static final String EVENTS_CONTROL_INBOUND = "events_control_inbound"; |
||||
|
||||
/** |
||||
* 默认进站处理 |
||||
*/ |
||||
public static final String EVENTS_DEFAULT_INBOUND = "events_default_inbound"; |
||||
|
||||
public static final String REPLY_EVENTS_OUTBOUND = "reply_events_outbound"; |
||||
|
||||
/** |
||||
* 新珠江收到的信息 |
||||
*/ |
||||
public static final String EVENTS_RECEIVE_INBOUND = "events_receive_inbound"; |
||||
|
||||
/** |
||||
* 接收服务端的数据报文 |
||||
*/ |
||||
public static final String EVENTS_SEND_INBOUND = "events_send_inbound"; |
||||
} |
||||
@ -0,0 +1,36 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
/** |
||||
* Unified Topic response format |
||||
* |
||||
* @author sean.zhou |
||||
* @version 0.1 |
||||
* @date 2021/11/15 |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
@Builder |
||||
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
public class CommonTopicResponse<T> { |
||||
|
||||
/** |
||||
* The command is sent and the response is matched by the tid and bid fields in the message, |
||||
* and the reply should keep the tid and bid the same. |
||||
*/ |
||||
private String tid; |
||||
|
||||
private String bid; |
||||
|
||||
private String method; |
||||
|
||||
private T data; |
||||
|
||||
private Long timestamp; |
||||
} |
||||
@ -0,0 +1,108 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description mqtt连接的参数 |
||||
* @date 2024-10-29 14:46:24 |
||||
*/ |
||||
public class MqttClientOptions { |
||||
|
||||
private MqttProtocolEnum protocol; |
||||
|
||||
private String host; |
||||
|
||||
private Integer port; |
||||
|
||||
private String username; |
||||
|
||||
private String password; |
||||
|
||||
private String clientId; |
||||
|
||||
private String path; |
||||
|
||||
/** |
||||
* 客户端连接的时候,订阅的主题 |
||||
*/ |
||||
private String inboundTopic; |
||||
|
||||
public MqttProtocolEnum getProtocol() { |
||||
return protocol; |
||||
} |
||||
|
||||
public void setProtocol(MqttProtocolEnum protocol) { |
||||
this.protocol = protocol; |
||||
} |
||||
|
||||
public String getHost() { |
||||
return host; |
||||
} |
||||
|
||||
public void setHost(String host) { |
||||
this.host = host; |
||||
} |
||||
|
||||
public Integer getPort() { |
||||
return port; |
||||
} |
||||
|
||||
public void setPort(Integer port) { |
||||
this.port = port; |
||||
} |
||||
|
||||
public String getUsername() { |
||||
return username; |
||||
} |
||||
|
||||
public void setUsername(String username) { |
||||
this.username = username; |
||||
} |
||||
|
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
|
||||
public String getClientId() { |
||||
return clientId; |
||||
} |
||||
|
||||
public void setClientId(String clientId) { |
||||
this.clientId = clientId; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return path; |
||||
} |
||||
|
||||
public void setPath(String path) { |
||||
this.path = path; |
||||
} |
||||
|
||||
public String getInboundTopic() { |
||||
return inboundTopic; |
||||
} |
||||
|
||||
public void setInboundTopic(String inboundTopic) { |
||||
this.inboundTopic = inboundTopic; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "MqttClientOptions{" + |
||||
"protocol=" + protocol + |
||||
", host='" + host + '\'' + |
||||
", port=" + port + |
||||
", username='" + username + '\'' + |
||||
", password='" + password + '\'' + |
||||
", clientId='" + clientId + '\'' + |
||||
", path='" + path + '\'' + |
||||
", inboundTopic='" + inboundTopic + '\'' + |
||||
'}'; |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 采用哪种协议进行数据交互 |
||||
* @date 2024-10-29 15:21:07 |
||||
*/ |
||||
public enum MqttProtocolEnum { |
||||
|
||||
MQTT("tcp"), |
||||
|
||||
MQTTS("tcp"), |
||||
|
||||
WS("ws"), |
||||
|
||||
WSS("wss"); |
||||
|
||||
final String protocol; |
||||
|
||||
MqttProtocolEnum(String protocol) { |
||||
this.protocol = protocol; |
||||
} |
||||
|
||||
public String getProtocolAddr() { |
||||
return protocol + "://"; |
||||
} |
||||
|
||||
public String getProtocol() { |
||||
return protocol; |
||||
} |
||||
} |
||||
@ -0,0 +1,16 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description mqtt选择模式 |
||||
* @date 2024-10-29 15:19:21 |
||||
*/ |
||||
public enum MqttUseEnum { |
||||
|
||||
BASIC, |
||||
|
||||
DRC |
||||
|
||||
} |
||||
@ -0,0 +1,20 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author sean.zhou |
||||
* @version 0.1 |
||||
* @date 2021/11/22 |
||||
*/ |
||||
@Data |
||||
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
public class ServiceReply<T> { |
||||
|
||||
private Integer result; |
||||
|
||||
private T info; |
||||
|
||||
private T output; |
||||
} |
||||
@ -0,0 +1,31 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
/** |
||||
* All the topics that need to be used in the project. |
||||
* |
||||
* @author ljf |
||||
* @version 0.1 |
||||
* @date 2025-01-22 |
||||
*/ |
||||
public class TopicConst { |
||||
|
||||
public static final String MH_UPLOAD = "mh_upload/"; |
||||
|
||||
public static final String EVENTS_UPLOAD = "events_upload/"; |
||||
|
||||
public static final String MH_COLLECTION = "mh_collection/"; |
||||
|
||||
public static final String EVENTS_COLLECTION = "events_collection/"; |
||||
|
||||
public static final String MH_CONTROL = "mh_control/"; |
||||
|
||||
public static final String EVENTS_CONTROL = "events_control/"; |
||||
|
||||
public static final String REGEX_SN = "[A-Za-z0-9]+"; |
||||
|
||||
public static final String THING_MODEL_PRE = "thing/"; |
||||
|
||||
public static final String PRODUCT = "product/"; |
||||
|
||||
public static final String SERVICES_SUF = "/services"; |
||||
} |
||||
@ -0,0 +1,60 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.regex.Pattern; |
||||
|
||||
import static com.mh.user.constants.TopicConst.*; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @version 1.0 |
||||
* @description: TODO |
||||
* @date 2024/11/06 14:28 |
||||
*/ |
||||
public enum TopicEnum { |
||||
|
||||
/** |
||||
* 客户端主动上报数据 |
||||
*/ |
||||
CLIENT_UPLOAD_DATA(Pattern.compile("^" + MH_UPLOAD + EVENTS_UPLOAD + REGEX_SN + "$"), ChannelName.EVENTS_UPLOAD_INBOUND), |
||||
|
||||
/** |
||||
* 服务端采集数据 |
||||
*/ |
||||
SERVER_COLLECTION_DATA(Pattern.compile("^" + MH_COLLECTION + EVENTS_COLLECTION + REGEX_SN + "$"), ChannelName.EVENTS_COLLECTION_INBOUND), |
||||
|
||||
/** |
||||
* 服务端控制指令 |
||||
*/ |
||||
SERVER_CONTROL_DATA(Pattern.compile("^" + MH_CONTROL + EVENTS_CONTROL + REGEX_SN + "$"), ChannelName.EVENTS_CONTROL_INBOUND), |
||||
|
||||
/** |
||||
* 订阅服务端发送的主题命令 |
||||
*/ |
||||
SERVER_SEND_DATA(Pattern.compile("^A/cmd/ctl/send" + "$"), ChannelName.EVENTS_SEND_INBOUND), |
||||
|
||||
UNKNOWN(Pattern.compile("^.*$"), ChannelName.DEFAULT_BOUND); |
||||
|
||||
final Pattern pattern; |
||||
|
||||
final String beanName; |
||||
|
||||
TopicEnum(Pattern pattern, String beanName) { |
||||
this.pattern = pattern; |
||||
this.beanName = beanName; |
||||
} |
||||
|
||||
public Pattern getPattern() { |
||||
return pattern; |
||||
} |
||||
|
||||
public String getBeanName() { |
||||
return beanName; |
||||
} |
||||
|
||||
public static TopicEnum find(String proName, String topic) { |
||||
// 去掉第一个"/"以及之前数据
|
||||
String finalTopic = topic.replaceFirst("^"+proName, "");; |
||||
return Arrays.stream(TopicEnum.values()).filter(topicEnum -> topicEnum.pattern.matcher(finalTopic).matches()).findAny().orElse(UNKNOWN); |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@
|
||||
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()); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,52 @@
|
||||
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); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,144 @@
|
||||
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; |
||||
|
||||
// 定时_时开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; |
||||
|
||||
// 定时_时开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; |
||||
|
||||
// 开延时
|
||||
@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; |
||||
|
||||
@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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,104 @@
|
||||
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 int oneHourTimeCloseSetOne; |
||||
private String oneHourTimeCloseSetOneId; |
||||
|
||||
// 定时_分关1
|
||||
private int oneMinTimeCloseSetOne; |
||||
private String oneMinTimeCloseSetOneId; |
||||
|
||||
// 开延时
|
||||
@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; |
||||
|
||||
@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(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,38 @@
|
||||
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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,77 @@
|
||||
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; |
||||
|
||||
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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,186 @@
|
||||
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") |
||||
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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@
|
||||
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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
|
||||
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; |
||||
|
||||
@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 + "'") |
||||
.toString(); |
||||
} |
||||
} |
||||
@ -0,0 +1,241 @@
|
||||
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; |
||||
|
||||
// 热泵12定时_时关1
|
||||
private int oneHourTimeCloseSetOne; |
||||
private String oneHourTimeCloseSetOneId; |
||||
|
||||
// 热泵12定时_分关1 (新增分钟设置)
|
||||
private int oneMinTimeCloseSetOne; |
||||
private String oneMinTimeCloseSetOneId; |
||||
|
||||
// 热泵12定时_时开2
|
||||
private int oneHourTimeOpenSetTwo; |
||||
private String oneHourTimeOpenSetTwoId; |
||||
|
||||
// 热泵12定时_分开2 (新增分钟设置)
|
||||
private int oneMinTimeOpenSetTwo; |
||||
private String oneMinTimeOpenSetTwoId; |
||||
|
||||
// 热泵12定时_时关2
|
||||
private int oneHourTimeCloseSetTwo; |
||||
private String oneHourTimeCloseSetTwoId; |
||||
|
||||
// 热泵12定时_分关2 (新增分钟设置)
|
||||
private int oneMinTimeCloseSetTwo; |
||||
private String oneMinTimeCloseSetTwoId; |
||||
|
||||
// 热泵12定时_时开3
|
||||
private int oneHourTimeOpenSetThree; |
||||
private String oneHourTimeOpenSetThreeId; |
||||
|
||||
// 热泵12定时_分开3 (新增分钟设置)
|
||||
private int oneMinTimeOpenSetThree; |
||||
private String oneMinTimeOpenSetThreeId; |
||||
|
||||
// 热泵12定时_时关3
|
||||
private int oneHourTimeCloseSetThree; |
||||
private String oneHourTimeCloseSetThreeId; |
||||
|
||||
// 热泵12定时_分关3 (新增分钟设置)
|
||||
private int oneMinTimeCloseSetThree; |
||||
private String oneMinTimeCloseSetThreeId; |
||||
|
||||
// 热泵12定时_时开1
|
||||
private int twoHourTimeOpenSetOne; |
||||
private String twoHourTimeOpenSetOneId; |
||||
|
||||
// 热泵34定时_分开1 (新增分钟设置)
|
||||
private int twoMinTimeOpenSetOne; |
||||
private String twoMinTimeOpenSetOneId; |
||||
|
||||
// 热泵34定时_时关1
|
||||
private int twoHourTimeCloseSetOne; |
||||
private String twoHourTimeCloseSetOneId; |
||||
|
||||
// 热泵34定时_分关1 (新增分钟设置)
|
||||
private int twoMinTimeCloseSetOne; |
||||
private String twoMinTimeCloseSetOneId; |
||||
|
||||
// 热泵34定时_时开2
|
||||
private int twoHourTimeOpenSetTwo; |
||||
private String twoHourTimeOpenSetTwoId; |
||||
|
||||
// 热泵34定时_分开2 (新增分钟设置)
|
||||
private int twoMinTimeOpenSetTwo; |
||||
private String twoMinTimeOpenSetTwoId; |
||||
|
||||
// 热泵34定时_时关2
|
||||
private int twoHourTimeCloseSetTwo; |
||||
private String twoHourTimeCloseSetTwoId; |
||||
|
||||
// 热泵34定时_分关2 (新增分钟设置)
|
||||
private int twoMinTimeCloseSetTwo; |
||||
private String twoMinTimeCloseSetTwoId; |
||||
|
||||
// 热泵34定时_时开3
|
||||
private int twoHourTimeOpenSetThree; |
||||
private String twoHourTimeOpenSetThreeId; |
||||
|
||||
// 热泵34定时_分开3 (新增分钟设置)
|
||||
private int twoMinTimeOpenSetThree; |
||||
private String twoMinTimeOpenSetThreeId; |
||||
|
||||
// 热泵34定时_时关3
|
||||
private int twoHourTimeCloseSetThree; |
||||
private String twoHourTimeCloseSetThreeId; |
||||
|
||||
// 热泵34定时_分关3 (新增分钟设置)
|
||||
private int twoMinTimeCloseSetThree; |
||||
private String twoMinTimeCloseSetThreeId; |
||||
|
||||
// 热泵_开机 -> 去掉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前缀
|
||||
@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; |
||||
|
||||
@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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,55 @@
|
||||
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; // 回水状态
|
||||
|
||||
private int orderNum; |
||||
|
||||
} |
||||
@ -0,0 +1,145 @@
|
||||
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 sTimeRead; |
||||
private String sTimeReadId; |
||||
|
||||
// 分_读 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 sTimeSet; |
||||
private String sTimeSetId; |
||||
|
||||
// 分_写 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; |
||||
|
||||
@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("sTimeRead=" + sTimeRead) |
||||
.add("sTimeReadId='" + sTimeReadId + "'") |
||||
.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("sTimeSet=" + sTimeSet) |
||||
.add("sTimeSetId='" + sTimeSetId + "'") |
||||
.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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,108 @@
|
||||
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") |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date createTime; |
||||
|
||||
/** 当前时间 */ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
@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") |
||||
@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(); |
||||
} |
||||
} |
||||
@ -0,0 +1,48 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description mqtt订阅管理 |
||||
* @date 2025-02-14 13:47:07 |
||||
*/ |
||||
@Data |
||||
public class MqttSubscriptionEntity { |
||||
|
||||
private Long id; |
||||
|
||||
private String topic; |
||||
|
||||
private Short qos; |
||||
|
||||
private String clientId; |
||||
|
||||
private String status; |
||||
|
||||
/** 创建者 */ |
||||
private String createBy; |
||||
|
||||
/** 创建时间 */ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date createTime; |
||||
|
||||
/** 更新者 */ |
||||
private String updateBy; |
||||
|
||||
/** 更新时间 */ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date updateTime; |
||||
|
||||
/** 备注 */ |
||||
private String remark; |
||||
|
||||
} |
||||
@ -0,0 +1,193 @@
|
||||
package com.mh.user.mapper; |
||||
|
||||
import com.mh.user.dto.HotWaterControlListVO; |
||||
import com.mh.user.entity.CollectionParamsManageEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
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}") |
||||
void updateCPMByOtherName(String name, BigDecimal value, String time, String quality); |
||||
|
||||
@Select("select top 1 * from collection_params_manage where other_name = #{name}") |
||||
@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); |
||||
|
||||
@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, " + |
||||
" cpm.cur_value, " + |
||||
" cpm.cur_time, " + |
||||
" cpm.param_type_id, " + |
||||
" 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 = "ct_order_num", property = "ctOrderNum"), |
||||
@Result(column = "dl_order_num", property = "dlOrderNum") |
||||
}) |
||||
List<HotWaterControlListVO> selectHotWaterByBuildingId(String buildingId); |
||||
} |
||||
@ -0,0 +1,32 @@
|
||||
package com.mh.user.mapper; |
||||
|
||||
import com.mh.user.entity.MqttSubscriptionEntity; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Select; |
||||
import tk.mybatis.mapper.common.BaseMapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description mqtt订阅mapper类 |
||||
* @date 2025-02-14 14:00:58 |
||||
*/ |
||||
@Mapper |
||||
public interface MqttSubscriptionMapper extends BaseMapper<MqttSubscriptionEntity> { |
||||
|
||||
@Select("<script>" + |
||||
"SELECT * FROM mqtt_subscription WHERE 1=1 " + |
||||
"<if test='topic != null and topic != \"\"'>AND topic = #{topic}</if>" + |
||||
"<if test='status != null and status != \"\"'>AND status = #{status}</if>" + |
||||
"ORDER BY create_time DESC " + |
||||
"</script>") |
||||
List<MqttSubscriptionEntity> selectListByTopic(@Param("topic") String topic, |
||||
@Param("status") String status); |
||||
|
||||
@Select("SELECT top 1 * FROM mqtt_subscription WHERE id = #{id}") |
||||
MqttSubscriptionEntity selectById(@Param("id") String id); |
||||
} |
||||
@ -0,0 +1,30 @@
|
||||
package com.mh.user.model; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 研华数据体 |
||||
* @date 2025-01-22 14:47:25 |
||||
*/ |
||||
@Data |
||||
public class SanShiFengDatas<T extends Number> { |
||||
|
||||
/** |
||||
* 对应研华的标签值 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 上报值 |
||||
*/ |
||||
private T value; |
||||
|
||||
// /**
|
||||
// * 质量值
|
||||
// */
|
||||
// private T quality;
|
||||
|
||||
} |
||||
@ -0,0 +1,45 @@
|
||||
package com.mh.user.model; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 研华网关发送接收数据 |
||||
* @date 2025-01-22 14:43:15 |
||||
*/ |
||||
@Data |
||||
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
public class SanShiFengReceiver<T> { |
||||
|
||||
/** |
||||
* 数据集合 |
||||
*/ |
||||
private List<T> datas; |
||||
|
||||
/** |
||||
* 主动上报数据时间(带T类型) |
||||
*/ |
||||
private String sn; |
||||
|
||||
private String plcName; |
||||
|
||||
private String projectName; |
||||
|
||||
private String time; |
||||
|
||||
// 确保在 getDatas() 方法中正确处理泛型类型
|
||||
public List<SanShiFengDatas> getDatas() { |
||||
// 如果是从 JSON 反序列化,使用 TypeReference
|
||||
if (this.datas != null) { |
||||
return (List<SanShiFengDatas>) this.datas; |
||||
} |
||||
return Collections.emptyList(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,39 @@
|
||||
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 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); |
||||
|
||||
CollectionParamsManageEntity selectDeviceInstallByOtherName(String name); |
||||
|
||||
List<HotWaterNowDataDTO> monitorList(String buildingId); |
||||
|
||||
List<HotWaterControlDTO> operateList(String floorId); |
||||
} |
||||
@ -0,0 +1,26 @@
|
||||
package com.mh.user.service; |
||||
|
||||
import com.mh.user.entity.MqttSubscriptionEntity; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description mqtt订阅管理 |
||||
* @date 2025-02-14 13:58:37 |
||||
*/ |
||||
public interface MqttSubscriptionService { |
||||
|
||||
List<MqttSubscriptionEntity> selectMqttSubList(MqttSubscriptionEntity mqttSubscription); |
||||
|
||||
MqttSubscriptionEntity selectMqttSubById(String msId); |
||||
|
||||
int insertMqttSub(MqttSubscriptionEntity mqttSubscription); |
||||
|
||||
int updateMqttSub(MqttSubscriptionEntity mqttSubscription); |
||||
|
||||
int deleteMqttSubByIds(String[] msIds); |
||||
|
||||
} |
||||
@ -0,0 +1,576 @@
|
||||
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.service.CollectionParamsManageService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Collections; |
||||
import java.util.Comparator; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project CHWS |
||||
* @description 采集参数设备实现类 |
||||
* @date 2025-12-10 11:30:54 |
||||
*/ |
||||
@Service |
||||
public class CollectionParamsManageServiceImpl implements CollectionParamsManageService { |
||||
|
||||
private final CollectionParamsManageMapper collectionParamsManageMapper; |
||||
|
||||
public CollectionParamsManageServiceImpl(CollectionParamsManageMapper collectionParamsManageMapper) { |
||||
this.collectionParamsManageMapper = collectionParamsManageMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<HotWaterNowDataDTO> monitorList(String buildingId) { |
||||
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() |
||||
// .peek(vo -> System.out.println(vo.getHiOrderNum()))
|
||||
.collect(Collectors.groupingBy(HotWaterControlListVO::getDeviceType)) |
||||
.entrySet().stream() |
||||
.map(houseEntry -> { |
||||
HotWaterControlDTO dto = new HotWaterControlDTO(); |
||||
dto.setId(houseEntry.getKey()); |
||||
dto.setName(houseEntry.getValue().get(0).getDeviceType()); |
||||
dto.setOrderNum(houseEntry.getValue().get(0).getCtOrderNum()); |
||||
|
||||
List<?> children = houseEntry.getValue().stream() |
||||
.collect(Collectors.groupingBy(HotWaterControlListVO::getDeviceId)) |
||||
.entrySet().stream() |
||||
.map(dlEntry -> { |
||||
List<HotWaterControlListVO> dlItems = dlEntry.getValue(); |
||||
switch (dto.getName()) { |
||||
case "系统": |
||||
HotWaterSystemControlVO vo = new HotWaterSystemControlVO(); |
||||
vo.setId(dlEntry.getKey()); |
||||
if (StringUtils.isBlank(dlItems.get(0).getDeviceName())) { |
||||
// 如果设备名称为空,则使用房间号
|
||||
vo.setName(dto.getName()); |
||||
} else { |
||||
vo.setName(dlItems.get(0).getDeviceName()); |
||||
} |
||||
vo.setOrderNum(dlItems.get(0).getDlOrderNum()); |
||||
// 单独对系统参数
|
||||
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": |
||||
// 回水温度
|
||||
vo.setInTemp(item.getCurValue()); |
||||
vo.setInTempId(item.getCpmId()); |
||||
break; |
||||
case "10": |
||||
// 水箱温度
|
||||
vo.setTankTemp(item.getCurValue()); |
||||
vo.setTankTempId(item.getCpmId()); |
||||
break; |
||||
case "19": |
||||
// 太阳能温度
|
||||
vo.setSolarTemp(item.getCurValue()); |
||||
vo.setSolarTempId(item.getCpmId()); |
||||
break; |
||||
case "15": |
||||
// 时间
|
||||
if ("年_读".equals(item.getOtherName())) { |
||||
vo.setYearTimeRead(item.getCurValue().intValue()); |
||||
vo.setYearTimeReadId(item.getCpmId()); |
||||
} else if ("月_读".equals(item.getOtherName())) { |
||||
vo.setMonthTimeRead(item.getCurValue().intValue()); |
||||
vo.setMonthTimeReadId(item.getCpmId()); |
||||
} else if ("日_读".equals(item.getOtherName())) { |
||||
vo.setDayTimeRead(item.getCurValue().intValue()); |
||||
vo.setDayTimeReadId(item.getCpmId()); |
||||
} else if ("时_读".equals(item.getOtherName())) { |
||||
vo.setHourTimeRead(item.getCurValue().intValue()); |
||||
vo.setHourTimeReadId(item.getCpmId()); |
||||
} else if ("分_读".equals(item.getOtherName())) { |
||||
vo.setMinTimeRead(item.getCurValue().intValue()); |
||||
vo.setMinTimeReadId(item.getCpmId()); |
||||
} else if ("秒_读".equals(item.getOtherName())) { |
||||
vo.setSTimeSet(item.getCurValue().intValue()); |
||||
vo.setSTimeSetId(item.getCpmId()); |
||||
} else if ("年_写".equals(item.getOtherName())) { |
||||
vo.setYearTimeSet(item.getCurValue().intValue()); |
||||
vo.setYearTimeSetId(item.getCpmId()); |
||||
} else if ("月_写".equals(item.getOtherName())) { |
||||
vo.setMonthTimeSet(item.getCurValue().intValue()); |
||||
vo.setMonthTimeSetId(item.getCpmId()); |
||||
} else if ("日_写".equals(item.getOtherName())) { |
||||
vo.setDayTimeSet(item.getCurValue().intValue()); |
||||
vo.setDayTimeSetId(item.getCpmId()); |
||||
} else if ("时_写".equals(item.getOtherName())) { |
||||
vo.setHourTimeSet(item.getCurValue().intValue()); |
||||
vo.setHourTimeSetId(item.getCpmId()); |
||||
} else if ("分_写".equals(item.getOtherName())) { |
||||
vo.setMinTimeSet(item.getCurValue().intValue()); |
||||
vo.setMinTimeSetId(item.getCpmId()); |
||||
} else if ("秒_写".equals(item.getOtherName())) { |
||||
vo.setSTimeSet(item.getCurValue().intValue()); |
||||
vo.setSTimeSetId(item.getCpmId()); |
||||
} |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
return vo; |
||||
case "热泵": |
||||
HotWaterHotPumpControlVO hotPumpVo = new HotWaterHotPumpControlVO(); // 修改类名
|
||||
hotPumpVo.setId(dlEntry.getKey()); |
||||
if (StringUtils.isBlank(dlItems.get(0).getDeviceName())) { |
||||
// 如果设备名称为空,则使用房间号
|
||||
hotPumpVo.setName(dto.getName()); |
||||
} else { |
||||
hotPumpVo.setName(dlItems.get(0).getDeviceName()); |
||||
} |
||||
hotPumpVo.setOrderNum(dlItems.get(0).getDlOrderNum()); |
||||
// 判断只有存在一个故障点,那么当前设备就是故障
|
||||
if (dlItems.stream().anyMatch(item -> ("3".equals(item.getParamTypeId()) && "1".equals(item.getCurValue().toString())))) { |
||||
hotPumpVo.setFault(1); // 去除pump前缀
|
||||
} |
||||
// 单独对系统参数
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "4": |
||||
// 定时开关
|
||||
if (item.getOtherName().contains("12定时_时开1")) { |
||||
hotPumpVo.setOneHourTimeOpenSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneHourTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_时关1")) { |
||||
hotPumpVo.setOneHourTimeCloseSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneHourTimeCloseSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_时开2")) { |
||||
hotPumpVo.setOneHourTimeOpenSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneHourTimeOpenSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_时关2")) { |
||||
hotPumpVo.setOneHourTimeCloseSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneHourTimeCloseSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_时开3")) { |
||||
hotPumpVo.setOneHourTimeOpenSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneHourTimeOpenSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_时关3")) { |
||||
hotPumpVo.setOneHourTimeCloseSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneHourTimeCloseSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_分开1")) { // 新增分钟设置
|
||||
hotPumpVo.setOneMinTimeOpenSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneMinTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_分关1")) { // 新增分钟设置
|
||||
hotPumpVo.setOneMinTimeCloseSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneMinTimeCloseSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_分开2")) { // 新增分钟设置
|
||||
hotPumpVo.setOneMinTimeOpenSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneMinTimeOpenSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_分关2")) { // 新增分钟设置
|
||||
hotPumpVo.setOneMinTimeCloseSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneMinTimeCloseSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_分开3")) { // 新增分钟设置
|
||||
hotPumpVo.setOneMinTimeOpenSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneMinTimeOpenSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("12定时_分关3")) { // 新增分钟设置
|
||||
hotPumpVo.setOneMinTimeCloseSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setOneMinTimeCloseSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_时开1")) { |
||||
hotPumpVo.setTwoHourTimeOpenSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoHourTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_时关1")) { |
||||
hotPumpVo.setTwoHourTimeCloseSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoHourTimeCloseSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_时开2")) { |
||||
hotPumpVo.setTwoHourTimeOpenSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoHourTimeOpenSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_时关2")) { |
||||
hotPumpVo.setTwoHourTimeCloseSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoHourTimeCloseSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_时开3")) { |
||||
hotPumpVo.setTwoHourTimeOpenSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoHourTimeOpenSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_时关3")) { |
||||
hotPumpVo.setTwoHourTimeCloseSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoHourTimeCloseSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_分开1")) { // 新增分钟设置
|
||||
hotPumpVo.setTwoMinTimeOpenSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoMinTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_分关1")) { // 新增分钟设置
|
||||
hotPumpVo.setTwoMinTimeCloseSetOne(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoMinTimeCloseSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_分开2")) { // 新增分钟设置
|
||||
hotPumpVo.setTwoMinTimeOpenSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoMinTimeOpenSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_分关2")) { // 新增分钟设置
|
||||
hotPumpVo.setTwoMinTimeCloseSetTwo(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoMinTimeCloseSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_分开3")) { // 新增分钟设置
|
||||
hotPumpVo.setTwoMinTimeOpenSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoMinTimeOpenSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("34定时_分关3")) { // 新增分钟设置
|
||||
hotPumpVo.setTwoMinTimeCloseSetThree(item.getCurValue().intValue()); |
||||
hotPumpVo.setTwoMinTimeCloseSetThreeId(item.getCpmId()); |
||||
} |
||||
break; |
||||
case "1": |
||||
// 启停控制
|
||||
hotPumpVo.setStartStopControl(item.getCurValue().intValue()); // 去除pump前缀
|
||||
hotPumpVo.setStartStopControlId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
case "2": |
||||
// 运行状态
|
||||
hotPumpVo.setRunState(item.getCurValue().intValue()); // 去除pump前缀
|
||||
hotPumpVo.setRunStateId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
case "10": |
||||
// 水箱温度
|
||||
hotPumpVo.setTankTemp(item.getCurValue()); // 去除pump前缀
|
||||
hotPumpVo.setTankTempId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
case "11": |
||||
// 出水温度
|
||||
hotPumpVo.setOutWaterTemp(item.getCurValue()); // 去除pump前缀
|
||||
hotPumpVo.setOutWaterTempId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
case "12": |
||||
// 回水温度
|
||||
hotPumpVo.setInWaterTemp(item.getCurValue()); // 去除pump前缀
|
||||
hotPumpVo.setInWaterTempId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
case "16": |
||||
// 累计运行时间
|
||||
hotPumpVo.setRunTime(item.getCurValue()); // 去除pump前缀
|
||||
hotPumpVo.setRunTimeId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
case "17": |
||||
// 开机
|
||||
hotPumpVo.setStart(item.getCurValue().toString()); // 去除pump前缀
|
||||
hotPumpVo.setStartId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
case "18": |
||||
// 关机
|
||||
hotPumpVo.setStop(item.getCurValue().toString()); // 去除pump前缀
|
||||
hotPumpVo.setStopId(item.getCpmId()); // 去除pump前缀
|
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
return hotPumpVo; |
||||
case "循环泵": |
||||
HotWaterCircuitPumpControlVO circuitPumpVo = new HotWaterCircuitPumpControlVO(); |
||||
circuitPumpVo.setId(dlEntry.getKey()); |
||||
if (StringUtils.isBlank(dlItems.get(0).getDeviceName())) { |
||||
// 如果设备名称为空,则使用房间号
|
||||
circuitPumpVo.setName(dto.getName()); |
||||
} else { |
||||
circuitPumpVo.setName(dlItems.get(0).getDeviceName()); |
||||
} |
||||
circuitPumpVo.setOrderNum(dlItems.get(0).getDlOrderNum()); |
||||
// 单独对系统参数
|
||||
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": |
||||
// 时控
|
||||
if (item.getOtherName().contains("定时_时开1")) { |
||||
circuitPumpVo.setOneHourTimeOpenSetOne(item.getCurValue().intValue()); |
||||
circuitPumpVo.setOneHourTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_时关1")) { |
||||
circuitPumpVo.setOneHourTimeCloseSetOne(item.getCurValue().intValue()); |
||||
circuitPumpVo.setOneHourTimeCloseSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分开1")) { |
||||
circuitPumpVo.setOneMinTimeOpenSetOne(item.getCurValue().intValue()); |
||||
circuitPumpVo.setOneMinTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分关1")) { |
||||
circuitPumpVo.setOneMinTimeCloseSetOne(item.getCurValue().intValue()); |
||||
circuitPumpVo.setOneMinTimeCloseSetOneId(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; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
return circuitPumpVo; |
||||
case "回水泵": |
||||
HotWaterBackPumpControlVO backPumpVo = new HotWaterBackPumpControlVO(); |
||||
backPumpVo.setId(dlEntry.getKey()); |
||||
if (StringUtils.isBlank(dlItems.get(0).getDeviceName())) { |
||||
// 如果设备名称为空,则使用房间号
|
||||
backPumpVo.setName(dto.getName()); |
||||
} else { |
||||
backPumpVo.setName(dlItems.get(0).getDeviceName()); |
||||
} |
||||
backPumpVo.setOrderNum(dlItems.get(0).getDlOrderNum()); |
||||
// 单独对系统参数
|
||||
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": |
||||
// 时控
|
||||
if (item.getOtherName().contains("定时_时开1")) { |
||||
backPumpVo.setOneHourTimeOpenSetOne(item.getCurValue().intValue()); |
||||
backPumpVo.setOneHourTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_时关1")) { |
||||
backPumpVo.setOneHourTimeCloseSetOne(item.getCurValue().intValue()); |
||||
backPumpVo.setOneHourTimeCloseSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分开1")) { |
||||
backPumpVo.setOneMinTimeOpenSetOne(item.getCurValue().intValue()); |
||||
backPumpVo.setOneMinTimeOpenSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分关1")) { |
||||
backPumpVo.setOneMinTimeCloseSetOne(item.getCurValue().intValue()); |
||||
backPumpVo.setOneMinTimeCloseSetOneId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_时开2")) { |
||||
backPumpVo.setOneHourTimeOpenSetTwo(item.getCurValue().intValue()); |
||||
backPumpVo.setOneHourTimeOpenSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_时关2")) { |
||||
backPumpVo.setOneHourTimeCloseSetTwo(item.getCurValue().intValue()); |
||||
backPumpVo.setOneHourTimeCloseSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分开2")) { |
||||
backPumpVo.setOneMinTimeOpenSetTwo(item.getCurValue().intValue()); |
||||
backPumpVo.setOneMinTimeOpenSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分关2")) { |
||||
backPumpVo.setOneMinTimeCloseSetTwo(item.getCurValue().intValue()); |
||||
backPumpVo.setOneMinTimeCloseSetTwoId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_时开3")) { |
||||
backPumpVo.setOneHourTimeOpenSetThree(item.getCurValue().intValue()); |
||||
backPumpVo.setOneHourTimeOpenSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_时关3")) { |
||||
backPumpVo.setOneHourTimeCloseSetThree(item.getCurValue().intValue()); |
||||
backPumpVo.setOneHourTimeCloseSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分开3")) { |
||||
backPumpVo.setOneMinTimeOpenSetThree(item.getCurValue().intValue()); |
||||
backPumpVo.setOneMinTimeOpenSetThreeId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("定时_分关3")) { |
||||
backPumpVo.setOneMinTimeCloseSetThree(item.getCurValue().intValue()); |
||||
backPumpVo.setOneMinTimeCloseSetThreeId(item.getCpmId()); |
||||
} |
||||
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; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
return backPumpVo; |
||||
case "设备校准": |
||||
HotWaterDeviceCalibrationControlVO deviceCalibrationVo = new HotWaterDeviceCalibrationControlVO(); |
||||
deviceCalibrationVo.setId(dlEntry.getKey()); |
||||
if (StringUtils.isBlank(dlItems.get(0).getDeviceName())) { |
||||
// 如果设备名称为空,则使用房间号
|
||||
deviceCalibrationVo.setName(dto.getName()); |
||||
} else { |
||||
deviceCalibrationVo.setName(dlItems.get(0).getDeviceName()); |
||||
} |
||||
deviceCalibrationVo.setOrderNum(dlItems.get(0).getDlOrderNum()); |
||||
// 单独对系统参数
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "0": |
||||
if (item.getOtherName().contains("工程量上限")) { |
||||
deviceCalibrationVo.setEngineeringMaxValue(item.getCurValue()); |
||||
deviceCalibrationVo.setEngineeringMaxValueId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("工程量下限")) { |
||||
deviceCalibrationVo.setEngineeringMinValue(item.getCurValue()); |
||||
deviceCalibrationVo.setEngineeringMinValueId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("数字量上限")) { |
||||
deviceCalibrationVo.setDigitalMaxValue(item.getCurValue()); |
||||
deviceCalibrationVo.setDigitalMaxValueId(item.getCpmId()); |
||||
} else if (item.getOtherName().contains("数字量下限")) { |
||||
deviceCalibrationVo.setDigitalMinValue(item.getCurValue()); |
||||
deviceCalibrationVo.setDigitalMinValueId(item.getCpmId()); |
||||
} |
||||
break; |
||||
case "9": |
||||
// 校准值
|
||||
deviceCalibrationVo.setCalibrationValue(item.getCurValue()); |
||||
deviceCalibrationVo.setCalibrationValueId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
return deviceCalibrationVo; |
||||
case "电表": |
||||
case "水表": |
||||
HotWaterDeviceControlVO meterVo = new HotWaterDeviceControlVO(); |
||||
meterVo.setId(dlEntry.getKey()); |
||||
if (StringUtils.isBlank(dlItems.get(0).getDeviceName())) { |
||||
meterVo.setName(dto.getName()); |
||||
} else { |
||||
meterVo.setName(dlItems.get(0).getDeviceName()); |
||||
} |
||||
meterVo.setOrderNum(dlItems.get(0).getDlOrderNum()); |
||||
// 单独对系统参数
|
||||
dlItems.forEach(item -> { |
||||
switch (item.getParamTypeId()) { |
||||
case "13": |
||||
meterVo.setTotalReading(item.getCurValue()); |
||||
meterVo.setTotalReadingId(item.getCpmId()); |
||||
break; |
||||
case "14": |
||||
meterVo.setTotalReading(item.getCurValue()); |
||||
meterVo.setTotalReadingId(item.getCpmId()); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
}); |
||||
return meterVo; |
||||
default: |
||||
break; |
||||
} |
||||
return null; |
||||
}) |
||||
.collect(Collectors.toList()); |
||||
dto.setChildren(children); |
||||
return dto; |
||||
}) |
||||
// 添加排序操作
|
||||
.sorted(Comparator.comparingInt(HotWaterControlDTO::getOrderNum)) |
||||
.collect(Collectors.toList()); |
||||
} |
||||
|
||||
@Override |
||||
public CollectionParamsManageEntity selectDeviceInstallByOtherName(String name) { |
||||
return collectionParamsManageMapper.selectDeviceInstallByOtherName(name); |
||||
} |
||||
|
||||
@Override |
||||
public void updateCPMByOtherName(String name, BigDecimal value, String time) { |
||||
try { |
||||
collectionParamsManageMapper.updateCPMByOtherName(name, value, time, "0"); |
||||
} catch (Exception e) { |
||||
collectionParamsManageMapper.updateCPMByOtherName(name, new BigDecimal(0), time, "-1"); |
||||
; |
||||
} |
||||
} |
||||
|
||||
@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; |
||||
} |
||||
} |
||||
@ -0,0 +1,61 @@
|
||||
package com.mh.user.service.impl; |
||||
|
||||
import com.mh.user.entity.MqttSubscriptionEntity; |
||||
import com.mh.user.mapper.MqttSubscriptionMapper; |
||||
import com.mh.user.service.MqttSubscriptionService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description mqtt订阅实现类 |
||||
* @date 2025-02-14 13:59:27 |
||||
*/ |
||||
@Service |
||||
public class MqttSubscriptionServiceImpl implements MqttSubscriptionService { |
||||
|
||||
private final MqttSubscriptionMapper mqttSubscriptionMapper; |
||||
|
||||
@Autowired |
||||
public MqttSubscriptionServiceImpl(MqttSubscriptionMapper mqttSubscriptionMapper) { |
||||
this.mqttSubscriptionMapper = mqttSubscriptionMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<MqttSubscriptionEntity> selectMqttSubList(MqttSubscriptionEntity mqttSubscription) { |
||||
if (mqttSubscription == null) { |
||||
return null; |
||||
} |
||||
return mqttSubscriptionMapper.selectListByTopic(mqttSubscription.getTopic(), mqttSubscription.getStatus()); |
||||
} |
||||
|
||||
@Override |
||||
public MqttSubscriptionEntity selectMqttSubById(String msId) { |
||||
return mqttSubscriptionMapper.selectById(msId); |
||||
} |
||||
|
||||
@Override |
||||
public int insertMqttSub(MqttSubscriptionEntity mqttSubscription) { |
||||
return mqttSubscriptionMapper.insert(mqttSubscription); |
||||
} |
||||
|
||||
@Override |
||||
public int updateMqttSub(MqttSubscriptionEntity mqttSubscription) { |
||||
return mqttSubscriptionMapper.updateByPrimaryKey(mqttSubscription); |
||||
} |
||||
|
||||
@Override |
||||
public int deleteMqttSubByIds(String[] msIds) { |
||||
if (msIds != null && msIds.length > 0) { |
||||
for (String msId : msIds) { |
||||
mqttSubscriptionMapper.deleteByPrimaryKey(msId); |
||||
} |
||||
return msIds.length; |
||||
} |
||||
return 0; |
||||
} |
||||
} |
||||
@ -0,0 +1,99 @@
|
||||
package com.mh.user.service.mqtt.config; |
||||
|
||||
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(1000); |
||||
|
||||
return mqttConnectOptions; |
||||
} |
||||
|
||||
@Bean |
||||
public MqttPahoClientFactory mqttClientFactory() { |
||||
DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory(); |
||||
factory.setConnectionOptions(mqttConnectionOptions()); |
||||
return factory; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,91 @@
|
||||
package com.mh.user.service.mqtt.config; |
||||
|
||||
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.service.mqtt.config; |
||||
|
||||
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.service.mqtt.config; |
||||
|
||||
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; |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,62 @@
|
||||
package com.mh.user.service.mqtt.handler; |
||||
|
||||
import com.mh.user.config.MHConfig; |
||||
import com.mh.user.constants.ChannelName; |
||||
import com.mh.user.constants.TopicEnum; |
||||
import com.mh.user.utils.SpringContextUtils; |
||||
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) SpringContextUtils.getBean(ChannelName.DEFAULT_BOUND));
|
||||
// }
|
||||
// 找到对应的主题消息通道
|
||||
if (topic.contains("/temp")) { |
||||
return Collections.singleton((MessageChannel) SpringContextUtils.getBean(ChannelName.EVENTS_UPLOAD_INBOUND)); |
||||
} else { |
||||
TopicEnum topicEnum = TopicEnum.find(mHConfig.getName() + "/", topic); |
||||
MessageChannel bean = (MessageChannel) SpringContextUtils.getBean(topicEnum.getBeanName()); |
||||
return Collections.singleton(bean); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,49 @@
|
||||
package com.mh.user.service.mqtt.service; |
||||
|
||||
import org.springframework.messaging.MessageHeaders; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 通道处理类 |
||||
* @date 2024-11-05 11:30:26 |
||||
*/ |
||||
public interface IEventsService { |
||||
|
||||
/** |
||||
* 处理主动上报 |
||||
* @param receiver |
||||
* @param headers |
||||
* @return |
||||
*/ |
||||
void handleInboundUpload(byte[] receiver, MessageHeaders headers) throws IOException; |
||||
|
||||
|
||||
/** |
||||
* 处理服务器主动采集上报 |
||||
* @param receiver |
||||
* @param headers |
||||
* @return |
||||
*/ |
||||
void handleInboundCollection(byte[] receiver, MessageHeaders headers) throws IOException; |
||||
|
||||
/** |
||||
* 处理控制上报 |
||||
* @param receiver |
||||
* @param headers |
||||
* @return |
||||
*/ |
||||
void handleInboundControl(byte[] receiver, MessageHeaders headers) throws IOException; |
||||
|
||||
/** |
||||
* 处理发送 |
||||
* @param receiver |
||||
* @param headers |
||||
* @throws IOException |
||||
*/ |
||||
void handleInboundSend(byte[] receiver, MessageHeaders headers) throws IOException; |
||||
|
||||
} |
||||
@ -0,0 +1,36 @@
|
||||
package com.mh.user.service.mqtt.service; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt |
||||
* @description 消息网关 |
||||
* @date 2024-10-30 14:43:55 |
||||
*/ |
||||
//@Component
|
||||
//@Configuration
|
||||
//@MessagingGateway(defaultRequestChannel = ChannelName.OUTBOUND)
|
||||
public interface IMqttGatewayService { |
||||
|
||||
/** |
||||
* 发送消息 |
||||
* @param topic |
||||
* @param payload |
||||
*/ |
||||
void publish(String topic, String payload, int qos); |
||||
|
||||
/** |
||||
* 发送消息 |
||||
* @param topic |
||||
* @param payload |
||||
*/ |
||||
void publish(String topic, byte[] payload); |
||||
|
||||
/** |
||||
* 发送消息并带上qos |
||||
* @param topic |
||||
* @param payload |
||||
* @param qos |
||||
*/ |
||||
void publish(String topic, byte[] payload, int qos); |
||||
} |
||||
@ -0,0 +1,96 @@
|
||||
package com.mh.user.service.mqtt.service; |
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference; |
||||
import com.mh.user.constants.CommonTopicResponse; |
||||
import com.mh.user.constants.ServiceReply; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description Mqtt发送消息 |
||||
* @date 2024-10-29 17:31:40 |
||||
*/ |
||||
public interface IMqttMsgSenderService { |
||||
|
||||
void publish(String topic, String pushMessage); |
||||
|
||||
/** |
||||
* 发布消息 |
||||
* @param topic target |
||||
* @param response message |
||||
*/ |
||||
void publish(String topic, CommonTopicResponse response); |
||||
|
||||
/** |
||||
* 使用qos发布消息 |
||||
* |
||||
* @param topic target |
||||
* @param qos qos |
||||
* @param response message |
||||
*/ |
||||
void publish(String topic, int qos, CommonTopicResponse response); |
||||
|
||||
/** |
||||
* 发送消息并同时接收响应 |
||||
* @param clazz |
||||
* @param topic |
||||
* @param response 通知启动是否成功 |
||||
* @return |
||||
*/ |
||||
<T> T publishWithReply(Class<T> clazz, String topic, CommonTopicResponse response); |
||||
|
||||
/** |
||||
* 发送消息并同时接收响应 |
||||
* @param clazz |
||||
* @param topic |
||||
* @param response |
||||
* @param retryTime |
||||
* @param <T> |
||||
* @return |
||||
*/ |
||||
<T> T publishWithReply(Class<T> clazz, String topic, CommonTopicResponse response, int retryTime); |
||||
|
||||
/** |
||||
* 专门用于发送服务消息 |
||||
* @param clazz The generic class for ServiceReply. |
||||
* @param sn |
||||
* @param method |
||||
* @param data |
||||
* @param bid |
||||
* @param <T> |
||||
* @return |
||||
*/ |
||||
<T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid); |
||||
|
||||
/** |
||||
* 仅用于为服务发送消息,不设置接收到的子类型 |
||||
* @param sn |
||||
* @param method |
||||
* @param data |
||||
* @param bid |
||||
* @return |
||||
*/ |
||||
ServiceReply publishServicesTopic(String sn, String method, Object data, String bid); |
||||
|
||||
/** |
||||
* 专门用于发送服务消息 |
||||
* @param clazz The generic class for ServiceReply. |
||||
* @param sn |
||||
* @param method |
||||
* @param data |
||||
* @param <T> |
||||
* @return |
||||
*/ |
||||
<T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data); |
||||
|
||||
/** |
||||
* 仅用于为服务发送消息,不设置接收到的子类型 |
||||
* @param sn |
||||
* @param method |
||||
* @param data |
||||
* @return |
||||
*/ |
||||
ServiceReply publishServicesTopic(String sn, String method, Object data); |
||||
|
||||
} |
||||
@ -0,0 +1,40 @@
|
||||
package com.mh.user.service.mqtt.service; |
||||
|
||||
import org.springframework.integration.mqtt.support.MqttHeaders; |
||||
import org.springframework.messaging.handler.annotation.Header; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description mqtt订阅主题 |
||||
* @date 2024-10-29 17:29:52 |
||||
*/ |
||||
public interface IMqttTopicService { |
||||
|
||||
/** |
||||
* 订阅主题 |
||||
* @param topic |
||||
*/ |
||||
void subscribe(@Header(MqttHeaders.TOPIC) String topic); |
||||
|
||||
/** |
||||
* 订阅主题并设置qos |
||||
* @param topic |
||||
* @param qos |
||||
*/ |
||||
void subscribe(@Header(MqttHeaders.TOPIC) String topic, int qos); |
||||
|
||||
/** |
||||
* 解绑主题 |
||||
* @param topic |
||||
*/ |
||||
void unsubscribe(@Header(MqttHeaders.TOPIC) String topic); |
||||
|
||||
/** |
||||
* 获取已订阅的主题 |
||||
* @return |
||||
*/ |
||||
String[] getSubscribedTopics(); |
||||
|
||||
} |
||||
@ -0,0 +1,152 @@
|
||||
package com.mh.user.service.mqtt.service.impl; |
||||
|
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.mh.user.constants.ChannelName; |
||||
import com.mh.user.constants.Constant; |
||||
import com.mh.user.entity.CollectionParamsManageEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.factory.Device; |
||||
import com.mh.user.factory.DeviceFactory; |
||||
import com.mh.user.model.SanShiFengDatas; |
||||
import com.mh.user.model.SanShiFengReceiver; |
||||
import com.mh.user.service.CollectionParamsManageService; |
||||
import com.mh.user.service.DeviceInstallService; |
||||
import com.mh.user.service.GatewayManageService; |
||||
import com.mh.user.service.mqtt.service.IEventsService; |
||||
import com.mh.user.strategy.DeviceStrategy; |
||||
import com.mh.user.strategy.DeviceStrategyFactory; |
||||
import io.netty.util.CharsetUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.integration.annotation.ServiceActivator; |
||||
import org.springframework.messaging.MessageHeaders; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.io.IOException; |
||||
import java.math.BigDecimal; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 通道消息处理 |
||||
* @date 2024-11-05 11:42:30 |
||||
*/ |
||||
@Slf4j |
||||
@Service |
||||
public class EventsServiceImpl implements IEventsService { |
||||
|
||||
@Autowired |
||||
private ObjectMapper mapper; |
||||
|
||||
@Autowired |
||||
private GatewayManageService gatewayManageService; |
||||
|
||||
@Autowired |
||||
private CollectionParamsManageService collectionParamManageService; |
||||
|
||||
@Autowired |
||||
private DeviceInstallService deviceInstallService; |
||||
|
||||
@ServiceActivator(inputChannel = ChannelName.EVENTS_UPLOAD_INBOUND) |
||||
@Override |
||||
public void handleInboundUpload(byte[] receiver, MessageHeaders headers) { |
||||
// 获取当前的主题
|
||||
String topic = Objects.requireNonNull(headers.get("mqtt_receivedTopic")).toString(); |
||||
handleInboundData(receiver, topic, "主动上报数据"); |
||||
} |
||||
|
||||
@ServiceActivator(inputChannel = ChannelName.EVENTS_COLLECTION_INBOUND) |
||||
@Override |
||||
public void handleInboundCollection(byte[] receiver, MessageHeaders headers) { |
||||
// 获取当前的主题
|
||||
String topic = Objects.requireNonNull(headers.get("mqtt_receivedTopic")).toString(); |
||||
handleInboundData(receiver, topic, "主动下发采集数据"); |
||||
} |
||||
|
||||
@ServiceActivator(inputChannel = ChannelName.EVENTS_CONTROL_INBOUND) |
||||
@Override |
||||
public void handleInboundControl(byte[] receiver, MessageHeaders headers) { |
||||
// 获取当前的主题
|
||||
String topic = Objects.requireNonNull(headers.get("mqtt_receivedTopic")).toString(); |
||||
handleInboundData(receiver, topic, "控制指令下发"); |
||||
} |
||||
|
||||
@ServiceActivator(inputChannel = ChannelName.EVENTS_SEND_INBOUND) |
||||
@Override |
||||
public void handleInboundSend(byte[] receiver, MessageHeaders headers) throws IOException { |
||||
String sendStr = new String(receiver, CharsetUtil.UTF_8); |
||||
log.info("接收到控制指令下发=>{}", sendStr); |
||||
} |
||||
|
||||
private void handleInboundData(byte[] receiver,String topic, String logMessage) { |
||||
try { |
||||
SanShiFengReceiver datas = new SanShiFengReceiver(); |
||||
datas = mapper.readValue(receiver, SanShiFengReceiver.class); |
||||
log.info("主题:{},类型:{}: ,数据:{}", topic, logMessage, datas.toString()); |
||||
// 开始遍历 数据
|
||||
String sn = datas.getSn(); |
||||
String plcName = datas.getPlcName(); |
||||
String projectName = datas.getProjectName(); |
||||
String time = datas.getTime(); |
||||
// 更新网关设备在线状态
|
||||
gatewayManageService.updateGatewayManageOnlineBySn(sn, 0); |
||||
// 修复类型转换问题
|
||||
List<?> rawDataList = datas.getDatas(); |
||||
for (Object rawData : rawDataList) { |
||||
// 安全地转换对象
|
||||
SanShiFengDatas data = new SanShiFengDatas(); |
||||
if (rawData instanceof SanShiFengDatas) { |
||||
data = (SanShiFengDatas) rawData; |
||||
} else { |
||||
// 如果是 LinkedHashMap,则手动转换
|
||||
JSONObject jsonObject = new JSONObject((HashMap<?, ?>) rawData); |
||||
try { |
||||
data = jsonObject.to(SanShiFengDatas.class); |
||||
} catch (Exception e) { |
||||
log.error("mqtt数据上报异常", e); |
||||
data.setName(jsonObject.getString("name")); |
||||
data.setValue(0); |
||||
} |
||||
} |
||||
// 不使用消息队列,查询属于哪种设备类型,然后通过策略进行数据解析
|
||||
log.info("设备SN:{},PLC名称:{},项目名称:{},时间:{},数据:{}", sn, plcName, projectName, time, data.toString()); |
||||
// 获取点位参数名称
|
||||
String name = data.getName(); |
||||
// 获取点位值
|
||||
BigDecimal value = new BigDecimal(0); |
||||
try { |
||||
value = new BigDecimal(String.valueOf(data.getValue())); |
||||
} catch (Exception e) { |
||||
value = BigDecimal.ZERO; |
||||
} |
||||
// 直接更新collectionParamManage参数值
|
||||
collectionParamManageService.updateCPMByOtherName(name, value, time); |
||||
// 查询device_install表,走之前的逻辑
|
||||
CollectionParamsManageEntity collectionParamsManageEntity = collectionParamManageService.selectDeviceInstallByOtherName(name); |
||||
if (null != collectionParamsManageEntity && collectionParamsManageEntity.getDeviceInstallId() != null) { |
||||
DeviceInstallEntity deviceInstallEntity = deviceInstallService.selectDeviceById(collectionParamsManageEntity.getDeviceInstallId()); |
||||
if (deviceInstallEntity != null) { |
||||
// 开始走策略判断
|
||||
String deviceType = deviceInstallEntity.getDeviceType(); |
||||
Device device = DeviceFactory.createDevice(deviceType); |
||||
DeviceStrategy strategy = DeviceStrategyFactory.createStrategy(deviceType); |
||||
if (null == strategy) { |
||||
continue; |
||||
} |
||||
device.setStrategy(strategy); |
||||
device.analysisMQTTReceiveData(time, deviceInstallEntity.getDeviceAddr(), String.valueOf(value), Constant.READ, deviceInstallEntity, collectionParamsManageEntity); |
||||
} |
||||
} |
||||
} |
||||
} catch (IOException e) { |
||||
log.error("处理数据时发生错误: ", e); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,54 @@
|
||||
package com.mh.user.service.mqtt.service.impl; |
||||
|
||||
import com.mh.user.service.mqtt.service.IMqttGatewayService; |
||||
import org.springframework.beans.factory.annotation.Qualifier; |
||||
import org.springframework.integration.mqtt.support.MqttHeaders; |
||||
import org.springframework.messaging.MessageChannel; |
||||
import org.springframework.messaging.support.MessageBuilder; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project EEMCS |
||||
* @description 网关实现类 |
||||
* @date 2025-02-07 08:44:55 |
||||
*/ |
||||
@Service |
||||
public class MqttGatewayServiceImpl implements IMqttGatewayService { |
||||
|
||||
private final MessageChannel outboundChannel; |
||||
|
||||
public MqttGatewayServiceImpl(@Qualifier("outbound") MessageChannel outboundChannel) { |
||||
this.outboundChannel = outboundChannel; |
||||
} |
||||
|
||||
@Override |
||||
public synchronized void publish(String topic, String payload, int qos) { |
||||
outboundChannel.send( |
||||
MessageBuilder |
||||
.withPayload(payload) |
||||
.setHeader(MqttHeaders.TOPIC, topic) |
||||
.setHeader(MqttHeaders.QOS, qos) |
||||
.build()); |
||||
} |
||||
|
||||
@Override |
||||
public void publish(String topic, byte[] payload) { |
||||
outboundChannel.send( |
||||
MessageBuilder |
||||
.withPayload(payload) |
||||
.setHeader(MqttHeaders.TOPIC, topic) |
||||
.build()); |
||||
} |
||||
|
||||
@Override |
||||
public void publish(String topic, byte[] payload, int qos) { |
||||
outboundChannel.send( |
||||
MessageBuilder |
||||
.withPayload(payload) |
||||
.setHeader(MqttHeaders.TOPIC, topic) |
||||
.setHeader(MqttHeaders.QOS, qos) |
||||
.build()); |
||||
} |
||||
} |
||||
@ -0,0 +1,142 @@
|
||||
package com.mh.user.service.mqtt.service.impl; |
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
import com.fasterxml.jackson.core.type.TypeReference; |
||||
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
import com.mh.user.constants.CommonTopicResponse; |
||||
import com.mh.user.constants.ServiceReply; |
||||
import com.mh.user.constants.TopicConst; |
||||
import com.mh.user.service.mqtt.service.IMqttGatewayService; |
||||
import com.mh.user.service.mqtt.service.IMqttMsgSenderService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
import java.util.Objects; |
||||
import java.util.UUID; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description mqtt不同类型发送消息 |
||||
* @date 2024-10-30 14:30:03 |
||||
*/ |
||||
@Slf4j |
||||
@Service |
||||
public class MqttMsgSenderServiceImpl implements IMqttMsgSenderService { |
||||
|
||||
@Autowired |
||||
private IMqttGatewayService mqttGatewayService; |
||||
|
||||
@Autowired |
||||
private ObjectMapper mapper; |
||||
|
||||
|
||||
/** |
||||
* 发布,默认qos为0,非持久化 |
||||
* |
||||
* @param pushMessage |
||||
* @param topic |
||||
*/ |
||||
@Override |
||||
public void publish(String topic, String pushMessage) { |
||||
synchronized (this) {//注意:这里一定要同步,否则,在多线程publish的情况下,线程会发生死锁,分析见文章最后补充
|
||||
try { |
||||
mqttGatewayService.publish(topic, pushMessage, 0); |
||||
log.info("发送主题:{},消息:{}", topic, pushMessage); |
||||
} catch (Exception e) { |
||||
log.error("发送主题异常:{},消息:{}", topic, pushMessage, e); |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void publish(String topic, CommonTopicResponse response) { |
||||
this.publish(topic, 1, response); |
||||
} |
||||
|
||||
@Override |
||||
public void publish(String topic, int qos, CommonTopicResponse response) { |
||||
try { |
||||
log.info("发送主题:{},消息:{}", topic, response.toString()); |
||||
mqttGatewayService.publish(topic, mapper.writeValueAsBytes(response), qos); |
||||
} catch (JsonProcessingException e) { |
||||
log.error("发送主题:{},消息:{}", topic, response.toString(), e); |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public <T> T publishWithReply(Class<T> clazz, String topic, CommonTopicResponse response) { |
||||
return this.publishWithReply(clazz, topic, response, 2); |
||||
} |
||||
|
||||
@Override |
||||
public <T> T publishWithReply(Class<T> clazz, String topic, CommonTopicResponse response, int retryTime) { |
||||
// AtomicInteger time = new AtomicInteger(0);
|
||||
// // Retry three times
|
||||
// while (time.getAndIncrement() <= retryTime) {
|
||||
// this.publish(topic, response);
|
||||
//
|
||||
// Chan<CommonTopicReceiver<T>> chan = Chan.getInstance();
|
||||
// // If the message is not received in 0.5 seconds then resend it again.
|
||||
// CommonTopicReceiver<T> receiver = chan.get(response.getTid());
|
||||
//
|
||||
// // Need to match tid and bid.
|
||||
// if (Objects.nonNull(receiver) && receiver.getTid().equals(response.getTid()) &&
|
||||
// receiver.getBid().equals(response.getBid())) {
|
||||
// if (clazz.isAssignableFrom(receiver.getData().getClass())) {
|
||||
// return receiver.getData();
|
||||
// }
|
||||
// throw new TypeMismatchException(receiver.getData(), clazz);
|
||||
// }
|
||||
// // It must be guaranteed that the tid and bid of each message are different.
|
||||
// response.setBid(UUID.randomUUID().toString());
|
||||
// response.setTid(UUID.randomUUID().toString());
|
||||
// }
|
||||
// throw new RuntimeException("没有消息接收到");
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data, String bid) { |
||||
String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + sn + TopicConst.SERVICES_SUF; |
||||
ServiceReply reply = this.publishWithReply(ServiceReply.class, topic, |
||||
CommonTopicResponse.builder() |
||||
.tid(UUID.randomUUID().toString()) |
||||
.bid(StringUtils.hasText(bid) ? bid : UUID.randomUUID().toString()) |
||||
.timestamp(System.currentTimeMillis()) |
||||
.method(method) |
||||
.data(Objects.requireNonNull(data, "")) |
||||
.build()); |
||||
if (Objects.isNull(clazz)) { |
||||
return reply; |
||||
} |
||||
// put together in "output"
|
||||
if (Objects.nonNull(reply.getInfo())) { |
||||
reply.setOutput(mapper.convertValue(reply.getInfo(), clazz)); |
||||
} |
||||
if (Objects.nonNull(reply.getOutput())) { |
||||
reply.setOutput(mapper.convertValue(reply.getOutput(), clazz)); |
||||
} |
||||
return reply; |
||||
} |
||||
|
||||
@Override |
||||
public ServiceReply publishServicesTopic(String sn, String method, Object data, String bid) { |
||||
return this.publishServicesTopic(null, sn, method, data, bid); |
||||
} |
||||
|
||||
@Override |
||||
public <T> ServiceReply<T> publishServicesTopic(TypeReference<T> clazz, String sn, String method, Object data) { |
||||
return this.publishServicesTopic(clazz, sn, method, data, null); |
||||
} |
||||
|
||||
@Override |
||||
public ServiceReply publishServicesTopic(String sn, String method, Object data) { |
||||
return this.publishServicesTopic(null, sn, method, data, null); |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
|
||||
package com.mh.user.service.mqtt.service.impl; |
||||
|
||||
import com.mh.user.service.mqtt.service.IMqttTopicService; |
||||
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
/** |
||||
* @author LJF |
||||
* @version 1.0 |
||||
* @project springboot-mqtt-demo |
||||
* @description 订阅主题实现类 |
||||
* @date 2024-10-29 17:36:31 |
||||
*/ |
||||
@Service |
||||
public class MqttTopicServiceImpl implements IMqttTopicService { |
||||
|
||||
@Resource |
||||
private MqttPahoMessageDrivenChannelAdapter adapter; |
||||
|
||||
@Override |
||||
public void subscribe(String topic) { |
||||
adapter.addTopic(topic); |
||||
} |
||||
|
||||
@Override |
||||
public void subscribe(String topic, int qos) { |
||||
adapter.addTopic(topic, qos); |
||||
} |
||||
|
||||
@Override |
||||
public void unsubscribe(String topic) { |
||||
adapter.removeTopic(topic); |
||||
} |
||||
|
||||
@Override |
||||
public String[] getSubscribedTopics() { |
||||
return adapter.getTopic(); |
||||
} |
||||
} |
||||
@ -1,3 +1,6 @@
|
||||
spring: |
||||
profiles: |
||||
active: dev |
||||
mvc: |
||||
pathmatch: |
||||
matching-strategy: ant_path_matcher |
||||
|
||||
Loading…
Reference in new issue