Browse Source

1、添加主机列表基本参数;

dev
mh 3 weeks ago
parent
commit
389faa7110
  1. 12
      user-service/src/main/java/com/mh/user/constants/ChillerParamsEnum.java
  2. 112
      user-service/src/main/java/com/mh/user/controller/ChillersController.java
  3. 4
      user-service/src/main/java/com/mh/user/service/chillers/ChillersService.java
  4. 161
      user-service/src/main/java/com/mh/user/service/chillers/impl/ChillersServiceImpl.java
  5. 10
      user-service/src/main/java/com/mh/user/utils/AnalysisReceiveOrder485.java
  6. 136
      user-service/src/main/java/com/mh/user/vo/HostListVO.java
  7. 72
      user-service/src/test/java/com/mh/user/SysUserTest.java

12
user-service/src/main/java/com/mh/user/constants/ChillerParamsEnum.java

@ -0,0 +1,12 @@
package com.mh.user.constants;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 主机枚举类
* @date 2024-08-28 17:21:39
*/
public enum ChillerParamsEnum {
}

112
user-service/src/main/java/com/mh/user/controller/ChillersController.java

@ -1,18 +1,18 @@
package com.mh.user.controller;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.mh.common.http.HttpResult;
import com.mh.user.dto.DisplayBoxDataDTO;
import com.mh.user.dto.TableInfoDTO;
import com.mh.user.entity.GaugeEntity;
import com.mh.user.entity.HostValue;
import com.mh.user.entity.TableDataEntity;
import com.mh.user.entity.TableInfoEntity;
import com.mh.user.entity.*;
import com.mh.user.service.chillers.ChillersService;
import com.mh.user.service.chillers.DeviceDisplayService;
import com.mh.user.service.chillers.GaugeService;
import com.mh.user.vo.HostListVO;
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;
@ -26,6 +26,7 @@ import java.util.List;
* @throws
*/
@RestController
@RequestMapping("/chillers")
public class ChillersController {
private final ChillersService chillersService;
@ -36,105 +37,12 @@ public class ChillersController {
this.deviceDisplayService = deviceDisplayService;
}
// 查询冷水机组各个部位的状态值
// @GetMapping("/chillers")
/**
* 查询冷水机组进出水温度值等设备数据详情
* @param deviceType
* @param type
* @return
*/
@GetMapping("/charts/getDisplayBoxData")
public HttpResult getDisplayBoxData(@RequestParam(value = "deviceType") String deviceType,
@RequestParam(value = "type") Integer type) {
List<DisplayBoxDataDTO> displayBoxDataDTOS = deviceDisplayService.deviceDisplayBoxData(deviceType, String.valueOf(type));
return HttpResult.ok("success", displayBoxDataDTOS);
}
/**
* 主机监测详情左侧表格数据
* @param deviceName
* @return
*/
@GetMapping("/charts/getHostTableOneData")
public HttpResult queryChillersOneTable(@RequestParam(value = "deviceName") String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
}
/**
* 主机监测详情顶部表格数据
* @param deviceName
* @return
*/
@GetMapping("/charts/getHostTopData")
public HttpResult queryChillersTopTable(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableDataEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryTopData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
}
/**
* 主机监测详情右侧一表格数据
* @param deviceName
* @return
*/
@GetMapping("/charts/getHostTableTwoData")
public HttpResult queryChillersRightTable(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 2));
return HttpResult.ok("success", tableInfoDTO);
@GetMapping("/queryListByProId")
public HttpResult queryChillersByProId(@RequestParam(value = "proId", required = false) String proId,
@RequestParam("systemId") String systemId) {
JSONArray resultJson = chillersService.queryChillersByProId(systemId, proId);
return HttpResult.ok(resultJson);
}
/**
* 主机监测详情右侧二表格数据
* @param deviceName
* @return
*/
@GetMapping("/charts/getHostTableThreeData")
public HttpResult queryChillersRightTable1(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 3));
return HttpResult.ok("success", tableInfoDTO);
}
// 冷却泵、冷冻泵、冷却塔详情页顶部表格数据
@GetMapping("/charts/getPumpOrTowerTopTableData")
public HttpResult getPumpOrTowerTopData(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableInfoEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryLeftAndRightData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
}
// 冷却泵、冷冻泵、冷却塔详情页顶部数据
// @GetMapping("/charts/getPumpOrTowerTopTableData")
@GetMapping("/charts/getPumpOrTowerTopData")
public HttpResult getPumpOrTowerTopTableData(@RequestParam(value = "deviceName", required = true) String deviceName) {
TableInfoDTO<TableDataEntity> tableInfoDTO = new TableInfoDTO<>();
tableInfoDTO.setTableInfo(chillersService.queryTopData(deviceName, 1));
return HttpResult.ok("success", tableInfoDTO);
}
// 获取冷却/冷冻水进出水温度、主机/冷却塔温度
@GetMapping("/operation/getTempValue")
public HttpResult getTempValue(@RequestParam(value = "deviceType", required = true) String deviceType) {
List<HostValue> hostValueList = chillersService.queryTempValue(deviceType);
JSONObject jsonObject = new JSONObject();
jsonObject.put("values", hostValueList);
return HttpResult.ok("success",jsonObject);
}
@Autowired
private GaugeService gaugeService;
// 设备监控页表盘分析图
@GetMapping("/charts/getGaugeData")
public HttpResult getGaugeData(@RequestParam(value = "type") String type, @RequestParam(value = "deviceName") String deviceName) {
GaugeEntity gaugeEntity = gaugeService.getGaugeData(type,deviceName);
return HttpResult.ok("success",gaugeEntity);
}
}

4
user-service/src/main/java/com/mh/user/service/chillers/ChillersService.java

@ -1,9 +1,12 @@
package com.mh.user.service.chillers;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.mh.user.entity.ChillersEntity;
import com.mh.user.entity.HostValue;
import com.mh.user.entity.TableDataEntity;
import com.mh.user.entity.TableInfoEntity;
import com.mh.user.vo.HostListVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -57,4 +60,5 @@ public interface ChillersService {
// 通过DDC地址查询对应的采集参数设备
List<String> queryDDCAddr(String ddcAddr);
JSONArray queryChillersByProId(String systemId, String proId);
}

161
user-service/src/main/java/com/mh/user/service/chillers/impl/ChillersServiceImpl.java

@ -1,17 +1,24 @@
package com.mh.user.service.chillers.impl;
import com.mh.user.entity.ChillersEntity;
import com.mh.user.entity.HostValue;
import com.mh.user.entity.TableDataEntity;
import com.mh.user.entity.TableInfoEntity;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mh.user.entity.*;
import com.mh.user.mapper.DevicesManageMapper;
import com.mh.user.mapper.MeterManageMapper;
import com.mh.user.mapper.ProjectInfoMapper;
import com.mh.user.mapper.chillers.ChillersMapper;
import com.mh.user.service.chillers.ChillersService;
import com.mh.user.utils.DateUtil;
import com.mh.user.utils.TimeDifferenceUtil;
import com.mh.user.vo.HostListVO;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author ljf
@ -31,9 +38,21 @@ public class ChillersServiceImpl implements ChillersService {
double coldWaterInt = 0.00; // 冷却水回水温度 0E
double coldWaterOut = 0.00; // 冷却水出水温度 0F
public ChillersServiceImpl(ChillersMapper chillersMapper, List<HostValue> hostValueList) {
private final DevicesManageMapper devicesManageMapper;
private final MeterManageMapper meterManageMapper;
private final ProjectInfoMapper projectInfoMapper;
public ChillersServiceImpl(ChillersMapper chillersMapper,
List<HostValue> hostValueList,
DevicesManageMapper devicesManageMapper,
MeterManageMapper meterManageMapper, ProjectInfoMapper projectInfoMapper) {
this.chillersMapper = chillersMapper;
this.hostValueList = hostValueList;
this.devicesManageMapper = devicesManageMapper;
this.meterManageMapper = meterManageMapper;
this.projectInfoMapper = projectInfoMapper;
}
@Override
@ -286,4 +305,136 @@ public class ChillersServiceImpl implements ChillersService {
public List<String> queryDDCAddr(String ddcAddr) {
return chillersMapper.queryDDCAddr(ddcAddr);
}
@Override
public JSONArray queryChillersByProId(String systemId, String proId) {
JSONArray resultJson = new JSONArray();
QueryWrapper<DevicesManageEntity> deviceQueryWrapper = new QueryWrapper<>();
if (systemId != null && !systemId.equalsIgnoreCase("")) {
deviceQueryWrapper.eq("system_id", systemId);
}
if (proId != null && !proId.equalsIgnoreCase("")) {
deviceQueryWrapper.eq("project_id", proId);
}
List<DevicesManageEntity> devicesManageEntityList = devicesManageMapper.selectList(deviceQueryWrapper.orderByAsc("id"));
if (devicesManageEntityList != null && !devicesManageEntityList.isEmpty()) {
HostListVO hostListVO = new HostListVO();
// 根据projectId进行分组
Map<Long, List<DevicesManageEntity>> proDevicesMap =
devicesManageEntityList.stream().collect(Collectors.groupingBy(DevicesManageEntity::getProjectId));
// 遍历分组后的数据
for (Map.Entry<Long, List<DevicesManageEntity>> entry : proDevicesMap.entrySet()) {
if (entry.getValue() != null && !entry.getValue().isEmpty()) {
// 根据key(projectId)获取对应的项目名称
String projectName = projectInfoMapper.selectById(entry.getKey()).getProjectName();
JSONObject proJson = new JSONObject();
proJson.put("name", projectName);
proJson.put("value", entry.getKey());
JSONArray children = new JSONArray();
List<DevicesManageEntity> devicesManageEntities = entry.getValue();
for (DevicesManageEntity devicesManageEntity : devicesManageEntities) {
JSONObject deviceJson = new JSONObject();
deviceJson.put("name", devicesManageEntity.getDeviceName());
deviceJson.put("value", devicesManageEntity.getId());
JSONArray mtArray = new JSONArray();
List<MeterManageEntity> meterManageEntities = meterManageMapper.selectList(
new QueryWrapper<MeterManageEntity>()
.eq("device_id", devicesManageEntity.getId())
.orderByAsc("sort"));
if (meterManageEntities != null && !meterManageEntities.isEmpty()) {
matchingChillersData(meterManageEntities, hostListVO);
// 额定制冷量
hostListVO.setRatedRef(String.valueOf(devicesManageEntity.getRatedRefrigerationCapacity()));
// 额定功率
hostListVO.setRatedPower(String.valueOf(devicesManageEntity.getRatedInputPower()));
// 额定COP
hostListVO.setRatedCop(String.valueOf(devicesManageEntity.getRatedCop()));
}
mtArray.add(hostListVO);
deviceJson.put("children", mtArray);
children.add(deviceJson);
}
proJson.put("children", children);
resultJson.add(proJson);
}
}
}
return resultJson;
}
private void matchingChillersData(List<MeterManageEntity> meterManageEntities, HostListVO hostListVO) {
hostListVO.reset();
for (MeterManageEntity meterManageEntity : meterManageEntities) {
// 匹配HostListVO展示给前端
String funCode = meterManageEntity.getFuncCode();
String curValue = String.valueOf(meterManageEntity.getCurValue());
switch (meterManageEntity.getMtCode()) {
case "0001":
if (funCode.equals("1")) {
hostListVO.setRunningStatus(curValue);
}
break;
case "0003":
if (funCode.equals("3")) {
hostListVO.setEnteringTempSet(curValue);
}
break;
case "0005":
if (funCode.equals("3")) {
hostListVO.setEvapLeavingChWTemp(curValue);
}
break;
case "0006":
if (funCode.equals("3")) {
hostListVO.setEvapEnteringChWTemp(curValue);
}
break;
case "0015":
if (funCode.equals("3")) {
hostListVO.setEvapApproach(curValue);
}
break;
case "0009":
if (funCode.equals("3")) {
hostListVO.setCondLeavingChWTemp(curValue);
}
break;
case "0010":
if (funCode.equals("3")) {
hostListVO.setCondEnteringChWTemp(curValue);
}
break;
case "0023":
if (funCode.equals("3")) {
hostListVO.setCondApproach(curValue);
}
break;
case "0139":
if (funCode.equals("3")) {
hostListVO.setRealTimeChillerAmps(curValue);
}
break;
case "0013":
if (funCode.equals("3")) {
hostListVO.setRealTimePower(curValue);
}
break;
case "0014":
if (funCode.equals("3")) {
hostListVO.setRealTimeCop(curValue);
}
break;
case "0122":
if (funCode.equals("3")) {
hostListVO.setRealTimeWarning(curValue);
hostListVO.setRealTimeFault(curValue);
}
break;
default:
break;
}
}
}
}

10
user-service/src/main/java/com/mh/user/utils/AnalysisReceiveOrder485.java

@ -46,7 +46,7 @@ public class AnalysisReceiveOrder485 {
//解析冷量表
public void analysisCloudOrder485(final String dataStr1, final DeviceCodeParamEntity deviceCodeParam) {
threadPoolService.execute(() -> {
// threadPoolService.execute(() -> {
// 去掉空格
String dataStr = dataStr1.replace(" ", "").toUpperCase();
// 检验报文
@ -59,7 +59,7 @@ public class AnalysisReceiveOrder485 {
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) {
//创建SimpleDateFormat对象,指定样式 2019-05-13 22:39:30
Date date = new Date();
String dateStr = "";
String dateStr = sdf1.format(date);;
//保留两位小数处理
DecimalFormat decimalFormat = new DecimalFormat("0.00");
// 表号
@ -75,14 +75,10 @@ public class AnalysisReceiveOrder485 {
DataResultClEntity dataResultCl = new DataResultClEntity();
String registerAddr = deviceCodeParam.getRegisterAddr();
if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:00:30")) {
dateStr = sdf1.format(date);
dateStr = dateStr.substring(0, 17) + "00";
System.out.println("插入时间00" + dateStr);
} else if (ExchangeStringUtil.isInDate(date, "00:00:30", "00:00:59")) {
dateStr = sdf1.format(date);
dateStr = dateStr.substring(0, 17) + "30";
System.out.println("插入时间30" + dateStr);
}
try {
@ -128,7 +124,7 @@ public class AnalysisReceiveOrder485 {
} else {
log.info("冷量计校验失败===>" + dataStr);
}
});
// });
}
public String analysisCloudQueue(QueueParam queueParam) {

136
user-service/src/main/java/com/mh/user/vo/HostListVO.java

@ -0,0 +1,136 @@
package com.mh.user.vo;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* @author LJF
* @version 1.0
* @project mh_esi
* @description 对前端展示的--主机列表
* @date 2024-08-28 11:21:19
*/
@Setter
@Getter
public class HostListVO implements Serializable {
private static final long serialVersionUID = 1L;
private String runningStatus;
/**
* 出水温度设定值
*/
private String enteringTempSet;
/**
* 蒸发器侧进水温度
*/
private String evapLeavingChWTemp;
/**
* 蒸发器侧出水温度
*/
private String evapEnteringChWTemp;
/**
* 蒸发器侧趋近温度
*/
private String evapApproach;
/**
* 冷凝器侧进水温度
*/
private String condLeavingChWTemp;
/**
* 冷凝器侧出水温度
*/
private String condEnteringChWTemp;
/**
* 冷凝器侧趋近温度
*/
private String condApproach;
/**
* 额定制冷量
*/
private String ratedRef;
/**
* 额定功率
*/
private String ratedPower;
/**
* 额定COP
*/
private String ratedCop;
/**
* 实时制冷量
*/
private String realTimeChillerAmps;
/**
* 实时功率
*/
private String realTimePower;
/**
* 实时COP
*/
private String realTimeCop;
/**
* 实时告警
*/
private String realTimeWarning;
/**
* 实时故障
*/
private String realTimeFault;
public void reset() {
this.runningStatus = null;
this.enteringTempSet = null;
this.evapLeavingChWTemp = null;
this.evapEnteringChWTemp = null;
this.evapApproach = null;
this.condLeavingChWTemp = null;
this.condEnteringChWTemp = null;
this.condApproach = null;
this.ratedRef = null;
this.ratedPower = null;
this.ratedCop = null;
this.realTimeChillerAmps = null;
this.realTimePower = null;
this.realTimeCop = null;
this.realTimeWarning = null;
this.realTimeFault = null;
}
@Override
public String toString() {
return "HostListVO{" +
"enteringTempSet='" + enteringTempSet + '\'' +
", evapLeavingChWTemp='" + evapLeavingChWTemp + '\'' +
", evapEnteringChWTemp='" + evapEnteringChWTemp + '\'' +
", evapApproach='" + evapApproach + '\'' +
", condLeavingChWTemp='" + condLeavingChWTemp + '\'' +
", condEnteringChWTemp='" + condEnteringChWTemp + '\'' +
", condApproach='" + condApproach + '\'' +
", ratedRef='" + ratedRef + '\'' +
", ratedPower='" + ratedPower + '\'' +
", ratedCop='" + ratedCop + '\'' +
", realTimeChillerAmps='" + realTimeChillerAmps + '\'' +
", realTimePower='" + realTimePower + '\'' +
", realTimeCop='" + realTimeCop + '\'' +
", realTimeWarning='" + realTimeWarning + '\'' +
", realTimeFault='" + realTimeFault + '\'' +
'}';
}
}

72
user-service/src/test/java/com/mh/user/SysUserTest.java

@ -1,5 +1,6 @@
package com.mh.user;
import com.mh.user.utils.ExchangeStringUtil;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@ -29,37 +30,50 @@ import java.util.List;
*/
public class SysUserTest {
private static final SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static void main(String[] args) throws ParseException, IOException {
// 读取TXT文件中的HTML内容
String htmlContent = readFile("C:/Users/MH/Desktop/getAir.txt");
// 使用Jsoup解析HTML
Document doc = Jsoup.parse(htmlContent);
// 提取所有的img标签
Elements imgElements = doc.select("img");
// 存储img标签的src属性
List<String> imgSrcs = new ArrayList<>();
for (Element img : imgElements) {
if (img.attr("src").startsWith("//")) {
imgSrcs.add("http:" + img.attr("src"));
} else {
imgSrcs.add(img.attr("src"));
}
}
for (int i = 0; i < imgSrcs.size(); i++) {
// 指定要保存的本地文件路径
Path localFilePath = Paths.get("D:/ljf/images/"+i+".jpg");
// 下载图片
try {
downloadImageToFile(imgSrcs.get(i), localFilePath);
} catch (IOException e) {
continue;
}
String dateStr = "";
Date date = new Date();
if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:00:30")) {
dateStr = sdf1.format(date);
dateStr = dateStr.substring(0, 17) + "00";
System.out.println("插入时间00" + dateStr);
} else if (ExchangeStringUtil.isInDate(date, "00:00:30", "00:00:59")) {
dateStr = sdf1.format(date);
dateStr = dateStr.substring(0, 17) + "30";
System.out.println("插入时间30" + dateStr);
}
// // 读取TXT文件中的HTML内容
// String htmlContent = readFile("C:/Users/MH/Desktop/getAir.txt");
//
// // 使用Jsoup解析HTML
// Document doc = Jsoup.parse(htmlContent);
//
// // 提取所有的img标签
// Elements imgElements = doc.select("img");
//
// // 存储img标签的src属性
// List<String> imgSrcs = new ArrayList<>();
// for (Element img : imgElements) {
// if (img.attr("src").startsWith("//")) {
// imgSrcs.add("http:" + img.attr("src"));
// } else {
// imgSrcs.add(img.attr("src"));
// }
// }
// for (int i = 0; i < imgSrcs.size(); i++) {
// // 指定要保存的本地文件路径
// Path localFilePath = Paths.get("D:/ljf/images/"+i+".jpg");
//
// // 下载图片
// try {
// downloadImageToFile(imgSrcs.get(i), localFilePath);
// } catch (IOException e) {
// continue;
// }
// }
}
private static String readFile(String filePath) throws IOException {

Loading…
Cancel
Save