From 1de4906d90e268579128b9fae911ea48c6f22469 Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Wed, 25 Oct 2023 09:16:47 +0800 Subject: [PATCH] chore:新五分钟数据接口 --- screen-api/src/main/java/com/moral/api/controller/HistoryFiveMinutelyController.java | 15 +++++ screen-api/src/main/java/com/moral/api/service/HistoryFiveMinutelyService.java | 4 + screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java | 57 +++++++++++++++++++ screen-api/src/main/java/com/moral/api/pojo/vo/historyFiveMinutely/QueryFiveDataByMacVO.java | 47 +++++++++++++++ 4 files changed, 123 insertions(+), 0 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/controller/HistoryFiveMinutelyController.java b/screen-api/src/main/java/com/moral/api/controller/HistoryFiveMinutelyController.java index c1a60d8..615fe10 100644 --- a/screen-api/src/main/java/com/moral/api/controller/HistoryFiveMinutelyController.java +++ b/screen-api/src/main/java/com/moral/api/controller/HistoryFiveMinutelyController.java @@ -1,20 +1,25 @@ package com.moral.api.controller; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.moral.api.pojo.dto.historyFiveMinutely.DeviceAndFiveMinuteDataDTO; import com.moral.api.pojo.form.historyFiveMinutely.QueryDeviceAndFiveMinuteDataForm; import com.moral.api.pojo.vo.historyFiveMinutely.DeviceAndFiveMinuteDataVO; +import com.moral.api.pojo.vo.historyFiveMinutely.QueryFiveDataByMacVO; import com.moral.api.service.HistoryFiveMinutelyService; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; import com.moral.util.WebUtils; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; @@ -81,6 +86,16 @@ } return ResultMessage.ok(popDataByMac); } + + + @GetMapping("queryFiveDataByMac") + @ApiOperation("������������������������") + public ResultMessage queryFiveDataByMac(@RequestParam @ApiParam(value = "mac",name = "mac���") String mac, + @RequestParam @ApiParam(value = "chooseTime",name = "������������������") String chooseTime, + @RequestParam @ApiParam(value = "time",name = "������") String time){ + QueryFiveDataByMacVO queryFiveDataByMacVO = historyFiveMinutelyService.queryFiveDataByMac(mac, chooseTime, time); + return ResultMessage.ok(ObjectUtils.isEmpty(queryFiveDataByMacVO)?"0":queryFiveDataByMacVO); + } } diff --git a/screen-api/src/main/java/com/moral/api/pojo/vo/historyFiveMinutely/QueryFiveDataByMacVO.java b/screen-api/src/main/java/com/moral/api/pojo/vo/historyFiveMinutely/QueryFiveDataByMacVO.java new file mode 100644 index 0000000..d927c65 --- /dev/null +++ b/screen-api/src/main/java/com/moral/api/pojo/vo/historyFiveMinutely/QueryFiveDataByMacVO.java @@ -0,0 +1,47 @@ +package com.moral.api.pojo.vo.historyFiveMinutely; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="QueryFiveDataByMacVO - ���������������", description="QueryFiveDataByMacVO - ���������������") +public class QueryFiveDataByMacVO implements Serializable{ + + @ApiModelProperty(value = "������������") + private String name; + + @ApiModelProperty(value = "������") + private String dataTime; + + @ApiModelProperty(value = "pm25") + private String a34004; + + @ApiModelProperty(value = "pm10") + private String a34002; + + @ApiModelProperty(value = "������������") + private String a21026; + + @ApiModelProperty(value = "������������") + private String a21004; + + @ApiModelProperty(value = "������������") + private String a21005; + + @ApiModelProperty(value = "������") + private String a05024; + + @ApiModelProperty(value = "������") + private String a01008; + + @ApiModelProperty(value = "������") + private String a01007; +} diff --git a/screen-api/src/main/java/com/moral/api/service/HistoryFiveMinutelyService.java b/screen-api/src/main/java/com/moral/api/service/HistoryFiveMinutelyService.java index 5ad395a..b46372f 100644 --- a/screen-api/src/main/java/com/moral/api/service/HistoryFiveMinutelyService.java +++ b/screen-api/src/main/java/com/moral/api/service/HistoryFiveMinutelyService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.moral.api.pojo.dto.historyFiveMinutely.DeviceAndFiveMinuteDataDTO; import com.moral.api.pojo.form.historyFiveMinutely.QueryDeviceAndFiveMinuteDataForm; +import com.moral.api.pojo.vo.historyFiveMinutely.QueryFiveDataByMacVO; import java.util.Date; import java.util.List; @@ -49,4 +50,7 @@ */ Map<String,Object> getPopDataByMac(Map<String, Object> params); + + QueryFiveDataByMacVO queryFiveDataByMac(String name,String chooseTime,String time); + } diff --git a/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java index a127858..36cffd6 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java @@ -17,6 +17,7 @@ import com.moral.api.pojo.ext.wind.WindListExt; import com.moral.api.pojo.form.device.MonitorPointQueryForm; import com.moral.api.pojo.form.historyFiveMinutely.QueryDeviceAndFiveMinuteDataForm; +import com.moral.api.pojo.vo.historyFiveMinutely.QueryFiveDataByMacVO; import com.moral.api.pojo.vo.user.QxUser; import com.moral.api.service.DeviceService; import com.moral.api.service.HistoryFiveMinutelyService; @@ -250,6 +251,62 @@ return orderSixParam(result); } + @Override + public QueryFiveDataByMacVO queryFiveDataByMac(String mac, String chooseTime, String time) { + Map<String, Object> datas = null; + if (chooseTime.equals("true")) { + String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); + String dbDataStr = historyHourlyMapper.queryLastHourlyMac(mac, time, timeUnits); + if (dbDataStr == null) { + return null; + } + datas = JSON.parseObject(dbDataStr, HashMap.class); + datas.put("dataTime", time); + } else { + datas = queryLastDataByMac(mac); + if (ObjectUtils.isEmpty(datas)){ + return null; + } + } + //������������������ + Map<String, Object> result = new HashMap<>(); + + //������������������code������ + List<String> sensorCodes = Arrays.asList("a34004", "a34002", "a21005", "a21004", "a21026", "a05024", "a99054", "a01008", "a01007"); + //������������������ + Device device = deviceService.getDeviceUnitAlramInforByMac(mac); + //��������������������������� + for (Sensor sensor : device.getVersion().getSensors()) { + if (!sensorCodes.contains(sensor.getCode())) + continue; + Object dataO = datas.get(sensor.getCode()); + if (dataO != null) { + String data = String.valueOf(dataO); + result.put(sensor.getCode(), data); + } else { + if (sensor.getCode().equals("a01008") ||sensor.getCode().equals("a01007")){ + result.put(sensor.getCode(), "-"); + }else { + result.put(sensor.getCode(), "0"); + } + + } + } + QueryFiveDataByMacVO queryFiveDataByMacVO = new QueryFiveDataByMacVO(); + queryFiveDataByMacVO.setName(device.getName()); + queryFiveDataByMacVO.setDataTime(datas.get("dataTime").toString()); + queryFiveDataByMacVO.setA34004(result.get("a34004").toString()); + queryFiveDataByMacVO.setA34002(result.get("a34002").toString()); + queryFiveDataByMacVO.setA21026(result.get("a21026").toString()); + queryFiveDataByMacVO.setA21004(result.get("a21004").toString()); + queryFiveDataByMacVO.setA21005(result.get("a21005").toString()); + queryFiveDataByMacVO.setA05024(result.get("a05024").toString()); + queryFiveDataByMacVO.setA01008(result.get("a01008").toString()); + queryFiveDataByMacVO.setA01007(result.get("a01007").toString()); + + return queryFiveDataByMacVO; + } + //��������������������������������� private Map<String, Object> orderSixParam(Map<String, Object> data) { LinkedHashMap result = new LinkedHashMap(); -- Gitblit v1.8.0