diff --git a/src/main/java/com/hivekion/scenario/entity/Resource.java b/src/main/java/com/hivekion/scenario/entity/Resource.java index 687befc..a9a8468 100644 --- a/src/main/java/com/hivekion/scenario/entity/Resource.java +++ b/src/main/java/com/hivekion/scenario/entity/Resource.java @@ -1,10 +1,14 @@ package com.hivekion.scenario.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 java.io.Serializable; import java.math.BigDecimal; +import java.util.Map; + +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -33,13 +37,14 @@ public class Resource implements Serializable { private String icon; @ApiModelProperty("纬度") - private BigDecimal lat; + private String lat; @ApiModelProperty("经度") - private BigDecimal lng; + private String lng; @ApiModelProperty("设施属性") - private byte[] resourceAttribut; + @TableField(typeHandler = JacksonTypeHandler.class) + private Map resourceAttribut; @ApiModelProperty("创建人") private String createOper; @@ -74,27 +79,27 @@ public class Resource implements Serializable { this.icon = icon; } - public BigDecimal getLat() { + public String getLat() { return lat; } - public void setLat(BigDecimal lat) { + public void setLat(String lat) { this.lat = lat; } - public BigDecimal getLng() { + public String getLng() { return lng; } - public void setLng(BigDecimal lng) { + public void setLng(String lng) { this.lng = lng; } - public byte[] getResourceAttribut() { + public Map getResourceAttribut() { return resourceAttribut; } - public void setResourceAttribut(byte[] resourceAttribut) { + public void setResourceAttribut(Map resourceAttribut) { this.resourceAttribut = resourceAttribut; } diff --git a/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java b/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java index 83a7e70..5a7a71c 100644 --- a/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java +++ b/src/main/java/com/hivekion/scenario/service/impl/ScenarioTaskServiceImpl.java @@ -1,5 +1,6 @@ package com.hivekion.scenario.service.impl; +import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -122,16 +123,20 @@ public class ScenarioTaskServiceImpl extends try { QueryWrapper weatherResourceQueryWrapper = new QueryWrapper<>(); weatherResourceQueryWrapper.eq("scenario_id", currentScenario.getId()).eq("room_id", roomId); - WeatherResource weatherResource = this.weatherResourceService.getOne(weatherResourceQueryWrapper); - ResponseCmdInfo responseCmdInfo = new ResponseCmdInfo(); + List weatherResourceList = this.weatherResourceService.list(); + ResponseCmdInfo responseCmdInfo = new ResponseCmdInfo(); responseCmdInfo.setScenarioId(currentScenario.getId()); responseCmdInfo.setRoom(roomId); - JSONObject weatherMsg = new JSONObject(); - DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - weatherMsg.putOnce("begTime", dtf.format(weatherResource.getLastBegTime())); - weatherMsg.putOnce("endTime", dtf.format(weatherResource.getLastEndTime())); - responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType()); - responseCmdInfo.setData(weatherMsg); + JSONArray weatherMsgArray = new JSONArray(); + for(WeatherResource weatherResource: weatherResourceList) { + JSONObject jsonObject = new JSONObject(); + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + jsonObject.putOnce("begTime", dtf.format(weatherResource.getLastBegTime())); + jsonObject.putOnce("endTime", dtf.format(weatherResource.getLastEndTime())); + weatherMsgArray.add(jsonObject); + responseCmdInfo.setCmdType("66-" + weatherResource.getWeatherType()); + } + responseCmdInfo.setData(weatherMsgArray); Global.sendCmdInfoQueue.add(responseCmdInfo); }catch (Exception ex){ ex.printStackTrace();