Compare commits
24 Commits
dev_bl_eem
...
dev
| Author | SHA1 | Date |
|---|---|---|
|
|
bde7a2669c | 1 day ago |
|
|
9e0bf9b7ee | 4 weeks ago |
|
|
440eab0f8c | 1 month ago |
|
|
455bc79c5a | 2 months ago |
|
|
364886f4cc | 2 months ago |
|
|
668f8e3fb2 | 2 months ago |
|
|
1150bf4cac | 2 months ago |
|
|
e43244596a | 2 months ago |
|
|
cc19ab5afd | 2 months ago |
|
|
7dd7b9866d | 2 months ago |
|
|
4a00010e3e | 2 months ago |
|
|
a12030c83c | 2 months ago |
|
|
9854414719 | 2 months ago |
|
|
63985b2bd8 | 3 months ago |
|
|
beb4bc866e | 3 months ago |
|
|
837e662c8d | 3 months ago |
|
|
2ceb622eb6 | 3 months ago |
|
|
4fd5c674b5 | 4 months ago |
|
|
1871e06353 | 6 months ago |
|
|
fc98e3bd6d | 10 months ago |
|
|
c83403c4cd | 1 year ago |
|
|
5210bcdd58 | 1 year ago |
|
|
ebabe3d17a | 1 year ago |
|
|
c4eaa3b97b | 1 year ago |
163 changed files with 12184 additions and 318 deletions
@ -0,0 +1,109 @@ |
|||||||
|
package com.mh.web.controller.energy; |
||||||
|
|
||||||
|
import com.mh.common.core.controller.BaseController; |
||||||
|
import com.mh.common.core.domain.entity.WaterLevel; |
||||||
|
import com.mh.common.core.domain.entity.WaterTemp; |
||||||
|
import com.mh.common.core.page.TableDataInfo; |
||||||
|
import com.mh.system.service.energy.IEnergyQueryService; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 生活热水能耗分析 |
||||||
|
* @date 2025-06-18 17:49:49 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/hot_energy") |
||||||
|
public class HotWaterEnergyController extends BaseController { |
||||||
|
|
||||||
|
private final IEnergyQueryService energyQueryService; |
||||||
|
|
||||||
|
public HotWaterEnergyController(IEnergyQueryService iEnergyQueryService) { |
||||||
|
this.energyQueryService = iEnergyQueryService; |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/query") |
||||||
|
public TableDataInfo queryEnergy(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||||
|
@RequestParam(value = "startDate", required = false) String startDate, |
||||||
|
@RequestParam(value = "endDate", required = false) String endDate, |
||||||
|
@RequestParam(value = "type") int type) { |
||||||
|
startPage(); |
||||||
|
List<?> result = energyQueryService.queryEnergyDataList(buildingId, startDate, endDate, type); |
||||||
|
return getDataTable(result); |
||||||
|
} |
||||||
|
|
||||||
|
//查询日月年用量汇总
|
||||||
|
@GetMapping(value = "/energySum") |
||||||
|
public TableDataInfo queryEnergySum(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||||
|
@RequestParam(value = "curDate", required = false) String curDate, |
||||||
|
@RequestParam(value = "type", required = true) Integer type) { |
||||||
|
startPage(); |
||||||
|
List<?> result = energyQueryService.queryEnergyDataSumList(buildingId, curDate, type); |
||||||
|
return getDataTable(result); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 温度变化表 |
||||||
|
* |
||||||
|
* @param buildingId |
||||||
|
* @param curDate |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@GetMapping("/waterTemp") |
||||||
|
public TableDataInfo queryWaterTemp(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||||
|
@RequestParam(value = "curDate", required = false) String curDate) { |
||||||
|
startPage(); |
||||||
|
List<WaterTemp> result = energyQueryService.queryWaterTemp(buildingId, curDate); |
||||||
|
return getDataTable(result); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 水位变化表 |
||||||
|
* |
||||||
|
* @param buildingId |
||||||
|
* @param curDate |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@GetMapping("/waterLevel") |
||||||
|
public TableDataInfo queryWaterLevel(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||||
|
@RequestParam(value = "curDate", required = false) String curDate) { |
||||||
|
startPage(); |
||||||
|
List<WaterLevel> result = energyQueryService.queryWaterLevel(buildingId, curDate); |
||||||
|
return getDataTable(result); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/queryDeviceDatas") |
||||||
|
public TableDataInfo queryDeviceDatas(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||||
|
@RequestParam(value = "startDate", required = false) String startDate, |
||||||
|
@RequestParam(value = "endDate", required = false) String endDate, |
||||||
|
@RequestParam(value = "deviceType", required = false) String deviceType) { |
||||||
|
startPage(); |
||||||
|
List<?> result = energyQueryService.queryDeviceDatas(buildingId, startDate, endDate, deviceType); |
||||||
|
return getDataTable(result); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/analysis/queryYear") //type=1(水),2(电),3(能耗),4(维保)
|
||||||
|
public TableDataInfo queryAnalysisYear(@RequestParam(value = "curDate",required = true) String curDate, |
||||||
|
@RequestParam(value = "buildingId",required = true) String buildingId, |
||||||
|
@RequestParam(value = "type",defaultValue = "3") int type) { |
||||||
|
startPage(); |
||||||
|
List<?> result = energyQueryService.queryAnalysisYear(curDate, buildingId, type); |
||||||
|
return getDataTable(result); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/analysis/queryMonth") //type=1(水),2(电),3(能耗),4(维保),5(使用时间)
|
||||||
|
public TableDataInfo queryAnalysisMonth(@RequestParam(value = "curDate",required = true) String curDate, |
||||||
|
@RequestParam(value = "buildingId",required = true) String buildingId, |
||||||
|
@RequestParam(value = "type",defaultValue = "3") int type) { |
||||||
|
startPage(); |
||||||
|
List<?> result = energyQueryService.queryAnalysisMonth(curDate, buildingId, type); |
||||||
|
return getDataTable(result); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,58 @@ |
|||||||
|
package com.mh.web.controller.energy; |
||||||
|
|
||||||
|
import com.mh.common.core.controller.BaseController; |
||||||
|
import com.mh.common.core.page.PageDomain; |
||||||
|
import com.mh.common.core.page.TableDataInfo; |
||||||
|
import com.mh.common.core.page.TableSupport; |
||||||
|
import com.mh.system.service.energy.IEnergyQueryService; |
||||||
|
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 EEMCS |
||||||
|
* @description 中央热水收益分析 |
||||||
|
* @date 2026-05-13 08:37:12 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/hot_water_revenue") |
||||||
|
public class HowWaterRevenueEnergyController extends BaseController { |
||||||
|
|
||||||
|
private final IEnergyQueryService energyQueryService; |
||||||
|
|
||||||
|
public HowWaterRevenueEnergyController(IEnergyQueryService iEnergyQueryService) { |
||||||
|
this.energyQueryService = iEnergyQueryService; |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping(value = "/energySum") |
||||||
|
public TableDataInfo queryEnergySum(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||||
|
@RequestParam(value = "startDate", required = false) String startDate, |
||||||
|
@RequestParam(value = "endDate", required = false) String endDate, |
||||||
|
@RequestParam(value = "type", required = true) Integer type) { |
||||||
|
startPage(); |
||||||
|
List<?> result = energyQueryService.queryRevenueEnergyDataSumList(buildingId, startDate, endDate, type); |
||||||
|
return getDataTable(result); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/query") |
||||||
|
public TableDataInfo queryEnergy(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||||
|
@RequestParam(value = "startDate", required = false) String startDate, |
||||||
|
@RequestParam(value = "endDate", required = false) String endDate, |
||||||
|
@RequestParam(value = "type") int type) { |
||||||
|
startPage(); |
||||||
|
List<?> result = energyQueryService.queryRevenueEnergyDataList(buildingId, startDate, endDate, type); |
||||||
|
TableDataInfo dataTable = getDataTable(result); |
||||||
|
// 或者总条数数据
|
||||||
|
PageDomain pageDomain = TableSupport.buildPageRequest(); |
||||||
|
pageDomain.setPageNum(0); |
||||||
|
List<?> result1 = energyQueryService.queryRevenueEnergyDataList(buildingId, startDate, endDate, type); |
||||||
|
dataTable.setTotal(result1.size()); |
||||||
|
return dataTable; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,178 @@ |
|||||||
|
package com.mh.web.controller.report; |
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
import com.mh.common.core.controller.BaseController; |
||||||
|
import com.mh.common.core.domain.AjaxResult; |
||||||
|
import com.mh.common.core.domain.dto.BFloorReportHotWaterDTO; |
||||||
|
import com.mh.common.core.domain.dto.ThreeFloorReportHotWaterDTO; |
||||||
|
import com.mh.common.core.domain.entity.FloorInfo; |
||||||
|
import com.mh.common.core.domain.entity.ReportHotWaterParamHis; |
||||||
|
import com.mh.common.core.domain.entity.ReportSysRunParamHis; |
||||||
|
import com.mh.common.core.page.TableDataInfo; |
||||||
|
import com.mh.common.utils.StringUtils; |
||||||
|
import com.mh.common.utils.file.handle.ExcelFillCellMergeHandler; |
||||||
|
import com.mh.common.utils.file.handle.ReportSysParamHandler; |
||||||
|
import com.mh.common.utils.file.handle.RowHeightStyleHandler; |
||||||
|
import com.mh.system.service.report.IReportHotWaterService; |
||||||
|
import com.mh.system.service.space.IFloorInfoService; |
||||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.net.URLEncoder; |
||||||
|
import java.util.List; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project NewZhujiang_Server |
||||||
|
* @description 热泵系统运行参数报表 |
||||||
|
* @date 2024-05-30 08:45:57 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/reportHotWater") |
||||||
|
@Slf4j |
||||||
|
public class ReportHotWaterController extends BaseController { |
||||||
|
|
||||||
|
private final IReportHotWaterService reportHotWaterService; |
||||||
|
|
||||||
|
private final IFloorInfoService floorInfoService; |
||||||
|
|
||||||
|
private ReportHotWaterController(IReportHotWaterService reportHotWaterService, IFloorInfoService floorInfoService) { |
||||||
|
this.reportHotWaterService = reportHotWaterService; |
||||||
|
this.floorInfoService = floorInfoService; |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/list") |
||||||
|
public TableDataInfo list(@RequestBody ReportHotWaterParamHis reportHotWaterParamHis) |
||||||
|
{ |
||||||
|
if (reportHotWaterParamHis.getPageNum() != 0) { |
||||||
|
PageHelper.startPage(reportHotWaterParamHis.getPageNum(), reportHotWaterParamHis.getPageSize()); |
||||||
|
} |
||||||
|
FloorInfo floorInfo = floorInfoService.selectFloorInfoById(reportHotWaterParamHis.getFloorId()); |
||||||
|
if (floorInfo == null) { |
||||||
|
throw new IllegalArgumentException("Floor not found"); |
||||||
|
} else { |
||||||
|
reportHotWaterParamHis.setFloorId(reportHotWaterParamHis.getFloorId() + "_" + floorInfo.getFloorName()); |
||||||
|
} |
||||||
|
List<ReportHotWaterParamHis> list = reportHotWaterService.selectList(reportHotWaterParamHis); |
||||||
|
return getDataTable(list); |
||||||
|
} |
||||||
|
|
||||||
|
@PutMapping("/edit") |
||||||
|
public AjaxResult edit(@RequestBody ReportHotWaterParamHis reportHotWaterParamHis) |
||||||
|
{ |
||||||
|
// FloorInfo floorInfo = floorInfoService.selectFloorInfoById(reportHotWaterParamHis.getFloorId());
|
||||||
|
// if (floorInfo == null) {
|
||||||
|
// throw new IllegalArgumentException("Floor not found");
|
||||||
|
// } else {
|
||||||
|
// reportHotWaterParamHis.setFloorId(reportHotWaterParamHis.getFloorId() + "_" + floorInfo.getFloorName());
|
||||||
|
// }
|
||||||
|
return toAjax(reportHotWaterService.updateRunParams(reportHotWaterParamHis)); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/export") |
||||||
|
public void exportExcel(@RequestBody ReportHotWaterParamHis reportHotWaterParamHis, HttpServletResponse response) { |
||||||
|
// 文件名
|
||||||
|
try { |
||||||
|
String fileName = "热水热泵运行记录表.xlsx"; |
||||||
|
String floorId = reportHotWaterParamHis.getFloorId(); |
||||||
|
FloorInfo floorInfo = floorInfoService.selectFloorInfoById(floorId); |
||||||
|
if (floorInfo == null) { |
||||||
|
throw new IllegalArgumentException("Floor not found"); |
||||||
|
} else { |
||||||
|
floorId = floorId + "_" + floorInfo.getFloorName(); |
||||||
|
reportHotWaterParamHis.setFloorId(floorId); |
||||||
|
} |
||||||
|
String headTitle = "热水热泵运行记录表"; |
||||||
|
if (!StringUtils.isBlank(floorId)) { |
||||||
|
if (floorId.contains("主楼")) { |
||||||
|
fileName = "主楼热水热泵运行记录表.xlsx"; |
||||||
|
headTitle = "主楼热水热泵运行记录表"; |
||||||
|
} else { |
||||||
|
fileName = "贵宾楼热水热泵运行记录表.xlsx"; |
||||||
|
headTitle = "贵宾楼热水热泵运行记录表"; |
||||||
|
} |
||||||
|
} |
||||||
|
// 从数据库获取数据
|
||||||
|
List<ReportHotWaterParamHis> list = reportHotWaterService.selectList(reportHotWaterParamHis); |
||||||
|
if (list != null) { |
||||||
|
// 设置响应格式
|
||||||
|
response.setContentType("application/vdn.ms-excel;charset=utf-8"); |
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileName, "UTF-8") + "\""); |
||||||
|
response.setCharacterEncoding("UTF-8"); |
||||||
|
ExcelFillCellMergeHandler mergePrevCol = new ExcelFillCellMergeHandler(); |
||||||
|
int headSize = 3; |
||||||
|
if (floorId.contains("贵宾楼")) { |
||||||
|
List<BFloorReportHotWaterDTO> infoDTOS = list.stream().map(info -> { |
||||||
|
BFloorReportHotWaterDTO deviceInfoDTO = new BFloorReportHotWaterDTO(); |
||||||
|
BeanUtils.copyProperties(info, deviceInfoDTO); |
||||||
|
// 单独处理启停和运行状态
|
||||||
|
deviceInfoDTO.setStatusRunHotPumpOneStr(info.getStatusRunHotPumpOne() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpOneStr(info.getStatusSwitchHotPumpOne() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpTwoStr(info.getStatusRunHotPumpTwo() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpTwoStr(info.getStatusSwitchHotPumpTwo() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpThreeStr(info.getStatusRunHotPumpThree() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpThreeStr(info.getStatusSwitchHotPumpThree() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpFourStr(info.getStatusRunHotPumpFour() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpFourStr(info.getStatusSwitchHotPumpFour() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpFiveStr(info.getStatusRunHotPumpFive() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpFiveStr(info.getStatusSwitchHotPumpFive() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpSixStr(info.getStatusRunHotPumpSix() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpSixStr(info.getStatusSwitchHotPumpSix() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpSevenStr(info.getStatusRunHotPumpSeven() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpSevenStr(info.getStatusSwitchHotPumpSeven() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpEightStr(info.getStatusRunHotPumpEight() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpEightStr(info.getStatusSwitchHotPumpEight() == 1 ? "开机" : "关机"); |
||||||
|
return deviceInfoDTO; |
||||||
|
}).collect(Collectors.toList()); |
||||||
|
|
||||||
|
// 内容格式
|
||||||
|
EasyExcel.write(response.getOutputStream(), BFloorReportHotWaterDTO.class) |
||||||
|
.registerWriteHandler(new ReportSysParamHandler(headTitle)) |
||||||
|
.registerWriteHandler(mergePrevCol) |
||||||
|
.registerWriteHandler(new RowHeightStyleHandler()) |
||||||
|
.sheet(fileName.replace(".xlsx", "")) |
||||||
|
.doWrite(infoDTOS); |
||||||
|
} else { |
||||||
|
List<ThreeFloorReportHotWaterDTO> infoDTOS = list.stream().map(info -> { |
||||||
|
ThreeFloorReportHotWaterDTO deviceInfoDTO = new ThreeFloorReportHotWaterDTO(); |
||||||
|
BeanUtils.copyProperties(info, deviceInfoDTO); |
||||||
|
// 单独处理启停和运行状态
|
||||||
|
deviceInfoDTO.setStatusRunHotPumpOneStr(info.getStatusRunHotPumpOne() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpOneStr(info.getStatusSwitchHotPumpOne() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunHotPumpTwoStr(info.getStatusRunHotPumpTwo() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusSwitchHotPumpTwoStr(info.getStatusSwitchHotPumpTwo() == 1 ? "开机" : "关机"); |
||||||
|
deviceInfoDTO.setStatusRunCyclePumpOneStr(info.getStatusRunCyclePumpOne() == 1 ? "运行" : "不运行"); |
||||||
|
deviceInfoDTO.setStatusRunCyclePumpTwoStr(info.getStatusRunCyclePumpTwo() == 1 ? "运行" : "不运行"); |
||||||
|
// deviceInfoDTO.setStatusRunHotPumpThreeStr(info.getStatusRunHotPumpThree() == 1 ? "运行" : "不运行");
|
||||||
|
// deviceInfoDTO.setStatusSwitchHotPumpThreeStr(info.getStatusSwitchHotPumpThree() == 1 ? "开机" : "关机");
|
||||||
|
// deviceInfoDTO.setStatusRunHotPumpFourStr(info.getStatusRunHotPumpFour() == 1 ? "运行" : "不运行");
|
||||||
|
// deviceInfoDTO.setStatusSwitchHotPumpFourStr(info.getStatusSwitchHotPumpFour() == 1 ? "开机" : "关机");
|
||||||
|
// deviceInfoDTO.setStatusRunSupplyPumpOneStr(info.getStatusRunSupplyPumpOne() == 1 ? "运行" : "不运行");
|
||||||
|
// deviceInfoDTO.setStatusRunSupplyPumpTwoStr(info.getStatusRunSupplyPumpTwo() == 1 ? "运行" : "不运行");
|
||||||
|
// deviceInfoDTO.setStatusRunSupplyPumpThreeStr(info.getStatusRunSupplyPumpThree() == 1 ? "运行" : "不运行");
|
||||||
|
// deviceInfoDTO.setStatusRunSupplyPumpFourStr(info.getStatusRunSupplyPumpFour() == 1 ? "运行" : "不运行");
|
||||||
|
return deviceInfoDTO; |
||||||
|
}).collect(Collectors.toList()); |
||||||
|
|
||||||
|
// 内容格式
|
||||||
|
EasyExcel.write(response.getOutputStream(), ThreeFloorReportHotWaterDTO.class) |
||||||
|
.registerWriteHandler(new ReportSysParamHandler(headTitle)) |
||||||
|
.registerWriteHandler(mergePrevCol) |
||||||
|
.registerWriteHandler(new RowHeightStyleHandler()) |
||||||
|
.sheet(fileName.replace(".xlsx", "")) |
||||||
|
.doWrite(infoDTOS); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} catch (IOException e) { |
||||||
|
throw new RuntimeException("下载报表异常"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package com.mh.common.config.wechat; |
||||||
|
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.http.client.BufferingClientHttpRequestFactory; |
||||||
|
import org.springframework.http.client.SimpleClientHttpRequestFactory; |
||||||
|
import org.springframework.web.client.RestTemplate; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description restTemplate配置 |
||||||
|
* @date 2025-06-30 14:35:10 |
||||||
|
*/ |
||||||
|
@Configuration |
||||||
|
public class RestTemplateConfig { |
||||||
|
|
||||||
|
// 配置类中定义Bean(全局禁用分块传输)
|
||||||
|
@Bean |
||||||
|
public RestTemplate restTemplate() { |
||||||
|
return new RestTemplateBuilder() |
||||||
|
.requestFactory(() -> new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())) |
||||||
|
.build(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,94 @@ |
|||||||
|
package com.mh.common.config.wechat; |
||||||
|
|
||||||
|
import me.chanjar.weixin.mp.api.WxMpService; |
||||||
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; |
||||||
|
import me.chanjar.weixin.mp.config.WxMpConfigStorage; |
||||||
|
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; |
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.net.URLEncoder; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-04-03 15:42 |
||||||
|
* @Description 微信网页授权信息配置类 |
||||||
|
*/ |
||||||
|
@Component |
||||||
|
@Configuration |
||||||
|
public class WechatMpConfig { |
||||||
|
|
||||||
|
@Value("${wechat.mpAppId}") |
||||||
|
private String mpAppId; |
||||||
|
@Value("${wechat.mpAppSecret}") |
||||||
|
private String mpAppSecret; |
||||||
|
@Value("${wechat.redirectUri}") |
||||||
|
private String redirectUri; |
||||||
|
@Value("${wechat.authorizedUrl}") |
||||||
|
private String authorizedUrl; |
||||||
|
@Value("${wechat.access_token}") |
||||||
|
private String accessToken; |
||||||
|
@Value("${wechat.userinfo}") |
||||||
|
private String userinfo; |
||||||
|
@Value("${wechat.pushUrl}") |
||||||
|
private String pushUrl; |
||||||
|
@Value("${wechat.baseUrl}") |
||||||
|
private String baseUrl; |
||||||
|
|
||||||
|
public String getBaseUrl() { |
||||||
|
return baseUrl; |
||||||
|
} |
||||||
|
|
||||||
|
public void setBaseUrl(String baseUrl) { |
||||||
|
this.baseUrl = baseUrl; |
||||||
|
} |
||||||
|
|
||||||
|
public String getAuthorizedUrl() { |
||||||
|
return authorizedUrl.replace("mpAppId", mpAppId).replace("REDIRECT_URI", URLEncoder.encode(redirectUri)); |
||||||
|
} |
||||||
|
|
||||||
|
public String getAccessTokenUrl() { |
||||||
|
return accessToken.replace("APPID", mpAppId).replace("SECRET", mpAppSecret); |
||||||
|
} |
||||||
|
|
||||||
|
public String getUserInfo(String accessToken, String openId) { |
||||||
|
return userinfo.replace("ACCESS_TOKEN", accessToken).replace("OPENID", openId); |
||||||
|
} |
||||||
|
|
||||||
|
public String getPushMsgUrl(String accessToken) { |
||||||
|
return pushUrl.replace("ACCESS_TOKEN", accessToken); |
||||||
|
} |
||||||
|
|
||||||
|
public String getMpAppId() { |
||||||
|
return mpAppId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getMpAppSecret() { |
||||||
|
return mpAppSecret; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 配置WxMpService所需信息 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean // 此注解指定在Spring容器启动时,就执行该方法并将该方法返回的对象交由Spring容器管理
|
||||||
|
public WxMpService wxMpService() { |
||||||
|
WxMpService wxMpService = new WxMpServiceImpl(); |
||||||
|
// 设置配置信息的存储位置
|
||||||
|
wxMpService.setWxMpConfigStorage(wxMpConfigStorage()); |
||||||
|
|
||||||
|
return wxMpService; |
||||||
|
} |
||||||
|
|
||||||
|
public WxMpConfigStorage wxMpConfigStorage() { |
||||||
|
// 使用这个实现类则表示将配置信息存储在内存中
|
||||||
|
WxMpDefaultConfigImpl wxMpInMemoryConfigStorage = new WxMpDefaultConfigImpl(); |
||||||
|
wxMpInMemoryConfigStorage.setAppId(getMpAppId()); |
||||||
|
wxMpInMemoryConfigStorage.setSecret(getMpAppSecret()); |
||||||
|
|
||||||
|
return wxMpInMemoryConfigStorage; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,62 @@ |
|||||||
|
package com.mh.common.config.wechat; |
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
import java.security.MessageDigest; |
||||||
|
import java.security.NoSuchAlgorithmException; |
||||||
|
import java.util.Base64; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.TreeMap; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author : Rainbow |
||||||
|
* @date : 2024-09-14 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class WechatSignUtil { |
||||||
|
|
||||||
|
/** |
||||||
|
* SHA-1加密 |
||||||
|
* @param params |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String generateSignature(Map<String, String> params) { |
||||||
|
// 使用TreeMap进行自然排序(按照key的ASCII码排序)
|
||||||
|
TreeMap<String, String> sortedParams = new TreeMap<>(params); |
||||||
|
|
||||||
|
// 拼接字符串
|
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
for (Map.Entry<String, String> entry : sortedParams.entrySet()) { |
||||||
|
if (stringBuilder.length() > 0) { |
||||||
|
stringBuilder.append("&"); |
||||||
|
} |
||||||
|
stringBuilder.append(entry.getKey()).append("=").append(entry.getValue()); |
||||||
|
} |
||||||
|
String string1 = stringBuilder.toString(); |
||||||
|
|
||||||
|
// SHA-1加密
|
||||||
|
try { |
||||||
|
// 获取SHA-1实例
|
||||||
|
MessageDigest digest = MessageDigest.getInstance("SHA-1"); |
||||||
|
|
||||||
|
// 将输入字符串转换为字节数组
|
||||||
|
byte[] encodedHash = digest.digest(string1.getBytes()); |
||||||
|
|
||||||
|
// 可选:将字节数组转换为Base64字符串,便于显示和传输
|
||||||
|
String base64Encoded = Base64.getEncoder().encodeToString(encodedHash); |
||||||
|
// log.info("SHA-1 (Base64 Encoded): {}", base64Encoded);
|
||||||
|
|
||||||
|
// 或者,直接以16进制形式输出
|
||||||
|
StringBuilder hexString = new StringBuilder(); |
||||||
|
for (byte b : encodedHash) { |
||||||
|
String hex = Integer.toHexString(0xff & b); |
||||||
|
if(hex.length() == 1) hexString.append('0'); |
||||||
|
hexString.append(hex); |
||||||
|
} |
||||||
|
// log.info("SHA-1 (Hexadecimal): {}", hexString);
|
||||||
|
return hexString.toString(); |
||||||
|
} catch (NoSuchAlgorithmException e) { |
||||||
|
throw new RuntimeException("SHA-1 algorithm not found", e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
package com.mh.common.constant; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description |
||||||
|
* @date 2025-06-18 16:32:56 |
||||||
|
*/ |
||||||
|
public enum EnergyType { |
||||||
|
HOUR("hour"), |
||||||
|
DAY("day"), |
||||||
|
MONTH("month"), |
||||||
|
YEAR("year"); |
||||||
|
|
||||||
|
private final String code; |
||||||
|
|
||||||
|
EnergyType(String code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,338 @@ |
|||||||
|
package com.mh.common.core.domain.dto; |
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||||
|
import com.alibaba.excel.annotation.write.style.*; |
||||||
|
import com.alibaba.excel.enums.poi.BorderStyleEnum; |
||||||
|
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
//import java.math.String;
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project NewZhujiang_Server |
||||||
|
* @description 三楼热水系统参数报表 |
||||||
|
* @date 2024-05-30 11:00:12 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@NoArgsConstructor |
||||||
|
@Accessors(chain = true) |
||||||
|
@HeadRowHeight(25) |
||||||
|
@HeadFontStyle(fontHeightInPoints = 14) |
||||||
|
@ContentFontStyle(fontHeightInPoints = 13) |
||||||
|
@ContentRowHeight(25) |
||||||
|
@ContentStyle( |
||||||
|
horizontalAlignment = HorizontalAlignmentEnum.CENTER, |
||||||
|
borderBottom = BorderStyleEnum.THIN, |
||||||
|
borderLeft = BorderStyleEnum.THIN, |
||||||
|
borderRight = BorderStyleEnum.THIN, |
||||||
|
borderTop = BorderStyleEnum.THIN |
||||||
|
) |
||||||
|
@ColumnWidth(10) |
||||||
|
public class BFloorReportHotWaterDTO { |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前时间 |
||||||
|
*/ |
||||||
|
@ColumnWidth(17) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "时间", "时间"}, index = 0) |
||||||
|
private String curTime; |
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 班次
|
||||||
|
// */
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "班次", "班次"}, index = 1)
|
||||||
|
// private String classes;
|
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "设定温度℃"}, index = 1) |
||||||
|
private BigDecimal tempSetHotPumpOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "实际温度℃"}, index = 2) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "设备开关机"}, index = 3) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpOneStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "设备运行状态"}, index = 4) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpOneStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "设定温度℃"}, index = 5) |
||||||
|
private BigDecimal tempSetHotPumpTwo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "实际温度℃"}, index = 6) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpTwo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "设备开关机"}, index = 7) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpTwoStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "设备运行状态"}, index = 8) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpTwoStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "3号热泵", "设定温度℃"}, index = 9) |
||||||
|
private BigDecimal tempSetHotPumpThree; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "3号热泵", "实际温度℃"}, index = 10) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpThree; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "3号热泵", "设备开关机"}, index = 11) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpThreeStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "3号热泵", "设备运行状态"}, index = 12) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpThreeStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "4号热泵", "设定温度℃"}, index = 13) |
||||||
|
private BigDecimal tempSetHotPumpFour; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "4号热泵", "实际温度℃"}, index = 14) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpFour; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "4号热泵", "设备开关机"}, index = 15) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpFourStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "4号热泵", "设备运行状态"}, index = 16) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpFourStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "5号热泵", "设定温度℃"}, index = 17) |
||||||
|
private BigDecimal tempSetHotPumpFive; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "5号热泵", "实际温度℃"}, index = 18) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpFive; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "5号热泵", "设备开关机"}, index = 19) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpFiveStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "5号热泵", "设备运行状态"}, index = 20) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpFiveStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "6号热泵", "设定温度℃"}, index = 21) |
||||||
|
private BigDecimal tempSetHotPumpSix; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "6号热泵", "实际温度℃"}, index = 22) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpSix; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "6号热泵", "设备开关机"}, index = 23) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpSixStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "6号热泵", "设备运行状态"}, index = 24) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpSixStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "7号热泵", "设定温度℃"}, index = 25) |
||||||
|
private BigDecimal tempSetHotPumpSeven; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "7号热泵", "实际温度℃"}, index = 26) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpSeven; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "7号热泵", "设备开关机"}, index = 27) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpSevenStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "7号热泵", "设备运行状态"}, index = 28) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpSevenStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "8号热泵", "设定温度℃"}, index = 29) |
||||||
|
private BigDecimal tempSetHotPumpEight; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "8号热泵", "实际温度℃"}, index = 30) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpEight; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "8号热泵", "设备开关机"}, index = 31) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpEightStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "8号热泵", "设备运行状态"}, index = 32) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpEightStr; |
||||||
|
|
||||||
|
// // 高区/裙楼设定压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "裙楼变频泵", "设定压力bar"}, index = 9)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presSetSupplyPumpAreaOne;
|
||||||
|
//
|
||||||
|
// // 高区/裙楼实际压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "裙楼变频泵", "实际压力bar"}, index = 10)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presRealSupplyPumpAreaOne;
|
||||||
|
//
|
||||||
|
// // 高区/裙楼1号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "裙楼变频泵", "1号泵运行状态"}, index = 11)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpOneStr;
|
||||||
|
//
|
||||||
|
// // 高区/裙楼2号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "裙楼变频泵", "2号泵运行状态"}, index = 12)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpTwoStr;
|
||||||
|
//
|
||||||
|
// // 中区/中厨设定压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中厨变频泵", "设定压力bar"}, index = 13)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presSetSupplyPumpAreaTwo;
|
||||||
|
//
|
||||||
|
// // 中区/中厨实际压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中厨变频泵", "实际压力bar"}, index = 14)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presRealSupplyPumpAreaTwo;
|
||||||
|
//
|
||||||
|
// // 中区/中厨1号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中厨变频泵", "1号泵运行状态"}, index = 15)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpThreeStr;
|
||||||
|
//
|
||||||
|
// // 中区/中厨2号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中厨变频泵", "2号泵运行状态"}, index = 16)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpFourStr;
|
||||||
|
|
||||||
|
// 贵宾楼液位1(米)
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "水箱液位", "水箱1液位(米)"}, index = 33) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal levelWaterTankOne; |
||||||
|
|
||||||
|
// 主楼液位2(米)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "水箱液位", "水箱2液位(米)"}, index = 34)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal levelWaterTankTwo;
|
||||||
|
|
||||||
|
// 巡查记录人
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "巡查记录人", "巡查记录人"}, index = 34) |
||||||
|
@ColumnWidth(20) |
||||||
|
private String recorder; |
||||||
|
|
||||||
|
// 备注信息
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "备注", "备注"}, index = 35) |
||||||
|
@ColumnWidth(20) |
||||||
|
private String remark; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,68 @@ |
|||||||
|
package com.mh.common.core.domain.dto; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Data; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class DataResultDTO { |
||||||
|
|
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
private String deviceNum; |
||||||
|
|
||||||
|
private String deviceName; |
||||||
|
|
||||||
|
private String deviceCode; |
||||||
|
|
||||||
|
private String deviceType; |
||||||
|
|
||||||
|
private BigDecimal lastValue; |
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date lastTime; |
||||||
|
|
||||||
|
private double curValue; |
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date curTime; |
||||||
|
|
||||||
|
private BigDecimal usedValue; |
||||||
|
|
||||||
|
private int ratio; |
||||||
|
|
||||||
|
private BigDecimal calcValue; |
||||||
|
|
||||||
|
private int grade; |
||||||
|
|
||||||
|
private String registerAddr; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("id", id) |
||||||
|
.append("buildingId", buildingId) |
||||||
|
.append("buildingName", buildingName) |
||||||
|
.append("deviceNum", deviceNum) |
||||||
|
.append("deviceName", deviceName) |
||||||
|
.append("deviceCode", deviceCode) |
||||||
|
.append("deviceType", deviceType) |
||||||
|
.append("lastValue", lastValue) |
||||||
|
.append("lastTime", lastTime) |
||||||
|
.append("curValue", curValue) |
||||||
|
.append("curTime", curTime) |
||||||
|
.append("usedValue", usedValue) |
||||||
|
.append("ratio", ratio) |
||||||
|
.append("calcValue", calcValue) |
||||||
|
.append("grade", grade) |
||||||
|
.append("registerAddr", registerAddr) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,77 @@ |
|||||||
|
package com.mh.common.core.domain.dto; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.StringJoiner; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水收益总的收益情况 |
||||||
|
* @date 2026-05-13 09:33:27 |
||||||
|
*/ |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public class HotWaterRevenueSumDTO { |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间 |
||||||
|
*/ |
||||||
|
private String curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑id |
||||||
|
*/ |
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
// 电表用量
|
||||||
|
private BigDecimal totalUseEleAmount; |
||||||
|
|
||||||
|
// 电量单价
|
||||||
|
private BigDecimal electPrice; |
||||||
|
|
||||||
|
// 用电金额
|
||||||
|
private BigDecimal totalUseEle; |
||||||
|
|
||||||
|
// 水表用量
|
||||||
|
private BigDecimal totalUseWaterAmount; |
||||||
|
|
||||||
|
// 水价
|
||||||
|
private BigDecimal waterPrice; |
||||||
|
|
||||||
|
// 用水金额
|
||||||
|
private BigDecimal totalUseWater; |
||||||
|
|
||||||
|
// 平均电表用量
|
||||||
|
private BigDecimal avgUseEle; |
||||||
|
|
||||||
|
// 平均水表用量
|
||||||
|
private BigDecimal avgUseWater; |
||||||
|
|
||||||
|
// 单耗
|
||||||
|
private BigDecimal unitConsumption; |
||||||
|
|
||||||
|
// 收益总额
|
||||||
|
private BigDecimal totalIncome; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new StringJoiner(", ", HotWaterRevenueSumDTO.class.getSimpleName() + "[", "]") |
||||||
|
.add("curDate='" + curDate + "'") |
||||||
|
.add("buildingId='" + buildingId + "'") |
||||||
|
.add("totalUseEleAmount=" + totalUseEleAmount) |
||||||
|
.add("electPrice=" + electPrice) |
||||||
|
.add("totalUseEle=" + totalUseEle) |
||||||
|
.add("totalUseWaterAmount=" + totalUseWaterAmount) |
||||||
|
.add("waterPrice=" + waterPrice) |
||||||
|
.add("totalUseWater=" + totalUseWater) |
||||||
|
.add("avgUseEle=" + avgUseEle) |
||||||
|
.add("avgUseWater=" + avgUseWater) |
||||||
|
.add("unitConsumption=" + unitConsumption) |
||||||
|
.add("totalIncome=" + totalIncome) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,220 @@ |
|||||||
|
package com.mh.common.core.domain.dto; |
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||||
|
import com.alibaba.excel.annotation.write.style.*; |
||||||
|
import com.alibaba.excel.enums.poi.BorderStyleEnum; |
||||||
|
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
//import java.math.String;
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project NewZhujiang_Server |
||||||
|
* @description 三楼热水系统参数报表 |
||||||
|
* @date 2024-05-30 11:00:12 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@NoArgsConstructor |
||||||
|
@Accessors(chain = true) |
||||||
|
@HeadRowHeight(25) |
||||||
|
@HeadFontStyle(fontHeightInPoints = 14) |
||||||
|
@ContentFontStyle(fontHeightInPoints = 13) |
||||||
|
@ContentRowHeight(25) |
||||||
|
@ContentStyle( |
||||||
|
horizontalAlignment = HorizontalAlignmentEnum.CENTER, |
||||||
|
borderBottom = BorderStyleEnum.THIN, |
||||||
|
borderLeft = BorderStyleEnum.THIN, |
||||||
|
borderRight = BorderStyleEnum.THIN, |
||||||
|
borderTop = BorderStyleEnum.THIN |
||||||
|
) |
||||||
|
@ColumnWidth(10) |
||||||
|
public class ThreeFloorReportHotWaterDTO { |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前时间 |
||||||
|
*/ |
||||||
|
@ColumnWidth(17) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "时间", "时间"}, index = 0) |
||||||
|
private String curTime; |
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 班次
|
||||||
|
// */
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "班次", "班次"}, index = 1)
|
||||||
|
// private String classes;
|
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "设定温度℃"}, index = 1) |
||||||
|
private BigDecimal tempSetHotPumpOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "实际温度℃"}, index = 2) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "设备开关机"}, index = 3) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpOneStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "1号热泵", "设备运行状态"}, index = 4) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpOneStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设定温度℃ |
||||||
|
*/ |
||||||
|
@ColumnWidth(10) |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "设定温度℃"}, index = 5) |
||||||
|
private BigDecimal tempSetHotPumpTwo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实际温度℃ |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "实际温度℃"}, index = 6) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal tempRealHotPumpTwo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备开关机 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "设备开关机"}, index = 7) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusSwitchHotPumpTwoStr; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备运行状态 |
||||||
|
*/ |
||||||
|
@ExcelProperty(value = {"${deviceType}", "2号热泵", "设备运行状态"}, index = 8) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunHotPumpTwoStr; |
||||||
|
|
||||||
|
// // 3号热泵设定温度(℃)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "3号热泵", "设定温度℃"}, index = 9)
|
||||||
|
// private BigDecimal tempSetHotPumpThree;
|
||||||
|
//
|
||||||
|
// // 3号热泵实际温度(℃)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "3号热泵", "实际温度℃"}, index = 10)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal tempRealHotPumpThree;
|
||||||
|
//
|
||||||
|
// // 3号热泵启停状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "3号热泵", "设备开关机"}, index = 11)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusSwitchHotPumpThreeStr;
|
||||||
|
//
|
||||||
|
// // 3号热泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "3号热泵", "设备运行状态"}, index = 12)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunHotPumpThreeStr;
|
||||||
|
//
|
||||||
|
// // 4号热泵设定温度(℃)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "4号热泵", "设定温度℃"}, index = 13)
|
||||||
|
// private BigDecimal tempSetHotPumpFour;
|
||||||
|
//
|
||||||
|
// // 4号热泵实际温度(℃)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "4号热泵", "实际温度℃"}, index = 14)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal tempRealHotPumpFour;
|
||||||
|
//
|
||||||
|
// // 4号热泵启停状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "4号热泵", "设备开关机"}, index = 15)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusSwitchHotPumpFourStr;
|
||||||
|
//
|
||||||
|
// // 4号热泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "4号热泵", "设备运行状态"}, index = 16)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunHotPumpFourStr;
|
||||||
|
//
|
||||||
|
// // 高区/高区设定压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "高区变频泵", "设定压力bar"}, index = 17)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presSetSupplyPumpAreaOne;
|
||||||
|
//
|
||||||
|
// // 高区/高区实际压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "高区变频泵", "实际压力bar"}, index = 18)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presRealSupplyPumpAreaOne;
|
||||||
|
//
|
||||||
|
// // 高区/高区1号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "高区变频泵", "1号泵运行状态"}, index = 19)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpOneStr;
|
||||||
|
//
|
||||||
|
// // 高区/高区2号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "高区变频泵", "2号泵运行状态"}, index = 20)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpTwoStr;
|
||||||
|
//
|
||||||
|
// // 中区/中区设定压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中区变频泵", "设定压力bar"}, index = 21)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presSetSupplyPumpAreaTwo;
|
||||||
|
//
|
||||||
|
// // 中区/中区实际压力(bar)
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中区变频泵", "实际压力bar"}, index = 22)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private BigDecimal presRealSupplyPumpAreaTwo;
|
||||||
|
//
|
||||||
|
// // 中区/中区1号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中区变频泵", "1号泵运行状态"}, index = 23)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpThreeStr;
|
||||||
|
//
|
||||||
|
// // 中区/中区2号泵运行状态
|
||||||
|
// @ExcelProperty(value = {"${deviceType}", "中区变频泵", "2号泵运行状态"}, index = 24)
|
||||||
|
// @ColumnWidth(10)
|
||||||
|
// private String statusRunSupplyPumpFourStr;
|
||||||
|
|
||||||
|
// 主楼与贵宾楼1号循环泵运行状态
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "主楼与贵宾楼循环泵", "1号循环泵运行状态"}, index = 9) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunCyclePumpOneStr; |
||||||
|
|
||||||
|
// 主楼与贵宾楼2号循环泵运行状态
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "主楼与贵宾楼循环泵", "2号循环泵运行状态"}, index = 10) |
||||||
|
@ColumnWidth(10) |
||||||
|
private String statusRunCyclePumpTwoStr; |
||||||
|
|
||||||
|
// 主楼水箱1
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "水箱液位", "水箱1液位(米)"}, index = 11) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal levelWaterTankOne; |
||||||
|
|
||||||
|
// 主楼水箱2
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "水箱液位", "水箱2液位(米)"}, index = 12) |
||||||
|
@ColumnWidth(10) |
||||||
|
private BigDecimal levelWaterTankTwo; |
||||||
|
|
||||||
|
// 巡查记录人
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "巡查记录人", "巡查记录人"}, index = 13) |
||||||
|
@ColumnWidth(20) |
||||||
|
private String recorder; |
||||||
|
|
||||||
|
// 备注信息
|
||||||
|
@ExcelProperty(value = {"${deviceType}", "备注", "备注"}, index = 14) |
||||||
|
@ColumnWidth(20) |
||||||
|
private String remark; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
package com.mh.common.core.domain.dto; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 天气温度历史记录查询 |
||||||
|
* @date 2025-06-16 11:21:48 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class WeatherDataDTO { |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间 |
||||||
|
*/ |
||||||
|
private String weatherDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 日期和星期 |
||||||
|
*/ |
||||||
|
private String dateAndWeek; |
||||||
|
|
||||||
|
/** |
||||||
|
* 最高温度 |
||||||
|
*/ |
||||||
|
private String maxTemp; |
||||||
|
|
||||||
|
/** |
||||||
|
* 最低温度 |
||||||
|
*/ |
||||||
|
private String minTemp; |
||||||
|
|
||||||
|
/** |
||||||
|
* 天气 |
||||||
|
*/ |
||||||
|
private String weatherConditions; |
||||||
|
|
||||||
|
/** |
||||||
|
* 风向 |
||||||
|
*/ |
||||||
|
private String windDirection; |
||||||
|
|
||||||
|
/** |
||||||
|
* 风速 |
||||||
|
*/ |
||||||
|
private String windPower; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("weatherDate", weatherDate) |
||||||
|
.append("dateAndWeek", dateAndWeek) |
||||||
|
.append("maxTemp", maxTemp) |
||||||
|
.append("minTemp", minTemp) |
||||||
|
.append("weatherConditions", weatherConditions) |
||||||
|
.append("windDirection", windDirection) |
||||||
|
.append("windPower", windPower) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class AnalysisMonth { |
||||||
|
|
||||||
|
private Long id; |
||||||
|
private String curDate; |
||||||
|
private String itemType; |
||||||
|
private String day01; |
||||||
|
private String day02; |
||||||
|
private String day03; |
||||||
|
private String day04; |
||||||
|
private String day05; |
||||||
|
private String day06; |
||||||
|
private String day07; |
||||||
|
private String day08; |
||||||
|
private String day09; |
||||||
|
private String day10; |
||||||
|
private String day11; |
||||||
|
private String day12; |
||||||
|
private String day13; |
||||||
|
private String day14; |
||||||
|
private String day15; |
||||||
|
private String day16; |
||||||
|
private String day17; |
||||||
|
private String day18; |
||||||
|
private String day19; |
||||||
|
private String day20; |
||||||
|
private String day21; |
||||||
|
private String day22; |
||||||
|
private String day23; |
||||||
|
private String day24; |
||||||
|
private String day25; |
||||||
|
private String day26; |
||||||
|
private String day27; |
||||||
|
private String day28; |
||||||
|
private String day29; |
||||||
|
private String day30; |
||||||
|
private String day31; |
||||||
|
private String day32; |
||||||
|
private String totalValue; |
||||||
|
private String buildingId; |
||||||
|
private String buildingName; |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class AnalysisYear { |
||||||
|
|
||||||
|
private Long id; |
||||||
|
private String curDate; |
||||||
|
private String itemType; |
||||||
|
private String month01; |
||||||
|
private String month02; |
||||||
|
private String month03; |
||||||
|
private String month04; |
||||||
|
private String month05; |
||||||
|
private String month06; |
||||||
|
private String month07; |
||||||
|
private String month08; |
||||||
|
private String month09; |
||||||
|
private String month10; |
||||||
|
private String month11; |
||||||
|
private String month12; |
||||||
|
private String totalValue; |
||||||
|
private String buildingId; |
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,84 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @date 2025-02-14 09:30:47 |
||||||
|
* @description 设备统计状态表 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class DeviceState { |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前时间 |
||||||
|
*/ |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备数目 |
||||||
|
*/ |
||||||
|
private int deviceNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 电表数目 |
||||||
|
*/ |
||||||
|
private int electNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 水表数目 |
||||||
|
*/ |
||||||
|
private int waterNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 泵数目 |
||||||
|
*/ |
||||||
|
private int pumpNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 压力表数目 |
||||||
|
*/ |
||||||
|
private int pressureNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 在线设备数目 |
||||||
|
*/ |
||||||
|
private int onlineNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 离线设备数目 |
||||||
|
*/ |
||||||
|
private int offlineNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 故障设备数目 |
||||||
|
*/ |
||||||
|
private int faultNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 上次故障数目 |
||||||
|
*/ |
||||||
|
private int lastFaultNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 故障环比 |
||||||
|
*/ |
||||||
|
private String faultP; |
||||||
|
|
||||||
|
/** |
||||||
|
* 热泵正在运行的数目 |
||||||
|
*/ |
||||||
|
private int pumpOnline; |
||||||
|
|
||||||
|
/** |
||||||
|
* 其他设备数目 |
||||||
|
*/ |
||||||
|
private int otherNum; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,70 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水Sum基础类 |
||||||
|
* @date 2026-05-13 09:50:45 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class EnergyBaseSum { |
||||||
|
|
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间 |
||||||
|
*/ |
||||||
|
private String curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑id |
||||||
|
*/ |
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 补水 |
||||||
|
*/ |
||||||
|
private BigDecimal fillWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 补水与昨日比 |
||||||
|
*/ |
||||||
|
private String fillWaterP; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用水 |
||||||
|
*/ |
||||||
|
private BigDecimal waterValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用水与昨日比 |
||||||
|
*/ |
||||||
|
private String waterP; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用电量 |
||||||
|
*/ |
||||||
|
private BigDecimal electValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用电与昨日比 |
||||||
|
*/ |
||||||
|
private String electP; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单耗 |
||||||
|
*/ |
||||||
|
private BigDecimal electWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单耗与昨日比 |
||||||
|
*/ |
||||||
|
private String electWaterP; |
||||||
|
} |
||||||
@ -0,0 +1,89 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水时间能耗实体类 |
||||||
|
* @date 2025-06-18 14:28:30 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("energy_day") |
||||||
|
public class EnergyDay { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间 |
||||||
|
*/ |
||||||
|
private String curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑id |
||||||
|
*/ |
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 产热量 |
||||||
|
*/ |
||||||
|
private BigDecimal hotWaterValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 使用用量 |
||||||
|
*/ |
||||||
|
private BigDecimal useHotWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用电量 |
||||||
|
*/ |
||||||
|
private BigDecimal electValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单耗 |
||||||
|
*/ |
||||||
|
private BigDecimal electWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 入住人数 |
||||||
|
*/ |
||||||
|
private int checkInCount; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用电 |
||||||
|
*/ |
||||||
|
private BigDecimal perElect; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用水 |
||||||
|
*/ |
||||||
|
private BigDecimal perWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新标志 |
||||||
|
*/ |
||||||
|
private String updateFlag; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑名称 |
||||||
|
*/ |
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前电表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal electCurValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前水表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal wtCurValue; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水时间能耗实体类 |
||||||
|
* @date 2025-06-18 14:28:30 |
||||||
|
*/ |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@Data |
||||||
|
@TableName("energy_day_sum") |
||||||
|
public class EnergyDaySum extends EnergyBaseSum { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,220 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水时间能耗实体类 |
||||||
|
* @date 2025-06-18 14:28:30 |
||||||
|
*/ |
||||||
|
@TableName("energy_hour") |
||||||
|
public class EnergyHour { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间 |
||||||
|
*/ |
||||||
|
private String curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑id |
||||||
|
*/ |
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 产热量 |
||||||
|
*/ |
||||||
|
private BigDecimal hotWaterValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 使用用量 |
||||||
|
*/ |
||||||
|
private BigDecimal useHotWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用电量 |
||||||
|
*/ |
||||||
|
private BigDecimal electValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单耗 |
||||||
|
*/ |
||||||
|
private BigDecimal electWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 入住人数 |
||||||
|
*/ |
||||||
|
private int checkInCount; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用电 |
||||||
|
*/ |
||||||
|
private BigDecimal perElect; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用水 |
||||||
|
*/ |
||||||
|
private BigDecimal perWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新标志 |
||||||
|
*/ |
||||||
|
private String updateFlag; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑名称 |
||||||
|
*/ |
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前电表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal electCurValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前水表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal wtCurValue; |
||||||
|
|
||||||
|
public String getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(String id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCurDate() { |
||||||
|
return curDate; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCurDate(String curDate) { |
||||||
|
this.curDate = curDate; |
||||||
|
} |
||||||
|
|
||||||
|
public String getBuildingId() { |
||||||
|
return buildingId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setBuildingId(String buildingId) { |
||||||
|
this.buildingId = buildingId; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getHotWaterValue() { |
||||||
|
return hotWaterValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHotWaterValue(BigDecimal hotWaterValue) { |
||||||
|
this.hotWaterValue = hotWaterValue; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getUseHotWater() { |
||||||
|
return useHotWater; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUseHotWater(BigDecimal useHotWater) { |
||||||
|
this.useHotWater = useHotWater; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getElectValue() { |
||||||
|
return electValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void setElectValue(BigDecimal electValue) { |
||||||
|
this.electValue = electValue; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getElectWater() { |
||||||
|
return electWater; |
||||||
|
} |
||||||
|
|
||||||
|
public void setElectWater(BigDecimal electWater) { |
||||||
|
this.electWater = electWater; |
||||||
|
} |
||||||
|
|
||||||
|
public int getCheckInCount() { |
||||||
|
return checkInCount; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCheckInCount(int checkInCount) { |
||||||
|
this.checkInCount = checkInCount; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getPerElect() { |
||||||
|
return perElect; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPerElect(BigDecimal perElect) { |
||||||
|
this.perElect = perElect; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getPerWater() { |
||||||
|
return perWater; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPerWater(BigDecimal perWater) { |
||||||
|
this.perWater = perWater; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUpdateFlag() { |
||||||
|
return updateFlag; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUpdateFlag(String updateFlag) { |
||||||
|
this.updateFlag = updateFlag; |
||||||
|
} |
||||||
|
|
||||||
|
public String getBuildingName() { |
||||||
|
return buildingName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setBuildingName(String buildingName) { |
||||||
|
this.buildingName = buildingName; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getElectCurValue() { |
||||||
|
return electCurValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void setElectCurValue(BigDecimal electCurValue) { |
||||||
|
this.electCurValue = electCurValue; |
||||||
|
} |
||||||
|
|
||||||
|
public BigDecimal getWtCurValue() { |
||||||
|
return wtCurValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void setWtCurValue(BigDecimal wtCurValue) { |
||||||
|
this.wtCurValue = wtCurValue; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("id", id) |
||||||
|
.append("curDate", curDate) |
||||||
|
.append("buildingId", buildingId) |
||||||
|
.append("hotWaterValue", hotWaterValue) |
||||||
|
.append("useHotWater", useHotWater) |
||||||
|
.append("electValue", electValue) |
||||||
|
.append("electWater", electWater) |
||||||
|
.append("checkInCount", checkInCount) |
||||||
|
.append("perElect", perElect) |
||||||
|
.append("perWater", perWater) |
||||||
|
.append("updateFlag", updateFlag) |
||||||
|
.append("buildingName", buildingName) |
||||||
|
.append("electCurValue", electCurValue) |
||||||
|
.append("wtCurValue", wtCurValue) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,89 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水时间能耗实体类 |
||||||
|
* @date 2025-06-18 14:28:30 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("energy_month") |
||||||
|
public class EnergyMonth { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间 |
||||||
|
*/ |
||||||
|
private String curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑id |
||||||
|
*/ |
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 产热量 |
||||||
|
*/ |
||||||
|
private BigDecimal hotWaterValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 使用用量 |
||||||
|
*/ |
||||||
|
private BigDecimal useHotWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用电量 |
||||||
|
*/ |
||||||
|
private BigDecimal electValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单耗 |
||||||
|
*/ |
||||||
|
private BigDecimal electWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 入住人数 |
||||||
|
*/ |
||||||
|
private int checkInCount; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用电 |
||||||
|
*/ |
||||||
|
private BigDecimal perElect; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用水 |
||||||
|
*/ |
||||||
|
private BigDecimal perWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新标志 |
||||||
|
*/ |
||||||
|
private String updateFlag; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑名称 |
||||||
|
*/ |
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前电表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal electCurValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前水表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal wtCurValue; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水时间能耗实体类 |
||||||
|
* @date 2025-06-18 14:28:30 |
||||||
|
*/ |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@Data |
||||||
|
@TableName("energy_month_sum") |
||||||
|
public class EnergyMonthSum extends EnergyBaseSum { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,89 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水时间能耗实体类 |
||||||
|
* @date 2025-06-18 14:28:30 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("energy_year") |
||||||
|
public class EnergyYear { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间 |
||||||
|
*/ |
||||||
|
private String curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑id |
||||||
|
*/ |
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
/** |
||||||
|
* 产热量 |
||||||
|
*/ |
||||||
|
private BigDecimal hotWaterValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 使用用量 |
||||||
|
*/ |
||||||
|
private BigDecimal useHotWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用电量 |
||||||
|
*/ |
||||||
|
private BigDecimal electValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单耗 |
||||||
|
*/ |
||||||
|
private BigDecimal electWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 入住人数 |
||||||
|
*/ |
||||||
|
private int checkInCount; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用电 |
||||||
|
*/ |
||||||
|
private BigDecimal perElect; |
||||||
|
|
||||||
|
/** |
||||||
|
* 人均用水 |
||||||
|
*/ |
||||||
|
private BigDecimal perWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新标志 |
||||||
|
*/ |
||||||
|
private String updateFlag; |
||||||
|
|
||||||
|
/** |
||||||
|
* 建筑名称 |
||||||
|
*/ |
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前电表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal electCurValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 当前水表读数 |
||||||
|
*/ |
||||||
|
private BigDecimal wtCurValue; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水时间能耗实体类 |
||||||
|
* @date 2025-06-18 14:28:30 |
||||||
|
*/ |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
@Data |
||||||
|
@TableName("energy_month_sum") |
||||||
|
public class EnergyYearSum extends EnergyBaseSum { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,286 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude; |
||||||
|
import com.mh.common.core.domain.BaseEntity; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.time.LocalDate; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.StringJoiner; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 生活热水供水热泵运行情况 |
||||||
|
* @date 2025-10-22 17:40:03 |
||||||
|
*/ |
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
@TableName("report_hot_water_param_his") |
||||||
|
public class ReportHotWaterParamHis extends BaseEntity implements Serializable { |
||||||
|
|
||||||
|
// 主键
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
// 楼层ID
|
||||||
|
private String floorId; |
||||||
|
|
||||||
|
// 记录日期
|
||||||
|
private LocalDate curDate; |
||||||
|
|
||||||
|
// 记录时间(varchar格式)
|
||||||
|
private String curTime; |
||||||
|
|
||||||
|
// 班次
|
||||||
|
private String classes; |
||||||
|
|
||||||
|
// 1号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpOne; |
||||||
|
|
||||||
|
// 1号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpOne; |
||||||
|
|
||||||
|
// 1号热泵启停状态(0-关闭,1-开启)
|
||||||
|
private Integer statusSwitchHotPumpOne; |
||||||
|
|
||||||
|
// 1号热泵运行状态(0-故障,1-正常)
|
||||||
|
private Integer statusRunHotPumpOne; |
||||||
|
|
||||||
|
// 2号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpTwo; |
||||||
|
|
||||||
|
// 2号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpTwo; |
||||||
|
|
||||||
|
// 2号热泵启停状态
|
||||||
|
private Integer statusSwitchHotPumpTwo; |
||||||
|
|
||||||
|
// 2号热泵运行状态
|
||||||
|
private Integer statusRunHotPumpTwo; |
||||||
|
|
||||||
|
// 3号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpThree; |
||||||
|
|
||||||
|
// 3号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpThree; |
||||||
|
|
||||||
|
// 3号热泵启停状态
|
||||||
|
private Integer statusSwitchHotPumpThree; |
||||||
|
|
||||||
|
// 3号热泵运行状态
|
||||||
|
private Integer statusRunHotPumpThree; |
||||||
|
|
||||||
|
// 4号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpFour; |
||||||
|
|
||||||
|
// 4号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpFour; |
||||||
|
|
||||||
|
// 4号热泵启停状态
|
||||||
|
private Integer statusSwitchHotPumpFour; |
||||||
|
|
||||||
|
// 4号热泵运行状态
|
||||||
|
private Integer statusRunHotPumpFour; |
||||||
|
|
||||||
|
// 5号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpFive; |
||||||
|
|
||||||
|
// 5号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpFive; |
||||||
|
|
||||||
|
// 5号热泵启停状态(0-关闭,1-开启)
|
||||||
|
private Integer statusSwitchHotPumpFive; |
||||||
|
|
||||||
|
// 5号热泵运行状态(0-故障,1-正常)
|
||||||
|
private Integer statusRunHotPumpFive; |
||||||
|
|
||||||
|
// 6号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpSix; |
||||||
|
|
||||||
|
// 6号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpSix; |
||||||
|
|
||||||
|
// 6号热泵启停状态
|
||||||
|
private Integer statusSwitchHotPumpSix; |
||||||
|
|
||||||
|
// 6号热泵运行状态
|
||||||
|
private Integer statusRunHotPumpSix; |
||||||
|
|
||||||
|
// 7号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpSeven; |
||||||
|
|
||||||
|
// 7号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpSeven; |
||||||
|
|
||||||
|
// 7号热泵启停状态
|
||||||
|
private Integer statusSwitchHotPumpSeven; |
||||||
|
|
||||||
|
// 7号热泵运行状态
|
||||||
|
private Integer statusRunHotPumpSeven; |
||||||
|
|
||||||
|
// 8号热泵设定温度(℃)
|
||||||
|
private BigDecimal tempSetHotPumpEight; |
||||||
|
|
||||||
|
// 8号热泵实际温度(℃)
|
||||||
|
private BigDecimal tempRealHotPumpEight; |
||||||
|
|
||||||
|
// 8号热泵启停状态
|
||||||
|
private Integer statusSwitchHotPumpEight; |
||||||
|
|
||||||
|
// 8号热泵运行状态
|
||||||
|
private Integer statusRunHotPumpEight; |
||||||
|
|
||||||
|
// 高区/裙楼设定压力(MPa)
|
||||||
|
private BigDecimal presSetSupplyPumpAreaOne; |
||||||
|
|
||||||
|
// 高区/裙楼实际压力(MPa)
|
||||||
|
private BigDecimal presRealSupplyPumpAreaOne; |
||||||
|
|
||||||
|
// 高区/裙楼1号泵运行状态
|
||||||
|
private Integer statusRunSupplyPumpOne; |
||||||
|
|
||||||
|
// 高区/裙楼2号泵运行状态
|
||||||
|
private Integer statusRunSupplyPumpTwo; |
||||||
|
|
||||||
|
// 中区/中厨设定压力(MPa)
|
||||||
|
private BigDecimal presSetSupplyPumpAreaTwo; |
||||||
|
|
||||||
|
// 中区/中厨实际压力(MPa)
|
||||||
|
private BigDecimal presRealSupplyPumpAreaTwo; |
||||||
|
|
||||||
|
// 中区/中厨1号泵运行状态
|
||||||
|
private Integer statusRunSupplyPumpThree; |
||||||
|
|
||||||
|
// 中区/中厨2号泵运行状态
|
||||||
|
private Integer statusRunSupplyPumpFour; |
||||||
|
|
||||||
|
// 高区/裙楼液位(米)
|
||||||
|
private BigDecimal levelWaterTankOne; |
||||||
|
|
||||||
|
// 中区/中厨液位(米)
|
||||||
|
private BigDecimal levelWaterTankTwo; |
||||||
|
|
||||||
|
// 主楼与贵宾楼循环泵1
|
||||||
|
private Integer statusRunCyclePumpOne; |
||||||
|
|
||||||
|
// 主楼与贵宾楼循环泵2
|
||||||
|
private Integer statusRunCyclePumpTwo; |
||||||
|
|
||||||
|
// 巡查记录人
|
||||||
|
private String recorder; |
||||||
|
|
||||||
|
// 备注信息
|
||||||
|
private String remark; |
||||||
|
|
||||||
|
@JsonIgnore |
||||||
|
@TableField(exist = false) |
||||||
|
private String searchValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 请求参数 |
||||||
|
*/ |
||||||
|
@TableField(exist = false) |
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||||
|
private Map<String, Object> params; |
||||||
|
|
||||||
|
/** 创建者 */ |
||||||
|
@JsonIgnore |
||||||
|
@TableField(exist = false) |
||||||
|
private String createBy; |
||||||
|
|
||||||
|
/** 创建时间 */ |
||||||
|
@TableField(exist = false) |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
/** 更新者 */ |
||||||
|
@JsonIgnore |
||||||
|
@TableField(exist = false) |
||||||
|
private String updateBy; |
||||||
|
|
||||||
|
/** 更新时间 */ |
||||||
|
@JsonIgnore |
||||||
|
@TableField(exist = false) |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
/** 更新者 */ |
||||||
|
@TableField(exist = false) |
||||||
|
private int pageNum; |
||||||
|
|
||||||
|
/** 更新者 */ |
||||||
|
@TableField(exist = false) |
||||||
|
private int pageSize; |
||||||
|
|
||||||
|
// 无参构造
|
||||||
|
public ReportHotWaterParamHis() { |
||||||
|
} |
||||||
|
|
||||||
|
// Getter/Setter 方法(此处省略,实际开发中建议使用 Lombok @Data)
|
||||||
|
|
||||||
|
// 业务方法示例:判断热泵1是否正常运行
|
||||||
|
public boolean isHotPump1Normal() { |
||||||
|
return statusRunHotPumpOne != null && statusRunHotPumpOne == 1; |
||||||
|
} |
||||||
|
|
||||||
|
// 业务方法示例:获取当前压力差值(高区)
|
||||||
|
public BigDecimal getHighAreaPressureDiff() { |
||||||
|
return presRealSupplyPumpAreaOne.subtract(presSetSupplyPumpAreaOne); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new StringJoiner(", ", ReportHotWaterParamHis.class.getSimpleName() + "[", "]") |
||||||
|
.add("id='" + id + "'") |
||||||
|
.add("floorId='" + floorId + "'") |
||||||
|
.add("curDate=" + curDate) |
||||||
|
.add("curTime='" + curTime + "'") |
||||||
|
.add("classes='" + classes + "'") |
||||||
|
.add("tempSetHotPumpOne=" + tempSetHotPumpOne) |
||||||
|
.add("tempRealHotPumpOne=" + tempRealHotPumpOne) |
||||||
|
.add("statusSwitchHotPumpOne=" + statusSwitchHotPumpOne) |
||||||
|
.add("statusRunHotPumpOne=" + statusRunHotPumpOne) |
||||||
|
.add("tempSetHotPumpTwo=" + tempSetHotPumpTwo) |
||||||
|
.add("tempRealHotPumpTwo=" + tempRealHotPumpTwo) |
||||||
|
.add("statusSwitchHotPumpTwo=" + statusSwitchHotPumpTwo) |
||||||
|
.add("statusRunHotPumpTwo=" + statusRunHotPumpTwo) |
||||||
|
.add("tempSetHotPumpThree=" + tempSetHotPumpThree) |
||||||
|
.add("tempRealHotPumpThree=" + tempRealHotPumpThree) |
||||||
|
.add("statusSwitchHotPumpThree=" + statusSwitchHotPumpThree) |
||||||
|
.add("statusRunHotPumpThree=" + statusRunHotPumpThree) |
||||||
|
.add("tempSetHotPumpFour=" + tempSetHotPumpFour) |
||||||
|
.add("tempRealHotPumpFour=" + tempRealHotPumpFour) |
||||||
|
.add("statusSwitchHotPumpFour=" + statusSwitchHotPumpFour) |
||||||
|
.add("statusRunHotPumpFour=" + statusRunHotPumpFour) |
||||||
|
.add("presSetSupplyPumpAreaOne=" + presSetSupplyPumpAreaOne) |
||||||
|
.add("presRealSupplyPumpAreaOne=" + presRealSupplyPumpAreaOne) |
||||||
|
.add("statusRunSupplyPumpOne=" + statusRunSupplyPumpOne) |
||||||
|
.add("statusRunSupplyPumpTwo=" + statusRunSupplyPumpTwo) |
||||||
|
.add("presSetSupplyPumpAreaTwo=" + presSetSupplyPumpAreaTwo) |
||||||
|
.add("presRealSupplyPumpAreaTwo=" + presRealSupplyPumpAreaTwo) |
||||||
|
.add("statusRunSupplyPumpThree=" + statusRunSupplyPumpThree) |
||||||
|
.add("statusRunSupplyPumpFour=" + statusRunSupplyPumpFour) |
||||||
|
.add("levelWaterTankOne=" + levelWaterTankOne) |
||||||
|
.add("levelWaterTankTwo=" + levelWaterTankTwo) |
||||||
|
.add("recorder='" + recorder + "'") |
||||||
|
.add("remark='" + remark + "'") |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,310 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||||
|
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude; |
||||||
|
import com.mh.common.core.domain.BaseEntity; |
||||||
|
import lombok.*; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
import org.springframework.data.annotation.Id; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.time.LocalDate; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 系统参数设备运行历史记录 |
||||||
|
* @date 2025-08-12 10:44:36 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("report_sys_run_param_his") |
||||||
|
public class ReportSysRunParamHis extends BaseEntity { |
||||||
|
|
||||||
|
/** |
||||||
|
* 自增主键 |
||||||
|
*/ |
||||||
|
@Id |
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主机id |
||||||
|
*/ |
||||||
|
private String deviceNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 日期 |
||||||
|
*/ |
||||||
|
private LocalDate curDate; |
||||||
|
|
||||||
|
/** |
||||||
|
* 时间(格式建议与数据库存储一致,如 "HH:mm:ss" 或 "yyyy-MM-dd HH:mm:ss") |
||||||
|
*/ |
||||||
|
private String curTime; |
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 班次
|
||||||
|
// */
|
||||||
|
// private String classes;
|
||||||
|
|
||||||
|
/** |
||||||
|
* 冷冻水进水温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempInChillerWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷冻水出水温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempOutChillerWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设计流量%(修正列名,原 "design flow" 含空格) |
||||||
|
*/ |
||||||
|
private BigDecimal designFlow; |
||||||
|
|
||||||
|
/** |
||||||
|
* 蒸发器压力kpa--磁悬浮 |
||||||
|
*/ |
||||||
|
private BigDecimal pressEvapSaturation; |
||||||
|
|
||||||
|
/** |
||||||
|
* 蒸发器饱和温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempEvapSaturation; |
||||||
|
|
||||||
|
/** |
||||||
|
* 蒸发器趋近温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempEvapApproaching; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷却水进水温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempInCoolingWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷却水出水温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempOutCoolingWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷凝器压力kpa--磁悬浮 |
||||||
|
*/ |
||||||
|
private BigDecimal pressCondenserSaturation; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷凝器饱和温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempCondenserSaturation; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷凝器趋近温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempCondenserApproaching; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷冻水设定值℃ |
||||||
|
*/ |
||||||
|
private BigDecimal setChillerWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷水机需求% |
||||||
|
*/ |
||||||
|
private BigDecimal setLoad; |
||||||
|
|
||||||
|
/** |
||||||
|
* 总电流% |
||||||
|
*/ |
||||||
|
private BigDecimal currentTotal; |
||||||
|
|
||||||
|
/** |
||||||
|
* 总输入功率kw |
||||||
|
*/ |
||||||
|
private BigDecimal inputPowerTotal; |
||||||
|
|
||||||
|
/** |
||||||
|
* 压缩比1 |
||||||
|
*/ |
||||||
|
private BigDecimal ratioCompOne; |
||||||
|
|
||||||
|
/** |
||||||
|
* 压缩比1 |
||||||
|
*/ |
||||||
|
private BigDecimal ratioCompTwo; |
||||||
|
|
||||||
|
/** |
||||||
|
* 压缩比1 |
||||||
|
*/ |
||||||
|
private BigDecimal ratioCompThree; |
||||||
|
|
||||||
|
/** |
||||||
|
* 膨胀阀开度% |
||||||
|
*/ |
||||||
|
private BigDecimal openExv; |
||||||
|
|
||||||
|
/** |
||||||
|
* 运行中的压缩机数量 |
||||||
|
*/ |
||||||
|
private Integer runCompNum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷冻水泵频率hz |
||||||
|
*/ |
||||||
|
private BigDecimal frequencyChiller; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷冻水出水压力kpa |
||||||
|
*/ |
||||||
|
private BigDecimal pressOutChillerWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷冻水进水压力kpa |
||||||
|
*/ |
||||||
|
private BigDecimal pressInChillerWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷却水泵频率hz |
||||||
|
*/ |
||||||
|
private BigDecimal frequencyCooling; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷却水出水压力kpa |
||||||
|
*/ |
||||||
|
private BigDecimal pressOutCoolingWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷却水进水压力kpa |
||||||
|
*/ |
||||||
|
private BigDecimal pressInCoolingWater; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷却塔水泵频率hz |
||||||
|
*/ |
||||||
|
private BigDecimal frequencyCoolingTower; |
||||||
|
|
||||||
|
/** |
||||||
|
* 冷却塔运行数量(原注释可能有误,根据列名调整) |
||||||
|
*/ |
||||||
|
private Integer runCoolingTower; |
||||||
|
|
||||||
|
/** |
||||||
|
* 恒压补水罐压力 |
||||||
|
*/ |
||||||
|
private BigDecimal pressConstantWaterTank; |
||||||
|
|
||||||
|
/** |
||||||
|
* 室外温度℃ |
||||||
|
*/ |
||||||
|
private BigDecimal tempOutdoor; |
||||||
|
|
||||||
|
/** |
||||||
|
* 室外湿度% |
||||||
|
*/ |
||||||
|
private BigDecimal humidityOutdoor; |
||||||
|
|
||||||
|
/** |
||||||
|
* 巡查记录人 |
||||||
|
*/ |
||||||
|
private String recorder; |
||||||
|
|
||||||
|
/** |
||||||
|
* 备注 |
||||||
|
*/ |
||||||
|
private String remark; |
||||||
|
|
||||||
|
@JsonIgnore |
||||||
|
@TableField(exist = false) |
||||||
|
private String searchValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* 请求参数 |
||||||
|
*/ |
||||||
|
@TableField(exist = false) |
||||||
|
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
||||||
|
private Map<String, Object> params; |
||||||
|
|
||||||
|
/** 创建者 */ |
||||||
|
@TableField(exist = false) |
||||||
|
private String createBy; |
||||||
|
|
||||||
|
/** 创建时间 */ |
||||||
|
@TableField(exist = false) |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
/** 更新者 */ |
||||||
|
@TableField(exist = false) |
||||||
|
private String updateBy; |
||||||
|
|
||||||
|
/** 更新时间 */ |
||||||
|
@TableField(exist = false) |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
/** 更新者 */ |
||||||
|
@TableField(exist = false) |
||||||
|
private int pageNum; |
||||||
|
|
||||||
|
/** 更新者 */ |
||||||
|
@TableField(exist = false) |
||||||
|
private int pageSize; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("id", id) |
||||||
|
.append("deviceNum", deviceNum) |
||||||
|
.append("curDate", curDate) |
||||||
|
.append("curTime", curTime) |
||||||
|
.append("tempInChillerWater", tempInChillerWater) |
||||||
|
.append("tempOutChillerWater", tempOutChillerWater) |
||||||
|
.append("designFlow", designFlow) |
||||||
|
.append("pressEvapSaturation", pressEvapSaturation) |
||||||
|
.append("tempEvapSaturation", tempEvapSaturation) |
||||||
|
.append("tempEvapApproaching", tempEvapApproaching) |
||||||
|
.append("tempInCoolingWater", tempInCoolingWater) |
||||||
|
.append("tempOutCoolingWater", tempOutCoolingWater) |
||||||
|
.append("pressCondenserSaturation", pressCondenserSaturation) |
||||||
|
.append("tempCondenserSaturation", tempCondenserSaturation) |
||||||
|
.append("tempCondenserApproaching", tempCondenserApproaching) |
||||||
|
.append("setChillerWater", setChillerWater) |
||||||
|
.append("setLoad", setLoad) |
||||||
|
.append("currentTotal", currentTotal) |
||||||
|
.append("inputPowerTotal", inputPowerTotal) |
||||||
|
.append("ratioCompOne", ratioCompOne) |
||||||
|
.append("ratioCompTwo", ratioCompTwo) |
||||||
|
.append("ratioCompThree", ratioCompThree) |
||||||
|
.append("openExv", openExv) |
||||||
|
.append("runCompNum", runCompNum) |
||||||
|
.append("frequencyChiller", frequencyChiller) |
||||||
|
.append("pressOutChillerWater", pressOutChillerWater) |
||||||
|
.append("pressInChillerWater", pressInChillerWater) |
||||||
|
.append("frequencyCooling", frequencyCooling) |
||||||
|
.append("pressOutCoolingWater", pressOutCoolingWater) |
||||||
|
.append("pressInCoolingWater", pressInCoolingWater) |
||||||
|
.append("frequencyCoolingTower", frequencyCoolingTower) |
||||||
|
.append("runCoolingTower", runCoolingTower) |
||||||
|
.append("pressConstantWaterTank", pressConstantWaterTank) |
||||||
|
.append("tempOutdoor", tempOutdoor) |
||||||
|
.append("humidityOutdoor", humidityOutdoor) |
||||||
|
.append("recorder", recorder) |
||||||
|
.append("remark", remark) |
||||||
|
.append("searchValue", searchValue) |
||||||
|
.append("params", params) |
||||||
|
.append("createBy", createBy) |
||||||
|
.append("createTime", createTime) |
||||||
|
.append("updateBy", updateBy) |
||||||
|
.append("updateTime", updateTime) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,117 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Data; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水液位 |
||||||
|
* @date 2025-06-19 16:18:12 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("water_level") |
||||||
|
public class WaterLevel { |
||||||
|
|
||||||
|
private String id; |
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date curDate; |
||||||
|
|
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
private String deviceNum; |
||||||
|
|
||||||
|
private String deviceName; |
||||||
|
|
||||||
|
private String temp00; |
||||||
|
|
||||||
|
private String temp01; |
||||||
|
|
||||||
|
private String temp02; |
||||||
|
|
||||||
|
private String temp03; |
||||||
|
|
||||||
|
private String temp04; |
||||||
|
|
||||||
|
private String temp05; |
||||||
|
|
||||||
|
private String temp06; |
||||||
|
|
||||||
|
private String temp07; |
||||||
|
|
||||||
|
private String temp08; |
||||||
|
|
||||||
|
private String temp09; |
||||||
|
|
||||||
|
private String temp10; |
||||||
|
|
||||||
|
private String temp11; |
||||||
|
|
||||||
|
private String temp12; |
||||||
|
|
||||||
|
private String temp13; |
||||||
|
|
||||||
|
private String temp14; |
||||||
|
|
||||||
|
private String temp15; |
||||||
|
|
||||||
|
private String temp16; |
||||||
|
|
||||||
|
private String temp17; |
||||||
|
|
||||||
|
private String temp18; |
||||||
|
|
||||||
|
private String temp19; |
||||||
|
|
||||||
|
private String temp20; |
||||||
|
|
||||||
|
private String temp21; |
||||||
|
|
||||||
|
private String temp22; |
||||||
|
|
||||||
|
private String temp23; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("id", id) |
||||||
|
.append("curDate", curDate) |
||||||
|
.append("buildingId", buildingId) |
||||||
|
.append("buildingName", buildingName) |
||||||
|
.append("deviceNum", deviceNum) |
||||||
|
.append("deviceName", deviceName) |
||||||
|
.append("temp00", temp00) |
||||||
|
.append("temp01", temp01) |
||||||
|
.append("temp02", temp02) |
||||||
|
.append("temp03", temp03) |
||||||
|
.append("temp04", temp04) |
||||||
|
.append("temp05", temp05) |
||||||
|
.append("temp06", temp06) |
||||||
|
.append("temp07", temp07) |
||||||
|
.append("temp08", temp08) |
||||||
|
.append("temp09", temp09) |
||||||
|
.append("temp10", temp10) |
||||||
|
.append("temp11", temp11) |
||||||
|
.append("temp12", temp12) |
||||||
|
.append("temp13", temp13) |
||||||
|
.append("temp14", temp14) |
||||||
|
.append("temp15", temp15) |
||||||
|
.append("temp16", temp16) |
||||||
|
.append("temp17", temp17) |
||||||
|
.append("temp18", temp18) |
||||||
|
.append("temp19", temp19) |
||||||
|
.append("temp20", temp20) |
||||||
|
.append("temp21", temp21) |
||||||
|
.append("temp22", temp22) |
||||||
|
.append("temp23", temp23) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,117 @@ |
|||||||
|
package com.mh.common.core.domain.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Data; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 热水温度 |
||||||
|
* @date 2025-06-19 16:18:12 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("water_temp") |
||||||
|
public class WaterTemp { |
||||||
|
|
||||||
|
private String id; |
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private Date curDate; |
||||||
|
|
||||||
|
private String buildingId; |
||||||
|
|
||||||
|
private String buildingName; |
||||||
|
|
||||||
|
private String deviceNum; |
||||||
|
|
||||||
|
private String deviceName; |
||||||
|
|
||||||
|
private String temp00; |
||||||
|
|
||||||
|
private String temp01; |
||||||
|
|
||||||
|
private String temp02; |
||||||
|
|
||||||
|
private String temp03; |
||||||
|
|
||||||
|
private String temp04; |
||||||
|
|
||||||
|
private String temp05; |
||||||
|
|
||||||
|
private String temp06; |
||||||
|
|
||||||
|
private String temp07; |
||||||
|
|
||||||
|
private String temp08; |
||||||
|
|
||||||
|
private String temp09; |
||||||
|
|
||||||
|
private String temp10; |
||||||
|
|
||||||
|
private String temp11; |
||||||
|
|
||||||
|
private String temp12; |
||||||
|
|
||||||
|
private String temp13; |
||||||
|
|
||||||
|
private String temp14; |
||||||
|
|
||||||
|
private String temp15; |
||||||
|
|
||||||
|
private String temp16; |
||||||
|
|
||||||
|
private String temp17; |
||||||
|
|
||||||
|
private String temp18; |
||||||
|
|
||||||
|
private String temp19; |
||||||
|
|
||||||
|
private String temp20; |
||||||
|
|
||||||
|
private String temp21; |
||||||
|
|
||||||
|
private String temp22; |
||||||
|
|
||||||
|
private String temp23; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("id", id) |
||||||
|
.append("curDate", curDate) |
||||||
|
.append("buildingId", buildingId) |
||||||
|
.append("buildingName", buildingName) |
||||||
|
.append("deviceNum", deviceNum) |
||||||
|
.append("deviceName", deviceName) |
||||||
|
.append("temp00", temp00) |
||||||
|
.append("temp01", temp01) |
||||||
|
.append("temp02", temp02) |
||||||
|
.append("temp03", temp03) |
||||||
|
.append("temp04", temp04) |
||||||
|
.append("temp05", temp05) |
||||||
|
.append("temp06", temp06) |
||||||
|
.append("temp07", temp07) |
||||||
|
.append("temp08", temp08) |
||||||
|
.append("temp09", temp09) |
||||||
|
.append("temp10", temp10) |
||||||
|
.append("temp11", temp11) |
||||||
|
.append("temp12", temp12) |
||||||
|
.append("temp13", temp13) |
||||||
|
.append("temp14", temp14) |
||||||
|
.append("temp15", temp15) |
||||||
|
.append("temp16", temp16) |
||||||
|
.append("temp17", temp17) |
||||||
|
.append("temp18", temp18) |
||||||
|
.append("temp19", temp19) |
||||||
|
.append("temp20", temp20) |
||||||
|
.append("temp21", temp21) |
||||||
|
.append("temp22", temp22) |
||||||
|
.append("temp23", temp23) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 10:59 |
||||||
|
* @Description |
||||||
|
*/ |
||||||
|
public class First { |
||||||
|
public String value; |
||||||
|
public String color; |
||||||
|
|
||||||
|
public First() { |
||||||
|
} |
||||||
|
|
||||||
|
public First(String value, String color) { |
||||||
|
this.value = value; |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public void setValue(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getColor() { |
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
public void setColor(String color) { |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 10:59 |
||||||
|
* @Description |
||||||
|
*/ |
||||||
|
public class Key1 { |
||||||
|
public String value; |
||||||
|
public String color; |
||||||
|
|
||||||
|
public Key1() { |
||||||
|
} |
||||||
|
|
||||||
|
public Key1(String value, String color) { |
||||||
|
this.value = value; |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public void setValue(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getColor() { |
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
public void setColor(String color) { |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 10:59 |
||||||
|
* @Description |
||||||
|
*/ |
||||||
|
public class Key2 { |
||||||
|
|
||||||
|
public String value; |
||||||
|
public String color; |
||||||
|
|
||||||
|
public Key2() { |
||||||
|
} |
||||||
|
|
||||||
|
public Key2(String value, String color) { |
||||||
|
this.value = value; |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public void setValue(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getColor() { |
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
public void setColor(String color) { |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 11:00 |
||||||
|
* @Description |
||||||
|
*/ |
||||||
|
public class Key3 { |
||||||
|
|
||||||
|
public String value; |
||||||
|
public String color; |
||||||
|
|
||||||
|
public Key3() { |
||||||
|
} |
||||||
|
|
||||||
|
public Key3(String value, String color) { |
||||||
|
this.value = value; |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public void setValue(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getColor() { |
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
public void setColor(String color) { |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 11:00 |
||||||
|
* @Description |
||||||
|
*/ |
||||||
|
public class Key4 { |
||||||
|
|
||||||
|
public String value; |
||||||
|
public String color; |
||||||
|
|
||||||
|
public Key4() { |
||||||
|
} |
||||||
|
|
||||||
|
public Key4(String value, String color) { |
||||||
|
this.value = value; |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public void setValue(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getColor() { |
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
public void setColor(String color) { |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 11:00 |
||||||
|
* @Description |
||||||
|
*/ |
||||||
|
public class Key5 { |
||||||
|
|
||||||
|
public String value; |
||||||
|
public String color; |
||||||
|
|
||||||
|
public Key5() { |
||||||
|
} |
||||||
|
|
||||||
|
public Key5(String value, String color) { |
||||||
|
this.value = value; |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public void setValue(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getColor() { |
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
public void setColor(String color) { |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,115 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 10:58 |
||||||
|
* @Description 推送消息实体类 |
||||||
|
*/ |
||||||
|
public class PushMsgEntity { |
||||||
|
public String touser; //接收人
|
||||||
|
public String templateId; //微信提供模板id
|
||||||
|
public String url; //消息推送消息url
|
||||||
|
public First first; //消息头消息
|
||||||
|
public Key1 key1; |
||||||
|
public Key2 key2; |
||||||
|
public Key3 key3; |
||||||
|
public Key4 key4; |
||||||
|
public Key5 key5; |
||||||
|
public Remark remark; |
||||||
|
|
||||||
|
public String getTouser() { |
||||||
|
return touser; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTouser(String touser) { |
||||||
|
this.touser = touser; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTemplateId() { |
||||||
|
return templateId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTemplateId(String templateId) { |
||||||
|
this.templateId = templateId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUrl() { |
||||||
|
return url; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUrl(String url) { |
||||||
|
this.url = url; |
||||||
|
} |
||||||
|
|
||||||
|
public First getFirst() { |
||||||
|
return first; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFirst(First first) { |
||||||
|
this.first = first; |
||||||
|
} |
||||||
|
|
||||||
|
public Key1 getKey1() { |
||||||
|
return key1; |
||||||
|
} |
||||||
|
|
||||||
|
public void setKey1(Key1 key1) { |
||||||
|
this.key1 = key1; |
||||||
|
} |
||||||
|
|
||||||
|
public Key2 getKey2() { |
||||||
|
return key2; |
||||||
|
} |
||||||
|
|
||||||
|
public void setKey2(Key2 key2) { |
||||||
|
this.key2 = key2; |
||||||
|
} |
||||||
|
|
||||||
|
public Key3 getKey3() { |
||||||
|
return key3; |
||||||
|
} |
||||||
|
|
||||||
|
public void setKey3(Key3 key3) { |
||||||
|
this.key3 = key3; |
||||||
|
} |
||||||
|
|
||||||
|
public Key4 getKey4() { |
||||||
|
return key4; |
||||||
|
} |
||||||
|
|
||||||
|
public void setKey4(Key4 key4) { |
||||||
|
this.key4 = key4; |
||||||
|
} |
||||||
|
|
||||||
|
public Key5 getKey5() { |
||||||
|
return key5; |
||||||
|
} |
||||||
|
|
||||||
|
public void setKey5(Key5 key5) { |
||||||
|
this.key5 = key5; |
||||||
|
} |
||||||
|
|
||||||
|
public Remark getRemark() { |
||||||
|
return remark; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRemark(Remark remark) { |
||||||
|
this.remark = remark; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "PushMsgEntity{" + |
||||||
|
"touser='" + touser + '\'' + |
||||||
|
", templateId='" + templateId + '\'' + |
||||||
|
", url='" + url + '\'' + |
||||||
|
", first=" + first + |
||||||
|
", key1=" + key1 + |
||||||
|
", key2=" + key2 + |
||||||
|
", key3=" + key3 + |
||||||
|
", key4=" + key4 + |
||||||
|
", key5=" + key5 + |
||||||
|
", remark=" + remark + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,36 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author chison |
||||||
|
* @date 2020-09-14 15:47 |
||||||
|
* @Description |
||||||
|
*/ |
||||||
|
public class Remark { |
||||||
|
|
||||||
|
public String value; |
||||||
|
public String color; |
||||||
|
|
||||||
|
public Remark() { |
||||||
|
} |
||||||
|
|
||||||
|
public Remark(String value, String color) { |
||||||
|
this.value = value; |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
|
||||||
|
public String getValue() { |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
public void setValue(String value) { |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public String getColor() { |
||||||
|
return color; |
||||||
|
} |
||||||
|
|
||||||
|
public void setColor(String color) { |
||||||
|
this.color = color; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,70 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 微信模板 |
||||||
|
* @date 2025-06-27 11:43:54 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("wechat_template") |
||||||
|
public class WechatTemplate { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String templateId; |
||||||
|
|
||||||
|
private String templateName; |
||||||
|
|
||||||
|
private String title; |
||||||
|
|
||||||
|
private String content1; |
||||||
|
|
||||||
|
private String content2; |
||||||
|
|
||||||
|
private String content3; |
||||||
|
|
||||||
|
private String content4; |
||||||
|
|
||||||
|
private String content5; |
||||||
|
|
||||||
|
private String remark; |
||||||
|
|
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 0:正常 1:不使用 |
||||||
|
*/ |
||||||
|
private int grade; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("id", id) |
||||||
|
.append("templateId", templateId) |
||||||
|
.append("templateName", templateName) |
||||||
|
.append("title", title) |
||||||
|
.append("content1", content1) |
||||||
|
.append("content2", content2) |
||||||
|
.append("content3", content3) |
||||||
|
.append("content4", content4) |
||||||
|
.append("content5", content5) |
||||||
|
.append("remark", remark) |
||||||
|
.append("createTime", createTime) |
||||||
|
.append("updateTime", updateTime) |
||||||
|
.append("grade", grade) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,52 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import lombok.Data; |
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 微信模板 |
||||||
|
* @date 2025-06-27 11:43:54 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@TableName("wechat_template_project") |
||||||
|
public class WechatTemplateProject { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private Long templateId; |
||||||
|
|
||||||
|
private Long projectId; |
||||||
|
|
||||||
|
private Long wechatUserId; |
||||||
|
|
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 0:正常 1:不使用 |
||||||
|
*/ |
||||||
|
private int grade; |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return new ToStringBuilder(this) |
||||||
|
.append("id", id) |
||||||
|
.append("templateId", templateId) |
||||||
|
.append("projectId", projectId) |
||||||
|
.append("wechatUserId", wechatUserId) |
||||||
|
.append("createTime", createTime) |
||||||
|
.append("updateTime", updateTime) |
||||||
|
.append("grade", grade) |
||||||
|
.toString(); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,172 @@ |
|||||||
|
package com.mh.common.core.domain.wechat; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project mh_esi |
||||||
|
* @description 微信用户实体类 |
||||||
|
* @date 2024-11-27 16:58:55 |
||||||
|
*/ |
||||||
|
@TableName("wechat_user_info") |
||||||
|
public class WechatUserInfo { |
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO) |
||||||
|
private Long id; |
||||||
|
|
||||||
|
private String userName; |
||||||
|
|
||||||
|
private String telNum; |
||||||
|
|
||||||
|
private String openId; |
||||||
|
|
||||||
|
private String nickName; |
||||||
|
|
||||||
|
private int sex; |
||||||
|
|
||||||
|
private String province; |
||||||
|
|
||||||
|
private String city; |
||||||
|
|
||||||
|
private String country; |
||||||
|
|
||||||
|
private String headimgurl; |
||||||
|
|
||||||
|
private int isStatus; |
||||||
|
|
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
public Long getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(Long id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUserName() { |
||||||
|
return userName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUserName(String userName) { |
||||||
|
this.userName = userName; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTelNum() { |
||||||
|
return telNum; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTelNum(String telNum) { |
||||||
|
this.telNum = telNum; |
||||||
|
} |
||||||
|
|
||||||
|
public String getOpenId() { |
||||||
|
return openId; |
||||||
|
} |
||||||
|
|
||||||
|
public void setOpenId(String openId) { |
||||||
|
this.openId = openId; |
||||||
|
} |
||||||
|
|
||||||
|
public String getNickName() { |
||||||
|
return nickName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setNickName(String nickName) { |
||||||
|
this.nickName = nickName; |
||||||
|
} |
||||||
|
|
||||||
|
public int getSex() { |
||||||
|
return sex; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSex(Integer sex) { |
||||||
|
this.sex = sex; |
||||||
|
} |
||||||
|
|
||||||
|
public String getProvince() { |
||||||
|
return province; |
||||||
|
} |
||||||
|
|
||||||
|
public void setProvince(String province) { |
||||||
|
this.province = province; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCity() { |
||||||
|
return city; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCity(String city) { |
||||||
|
this.city = city; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCountry() { |
||||||
|
return country; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCountry(String country) { |
||||||
|
this.country = country; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSex(int sex) { |
||||||
|
this.sex = sex; |
||||||
|
} |
||||||
|
|
||||||
|
public String getHeadimgurl() { |
||||||
|
return headimgurl; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHeadimgurl(String headimgurl) { |
||||||
|
this.headimgurl = headimgurl; |
||||||
|
} |
||||||
|
|
||||||
|
public int getIsStatus() { |
||||||
|
return isStatus; |
||||||
|
} |
||||||
|
|
||||||
|
public void setIsStatus(int isStatus) { |
||||||
|
this.isStatus = isStatus; |
||||||
|
} |
||||||
|
|
||||||
|
public Date getCreateTime() { |
||||||
|
return createTime; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) { |
||||||
|
this.createTime = createTime; |
||||||
|
} |
||||||
|
|
||||||
|
public Date getUpdateTime() { |
||||||
|
return updateTime; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) { |
||||||
|
this.updateTime = updateTime; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "WechatUserInfoEntity{" + |
||||||
|
"id=" + id + |
||||||
|
", userName='" + userName + '\'' + |
||||||
|
", telNum='" + telNum + '\'' + |
||||||
|
", openId='" + openId + '\'' + |
||||||
|
", nickName='" + nickName + '\'' + |
||||||
|
", sex=" + sex + |
||||||
|
", province='" + province + '\'' + |
||||||
|
", city='" + city + '\'' + |
||||||
|
", country='" + country + '\'' + |
||||||
|
", headimgurl='" + headimgurl + '\'' + |
||||||
|
", isStatus=" + isStatus + |
||||||
|
", createTime=" + createTime + |
||||||
|
", updateTime=" + updateTime + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,63 @@ |
|||||||
|
package com.mh.common.core.redis; |
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate; |
||||||
|
import org.springframework.data.redis.core.script.RedisScript; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 锁 |
||||||
|
* @date 2025-06-06 16:08:13 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@Component |
||||||
|
public class RedisLock { |
||||||
|
|
||||||
|
private final StringRedisTemplate redisTemplate; |
||||||
|
|
||||||
|
public RedisLock(StringRedisTemplate redisTemplate) { |
||||||
|
this.redisTemplate = redisTemplate; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取锁 |
||||||
|
*/ |
||||||
|
public boolean lock(String key, String requestId, long expireTimeInSeconds) { |
||||||
|
Boolean success = redisTemplate.opsForValue().setIfAbsent(key, requestId, expireTimeInSeconds, TimeUnit.SECONDS); |
||||||
|
return Boolean.TRUE.equals(success); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 尝试获取锁(带超时) |
||||||
|
*/ |
||||||
|
public boolean tryLock(String key, String requestId, long expireTime, long timeoutMs) throws InterruptedException { |
||||||
|
long startTime = System.currentTimeMillis(); |
||||||
|
while (System.currentTimeMillis() - startTime < timeoutMs) { |
||||||
|
if (lock(key, requestId, expireTime)) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
Thread.sleep(50); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 释放锁(使用 Lua 脚本保证原子性) |
||||||
|
*/ |
||||||
|
public void unlock(String key, String requestId) { |
||||||
|
String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"; |
||||||
|
RedisScript<Long> redisScript = RedisScript.of(script, Long.class); |
||||||
|
|
||||||
|
Long result = redisTemplate.execute(redisScript, Collections.singletonList(key), requestId); |
||||||
|
|
||||||
|
if (result == null || result == 0) { |
||||||
|
log.warn("释放锁失败,可能已被其他线程释放 key={}", key); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
package com.mh.common.model.response; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description 定义统一的数据解析结果对象 |
||||||
|
* @date 2026-04-28 11:41:34 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class ParseResult { |
||||||
|
|
||||||
|
private boolean success; |
||||||
|
private BigDecimal value; |
||||||
|
private String tagName; |
||||||
|
private int quality; |
||||||
|
private String errorMessage; |
||||||
|
|
||||||
|
public static ParseResult success(BigDecimal value, String tagName) { |
||||||
|
ParseResult result = new ParseResult(); |
||||||
|
result.setSuccess(true); |
||||||
|
result.setValue(value); |
||||||
|
result.setTagName(tagName); |
||||||
|
result.setQuality(0); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
public static ParseResult fail(String errorMessage) { |
||||||
|
ParseResult result = new ParseResult(); |
||||||
|
result.setSuccess(false); |
||||||
|
result.setErrorMessage(errorMessage); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,446 @@ |
|||||||
|
package com.mh.common.utils; |
||||||
|
|
||||||
|
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.math.RoundingMode; |
||||||
|
import java.text.DecimalFormat; |
||||||
|
import java.text.ParseException; |
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ljf |
||||||
|
* @title : |
||||||
|
* @description : 解析485接收的数据 |
||||||
|
* @updateTime 2020-04-23 |
||||||
|
* @throws : |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class AnalysisReceiveOrder485 { |
||||||
|
|
||||||
|
// 调用service
|
||||||
|
// private final SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
// private final DecimalFormat df = new DecimalFormat("#.##");
|
||||||
|
|
||||||
|
//解析冷量表
|
||||||
|
public void analysisCloudOrder485(final String dataStr1, final CollectionParamsManage deviceCodeParam) { |
||||||
|
// 去掉空格
|
||||||
|
String dataStr = dataStr1.replace(" ", "").toUpperCase(); |
||||||
|
// 检验报文
|
||||||
|
String checkStr = dataStr.substring(0, dataStr.length() - 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(checkStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
|
||||||
|
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
||||||
|
//创建SimpleDateFormat对象,指定样式 2019-05-13 22:39:30
|
||||||
|
// Date date = new Date();
|
||||||
|
// String dateStr = sdf1.format(date);
|
||||||
|
//保留两位小数处理
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("0.00"); |
||||||
|
// 表号
|
||||||
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
||||||
|
// 读数
|
||||||
|
String data = ""; |
||||||
|
data = dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
||||||
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4) |
||||||
|
+ dataStr.substring(dataStr.length() - 12, dataStr.length() - 10) |
||||||
|
+ dataStr.substring(dataStr.length() - 10, dataStr.length() - 8); |
||||||
|
|
||||||
|
String registerAddr = deviceCodeParam.getRegisterAddr(); |
||||||
|
// if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:00:30")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "00";
|
||||||
|
// } else if (ExchangeStringUtil.isInDate(date, "00:00:30", "00:00:59")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "30";
|
||||||
|
// }
|
||||||
|
try { |
||||||
|
if (registerAddr.equals("32") || registerAddr.equals("33") || registerAddr.equals("35") || registerAddr.equals("36")) { |
||||||
|
data = decimalFormat.format(Math.abs(ExchangeStringUtil.hexToSingle(data)));//十六进制字符串转IEEE754浮点型
|
||||||
|
// log.info("冷量计==>{},寄存器地址==>{},读数==>{}", cloudId, registerAddr, data);
|
||||||
|
} else if (registerAddr.equals("31") || registerAddr.equals("34")) { |
||||||
|
long lData = Long.parseLong(ExchangeStringUtil.hexToDec(data)); |
||||||
|
// log.info("冷量计==>{},寄存器地址==>{},累计读数==>{}", cloudId, registerAddr, lData);
|
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("保存冷量计数据失败!", e); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// log.info("冷量计校验失败===>{}", dataStr);
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 解析水表返回的数据 |
||||||
|
* |
||||||
|
* @param dataStr1 |
||||||
|
*/ |
||||||
|
public String analysisWaterOrder485(final String dataStr1, final CollectionParamsManage deviceCodeParam) { |
||||||
|
// 去掉空格
|
||||||
|
String dataStr = dataStr1.replace(" ", "").toUpperCase(); |
||||||
|
// 检验报文
|
||||||
|
String checkStr = dataStr.substring(0, dataStr.length() - 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(checkStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
|
||||||
|
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
||||||
|
//创建SimpleDateFormat对象,指定样式 2019-05-13 22:39:30
|
||||||
|
// Date date = new Date();
|
||||||
|
// String dateStr = sdf1.format(date);
|
||||||
|
//保留两位小数处理
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("0.00"); |
||||||
|
// 表号
|
||||||
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
||||||
|
// 读数
|
||||||
|
String data = ""; |
||||||
|
data = dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
||||||
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4) |
||||||
|
+ dataStr.substring(dataStr.length() - 12, dataStr.length() - 10) |
||||||
|
+ dataStr.substring(dataStr.length() - 10, dataStr.length() - 8); |
||||||
|
|
||||||
|
int dataType = deviceCodeParam.getDataType(); |
||||||
|
// if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:00:30")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "00";
|
||||||
|
// // System.out.println("插入时间00" + dateStr);
|
||||||
|
// } else if (ExchangeStringUtil.isInDate(date, "00:00:30", "00:00:59")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "30";
|
||||||
|
// // System.out.println("插入时间30" + dateStr);
|
||||||
|
// }
|
||||||
|
try { |
||||||
|
if (dataType == 3) { |
||||||
|
data = decimalFormat.format(Math.abs(ExchangeStringUtil.hexToSingle(data)));//十六进制字符串转IEEE754浮点型
|
||||||
|
// log.info("水表==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} else if (dataType == 2) { |
||||||
|
data = dataStr.substring(dataStr.length() - 12, dataStr.length() - 10) |
||||||
|
+ dataStr.substring(dataStr.length() - 10, dataStr.length() - 8) |
||||||
|
+ dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
||||||
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4); |
||||||
|
data = ExchangeStringUtil.hexToDec(data); |
||||||
|
BigDecimal bigDecimal = new BigDecimal(data); |
||||||
|
bigDecimal = bigDecimal.divide(new BigDecimal((int) Math.pow(10, deviceCodeParam.getDigits()))).setScale(2, RoundingMode.HALF_UP); // 除以1000并保留整数
|
||||||
|
data = bigDecimal.toString(); |
||||||
|
// log.info("水表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} |
||||||
|
// 判断data大于99999999,就返回空
|
||||||
|
if (new BigDecimal(data).intValue() > 99999999) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return data; |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("保存水表数据失败!", e); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// log.info("水表===>{}", dataStr);
|
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 解析电表返回的数据 |
||||||
|
* |
||||||
|
* @param dataStr1 |
||||||
|
*/ |
||||||
|
public String analysisMeterOrder485(final String dataStr1, final CollectionParamsManage deviceCodeParam) { |
||||||
|
// 去掉空格
|
||||||
|
String dataStr = dataStr1.replace(" ", "").toUpperCase(); |
||||||
|
// 检验报文
|
||||||
|
String checkStr = dataStr.substring(0, dataStr.length() - 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(checkStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
|
||||||
|
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
||||||
|
//创建SimpleDateFormat对象,指定样式 2019-05-13 22:39:30
|
||||||
|
// Date date = new Date();
|
||||||
|
// String dateStr = sdf1.format(date);
|
||||||
|
; |
||||||
|
//保留两位小数处理
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("0.00"); |
||||||
|
// 表号
|
||||||
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
||||||
|
// 读数 02 04 04 00 04 4D 1F FD DD
|
||||||
|
String data = ""; |
||||||
|
data = dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
||||||
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4) |
||||||
|
+ dataStr.substring(dataStr.length() - 12, dataStr.length() - 10) |
||||||
|
+ dataStr.substring(dataStr.length() - 10, dataStr.length() - 8); |
||||||
|
|
||||||
|
int dataType = deviceCodeParam.getDataType(); |
||||||
|
// if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:00:30")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "00";
|
||||||
|
// // System.out.println("插入时间00" + dateStr);
|
||||||
|
// } else if (ExchangeStringUtil.isInDate(date, "00:00:30", "00:00:59")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "30";
|
||||||
|
// // System.out.println("插入时间30" + dateStr);
|
||||||
|
// }
|
||||||
|
try { |
||||||
|
if (dataType == 3) { |
||||||
|
data = decimalFormat.format(Math.abs(ExchangeStringUtil.hexToSingle(data)));//十六进制字符串转IEEE754浮点型
|
||||||
|
// log.info("电表==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} else if (dataType == 2) { |
||||||
|
data = ExchangeStringUtil.hexToDec(data); |
||||||
|
// log.info("电表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} else if (dataType == 4) { |
||||||
|
data = dataStr.substring(dataStr.length() - 12, dataStr.length() - 10) |
||||||
|
+ dataStr.substring(dataStr.length() - 10, dataStr.length() - 8) |
||||||
|
+ dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
||||||
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4); |
||||||
|
data = ExchangeStringUtil.hexToDec(data); |
||||||
|
BigDecimal bigDecimal = new BigDecimal(data); |
||||||
|
bigDecimal = bigDecimal.divide(new BigDecimal((int) Math.pow(10, deviceCodeParam.getDigits()))).setScale(2, RoundingMode.HALF_UP); // 除以1000并保留整数
|
||||||
|
data = bigDecimal.toString(); |
||||||
|
// log.info("电表==>{},寄存器地址==>{},累计读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} |
||||||
|
// 判断data大于99999999,就返回空
|
||||||
|
if (new BigDecimal(data).intValue() > 99999999) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return data; |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("保存电表数据失败!", e); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// log.info("电表===>{}", dataStr);
|
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
public static int dValue(String lastDate) throws ParseException { |
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||||
|
Date lastTime = format.parse(lastDate); |
||||||
|
long min = lastTime.getTime(); |
||||||
|
Calendar calendar = Calendar.getInstance(); |
||||||
|
long min1 = calendar.getTimeInMillis(); |
||||||
|
long subtract = min1 - min; |
||||||
|
// // System.out.println("相减值: " + subtract/(1000*60));
|
||||||
|
return (int) subtract / (1000 * 60); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// 判断是否存在寄存器地址
|
||||||
|
public Boolean queryRegisterAddr(List<String> stringList, String registerAddr) { |
||||||
|
boolean flag = false; |
||||||
|
for (int i = 0; i < stringList.size(); i++) { |
||||||
|
if (stringList.get(i).equalsIgnoreCase(registerAddr)) { |
||||||
|
flag = true; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
return flag; |
||||||
|
} |
||||||
|
|
||||||
|
public String analysisHeatPumpOrder485(String receiveStr, CollectionParamsManage deviceCodeParam) { |
||||||
|
// 去掉空格
|
||||||
|
String dataStr = receiveStr.replace(" ", "").toUpperCase(); |
||||||
|
// 检验报文
|
||||||
|
String checkStr = dataStr.substring(0, dataStr.length() - 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(checkStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
|
||||||
|
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
||||||
|
//创建SimpleDateFormat对象,指定样式 2019-05-13 22:39:30
|
||||||
|
// Date date = new Date();
|
||||||
|
// String dateStr = sdf1.format(date);
|
||||||
|
|
||||||
|
//保留两位小数处理
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("0.00"); |
||||||
|
// 表号
|
||||||
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
||||||
|
// 读数
|
||||||
|
String data = ""; |
||||||
|
data = dataStr.substring(dataStr.length() - 8, dataStr.length() - 6) |
||||||
|
+ dataStr.substring(dataStr.length() - 6, dataStr.length() - 4); |
||||||
|
|
||||||
|
int dataType = deviceCodeParam.getDataType(); |
||||||
|
// if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:00:30")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "00";
|
||||||
|
// // System.out.println("插入时间00" + dateStr);
|
||||||
|
// } else if (ExchangeStringUtil.isInDate(date, "00:00:30", "00:00:59")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "30";
|
||||||
|
// // System.out.println("插入时间30" + dateStr);
|
||||||
|
// }
|
||||||
|
try { |
||||||
|
if (dataType == 3) { |
||||||
|
data = decimalFormat.format(Math.abs(ExchangeStringUtil.hexToSingle(data)));//十六进制字符串转IEEE754浮点型
|
||||||
|
} else if (dataType == 2 && (deviceCodeParam.getParamType().equals("5") |
||||||
|
|| deviceCodeParam.getParamType().equals("2") |
||||||
|
|| deviceCodeParam.getParamType().equals("12") |
||||||
|
|| deviceCodeParam.getParamType().equals("14") |
||||||
|
|| deviceCodeParam.getParamType().equals("48") |
||||||
|
)) { |
||||||
|
data = ExchangeStringUtil.hexToDec(data); |
||||||
|
} |
||||||
|
// log.info("热泵==>{},寄存器地址==>{},读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
return data; |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("保存热泵数据失败!", e); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// log.info("热泵===>{}", dataStr);
|
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
public String analysisLiquidOrder485(String receiveStr, CollectionParamsManage deviceCodeParam) { |
||||||
|
// 去掉空格
|
||||||
|
String dataStr = receiveStr.replace(" ", "").toUpperCase(); |
||||||
|
// 检验报文
|
||||||
|
String checkStr = dataStr.substring(0, dataStr.length() - 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(checkStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
|
||||||
|
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
||||||
|
//创建SimpleDateFormat对象,指定样式 2019-05-13 22:39:30
|
||||||
|
// Date date = new Date();
|
||||||
|
// String dateStr = sdf1.format(date);
|
||||||
|
|
||||||
|
// 表号
|
||||||
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
||||||
|
// 读数
|
||||||
|
String data = ""; |
||||||
|
data = dataStr.substring(dataStr.length() - 8, dataStr.length() - 4); |
||||||
|
|
||||||
|
int dataType = deviceCodeParam.getDataType(); |
||||||
|
// if (ExchangeStringUtil.isInDate(date, "00:00:00", "00:00:30")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "00";
|
||||||
|
// //// System.out.println("插入时间00" + dateStr);
|
||||||
|
// } else if (ExchangeStringUtil.isInDate(date, "00:00:30", "00:00:59")) {
|
||||||
|
// dateStr = dateStr.substring(0, 17) + "30";
|
||||||
|
// //.out.println("插入时间30" + dateStr);
|
||||||
|
// }
|
||||||
|
try { |
||||||
|
if (dataType == 2 && (deviceCodeParam.getParamType().equals("11"))) { |
||||||
|
data = ExchangeStringUtil.hexToDec(data); |
||||||
|
BigDecimal bigDecimal = new BigDecimal(data); |
||||||
|
bigDecimal = bigDecimal.divide(new BigDecimal((int) Math.pow(10, deviceCodeParam.getDigits()))).setScale(3, RoundingMode.HALF_UP); // 除以1000并保留整数
|
||||||
|
data = bigDecimal.toString(); |
||||||
|
// log.info("液位==>{},寄存器地址==>{},实时读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} |
||||||
|
// 判断data大于99999999,就返回空
|
||||||
|
if (new BigDecimal(data).intValue() > 100) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return data; |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("保存液位数据失败!", e); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// log.info("液位===>{}", dataStr);
|
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
public String analysisTempHumiditySensorOrder485(String receiveStr, CollectionParamsManage deviceCodeParam) { |
||||||
|
// 去掉空格
|
||||||
|
String dataStr = receiveStr.replace(" ", "").toUpperCase(); |
||||||
|
// 检验报文
|
||||||
|
String checkStr = dataStr.substring(0, dataStr.length() - 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(checkStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
|
||||||
|
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
||||||
|
// 表号
|
||||||
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
||||||
|
// 读数
|
||||||
|
String data = ""; |
||||||
|
data = dataStr.substring(dataStr.length() - 8, dataStr.length() - 4); |
||||||
|
|
||||||
|
int dataType = deviceCodeParam.getDataType(); |
||||||
|
try { |
||||||
|
if (dataType == 2) { |
||||||
|
data = ExchangeStringUtil.hexToDec(data); |
||||||
|
BigDecimal bigDecimal = new BigDecimal(data); |
||||||
|
if (deviceCodeParam.getParamType().equals("12")){ |
||||||
|
// 温度
|
||||||
|
bigDecimal = bigDecimal.multiply(new BigDecimal(165)).divide(new BigDecimal(1650)).subtract(new BigDecimal(40)); |
||||||
|
} else if (deviceCodeParam.getParamType().equals("35")) { |
||||||
|
// 湿度
|
||||||
|
bigDecimal = bigDecimal.multiply(new BigDecimal(100)); |
||||||
|
} |
||||||
|
bigDecimal = bigDecimal.divide(new BigDecimal((int) Math.pow(10, deviceCodeParam.getDigits()))).setScale(3, RoundingMode.HALF_UP); // 除以1000并保留整数
|
||||||
|
data = bigDecimal.toString(); |
||||||
|
// log.info("液位==>{},寄存器地址==>{},实时读数==>{}", cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} |
||||||
|
// // 判断data大于99999999,就返回空
|
||||||
|
// if (new BigDecimal(data).intValue() > 130) {
|
||||||
|
// return "";
|
||||||
|
// }
|
||||||
|
return data; |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("保存液位数据失败!", e); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// log.info("液位===>{}", dataStr);
|
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
public String analysisLiquidControlOrder485(String receiveStr, CollectionParamsManage deviceCodeParam) { |
||||||
|
// log.error("接收数据:{},{}", receiveStr,deviceCodeParam.toString());
|
||||||
|
String dataStr = receiveStr.replace(" ", "").toUpperCase(); |
||||||
|
// 检验报文
|
||||||
|
String checkStr = dataStr.substring(0, dataStr.length() - 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(checkStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
|
||||||
|
if (checkWord.equalsIgnoreCase(dataStr.substring(dataStr.length() - 4))) { |
||||||
|
// 表号
|
||||||
|
String cloudId = ExchangeStringUtil.hexToDec(dataStr.substring(0, 2)); |
||||||
|
// 读数
|
||||||
|
String data = ""; |
||||||
|
data = dataStr.substring(dataStr.length() - 12, dataStr.length() - 8); |
||||||
|
// 保留小数位数
|
||||||
|
String dot = ""; |
||||||
|
dot = dataStr.substring(dataStr.length() - 8, dataStr.length() - 4); |
||||||
|
|
||||||
|
int dataType = deviceCodeParam.getDataType(); |
||||||
|
try { |
||||||
|
if (dataType == 2) { |
||||||
|
data = ExchangeStringUtil.hexToDec(data); |
||||||
|
dot = ExchangeStringUtil.hexToDec(dot); |
||||||
|
BigDecimal bigDecimal = new BigDecimal(data); |
||||||
|
bigDecimal = bigDecimal.divide(BigDecimal.valueOf(Math.pow(10, Integer.parseInt(dot)))).setScale(3, RoundingMode.HALF_UP); // 除以1000并保留整数
|
||||||
|
data = bigDecimal.toString(); |
||||||
|
// log.error("贵宾楼液位报文==>{},地址==>{},寄存器地址==>{},实时读数==>{}", receiveStr, cloudId, deviceCodeParam.getRegisterAddr(), data);
|
||||||
|
} |
||||||
|
// 判断data大于99999999,就返回空
|
||||||
|
if (new BigDecimal(data).intValue() > 10) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
return data; |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("保存液位数据失败!", e); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// log.info("液位===>{}", dataStr);
|
||||||
|
return ""; |
||||||
|
} |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
CollectionParamsManage collectionParamsManage = new CollectionParamsManage(); |
||||||
|
collectionParamsManage.setDataType(2); |
||||||
|
collectionParamsManage.setDigits(2); |
||||||
|
System.out.println(new AnalysisReceiveOrder485().analysisWaterOrder485("2103040012D68765F6", collectionParamsManage)); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,253 @@ |
|||||||
|
package com.mh.common.utils; |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC16_CCITT:多项式x16+x12+x5+1(0x1021),初始值0x0000,低位在前,高位在后,结果与0x0000异或 |
||||||
|
* CRC16_CCITT_FALSE:多项式x16+x12+x5+1(0x1021),初始值0xFFFF,低位在后,高位在前,结果与0x0000异或 |
||||||
|
* CRC16_XMODEM:多项式x16+x12+x5+1(0x1021),初始值0x0000,低位在后,高位在前,结果与0x0000异或 |
||||||
|
* CRC16_X25:多项式x16+x12+x5+1(0x1021),初始值0xffff,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* CRC16_MODBUS:多项式x16+x15+x2+1(0x8005),初始值0xFFFF,低位在前,高位在后,结果与0x0000异或 |
||||||
|
* CRC16_IBM:多项式x16+x15+x2+1(0x8005),初始值0x0000,低位在前,高位在后,结果与0x0000异或 |
||||||
|
* CRC16_MAXIM:多项式x16+x15+x2+1(0x8005),初始值0x0000,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* CRC16_USB:多项式x16+x15+x2+1(0x8005),初始值0xFFFF,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* CRC16_DNP:多项式x16+x13+x12+x11+x10+x8+x6+x5+x2+1(0x3D65),初始值0x0000,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* <p> |
||||||
|
* (1)、预置1个16位的寄存器为十六进制FFFF(即全为1),称此寄存器为CRC寄存器; |
||||||
|
* (2)、把第一个8位二进制数据(既通讯信息帧的第一个字节)与16位的CRC寄存器的低8位相异或,把结果放于CRC寄存器,高八位数据不变; |
||||||
|
* (3)、把CRC寄存器的内容右移一位(朝低位)用0填补最高位,并检查右移后的移出位; |
||||||
|
* (4)、如果移出位为0:重复第3步(再次右移一位);如果移出位为1,CRC寄存器与多项式A001(1010 0000 0000 0001)进行异或; |
||||||
|
* (5)、重复步骤3和4,直到右移8次,这样整个8位数据全部进行了处理; |
||||||
|
* (6)、重复步骤2到步骤5,进行通讯信息帧下一个字节的处理; |
||||||
|
* (7)、将该通讯信息帧所有字节按上述步骤计算完成后,得到的16位CRC寄存器的高、低字节进行交换; |
||||||
|
* (8)、最后得到的CRC寄存器内容即为:CRC码。 |
||||||
|
* <p> |
||||||
|
* 以上计算步骤中的多项式0xA001是0x8005按位颠倒后的结果。 |
||||||
|
* 0x8408是0x1021按位颠倒后的结果。 |
||||||
|
* 在线校验工具 |
||||||
|
* http://www.ip33.com/crc.html
|
||||||
|
* https://blog.csdn.net/htmlxx/article/details/17369105
|
||||||
|
* <p> |
||||||
|
* Author:Water |
||||||
|
* Time:2018/11/19 0019 15:03 |
||||||
|
*/ |
||||||
|
public class CRC16 { |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC16_CCITT:多项式x16+x12+x5+1(0x1021),初始值0x0000,低位在前,高位在后,结果与0x0000异或 |
||||||
|
* 0x8408是0x1021按位颠倒后的结果。 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_CCITT(byte[] buffer) { |
||||||
|
int wCRCin = 0x0000; |
||||||
|
int wCPoly = 0x8408; |
||||||
|
for (byte b : buffer) { |
||||||
|
wCRCin ^= ((int) b & 0x00ff); |
||||||
|
for (int j = 0; j < 8; j++) { |
||||||
|
if ((wCRCin & 0x0001) != 0) { |
||||||
|
wCRCin >>= 1; |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} else { |
||||||
|
wCRCin >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
// wCRCin=(wCRCin<<8)|(wCRCin>>8);
|
||||||
|
// wCRCin &= 0xffff;
|
||||||
|
return wCRCin ^= 0x0000; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC-CCITT (0xFFFF) |
||||||
|
* CRC16_CCITT_FALSE:多项式x16+x12+x5+1(0x1021),初始值0xFFFF,低位在后,高位在前,结果与0x0000异或 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_CCITT_FALSE(byte[] buffer) { |
||||||
|
int wCRCin = 0xffff; |
||||||
|
int wCPoly = 0x1021; |
||||||
|
for (byte b : buffer) { |
||||||
|
for (int i = 0; i < 8; i++) { |
||||||
|
boolean bit = ((b >> (7 - i) & 1) == 1); |
||||||
|
boolean c15 = ((wCRCin >> 15 & 1) == 1); |
||||||
|
wCRCin <<= 1; |
||||||
|
if (c15 ^ bit) |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} |
||||||
|
} |
||||||
|
wCRCin &= 0xffff; |
||||||
|
return wCRCin ^= 0x0000; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC-CCITT (XModem) |
||||||
|
* CRC16_XMODEM:多项式x16+x12+x5+1(0x1021),初始值0x0000,低位在后,高位在前,结果与0x0000异或 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_XMODEM(byte[] buffer) { |
||||||
|
int wCRCin = 0x0000; // initial value 65535
|
||||||
|
int wCPoly = 0x1021; // 0001 0000 0010 0001 (0, 5, 12)
|
||||||
|
for (byte b : buffer) { |
||||||
|
for (int i = 0; i < 8; i++) { |
||||||
|
boolean bit = ((b >> (7 - i) & 1) == 1); |
||||||
|
boolean c15 = ((wCRCin >> 15 & 1) == 1); |
||||||
|
wCRCin <<= 1; |
||||||
|
if (c15 ^ bit) |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} |
||||||
|
} |
||||||
|
wCRCin &= 0xffff; |
||||||
|
return wCRCin ^= 0x0000; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* CRC16_X25:多项式x16+x12+x5+1(0x1021),初始值0xffff,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* 0x8408是0x1021按位颠倒后的结果。 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_X25(byte[] buffer) { |
||||||
|
int wCRCin = 0xffff; |
||||||
|
int wCPoly = 0x8408; |
||||||
|
for (byte b : buffer) { |
||||||
|
wCRCin ^= ((int) b & 0x00ff); |
||||||
|
for (int j = 0; j < 8; j++) { |
||||||
|
if ((wCRCin & 0x0001) != 0) { |
||||||
|
wCRCin >>= 1; |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} else { |
||||||
|
wCRCin >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return wCRCin ^= 0xffff; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC-16 (Modbus) |
||||||
|
* CRC16_MODBUS:多项式x16+x15+x2+1(0x8005),初始值0xFFFF,低位在前,高位在后,结果与0x0000异或 |
||||||
|
* 0xA001是0x8005按位颠倒后的结果 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_MODBUS(byte[] buffer) { |
||||||
|
int wCRCin = 0xffff; |
||||||
|
int POLYNOMIAL = 0xa001; |
||||||
|
for (byte b : buffer) { |
||||||
|
wCRCin ^= ((int) b & 0x00ff); |
||||||
|
for (int j = 0; j < 8; j++) { |
||||||
|
if ((wCRCin & 0x0001) != 0) { |
||||||
|
wCRCin >>= 1; |
||||||
|
wCRCin ^= POLYNOMIAL; |
||||||
|
} else { |
||||||
|
wCRCin >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return wCRCin ^= 0x0000; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC-16 |
||||||
|
* CRC16_IBM:多项式x16+x15+x2+1(0x8005),初始值0x0000,低位在前,高位在后,结果与0x0000异或 |
||||||
|
* 0xA001是0x8005按位颠倒后的结果 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_IBM(byte[] buffer) { |
||||||
|
int wCRCin = 0x0000; |
||||||
|
int wCPoly = 0xa001; |
||||||
|
for (byte b : buffer) { |
||||||
|
wCRCin ^= ((int) b & 0x00ff); |
||||||
|
for (int j = 0; j < 8; j++) { |
||||||
|
if ((wCRCin & 0x0001) != 0) { |
||||||
|
wCRCin >>= 1; |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} else { |
||||||
|
wCRCin >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return wCRCin ^= 0x0000; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC16_MAXIM:多项式x16+x15+x2+1(0x8005),初始值0x0000,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* 0xA001是0x8005按位颠倒后的结果 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_MAXIM(byte[] buffer) { |
||||||
|
int wCRCin = 0x0000; |
||||||
|
int wCPoly = 0xa001; |
||||||
|
for (byte b : buffer) { |
||||||
|
wCRCin ^= ((int) b & 0x00ff); |
||||||
|
for (int j = 0; j < 8; j++) { |
||||||
|
if ((wCRCin & 0x0001) != 0) { |
||||||
|
wCRCin >>= 1; |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} else { |
||||||
|
wCRCin >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return wCRCin ^= 0xffff; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC16_USB:多项式x16+x15+x2+1(0x8005),初始值0xFFFF,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* 0xA001是0x8005按位颠倒后的结果 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_USB(byte[] buffer) { |
||||||
|
int wCRCin = 0xFFFF; |
||||||
|
int wCPoly = 0xa001; |
||||||
|
for (byte b : buffer) { |
||||||
|
wCRCin ^= ((int) b & 0x00ff); |
||||||
|
for (int j = 0; j < 8; j++) { |
||||||
|
if ((wCRCin & 0x0001) != 0) { |
||||||
|
wCRCin >>= 1; |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} else { |
||||||
|
wCRCin >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return wCRCin ^= 0xffff; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* CRC16_DNP:多项式x16+x13+x12+x11+x10+x8+x6+x5+x2+1(0x3D65),初始值0x0000,低位在前,高位在后,结果与0xFFFF异或 |
||||||
|
* 0xA6BC是0x3D65按位颠倒后的结果 |
||||||
|
* |
||||||
|
* @param buffer |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static int CRC16_DNP(byte[] buffer) { |
||||||
|
int wCRCin = 0x0000; |
||||||
|
int wCPoly = 0xA6BC; |
||||||
|
for (byte b : buffer) { |
||||||
|
wCRCin ^= ((int) b & 0x00ff); |
||||||
|
for (int j = 0; j < 8; j++) { |
||||||
|
if ((wCRCin & 0x0001) != 0) { |
||||||
|
wCRCin >>= 1; |
||||||
|
wCRCin ^= wCPoly; |
||||||
|
} else { |
||||||
|
wCRCin >>= 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return wCRCin ^= 0xffff; |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,99 @@ |
|||||||
|
package com.mh.common.utils; |
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf; |
||||||
|
import io.netty.buffer.Unpooled; |
||||||
|
import io.netty.channel.ChannelHandlerContext; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description Modbus协议工具类 |
||||||
|
* @date 2025-06-06 14:40:24 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class ModbusUtils { |
||||||
|
|
||||||
|
public static String createReadOrder(String mtCode, String funCode, String registerAddr, String registerNum) { |
||||||
|
// 开始创建指令
|
||||||
|
// 拼接指令
|
||||||
|
String sendOrderStr = ExchangeStringUtil.addZeroForNum(mtCode, 2) |
||||||
|
+ ExchangeStringUtil.addZeroForNum(funCode, 2) |
||||||
|
+ ExchangeStringUtil.addZeroForNum(registerAddr, 4) |
||||||
|
+ ExchangeStringUtil.addZeroForNum(registerNum, 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(sendOrderStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
sendOrderStr = sendOrderStr + checkWord; |
||||||
|
return sendOrderStr; |
||||||
|
} |
||||||
|
|
||||||
|
public static String createControlCode(String mtCode, Integer type, String registerAddr, String param) { |
||||||
|
String orderStr; |
||||||
|
mtCode = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(mtCode), 2); |
||||||
|
registerAddr = ExchangeStringUtil.addZeroForNum(registerAddr, 4); |
||||||
|
param = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(param), 4); |
||||||
|
orderStr = mtCode + "06" + registerAddr + param; |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(orderStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
// 发送的指令
|
||||||
|
// log.info("发送指令:{}", orderStr+checkWord);
|
||||||
|
return orderStr + checkWord; |
||||||
|
} |
||||||
|
|
||||||
|
public static ByteBuf getByteBuf(ChannelHandlerContext ctx, String sendStr) { |
||||||
|
// byte类型的数据
|
||||||
|
// String sendStr = "5803004900021914"; // 冷量计
|
||||||
|
// 申请一个数据结构存储信息
|
||||||
|
ByteBuf buffer = ctx.alloc().buffer(); |
||||||
|
// 将信息放入数据结构中
|
||||||
|
buffer.writeBytes(ExchangeStringUtil.hexStrToBinaryStr(sendStr));//对接需要16进制
|
||||||
|
return buffer; |
||||||
|
} |
||||||
|
|
||||||
|
public static ByteBuf createByteBuf(String sendStr) { |
||||||
|
// byte类型的数据
|
||||||
|
// String sendStr = "5803004900021914"; // 冷量计
|
||||||
|
// 申请一个数据结构存储信息
|
||||||
|
ByteBuf buffer = Unpooled.buffer(); |
||||||
|
// 将信息放入数据结构中
|
||||||
|
buffer.writeBytes(ExchangeStringUtil.hexStrToBinaryStr(sendStr));//对接需要16进制
|
||||||
|
return buffer; |
||||||
|
} |
||||||
|
|
||||||
|
public static String createTenControlCode(String mtCode, Integer type, String registerAddr, Integer digits, String param) { |
||||||
|
// 14 10 01 08 00 02 04 07 08 00 03 7A 22
|
||||||
|
// 14:地址:mtCode
|
||||||
|
// 10:功能码
|
||||||
|
// 01 08:寄存器地址 registerAddr
|
||||||
|
// 寄存器大小: 00 02
|
||||||
|
// 04:数据长度
|
||||||
|
// 07 08:数据值
|
||||||
|
// 00 03:小数位数 digits
|
||||||
|
// 7A 22:校验码
|
||||||
|
String orderStr; |
||||||
|
mtCode = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(mtCode), 2); |
||||||
|
registerAddr = ExchangeStringUtil.addZeroForNum(registerAddr, 4); |
||||||
|
param = String.valueOf(new BigDecimal(param).multiply(BigDecimal.valueOf(Math.pow(10, digits))).intValue()); |
||||||
|
param = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(param), 4); |
||||||
|
String dot = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(String.valueOf(digits)), 4); |
||||||
|
orderStr = mtCode + "10" + registerAddr + "0002" + "04" + param + dot; |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(orderStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
// 发送的指令
|
||||||
|
return orderStr+checkWord; |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
System.out.println(createTenControlCode("20", 1, "0108", 3, "2.1")); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,77 @@ |
|||||||
|
package com.mh.common.utils; |
||||||
|
|
||||||
|
|
||||||
|
import com.google.common.cache.Cache; |
||||||
|
import com.google.common.cache.CacheBuilder; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
import java.util.concurrent.BlockingQueue; |
||||||
|
import java.util.concurrent.LinkedBlockingQueue; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project TAD_Server |
||||||
|
* @description 缓存等待数据 |
||||||
|
* @date 2023/7/4 08:45:16 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class NettyTools { |
||||||
|
|
||||||
|
/** |
||||||
|
* 响应消息缓存 |
||||||
|
*/ |
||||||
|
private static final Cache<String, BlockingQueue<String>> responseMsgCache = CacheBuilder.newBuilder() |
||||||
|
.maximumSize(500) |
||||||
|
.expireAfterWrite(1000, TimeUnit.SECONDS) |
||||||
|
.build(); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 等待响应消息 |
||||||
|
* @param key 消息唯一标识 |
||||||
|
* @return ReceiveDdcMsgVo |
||||||
|
*/ |
||||||
|
public static boolean waitReceiveMsg(String key) { |
||||||
|
|
||||||
|
try { |
||||||
|
//设置超时时间
|
||||||
|
String vo = Objects.requireNonNull(responseMsgCache.getIfPresent(key)) |
||||||
|
.poll(1000 * 10, TimeUnit.MILLISECONDS); |
||||||
|
|
||||||
|
//删除key
|
||||||
|
responseMsgCache.invalidate(key); |
||||||
|
return StringUtils.isNotBlank(vo); |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("获取数据异常,sn={},msg=null",key); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化响应消息的队列 |
||||||
|
* @param key 消息唯一标识 |
||||||
|
*/ |
||||||
|
public static void initReceiveMsg(String key) { |
||||||
|
responseMsgCache.put(key,new LinkedBlockingQueue<String>(1)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置响应消息 |
||||||
|
* @param key 消息唯一标识 |
||||||
|
*/ |
||||||
|
public static void setReceiveMsg(String key, String msg) { |
||||||
|
|
||||||
|
if(responseMsgCache.getIfPresent(key) != null){ |
||||||
|
Objects.requireNonNull(responseMsgCache.getIfPresent(key)).add(msg); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
log.warn("sn {}不存在",key); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,64 @@ |
|||||||
|
package com.mh.common.utils; |
||||||
|
|
||||||
|
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||||
|
import io.netty.buffer.ByteBuf; |
||||||
|
import io.netty.channel.ChannelHandlerContext; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ljf |
||||||
|
* @title : |
||||||
|
* @description : 发送指令工具类 |
||||||
|
* @updateTime 2021-01-26 |
||||||
|
* @throws : |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class SendOrderUtils { |
||||||
|
|
||||||
|
// 发送所有类型采集报文
|
||||||
|
public static void sendAllOrder(CollectionParamsManage paramsManage, ChannelHandlerContext ctx, int num, int size) { |
||||||
|
// 开始创建指令
|
||||||
|
String mtCode = paramsManage.getMtCode(); // 采集编号
|
||||||
|
String funCode = paramsManage.getFuncCode(); // 功能码
|
||||||
|
String registerAddr = paramsManage.getRegisterAddr(); // 寄存器地址
|
||||||
|
String registerNum = String.valueOf(paramsManage.getRegisterSize()); // 寄存器数量
|
||||||
|
// 拼接指令
|
||||||
|
String sendOrderStr = ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex(mtCode), 2) |
||||||
|
+ ExchangeStringUtil.addZeroForNum(funCode, 2) |
||||||
|
+ ExchangeStringUtil.addZeroForNum(registerAddr, 4) |
||||||
|
+ ExchangeStringUtil.addZeroForNum(registerNum, 4); |
||||||
|
byte[] strOrder = ExchangeStringUtil.hexStrToBinaryStr(sendOrderStr); |
||||||
|
int checkNum = CRC16.CRC16_MODBUS(strOrder); |
||||||
|
String checkWord = ExchangeStringUtil.decToHex(String.valueOf(checkNum)); |
||||||
|
checkWord = checkWord.substring(2, 4) + checkWord.substring(0, 2); |
||||||
|
sendOrderStr = sendOrderStr + checkWord; |
||||||
|
ByteBuf buffer = getByteBuf(ctx, sendOrderStr); |
||||||
|
// 发送数据
|
||||||
|
ctx.channel().writeAndFlush(buffer); |
||||||
|
// log.info("sends :" + sendOrderStr + ",num:" + num + ",records:" + size);
|
||||||
|
try { |
||||||
|
Thread.sleep(500); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
log.error("线程休眠异常", e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static ByteBuf getByteBuf(ChannelHandlerContext ctx, String sendStr) { |
||||||
|
// 申请一个数据结构存储信息
|
||||||
|
ByteBuf buffer = ctx.alloc().buffer(); |
||||||
|
// 将信息放入数据结构中
|
||||||
|
buffer.writeBytes(ExchangeStringUtil.hexStrToBinaryStr(sendStr));//对接需要16进制
|
||||||
|
return buffer; |
||||||
|
} |
||||||
|
|
||||||
|
public static void sendOrderToDTU(ChannelHandlerContext ctx, String sendStr) { |
||||||
|
ByteBuf buffer = getByteBuf(ctx, sendStr); |
||||||
|
// 发送数据
|
||||||
|
ctx.channel().writeAndFlush(buffer); |
||||||
|
try { |
||||||
|
Thread.sleep(500); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
log.error("线程休眠异常", e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,81 @@ |
|||||||
|
package com.mh.common.utils.file.handle; |
||||||
|
|
||||||
|
import com.alibaba.excel.metadata.Head; |
||||||
|
import com.alibaba.excel.metadata.data.WriteCellData; |
||||||
|
import com.alibaba.excel.write.handler.CellWriteHandler; |
||||||
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
||||||
|
import com.alibaba.excel.write.metadata.holder.WriteTableHolder; |
||||||
|
import org.apache.poi.ss.usermodel.Cell; |
||||||
|
import org.apache.poi.ss.usermodel.Row; |
||||||
|
import org.apache.poi.ss.usermodel.Sheet; |
||||||
|
import org.apache.poi.ss.util.CellRangeAddress; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project NewZhujiang_Server |
||||||
|
* @description 列合并 |
||||||
|
* @date 2024-06-03 10:01:07 |
||||||
|
*/ |
||||||
|
public class ExcelFillCellMergeHandler implements CellWriteHandler { |
||||||
|
private static final String KEY ="%s-%s"; |
||||||
|
//所有的合并信息都存在了这个map里面
|
||||||
|
Map<String, Integer> mergeInfo = new HashMap<>(); |
||||||
|
|
||||||
|
public ExcelFillCellMergeHandler() { |
||||||
|
} |
||||||
|
public ExcelFillCellMergeHandler(Map<String, Integer> mergeInfo) { |
||||||
|
this.mergeInfo = mergeInfo; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer integer, Integer integer1, Boolean aBoolean) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, WriteCellData<?> cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { |
||||||
|
|
||||||
|
//当前行
|
||||||
|
int curRowIndex = cell.getRowIndex(); |
||||||
|
//当前列
|
||||||
|
int curColIndex = cell.getColumnIndex(); |
||||||
|
|
||||||
|
Integer num = mergeInfo.get(String.format(KEY, curRowIndex, curColIndex)); |
||||||
|
if(null != num){ |
||||||
|
// 合并最后一行 ,列
|
||||||
|
mergeWithPrevCol(writeSheetHolder, cell, curRowIndex, curColIndex,num); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void mergeWithPrevCol(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex, int num) { |
||||||
|
Sheet sheet = writeSheetHolder.getSheet(); |
||||||
|
CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex, curRowIndex, curColIndex, curColIndex + num); |
||||||
|
sheet.addMergedRegion(cellRangeAddress); |
||||||
|
} |
||||||
|
|
||||||
|
//num从第几列开始增加多少列
|
||||||
|
// curRowIndex 在第几行进行行合并
|
||||||
|
// curColIndex 在第几列进行合并
|
||||||
|
// num 合并多少格
|
||||||
|
// 比如我上图中中心需要在第三行 从0列开始合并三列 所以我可以传入 (3,0,2)
|
||||||
|
public void add (int curRowIndex, int curColIndex , int num){ |
||||||
|
mergeInfo.put(String.format(KEY, curRowIndex, curColIndex),num); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
package com.mh.common.utils.file.handle; |
||||||
|
|
||||||
|
import com.alibaba.excel.metadata.Head; |
||||||
|
import com.alibaba.excel.write.handler.CellWriteHandler; |
||||||
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
||||||
|
import com.alibaba.excel.write.metadata.holder.WriteTableHolder; |
||||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||||
|
import org.apache.poi.ss.usermodel.Row; |
||||||
|
import org.springframework.util.PropertyPlaceholderHelper; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Properties; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project NewZhujiang_Server |
||||||
|
* @description 报表handle |
||||||
|
* @date 2024-05-31 17:36:38 |
||||||
|
*/ |
||||||
|
public class ReportSysParamHandler implements CellWriteHandler { |
||||||
|
|
||||||
|
private final String title; |
||||||
|
|
||||||
|
PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("${", "}"); |
||||||
|
|
||||||
|
public ReportSysParamHandler(String title) { |
||||||
|
this.title = title; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, |
||||||
|
Row row, Head head, Integer integer, Integer integer1, Boolean aBoolean) { |
||||||
|
if (head != null) { |
||||||
|
List<String> headNameList = head.getHeadNameList(); |
||||||
|
if (CollectionUtils.isNotEmpty(headNameList)) { |
||||||
|
Properties properties = new Properties(); |
||||||
|
properties.setProperty("deviceType", title); |
||||||
|
for (int i = 0; i < headNameList.size(); i++) { |
||||||
|
headNameList.set(i, placeholderHelper.replacePlaceholders(headNameList.get(i), properties)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
package com.mh.common.utils.file.handle; |
||||||
|
|
||||||
|
import com.alibaba.excel.write.style.row.AbstractRowHeightStyleStrategy; |
||||||
|
import org.apache.poi.ss.usermodel.Row; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project NewZhujiang_Server |
||||||
|
* @description 处理行高 |
||||||
|
* @date 2024-08-09 15:03:37 |
||||||
|
*/ |
||||||
|
public class RowHeightStyleHandler extends AbstractRowHeightStyleStrategy { |
||||||
|
@Override |
||||||
|
protected void setHeadColumnHeight(Row row, int i) { |
||||||
|
if (i == 2) { |
||||||
|
row.setHeightInPoints(70); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void setContentColumnHeight(Row row, int i) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
package com.mh.framework.netty; |
||||||
|
|
||||||
|
import io.netty.bootstrap.ServerBootstrap; |
||||||
|
import io.netty.channel.ChannelFuture; |
||||||
|
import io.netty.channel.ChannelOption; |
||||||
|
import io.netty.channel.nio.NioEventLoopGroup; |
||||||
|
import io.netty.channel.socket.nio.NioServerSocketChannel; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
@Slf4j |
||||||
|
public class EchoServer { |
||||||
|
|
||||||
|
private final int port; |
||||||
|
|
||||||
|
public EchoServer(int port) { |
||||||
|
this.port = port; |
||||||
|
} |
||||||
|
|
||||||
|
public void start() { |
||||||
|
// 创建EventLoopGroup
|
||||||
|
NioEventLoopGroup bossGroup = new NioEventLoopGroup(); |
||||||
|
NioEventLoopGroup workerGroup = new NioEventLoopGroup(); |
||||||
|
|
||||||
|
ServerBootstrap serverBootstrap = new ServerBootstrap(); |
||||||
|
serverBootstrap.group(bossGroup, workerGroup) |
||||||
|
.channel(NioServerSocketChannel.class) |
||||||
|
.localAddress(port) |
||||||
|
.option(ChannelOption.SO_BACKLOG, 1204) |
||||||
|
.childHandler(new ServerChannelInitializer()); |
||||||
|
|
||||||
|
// 异步绑定端口
|
||||||
|
ChannelFuture channelFuture = serverBootstrap.bind(); |
||||||
|
|
||||||
|
// 添加监听器处理绑定结果
|
||||||
|
channelFuture.addListener(future -> { |
||||||
|
if (future.isSuccess()) { |
||||||
|
// log.info("服务器启动成功,开始监听端口: {}", port);
|
||||||
|
} else { |
||||||
|
log.error("服务器启动失败,端口: {}", port, future.cause()); |
||||||
|
bossGroup.shutdownGracefully(); // 绑定失败立即关闭资源
|
||||||
|
workerGroup.shutdownGracefully(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
// ❌ 移除 sync() 阻塞调用
|
||||||
|
// channelFuture.channel().closeFuture().sync(); --> 删除这行
|
||||||
|
|
||||||
|
// 可选:添加 JVM 关闭钩子优雅关闭资源
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
||||||
|
// log.info("JVM 正在关闭,准备释放 Netty 资源...");
|
||||||
|
bossGroup.shutdownGracefully(); |
||||||
|
workerGroup.shutdownGracefully(); |
||||||
|
// log.info("Netty 资源已释放");
|
||||||
|
})); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,498 @@ |
|||||||
|
package com.mh.framework.netty; |
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray; |
||||||
|
import com.alibaba.fastjson2.JSONObject; |
||||||
|
import com.mh.common.constant.Constants; |
||||||
|
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||||
|
import com.mh.common.core.domain.entity.SysDictData; |
||||||
|
import com.mh.common.core.redis.RedisCache; |
||||||
|
import com.mh.common.model.request.AdvantechDatas; |
||||||
|
import com.mh.common.model.request.AdvantechReceiver; |
||||||
|
import com.mh.common.utils.*; |
||||||
|
import com.mh.common.utils.spring.SpringUtils; |
||||||
|
import com.mh.framework.netty.session.ServerSession; |
||||||
|
import com.mh.framework.netty.session.SessionMap; |
||||||
|
import com.mh.framework.netty.task.CallbackTask; |
||||||
|
//import com.mh.framework.netty.task.CallbackTaskScheduler;
|
||||||
|
import com.mh.framework.netty.task.CallbackTaskScheduler; |
||||||
|
import com.mh.framework.rabbitmq.producer.SendMsgByTopic; |
||||||
|
import com.mh.system.service.device.ICollectionParamsManageService; |
||||||
|
import com.mh.system.service.device.IGatewayManageService; |
||||||
|
import io.netty.buffer.ByteBuf; |
||||||
|
import io.netty.channel.ChannelHandlerContext; |
||||||
|
import io.netty.channel.ChannelInboundHandlerAdapter; |
||||||
|
import io.netty.handler.timeout.IdleState; |
||||||
|
import io.netty.handler.timeout.IdleStateEvent; |
||||||
|
import io.netty.util.ReferenceCountUtil; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
@Slf4j |
||||||
|
public class EchoServerHandler extends ChannelInboundHandlerAdapter { |
||||||
|
|
||||||
|
// 调用service层的接口信息
|
||||||
|
IGatewayManageService gatewayManageService = SpringUtils.getBean(IGatewayManageService.class); |
||||||
|
ICollectionParamsManageService collectionParamsManageService = SpringUtils.getBean(ICollectionParamsManageService.class); |
||||||
|
SendMsgByTopic sendMsgByTopic = SpringUtils.getBean(SendMsgByTopic.class); |
||||||
|
RedisCache redisCache = SpringUtils.getBean(RedisCache.class); |
||||||
|
|
||||||
|
/** |
||||||
|
* 空闲次数 |
||||||
|
*/ |
||||||
|
private int idleCount = 1; |
||||||
|
private int count = 0; |
||||||
|
private List<String> orderList; |
||||||
|
private int num = 0; |
||||||
|
private int size = 0; |
||||||
|
private String IP; |
||||||
|
private String port; |
||||||
|
private String receiveStr = ""; |
||||||
|
private List<CollectionParamsManage> deviceCodeParamList; |
||||||
|
|
||||||
|
/** |
||||||
|
* 客户端连接会触发 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void channelActive(ChannelHandlerContext ctx) throws Exception { |
||||||
|
// log.info("Channel active......");
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 超时处理 |
||||||
|
* 如果120秒没有接受客户端的心跳,就触发; |
||||||
|
* 如果超过3次,则直接关闭; |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void userEventTriggered(ChannelHandlerContext ctx, Object obj) throws Exception { |
||||||
|
if (obj instanceof IdleStateEvent) { |
||||||
|
IdleStateEvent event = (IdleStateEvent) obj; |
||||||
|
if (IdleState.READER_IDLE.equals(event.state())) { //如果读通道处于空闲状态,说明没有接收到心跳命令
|
||||||
|
// log.info("第{}已经40秒没有接收到客户端的信息了", idleCount);
|
||||||
|
receiveStr = ""; |
||||||
|
num = num + 1; |
||||||
|
if (num > size - 1) { |
||||||
|
num = 0; |
||||||
|
// // 关闭连接
|
||||||
|
// ctx.close();
|
||||||
|
// 继续发送下一个采集指令
|
||||||
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num),ctx,num,size); |
||||||
|
} else { |
||||||
|
// 继续发送下一个采集指令
|
||||||
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
||||||
|
} |
||||||
|
} |
||||||
|
} else { |
||||||
|
super.userEventTriggered(ctx, obj); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 对于每一个传入的消息都要被调用
|
||||||
|
@Override |
||||||
|
public void channelRead(ChannelHandlerContext ctx, Object msg) { |
||||||
|
try { |
||||||
|
//接收到服务端发来的数据进行业务处理
|
||||||
|
ByteBuf buf = (ByteBuf) msg; |
||||||
|
byte[] bytes = new byte[buf.readableBytes()]; |
||||||
|
buf.readBytes(bytes);//复制内容到字节数组bytes
|
||||||
|
buf.clear(); |
||||||
|
// 截取IP地址
|
||||||
|
IP = ExchangeStringUtil.getMidString(ctx.channel().remoteAddress() + "", "/", ":"); |
||||||
|
// 截取端口号
|
||||||
|
port = ExchangeStringUtil.getMidString(ctx.channel().remoteAddress() + "", ":", ""); |
||||||
|
if (bytes.length <= 1024) { |
||||||
|
//将接收到的数据转为字符串,此字符串就是客户端发送的字符串
|
||||||
|
receiveStr = receiveStr + ExchangeStringUtil.bytesToHexString(bytes);//将接收到的数据转为字符串,此字符串就是客户端发送的字符串
|
||||||
|
receiveStr = receiveStr.replace("null", ""); //去null
|
||||||
|
receiveStr = receiveStr.replace(" ", ""); //去空格
|
||||||
|
//// log.info("channelRead接收到的数据:" + receiveStr + ",length:" + receiveStr.length());
|
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("channelRead异常", e); |
||||||
|
} finally { |
||||||
|
ReferenceCountUtil.release(msg); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 当前批量读取中的最后一条消息
|
||||||
|
@Override |
||||||
|
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { |
||||||
|
//心跳包报文: 24 00 60 95
|
||||||
|
receiveStr = receiveStr.toUpperCase();//返回值全部变成大写
|
||||||
|
//心跳包处理
|
||||||
|
if ((receiveStr.length() == 8) && receiveStr.startsWith("24")) { |
||||||
|
// 开始进行会话保存
|
||||||
|
dealSession(ctx); |
||||||
|
idleCount = 1; |
||||||
|
port = receiveStr.substring(4, 8);//心跳包包含网关端口(自己定义返回心跳包)
|
||||||
|
// 更新对应的网关在线情况
|
||||||
|
gatewayManageService.updateGatewayStatus(receiveStr); |
||||||
|
//根据端口或者IP或者心跳包查询网关对应的项目名称
|
||||||
|
// 生成采集指令
|
||||||
|
if (!SpringUtils.getBean(RedisCache.class).hasKey(receiveStr)) { |
||||||
|
collectionParamsManageService.createDtuCollectionParams(); |
||||||
|
} |
||||||
|
JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(receiveStr); |
||||||
|
if (StringUtils.isNotNull(arrayCache)) { |
||||||
|
deviceCodeParamList = arrayCache.toList(CollectionParamsManage.class); |
||||||
|
} |
||||||
|
size = deviceCodeParamList.size(); |
||||||
|
// 清空receiveStr
|
||||||
|
receiveStr = ""; |
||||||
|
num = 0; |
||||||
|
// 发送采集报文
|
||||||
|
if (size > 0) { |
||||||
|
if (idleCount < 2) { |
||||||
|
Thread.sleep(200); |
||||||
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
||||||
|
idleCount++; |
||||||
|
} else { |
||||||
|
ctx.channel().close(); |
||||||
|
} |
||||||
|
} |
||||||
|
} else if (receiveStr.length() == 18) { |
||||||
|
// 水电表返回数据解析或者液位传感器数据返回
|
||||||
|
idleCount = 1; |
||||||
|
if (redisCache.hasKey("order_send_read")) { |
||||||
|
log.error("order_send_read存在,接收到指令是{}", receiveStr); |
||||||
|
if (redisCache.hasKey("order_send_register")) { |
||||||
|
Object orderSendRegister = redisCache.getCacheObject("order_send_register"); |
||||||
|
String orderSendRegisterStr = String.valueOf(orderSendRegister); |
||||||
|
// 根据_进行数据转换成数组
|
||||||
|
// redisCache.setCacheObject("order_send_register",
|
||||||
|
// collectionParamsManage.getMtCode() + "_"
|
||||||
|
// + collectionParamsManage.getRegisterAddr() + "_"
|
||||||
|
// + collectionParamsManage.getRegisterSize() + "_"
|
||||||
|
// + collectionParamsManage.getParamType() + "_"
|
||||||
|
// + collectionParamsManage.getDataType() + "_"
|
||||||
|
// + collectionParamsManage.getOtherName()
|
||||||
|
// );
|
||||||
|
String[] split = orderSendRegisterStr.split("_"); |
||||||
|
CollectionParamsManage collectionParamsManage = new CollectionParamsManage(); |
||||||
|
collectionParamsManage.setDataType(Integer.valueOf(split[4])); |
||||||
|
collectionParamsManage.setParamType(split[3]); |
||||||
|
collectionParamsManage.setOtherName(split[5]); |
||||||
|
collectionParamsManage.setQuality("0"); |
||||||
|
analysisReceiveData(receiveStr, collectionParamsManage); |
||||||
|
redisCache.deleteObject("order_send_read"); |
||||||
|
} |
||||||
|
} else { |
||||||
|
nextSendOrder(ctx); |
||||||
|
} |
||||||
|
} else if (receiveStr.length() == 12 || receiveStr.length() == 14) { |
||||||
|
// 热泵返回数据解析
|
||||||
|
idleCount = 1; |
||||||
|
// log.info("热泵读取接收===>{},长度:{},是否存在order_send_read: {}", receiveStr, receiveStr.length(), redisCache.hasKey("order_send_read"));
|
||||||
|
if (redisCache.hasKey("order_send_read")) { |
||||||
|
log.error("order_send_read存在,接收到指令是{}", receiveStr); |
||||||
|
if (redisCache.hasKey("order_send_register")) { |
||||||
|
Object orderSendRegister = redisCache.getCacheObject("order_send_register"); |
||||||
|
String orderSendRegisterStr = String.valueOf(orderSendRegister); |
||||||
|
// 根据_进行数据转换成数组
|
||||||
|
// redisCache.setCacheObject("order_send_register",
|
||||||
|
// collectionParamsManage.getMtCode() + "_"
|
||||||
|
// + collectionParamsManage.getRegisterAddr() + "_"
|
||||||
|
// + collectionParamsManage.getRegisterSize() + "_"
|
||||||
|
// + collectionParamsManage.getParamType() + "_"
|
||||||
|
// + collectionParamsManage.getDataType() + "_"
|
||||||
|
// + collectionParamsManage.getOtherName()
|
||||||
|
// );
|
||||||
|
String[] split = orderSendRegisterStr.split("_"); |
||||||
|
CollectionParamsManage collectionParamsManage = new CollectionParamsManage(); |
||||||
|
collectionParamsManage.setDataType(Integer.valueOf(split[4])); |
||||||
|
collectionParamsManage.setParamType(split[3]); |
||||||
|
collectionParamsManage.setOtherName(split[5]); |
||||||
|
collectionParamsManage.setQuality("0"); |
||||||
|
analysisReceiveData(receiveStr, collectionParamsManage); |
||||||
|
redisCache.deleteObject("order_send_read"); |
||||||
|
} |
||||||
|
} else { |
||||||
|
// 液位控制之类响应返回
|
||||||
|
if (receiveStr.length() == 12 && "10".equals(receiveStr.substring(2,4))) { |
||||||
|
// 液位控制返回数据解析
|
||||||
|
idleCount = 1; |
||||||
|
nextSendOrder(ctx); |
||||||
|
controlOrder(ctx); |
||||||
|
} else { |
||||||
|
nextSendOrder(ctx); |
||||||
|
} |
||||||
|
} |
||||||
|
} else if (receiveStr.length() == 16) { |
||||||
|
idleCount = 1; |
||||||
|
nextSendOrder(ctx); |
||||||
|
// 热泵设置指令返回
|
||||||
|
controlOrder(ctx); |
||||||
|
} else if (receiveStr.length() > 20 && receiveStr.length() < 100) { |
||||||
|
idleCount = 1; |
||||||
|
// 清空receiveStr
|
||||||
|
nextSendOrder(ctx); |
||||||
|
controlOrder(ctx); |
||||||
|
} |
||||||
|
ctx.flush(); |
||||||
|
} |
||||||
|
|
||||||
|
private void controlOrder(ChannelHandlerContext ctx) { |
||||||
|
// 热泵设置指令返回
|
||||||
|
if (redisCache.hasKey("order_send")) { |
||||||
|
// 判断是否有指令发送
|
||||||
|
Object orderSend = redisCache.getCacheObject("order_send"); |
||||||
|
String orderSendStr = String.valueOf(orderSend); |
||||||
|
String orderSendRegisterStr = ""; |
||||||
|
if (redisCache.hasKey("order_send_register")) { |
||||||
|
Object orderSendRegister = redisCache.getCacheObject("order_send_register"); |
||||||
|
orderSendRegisterStr = String.valueOf(orderSendRegister); |
||||||
|
// 根据_进行数据转换成数组
|
||||||
|
// redisCache.setCacheObject("order_send_register",
|
||||||
|
// collectionParamsManage.getMtCode() + "_"
|
||||||
|
// + collectionParamsManage.getRegisterAddr() + "_"
|
||||||
|
// + collectionParamsManage.getRegisterSize() + "_"
|
||||||
|
// + collectionParamsManage.getRegisterSize() + "_"
|
||||||
|
// + collectionParamsManage.getDataType()
|
||||||
|
// );
|
||||||
|
String[] split = orderSendRegisterStr.split("_"); |
||||||
|
orderSendRegisterStr = split[1]; |
||||||
|
} else { |
||||||
|
orderSendRegisterStr = orderSendStr.substring(4, 8); |
||||||
|
} |
||||||
|
String readOrder = ""; |
||||||
|
if (receiveStr.contains(orderSendStr)) { |
||||||
|
// 发送读取热泵设置温度
|
||||||
|
readOrder = ModbusUtils.createReadOrder(orderSendStr.substring(0, 2), |
||||||
|
"03", |
||||||
|
orderSendRegisterStr, |
||||||
|
"1"); |
||||||
|
|
||||||
|
} else if (receiveStr.substring(0, 8).equals(orderSendStr.substring(0, 8))){ |
||||||
|
// 发送读取液位设置值
|
||||||
|
readOrder = ModbusUtils.createReadOrder(orderSendStr.substring(0, 2), |
||||||
|
"03", |
||||||
|
orderSendRegisterStr, |
||||||
|
"2"); |
||||||
|
} |
||||||
|
// 发送读取指令
|
||||||
|
redisCache.setCacheObject("order_send_read", readOrder, 10, TimeUnit.SECONDS); |
||||||
|
ctx.writeAndFlush(ModbusUtils.createByteBuf(readOrder)); |
||||||
|
// 发送读取指令
|
||||||
|
log.error("热泵设置读取指令发送:{},order_send_read键值:{}", readOrder, redisCache.hasKey("order_send_read")); |
||||||
|
log.error("热泵设置指令返回:{}", receiveStr); |
||||||
|
NettyTools.setReceiveMsg("order_wait", receiveStr); |
||||||
|
redisCache.deleteObject("order_send"); |
||||||
|
receiveStr = ""; |
||||||
|
try { |
||||||
|
Thread.sleep(500); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
throw new RuntimeException(e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void dealSession(ChannelHandlerContext ctx) { |
||||||
|
// 获取表号
|
||||||
|
String deviceCode =receiveStr; |
||||||
|
String meterNum = deviceCode; |
||||||
|
deviceCode = deviceCode + ctx.channel().remoteAddress(); |
||||||
|
//新的session的创建
|
||||||
|
ServerSession session = new ServerSession(ctx.channel(), deviceCode); |
||||||
|
|
||||||
|
//进行登录逻辑处理,异步进行处理。并且需要知道 处理的结果。 callbacktask就要
|
||||||
|
//派上用场了
|
||||||
|
String finalDeviceCode = deviceCode; |
||||||
|
CallbackTaskScheduler.add(new CallbackTask<Boolean>() { |
||||||
|
@Override |
||||||
|
public Boolean execute() throws Exception { |
||||||
|
//进行 login 逻辑的处理
|
||||||
|
return action(session, finalDeviceCode, ctx); |
||||||
|
} |
||||||
|
//没有异常的话,我们进行处理
|
||||||
|
@Override |
||||||
|
public void onBack(Boolean result) { |
||||||
|
if(result) { |
||||||
|
// log.info("设备保存会话: 设备号 = " + session.getSessionId());
|
||||||
|
//ctx.pipeline().remove(LoginRequestHandler.class); //压测需要放开
|
||||||
|
} else { |
||||||
|
// log.info("设备刷新会话: 设备号 = " + session.getSessionId());
|
||||||
|
SessionMap.inst().updateSession(finalDeviceCode ,session, meterNum); |
||||||
|
//// log.info("设备登录失败: 设备号 = " + session.getSessionId());
|
||||||
|
//ServerSession.closeSession(ctx);
|
||||||
|
// 假如说已经在会话中了,直接断开连接
|
||||||
|
//ctx.close();
|
||||||
|
} |
||||||
|
} |
||||||
|
//有异常的话,我们进行处理
|
||||||
|
@Override |
||||||
|
public void onException(Throwable t) { |
||||||
|
// log.info("设备登录异常: 设备号 = " + session.getSessionId());
|
||||||
|
ServerSession.closeSession(ctx); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
private void nextSendOrder(ChannelHandlerContext ctx) throws InterruptedException { |
||||||
|
// 发送指令响应不用解析
|
||||||
|
if (receiveStr.length() != 16 && receiveStr.length() < 20) { |
||||||
|
// 解析采集的报文,并保存到数据库
|
||||||
|
analysisReceiveData(receiveStr, deviceCodeParamList.get(num)); |
||||||
|
} |
||||||
|
// 判断是否有远程指令发送,如果有先不采集
|
||||||
|
if (redisCache.hasKey("order_send")) { |
||||||
|
log.error("有远程设置指令发送,不进行采集"); |
||||||
|
return; |
||||||
|
} |
||||||
|
// 清空receiveStr
|
||||||
|
receiveStr = ""; |
||||||
|
// 判断发送的下标,如果不等于指令数组大小
|
||||||
|
num = num + 1; |
||||||
|
if (num > size - 1) { |
||||||
|
num = 0; |
||||||
|
Thread.sleep(1000); |
||||||
|
// 继续发送下一个采集指令
|
||||||
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
||||||
|
// log.info("------一轮采集完成,继续下一轮--------");
|
||||||
|
} else { |
||||||
|
// 添加一个状态值,判断是否继续发送指令 update by ljf on 2020-08-07
|
||||||
|
if (Constants.WEB_FLAG) { |
||||||
|
num = 0; |
||||||
|
// 关闭连接
|
||||||
|
receiveStr = null; |
||||||
|
ctx.close(); |
||||||
|
} else { |
||||||
|
Thread.sleep(1000); |
||||||
|
// 继续发送下一个采集指令
|
||||||
|
SendOrderUtils.sendAllOrder(deviceCodeParamList.get(num), ctx, num, size); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void analysisReceiveData(final String receiveStr, final CollectionParamsManage deviceCodeParamEntity) { |
||||||
|
AnalysisReceiveOrder485 analysisReceiveOrder485 = new AnalysisReceiveOrder485(); |
||||||
|
String analysisData = ""; |
||||||
|
switch (deviceCodeParamEntity.getParamType()) { |
||||||
|
case "16" -> |
||||||
|
// 电表
|
||||||
|
analysisData = analysisReceiveOrder485.analysisMeterOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "18" -> |
||||||
|
// 水表
|
||||||
|
analysisData = analysisReceiveOrder485.analysisWaterOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "5" -> |
||||||
|
// 热泵故障报警
|
||||||
|
analysisData = analysisReceiveOrder485.analysisHeatPumpOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "2" -> |
||||||
|
// 热泵启停控制
|
||||||
|
analysisData = analysisReceiveOrder485.analysisHeatPumpOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "12" -> { |
||||||
|
if (deviceCodeParamEntity.getMtType().equals("8")) { |
||||||
|
// 温湿度传感器
|
||||||
|
analysisData = analysisReceiveOrder485.analysisTempHumiditySensorOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
} else { |
||||||
|
// 热泵实际温度
|
||||||
|
analysisData = analysisReceiveOrder485.analysisHeatPumpOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
case "14" -> |
||||||
|
// 热泵读取温度设置
|
||||||
|
analysisData = analysisReceiveOrder485.analysisHeatPumpOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "48" -> |
||||||
|
// 热泵读取电流
|
||||||
|
analysisData = analysisReceiveOrder485.analysisHeatPumpOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "11" -> { |
||||||
|
// 液位设定值
|
||||||
|
if (deviceCodeParamEntity.getMtType().equals("11")) { |
||||||
|
analysisData = analysisReceiveOrder485.analysisLiquidControlOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
} else { |
||||||
|
// 液位计
|
||||||
|
analysisData = analysisReceiveOrder485.analysisLiquidOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
case "13" -> |
||||||
|
// 压力
|
||||||
|
analysisData = analysisReceiveOrder485.analysisTempHumiditySensorOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "35" -> |
||||||
|
// 湿度
|
||||||
|
analysisData = analysisReceiveOrder485.analysisTempHumiditySensorOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
case "10" -> { |
||||||
|
// 液位设定值
|
||||||
|
if (deviceCodeParamEntity.getMtType().equals("11")) { |
||||||
|
// 液位设定值
|
||||||
|
analysisData = analysisReceiveOrder485.analysisLiquidControlOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
case "46" -> { |
||||||
|
// 液位误差值设置
|
||||||
|
if (deviceCodeParamEntity.getMtType().equals("11")) { |
||||||
|
// 液位误差设定值
|
||||||
|
analysisData = analysisReceiveOrder485.analysisLiquidControlOrder485(receiveStr, deviceCodeParamEntity); |
||||||
|
} |
||||||
|
} |
||||||
|
default -> { |
||||||
|
// log.info("设备类型错误");
|
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
if (analysisData.isEmpty()) { |
||||||
|
// log.info("解析数据为空");
|
||||||
|
return; |
||||||
|
} |
||||||
|
// 格式化数据,配置成研华网关 AdvantechReceiver
|
||||||
|
AdvantechReceiver advantechReceiver = new AdvantechReceiver(); |
||||||
|
advantechReceiver.setTs(DateUtils.dateToString(new Date(), Constants.DATE_FORMAT)); |
||||||
|
List<AdvantechDatas> advantechDatas = new ArrayList<>(); |
||||||
|
AdvantechDatas datas = new AdvantechDatas(); |
||||||
|
datas.setValue(new BigDecimal(analysisData)); |
||||||
|
datas.setTag(deviceCodeParamEntity.getOtherName()); |
||||||
|
datas.setQuality(0); |
||||||
|
advantechDatas.add(datas); |
||||||
|
advantechReceiver.setD(advantechDatas); |
||||||
|
// log.error("接收到的指令==》{},发送数据到MQTT==》{}", receiveStr, JSONObject.toJSONString(advantechReceiver));
|
||||||
|
sendMsgByTopic.sendToDeviceMQ(JSONObject.toJSONString(advantechReceiver)); |
||||||
|
// 判断otherName的值
|
||||||
|
if ("2".equals(deviceCodeParamEntity.getGatewayId()) && deviceCodeParamEntity.getOtherName().contains("实际温度")) { |
||||||
|
datas = new AdvantechDatas(); |
||||||
|
advantechDatas.clear(); |
||||||
|
datas.setValue(new BigDecimal(analysisData)); |
||||||
|
datas.setTag("贵宾楼水箱-温度"); |
||||||
|
datas.setQuality(0); |
||||||
|
advantechDatas.add(datas); |
||||||
|
advantechReceiver.setD(advantechDatas); |
||||||
|
sendMsgByTopic.sendToDeviceMQ(JSONObject.toJSONString(advantechReceiver)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 异常捕捉
|
||||||
|
@Override |
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { |
||||||
|
cause.getCause().printStackTrace(); |
||||||
|
// log.info("异常捕捉,执行ctx.close" + cause.getCause());
|
||||||
|
ctx.close(); // 关闭该Channel
|
||||||
|
} |
||||||
|
|
||||||
|
// 客户端断开
|
||||||
|
@Override |
||||||
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception { |
||||||
|
ctx.close();// 关闭流
|
||||||
|
// log.info("客户端断开,执行ctx.close()......");
|
||||||
|
} |
||||||
|
|
||||||
|
private boolean action(ServerSession session, String deviceCode, ChannelHandlerContext ctx) { |
||||||
|
//user验证
|
||||||
|
boolean isValidUser = checkUser(deviceCode,session); |
||||||
|
session.bind(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
private boolean checkUser(String deviceCode,ServerSession session) { |
||||||
|
//当前用户已经登录
|
||||||
|
if(SessionMap.inst().hasLogin(deviceCode)) { |
||||||
|
// log.info("设备已经登录: 设备号 = " + deviceCode);
|
||||||
|
return false; |
||||||
|
} |
||||||
|
//一般情况下,我们会将 user存储到 DB中,然后对user的用户名和密码进行校验
|
||||||
|
//但是,我们这边没有进行db的集成,所以我们想一个别的办法进行user的校验。在我们的sessionMap进行以下校验
|
||||||
|
//为什么选sessionmap,因为我们user的会话,都是存储到sessionmap中的,sessionmap中只要有这个user的会话,说明就是ok的
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
package com.mh.framework.netty; |
||||||
|
|
||||||
|
import com.mh.common.core.domain.entity.OrderEntity; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description netty |
||||||
|
* @date 2025-06-06 15:13:06 |
||||||
|
*/ |
||||||
|
public interface INettyService { |
||||||
|
|
||||||
|
boolean sendOrder(List<OrderEntity> changeValues); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,147 @@ |
|||||||
|
package com.mh.framework.netty; |
||||||
|
|
||||||
|
import com.mh.common.core.domain.AjaxResult; |
||||||
|
import com.mh.common.core.domain.entity.CollectionParamsManage; |
||||||
|
import com.mh.common.core.domain.entity.GatewayManage; |
||||||
|
import com.mh.common.core.domain.entity.OrderEntity; |
||||||
|
import com.mh.common.core.redis.RedisCache; |
||||||
|
import com.mh.common.core.redis.RedisLock; |
||||||
|
import com.mh.common.utils.ModbusUtils; |
||||||
|
import com.mh.common.utils.NettyTools; |
||||||
|
import com.mh.common.utils.StringUtils; |
||||||
|
import com.mh.framework.netty.session.ServerSession; |
||||||
|
import com.mh.framework.netty.session.SessionMap; |
||||||
|
import com.mh.system.mapper.device.CollectionParamsManageMapper; |
||||||
|
import com.mh.system.mapper.device.GatewayManageMapper; |
||||||
|
import jakarta.annotation.Resource; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Set; |
||||||
|
import java.util.UUID; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project EEMCS |
||||||
|
* @description netty实现类 |
||||||
|
* @date 2025-06-06 15:13:23 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
@Service |
||||||
|
public class NettyServiceImpl implements INettyService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private CollectionParamsManageMapper collectionParamsManageMapper; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private GatewayManageMapper gatewayManageMapper; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private RedisCache redisCache; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private RedisLock redisLock; |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean sendOrder(List<OrderEntity> changeValues) { |
||||||
|
for (OrderEntity changeValue : changeValues) { |
||||||
|
String cpmId = changeValue.getId(); |
||||||
|
CollectionParamsManage collectionParamsManage = collectionParamsManageMapper.selectById(cpmId); |
||||||
|
if (null == collectionParamsManage) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
GatewayManage gatewayManage = gatewayManageMapper.selectById(collectionParamsManage.getGatewayId()); |
||||||
|
if (null == gatewayManage || StringUtils.isEmpty(gatewayManage.getHeartBeat())) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
ConcurrentHashMap<String, ServerSession> map = SessionMap.inst().getMap(); |
||||||
|
Set<Map.Entry<String, ServerSession>> entries = map.entrySet(); |
||||||
|
boolean flag = false; |
||||||
|
String keyVal = null; |
||||||
|
for (Map.Entry<String, ServerSession> entry : entries) { |
||||||
|
String key = entry.getKey(); |
||||||
|
if (key.contains(gatewayManage.getHeartBeat())){ |
||||||
|
flag = true; |
||||||
|
keyVal = key; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
if (flag) { |
||||||
|
ServerSession serverSession = map.get(keyVal); |
||||||
|
String controlCode = ""; |
||||||
|
// 增加了液位控制仪
|
||||||
|
if ("11".equals(collectionParamsManage.getMtType())) { |
||||||
|
controlCode = ModbusUtils.createTenControlCode(collectionParamsManage.getMtCode(), |
||||||
|
changeValue.getType(), |
||||||
|
collectionParamsManage.getRegisterAddr(), |
||||||
|
collectionParamsManage.getDigits(), |
||||||
|
changeValue.getParam()); |
||||||
|
} else { |
||||||
|
// 目前只有DTU,modbus方式,只创建modbus先
|
||||||
|
controlCode = ModbusUtils.createControlCode(collectionParamsManage.getMtCode(), |
||||||
|
changeValue.getType(), |
||||||
|
collectionParamsManage.getRegisterAddr(), |
||||||
|
changeValue.getParam()); |
||||||
|
} |
||||||
|
if (StringUtils.isEmpty(controlCode)) { |
||||||
|
log.error("创建控制码失败"); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
String requestId = UUID.randomUUID().toString(); // 唯一标识当前请求
|
||||||
|
String lockKey = "lock:order_send:" + gatewayManage.getHeartBeat(); // 按网关分锁
|
||||||
|
|
||||||
|
try { |
||||||
|
if (!redisLock.tryLock(lockKey, requestId, 10, 10)) { |
||||||
|
log.warn("获取锁失败,当前操作繁忙"); |
||||||
|
return false; |
||||||
|
} |
||||||
|
// 初始化发送指令
|
||||||
|
NettyTools.initReceiveMsg("order_wait"); |
||||||
|
// 设置缓存,方便在netty中判断发送的指令
|
||||||
|
redisCache.setCacheObject("order_send", controlCode, 10, TimeUnit.SECONDS); |
||||||
|
redisCache.setCacheObject("order_send_register", |
||||||
|
collectionParamsManage.getMtCode() + "_" |
||||||
|
+ collectionParamsManage.getRegisterAddr() + "_" |
||||||
|
+ collectionParamsManage.getRegisterSize() + "_" |
||||||
|
+ collectionParamsManage.getParamType() + "_" |
||||||
|
+ collectionParamsManage.getDataType() + "_" |
||||||
|
+ collectionParamsManage.getOtherName() |
||||||
|
); |
||||||
|
Thread.sleep(500); |
||||||
|
// 发送控制指令
|
||||||
|
// 会话通道
|
||||||
|
log.error("会话:{},通道:{},id:{}", serverSession, serverSession.getChannel(), serverSession.getSessionId()); |
||||||
|
serverSession.getChannel().writeAndFlush(ModbusUtils.createByteBuf(controlCode)); |
||||||
|
// 等待指令
|
||||||
|
if (NettyTools.waitReceiveMsg("order_wait")) { |
||||||
|
// 初始化发送指令
|
||||||
|
Thread.sleep(3000); |
||||||
|
return true; |
||||||
|
// if (NettyTools.waitReceiveMsg("order_wait_read")) {
|
||||||
|
// return true;
|
||||||
|
// } else {
|
||||||
|
// log.error("读取指令异常,心跳包:{}", gatewayManage.getHeartBeat());
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
} else { |
||||||
|
log.error("发送指令异常,心跳包:{}", gatewayManage.getHeartBeat()); |
||||||
|
return false; |
||||||
|
} |
||||||
|
} catch (InterruptedException e) { |
||||||
|
log.error("发送指令异常", e); |
||||||
|
} finally { |
||||||
|
redisLock.unlock(lockKey, requestId); |
||||||
|
} |
||||||
|
} |
||||||
|
log.error("当前设备不在线,心跳包:{}",gatewayManage.getHeartBeat()); |
||||||
|
return false; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,33 @@ |
|||||||
|
package com.mh.framework.netty; |
||||||
|
|
||||||
|
import io.netty.channel.ChannelInitializer; |
||||||
|
import io.netty.channel.ChannelPipeline; |
||||||
|
import io.netty.channel.socket.SocketChannel; |
||||||
|
import io.netty.handler.timeout.IdleStateHandler; |
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
public class ServerChannelInitializer extends ChannelInitializer<SocketChannel>{ |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initChannel(SocketChannel socketChannel) throws Exception { |
||||||
|
ChannelPipeline pipeline = socketChannel.pipeline(); |
||||||
|
|
||||||
|
/* LineBasedFrameDecoder的工作原理是:依次遍历ByteBuf中的可读字节, |
||||||
|
判断看其是否有”\n” 或 “\r\n”, 如果有就以此位置为结束位置。 |
||||||
|
从可读索引到结束位置的区间的字节就组成了一行。 它是以换行符为结束标志的解码器, |
||||||
|
支持携带结束符和不带结束符两种解码方式,同时支持配置单行的最大长度, |
||||||
|
如果读到了最大长度之后仍然没有发现换行符,则抛出异常,同时忽略掉之前读到的异常码流。*/ |
||||||
|
// pipeline.addLast(new LineBasedFrameDecoder(10010));
|
||||||
|
//字符串解码和编码
|
||||||
|
//LineBasedFrameDecoder + StringDecoder 就是一个按行切换的文本解码器。
|
||||||
|
// pipeline.addLast( new StringDecoder());
|
||||||
|
// pipeline.addLast( new StringEncoder());
|
||||||
|
// 设置读写超时操作
|
||||||
|
// 入参说明: 读超时时间、写超时时间、所有类型的超时时间、时间格式
|
||||||
|
pipeline.addLast(new IdleStateHandler(40, 40, 40, TimeUnit.SECONDS)); |
||||||
|
//服务器的逻辑
|
||||||
|
pipeline.addLast("handler", new EchoServerHandler()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,66 @@ |
|||||||
|
package com.mh.framework.netty.session; |
||||||
|
|
||||||
|
import io.netty.channel.Channel; |
||||||
|
import io.netty.channel.ChannelFuture; |
||||||
|
import io.netty.channel.ChannelFutureListener; |
||||||
|
import io.netty.channel.ChannelHandlerContext; |
||||||
|
import io.netty.util.AttributeKey; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
@Data |
||||||
|
@Slf4j |
||||||
|
public class ServerSession { |
||||||
|
public static final AttributeKey<ServerSession> SESSION_KEY = |
||||||
|
AttributeKey.valueOf("SESSION_KEY"); |
||||||
|
//通道
|
||||||
|
private Channel channel; |
||||||
|
private final String sessionId; |
||||||
|
private boolean isLogin = false; |
||||||
|
|
||||||
|
public ServerSession(Channel channel, String deviceCode){ |
||||||
|
this.channel = channel; |
||||||
|
this.sessionId = deviceCode; |
||||||
|
} |
||||||
|
|
||||||
|
//session需要和通道进行一定的关联,他是在构造函数中关联上的;
|
||||||
|
//session还需要通过sessionkey和channel进行再次的关联;channel.attr方法.set当前的
|
||||||
|
// serverSession
|
||||||
|
//session需要被添加到我们的SessionMap中
|
||||||
|
public void bind(){ |
||||||
|
// log.info("server Session 会话进行绑定 :" + channel.remoteAddress());
|
||||||
|
channel.attr(SESSION_KEY).set(this); |
||||||
|
SessionMap.inst().addSession(sessionId, this); |
||||||
|
this.isLogin = true; |
||||||
|
} |
||||||
|
|
||||||
|
//通过channel获取session
|
||||||
|
public static ServerSession getSession(ChannelHandlerContext ctx){ |
||||||
|
Channel channel = ctx.channel(); |
||||||
|
return channel.attr(SESSION_KEY).get(); |
||||||
|
} |
||||||
|
|
||||||
|
//关闭session,新增返回一个meterNum用于纪录设备下线时间2024-05-08
|
||||||
|
public static String closeSession(ChannelHandlerContext ctx){ |
||||||
|
String meterNum = null; |
||||||
|
ServerSession serverSession = ctx.channel().attr(SESSION_KEY).get(); |
||||||
|
if(serverSession != null && serverSession.getSessionId() != null) { |
||||||
|
ChannelFuture future = serverSession.channel.close(); |
||||||
|
future.addListener((ChannelFutureListener) future1 -> { |
||||||
|
if(!future1.isSuccess()) { |
||||||
|
// log.info("Channel close error!");
|
||||||
|
} |
||||||
|
}); |
||||||
|
ctx.close(); |
||||||
|
meterNum = serverSession.sessionId; |
||||||
|
SessionMap.inst().removeSession(serverSession.sessionId); |
||||||
|
// log.info(ctx.channel().remoteAddress()+" "+serverSession.sessionId + "==>移除会话");
|
||||||
|
} |
||||||
|
return meterNum; |
||||||
|
} |
||||||
|
|
||||||
|
//写消息
|
||||||
|
public void writeAndFlush(Object msg) { |
||||||
|
channel.writeAndFlush(msg); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,96 @@ |
|||||||
|
package com.mh.framework.netty.session; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
|
||||||
|
import java.util.Iterator; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
@Data |
||||||
|
@Slf4j |
||||||
|
public class SessionMap { |
||||||
|
|
||||||
|
private ThreadLocal<Boolean> sceneThreadLocal = new ThreadLocal<>(); |
||||||
|
|
||||||
|
//用单例模式进行sessionMap的创建
|
||||||
|
private SessionMap(){} |
||||||
|
|
||||||
|
private static SessionMap singleInstance = new SessionMap(); |
||||||
|
|
||||||
|
public static SessionMap inst() { |
||||||
|
return singleInstance; |
||||||
|
} |
||||||
|
|
||||||
|
//进行会话的保存
|
||||||
|
//key 我们使用 sessionId;value 需要是 serverSession
|
||||||
|
private ConcurrentHashMap<String, ServerSession> map = new ConcurrentHashMap<>(256); |
||||||
|
//添加session
|
||||||
|
public void addSession(String sessionId, ServerSession s) { |
||||||
|
map.put(sessionId, s); |
||||||
|
// log.info("IP地址:"+s.getChannel().remoteAddress()+" "+ sessionId + " 表具上线,总共表具:" + map.size());
|
||||||
|
} |
||||||
|
|
||||||
|
//删除session
|
||||||
|
public void removeSession(String sessionId) { |
||||||
|
if(map.containsKey(sessionId)) { |
||||||
|
ServerSession s = map.get(sessionId); |
||||||
|
map.remove(sessionId); |
||||||
|
// log.info("设备id下线:{},在线设备:{}", s.getSessionId(), map.size() );
|
||||||
|
} |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean hasLogin(String sessionId) { |
||||||
|
Iterator<Map.Entry<String, ServerSession>> iterator = map.entrySet().iterator(); |
||||||
|
while(iterator.hasNext()) { |
||||||
|
Map.Entry<String, ServerSession> next = iterator.next(); |
||||||
|
if(sessionId != null && sessionId.equalsIgnoreCase(next.getValue().getSessionId())) { |
||||||
|
return true ; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
//如果在线,肯定有sessionMap里保存的 serverSession
|
||||||
|
//如果不在线,serverSession也没有。用这个来判断是否在线
|
||||||
|
public List<ServerSession> getSessionBy(String sessionId) { |
||||||
|
return map.values().stream(). |
||||||
|
filter(s -> s.getSessionId().equals(sessionId)). |
||||||
|
collect(Collectors.toList()); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean getScene() { |
||||||
|
return sceneThreadLocal.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void initScene(Boolean status) { |
||||||
|
if (sceneThreadLocal == null) { |
||||||
|
// log.info("======创建ThreadLocal======");
|
||||||
|
sceneThreadLocal = new ThreadLocal<>(); |
||||||
|
} |
||||||
|
// log.info("设置状态==>" + status);
|
||||||
|
sceneThreadLocal.set(status); |
||||||
|
} |
||||||
|
|
||||||
|
public void clearScene() { |
||||||
|
initScene(null); |
||||||
|
sceneThreadLocal.remove(); |
||||||
|
} |
||||||
|
|
||||||
|
public void updateSession(String sessionId, ServerSession session, String meterNum) { |
||||||
|
Iterator<Map.Entry<String, ServerSession>> iterator = map.entrySet().iterator(); |
||||||
|
while(iterator.hasNext()) { |
||||||
|
Map.Entry<String, ServerSession> next = iterator.next(); |
||||||
|
if (next.getKey().contains(meterNum)){ |
||||||
|
iterator.remove(); |
||||||
|
} |
||||||
|
if(sessionId != null && sessionId.equalsIgnoreCase(next.getValue().getSessionId())) { |
||||||
|
next.setValue(session); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
package com.mh.framework.netty.task; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project TAD_Server |
||||||
|
* @description 回调任务 |
||||||
|
* @date 2023/7/3 15:34:11 |
||||||
|
*/ |
||||||
|
public interface CallbackTask<T> { |
||||||
|
T execute() throws Exception; |
||||||
|
|
||||||
|
/** |
||||||
|
* // 执行没有 异常的情况下的 返回值
|
||||||
|
* @param t |
||||||
|
*/ |
||||||
|
void onBack(T t); |
||||||
|
|
||||||
|
void onException(Throwable t); |
||||||
|
} |
||||||
@ -0,0 +1,78 @@ |
|||||||
|
package com.mh.framework.netty.task; |
||||||
|
|
||||||
|
import com.google.common.util.concurrent.*; |
||||||
|
|
||||||
|
import java.util.concurrent.*; |
||||||
|
import java.util.concurrent.atomic.AtomicBoolean; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project TAD_Server |
||||||
|
* @description 回调任务 |
||||||
|
* @date 2023/7/3 15:34:11 |
||||||
|
*/ |
||||||
|
public class CallbackTaskScheduler extends Thread { |
||||||
|
private final BlockingQueue<CallbackTask> executeTaskQueue = |
||||||
|
new LinkedBlockingQueue<>(); |
||||||
|
private final ExecutorService pool = Executors.newCachedThreadPool(); |
||||||
|
private final ListeningExecutorService lpool = MoreExecutors.listeningDecorator(pool); |
||||||
|
private static CallbackTaskScheduler inst = new CallbackTaskScheduler(); |
||||||
|
private final AtomicBoolean running = new AtomicBoolean(true); |
||||||
|
|
||||||
|
private CallbackTaskScheduler() { |
||||||
|
this.start(); |
||||||
|
} |
||||||
|
|
||||||
|
//add task
|
||||||
|
public static <T> void add(CallbackTask<T> executeTask) { |
||||||
|
inst.executeTaskQueue.offer(executeTask); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
while (running.get()) { |
||||||
|
handleTask(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 停止调度器 |
||||||
|
*/ |
||||||
|
public static void shutdown() { |
||||||
|
inst.running.set(false); |
||||||
|
inst.pool.shutdown(); |
||||||
|
} |
||||||
|
|
||||||
|
//任务执行
|
||||||
|
private void handleTask() { |
||||||
|
try { |
||||||
|
// 使用 take() 阻塞等待,直到有任务
|
||||||
|
CallbackTask executeTask = executeTaskQueue.take(); |
||||||
|
handleTask(executeTask); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
Thread.currentThread().interrupt(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private <T> void handleTask(CallbackTask<T> executeTask) { |
||||||
|
ListenableFuture<T> future = lpool.submit(new Callable<T>() { |
||||||
|
public T call() throws Exception { |
||||||
|
return executeTask.execute(); |
||||||
|
} |
||||||
|
}); |
||||||
|
Futures.addCallback(future, new FutureCallback<T>() { |
||||||
|
@Override |
||||||
|
public void onSuccess(T t) { |
||||||
|
executeTask.onBack(t); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void onFailure(Throwable throwable) { |
||||||
|
executeTask.onException(throwable); |
||||||
|
} |
||||||
|
}, lpool); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
@ -0,0 +1,6 @@ |
|||||||
|
package com.mh.framework.netty.task; |
||||||
|
|
||||||
|
//不需要知道异步线程的 返回值
|
||||||
|
public interface ExecuteTask { |
||||||
|
void execute(); |
||||||
|
} |
||||||
@ -0,0 +1,67 @@ |
|||||||
|
package com.mh.framework.netty.task; |
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue; |
||||||
|
import java.util.concurrent.ExecutorService; |
||||||
|
import java.util.concurrent.Executors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project TAD_Server |
||||||
|
* @description 任务定时 |
||||||
|
* @date 2023/7/3 15:34:11 |
||||||
|
*/ |
||||||
|
public class FutureTaskScheduler extends Thread{ |
||||||
|
private ConcurrentLinkedQueue<ExecuteTask> executeTaskQueue = |
||||||
|
new ConcurrentLinkedQueue<>(); |
||||||
|
private long sleepTime = 200; |
||||||
|
private ExecutorService pool = Executors.newFixedThreadPool(10); |
||||||
|
private static FutureTaskScheduler inst = new FutureTaskScheduler(); |
||||||
|
public FutureTaskScheduler() { |
||||||
|
this.start(); |
||||||
|
} |
||||||
|
//任务添加
|
||||||
|
public static void add(ExecuteTask executeTask) { |
||||||
|
inst.executeTaskQueue.add(executeTask); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
while (true) { |
||||||
|
handleTask(); |
||||||
|
//threadSleep(sleepTime);
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void threadSleep(long sleepTime) { |
||||||
|
try { |
||||||
|
Thread.sleep(sleepTime); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
//执行任务
|
||||||
|
private void handleTask() { |
||||||
|
ExecuteTask executeTask; |
||||||
|
while (executeTaskQueue.peek() != null) { |
||||||
|
executeTask = executeTaskQueue.poll(); |
||||||
|
handleTask(executeTask); |
||||||
|
} |
||||||
|
//刷新心跳时间
|
||||||
|
} |
||||||
|
private void handleTask(ExecuteTask executeTask) { |
||||||
|
pool.execute(new ExecuteRunnable(executeTask)); |
||||||
|
} |
||||||
|
|
||||||
|
class ExecuteRunnable implements Runnable { |
||||||
|
ExecuteTask executeTask; |
||||||
|
public ExecuteRunnable(ExecuteTask executeTask) { |
||||||
|
this.executeTask = executeTask; |
||||||
|
} |
||||||
|
@Override |
||||||
|
public void run() { |
||||||
|
executeTask.execute(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue