Merge remote-tracking branch 'origin/master'
# Conflicts: # lh-admin/src/main/resources/application-druid.yml
正在显示
77 个修改的文件
包含
2943 行增加
和
629 行删除
| @@ -35,7 +35,11 @@ | @@ -35,7 +35,11 @@ | ||
| 35 | <groupId>com.zhonglai.luhui</groupId> | 35 | <groupId>com.zhonglai.luhui</groupId> |
| 36 | <artifactId>ruoyi-generator</artifactId> | 36 | <artifactId>ruoyi-generator</artifactId> |
| 37 | </dependency> | 37 | </dependency> |
| 38 | - | 38 | + <!-- 代码生成模块--> |
| 39 | + <dependency> | ||
| 40 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 41 | + <artifactId>lh-mqtt-service</artifactId> | ||
| 42 | + </dependency> | ||
| 39 | <!-- 文档 --> | 43 | <!-- 文档 --> |
| 40 | <dependency > | 44 | <dependency > |
| 41 | <groupId>io.springfox</groupId> | 45 | <groupId>io.springfox</groupId> |
| @@ -12,6 +12,8 @@ import org.springframework.context.annotation.ComponentScan; | @@ -12,6 +12,8 @@ import org.springframework.context.annotation.ComponentScan; | ||
| 12 | "com.ruoyi.generator", | 12 | "com.ruoyi.generator", |
| 13 | "com.zhonglai.luhui.admin.config", | 13 | "com.zhonglai.luhui.admin.config", |
| 14 | "com.zhonglai.luhui.admin.controller", | 14 | "com.zhonglai.luhui.admin.controller", |
| 15 | + "com.zhonglai.luhui.mqtt.comm.service.redis", | ||
| 16 | + "com.zhonglai.luhui.mqtt.service.db.mode" | ||
| 15 | }) | 17 | }) |
| 16 | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) | 18 | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) |
| 17 | public class AdminApplication { | 19 | public class AdminApplication { |
lh-admin/src/main/java/com/zhonglai/luhui/admin/controller/iot/IotDeviceControlController.java
0 → 100644
| 1 | +package com.zhonglai.luhui.admin.controller.iot; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.ruoyi.common.annotation.Log; | ||
| 5 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 6 | +import com.ruoyi.common.core.domain.Message; | ||
| 7 | +import com.ruoyi.common.core.domain.MessageCode; | ||
| 8 | +import com.ruoyi.common.enums.BusinessType; | ||
| 9 | +import com.ruoyi.common.utils.StringUtils; | ||
| 10 | +import com.ruoyi.common.utils.html.HttpUtils; | ||
| 11 | +import com.ruoyi.system.domain.IotDevice; | ||
| 12 | +import com.ruoyi.system.service.IIotDeviceService; | ||
| 13 | +import com.ruoyi.system.service.IIotTerminalService; | ||
| 14 | +import io.swagger.annotations.Api; | ||
| 15 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 16 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 17 | +import io.swagger.annotations.ApiOperation; | ||
| 18 | +import okhttp3.Response; | ||
| 19 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 21 | +import org.springframework.stereotype.Controller; | ||
| 22 | +import org.springframework.transaction.annotation.Transactional; | ||
| 23 | +import org.springframework.web.bind.annotation.*; | ||
| 24 | + | ||
| 25 | +import javax.servlet.http.HttpServletResponse; | ||
| 26 | +import java.io.IOException; | ||
| 27 | +import java.util.HashMap; | ||
| 28 | +import java.util.Map; | ||
| 29 | + | ||
| 30 | +@Api(tags = "设备控制") | ||
| 31 | +@Controller | ||
| 32 | +@RequestMapping("/iot/iotDeviceControl") | ||
| 33 | +public class IotDeviceControlController { | ||
| 34 | + @Autowired | ||
| 35 | + private IIotDeviceService iotDeviceService; | ||
| 36 | + @Autowired | ||
| 37 | + private IIotTerminalService iIotTerminalService; | ||
| 38 | + private String getServiceAdrres(HttpServletResponse response,String imei) throws IOException { | ||
| 39 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 40 | + response.setCharacterEncoding("UTF-8"); | ||
| 41 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 42 | + { | ||
| 43 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 44 | + return null; | ||
| 45 | + } | ||
| 46 | + return "http://"+iotDevice.getListen_service_ip()+"device/control/"+imei; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @ApiOperation("固件版本更新") | ||
| 50 | + @ApiImplicitParams({ | ||
| 51 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 52 | + @ApiImplicitParam(value = "版本号",name = "firmwareVersion") | ||
| 53 | + }) | ||
| 54 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:firmwareUp')") | ||
| 55 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 56 | + @ResponseBody | ||
| 57 | + @PostMapping("/firmwareUp/{imei}") | ||
| 58 | + public String firmwareUp(HttpServletResponse response,@PathVariable String imei,String firmwareVersion,Integer code) throws IOException { | ||
| 59 | + String url = getServiceAdrres(response,imei); | ||
| 60 | + if(null == url) | ||
| 61 | + { | ||
| 62 | + return null; | ||
| 63 | + } | ||
| 64 | + Map<String,Object> map = new HashMap<>(); | ||
| 65 | + Map<String,Object> valueMap = new HashMap<>(); | ||
| 66 | + valueMap.put("firmwareVersion",firmwareVersion); | ||
| 67 | + valueMap.put("code",code); | ||
| 68 | + Response response1 = HttpUtils.postJsonBody(url, formBody -> { | ||
| 69 | + formBody.put("0", valueMap); | ||
| 70 | + }); | ||
| 71 | + return response1.body().string(); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @ApiOperation("设备重启") | ||
| 75 | + @ApiImplicitParams({ | ||
| 76 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 77 | + @ApiImplicitParam(value = "restart 1重启,2复位,3恢复出厂值",name = "restart"), | ||
| 78 | + }) | ||
| 79 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:restart')") | ||
| 80 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 81 | + @ResponseBody | ||
| 82 | + @PostMapping("/restart/{imei}/{restart}") | ||
| 83 | + public String restart(HttpServletResponse response,@PathVariable String imei ,@PathVariable Integer restart) throws IOException { | ||
| 84 | + String url = getServiceAdrres(response,imei); | ||
| 85 | + if(null == url) | ||
| 86 | + { | ||
| 87 | + return null; | ||
| 88 | + } | ||
| 89 | + Map<String,Object> map = new HashMap<>(); | ||
| 90 | + Map<String,Object> valueMap = new HashMap<>(); | ||
| 91 | + valueMap.put("restart",restart); | ||
| 92 | + Response response1 = HttpUtils.postJsonBody(url, formBody -> { | ||
| 93 | + formBody.put("0",valueMap); | ||
| 94 | + }); | ||
| 95 | + return response1.body().string(); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + @ApiOperation("获取指定设备版本信息") | ||
| 99 | + @ApiImplicitParams({ | ||
| 100 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 101 | + }) | ||
| 102 | + @ResponseBody | ||
| 103 | + @PostMapping("/getFirmwareVersion/{imei}") | ||
| 104 | + public String getFirmwareVersion(HttpServletResponse response,@PathVariable String imei) throws IOException { | ||
| 105 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 106 | + response.setCharacterEncoding("UTF-8"); | ||
| 107 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 108 | + { | ||
| 109 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 110 | + return null; | ||
| 111 | + } | ||
| 112 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/getFirmwareVersion/"+iotDevice.getMqtt_username(); | ||
| 113 | + | ||
| 114 | + Response response1 = HttpUtils.postFromBody(url, builder -> { | ||
| 115 | + }, formBody -> { | ||
| 116 | + }); | ||
| 117 | + return response1.body().string(); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + @ApiOperation("强行断开链接") | ||
| 121 | + @ApiImplicitParams({ | ||
| 122 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 123 | + }) | ||
| 124 | + @ResponseBody | ||
| 125 | + @PostMapping("/closeSession/{imei}") | ||
| 126 | + public String closeSession(HttpServletResponse response,@PathVariable String imei) throws IOException { | ||
| 127 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 128 | + response.setCharacterEncoding("UTF-8"); | ||
| 129 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 130 | + { | ||
| 131 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 132 | + return null; | ||
| 133 | + } | ||
| 134 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/closeSession/"+imei; | ||
| 135 | + | ||
| 136 | + Response response1 = HttpUtils.postFromBody(url, builder -> { | ||
| 137 | + }, formBody -> { | ||
| 138 | + }); | ||
| 139 | + return response1.body().string(); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + @ApiOperation("删除主机") | ||
| 143 | + @ApiImplicitParams({ | ||
| 144 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 145 | + }) | ||
| 146 | + @Transactional | ||
| 147 | + @ResponseBody | ||
| 148 | + @PostMapping("/delIotDevice/{imei}") | ||
| 149 | + public String delIotDevice(HttpServletResponse response,@PathVariable String imei) { | ||
| 150 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 151 | + iotDeviceService.deleteIotDeviceByClient_id(imei); | ||
| 152 | + iIotTerminalService.deleteIotTerminalByDeviceId(imei); | ||
| 153 | + response.setCharacterEncoding("UTF-8"); | ||
| 154 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 155 | + { | ||
| 156 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 157 | + } | ||
| 158 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/delIotDevice/"+imei; | ||
| 159 | + | ||
| 160 | + try { | ||
| 161 | + String str = HttpUtils.getResponseString(HttpUtils.postFromBody(url, builder -> { | ||
| 162 | + }, formBody -> { | ||
| 163 | + })); | ||
| 164 | + if(null != str) | ||
| 165 | + { | ||
| 166 | + return str; | ||
| 167 | + } | ||
| 168 | + } catch (IOException e) { | ||
| 169 | + } | ||
| 170 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 171 | + | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + @ApiOperation("删除终端") | ||
| 175 | + @ApiImplicitParams({ | ||
| 176 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 177 | + }) | ||
| 178 | + @ResponseBody | ||
| 179 | + @PostMapping("/delIotTerminal/{imei}/{number}") | ||
| 180 | + public String delIotTerminal(HttpServletResponse response,@PathVariable String imei,@PathVariable String number) { | ||
| 181 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 182 | + iIotTerminalService.deleteIotTerminalById(imei+"_"+number); | ||
| 183 | + response.setCharacterEncoding("UTF-8"); | ||
| 184 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 185 | + { | ||
| 186 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 187 | + } | ||
| 188 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/delIotTerminal/"+imei+"/"+number; | ||
| 189 | + | ||
| 190 | + String str = null; | ||
| 191 | + try { | ||
| 192 | + str = HttpUtils.getResponseString(HttpUtils.postFromBody(url, builder -> { | ||
| 193 | + }, formBody -> { | ||
| 194 | + })); | ||
| 195 | + } catch (IOException e) { | ||
| 196 | + } | ||
| 197 | + if(null != str) | ||
| 198 | + { | ||
| 199 | + return str; | ||
| 200 | + } | ||
| 201 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + @ApiOperation(value = "读取属性") | ||
| 205 | + @ApiImplicitParams({ | ||
| 206 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 207 | + @ApiImplicitParam(value = "传感器编号(0,1_1,10_1)",name = "sensor_number"), | ||
| 208 | + @ApiImplicitParam(value = "属性集合(id1,id2,id3)",name = "attributes"), | ||
| 209 | + }) | ||
| 210 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:upSummary')") | ||
| 211 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 212 | + @ResponseBody | ||
| 213 | + @PostMapping("/readAttribute/{imei}/{sensor_number}") | ||
| 214 | + public String readAttribute(HttpServletResponse response,@PathVariable String imei,@PathVariable String sensor_number,String attributes) throws IOException { | ||
| 215 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 216 | + response.setCharacterEncoding("UTF-8"); | ||
| 217 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 218 | + { | ||
| 219 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 220 | + return null; | ||
| 221 | + } | ||
| 222 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/read/"+imei; | ||
| 223 | + Map<String,Object> map = new HashMap<>(); | ||
| 224 | + map.put(sensor_number,attributes); | ||
| 225 | + Response response1 = HttpUtils.postJsonBody(url, jsonObject -> jsonObject.putAll(map)); | ||
| 226 | + return response1.body().string(); | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + @ApiOperation(value = "设置主机自定义参数",notes = "自定义数据模型:\n" + | ||
| 230 | + "{\n" + | ||
| 231 | + " \t \"name\": \"wumei-smart\",\n" + | ||
| 232 | + " \t \"chip\": \"esp8266\",\n" + | ||
| 233 | + " \t \"author\": \"kerwincui\",\n" + | ||
| 234 | + " \t \"version\": 1.2,\n" + | ||
| 235 | + " \t \"createTime\": \"2022-06-06\"\n" + | ||
| 236 | + " }") | ||
| 237 | + @ApiImplicitParams({ | ||
| 238 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 239 | + @ApiImplicitParam(value = "自定义数据json字符串",name = "summary") | ||
| 240 | + }) | ||
| 241 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:upSummary')") | ||
| 242 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 243 | + @ResponseBody | ||
| 244 | + @PostMapping("/upSummary/{imei}") | ||
| 245 | + public String upSummary(HttpServletResponse response,@PathVariable String imei,String summary) throws IOException { | ||
| 246 | + String url = getServiceAdrres(response,imei); | ||
| 247 | + if(null == url) | ||
| 248 | + { | ||
| 249 | + return null; | ||
| 250 | + } | ||
| 251 | + Map<String,Object> valueMap = new HashMap<>(); | ||
| 252 | + valueMap.put("summary",JSONObject.parseObject(summary)); | ||
| 253 | + Response response1 = HttpUtils.postJsonBody(url,formBody -> { | ||
| 254 | + formBody.put("0", valueMap); | ||
| 255 | + }); | ||
| 256 | + return response1.body().string(); | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + @ApiOperation(value = "修改指定终端属性",notes = "配置参数模型:\n" + | ||
| 260 | + "{\n" + | ||
| 261 | + " \"id1\":\"value1\",\n" + | ||
| 262 | + " \"id2\":\"value2\",\n" + | ||
| 263 | + " \"id3\":\"value3\"\n" + | ||
| 264 | + " }") | ||
| 265 | + @ApiImplicitParams({ | ||
| 266 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 267 | + @ApiImplicitParam(value = "终端编号(如:1_1)",name = "number"), | ||
| 268 | + @ApiImplicitParam(value = "配置参数json字符串",name = "config") | ||
| 269 | + }) | ||
| 270 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:upTerminalConfig')") | ||
| 271 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 272 | + @ResponseBody | ||
| 273 | + @PostMapping("/upTerminalConfig/{imei}/{number}") | ||
| 274 | + public String upTerminalConfig(HttpServletResponse response, @PathVariable String imei,@PathVariable String number,@RequestBody Map<String,Object> config) throws IOException { | ||
| 275 | + String url = getServiceAdrres(response,imei); | ||
| 276 | + if(null == url) | ||
| 277 | + { | ||
| 278 | + return null; | ||
| 279 | + } | ||
| 280 | + Map<String,Object> map = new HashMap<>(); | ||
| 281 | + map.put(number,config); | ||
| 282 | + Response response1 = HttpUtils.postJsonBody(url, jsonObject -> jsonObject.putAll(map)); | ||
| 283 | + return response1.body().string(); | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + @ApiOperation(value = "批量修改终端属性",notes = "批量数据模型:\n" + | ||
| 287 | + "{\n" + | ||
| 288 | + " \"1\":{\n" + | ||
| 289 | + " \"id1\":\"value1\",\n" + | ||
| 290 | + " \"id2\":\"value2\",\n" + | ||
| 291 | + " \"id3\":\"value3\"\n" + | ||
| 292 | + " },\n" + | ||
| 293 | + " \"3\":{\n" + | ||
| 294 | + " \"id1\":\"value1\",\n" + | ||
| 295 | + " \"id2\":\"value2\",\n" + | ||
| 296 | + " \"id3\":\"value3\"\n" + | ||
| 297 | + " },\n" + | ||
| 298 | + " \"4\":{\n" + | ||
| 299 | + " \"id1\":\"value1\",\n" + | ||
| 300 | + " \"id2\":\"value2\",\n" + | ||
| 301 | + " \"id3\":\"value3\"\n" + | ||
| 302 | + " }\n" + | ||
| 303 | + "}") | ||
| 304 | + @ApiImplicitParam(value = "批量数据json字符串",name = "map") | ||
| 305 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:batchUpTerminalConfig')") | ||
| 306 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 307 | + @ResponseBody | ||
| 308 | + @PostMapping("/batchUpTerminalConfig/{imei}") | ||
| 309 | + public String batchUpTerminalConfig(HttpServletResponse response,@PathVariable String imei,@RequestBody Map<String,Object> map) throws IOException { | ||
| 310 | + String url = getServiceAdrres(response,imei); | ||
| 311 | + if(null == url) | ||
| 312 | + { | ||
| 313 | + return null; | ||
| 314 | + } | ||
| 315 | + Response response1 = HttpUtils.postJsonBody(url, builder -> { | ||
| 316 | + | ||
| 317 | + }, formBody -> { | ||
| 318 | + for (String key:map.keySet()) | ||
| 319 | + { | ||
| 320 | + formBody.put(key, map.get(key)); | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + }); | ||
| 324 | + return response1.body().string(); | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + | ||
| 328 | +} |
| @@ -3,6 +3,10 @@ package com.zhonglai.luhui.admin.controller.iot; | @@ -3,6 +3,10 @@ package com.zhonglai.luhui.admin.controller.iot; | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import javax.servlet.http.HttpServletResponse; | 4 | import javax.servlet.http.HttpServletResponse; |
| 5 | 5 | ||
| 6 | +import com.ruoyi.common.core.domain.Message; | ||
| 7 | +import com.ruoyi.common.utils.DateUtils; | ||
| 8 | +import com.ruoyi.system.domain.IotProduct; | ||
| 9 | +import com.ruoyi.system.service.IIotProductService; | ||
| 6 | import io.swagger.annotations.Api; | 10 | import io.swagger.annotations.Api; |
| 7 | import io.swagger.annotations.ApiOperation; | 11 | import io.swagger.annotations.ApiOperation; |
| 8 | import org.springframework.security.access.prepost.PreAuthorize; | 12 | import org.springframework.security.access.prepost.PreAuthorize; |
| @@ -37,7 +41,6 @@ public class IotDeviceController extends BaseController | @@ -37,7 +41,6 @@ public class IotDeviceController extends BaseController | ||
| 37 | { | 41 | { |
| 38 | @Autowired | 42 | @Autowired |
| 39 | private IIotDeviceService iotDeviceService; | 43 | private IIotDeviceService iotDeviceService; |
| 40 | - | ||
| 41 | /** | 44 | /** |
| 42 | * 查询主机/网关列表 | 45 | * 查询主机/网关列表 |
| 43 | */ | 46 | */ |
| @@ -82,9 +85,11 @@ public class IotDeviceController extends BaseController | @@ -82,9 +85,11 @@ public class IotDeviceController extends BaseController | ||
| 82 | @ApiOperation("新增主机/网关") | 85 | @ApiOperation("新增主机/网关") |
| 83 | @PreAuthorize("@ss.hasPermi('iot:IotDevice:add')") | 86 | @PreAuthorize("@ss.hasPermi('iot:IotDevice:add')") |
| 84 | @Log(title = "主机/网关", businessType = BusinessType.INSERT) | 87 | @Log(title = "主机/网关", businessType = BusinessType.INSERT) |
| 85 | - @PostMapping | 88 | + @PostMapping("add") |
| 86 | public AjaxResult add(@RequestBody IotDevice iotDevice) | 89 | public AjaxResult add(@RequestBody IotDevice iotDevice) |
| 87 | { | 90 | { |
| 91 | + iotDevice.setCreate_by(getUsername()); | ||
| 92 | + iotDevice.setUpdate_time(DateUtils.getNowTimeMilly()); | ||
| 88 | return toAjax(iotDeviceService.insertIotDevice(iotDevice)); | 93 | return toAjax(iotDeviceService.insertIotDevice(iotDevice)); |
| 89 | } | 94 | } |
| 90 | 95 | ||
| @@ -94,9 +99,11 @@ public class IotDeviceController extends BaseController | @@ -94,9 +99,11 @@ public class IotDeviceController extends BaseController | ||
| 94 | @ApiOperation("修改主机/网关") | 99 | @ApiOperation("修改主机/网关") |
| 95 | @PreAuthorize("@ss.hasPermi('iot:IotDevice:edit')") | 100 | @PreAuthorize("@ss.hasPermi('iot:IotDevice:edit')") |
| 96 | @Log(title = "主机/网关", businessType = BusinessType.UPDATE) | 101 | @Log(title = "主机/网关", businessType = BusinessType.UPDATE) |
| 97 | - @PutMapping | 102 | + @PutMapping("edit") |
| 98 | public AjaxResult edit(@RequestBody IotDevice iotDevice) | 103 | public AjaxResult edit(@RequestBody IotDevice iotDevice) |
| 99 | { | 104 | { |
| 105 | + iotDevice.setUpdate_by(getUsername()); | ||
| 106 | + iotDevice.setUpdate_time(DateUtils.getNowTimeMilly()); | ||
| 100 | return toAjax(iotDeviceService.updateIotDevice(iotDevice)); | 107 | return toAjax(iotDeviceService.updateIotDevice(iotDevice)); |
| 101 | } | 108 | } |
| 102 | 109 |
| @@ -19,8 +19,8 @@ import com.ruoyi.common.annotation.Log; | @@ -19,8 +19,8 @@ import com.ruoyi.common.annotation.Log; | ||
| 19 | import com.ruoyi.common.core.controller.BaseController; | 19 | import com.ruoyi.common.core.controller.BaseController; |
| 20 | import com.ruoyi.common.core.domain.AjaxResult; | 20 | import com.ruoyi.common.core.domain.AjaxResult; |
| 21 | import com.ruoyi.common.enums.BusinessType; | 21 | import com.ruoyi.common.enums.BusinessType; |
| 22 | -import com.ruoyi.system.domain.IotUser; | ||
| 23 | -import com.ruoyi.system.service.IIotUserService; | 22 | +import com.ruoyi.system.domain.IotProduct; |
| 23 | +import com.ruoyi.system.service.IIotProductService; | ||
| 24 | import com.ruoyi.common.utils.poi.ExcelUtil; | 24 | import com.ruoyi.common.utils.poi.ExcelUtil; |
| 25 | import com.ruoyi.common.core.page.TableDataInfo; | 25 | import com.ruoyi.common.core.page.TableDataInfo; |
| 26 | 26 | ||
| @@ -32,22 +32,22 @@ import com.ruoyi.common.core.page.TableDataInfo; | @@ -32,22 +32,22 @@ import com.ruoyi.common.core.page.TableDataInfo; | ||
| 32 | */ | 32 | */ |
| 33 | @Api(tags = "产品") | 33 | @Api(tags = "产品") |
| 34 | @RestController | 34 | @RestController |
| 35 | -@RequestMapping("/iot/IotUser") | ||
| 36 | -public class IotUserController extends BaseController | 35 | +@RequestMapping("/iot/IotProduct") |
| 36 | +public class IotProductController extends BaseController | ||
| 37 | { | 37 | { |
| 38 | @Autowired | 38 | @Autowired |
| 39 | - private IIotUserService iotUserService; | 39 | + private IIotProductService IotProductService; |
| 40 | 40 | ||
| 41 | /** | 41 | /** |
| 42 | * 查询产品列表 | 42 | * 查询产品列表 |
| 43 | */ | 43 | */ |
| 44 | @ApiOperation("查询产品列表") | 44 | @ApiOperation("查询产品列表") |
| 45 | - @PreAuthorize("@ss.hasPermi('iot:IotUser:list')") | 45 | + @PreAuthorize("@ss.hasPermi('iot:IotProduct:list')") |
| 46 | @GetMapping("/list") | 46 | @GetMapping("/list") |
| 47 | - public TableDataInfo list(IotUser iotUser) | 47 | + public TableDataInfo list(IotProduct iotProduct) |
| 48 | { | 48 | { |
| 49 | startPage(); | 49 | startPage(); |
| 50 | - List<IotUser> list = iotUserService.selectIotUserList(iotUser); | 50 | + List<IotProduct> list = IotProductService.selectIotProductList(iotProduct); |
| 51 | return getDataTable(list); | 51 | return getDataTable(list); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| @@ -55,13 +55,13 @@ public class IotUserController extends BaseController | @@ -55,13 +55,13 @@ public class IotUserController extends BaseController | ||
| 55 | * 导出产品列表 | 55 | * 导出产品列表 |
| 56 | */ | 56 | */ |
| 57 | @ApiOperation("导出产品列表") | 57 | @ApiOperation("导出产品列表") |
| 58 | - @PreAuthorize("@ss.hasPermi('iot:IotUser:export')") | 58 | + @PreAuthorize("@ss.hasPermi('iot:IotProduct:export')") |
| 59 | @Log(title = "产品", businessType = BusinessType.EXPORT) | 59 | @Log(title = "产品", businessType = BusinessType.EXPORT) |
| 60 | @PostMapping("/export") | 60 | @PostMapping("/export") |
| 61 | - public void export(HttpServletResponse response, IotUser iotUser) | 61 | + public void export(HttpServletResponse response, IotProduct iotProduct) |
| 62 | { | 62 | { |
| 63 | - List<IotUser> list = iotUserService.selectIotUserList(iotUser); | ||
| 64 | - ExcelUtil<IotUser> util = new ExcelUtil<IotUser>(IotUser.class); | 63 | + List<IotProduct> list = IotProductService.selectIotProductList(iotProduct); |
| 64 | + ExcelUtil<IotProduct> util = new ExcelUtil<IotProduct>(IotProduct.class); | ||
| 65 | util.exportExcel(response, list, "产品数据"); | 65 | util.exportExcel(response, list, "产品数据"); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| @@ -69,46 +69,46 @@ public class IotUserController extends BaseController | @@ -69,46 +69,46 @@ public class IotUserController extends BaseController | ||
| 69 | * 获取产品详细信息 | 69 | * 获取产品详细信息 |
| 70 | */ | 70 | */ |
| 71 | @ApiOperation("获取产品详细信息") | 71 | @ApiOperation("获取产品详细信息") |
| 72 | - @PreAuthorize("@ss.hasPermi('iot:IotUser:query')") | 72 | + @PreAuthorize("@ss.hasPermi('iot:IotProduct:query')") |
| 73 | @GetMapping(value = "/{id}") | 73 | @GetMapping(value = "/{id}") |
| 74 | public AjaxResult getInfo(@PathVariable("id") Integer id) | 74 | public AjaxResult getInfo(@PathVariable("id") Integer id) |
| 75 | { | 75 | { |
| 76 | - return AjaxResult.success(iotUserService.selectIotUserById(id)); | 76 | + return AjaxResult.success(IotProductService.selectIotProductById(id)); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | /** | 79 | /** |
| 80 | * 新增产品 | 80 | * 新增产品 |
| 81 | */ | 81 | */ |
| 82 | @ApiOperation("新增产品") | 82 | @ApiOperation("新增产品") |
| 83 | - @PreAuthorize("@ss.hasPermi('iot:IotUser:add')") | 83 | + @PreAuthorize("@ss.hasPermi('iot:IotProduct:add')") |
| 84 | @Log(title = "产品", businessType = BusinessType.INSERT) | 84 | @Log(title = "产品", businessType = BusinessType.INSERT) |
| 85 | @PostMapping | 85 | @PostMapping |
| 86 | - public AjaxResult add(@RequestBody IotUser iotUser) | 86 | + public AjaxResult add(@RequestBody IotProduct iotProduct) |
| 87 | { | 87 | { |
| 88 | - return toAjax(iotUserService.insertIotUser(iotUser)); | 88 | + return toAjax(IotProductService.insertIotProduct(iotProduct)); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | /** | 91 | /** |
| 92 | * 修改产品 | 92 | * 修改产品 |
| 93 | */ | 93 | */ |
| 94 | @ApiOperation("修改产品") | 94 | @ApiOperation("修改产品") |
| 95 | - @PreAuthorize("@ss.hasPermi('iot:IotUser:edit')") | 95 | + @PreAuthorize("@ss.hasPermi('iot:IotProduct:edit')") |
| 96 | @Log(title = "产品", businessType = BusinessType.UPDATE) | 96 | @Log(title = "产品", businessType = BusinessType.UPDATE) |
| 97 | @PutMapping | 97 | @PutMapping |
| 98 | - public AjaxResult edit(@RequestBody IotUser iotUser) | 98 | + public AjaxResult edit(@RequestBody IotProduct iotProduct) |
| 99 | { | 99 | { |
| 100 | - return toAjax(iotUserService.updateIotUser(iotUser)); | 100 | + return toAjax(IotProductService.updateIotProduct(iotProduct)); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | /** | 103 | /** |
| 104 | * 删除产品 | 104 | * 删除产品 |
| 105 | */ | 105 | */ |
| 106 | @ApiOperation("删除产品") | 106 | @ApiOperation("删除产品") |
| 107 | - @PreAuthorize("@ss.hasPermi('iot:IotUser:remove')") | 107 | + @PreAuthorize("@ss.hasPermi('iot:IotProduct:remove')") |
| 108 | @Log(title = "产品", businessType = BusinessType.DELETE) | 108 | @Log(title = "产品", businessType = BusinessType.DELETE) |
| 109 | @DeleteMapping("/{ids}") | 109 | @DeleteMapping("/{ids}") |
| 110 | public AjaxResult remove(@PathVariable Integer[] ids) | 110 | public AjaxResult remove(@PathVariable Integer[] ids) |
| 111 | { | 111 | { |
| 112 | - return toAjax(iotUserService.deleteIotUserByIds(ids)); | 112 | + return toAjax(IotProductService.deleteIotProductByIds(ids)); |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
lh-admin/src/main/java/com/zhonglai/luhui/admin/controller/iot/IotProductTranslateController.java
0 → 100644
| 1 | +package com.zhonglai.luhui.admin.controller.iot; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import javax.servlet.http.HttpServletResponse; | ||
| 5 | + | ||
| 6 | +import com.ruoyi.common.core.redis.RedisCache; | ||
| 7 | +import com.ruoyi.common.utils.DateUtils; | ||
| 8 | +import io.swagger.annotations.Api; | ||
| 9 | +import io.swagger.annotations.ApiOperation; | ||
| 10 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 15 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 16 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 17 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 18 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.RestController; | ||
| 20 | +import com.ruoyi.common.annotation.Log; | ||
| 21 | +import com.ruoyi.common.core.controller.BaseController; | ||
| 22 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 23 | +import com.ruoyi.common.enums.BusinessType; | ||
| 24 | +import com.ruoyi.system.domain.IotProductTranslate; | ||
| 25 | +import com.ruoyi.system.service.IIotProductTranslateService; | ||
| 26 | +import com.ruoyi.common.utils.poi.ExcelUtil; | ||
| 27 | +import com.ruoyi.common.core.page.TableDataInfo; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * 产品指标翻译Controller | ||
| 31 | + * | ||
| 32 | + * @author 钟来 | ||
| 33 | + * @date 2022-11-04 | ||
| 34 | + */ | ||
| 35 | +@Api(tags = "产品指标翻译") | ||
| 36 | +@RestController | ||
| 37 | +@RequestMapping("/iot/IotProductTranslate") | ||
| 38 | +public class IotProductTranslateController extends BaseController | ||
| 39 | +{ | ||
| 40 | + @Autowired | ||
| 41 | + private IIotProductTranslateService iotProductTranslateService; | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 查询产品指标翻译列表 | ||
| 45 | + */ | ||
| 46 | + @ApiOperation("查询产品指标翻译列表") | ||
| 47 | + @PreAuthorize("@ss.hasPermi('iot:IotProductTranslate:list')") | ||
| 48 | + @GetMapping("/list") | ||
| 49 | + public TableDataInfo list(IotProductTranslate iotProductTranslate) | ||
| 50 | + { | ||
| 51 | + startPage(); | ||
| 52 | + List<IotProductTranslate> list = iotProductTranslateService.selectIotProductTranslateList(iotProductTranslate); | ||
| 53 | + return getDataTable(list); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 导出产品指标翻译列表 | ||
| 58 | + */ | ||
| 59 | + @ApiOperation("导出产品指标翻译列表") | ||
| 60 | + @PreAuthorize("@ss.hasPermi('iot:IotProductTranslate:export')") | ||
| 61 | + @Log(title = "产品指标翻译", businessType = BusinessType.EXPORT) | ||
| 62 | + @PostMapping("/export") | ||
| 63 | + public void export(HttpServletResponse response, IotProductTranslate iotProductTranslate) | ||
| 64 | + { | ||
| 65 | + List<IotProductTranslate> list = iotProductTranslateService.selectIotProductTranslateList(iotProductTranslate); | ||
| 66 | + ExcelUtil<IotProductTranslate> util = new ExcelUtil<IotProductTranslate>(IotProductTranslate.class); | ||
| 67 | + util.exportExcel(response, list, "产品指标翻译数据"); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 获取产品指标翻译详细信息 | ||
| 72 | + */ | ||
| 73 | + @ApiOperation("获取产品指标翻译详细信息") | ||
| 74 | + @PreAuthorize("@ss.hasPermi('iot:IotProductTranslate:query')") | ||
| 75 | + @GetMapping(value = "/{id}") | ||
| 76 | + public AjaxResult getInfo(@PathVariable("id") Integer id) | ||
| 77 | + { | ||
| 78 | + return AjaxResult.success(iotProductTranslateService.selectIotProductTranslateById(id)); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 新增产品指标翻译 | ||
| 83 | + */ | ||
| 84 | + @ApiOperation("新增产品指标翻译") | ||
| 85 | + @PreAuthorize("@ss.hasPermi('iot:IotProductTranslate:add')") | ||
| 86 | + @Log(title = "产品指标翻译", businessType = BusinessType.INSERT) | ||
| 87 | + @PostMapping | ||
| 88 | + public AjaxResult add(@RequestBody IotProductTranslate iotProductTranslate) | ||
| 89 | + { | ||
| 90 | + iotProductTranslate.setCreate_time(DateUtils.getNowTimeMilly()); | ||
| 91 | + return toAjax(iotProductTranslateService.insertIotProductTranslate(iotProductTranslate)); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + @ApiOperation("批量新增产品指标翻译") | ||
| 95 | + @PreAuthorize("@ss.hasPermi('iot:IotProductTranslate:addAll')") | ||
| 96 | + @Log(title = "产品指标翻译", businessType = BusinessType.INSERT) | ||
| 97 | + @PostMapping("/addAll") | ||
| 98 | + public AjaxResult addAll(@RequestBody List<IotProductTranslate> list) | ||
| 99 | + { | ||
| 100 | + return toAjax(iotProductTranslateService.insertAll(list)); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * 修改产品指标翻译 | ||
| 105 | + */ | ||
| 106 | + @ApiOperation("修改产品指标翻译") | ||
| 107 | + @PreAuthorize("@ss.hasPermi('iot:IotProductTranslate:edit')") | ||
| 108 | + @Log(title = "产品指标翻译", businessType = BusinessType.UPDATE) | ||
| 109 | + @PutMapping | ||
| 110 | + public AjaxResult edit(@RequestBody IotProductTranslate iotProductTranslate) | ||
| 111 | + { | ||
| 112 | + return toAjax(iotProductTranslateService.updateIotProductTranslate(iotProductTranslate)); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /** | ||
| 116 | + * 删除产品指标翻译 | ||
| 117 | + */ | ||
| 118 | + @ApiOperation("删除产品指标翻译") | ||
| 119 | + @PreAuthorize("@ss.hasPermi('iot:IotProductTranslate:remove')") | ||
| 120 | + @Log(title = "产品指标翻译", businessType = BusinessType.DELETE) | ||
| 121 | + @DeleteMapping("/{ids}") | ||
| 122 | + public AjaxResult remove(@PathVariable Integer[] ids) | ||
| 123 | + { | ||
| 124 | + return toAjax(iotProductTranslateService.deleteIotProductTranslateByIds(ids)); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | +} |
| @@ -3,6 +3,8 @@ package com.zhonglai.luhui.admin.controller.iot; | @@ -3,6 +3,8 @@ package com.zhonglai.luhui.admin.controller.iot; | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import javax.servlet.http.HttpServletResponse; | 4 | import javax.servlet.http.HttpServletResponse; |
| 5 | 5 | ||
| 6 | +import com.ruoyi.common.utils.DateUtils; | ||
| 7 | +import com.ruoyi.system.service.IIotProductTranslateService; | ||
| 6 | import io.swagger.annotations.Api; | 8 | import io.swagger.annotations.Api; |
| 7 | import io.swagger.annotations.ApiOperation; | 9 | import io.swagger.annotations.ApiOperation; |
| 8 | import org.springframework.security.access.prepost.PreAuthorize; | 10 | import org.springframework.security.access.prepost.PreAuthorize; |
| @@ -97,6 +99,7 @@ public class IotTerminalController extends BaseController | @@ -97,6 +99,7 @@ public class IotTerminalController extends BaseController | ||
| 97 | @PutMapping | 99 | @PutMapping |
| 98 | public AjaxResult edit(@RequestBody IotTerminal iotTerminal) | 100 | public AjaxResult edit(@RequestBody IotTerminal iotTerminal) |
| 99 | { | 101 | { |
| 102 | + iotTerminal.setUpdate_time(DateUtils.getNowTimeMilly()); | ||
| 100 | return toAjax(iotTerminalService.updateIotTerminal(iotTerminal)); | 103 | return toAjax(iotTerminalService.updateIotTerminal(iotTerminal)); |
| 101 | } | 104 | } |
| 102 | 105 |
| 1 | package com.zhonglai.luhui.admin.controller.iot; | 1 | package com.zhonglai.luhui.admin.controller.iot; |
| 2 | 2 | ||
| 3 | -import java.util.List; | 3 | +import java.util.*; |
| 4 | import javax.servlet.http.HttpServletResponse; | 4 | import javax.servlet.http.HttpServletResponse; |
| 5 | 5 | ||
| 6 | +import com.alibaba.fastjson.JSON; | ||
| 7 | +import com.alibaba.fastjson.JSONObject; | ||
| 8 | +import com.ruoyi.system.domain.DistributionCurrencyModel; | ||
| 9 | +import com.ruoyi.system.domain.IotProduct; | ||
| 10 | +import com.ruoyi.system.service.IIotProductService; | ||
| 11 | +import com.zhonglai.luhui.admin.dto.IotThingsModelAddApi; | ||
| 12 | +import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; | ||
| 13 | +import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.specs.*; | ||
| 14 | +import com.zhonglai.luhui.mqtt.service.db.mode.TerminalDataThingsModeService; | ||
| 6 | import io.swagger.annotations.Api; | 15 | import io.swagger.annotations.Api; |
| 7 | import io.swagger.annotations.ApiOperation; | 16 | import io.swagger.annotations.ApiOperation; |
| 8 | import org.springframework.security.access.prepost.PreAuthorize; | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 19 | +import org.springframework.transaction.annotation.Transactional; | ||
| 10 | import org.springframework.web.bind.annotation.GetMapping; | 20 | import org.springframework.web.bind.annotation.GetMapping; |
| 11 | import org.springframework.web.bind.annotation.PostMapping; | 21 | import org.springframework.web.bind.annotation.PostMapping; |
| 12 | import org.springframework.web.bind.annotation.PutMapping; | 22 | import org.springframework.web.bind.annotation.PutMapping; |
| @@ -26,7 +36,7 @@ import com.ruoyi.common.core.page.TableDataInfo; | @@ -26,7 +36,7 @@ import com.ruoyi.common.core.page.TableDataInfo; | ||
| 26 | 36 | ||
| 27 | /** | 37 | /** |
| 28 | * 物模型模板Controller | 38 | * 物模型模板Controller |
| 29 | - * | 39 | + * |
| 30 | * @author 钟来 | 40 | * @author 钟来 |
| 31 | * @date 2022-08-26 | 41 | * @date 2022-08-26 |
| 32 | */ | 42 | */ |
| @@ -38,6 +48,11 @@ public class IotThingsModelController extends BaseController | @@ -38,6 +48,11 @@ public class IotThingsModelController extends BaseController | ||
| 38 | @Autowired | 48 | @Autowired |
| 39 | private IIotThingsModelService iotThingsModelService; | 49 | private IIotThingsModelService iotThingsModelService; |
| 40 | 50 | ||
| 51 | + @Autowired | ||
| 52 | + private TerminalDataThingsModeService terminalDataThingsModeService; | ||
| 53 | + | ||
| 54 | + @Autowired | ||
| 55 | + private IIotProductService iIotProductService; | ||
| 41 | /** | 56 | /** |
| 42 | * 查询物模型模板列表 | 57 | * 查询物模型模板列表 |
| 43 | */ | 58 | */ |
| @@ -83,9 +98,46 @@ public class IotThingsModelController extends BaseController | @@ -83,9 +98,46 @@ public class IotThingsModelController extends BaseController | ||
| 83 | @PreAuthorize("@ss.hasPermi('iot:IotThingsModel:add')") | 98 | @PreAuthorize("@ss.hasPermi('iot:IotThingsModel:add')") |
| 84 | @Log(title = "物模型模板", businessType = BusinessType.INSERT) | 99 | @Log(title = "物模型模板", businessType = BusinessType.INSERT) |
| 85 | @PostMapping | 100 | @PostMapping |
| 86 | - public AjaxResult add(@RequestBody IotThingsModel iotThingsModel) | 101 | + public AjaxResult add(@RequestBody IotThingsModelAddApi iotThingsModelAddApi) |
| 87 | { | 102 | { |
| 88 | - return toAjax(iotThingsModelService.insertIotThingsModel(iotThingsModel)); | 103 | + IotThingsModel iotThingsModel = iotThingsModelAddApi.getIotThingsModel(); |
| 104 | + iotThingsModel.setCreate_by(getUsername()); | ||
| 105 | + ThingsModelItemBase thingsModelItemBase = null; | ||
| 106 | + switch (iotThingsModel.getData_type()) | ||
| 107 | + { | ||
| 108 | + case "integer": | ||
| 109 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), IntegerModelOutput.class); | ||
| 110 | + break; | ||
| 111 | + case "decimal": | ||
| 112 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), DecimalModelOutput.class); | ||
| 113 | + break; | ||
| 114 | + case "string": | ||
| 115 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), StringModelOutput.class); | ||
| 116 | + | ||
| 117 | + break; | ||
| 118 | + case "bool": | ||
| 119 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), BoolModelOutput.class); | ||
| 120 | + | ||
| 121 | + break; | ||
| 122 | + case "array": | ||
| 123 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), ArrayModelOutput.class); | ||
| 124 | + | ||
| 125 | + break; | ||
| 126 | + case "enum": | ||
| 127 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), EnumModelOutput.class); | ||
| 128 | + break; | ||
| 129 | + } | ||
| 130 | + if(null == thingsModelItemBase) | ||
| 131 | + { | ||
| 132 | + return AjaxResult.error("请输入数模型"); | ||
| 133 | + } | ||
| 134 | + iotThingsModel.setSpecs(JSONObject.toJSONString(thingsModelItemBase)); | ||
| 135 | + | ||
| 136 | + IotProduct iotProduct = iIotProductService.selectIotProductById(iotThingsModel.getProduct_id()); | ||
| 137 | + iotThingsModel.setMqtt_username(iotProduct.getMqtt_username()); | ||
| 138 | + int ri = iotThingsModelService.insertIotThingsModel(iotThingsModel); | ||
| 139 | + terminalDataThingsModeService.saveIotThingsModel(JSON.parseObject(JSONObject.toJSONString(iotThingsModel),IotThingsModel.class)); | ||
| 140 | + return toAjax(ri); | ||
| 89 | } | 141 | } |
| 90 | 142 | ||
| 91 | /** | 143 | /** |
| @@ -95,9 +147,47 @@ public class IotThingsModelController extends BaseController | @@ -95,9 +147,47 @@ public class IotThingsModelController extends BaseController | ||
| 95 | @PreAuthorize("@ss.hasPermi('iot:IotThingsModel:edit')") | 147 | @PreAuthorize("@ss.hasPermi('iot:IotThingsModel:edit')") |
| 96 | @Log(title = "物模型模板", businessType = BusinessType.UPDATE) | 148 | @Log(title = "物模型模板", businessType = BusinessType.UPDATE) |
| 97 | @PutMapping | 149 | @PutMapping |
| 98 | - public AjaxResult edit(@RequestBody IotThingsModel iotThingsModel) | 150 | + public AjaxResult edit(@RequestBody IotThingsModelAddApi iotThingsModelAddApi) |
| 99 | { | 151 | { |
| 100 | - return toAjax(iotThingsModelService.updateIotThingsModel(iotThingsModel)); | 152 | + IotThingsModel iotThingsModel = iotThingsModelAddApi.getIotThingsModel(); |
| 153 | + iotThingsModel.setCreate_by(getUsername()); | ||
| 154 | + ThingsModelItemBase thingsModelItemBase = null; | ||
| 155 | + switch (iotThingsModel.getData_type()) | ||
| 156 | + { | ||
| 157 | + case "integer": | ||
| 158 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), IntegerModelOutput.class); | ||
| 159 | + break; | ||
| 160 | + case "decimal": | ||
| 161 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), DecimalModelOutput.class); | ||
| 162 | + break; | ||
| 163 | + case "string": | ||
| 164 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), StringModelOutput.class); | ||
| 165 | + | ||
| 166 | + break; | ||
| 167 | + case "bool": | ||
| 168 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), BoolModelOutput.class); | ||
| 169 | + | ||
| 170 | + break; | ||
| 171 | + case "array": | ||
| 172 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), ArrayModelOutput.class); | ||
| 173 | + | ||
| 174 | + break; | ||
| 175 | + case "enum": | ||
| 176 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), EnumModelOutput.class); | ||
| 177 | + break; | ||
| 178 | + } | ||
| 179 | + if(null == thingsModelItemBase) | ||
| 180 | + { | ||
| 181 | + return AjaxResult.error("请输入数模型"); | ||
| 182 | + } | ||
| 183 | + iotThingsModel.setSpecs(JSONObject.toJSONString(thingsModelItemBase)); | ||
| 184 | + int ri =iotThingsModelService.updateIotThingsModel(iotThingsModel); | ||
| 185 | + | ||
| 186 | + IotThingsModel oldiotThingsModel = iotThingsModelService.selectIotThingsModelByModel_id(iotThingsModel.getModel_id()); | ||
| 187 | + IotProduct iotProduct = iIotProductService.selectIotProductById(oldiotThingsModel.getProduct_id()); | ||
| 188 | + iotThingsModel.setMqtt_username(iotProduct.getMqtt_username()); | ||
| 189 | + terminalDataThingsModeService.saveIotThingsModel(JSON.parseObject(JSONObject.toJSONString(iotThingsModel),IotThingsModel.class)); | ||
| 190 | + return toAjax(ri); | ||
| 101 | } | 191 | } |
| 102 | 192 | ||
| 103 | /** | 193 | /** |
| @@ -106,9 +196,49 @@ public class IotThingsModelController extends BaseController | @@ -106,9 +196,49 @@ public class IotThingsModelController extends BaseController | ||
| 106 | @ApiOperation("删除物模型模板") | 196 | @ApiOperation("删除物模型模板") |
| 107 | @PreAuthorize("@ss.hasPermi('iot:IotThingsModel:remove')") | 197 | @PreAuthorize("@ss.hasPermi('iot:IotThingsModel:remove')") |
| 108 | @Log(title = "物模型模板", businessType = BusinessType.DELETE) | 198 | @Log(title = "物模型模板", businessType = BusinessType.DELETE) |
| 199 | + @Transactional | ||
| 109 | @DeleteMapping("/{model_ids}") | 200 | @DeleteMapping("/{model_ids}") |
| 110 | public AjaxResult remove(@PathVariable Integer[] model_ids) | 201 | public AjaxResult remove(@PathVariable Integer[] model_ids) |
| 111 | { | 202 | { |
| 112 | - return toAjax(iotThingsModelService.deleteIotThingsModelByModel_ids(model_ids)); | 203 | + Map<String,List<String>> map = new HashMap<>(); |
| 204 | + List<IotThingsModel> list = iotThingsModelService.selectIotThingsModelListByIds(model_ids); | ||
| 205 | + if(null != list && list.size() !=0) | ||
| 206 | + { | ||
| 207 | + for(IotThingsModel iotThingsModel:list) | ||
| 208 | + { | ||
| 209 | + List<String> identifiers = map.get(iotThingsModel.getMqtt_username()); | ||
| 210 | + if(null == identifiers ) | ||
| 211 | + { | ||
| 212 | + identifiers = new ArrayList<>(); | ||
| 213 | + map.put(iotThingsModel.getMqtt_username(),identifiers); | ||
| 214 | + } | ||
| 215 | + identifiers.add(iotThingsModel.getIdentifier()); | ||
| 216 | + } | ||
| 217 | + } | ||
| 218 | + int ri =iotThingsModelService.deleteIotThingsModelByModel_ids(model_ids); | ||
| 219 | + if(null != map && map.size() !=0) | ||
| 220 | + { | ||
| 221 | + for(String key:map.keySet()) | ||
| 222 | + { | ||
| 223 | + terminalDataThingsModeService.delIotThingsModel(key, map.get(key).toArray()); | ||
| 224 | + } | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + return toAjax(ri); | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + @ApiOperation("分配通用模型") | ||
| 231 | + @PreAuthorize("@ss.hasPermi('iot:IotThingsModel:distributionTemplate')") | ||
| 232 | + @Log(title = "物模型模板", businessType = BusinessType.INSERT) | ||
| 233 | + @PostMapping("/distributionTemplate/{product_id}") | ||
| 234 | + public AjaxResult distributionTemplate(@PathVariable Integer product_id,Integer[] tmplatemModel_ids) | ||
| 235 | + { | ||
| 236 | + DistributionCurrencyModel distributionCurrencyModel = new DistributionCurrencyModel(); | ||
| 237 | + IotProduct iotProduct = iIotProductService.selectIotProductById(product_id); | ||
| 238 | + distributionCurrencyModel.setModel_ids(tmplatemModel_ids); | ||
| 239 | + distributionCurrencyModel.setMqtt_username(iotProduct.getMqtt_username()); | ||
| 240 | + distributionCurrencyModel.setProduct_id(iotProduct.getId()); | ||
| 241 | + int ri = iotThingsModelService.distributionIotThingsModelTemplate(distributionCurrencyModel); | ||
| 242 | + return toAjax(ri); | ||
| 113 | } | 243 | } |
| 114 | } | 244 | } |
lh-admin/src/main/java/com/zhonglai/luhui/admin/controller/iot/IotThingsModelTemplateController.java
0 → 100644
| 1 | +package com.zhonglai.luhui.admin.controller.iot; | ||
| 2 | + | ||
| 3 | +import java.util.Date; | ||
| 4 | +import java.util.List; | ||
| 5 | +import javax.servlet.http.HttpServletResponse; | ||
| 6 | + | ||
| 7 | +import com.alibaba.fastjson.JSON; | ||
| 8 | +import com.alibaba.fastjson.JSONObject; | ||
| 9 | +import com.ruoyi.system.domain.IotProduct; | ||
| 10 | +import com.ruoyi.system.domain.IotThingsModel; | ||
| 11 | +import com.ruoyi.system.service.IIotProductService; | ||
| 12 | +import com.zhonglai.luhui.admin.dto.IotThingsModelAddApi; | ||
| 13 | +import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; | ||
| 14 | +import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.specs.*; | ||
| 15 | +import io.swagger.annotations.Api; | ||
| 16 | +import io.swagger.annotations.ApiOperation; | ||
| 17 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 19 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 22 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 23 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 24 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 25 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 26 | +import org.springframework.web.bind.annotation.RestController; | ||
| 27 | +import com.ruoyi.common.annotation.Log; | ||
| 28 | +import com.ruoyi.common.core.controller.BaseController; | ||
| 29 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 30 | +import com.ruoyi.common.enums.BusinessType; | ||
| 31 | +import com.ruoyi.system.domain.IotThingsModelTemplate; | ||
| 32 | +import com.ruoyi.system.service.IIotThingsModelTemplateService; | ||
| 33 | +import com.ruoyi.common.utils.poi.ExcelUtil; | ||
| 34 | +import com.ruoyi.common.core.page.TableDataInfo; | ||
| 35 | + | ||
| 36 | +/** | ||
| 37 | + * 物模型模板Controller | ||
| 38 | + * | ||
| 39 | + * @author 钟来 | ||
| 40 | + * @date 2022-10-24 | ||
| 41 | + */ | ||
| 42 | +@Api(tags = "物模型模板公用模型") | ||
| 43 | +@RestController | ||
| 44 | +@RequestMapping("/iot/IotThingsModelTemplate") | ||
| 45 | +public class IotThingsModelTemplateController extends BaseController | ||
| 46 | +{ | ||
| 47 | + @Autowired | ||
| 48 | + private IIotThingsModelTemplateService iotThingsModelTemplateService; | ||
| 49 | + | ||
| 50 | + @Autowired | ||
| 51 | + private IIotProductService iIotProductService; | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 查询物模型模板列表 | ||
| 55 | + */ | ||
| 56 | + @ApiOperation("查询物模型模板列表") | ||
| 57 | + @PreAuthorize("@ss.hasPermi('iot:IotThingsModelTemplate:list')") | ||
| 58 | + @GetMapping("/list") | ||
| 59 | + public TableDataInfo list(IotThingsModelTemplate iotThingsModelTemplate) | ||
| 60 | + { | ||
| 61 | + startPage(); | ||
| 62 | + List<IotThingsModelTemplate> list = iotThingsModelTemplateService.selectIotThingsModelTemplateList(iotThingsModelTemplate); | ||
| 63 | + return getDataTable(list); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * 导出物模型模板列表 | ||
| 68 | + */ | ||
| 69 | + @ApiOperation("导出物模型模板列表") | ||
| 70 | + @PreAuthorize("@ss.hasPermi('iot:IotThingsModelTemplate:export')") | ||
| 71 | + @Log(title = "物模型模板", businessType = BusinessType.EXPORT) | ||
| 72 | + @PostMapping("/export") | ||
| 73 | + public void export(HttpServletResponse response, IotThingsModelTemplate iotThingsModelTemplate) | ||
| 74 | + { | ||
| 75 | + List<IotThingsModelTemplate> list = iotThingsModelTemplateService.selectIotThingsModelTemplateList(iotThingsModelTemplate); | ||
| 76 | + ExcelUtil<IotThingsModelTemplate> util = new ExcelUtil<IotThingsModelTemplate>(IotThingsModelTemplate.class); | ||
| 77 | + util.exportExcel(response, list, "物模型模板数据"); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 获取物模型模板详细信息 | ||
| 82 | + */ | ||
| 83 | + @ApiOperation("获取物模型模板详细信息") | ||
| 84 | + @PreAuthorize("@ss.hasPermi('iot:IotThingsModelTemplate:query')") | ||
| 85 | + @GetMapping(value = "/{model_id}") | ||
| 86 | + public AjaxResult getInfo(@PathVariable("model_id") Integer model_id) | ||
| 87 | + { | ||
| 88 | + return AjaxResult.success(iotThingsModelTemplateService.selectIotThingsModelTemplateByModel_id(model_id)); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 新增物模型模板 | ||
| 93 | + */ | ||
| 94 | + @ApiOperation("新增物模型模板") | ||
| 95 | + @PreAuthorize("@ss.hasPermi('iot:IotThingsModelTemplate:add')") | ||
| 96 | + @Log(title = "物模型模板", businessType = BusinessType.INSERT) | ||
| 97 | + @PostMapping | ||
| 98 | + public AjaxResult add(@RequestBody IotThingsModelAddApi iotThingsModelAddApi) | ||
| 99 | + { | ||
| 100 | + IotThingsModelTemplate iotThingsModel = JSONObject.parseObject(JSONObject.toJSONString(iotThingsModelAddApi.getIotThingsModel()),IotThingsModelTemplate.class); | ||
| 101 | + iotThingsModel.setCreate_by(getUsername()); | ||
| 102 | + ThingsModelItemBase thingsModelItemBase = null; | ||
| 103 | + switch (iotThingsModel.getData_type()) | ||
| 104 | + { | ||
| 105 | + case "integer": | ||
| 106 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), IntegerModelOutput.class); | ||
| 107 | + break; | ||
| 108 | + case "decimal": | ||
| 109 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), DecimalModelOutput.class); | ||
| 110 | + break; | ||
| 111 | + case "string": | ||
| 112 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), StringModelOutput.class); | ||
| 113 | + | ||
| 114 | + break; | ||
| 115 | + case "bool": | ||
| 116 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), BoolModelOutput.class); | ||
| 117 | + | ||
| 118 | + break; | ||
| 119 | + case "array": | ||
| 120 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), ArrayModelOutput.class); | ||
| 121 | + | ||
| 122 | + break; | ||
| 123 | + case "enum": | ||
| 124 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), EnumModelOutput.class); | ||
| 125 | + break; | ||
| 126 | + } | ||
| 127 | + if(null == thingsModelItemBase) | ||
| 128 | + { | ||
| 129 | + return AjaxResult.error("请输入数模型"); | ||
| 130 | + } | ||
| 131 | + iotThingsModel.setSpecs(JSONObject.toJSONString(thingsModelItemBase)); | ||
| 132 | + iotThingsModel.setCreate_time(new Date()); | ||
| 133 | + int ri = iotThingsModelTemplateService.insertIotThingsModelTemplate(iotThingsModel); | ||
| 134 | + return toAjax(ri); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * 修改物模型模板 | ||
| 139 | + */ | ||
| 140 | + @ApiOperation("修改物模型模板") | ||
| 141 | + @PreAuthorize("@ss.hasPermi('iot:IotThingsModelTemplate:edit')") | ||
| 142 | + @Log(title = "物模型模板", businessType = BusinessType.UPDATE) | ||
| 143 | + @PutMapping | ||
| 144 | + public AjaxResult edit(@RequestBody IotThingsModelAddApi iotThingsModelAddApi) | ||
| 145 | + { | ||
| 146 | + IotThingsModelTemplate iotThingsModel = JSONObject.parseObject(JSONObject.toJSONString(iotThingsModelAddApi.getIotThingsModel()),IotThingsModelTemplate.class); | ||
| 147 | + iotThingsModel.setCreate_by(getUsername()); | ||
| 148 | + ThingsModelItemBase thingsModelItemBase = null; | ||
| 149 | + switch (iotThingsModel.getData_type()) | ||
| 150 | + { | ||
| 151 | + case "integer": | ||
| 152 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), IntegerModelOutput.class); | ||
| 153 | + break; | ||
| 154 | + case "decimal": | ||
| 155 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), DecimalModelOutput.class); | ||
| 156 | + break; | ||
| 157 | + case "string": | ||
| 158 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), StringModelOutput.class); | ||
| 159 | + | ||
| 160 | + break; | ||
| 161 | + case "bool": | ||
| 162 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), BoolModelOutput.class); | ||
| 163 | + | ||
| 164 | + break; | ||
| 165 | + case "array": | ||
| 166 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), ArrayModelOutput.class); | ||
| 167 | + | ||
| 168 | + break; | ||
| 169 | + case "enum": | ||
| 170 | + thingsModelItemBase = JSONObject.parseObject(JSON.toJSONString(iotThingsModelAddApi.getThingsModelBase()), EnumModelOutput.class); | ||
| 171 | + break; | ||
| 172 | + } | ||
| 173 | + if(null == thingsModelItemBase) | ||
| 174 | + { | ||
| 175 | + return AjaxResult.error("请输入数模型"); | ||
| 176 | + } | ||
| 177 | + iotThingsModel.setSpecs(JSONObject.toJSONString(thingsModelItemBase)); | ||
| 178 | + int ri =iotThingsModelTemplateService.updateIotThingsModelTemplate(iotThingsModel); | ||
| 179 | + | ||
| 180 | + return toAjax(ri); | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * 删除物模型模板 | ||
| 185 | + */ | ||
| 186 | + @ApiOperation("删除物模型模板") | ||
| 187 | + @PreAuthorize("@ss.hasPermi('iot:IotThingsModelTemplate:remove')") | ||
| 188 | + @Log(title = "物模型模板", businessType = BusinessType.DELETE) | ||
| 189 | + @DeleteMapping("/{model_ids}") | ||
| 190 | + public AjaxResult remove(@PathVariable Integer[] model_ids) | ||
| 191 | + { | ||
| 192 | + return toAjax(iotThingsModelTemplateService.deleteIotThingsModelTemplateByModel_ids(model_ids)); | ||
| 193 | + } | ||
| 194 | +} |
| 1 | +package com.zhonglai.luhui.admin.dto; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.ruoyi.system.domain.IotThingsModel; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | + | ||
| 8 | +import java.util.Map; | ||
| 9 | + | ||
| 10 | +@ApiModel("物模型添加对象") | ||
| 11 | +public class IotThingsModelAddApi { | ||
| 12 | + @ApiModelProperty("物模型信息") | ||
| 13 | + private IotThingsModel iotThingsModel; | ||
| 14 | + @ApiModelProperty("specs数据定义对象") | ||
| 15 | + private Map<String,Object> thingsModelBase; | ||
| 16 | + | ||
| 17 | + public IotThingsModel getIotThingsModel() { | ||
| 18 | + return iotThingsModel; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public void setIotThingsModel(IotThingsModel iotThingsModel) { | ||
| 22 | + this.iotThingsModel = iotThingsModel; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public Map<String,Object> getThingsModelBase() { | ||
| 26 | + return thingsModelBase; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public void setThingsModelBase(Map<String,Object> thingsModelBase) { | ||
| 30 | + this.thingsModelBase = thingsModelBase; | ||
| 31 | + } | ||
| 32 | +} |
| @@ -6,7 +6,6 @@ spring: | @@ -6,7 +6,6 @@ spring: | ||
| 6 | druid: | 6 | druid: |
| 7 | # 主库数据源 | 7 | # 主库数据源 |
| 8 | master: | 8 | master: |
| 9 | -# url: jdbc:mysql://114.215.126.2:3306/jc-wenjuan?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 | ||
| 10 | url: jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 | 9 | url: jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| 11 | username: luhui | 10 | username: luhui |
| 12 | password: Luhui586 | 11 | password: Luhui586 |
| 1 | -# 项目相关配置 jhlt: # 名称 name: zhonglai # 版本 version: 3.8.2 # 版权年份 copyrightYear: 2022 # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) profile: D:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 captchaType: math # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8080 servlet: # 应用的访问路径 context-path: / tomcat: # tomcat的URI编码 uri-encoding: UTF-8 # 连接数满后的排队数,默认为100 accept-count: 1000 threads: # tomcat最大线程数,默认为200 max: 800 # Tomcat启动初始化的线程数,默认值10 min-spare: 100 # 日志配置 logging: level: com.ruoyi: debug org.springframework: warn # Spring配置 spring: # 资源信息 messages: # 国际化资源文件路径 basename: i18n/messages profiles: active: druid # 文件上传 servlet: multipart: # 单个文件大小 max-file-size: 10MB # 设置总上传的文件大小 max-request-size: 20MB # 服务模块 devtools: restart: # 热部署开关 enabled: true # redis 配置 redis: # 地址 host: 47.112.163.61 # 端口,默认为6379 port: 9527 # 数据库索引 database: 0 # 密码 password: Luhui586 # 连接超时时间 timeout: 10s lettuce: pool: # 连接池中的最小空闲连接 min-idle: 0 # 连接池中的最大空闲连接 max-idle: 8 # 连接池的最大数据库连接数 max-active: 8 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # token配置 token: # 令牌自定义标识 header: Authorization # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) expireTime: 30 # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=countSql # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # 防止XSS攻击 xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* sys: ## // 对于登录login 注册register 验证码captchaImage 允许匿名访问 antMatchers: /login,/register,/captchaImage,/getCacheObject,/v2/api-docs,/tool/gen/generatorCodeFromDb | ||
| 1 | +# 项目相关配置 jhlt: # 名称 name: zhonglai # 版本 version: 3.8.2 # 版权年份 copyrightYear: 2022 # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) profile: D:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 captchaType: math # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8080 servlet: # 应用的访问路径 context-path: / tomcat: # tomcat的URI编码 uri-encoding: UTF-8 # 连接数满后的排队数,默认为100 accept-count: 1000 threads: # tomcat最大线程数,默认为200 max: 800 # Tomcat启动初始化的线程数,默认值10 min-spare: 100 # 日志配置 logging: level: com.ruoyi: debug org.springframework: warn # Spring配置 spring: # 资源信息 messages: # 国际化资源文件路径 basename: i18n/messages profiles: active: druid # 文件上传 servlet: multipart: # 单个文件大小 max-file-size: 10MB # 设置总上传的文件大小 max-request-size: 20MB # 服务模块 devtools: restart: # 热部署开关 enabled: true # redis 配置 redis: # 地址 host: 47.112.163.61 # 端口,默认为6379 port: 9527 # 数据库索引 database: 1 # 密码 password: Luhui586 # 连接超时时间 timeout: 10s lettuce: pool: # 连接池中的最小空闲连接 min-idle: 0 # 连接池中的最大空闲连接 max-idle: 8 # 连接池的最大数据库连接数 max-active: 8 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # token配置 token: # 令牌自定义标识 header: Authorization # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) expireTime: 1440 # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=countSql # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # 防止XSS攻击 xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* mqtt: client: device_life: 180 sys: ## // 对于登录login 注册register 验证码captchaImage 允许匿名访问 antMatchers: /login,/register,/captchaImage,/getCacheObject,/v2/api-docs,/tool/gen/generatorCodeFromDb |
lh-api/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | + <parent> | ||
| 6 | + <artifactId>Luhui</artifactId> | ||
| 7 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 8 | + <version>1.0-SNAPSHOT</version> | ||
| 9 | + </parent> | ||
| 10 | + <modelVersion>4.0.0</modelVersion> | ||
| 11 | + | ||
| 12 | + <artifactId>lh-api</artifactId> | ||
| 13 | + | ||
| 14 | + <dependencies> | ||
| 15 | + <!-- spring-boot-devtools --> | ||
| 16 | + <dependency> | ||
| 17 | + <groupId>org.springframework.boot</groupId> | ||
| 18 | + <artifactId>spring-boot-devtools</artifactId> | ||
| 19 | + <optional>true</optional> <!-- 表示依赖不会传递 --> | ||
| 20 | + </dependency> | ||
| 21 | + | ||
| 22 | + <!-- Mysql驱动包 --> | ||
| 23 | + <dependency> | ||
| 24 | + <groupId>mysql</groupId> | ||
| 25 | + <artifactId>mysql-connector-java</artifactId> | ||
| 26 | + </dependency> | ||
| 27 | + | ||
| 28 | + <!-- 核心模块--> | ||
| 29 | + <dependency> | ||
| 30 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 31 | + <artifactId>ruoyi-framework</artifactId> | ||
| 32 | + </dependency> | ||
| 33 | + <!-- 代码生成模块--> | ||
| 34 | + <dependency> | ||
| 35 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 36 | + <artifactId>ruoyi-generator</artifactId> | ||
| 37 | + </dependency> | ||
| 38 | + <!-- 代码生成模块--> | ||
| 39 | + <dependency> | ||
| 40 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 41 | + <artifactId>lh-mqtt-service</artifactId> | ||
| 42 | + </dependency> | ||
| 43 | + <!-- 文档 --> | ||
| 44 | + <dependency > | ||
| 45 | + <groupId>io.springfox</groupId> | ||
| 46 | + <artifactId>springfox-swagger2</artifactId> | ||
| 47 | + <version>${swagger.version}</version> | ||
| 48 | + <exclusions> | ||
| 49 | + <exclusion> | ||
| 50 | + <groupId>io.swagger</groupId> | ||
| 51 | + <artifactId>swagger-models</artifactId> | ||
| 52 | + </exclusion> | ||
| 53 | + <exclusion> | ||
| 54 | + <groupId>com.google.guava</groupId> | ||
| 55 | + <artifactId>guava</artifactId> | ||
| 56 | + </exclusion> | ||
| 57 | + </exclusions> | ||
| 58 | + </dependency> | ||
| 59 | + <!--https://mvnrepository.com/artifact/io.swagger/swagger-models--> | ||
| 60 | + <dependency> | ||
| 61 | + <groupId>io.swagger</groupId> | ||
| 62 | + <artifactId>swagger-models</artifactId> | ||
| 63 | + <version>${swagger-models.version}</version> | ||
| 64 | + </dependency> | ||
| 65 | + <dependency> | ||
| 66 | + <groupId>io.springfox</groupId> | ||
| 67 | + <artifactId>springfox-swagger-ui</artifactId> | ||
| 68 | + <version>${swagger.version}</version> | ||
| 69 | + </dependency> | ||
| 70 | + <!--<!– https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui –>--> | ||
| 71 | + <dependency> | ||
| 72 | + <groupId>com.github.xiaoymin</groupId> | ||
| 73 | + <artifactId>swagger-bootstrap-ui</artifactId> | ||
| 74 | + <version>${swagger-ui.version}</version> | ||
| 75 | + </dependency> | ||
| 76 | + | ||
| 77 | + <dependency> | ||
| 78 | + <groupId>org.aspectj</groupId> | ||
| 79 | + <artifactId>aspectjweaver</artifactId> | ||
| 80 | + </dependency> | ||
| 81 | + <dependency> | ||
| 82 | + <groupId>org.aspectj</groupId> | ||
| 83 | + <artifactId>aspectjrt</artifactId> | ||
| 84 | + </dependency> | ||
| 85 | + </dependencies> | ||
| 86 | + | ||
| 87 | + <build> | ||
| 88 | + <finalName>lh-api</finalName> | ||
| 89 | + <plugins> | ||
| 90 | + <plugin> | ||
| 91 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 92 | + <artifactId>maven-jar-plugin</artifactId> | ||
| 93 | + <version>2.4</version> | ||
| 94 | + <configuration> | ||
| 95 | + <archive> | ||
| 96 | + <!-- | ||
| 97 | + 生成的jar中,不要包含pom.xml和pom.properties这两个文件 | ||
| 98 | + --> | ||
| 99 | + <addMavenDescriptor>false</addMavenDescriptor> | ||
| 100 | + <manifest> | ||
| 101 | + <!-- | ||
| 102 | + 是否要把第三方jar放到manifest的classpath中 | ||
| 103 | + --> | ||
| 104 | + <addClasspath>true</addClasspath> | ||
| 105 | + | ||
| 106 | + <!-- | ||
| 107 | + 生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/ | ||
| 108 | + --> | ||
| 109 | + <classpathPrefix>lib/</classpathPrefix> | ||
| 110 | + <mainClass>com.zhonglai.luhui.admin.AdminApplication</mainClass> | ||
| 111 | + </manifest> | ||
| 112 | + </archive> | ||
| 113 | + </configuration> | ||
| 114 | + </plugin> | ||
| 115 | + | ||
| 116 | + <!-- The configuration of maven-assembly-plugin --> | ||
| 117 | + <plugin> | ||
| 118 | + <groupId>org.apache.maven.plugins</groupId> | ||
| 119 | + <artifactId>maven-assembly-plugin</artifactId> | ||
| 120 | + <version>2.4</version> | ||
| 121 | + <configuration> | ||
| 122 | + <descriptors> | ||
| 123 | + <descriptor>src/main/resources/package.xml</descriptor> | ||
| 124 | + </descriptors> | ||
| 125 | + </configuration> | ||
| 126 | + <executions> | ||
| 127 | + <execution> | ||
| 128 | + <id>make-assembly</id> | ||
| 129 | + <phase>package</phase> | ||
| 130 | + <goals> | ||
| 131 | + <goal>single</goal> | ||
| 132 | + </goals> | ||
| 133 | + </execution> | ||
| 134 | + </executions> | ||
| 135 | + </plugin> | ||
| 136 | + </plugins> | ||
| 137 | + </build> | ||
| 138 | +</project> |
lh-central-control/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | + <parent> | ||
| 6 | + <artifactId>Luhui</artifactId> | ||
| 7 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 8 | + <version>1.0-SNAPSHOT</version> | ||
| 9 | + </parent> | ||
| 10 | + <modelVersion>4.0.0</modelVersion> | ||
| 11 | + | ||
| 12 | + <artifactId>lh-central-control</artifactId> | ||
| 13 | + | ||
| 14 | + <description> | ||
| 15 | + 中控平台 | ||
| 16 | + </description> | ||
| 17 | + | ||
| 18 | + <dependencies> | ||
| 19 | + <!-- spring-boot-devtools --> | ||
| 20 | + <dependency> | ||
| 21 | + <groupId>org.springframework.boot</groupId> | ||
| 22 | + <artifactId>spring-boot-devtools</artifactId> | ||
| 23 | + <optional>true</optional> <!-- 表示依赖不会传递 --> | ||
| 24 | + </dependency> | ||
| 25 | + <!-- SpringBoot Web容器 --> | ||
| 26 | + <dependency> | ||
| 27 | + <groupId>org.springframework.boot</groupId> | ||
| 28 | + <artifactId>spring-boot-starter-web</artifactId> | ||
| 29 | + </dependency> | ||
| 30 | + <!-- Spring框架基本的核心工具 --> | ||
| 31 | + <dependency> | ||
| 32 | + <groupId>org.springframework</groupId> | ||
| 33 | + <artifactId>spring-context-support</artifactId> | ||
| 34 | + </dependency> | ||
| 35 | + <!-- SpringWeb模块 --> | ||
| 36 | + <dependency> | ||
| 37 | + <groupId>org.springframework</groupId> | ||
| 38 | + <artifactId>spring-web</artifactId> | ||
| 39 | + </dependency> | ||
| 40 | + <!-- servlet包 --> | ||
| 41 | + <dependency> | ||
| 42 | + <groupId>javax.servlet</groupId> | ||
| 43 | + <artifactId>javax.servlet-api</artifactId> | ||
| 44 | + </dependency> | ||
| 45 | + <dependency> | ||
| 46 | + <groupId>org.apache.commons</groupId> | ||
| 47 | + <artifactId>commons-text</artifactId> | ||
| 48 | + </dependency> | ||
| 49 | + | ||
| 50 | + <!-- 文档 --> | ||
| 51 | + <dependency> | ||
| 52 | + <groupId>io.springfox</groupId> | ||
| 53 | + <artifactId>springfox-swagger2</artifactId> | ||
| 54 | + <version>${swagger.version}</version> | ||
| 55 | + <exclusions> | ||
| 56 | + <exclusion> | ||
| 57 | + <groupId>io.swagger</groupId> | ||
| 58 | + <artifactId>swagger-models</artifactId> | ||
| 59 | + </exclusion> | ||
| 60 | + <exclusion> | ||
| 61 | + <groupId>com.google.guava</groupId> | ||
| 62 | + <artifactId>guava</artifactId> | ||
| 63 | + </exclusion> | ||
| 64 | + </exclusions> | ||
| 65 | + </dependency> | ||
| 66 | + <!--https://mvnrepository.com/artifact/io.swagger/swagger-models--> | ||
| 67 | + <dependency> | ||
| 68 | + <groupId>io.swagger</groupId> | ||
| 69 | + <artifactId>swagger-models</artifactId> | ||
| 70 | + <version>${swagger-models.version}</version> | ||
| 71 | + </dependency> | ||
| 72 | + <dependency> | ||
| 73 | + <groupId>io.springfox</groupId> | ||
| 74 | + <artifactId>springfox-swagger-ui</artifactId> | ||
| 75 | + <version>${swagger.version}</version> | ||
| 76 | + </dependency> | ||
| 77 | + <!--<!– https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui –>--> | ||
| 78 | + <dependency> | ||
| 79 | + <groupId>com.github.xiaoymin</groupId> | ||
| 80 | + <artifactId>swagger-bootstrap-ui</artifactId> | ||
| 81 | + <version>${swagger-ui.version}</version> | ||
| 82 | + </dependency> | ||
| 83 | + | ||
| 84 | + <!-- mqtt --> | ||
| 85 | + <dependency> | ||
| 86 | + <groupId>org.eclipse.paho</groupId> | ||
| 87 | + <artifactId>org.eclipse.paho.client.mqttv3</artifactId> | ||
| 88 | + </dependency> | ||
| 89 | + | ||
| 90 | + <dependency> | ||
| 91 | + <groupId>net.jodah</groupId> | ||
| 92 | + <artifactId>expiringmap</artifactId> | ||
| 93 | + </dependency> | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + <!-- 数据库 --> | ||
| 97 | + <dependency> | ||
| 98 | + <groupId>commons-dbcp</groupId> | ||
| 99 | + <artifactId>commons-dbcp</artifactId> | ||
| 100 | + <version>1.4</version> | ||
| 101 | + </dependency> | ||
| 102 | + <dependency> | ||
| 103 | + <groupId>commons-dbutils</groupId> | ||
| 104 | + <artifactId>commons-dbutils</artifactId> | ||
| 105 | + <version>1.6</version> | ||
| 106 | + </dependency> | ||
| 107 | + <dependency> | ||
| 108 | + <groupId>commons-pool</groupId> | ||
| 109 | + <artifactId>commons-pool</artifactId> | ||
| 110 | + <version>1.6</version> | ||
| 111 | + </dependency> | ||
| 112 | + <dependency> | ||
| 113 | + <groupId>mysql</groupId> | ||
| 114 | + <artifactId>mysql-connector-java</artifactId> | ||
| 115 | + <version>8.0.17</version> | ||
| 116 | + </dependency> | ||
| 117 | + | ||
| 118 | + <!-- 阿里JSON解析器 --> | ||
| 119 | + <dependency> | ||
| 120 | + <groupId>com.alibaba</groupId> | ||
| 121 | + <artifactId>fastjson</artifactId> | ||
| 122 | + </dependency> | ||
| 123 | + | ||
| 124 | + <!--常用工具类 --> | ||
| 125 | + <dependency> | ||
| 126 | + <groupId>org.apache.commons</groupId> | ||
| 127 | + <artifactId>commons-lang3</artifactId> | ||
| 128 | + </dependency> | ||
| 129 | + | ||
| 130 | + <!-- redis 缓存操作 --> | ||
| 131 | + <dependency> | ||
| 132 | + <groupId>org.springframework.boot</groupId> | ||
| 133 | + <artifactId>spring-boot-starter-data-redis</artifactId> | ||
| 134 | + <exclusions> | ||
| 135 | + <exclusion> | ||
| 136 | + <groupId>io.lettuce</groupId> | ||
| 137 | + <artifactId>lettuce-core</artifactId> | ||
| 138 | + </exclusion> | ||
| 139 | + </exclusions> | ||
| 140 | + </dependency> | ||
| 141 | + <dependency> | ||
| 142 | + <groupId>redis.clients</groupId> | ||
| 143 | + <artifactId>jedis</artifactId> | ||
| 144 | + </dependency> | ||
| 145 | + | ||
| 146 | + <!-- 通用工具--> | ||
| 147 | + <dependency> | ||
| 148 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 149 | + <artifactId>lh-domain</artifactId> | ||
| 150 | + </dependency> | ||
| 151 | + | ||
| 152 | + </dependencies> | ||
| 153 | +</project> |
| 1 | +package com.zhonglai.luhui.central.control.comm; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +public class Message { | ||
| 5 | + private int code; | ||
| 6 | + private String message; | ||
| 7 | + private Object data; | ||
| 8 | + | ||
| 9 | + public Message() { | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + public Message(MessageCodeType code, String message, Object data) { | ||
| 13 | + this.code = code.getCode(); | ||
| 14 | + this.message = message; | ||
| 15 | + if (null == message || "".equals(message)) { | ||
| 16 | + this.message = code.getMessage(); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + this.data = data; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public Message(MessageCodeType code, Object data) { | ||
| 23 | + this.code = code.getCode(); | ||
| 24 | + this.message = code.getMessage(); | ||
| 25 | + this.data = data; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public Message(MessageCodeType code, String message) { | ||
| 29 | + this.code = code.getCode(); | ||
| 30 | + this.message = message; | ||
| 31 | + this.data = null; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public Message(MessageCodeType code) { | ||
| 35 | + this.code = code.getCode(); | ||
| 36 | + this.message = code.getMessage(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setCode(MessageCode messageCode ) | ||
| 40 | + { | ||
| 41 | + code = messageCode.code; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public void setCode(MessageCodeType code) { | ||
| 45 | + this.code = code.getCode(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public int getCode() { | ||
| 49 | + return code; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setCode(int code) { | ||
| 53 | + this.code = code; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public String getMessage() { | ||
| 57 | + return message; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setMessage(String message) { | ||
| 61 | + this.message = message; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public Object getData() { | ||
| 65 | + return data; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void setData(Object data) { | ||
| 69 | + this.data = data; | ||
| 70 | + } | ||
| 71 | +} |
lh-central-control/src/main/java/com/zhonglai/luhui/central/control/comm/MessageCode.java
0 → 100644
| 1 | +package com.zhonglai.luhui.central.control.comm; | ||
| 2 | + | ||
| 3 | +public enum MessageCode implements MessageCodeType{ | ||
| 4 | + DEFAULT_FAIL_CODE(0, "请求失败"), | ||
| 5 | + DEFAULT_SUCCESS_CODE(1, "请求成功"), | ||
| 6 | + SESSION_TIME_OUT(2, "会话超时,请刷新令牌"), | ||
| 7 | + USER_INVALID(4, "用户失效,请重新登录"), | ||
| 8 | + SYS_ERROR(3, "已知系统错误"), | ||
| 9 | + REQUEST_METHOD_ERROR(6, "请求方式错误"), | ||
| 10 | + REQUEST_PATH_ERROR(7, "请求路径错误"), | ||
| 11 | + UNKNOWN_SYS_ERROR(5, "未知系统错误"); | ||
| 12 | + | ||
| 13 | + public int code; | ||
| 14 | + public String message; | ||
| 15 | + | ||
| 16 | + public int getCode() { | ||
| 17 | + return this.code; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public String getMessage() { | ||
| 21 | + return this.message; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + private MessageCode(int code, String message) { | ||
| 25 | + this.code = code; | ||
| 26 | + this.message = message; | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package com.zhonglai.luhui.central.control.comm; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * mqtt消息解析结果 | ||
| 5 | + */ | ||
| 6 | +public enum MqttAnalysisMessageResult { | ||
| 7 | + /** | ||
| 8 | + * 成功 | ||
| 9 | + */ | ||
| 10 | + Success, | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 失败 | ||
| 14 | + */ | ||
| 15 | + Fail, | ||
| 16 | + /** | ||
| 17 | + *topic异常 | ||
| 18 | + */ | ||
| 19 | + TopicException, | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + *设备不存在 | ||
| 23 | + */ | ||
| 24 | + DeviceDoesNotExist, | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + *payload解析异常 | ||
| 28 | + */ | ||
| 29 | + PayloadParsingException | ||
| 30 | +} |
lh-central-control/src/main/java/com/zhonglai/luhui/central/control/comm/MyException.java
0 → 100644
| 1 | +package com.zhonglai.luhui.central.control.comm; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +public class MyException extends RuntimeException{ | ||
| 5 | + private static final long serialVersionUID = 8827598182853467258L; | ||
| 6 | + private Message errmge; | ||
| 7 | + | ||
| 8 | + public MyException(Message myMessage) { | ||
| 9 | + super(myMessage.getMessage()); | ||
| 10 | + this.errmge = myMessage; | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + public MyException(String message, Throwable cause) { | ||
| 14 | + super(message, cause); | ||
| 15 | + } | ||
| 16 | + public MyException(String message) { | ||
| 17 | + super(message); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | +} |
lh-central-control/src/main/java/com/zhonglai/luhui/central/control/comm/SysParameter.java
0 → 100644
| 1 | +package com.zhonglai.luhui.central.control.comm; | ||
| 2 | + | ||
| 3 | +import org.slf4j.Logger; | ||
| 4 | +import org.slf4j.LoggerFactory; | ||
| 5 | +import org.springframework.beans.factory.annotation.Value; | ||
| 6 | +import org.springframework.context.annotation.Configuration; | ||
| 7 | + | ||
| 8 | +import javax.annotation.PostConstruct; | ||
| 9 | + | ||
| 10 | +@Configuration | ||
| 11 | +public class SysParameter { | ||
| 12 | + private static Logger log = LoggerFactory.getLogger(SysParameter.class); | ||
| 13 | + | ||
| 14 | + public static String service_ip = ""; //服务所在地址 | ||
| 15 | + | ||
| 16 | + @Value("${mqtt.topicconfig:/{{roleid}}/{{username}}/{{clientid}}/{{topicType}}/{{messageid}}}") | ||
| 17 | + public String tempTopicconfig ; //topic 配置 | ||
| 18 | + | ||
| 19 | + @Value("${mqtt.topics") | ||
| 20 | + public String topics ; //topic | ||
| 21 | + | ||
| 22 | + public static String topicconfig ; //topic 配置 | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + @PostConstruct | ||
| 26 | + public void init() { | ||
| 27 | + inittopicconfig(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public void inittopicconfig() | ||
| 31 | + { | ||
| 32 | + topicconfig = tempTopicconfig; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | +} |
| 1 | +package com.zhonglai.luhui.central.control.comm; | ||
| 2 | + | ||
| 3 | +import org.apache.commons.lang3.StringUtils; | ||
| 4 | +import org.slf4j.Logger; | ||
| 5 | +import org.slf4j.LoggerFactory; | ||
| 6 | + | ||
| 7 | +import java.lang.reflect.Field; | ||
| 8 | +import java.util.Optional; | ||
| 9 | + | ||
| 10 | +public class Topic { | ||
| 11 | + private static final Logger log = LoggerFactory.getLogger(Topic.class); | ||
| 12 | + | ||
| 13 | + private String roleid; | ||
| 14 | + private String username; | ||
| 15 | + private String clientid; | ||
| 16 | + private String topicType; | ||
| 17 | + private String messageid; | ||
| 18 | + private String payloadtype; | ||
| 19 | + | ||
| 20 | + public Topic() { | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public Topic(String roleid, String username, String clientid, String topicType, String payloadtype) { | ||
| 24 | + this.roleid = roleid; | ||
| 25 | + this.username = username; | ||
| 26 | + this.clientid = clientid; | ||
| 27 | + this.topicType = topicType; | ||
| 28 | + this.payloadtype = payloadtype; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public Topic(String roleid, String username, String clientid, String topicType, String messageid, String payloadtype) { | ||
| 32 | + this.roleid = roleid; | ||
| 33 | + this.username = username; | ||
| 34 | + this.clientid = clientid; | ||
| 35 | + this.topicType = topicType; | ||
| 36 | + this.messageid = messageid; | ||
| 37 | + this.payloadtype = payloadtype; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public Topic(String topic) | ||
| 41 | + { | ||
| 42 | + topic = Optional.ofNullable(topic).orElseThrow(()->new MyException("topic为空")); | ||
| 43 | + String[] sts = topic.split("/"); | ||
| 44 | + String[] config = SysParameter.topicconfig.split("/"); | ||
| 45 | + int number = sts.length; | ||
| 46 | + if(number>config.length) | ||
| 47 | + { | ||
| 48 | + number = config.length; | ||
| 49 | + } | ||
| 50 | + for(int i=1;i<number;i++) | ||
| 51 | + { | ||
| 52 | + String cf = config[i].replace("{{","").replace("}}",""); | ||
| 53 | + try { | ||
| 54 | + Field field = this.getClass().getDeclaredField(cf); | ||
| 55 | + field.set(this,sts[i]); | ||
| 56 | + } catch (NoSuchFieldException e) { | ||
| 57 | + log.info("{}生成topic时没有属性{}",topic,cf); | ||
| 58 | + } catch (IllegalAccessException e) { | ||
| 59 | + log.info("{}生成topic时无法给{}赋值{}",topic,cf,sts[i]); | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + if("ONLINE".equals(topicType.toUpperCase())) | ||
| 64 | + { | ||
| 65 | + this.payloadtype = "String"; | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 生成缓存关键字 | ||
| 71 | + * @return | ||
| 72 | + */ | ||
| 73 | + public String generateRedicKey() | ||
| 74 | + { | ||
| 75 | + return generate(":"); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 生成发送消息的topic | ||
| 80 | + * @return | ||
| 81 | + */ | ||
| 82 | + public String generateSendMessageTopic() | ||
| 83 | + { | ||
| 84 | + return "/"+generate("/"); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 生成客户端关键字 | ||
| 89 | + * @return | ||
| 90 | + */ | ||
| 91 | + public String generateClienKey() | ||
| 92 | + { | ||
| 93 | + return "/"+generate("/"); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + private String generate(String division) | ||
| 97 | + { | ||
| 98 | + String str = SysParameter.topicconfig; | ||
| 99 | + if(StringUtils.isEmpty(roleid)) | ||
| 100 | + { | ||
| 101 | + roleid = "2"; | ||
| 102 | + } | ||
| 103 | + str = str.replace("/{{roleid}}",roleid+division); | ||
| 104 | + | ||
| 105 | + if(StringUtils.isEmpty(username)) | ||
| 106 | + { | ||
| 107 | + username = "+"; | ||
| 108 | + } | ||
| 109 | + str = str.replace("/{{username}}",username+division); | ||
| 110 | + | ||
| 111 | + if(StringUtils.isEmpty(clientid)) | ||
| 112 | + { | ||
| 113 | + clientid = "+"; | ||
| 114 | + } | ||
| 115 | + str = str.replace("/{{clientid}}",clientid+division); | ||
| 116 | + | ||
| 117 | + if(StringUtils.isEmpty(payloadtype)) | ||
| 118 | + { | ||
| 119 | + payloadtype = "String"; | ||
| 120 | + } | ||
| 121 | + str = str.replace("/{{payloadtype}}",payloadtype+division); | ||
| 122 | + | ||
| 123 | + if(StringUtils.isEmpty(topicType)) | ||
| 124 | + { | ||
| 125 | + topicType = "PUT"; | ||
| 126 | + } | ||
| 127 | + str = str.replace("/{{topicType}}",topicType+division); | ||
| 128 | + | ||
| 129 | + if(StringUtils.isNotEmpty(messageid)) | ||
| 130 | + { | ||
| 131 | + str = str.replace("/{{messageid}}",messageid); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + return str; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public String getRoleid() { | ||
| 138 | + return roleid; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public void setRoleid(String roleid) { | ||
| 142 | + this.roleid = roleid; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public String getUsername() { | ||
| 146 | + return username; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public void setUsername(String username) { | ||
| 150 | + this.username = username; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + public String getClientid() { | ||
| 154 | + return clientid; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public void setClientid(String clientid) { | ||
| 158 | + this.clientid = clientid; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + public String getTopicType() { | ||
| 162 | + return topicType; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + public void setTopicType(String topicType) { | ||
| 166 | + this.topicType = topicType; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + public String getMessageid() { | ||
| 170 | + return messageid; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + public void setMessageid(String messageid) { | ||
| 174 | + this.messageid = messageid; | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + public String getPayloadtype() { | ||
| 178 | + return payloadtype; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + public void setPayloadtype(String payloadtype) { | ||
| 182 | + this.payloadtype = payloadtype; | ||
| 183 | + } | ||
| 184 | +} |
lh-central-control/src/main/java/com/zhonglai/luhui/central/control/config/MqttConfig.java
0 → 100644
| 1 | +package com.zhonglai.luhui.central.control.config; | ||
| 2 | + | ||
| 3 | +import org.springframework.beans.factory.annotation.Value; | ||
| 4 | +import org.springframework.stereotype.Component; | ||
| 5 | + | ||
| 6 | +@Component | ||
| 7 | +public class MqttConfig { | ||
| 8 | + @Value("${mqtt.broker}") | ||
| 9 | + private String broker; | ||
| 10 | + @Value("${mqtt.clientId}") | ||
| 11 | + private String clientId; | ||
| 12 | + @Value("${mqtt.topics}") | ||
| 13 | + private String topics; | ||
| 14 | + @Value("${mqtt.username}") | ||
| 15 | + private String username; | ||
| 16 | + @Value("${mqtt.password}") | ||
| 17 | + private String password; | ||
| 18 | + | ||
| 19 | + public String getBroker() { | ||
| 20 | + return broker; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setBroker(String broker) { | ||
| 24 | + this.broker = broker; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public String getClientId() { | ||
| 28 | + return clientId; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setClientId(String clientId) { | ||
| 32 | + this.clientId = clientId; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public String getTopics() { | ||
| 36 | + return topics; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setTopics(String topics) { | ||
| 40 | + this.topics = topics; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getUsername() { | ||
| 44 | + return username; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setUsername(String username) { | ||
| 48 | + this.username = username; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public String getPassword() { | ||
| 52 | + return password; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void setPassword(String password) { | ||
| 56 | + this.password = password; | ||
| 57 | + } | ||
| 58 | +} |
lh-central-control/src/main/java/com/zhonglai/luhui/central/control/service/MqttClientService.java
0 → 100644
| 1 | +package com.zhonglai.luhui.central.control.service; | ||
| 2 | + | ||
| 3 | +import com.zhonglai.luhui.central.control.config.MqttConfig; | ||
| 4 | +import com.zhonglai.luhui.central.control.util.ByteUtil; | ||
| 5 | +import org.eclipse.paho.client.mqttv3.*; | ||
| 6 | +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | + | ||
| 12 | +import javax.annotation.PostConstruct; | ||
| 13 | + | ||
| 14 | +@Service | ||
| 15 | +public class MqttClientService { | ||
| 16 | + private Logger log = LoggerFactory.getLogger(MqttClientService.class); | ||
| 17 | + | ||
| 18 | + @Autowired | ||
| 19 | + private MqttConfig mqttConfig; | ||
| 20 | + | ||
| 21 | + @Autowired | ||
| 22 | + private MqttMessageArrivedService mqttMessageArrivedService; | ||
| 23 | + | ||
| 24 | + @Autowired | ||
| 25 | + private MqttOperation mqttOperation; | ||
| 26 | + | ||
| 27 | + private MqttClient mqttclient; | ||
| 28 | + | ||
| 29 | + private MqttConnectOptions options; | ||
| 30 | + | ||
| 31 | + { | ||
| 32 | + if(null == mqttclient) | ||
| 33 | + { | ||
| 34 | + try { | ||
| 35 | + mqttclient = new MqttClient(mqttConfig.getBroker(), mqttConfig.getClientId(), new MemoryPersistence()); | ||
| 36 | + } catch (MqttException e) { | ||
| 37 | + e.printStackTrace(); | ||
| 38 | + } | ||
| 39 | + options = new MqttConnectOptions(); | ||
| 40 | + options.setCleanSession(true); | ||
| 41 | + options.setConnectionTimeout(15); | ||
| 42 | + //设置断开后重新连接 | ||
| 43 | + options.setAutomaticReconnect(true); | ||
| 44 | + mqttclient.setCallback(new MqttCallbackExtended() { | ||
| 45 | + @Override | ||
| 46 | + public void connectComplete(boolean b, String s) { | ||
| 47 | + log.info("连接成功"); | ||
| 48 | + try { | ||
| 49 | + subscribe(); | ||
| 50 | + } catch (MqttException e) { | ||
| 51 | + e.printStackTrace(); | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Override | ||
| 56 | + public void connectionLost(Throwable cause) { | ||
| 57 | + log.error("连接丢失",cause); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public void messageArrived(String topic, MqttMessage message) { | ||
| 62 | + log.info("接收到消息topc:{}, mqttMessage {},payload 十六进制 {}",topic,message, ByteUtil.hexStringToSpace(ByteUtil.toHexString(message.getPayload()))); | ||
| 63 | + mqttMessageArrivedService.analysisMessage(topic,message); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public void deliveryComplete(IMqttDeliveryToken token) { | ||
| 68 | + try { | ||
| 69 | + log.info("成功发出消息 messageid{}",token.getMessage()); | ||
| 70 | + } catch (MqttException e) { | ||
| 71 | + e.printStackTrace(); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + }); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @PostConstruct | ||
| 80 | + public void init() throws MqttException { | ||
| 81 | + log.info("-----------终端数据模型配置成功--------------------"); | ||
| 82 | + connect(); | ||
| 83 | + log.info("-----------mqtt连接服务器成功--------------------"); | ||
| 84 | + subscribe(); | ||
| 85 | + log.info("-----------订阅{}成功--------------------",mqttConfig.getTopics()); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + private void connect() throws MqttException { | ||
| 89 | + options.setUserName(mqttConfig.getUsername()); | ||
| 90 | + options.setPassword(mqttConfig.getPassword().toCharArray()); | ||
| 91 | + mqttclient.connect(options); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + private void subscribe() throws MqttException { | ||
| 95 | + mqttOperation.subscribe(mqttclient,mqttConfig.getTopics().split(",")); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | +} |
| 1 | +package com.zhonglai.luhui.central.control.service; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.system.domain.IotDevice; | ||
| 4 | +import com.zhonglai.luhui.central.control.comm.MqttAnalysisMessageResult; | ||
| 5 | +import com.zhonglai.luhui.central.control.comm.Topic; | ||
| 6 | +import org.eclipse.paho.client.mqttv3.MqttMessage; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 数据解析业务 | ||
| 14 | + */ | ||
| 15 | +@Service | ||
| 16 | +public class MqttMessageArrivedService { | ||
| 17 | + @Autowired | ||
| 18 | + private DeviceService deviceService ; | ||
| 19 | + | ||
| 20 | + private Logger log = LoggerFactory.getLogger(MqttMessageArrivedService.class); | ||
| 21 | + | ||
| 22 | + public MqttAnalysisMessageResult analysisMessage(String topicStr, MqttMessage message) | ||
| 23 | + { | ||
| 24 | + Topic topic = new Topic(topicStr); | ||
| 25 | + if(null == topic) | ||
| 26 | + { | ||
| 27 | + log.error("消息{},解析出来的topic为空,不做解析",topicStr); | ||
| 28 | + return MqttAnalysisMessageResult.TopicException; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + IotDevice iotDevice = deviceService.getDeviceById(topic.getClientid()); | ||
| 32 | + if(null == iotDevice) | ||
| 33 | + { | ||
| 34 | + log.info("设备{}不存在",topic.getClientid()); | ||
| 35 | + return MqttAnalysisMessageResult.DeviceDoesNotExist; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + //消息分发 | ||
| 39 | + try { | ||
| 40 | +// messageDistribution(); | ||
| 41 | + }catch (Exception e) | ||
| 42 | + { | ||
| 43 | + log.info("消息解析异常",e); | ||
| 44 | + return MqttAnalysisMessageResult.PayloadParsingException; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + return MqttAnalysisMessageResult.Success; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | +} |
lh-central-control/src/main/java/com/zhonglai/luhui/central/control/service/MqttOperation.java
0 → 100644
| 1 | +package com.zhonglai.luhui.central.control.service; | ||
| 2 | + | ||
| 3 | +import org.eclipse.paho.client.mqttv3.MqttClient; | ||
| 4 | +import org.eclipse.paho.client.mqttv3.MqttException; | ||
| 5 | +import org.eclipse.paho.client.mqttv3.MqttMessage; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | + | ||
| 8 | +import java.nio.ByteBuffer; | ||
| 9 | +import java.nio.charset.Charset; | ||
| 10 | + | ||
| 11 | +@Service | ||
| 12 | +public class MqttOperation { | ||
| 13 | + public void subscribe(MqttClient mqttclient,String[] topicFilters) throws MqttException { | ||
| 14 | + mqttclient.subscribe(topicFilters); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public void publish(MqttClient mqttclient,String topic, MqttMessage message) throws MqttException { | ||
| 18 | + mqttclient.publish(topic,message); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public void publish(MqttClient mqttclient,String topic, String messageStr) throws MqttException { | ||
| 22 | + MqttMessage message = new MqttMessage(); | ||
| 23 | + message.setPayload(messageStr.getBytes()); | ||
| 24 | + mqttclient.publish(topic,message); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public void closeClient (MqttClient mqttclient,String clientId,String code,String messageStr) throws MqttException { | ||
| 28 | + String topic = "SYSOPERATION/CLOSE"; | ||
| 29 | + MqttMessage message = new MqttMessage(); | ||
| 30 | + Charset charset = Charset.forName("utf-8"); | ||
| 31 | + ByteBuffer payload = charset.encode(clientId+","+code+","+messageStr); | ||
| 32 | + message.setPayload(payload.array()); | ||
| 33 | + mqttclient.publish(topic,message); | ||
| 34 | + } | ||
| 35 | +} |
| 1 | +package com.zhonglai.luhui.central.control.util; | ||
| 2 | + | ||
| 3 | +import java.util.Arrays; | ||
| 4 | + | ||
| 5 | +public class ByteUtil { | ||
| 6 | + /** | ||
| 7 | + * byte数组中取int数值,本方法适用于(低位在前,高位在后)的顺序,和和intToBytes()配套使用 | ||
| 8 | + * | ||
| 9 | + * @param src | ||
| 10 | + * byte数组 | ||
| 11 | + * @param offset | ||
| 12 | + * 从数组的第offset位开始 | ||
| 13 | + * @return int数值 | ||
| 14 | + */ | ||
| 15 | + public static long bytesToLongASC(byte[] src, int offset,int lenth) { | ||
| 16 | + int value = 0; | ||
| 17 | + for(int i=0;i<lenth;i++) | ||
| 18 | + { | ||
| 19 | + value = value | ((src[offset+i] & 0xFF)<<(8*i)); | ||
| 20 | + } | ||
| 21 | + return value; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 把16进制字符串转换成字节数组 | ||
| 26 | + * | ||
| 27 | + * @param hex | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + public static byte[] hexStringToByte(String hex) { | ||
| 31 | + int len = (hex.length() / 2); | ||
| 32 | + byte[] result = new byte[len]; | ||
| 33 | + char[] achar = hex.toCharArray(); | ||
| 34 | + for (int i = 0; i < len; i++) { | ||
| 35 | + int pos = i * 2; | ||
| 36 | + result[i] = (byte) (toByte(achar[pos]) << 4 | toByte(achar[pos + 1])); | ||
| 37 | + } | ||
| 38 | + return result; | ||
| 39 | + } | ||
| 40 | + private static byte toByte(char c) { | ||
| 41 | + byte b = (byte) "0123456789ABCDEF".indexOf(c); | ||
| 42 | + return b; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 把16进制字符串转换成字节数组 | ||
| 47 | + * | ||
| 48 | + * @param hex | ||
| 49 | + * @return | ||
| 50 | + */ | ||
| 51 | + public static String hexStringToSpace(String hex) { | ||
| 52 | + if (null == hex) { | ||
| 53 | + return null; | ||
| 54 | + } else { | ||
| 55 | + StringBuilder sb = new StringBuilder(hex.length() << 1); | ||
| 56 | + | ||
| 57 | + for(int i = 0; i < hex.length(); i+=2) { | ||
| 58 | + sb.append(hex.substring(i,i+2)).append(" "); | ||
| 59 | + } | ||
| 60 | + return sb.toString(); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 把原数组加点目标数组后面 | ||
| 66 | + * @param dest 目标数组 | ||
| 67 | + * @param src 原数组 | ||
| 68 | + * @return | ||
| 69 | + */ | ||
| 70 | + public static byte[] addBytes(byte[] dest,byte[] src ) | ||
| 71 | + { | ||
| 72 | + int dl = dest.length; | ||
| 73 | + int sl = src.length; | ||
| 74 | + dest = Arrays.copyOf(dest, dl+sl);//数组扩容 | ||
| 75 | + System.arraycopy(src,0,dest,dl,src.length); | ||
| 76 | + return dest; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 将int数值转换为占四个字节的byte数组,本方法适用于(高位在前,低位在后)的顺序。 和bytesToInt2()配套使用 | ||
| 81 | + */ | ||
| 82 | + public static byte[] intToBytesDESC(long value,int lenth) | ||
| 83 | + { | ||
| 84 | + byte[] src = new byte[lenth]; | ||
| 85 | + for(int i=0;i<lenth;i++) | ||
| 86 | + { | ||
| 87 | + src[i] = (byte) ((value>>(8*(lenth-i-1))) & 0xFF); | ||
| 88 | + } | ||
| 89 | + return src; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 将int数值转换为占四个字节的byte数组,本方法适用于(低位在前,高位在后)的顺序。 和bytesToInt()配套使用 | ||
| 94 | + * @param value | ||
| 95 | + * 要转换的int值 | ||
| 96 | + * @return byte数组 | ||
| 97 | + */ | ||
| 98 | + public static byte[] intToBytesASC( long value,int lenth) | ||
| 99 | + { | ||
| 100 | + byte[] src = new byte[lenth]; | ||
| 101 | + for(int i=lenth;i>0;i--) | ||
| 102 | + { | ||
| 103 | + src[i-1] = (byte) ((value>>(8*(i-1))) & 0xFF); | ||
| 104 | + } | ||
| 105 | + return src; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public static void main(String[] args) { | ||
| 109 | + System.out.println(ByteUtil.toHexString( ByteUtil.intToBytesASC(2011239256,4))); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * ip转化位4byte | ||
| 114 | + * @param ip | ||
| 115 | + * @return | ||
| 116 | + */ | ||
| 117 | + public static byte[] ipTo4Byte(String ip) | ||
| 118 | + { | ||
| 119 | + String[] ips = ip.split("."); | ||
| 120 | + return new byte[]{(byte) Integer.parseInt(ips[0]),(byte) Integer.parseInt(ips[1]),(byte) Integer.parseInt(ips[2]),(byte) Integer.parseInt(ips[3])}; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * byte数组中取int数值,本方法适用于(低位在后,高位在前)的顺序。和intToBytes2()配套使用 | ||
| 125 | + */ | ||
| 126 | + public static long bytesToLongDESC(byte[] src, int offset,int lenth) { | ||
| 127 | + long value = 0; | ||
| 128 | + for(int i=lenth;i>0;i--) | ||
| 129 | + { | ||
| 130 | + value = value | ((src[offset+(lenth-i)] & 0xFF)<<(8*(i-1))); | ||
| 131 | + } | ||
| 132 | + return value; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + private static final char[] hex = "0123456789abcdef".toCharArray(); | ||
| 136 | + public static String toHexString(byte[] bytes) { | ||
| 137 | + if (null == bytes) { | ||
| 138 | + return null; | ||
| 139 | + } else { | ||
| 140 | + StringBuilder sb = new StringBuilder(bytes.length << 1); | ||
| 141 | + | ||
| 142 | + for(int i = 0; i < bytes.length; ++i) { | ||
| 143 | + sb.append(hex[(bytes[i] & 240) >> 4]).append(hex[bytes[i] & 15]); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + return sb.toString(); | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + /** | ||
| 151 | + * 计算CRC16/Modbus校验码 低位在前,高位在后 | ||
| 152 | + * | ||
| 153 | + * @param str 十六进制字符串 | ||
| 154 | + * @return | ||
| 155 | + */ | ||
| 156 | + public static String getCRC16(String str) { | ||
| 157 | + byte[] bytes = hexStringToByte(str); | ||
| 158 | + return getCRC16(bytes); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + /** | ||
| 162 | + * 计算CRC16/Modbus校验码 低位在前,高位在后 | ||
| 163 | + * | ||
| 164 | + * @return | ||
| 165 | + */ | ||
| 166 | + public static String getCRC16( byte[] bytes) { | ||
| 167 | + int CRC = 0x0000ffff; | ||
| 168 | + int POLYNOMIAL = 0x0000a001; | ||
| 169 | + | ||
| 170 | + int i, j; | ||
| 171 | + for (i = 0; i < bytes.length; i++) { | ||
| 172 | + CRC ^= ((int) bytes[i] & 0x000000ff); | ||
| 173 | + for (j = 0; j < 8; j++) { | ||
| 174 | + if ((CRC & 0x00000001) != 0) { | ||
| 175 | + CRC >>= 1; | ||
| 176 | + CRC ^= POLYNOMIAL; | ||
| 177 | + } else { | ||
| 178 | + CRC >>= 1; | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + String crc = Integer.toHexString(CRC); | ||
| 183 | + if (crc.length() == 2) { | ||
| 184 | + crc = "00" + crc; | ||
| 185 | + } else if (crc.length() == 3) { | ||
| 186 | + crc = "0" + crc; | ||
| 187 | + } | ||
| 188 | + crc = crc.substring(2, 4) + crc.substring(0, 2); | ||
| 189 | + return crc.toUpperCase(); | ||
| 190 | + } | ||
| 191 | +} |
lh-domain/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | + <parent> | ||
| 6 | + <artifactId>Luhui</artifactId> | ||
| 7 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 8 | + <version>1.0-SNAPSHOT</version> | ||
| 9 | + </parent> | ||
| 10 | + <modelVersion>4.0.0</modelVersion> | ||
| 11 | + | ||
| 12 | + <artifactId>lh-domain</artifactId> | ||
| 13 | + | ||
| 14 | + <dependencies> | ||
| 15 | + <dependency> | ||
| 16 | + <groupId>org.apache.commons</groupId> | ||
| 17 | + <artifactId>commons-lang3</artifactId> | ||
| 18 | + </dependency> | ||
| 19 | + <dependency> | ||
| 20 | + <groupId>org.springframework.data</groupId> | ||
| 21 | + <artifactId>spring-data-commons</artifactId> | ||
| 22 | + </dependency> | ||
| 23 | + <dependency> | ||
| 24 | + <groupId>jakarta.validation</groupId> | ||
| 25 | + <artifactId>jakarta.validation-api</artifactId> | ||
| 26 | + </dependency> | ||
| 27 | + <!-- Swagger3依赖 --> | ||
| 28 | + <dependency> | ||
| 29 | + <groupId>io.springfox</groupId> | ||
| 30 | + <artifactId>springfox-boot-starter</artifactId> | ||
| 31 | + <version>${swagger.version}</version> | ||
| 32 | + <exclusions> | ||
| 33 | + <exclusion> | ||
| 34 | + <groupId>io.swagger</groupId> | ||
| 35 | + <artifactId>swagger-models</artifactId> | ||
| 36 | + </exclusion> | ||
| 37 | + </exclusions> | ||
| 38 | + </dependency> | ||
| 39 | + </dependencies> | ||
| 40 | +</project> |
| 1 | -package com.zhonglai.luhui.mqtt.comm.dto.iot; | 1 | +package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | -import io.swagger.annotations.ApiModel; | ||
| 4 | -import io.swagger.annotations.ApiModelProperty; | ||
| 5 | import org.apache.commons.lang3.builder.ToStringBuilder; | 3 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 6 | import org.apache.commons.lang3.builder.ToStringStyle; | 4 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | 7 | ||
| 8 | -import java.util.List; | ||
| 9 | -import java.util.Map; | 8 | +import java.io.Serializable; |
| 10 | 9 | ||
| 11 | /** | 10 | /** |
| 12 | * 主机/网关对象 iot_device | 11 | * 主机/网关对象 iot_device |
| @@ -15,7 +14,7 @@ import java.util.Map; | @@ -15,7 +14,7 @@ import java.util.Map; | ||
| 15 | * @date 2022-08-26 | 14 | * @date 2022-08-26 |
| 16 | */ | 15 | */ |
| 17 | @ApiModel("主机/网关") | 16 | @ApiModel("主机/网关") |
| 18 | -public class IotDevice | 17 | +public class IotDevice implements Serializable |
| 19 | { | 18 | { |
| 20 | private static final long serialVersionUID = 1L; | 19 | private static final long serialVersionUID = 1L; |
| 21 | 20 | ||
| @@ -45,7 +44,7 @@ public class IotDevice | @@ -45,7 +44,7 @@ public class IotDevice | ||
| 45 | 44 | ||
| 46 | /** 固件版本 */ | 45 | /** 固件版本 */ |
| 47 | @ApiModelProperty("固件版本") | 46 | @ApiModelProperty("固件版本") |
| 48 | - private Float firmware_version; | 47 | + private String firmware_version; |
| 49 | 48 | ||
| 50 | /** 图片地址 */ | 49 | /** 图片地址 */ |
| 51 | @ApiModelProperty("图片地址") | 50 | @ApiModelProperty("图片地址") |
| @@ -84,7 +83,7 @@ public class IotDevice | @@ -84,7 +83,7 @@ public class IotDevice | ||
| 84 | private Integer rssi; | 83 | private Integer rssi; |
| 85 | 84 | ||
| 86 | /** 设备状态(1-未激活,2-禁用,3-在线,4-离线) */ | 85 | /** 设备状态(1-未激活,2-禁用,3-在线,4-离线) */ |
| 87 | - @ApiModelProperty("设备状态(1-未激活,2-禁用,3-在线,4-离线)") | 86 | + @ApiModelProperty("设备状态(1-未激活,2-禁用,3-在线,4-离线,5-锁定)") |
| 88 | private Integer status; | 87 | private Integer status; |
| 89 | 88 | ||
| 90 | /** 设备摘要,格式[{"name":"device"},{"chip":"esp8266"}] */ | 89 | /** 设备摘要,格式[{"name":"device"},{"chip":"esp8266"}] */ |
| @@ -103,23 +102,63 @@ public class IotDevice | @@ -103,23 +102,63 @@ public class IotDevice | ||
| 103 | @ApiModelProperty("更新时间") | 102 | @ApiModelProperty("更新时间") |
| 104 | private Integer update_time; | 103 | private Integer update_time; |
| 105 | 104 | ||
| 106 | - /** 用户id */ | ||
| 107 | - @ApiModelProperty("用户id") | ||
| 108 | - private Integer user_id; | 105 | + @ApiModelProperty("产品id") |
| 106 | + private Integer product_id; | ||
| 107 | + | ||
| 108 | + @ApiModelProperty("mqtt用户名/设备类型") | ||
| 109 | + private String mqtt_username; | ||
| 109 | 110 | ||
| 110 | @ApiModelProperty("负载类型(String,Json,Bite16,Bite32)") | 111 | @ApiModelProperty("负载类型(String,Json,Bite16,Bite32)") |
| 111 | private String payload_type; | 112 | private String payload_type; |
| 112 | - @ApiModelProperty("payload 协议模型") | ||
| 113 | - private String business_model; //payload 协议模型 | ||
| 114 | 113 | ||
| 115 | - public String getBusiness_model() { | ||
| 116 | - return business_model; | 114 | + @ApiModelProperty("物模型配置") |
| 115 | + private String things_model_config; //payload 协议模型 | ||
| 116 | + | ||
| 117 | + @ApiModelProperty("监听服务器的ip") | ||
| 118 | + private String listen_service_ip; | ||
| 119 | + | ||
| 120 | + @ApiModelProperty("描述") | ||
| 121 | + private String remark; | ||
| 122 | + | ||
| 123 | + @ApiModelProperty("设备生命周期") | ||
| 124 | + private Long device_life; | ||
| 125 | + | ||
| 126 | + @ApiModelProperty("数据更新时间") | ||
| 127 | + private Integer data_update_time; | ||
| 128 | + | ||
| 129 | + public Integer getData_update_time() { | ||
| 130 | + return data_update_time; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public void setData_update_time(Integer data_update_time) { | ||
| 134 | + this.data_update_time = data_update_time; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public Long getDevice_life() { | ||
| 138 | + return device_life; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public void setDevice_life(Long device_life) { | ||
| 142 | + this.device_life = device_life; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public String getListen_service_ip() { | ||
| 146 | + return listen_service_ip; | ||
| 117 | } | 147 | } |
| 118 | 148 | ||
| 119 | - public void setBusiness_model(String business_model) { | ||
| 120 | - this.business_model = business_model; | 149 | + public void setListen_service_ip(String listen_service_ip) { |
| 150 | + this.listen_service_ip = listen_service_ip; | ||
| 121 | } | 151 | } |
| 122 | 152 | ||
| 153 | + public String getThings_model_config() { | ||
| 154 | + return things_model_config; | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + public void setThings_model_config(String things_model_config) { | ||
| 158 | + this.things_model_config = things_model_config; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + | ||
| 123 | public String getPayload_type() { | 162 | public String getPayload_type() { |
| 124 | return payload_type; | 163 | return payload_type; |
| 125 | } | 164 | } |
| @@ -182,12 +221,12 @@ public class IotDevice | @@ -182,12 +221,12 @@ public class IotDevice | ||
| 182 | { | 221 | { |
| 183 | return del_flag; | 222 | return del_flag; |
| 184 | } | 223 | } |
| 185 | - public void setFirmware_version(Float firmware_version) | 224 | + public void setFirmware_version(String firmware_version) |
| 186 | { | 225 | { |
| 187 | this.firmware_version = firmware_version; | 226 | this.firmware_version = firmware_version; |
| 188 | } | 227 | } |
| 189 | 228 | ||
| 190 | - public Float getFirmware_version() | 229 | + public String getFirmware_version() |
| 191 | { | 230 | { |
| 192 | return firmware_version; | 231 | return firmware_version; |
| 193 | } | 232 | } |
| @@ -317,40 +356,29 @@ public class IotDevice | @@ -317,40 +356,29 @@ public class IotDevice | ||
| 317 | { | 356 | { |
| 318 | return update_time; | 357 | return update_time; |
| 319 | } | 358 | } |
| 320 | - public void setUser_id(Integer user_id) | ||
| 321 | - { | ||
| 322 | - this.user_id = user_id; | ||
| 323 | - } | ||
| 324 | - | ||
| 325 | - public Integer getUser_id() | ||
| 326 | - { | ||
| 327 | - return user_id; | ||
| 328 | - } | ||
| 329 | - | ||
| 330 | - public String toString() { | ||
| 331 | - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||
| 332 | - .append("active_time", getActive_time()) | ||
| 333 | - .append("client_id", getClient_id()) | ||
| 334 | - .append("completion_auth", getCompletion_auth()) | ||
| 335 | - .append("create_by", getCreate_by()) | ||
| 336 | - .append("create_time", getCreate_time()) | ||
| 337 | - .append("del_flag", getDel_flag()) | ||
| 338 | - .append("firmware_version", getFirmware_version()) | ||
| 339 | - .append("img_url", getImg_url()) | ||
| 340 | - .append("is_shadow", getIs_shadow()) | ||
| 341 | - .append("latitude", getLatitude()) | ||
| 342 | - .append("location_way", getLocation_way()) | ||
| 343 | - .append("longitude", getLongitude()) | ||
| 344 | - .append("name", getName()) | ||
| 345 | - .append("network_address", getNetwork_address()) | ||
| 346 | - .append("network_ip", getNetwork_ip()) | ||
| 347 | - .append("rssi", getRssi()) | ||
| 348 | - .append("status", getStatus()) | ||
| 349 | - .append("summary", getSummary()) | ||
| 350 | - .append("things_model_value", getThings_model_value()) | ||
| 351 | - .append("update_by", getUpdate_by()) | ||
| 352 | - .append("update_time", getUpdate_time()) | ||
| 353 | - .append("user_id", getUser_id()) | ||
| 354 | - .toString(); | 359 | + |
| 360 | + public Integer getProduct_id() { | ||
| 361 | + return product_id; | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + public void setProduct_id(Integer product_id) { | ||
| 365 | + this.product_id = product_id; | ||
| 355 | } | 366 | } |
| 367 | + | ||
| 368 | + public String getMqtt_username() { | ||
| 369 | + return mqtt_username; | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + public void setMqtt_username(String mqtt_username) { | ||
| 373 | + this.mqtt_username = mqtt_username; | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + public String getRemark() { | ||
| 377 | + return remark; | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | + public void setRemark(String remark) { | ||
| 381 | + this.remark = remark; | ||
| 382 | + } | ||
| 383 | + | ||
| 356 | } | 384 | } |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | +import com.ruoyi.system.domain.tool.BaseEntity; | ||
| 3 | import org.apache.commons.lang3.builder.ToStringBuilder; | 4 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 4 | import org.apache.commons.lang3.builder.ToStringStyle; | 5 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 5 | -import com.ruoyi.common.annotation.Excel; | ||
| 6 | -import com.ruoyi.common.core.domain.BaseEntity; | ||
| 7 | import io.swagger.annotations.ApiModel; | 6 | import io.swagger.annotations.ApiModel; |
| 8 | import io.swagger.annotations.ApiModelProperty; | 7 | import io.swagger.annotations.ApiModelProperty; |
| 9 | 8 | ||
| 9 | +import java.io.Serializable; | ||
| 10 | + | ||
| 10 | /** | 11 | /** |
| 11 | * topic权限控制对象 iot_permission | 12 | * topic权限控制对象 iot_permission |
| 12 | * | 13 | * |
| @@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; | @@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; | ||
| 14 | * @date 2022-08-26 | 15 | * @date 2022-08-26 |
| 15 | */ | 16 | */ |
| 16 | @ApiModel("topic权限控制") | 17 | @ApiModel("topic权限控制") |
| 17 | -public class IotPermission extends BaseEntity | 18 | +public class IotPermission implements Serializable |
| 18 | { | 19 | { |
| 19 | private static final long serialVersionUID = 1L; | 20 | private static final long serialVersionUID = 1L; |
| 20 | 21 |
| 1 | -package com.zhonglai.luhui.mqtt.comm.dto.iot; | 1 | +package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | -import io.swagger.annotations.ApiModel; | ||
| 4 | -import io.swagger.annotations.ApiModelProperty; | 3 | +import com.ruoyi.system.domain.tool.BaseEntity; |
| 5 | import org.apache.commons.lang3.builder.ToStringBuilder; | 4 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 6 | import org.apache.commons.lang3.builder.ToStringStyle; | 5 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 6 | +import io.swagger.annotations.ApiModel; | ||
| 7 | +import io.swagger.annotations.ApiModelProperty; | ||
| 8 | + | ||
| 9 | +import java.io.Serializable; | ||
| 7 | 10 | ||
| 8 | /** | 11 | /** |
| 9 | - * 产品对象 iot_user | 12 | + * 产品对象 iot_product |
| 10 | * | 13 | * |
| 11 | * @author 钟来 | 14 | * @author 钟来 |
| 12 | * @date 2022-08-26 | 15 | * @date 2022-08-26 |
| 13 | */ | 16 | */ |
| 14 | @ApiModel("产品") | 17 | @ApiModel("产品") |
| 15 | -public class IotUser | 18 | +public class IotProduct implements Serializable |
| 16 | { | 19 | { |
| 17 | private static final long serialVersionUID = 1L; | 20 | private static final long serialVersionUID = 1L; |
| 18 | 21 | ||
| @@ -34,7 +37,7 @@ public class IotUser | @@ -34,7 +37,7 @@ public class IotUser | ||
| 34 | 37 | ||
| 35 | /** 密码 */ | 38 | /** 密码 */ |
| 36 | @ApiModelProperty("密码") | 39 | @ApiModelProperty("密码") |
| 37 | - private String password; | 40 | + private String mqtt_password; |
| 38 | 41 | ||
| 39 | /** 角色id */ | 42 | /** 角色id */ |
| 40 | @ApiModelProperty("角色id") | 43 | @ApiModelProperty("角色id") |
| @@ -42,7 +45,7 @@ public class IotUser | @@ -42,7 +45,7 @@ public class IotUser | ||
| 42 | 45 | ||
| 43 | /** 盐 */ | 46 | /** 盐 */ |
| 44 | @ApiModelProperty("盐") | 47 | @ApiModelProperty("盐") |
| 45 | - private String salt; | 48 | + private String mqtt_salt; |
| 46 | 49 | ||
| 47 | /** 是否使用(0否,1是) */ | 50 | /** 是否使用(0否,1是) */ |
| 48 | @ApiModelProperty("是否使用(0否,1是)") | 51 | @ApiModelProperty("是否使用(0否,1是)") |
| @@ -50,7 +53,11 @@ public class IotUser | @@ -50,7 +53,11 @@ public class IotUser | ||
| 50 | 53 | ||
| 51 | /** 用户名 */ | 54 | /** 用户名 */ |
| 52 | @ApiModelProperty("用户名") | 55 | @ApiModelProperty("用户名") |
| 53 | - private String username; | 56 | + private String mqtt_username; |
| 57 | + | ||
| 58 | + @ApiModelProperty("产品名称") | ||
| 59 | + private String product_name; | ||
| 60 | + | ||
| 54 | 61 | ||
| 55 | public void setCreate_time(Integer create_time) | 62 | public void setCreate_time(Integer create_time) |
| 56 | { | 63 | { |
| @@ -88,16 +95,7 @@ public class IotUser | @@ -88,16 +95,7 @@ public class IotUser | ||
| 88 | { | 95 | { |
| 89 | return open_encryption; | 96 | return open_encryption; |
| 90 | } | 97 | } |
| 91 | - public void setPassword(String password) | ||
| 92 | - { | ||
| 93 | - this.password = password; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - public String getPassword() | ||
| 97 | - { | ||
| 98 | - return password; | ||
| 99 | - } | ||
| 100 | - public void setRole_id(Integer role_id) | 98 | + public void setRole_id(Integer role_id) |
| 101 | { | 99 | { |
| 102 | this.role_id = role_id; | 100 | this.role_id = role_id; |
| 103 | } | 101 | } |
| @@ -106,16 +104,8 @@ public class IotUser | @@ -106,16 +104,8 @@ public class IotUser | ||
| 106 | { | 104 | { |
| 107 | return role_id; | 105 | return role_id; |
| 108 | } | 106 | } |
| 109 | - public void setSalt(String salt) | ||
| 110 | - { | ||
| 111 | - this.salt = salt; | ||
| 112 | - } | ||
| 113 | 107 | ||
| 114 | - public String getSalt() | ||
| 115 | - { | ||
| 116 | - return salt; | ||
| 117 | - } | ||
| 118 | - public void setUsed(Integer used) | 108 | + public void setUsed(Integer used) |
| 119 | { | 109 | { |
| 120 | this.used = used; | 110 | this.used = used; |
| 121 | } | 111 | } |
| @@ -124,27 +114,52 @@ public class IotUser | @@ -124,27 +114,52 @@ public class IotUser | ||
| 124 | { | 114 | { |
| 125 | return used; | 115 | return used; |
| 126 | } | 116 | } |
| 127 | - public void setUsername(String username) | ||
| 128 | - { | ||
| 129 | - this.username = username; | 117 | + |
| 118 | + public String getMqtt_password() { | ||
| 119 | + return mqtt_password; | ||
| 130 | } | 120 | } |
| 131 | 121 | ||
| 132 | - public String getUsername() | ||
| 133 | - { | ||
| 134 | - return username; | 122 | + public void setMqtt_password(String mqtt_password) { |
| 123 | + this.mqtt_password = mqtt_password; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + public String getMqtt_salt() { | ||
| 127 | + return mqtt_salt; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + public void setMqtt_salt(String mqtt_salt) { | ||
| 131 | + this.mqtt_salt = mqtt_salt; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public String getMqtt_username() { | ||
| 135 | + return mqtt_username; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + public void setMqtt_username(String mqtt_username) { | ||
| 139 | + this.mqtt_username = mqtt_username; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + public String getProduct_name() { | ||
| 143 | + return product_name; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public void setProduct_name(String product_name) { | ||
| 147 | + this.product_name = product_name; | ||
| 135 | } | 148 | } |
| 136 | 149 | ||
| 150 | + @Override | ||
| 137 | public String toString() { | 151 | public String toString() { |
| 138 | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | 152 | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| 139 | .append("create_time", getCreate_time()) | 153 | .append("create_time", getCreate_time()) |
| 140 | .append("encryption_type", getEncryption_type()) | 154 | .append("encryption_type", getEncryption_type()) |
| 141 | .append("id", getId()) | 155 | .append("id", getId()) |
| 142 | .append("open_encryption", getOpen_encryption()) | 156 | .append("open_encryption", getOpen_encryption()) |
| 143 | - .append("password", getPassword()) | 157 | + .append("mqtt_password", getMqtt_password()) |
| 144 | .append("role_id", getRole_id()) | 158 | .append("role_id", getRole_id()) |
| 145 | - .append("salt", getSalt()) | 159 | + .append("mqtt_salt", getMqtt_salt()) |
| 146 | .append("used", getUsed()) | 160 | .append("used", getUsed()) |
| 147 | - .append("username", getUsername()) | 161 | + .append("mqtt_username", getMqtt_username()) |
| 162 | + .append("product_name", getProduct_name()) | ||
| 148 | .toString(); | 163 | .toString(); |
| 149 | } | 164 | } |
| 150 | } | 165 | } |
| 1 | -package com.zhonglai.luhui.mqtt.comm.dto.iot; | 1 | +package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | +import com.ruoyi.system.domain.tool.BaseEntity; | ||
| 3 | import io.swagger.annotations.ApiModel; | 4 | import io.swagger.annotations.ApiModel; |
| 4 | import io.swagger.annotations.ApiModelProperty; | 5 | import io.swagger.annotations.ApiModelProperty; |
| 5 | import org.apache.commons.lang3.builder.ToStringBuilder; | 6 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 6 | import org.apache.commons.lang3.builder.ToStringStyle; | 7 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| 9 | - * 公司对象 iot_role | 10 | + * 产品指标翻译对象 iot_product_translate |
| 10 | * | 11 | * |
| 11 | * @author 钟来 | 12 | * @author 钟来 |
| 12 | - * @date 2022-08-26 | 13 | + * @date 2022-11-04 |
| 13 | */ | 14 | */ |
| 14 | -@ApiModel("公司") | ||
| 15 | -public class IotRole | 15 | +@ApiModel("产品指标翻译") |
| 16 | +public class IotProductTranslate extends BaseEntity | ||
| 16 | { | 17 | { |
| 17 | private static final long serialVersionUID = 1L; | 18 | private static final long serialVersionUID = 1L; |
| 18 | 19 | ||
| @@ -20,21 +21,21 @@ public class IotRole | @@ -20,21 +21,21 @@ public class IotRole | ||
| 20 | @ApiModelProperty("创建时间") | 21 | @ApiModelProperty("创建时间") |
| 21 | private Integer create_time; | 22 | private Integer create_time; |
| 22 | 23 | ||
| 23 | - /** 描述 */ | ||
| 24 | - @ApiModelProperty("描述") | ||
| 25 | - private String describe; | ||
| 26 | - | ||
| 27 | /** 主键 */ | 24 | /** 主键 */ |
| 28 | @ApiModelProperty("主键") | 25 | @ApiModelProperty("主键") |
| 29 | private Integer id; | 26 | private Integer id; |
| 30 | 27 | ||
| 31 | - /** 名称 */ | ||
| 32 | - @ApiModelProperty("名称") | ||
| 33 | - private String name; | 28 | + /** 模型标识 */ |
| 29 | + @ApiModelProperty("模型标识") | ||
| 30 | + private String model_identifier; | ||
| 31 | + | ||
| 32 | + /** 产品id */ | ||
| 33 | + @ApiModelProperty("产品id") | ||
| 34 | + private Integer product_id; | ||
| 34 | 35 | ||
| 35 | - /** 是否使用(0否,1是) */ | ||
| 36 | - @ApiModelProperty("是否使用(0否,1是)") | ||
| 37 | - private Integer used; | 36 | + /** 翻译的模型标识(支持两层josn键值,用英文点分割) */ |
| 37 | + @ApiModelProperty("翻译的模型标识(支持两层josn键值,用英文点分割如:11:start)") | ||
| 38 | + private String translate_identifier; | ||
| 38 | 39 | ||
| 39 | public void setCreate_time(Integer create_time) | 40 | public void setCreate_time(Integer create_time) |
| 40 | { | 41 | { |
| @@ -45,50 +46,51 @@ public class IotRole | @@ -45,50 +46,51 @@ public class IotRole | ||
| 45 | { | 46 | { |
| 46 | return create_time; | 47 | return create_time; |
| 47 | } | 48 | } |
| 48 | - public void setDescribe(String describe) | 49 | + public void setId(Integer id) |
| 49 | { | 50 | { |
| 50 | - this.describe = describe; | 51 | + this.id = id; |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | - public String getDescribe() | 54 | + public Integer getId() |
| 54 | { | 55 | { |
| 55 | - return describe; | 56 | + return id; |
| 56 | } | 57 | } |
| 57 | - public void setId(Integer id) | 58 | + public void setModel_identifier(String model_identifier) |
| 58 | { | 59 | { |
| 59 | - this.id = id; | 60 | + this.model_identifier = model_identifier; |
| 60 | } | 61 | } |
| 61 | 62 | ||
| 62 | - public Integer getId() | 63 | + public String getModel_identifier() |
| 63 | { | 64 | { |
| 64 | - return id; | 65 | + return model_identifier; |
| 65 | } | 66 | } |
| 66 | - public void setName(String name) | 67 | + public void setProduct_id(Integer product_id) |
| 67 | { | 68 | { |
| 68 | - this.name = name; | 69 | + this.product_id = product_id; |
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | - public String getName() | 72 | + public Integer getProduct_id() |
| 72 | { | 73 | { |
| 73 | - return name; | 74 | + return product_id; |
| 74 | } | 75 | } |
| 75 | - public void setUsed(Integer used) | 76 | + public void setTranslate_identifier(String translate_identifier) |
| 76 | { | 77 | { |
| 77 | - this.used = used; | 78 | + this.translate_identifier = translate_identifier; |
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | - public Integer getUsed() | 81 | + public String getTranslate_identifier() |
| 81 | { | 82 | { |
| 82 | - return used; | 83 | + return translate_identifier; |
| 83 | } | 84 | } |
| 84 | 85 | ||
| 86 | + @Override | ||
| 85 | public String toString() { | 87 | public String toString() { |
| 86 | - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | 88 | + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
| 87 | .append("create_time", getCreate_time()) | 89 | .append("create_time", getCreate_time()) |
| 88 | - .append("describe", getDescribe()) | ||
| 89 | .append("id", getId()) | 90 | .append("id", getId()) |
| 90 | - .append("name", getName()) | ||
| 91 | - .append("used", getUsed()) | 91 | + .append("model_identifier", getModel_identifier()) |
| 92 | + .append("product_id", getProduct_id()) | ||
| 93 | + .append("translate_identifier", getTranslate_identifier()) | ||
| 92 | .toString(); | 94 | .toString(); |
| 93 | } | 95 | } |
| 94 | } | 96 | } |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | +import com.ruoyi.system.domain.tool.BaseEntity; | ||
| 3 | import org.apache.commons.lang3.builder.ToStringBuilder; | 4 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 4 | import org.apache.commons.lang3.builder.ToStringStyle; | 5 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 5 | -import com.ruoyi.common.annotation.Excel; | ||
| 6 | -import com.ruoyi.common.core.domain.BaseEntity; | ||
| 7 | import io.swagger.annotations.ApiModel; | 6 | import io.swagger.annotations.ApiModel; |
| 8 | import io.swagger.annotations.ApiModelProperty; | 7 | import io.swagger.annotations.ApiModelProperty; |
| 9 | 8 | ||
| 9 | +import java.io.Serializable; | ||
| 10 | + | ||
| 10 | /** | 11 | /** |
| 11 | * 公司对象 iot_role | 12 | * 公司对象 iot_role |
| 12 | * | 13 | * |
| @@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; | @@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; | ||
| 14 | * @date 2022-08-26 | 15 | * @date 2022-08-26 |
| 15 | */ | 16 | */ |
| 16 | @ApiModel("公司") | 17 | @ApiModel("公司") |
| 17 | -public class IotRole extends BaseEntity | 18 | +public class IotRole implements Serializable |
| 18 | { | 19 | { |
| 19 | private static final long serialVersionUID = 1L; | 20 | private static final long serialVersionUID = 1L; |
| 20 | 21 |
| @@ -2,11 +2,11 @@ package com.ruoyi.system.domain; | @@ -2,11 +2,11 @@ package com.ruoyi.system.domain; | ||
| 2 | 2 | ||
| 3 | import org.apache.commons.lang3.builder.ToStringBuilder; | 3 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 4 | import org.apache.commons.lang3.builder.ToStringStyle; | 4 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 5 | -import com.ruoyi.common.annotation.Excel; | ||
| 6 | -import com.ruoyi.common.core.domain.BaseEntity; | ||
| 7 | import io.swagger.annotations.ApiModel; | 5 | import io.swagger.annotations.ApiModel; |
| 8 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
| 9 | 7 | ||
| 8 | +import java.io.Serializable; | ||
| 9 | + | ||
| 10 | /** | 10 | /** |
| 11 | * 终端对象 iot_terminal | 11 | * 终端对象 iot_terminal |
| 12 | * | 12 | * |
| @@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModelProperty; | @@ -14,7 +14,7 @@ import io.swagger.annotations.ApiModelProperty; | ||
| 14 | * @date 2022-08-26 | 14 | * @date 2022-08-26 |
| 15 | */ | 15 | */ |
| 16 | @ApiModel("终端") | 16 | @ApiModel("终端") |
| 17 | -public class IotTerminal extends BaseEntity | 17 | +public class IotTerminal implements Serializable |
| 18 | { | 18 | { |
| 19 | private static final long serialVersionUID = 1L; | 19 | private static final long serialVersionUID = 1L; |
| 20 | 20 | ||
| @@ -37,7 +37,48 @@ public class IotTerminal extends BaseEntity | @@ -37,7 +37,48 @@ public class IotTerminal extends BaseEntity | ||
| 37 | /** 更新时间 */ | 37 | /** 更新时间 */ |
| 38 | @ApiModelProperty("更新时间") | 38 | @ApiModelProperty("更新时间") |
| 39 | private Integer update_time; | 39 | private Integer update_time; |
| 40 | + @ApiModelProperty("物模型配置") | ||
| 41 | + private String things_model_config; //payload 协议模型 | ||
| 42 | + | ||
| 43 | + @ApiModelProperty("产品id") | ||
| 44 | + private Integer product_id; | ||
| 45 | + | ||
| 46 | + @ApiModelProperty("产品名称") | ||
| 47 | + private String mqtt_username; | ||
| 48 | + | ||
| 49 | + @ApiModelProperty("数据更新时间") | ||
| 50 | + private Integer data_update_time; | ||
| 51 | + | ||
| 52 | + public Integer getData_update_time() { | ||
| 53 | + return data_update_time; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public void setData_update_time(Integer data_update_time) { | ||
| 57 | + this.data_update_time = data_update_time; | ||
| 58 | + } | ||
| 59 | + public Integer getProduct_id() { | ||
| 60 | + return product_id; | ||
| 61 | + } | ||
| 40 | 62 | ||
| 63 | + public void setProduct_id(Integer product_id) { | ||
| 64 | + this.product_id = product_id; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public String getMqtt_username() { | ||
| 68 | + return mqtt_username; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public void setMqtt_username(String mqtt_username) { | ||
| 72 | + this.mqtt_username = mqtt_username; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public String getThings_model_config() { | ||
| 76 | + return things_model_config; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void setThings_model_config(String things_model_config) { | ||
| 80 | + this.things_model_config = things_model_config; | ||
| 81 | + } | ||
| 41 | public void setDevice_id(String device_id) | 82 | public void setDevice_id(String device_id) |
| 42 | { | 83 | { |
| 43 | this.device_id = device_id; | 84 | this.device_id = device_id; |
| @@ -92,6 +133,8 @@ public class IotTerminal extends BaseEntity | @@ -92,6 +133,8 @@ public class IotTerminal extends BaseEntity | ||
| 92 | .append("name", getName()) | 133 | .append("name", getName()) |
| 93 | .append("things_model_value", getThings_model_value()) | 134 | .append("things_model_value", getThings_model_value()) |
| 94 | .append("update_time", getUpdate_time()) | 135 | .append("update_time", getUpdate_time()) |
| 136 | + .append("product_id", getProduct_id()) | ||
| 137 | + .append("mqtt_username", getMqtt_username()) | ||
| 95 | .toString(); | 138 | .toString(); |
| 96 | } | 139 | } |
| 97 | } | 140 | } |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | +import com.ruoyi.system.domain.tool.BaseEntity; | ||
| 3 | import org.apache.commons.lang3.builder.ToStringBuilder; | 4 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 4 | import org.apache.commons.lang3.builder.ToStringStyle; | 5 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 5 | -import com.ruoyi.common.annotation.Excel; | ||
| 6 | -import com.ruoyi.common.core.domain.BaseEntity; | ||
| 7 | import io.swagger.annotations.ApiModel; | 6 | import io.swagger.annotations.ApiModel; |
| 8 | import io.swagger.annotations.ApiModelProperty; | 7 | import io.swagger.annotations.ApiModelProperty; |
| 9 | 8 | ||
| 9 | +import java.io.Serializable; | ||
| 10 | + | ||
| 10 | /** | 11 | /** |
| 11 | * 物模型模板对象 iot_things_model | 12 | * 物模型模板对象 iot_things_model |
| 12 | * | 13 | * |
| @@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; | @@ -14,7 +15,7 @@ import io.swagger.annotations.ApiModelProperty; | ||
| 14 | * @date 2022-08-26 | 15 | * @date 2022-08-26 |
| 15 | */ | 16 | */ |
| 16 | @ApiModel("物模型模板") | 17 | @ApiModel("物模型模板") |
| 17 | -public class IotThingsModel extends BaseEntity | 18 | +public class IotThingsModel implements Serializable |
| 18 | { | 19 | { |
| 19 | private static final long serialVersionUID = 1L; | 20 | private static final long serialVersionUID = 1L; |
| 20 | 21 | ||
| @@ -74,11 +75,70 @@ public class IotThingsModel extends BaseEntity | @@ -74,11 +75,70 @@ public class IotThingsModel extends BaseEntity | ||
| 74 | @ApiModelProperty("更新时间") | 75 | @ApiModelProperty("更新时间") |
| 75 | private java.util.Date update_time; | 76 | private java.util.Date update_time; |
| 76 | 77 | ||
| 77 | - /** 用户id */ | ||
| 78 | - @ApiModelProperty("用户id") | ||
| 79 | - private Integer user_id; | 78 | + @ApiModelProperty("mqtt用户名/设备类型") |
| 79 | + private String mqtt_username; | ||
| 80 | + | ||
| 81 | + @ApiModelProperty("产品id") | ||
| 82 | + private Integer product_id; | ||
| 83 | + | ||
| 84 | + @ApiModelProperty("是否配置属性(0否,1是)") | ||
| 85 | + private Integer is_config; | ||
| 86 | + | ||
| 87 | + @ApiModelProperty("展示类型") | ||
| 88 | + private String view_type; | ||
| 89 | + | ||
| 90 | + @ApiModelProperty("对应配置属性名称集合(英文逗号分割)") | ||
| 91 | + private String config_names; | ||
| 92 | + | ||
| 93 | + @ApiModelProperty("归属(0主键,1终端)") | ||
| 94 | + private String ascription; | ||
| 95 | + | ||
| 96 | + /** 数据定义 */ | ||
| 97 | + @ApiModelProperty("数据定义") | ||
| 98 | + private String remark; | ||
| 99 | + | ||
| 100 | + public String getAscription() { | ||
| 101 | + return ascription; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public void setAscription(String ascription) { | ||
| 105 | + this.ascription = ascription; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public String getRemark() { | ||
| 109 | + return remark; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public void setRemark(String remark) { | ||
| 113 | + this.remark = remark; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public String getView_type() { | ||
| 117 | + return view_type; | ||
| 118 | + } | ||
| 80 | 119 | ||
| 81 | - public void setCreate_by(String create_by) | 120 | + public void setView_type(String view_type) { |
| 121 | + this.view_type = view_type; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public String getConfig_names() { | ||
| 125 | + return config_names; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public void setConfig_names(String config_names) { | ||
| 129 | + this.config_names = config_names; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public Integer getIs_config() { | ||
| 133 | + return is_config; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public void setIs_config(Integer is_config) { | ||
| 137 | + this.is_config = is_config; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + | ||
| 141 | + public void setCreate_by(String create_by) | ||
| 82 | { | 142 | { |
| 83 | this.create_by = create_by; | 143 | this.create_by = create_by; |
| 84 | } | 144 | } |
| @@ -204,14 +264,21 @@ public class IotThingsModel extends BaseEntity | @@ -204,14 +264,21 @@ public class IotThingsModel extends BaseEntity | ||
| 204 | { | 264 | { |
| 205 | return update_time; | 265 | return update_time; |
| 206 | } | 266 | } |
| 207 | - public void setUser_id(Integer user_id) | ||
| 208 | - { | ||
| 209 | - this.user_id = user_id; | 267 | + |
| 268 | + public String getMqtt_username() { | ||
| 269 | + return mqtt_username; | ||
| 210 | } | 270 | } |
| 211 | 271 | ||
| 212 | - public Integer getUser_id() | ||
| 213 | - { | ||
| 214 | - return user_id; | 272 | + public void setMqtt_username(String mqtt_username) { |
| 273 | + this.mqtt_username = mqtt_username; | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + public Integer getProduct_id() { | ||
| 277 | + return product_id; | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + public void setProduct_id(Integer product_id) { | ||
| 281 | + this.product_id = product_id; | ||
| 215 | } | 282 | } |
| 216 | 283 | ||
| 217 | @Override | 284 | @Override |
| @@ -227,12 +294,12 @@ public class IotThingsModel extends BaseEntity | @@ -227,12 +294,12 @@ public class IotThingsModel extends BaseEntity | ||
| 227 | .append("is_top", getIs_top()) | 294 | .append("is_top", getIs_top()) |
| 228 | .append("model_id", getModel_id()) | 295 | .append("model_id", getModel_id()) |
| 229 | .append("model_name", getModel_name()) | 296 | .append("model_name", getModel_name()) |
| 230 | - .append("remark", getRemark()) | ||
| 231 | .append("specs", getSpecs()) | 297 | .append("specs", getSpecs()) |
| 232 | .append("type", getType()) | 298 | .append("type", getType()) |
| 233 | .append("update_by", getUpdate_by()) | 299 | .append("update_by", getUpdate_by()) |
| 234 | .append("update_time", getUpdate_time()) | 300 | .append("update_time", getUpdate_time()) |
| 235 | - .append("user_id", getUser_id()) | 301 | + .append("product_id", getProduct_id()) |
| 302 | + .append("mqtt_username", getMqtt_username()) | ||
| 236 | .toString(); | 303 | .toString(); |
| 237 | } | 304 | } |
| 238 | } | 305 | } |
| 1 | -package com.zhonglai.luhui.mqtt.comm.dto.iot; | 1 | +package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | +import com.ruoyi.system.domain.tool.BaseEntity; | ||
| 3 | import io.swagger.annotations.ApiModel; | 4 | import io.swagger.annotations.ApiModel; |
| 4 | import io.swagger.annotations.ApiModelProperty; | 5 | import io.swagger.annotations.ApiModelProperty; |
| 5 | import org.apache.commons.lang3.builder.ToStringBuilder; | 6 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 6 | import org.apache.commons.lang3.builder.ToStringStyle; | 7 | import org.apache.commons.lang3.builder.ToStringStyle; |
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| 9 | - * 物模型模板对象 iot_things_model | 10 | + * 物模型模板对象 iot_things_model_template |
| 10 | * | 11 | * |
| 11 | * @author 钟来 | 12 | * @author 钟来 |
| 12 | - * @date 2022-08-26 | 13 | + * @date 2022-10-24 |
| 13 | */ | 14 | */ |
| 14 | @ApiModel("物模型模板") | 15 | @ApiModel("物模型模板") |
| 15 | -public class IotThingsModel | 16 | +public class IotThingsModelTemplate extends BaseEntity |
| 16 | { | 17 | { |
| 17 | private static final long serialVersionUID = 1L; | 18 | private static final long serialVersionUID = 1L; |
| 18 | 19 | ||
| 20 | + /** 归属(0主键,1终端) */ | ||
| 21 | + @ApiModelProperty("归属(0主键,1终端)") | ||
| 22 | + private Integer ascription; | ||
| 23 | + | ||
| 24 | + /** 对应配置属性名称集合(英文逗号分割) */ | ||
| 25 | + @ApiModelProperty("对应配置属性名称集合(英文逗号分割)") | ||
| 26 | + private String config_names; | ||
| 27 | + | ||
| 19 | /** 创建者 */ | 28 | /** 创建者 */ |
| 20 | @ApiModelProperty("创建者") | 29 | @ApiModelProperty("创建者") |
| 21 | private String create_by; | 30 | private String create_by; |
| @@ -36,6 +45,10 @@ public class IotThingsModel | @@ -36,6 +45,10 @@ public class IotThingsModel | ||
| 36 | @ApiModelProperty("标识符,用户下唯一") | 45 | @ApiModelProperty("标识符,用户下唯一") |
| 37 | private String identifier; | 46 | private String identifier; |
| 38 | 47 | ||
| 48 | + /** 是否配置属性(0否,1是) */ | ||
| 49 | + @ApiModelProperty("是否配置属性(0否,1是)") | ||
| 50 | + private Integer is_config; | ||
| 51 | + | ||
| 39 | /** 是否实时监测(0-否,1-是) */ | 52 | /** 是否实时监测(0-否,1-是) */ |
| 40 | @ApiModelProperty("是否实时监测(0-否,1-是)") | 53 | @ApiModelProperty("是否实时监测(0-否,1-是)") |
| 41 | private Integer is_monitor; | 54 | private Integer is_monitor; |
| @@ -56,6 +69,14 @@ public class IotThingsModel | @@ -56,6 +69,14 @@ public class IotThingsModel | ||
| 56 | @ApiModelProperty("物模型名称") | 69 | @ApiModelProperty("物模型名称") |
| 57 | private String model_name; | 70 | private String model_name; |
| 58 | 71 | ||
| 72 | + /** mqtt用户名/设备类型 */ | ||
| 73 | + @ApiModelProperty("mqtt用户名/设备类型") | ||
| 74 | + private String mqtt_username; | ||
| 75 | + | ||
| 76 | + /** 产品id */ | ||
| 77 | + @ApiModelProperty("产品id") | ||
| 78 | + private Integer product_id; | ||
| 79 | + | ||
| 59 | /** 数据定义 */ | 80 | /** 数据定义 */ |
| 60 | @ApiModelProperty("数据定义") | 81 | @ApiModelProperty("数据定义") |
| 61 | private String specs; | 82 | private String specs; |
| @@ -72,23 +93,29 @@ public class IotThingsModel | @@ -72,23 +93,29 @@ public class IotThingsModel | ||
| 72 | @ApiModelProperty("更新时间") | 93 | @ApiModelProperty("更新时间") |
| 73 | private java.util.Date update_time; | 94 | private java.util.Date update_time; |
| 74 | 95 | ||
| 75 | - /** 用户id */ | ||
| 76 | - @ApiModelProperty("用户id") | ||
| 77 | - private Integer user_id; | ||
| 78 | - | ||
| 79 | - /** 用户id */ | ||
| 80 | - @ApiModelProperty("用户名称") | ||
| 81 | - private Integer user_name; | 96 | + /** 页面展示类型 */ |
| 97 | + @ApiModelProperty("页面展示类型") | ||
| 98 | + private String view_type; | ||
| 82 | 99 | ||
| 83 | - public Integer getUser_name() { | ||
| 84 | - return user_name; | 100 | + public void setAscription(Integer ascription) |
| 101 | + { | ||
| 102 | + this.ascription = ascription; | ||
| 85 | } | 103 | } |
| 86 | 104 | ||
| 87 | - public void setUser_name(Integer user_name) { | ||
| 88 | - this.user_name = user_name; | 105 | + public Integer getAscription() |
| 106 | + { | ||
| 107 | + return ascription; | ||
| 108 | + } | ||
| 109 | + public void setConfig_names(String config_names) | ||
| 110 | + { | ||
| 111 | + this.config_names = config_names; | ||
| 89 | } | 112 | } |
| 90 | 113 | ||
| 91 | - public void setCreate_by(String create_by) | 114 | + public String getConfig_names() |
| 115 | + { | ||
| 116 | + return config_names; | ||
| 117 | + } | ||
| 118 | + public void setCreate_by(String create_by) | ||
| 92 | { | 119 | { |
| 93 | this.create_by = create_by; | 120 | this.create_by = create_by; |
| 94 | } | 121 | } |
| @@ -133,6 +160,15 @@ public class IotThingsModel | @@ -133,6 +160,15 @@ public class IotThingsModel | ||
| 133 | { | 160 | { |
| 134 | return identifier; | 161 | return identifier; |
| 135 | } | 162 | } |
| 163 | + public void setIs_config(Integer is_config) | ||
| 164 | + { | ||
| 165 | + this.is_config = is_config; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + public Integer getIs_config() | ||
| 169 | + { | ||
| 170 | + return is_config; | ||
| 171 | + } | ||
| 136 | public void setIs_monitor(Integer is_monitor) | 172 | public void setIs_monitor(Integer is_monitor) |
| 137 | { | 173 | { |
| 138 | this.is_monitor = is_monitor; | 174 | this.is_monitor = is_monitor; |
| @@ -178,6 +214,24 @@ public class IotThingsModel | @@ -178,6 +214,24 @@ public class IotThingsModel | ||
| 178 | { | 214 | { |
| 179 | return model_name; | 215 | return model_name; |
| 180 | } | 216 | } |
| 217 | + public void setMqtt_username(String mqtt_username) | ||
| 218 | + { | ||
| 219 | + this.mqtt_username = mqtt_username; | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + public String getMqtt_username() | ||
| 223 | + { | ||
| 224 | + return mqtt_username; | ||
| 225 | + } | ||
| 226 | + public void setProduct_id(Integer product_id) | ||
| 227 | + { | ||
| 228 | + this.product_id = product_id; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + public Integer getProduct_id() | ||
| 232 | + { | ||
| 233 | + return product_id; | ||
| 234 | + } | ||
| 181 | public void setSpecs(String specs) | 235 | public void setSpecs(String specs) |
| 182 | { | 236 | { |
| 183 | this.specs = specs; | 237 | this.specs = specs; |
| @@ -214,33 +268,40 @@ public class IotThingsModel | @@ -214,33 +268,40 @@ public class IotThingsModel | ||
| 214 | { | 268 | { |
| 215 | return update_time; | 269 | return update_time; |
| 216 | } | 270 | } |
| 217 | - public void setUser_id(Integer user_id) | 271 | + public void setView_type(String view_type) |
| 218 | { | 272 | { |
| 219 | - this.user_id = user_id; | 273 | + this.view_type = view_type; |
| 220 | } | 274 | } |
| 221 | 275 | ||
| 222 | - public Integer getUser_id() | 276 | + public String getView_type() |
| 223 | { | 277 | { |
| 224 | - return user_id; | 278 | + return view_type; |
| 225 | } | 279 | } |
| 226 | 280 | ||
| 281 | + @Override | ||
| 227 | public String toString() { | 282 | public String toString() { |
| 228 | - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | 283 | + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
| 284 | + .append("ascription", getAscription()) | ||
| 285 | + .append("config_names", getConfig_names()) | ||
| 229 | .append("create_by", getCreate_by()) | 286 | .append("create_by", getCreate_by()) |
| 230 | .append("create_time", getCreate_time()) | 287 | .append("create_time", getCreate_time()) |
| 231 | .append("data_type", getData_type()) | 288 | .append("data_type", getData_type()) |
| 232 | .append("del_flag", getDel_flag()) | 289 | .append("del_flag", getDel_flag()) |
| 233 | .append("identifier", getIdentifier()) | 290 | .append("identifier", getIdentifier()) |
| 291 | + .append("is_config", getIs_config()) | ||
| 234 | .append("is_monitor", getIs_monitor()) | 292 | .append("is_monitor", getIs_monitor()) |
| 235 | .append("is_save_log", getIs_save_log()) | 293 | .append("is_save_log", getIs_save_log()) |
| 236 | .append("is_top", getIs_top()) | 294 | .append("is_top", getIs_top()) |
| 237 | .append("model_id", getModel_id()) | 295 | .append("model_id", getModel_id()) |
| 238 | .append("model_name", getModel_name()) | 296 | .append("model_name", getModel_name()) |
| 297 | + .append("mqtt_username", getMqtt_username()) | ||
| 298 | + .append("product_id", getProduct_id()) | ||
| 299 | + .append("remark", getRemark()) | ||
| 239 | .append("specs", getSpecs()) | 300 | .append("specs", getSpecs()) |
| 240 | .append("type", getType()) | 301 | .append("type", getType()) |
| 241 | .append("update_by", getUpdate_by()) | 302 | .append("update_by", getUpdate_by()) |
| 242 | .append("update_time", getUpdate_time()) | 303 | .append("update_time", getUpdate_time()) |
| 243 | - .append("user_id", getUser_id()) | 304 | + .append("view_type", getView_type()) |
| 244 | .toString(); | 305 | .toString(); |
| 245 | } | 306 | } |
| 246 | } | 307 | } |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | -import com.ruoyi.common.annotation.Excel; | ||
| 4 | -import com.ruoyi.common.annotation.Excel.ColumnType; | ||
| 5 | -import com.ruoyi.common.core.domain.BaseEntity; | 3 | +import com.ruoyi.system.domain.tool.BaseEntity; |
| 4 | +import com.ruoyi.system.domain.tool.Excel; | ||
| 6 | import io.swagger.annotations.ApiModel; | 5 | import io.swagger.annotations.ApiModel; |
| 7 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
| 8 | import org.apache.commons.lang3.builder.ToStringBuilder; | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| @@ -23,7 +22,7 @@ public class SysConfig extends BaseEntity | @@ -23,7 +22,7 @@ public class SysConfig extends BaseEntity | ||
| 23 | 22 | ||
| 24 | /** 参数主键 */ | 23 | /** 参数主键 */ |
| 25 | @ApiModelProperty("参数主键") | 24 | @ApiModelProperty("参数主键") |
| 26 | - @Excel(name = "参数主键", cellType = ColumnType.NUMERIC) | 25 | + @Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC) |
| 27 | private Long configId; | 26 | private Long configId; |
| 28 | 27 | ||
| 29 | /** 参数名称 */ | 28 | /** 参数名称 */ |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonFormat; | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 4 | -import com.ruoyi.common.annotation.Excel; | ||
| 5 | -import com.ruoyi.common.annotation.Excel.ColumnType; | ||
| 6 | -import com.ruoyi.common.core.domain.BaseEntity; | 4 | +import com.ruoyi.system.domain.tool.BaseEntity; |
| 5 | +import com.ruoyi.system.domain.tool.Excel; | ||
| 7 | 6 | ||
| 8 | import java.util.Date; | 7 | import java.util.Date; |
| 9 | 8 | ||
| @@ -17,7 +16,7 @@ public class SysLogininfor extends BaseEntity | @@ -17,7 +16,7 @@ public class SysLogininfor extends BaseEntity | ||
| 17 | private static final long serialVersionUID = 1L; | 16 | private static final long serialVersionUID = 1L; |
| 18 | 17 | ||
| 19 | /** ID */ | 18 | /** ID */ |
| 20 | - @Excel(name = "序号", cellType = ColumnType.NUMERIC) | 19 | + @Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC) |
| 21 | private Long infoId; | 20 | private Long infoId; |
| 22 | 21 | ||
| 23 | /** 用户账号 */ | 22 | /** 用户账号 */ |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | -import com.ruoyi.common.core.domain.BaseEntity; | ||
| 4 | -import com.ruoyi.common.xss.Xss; | 3 | +import com.ruoyi.system.domain.tool.BaseEntity; |
| 4 | +import com.ruoyi.system.domain.tool.Xss; | ||
| 5 | import io.swagger.annotations.ApiModel; | 5 | import io.swagger.annotations.ApiModel; |
| 6 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
| 7 | import org.apache.commons.lang3.builder.ToStringBuilder; | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonFormat; | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 4 | -import com.ruoyi.common.annotation.Excel; | ||
| 5 | -import com.ruoyi.common.annotation.Excel.ColumnType; | ||
| 6 | -import com.ruoyi.common.core.domain.BaseEntity; | 4 | +import com.ruoyi.system.domain.tool.BaseEntity; |
| 5 | +import com.ruoyi.system.domain.tool.Excel; | ||
| 7 | import io.swagger.annotations.ApiModel; | 6 | import io.swagger.annotations.ApiModel; |
| 8 | import io.swagger.annotations.ApiModelProperty; | 7 | import io.swagger.annotations.ApiModelProperty; |
| 9 | 8 | ||
| @@ -21,7 +20,7 @@ public class SysOperLog extends BaseEntity | @@ -21,7 +20,7 @@ public class SysOperLog extends BaseEntity | ||
| 21 | 20 | ||
| 22 | /** 日志主键 */ | 21 | /** 日志主键 */ |
| 23 | @ApiModelProperty("操作序号") | 22 | @ApiModelProperty("操作序号") |
| 24 | - @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) | 23 | + @Excel(name = "操作序号", cellType = Excel.ColumnType.NUMERIC) |
| 25 | private Long operId; | 24 | private Long operId; |
| 26 | 25 | ||
| 27 | /** 操作模块 */ | 26 | /** 操作模块 */ |
| 1 | package com.ruoyi.system.domain; | 1 | package com.ruoyi.system.domain; |
| 2 | 2 | ||
| 3 | -import com.ruoyi.common.annotation.Excel; | ||
| 4 | -import com.ruoyi.common.annotation.Excel.ColumnType; | ||
| 5 | -import com.ruoyi.common.core.domain.BaseEntity; | 3 | +import com.ruoyi.system.domain.tool.BaseEntity; |
| 4 | +import com.ruoyi.system.domain.tool.Excel; | ||
| 6 | import io.swagger.annotations.ApiModel; | 5 | import io.swagger.annotations.ApiModel; |
| 7 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
| 8 | import org.apache.commons.lang3.builder.ToStringBuilder; | 7 | import org.apache.commons.lang3.builder.ToStringBuilder; |
| @@ -23,7 +22,7 @@ public class SysPost extends BaseEntity | @@ -23,7 +22,7 @@ public class SysPost extends BaseEntity | ||
| 23 | 22 | ||
| 24 | /** 岗位序号 */ | 23 | /** 岗位序号 */ |
| 25 | @ApiModelProperty("岗位序号") | 24 | @ApiModelProperty("岗位序号") |
| 26 | - @Excel(name = "岗位序号", cellType = ColumnType.NUMERIC) | 25 | + @Excel(name = "岗位序号", cellType = Excel.ColumnType.NUMERIC) |
| 27 | private Long postId; | 26 | private Long postId; |
| 28 | 27 | ||
| 29 | /** 岗位编码 */ | 28 | /** 岗位编码 */ |
| 1 | -package com.ruoyi.common.core.domain; | 1 | +package com.ruoyi.system.domain.tool; |
| 2 | 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonFormat; | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 4 | import org.springframework.data.annotation.Transient; | 4 | import org.springframework.data.annotation.Transient; |
| 1 | -package com.ruoyi.common.annotation; | ||
| 2 | - | ||
| 3 | -import com.ruoyi.common.utils.poi.ExcelHandlerAdapter; | 1 | +package com.ruoyi.system.domain.tool; |
| 4 | 2 | ||
| 5 | import java.lang.annotation.ElementType; | 3 | import java.lang.annotation.ElementType; |
| 6 | import java.lang.annotation.Retention; | 4 | import java.lang.annotation.Retention; |
| 1 | -package com.ruoyi.common.xss; | 1 | +package com.ruoyi.system.domain.tool; |
| 2 | 2 | ||
| 3 | -import com.ruoyi.common.utils.StringUtils; | 3 | + |
| 4 | +import org.apache.commons.lang3.StringUtils; | ||
| 4 | 5 | ||
| 5 | import javax.validation.ConstraintValidator; | 6 | import javax.validation.ConstraintValidator; |
| 6 | import javax.validation.ConstraintValidatorContext; | 7 | import javax.validation.ConstraintValidatorContext; |
| 1 | package com.ruoyi.system.domain.vo; | 1 | package com.ruoyi.system.domain.vo; |
| 2 | 2 | ||
| 3 | -import com.ruoyi.common.utils.StringUtils; | 3 | + |
| 4 | +import org.apache.commons.lang3.StringUtils; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * 路由显示信息 | 7 | * 路由显示信息 |
| @@ -58,7 +59,7 @@ public class MetaVo | @@ -58,7 +59,7 @@ public class MetaVo | ||
| 58 | this.title = title; | 59 | this.title = title; |
| 59 | this.icon = icon; | 60 | this.icon = icon; |
| 60 | this.noCache = noCache; | 61 | this.noCache = noCache; |
| 61 | - if (StringUtils.ishttp(link)) | 62 | + if (StringUtils.startsWithAny(link, "http://", "https://")) |
| 62 | { | 63 | { |
| 63 | this.link = link; | 64 | this.link = link; |
| 64 | } | 65 | } |
| @@ -21,14 +21,14 @@ | @@ -21,14 +21,14 @@ | ||
| 21 | # rssi 设备强度(信号极好[-55— 0],信号好[-70— -55],信号一般[-85— -70],信号差[-100— -85]) | 21 | # rssi 设备强度(信号极好[-55— 0],信号好[-70— -55],信号一般[-85— -70],信号差[-100— -85]) |
| 22 | # status 设备状态,固定为3,表示在线 | 22 | # status 设备状态,固定为3,表示在线 |
| 23 | # userId 用户的ID,1=admin | 23 | # userId 用户的ID,1=admin |
| 24 | -# firmwareVersion 固件版本 | 24 | +# firmware_version 固件版本 |
| 25 | # longitude 经度,可选,使用设备定位时需要上传 | 25 | # longitude 经度,可选,使用设备定位时需要上传 |
| 26 | # latitude 纬度,可选,使用设备定位时需要上传 | 26 | # latitude 纬度,可选,使用设备定位时需要上传 |
| 27 | # summary 摘要,可选,设备的配置信息等,json格式,对象可自定义 | 27 | # summary 摘要,可选,设备的配置信息等,json格式,对象可自定义 |
| 28 | { | 28 | { |
| 29 | "0":{ | 29 | "0":{ |
| 30 | "rssi": -43, | 30 | "rssi": -43, |
| 31 | - "firmwareVersion": 1.2, | 31 | + "firmware_version": 1.2, |
| 32 | "longitude": 0, | 32 | "longitude": 0, |
| 33 | "latitude": 0, | 33 | "latitude": 0, |
| 34 | "summary": { | 34 | "summary": { |
| @@ -134,7 +134,7 @@ | @@ -134,7 +134,7 @@ | ||
| 134 | { | 134 | { |
| 135 | "0":{ | 135 | "0":{ |
| 136 | "restart": 1, | 136 | "restart": 1, |
| 137 | - "firmwareVersion": 1.2, | 137 | + "firmware_version": 1.2, |
| 138 | "longitude": 0, | 138 | "longitude": 0, |
| 139 | "latitude": 0, | 139 | "latitude": 0, |
| 140 | "summary": { | 140 | "summary": { |
| @@ -12,11 +12,42 @@ | @@ -12,11 +12,42 @@ | ||
| 12 | <artifactId>lh-mqtt-service</artifactId> | 12 | <artifactId>lh-mqtt-service</artifactId> |
| 13 | 13 | ||
| 14 | <dependencies> | 14 | <dependencies> |
| 15 | + <!-- spring-boot-devtools --> | ||
| 16 | + <dependency> | ||
| 17 | + <groupId>org.springframework.boot</groupId> | ||
| 18 | + <artifactId>spring-boot-devtools</artifactId> | ||
| 19 | + <optional>true</optional> <!-- 表示依赖不会传递 --> | ||
| 20 | + </dependency> | ||
| 15 | <!-- SpringBoot Web容器 --> | 21 | <!-- SpringBoot Web容器 --> |
| 16 | <dependency> | 22 | <dependency> |
| 17 | <groupId>org.springframework.boot</groupId> | 23 | <groupId>org.springframework.boot</groupId> |
| 18 | <artifactId>spring-boot-starter-web</artifactId> | 24 | <artifactId>spring-boot-starter-web</artifactId> |
| 19 | </dependency> | 25 | </dependency> |
| 26 | + <!-- Spring框架基本的核心工具 --> | ||
| 27 | + <dependency> | ||
| 28 | + <groupId>org.springframework</groupId> | ||
| 29 | + <artifactId>spring-context-support</artifactId> | ||
| 30 | + </dependency> | ||
| 31 | + <!-- SpringWeb模块 --> | ||
| 32 | + <dependency> | ||
| 33 | + <groupId>org.springframework</groupId> | ||
| 34 | + <artifactId>spring-web</artifactId> | ||
| 35 | + </dependency> | ||
| 36 | + <!-- yml解析器 --> | ||
| 37 | + <dependency> | ||
| 38 | + <groupId>org.yaml</groupId> | ||
| 39 | + <artifactId>snakeyaml</artifactId> | ||
| 40 | + </dependency> | ||
| 41 | + <!-- servlet包 --> | ||
| 42 | + <dependency> | ||
| 43 | + <groupId>javax.servlet</groupId> | ||
| 44 | + <artifactId>javax.servlet-api</artifactId> | ||
| 45 | + </dependency> | ||
| 46 | + <dependency> | ||
| 47 | + <groupId>org.apache.commons</groupId> | ||
| 48 | + <artifactId>commons-text</artifactId> | ||
| 49 | + </dependency> | ||
| 50 | + | ||
| 20 | <!-- 文档 --> | 51 | <!-- 文档 --> |
| 21 | <dependency> | 52 | <dependency> |
| 22 | <groupId>io.springfox</groupId> | 53 | <groupId>io.springfox</groupId> |
| @@ -58,11 +89,6 @@ | @@ -58,11 +89,6 @@ | ||
| 58 | </dependency> | 89 | </dependency> |
| 59 | 90 | ||
| 60 | <dependency> | 91 | <dependency> |
| 61 | - <groupId>org.springframework.boot</groupId> | ||
| 62 | - <artifactId>spring-boot-starter-tomcat</artifactId> | ||
| 63 | - <scope>provided</scope> | ||
| 64 | - </dependency> | ||
| 65 | - <dependency> | ||
| 66 | <groupId>net.jodah</groupId> | 92 | <groupId>net.jodah</groupId> |
| 67 | <artifactId>expiringmap</artifactId> | 93 | <artifactId>expiringmap</artifactId> |
| 68 | </dependency> | 94 | </dependency> |
| @@ -113,8 +139,17 @@ | @@ -113,8 +139,17 @@ | ||
| 113 | <dependency> | 139 | <dependency> |
| 114 | <groupId>org.springframework.boot</groupId> | 140 | <groupId>org.springframework.boot</groupId> |
| 115 | <artifactId>spring-boot-starter-data-redis</artifactId> | 141 | <artifactId>spring-boot-starter-data-redis</artifactId> |
| 142 | + <exclusions> | ||
| 143 | + <exclusion> | ||
| 144 | + <groupId>io.lettuce</groupId> | ||
| 145 | + <artifactId>lettuce-core</artifactId> | ||
| 146 | + </exclusion> | ||
| 147 | + </exclusions> | ||
| 148 | + </dependency> | ||
| 149 | + <dependency> | ||
| 150 | + <groupId>redis.clients</groupId> | ||
| 151 | + <artifactId>jedis</artifactId> | ||
| 116 | </dependency> | 152 | </dependency> |
| 117 | - | ||
| 118 | <!-- Token生成与解析--> | 153 | <!-- Token生成与解析--> |
| 119 | <dependency> | 154 | <dependency> |
| 120 | <groupId>io.jsonwebtoken</groupId> | 155 | <groupId>io.jsonwebtoken</groupId> |
| @@ -126,6 +161,12 @@ | @@ -126,6 +161,12 @@ | ||
| 126 | <artifactId>okhttp</artifactId> | 161 | <artifactId>okhttp</artifactId> |
| 127 | </dependency> | 162 | </dependency> |
| 128 | 163 | ||
| 164 | + <!-- 通用工具--> | ||
| 165 | + <dependency> | ||
| 166 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 167 | + <artifactId>lh-domain</artifactId> | ||
| 168 | + </dependency> | ||
| 169 | + | ||
| 129 | </dependencies> | 170 | </dependencies> |
| 130 | 171 | ||
| 131 | <build> | 172 | <build> |
| @@ -151,7 +192,7 @@ | @@ -151,7 +192,7 @@ | ||
| 151 | 生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/ | 192 | 生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/ |
| 152 | --> | 193 | --> |
| 153 | <classpathPrefix>lib/</classpathPrefix> | 194 | <classpathPrefix>lib/</classpathPrefix> |
| 154 | - <mainClass>com.zhonglai.waibao.juheliaotian.mqtt.service.MqttServiceApplication</mainClass> | 195 | + <mainClass>com.zhonglai.luhui.mqtt.MqttApplication</mainClass> |
| 155 | </manifest> | 196 | </manifest> |
| 156 | </archive> | 197 | </archive> |
| 157 | </configuration> | 198 | </configuration> |
| 1 | package com.zhonglai.luhui.mqtt.comm.agreement; | 1 | package com.zhonglai.luhui.mqtt.comm.agreement; |
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson.JSONObject; | ||
| 4 | import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreement; | 3 | import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreement; |
| 5 | import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreementFactory; | 4 | import com.zhonglai.luhui.mqtt.comm.factory.BusinessAgreementFactory; |
| 6 | import com.zhonglai.luhui.mqtt.comm.factory.Topic; | 5 | import com.zhonglai.luhui.mqtt.comm.factory.Topic; |
| 1 | package com.zhonglai.luhui.mqtt.comm.config; | 1 | package com.zhonglai.luhui.mqtt.comm.config; |
| 2 | 2 | ||
| 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; | 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
| 4 | +import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
| 4 | import com.fasterxml.jackson.annotation.PropertyAccessor; | 5 | import com.fasterxml.jackson.annotation.PropertyAccessor; |
| 5 | import com.fasterxml.jackson.databind.ObjectMapper; | 6 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 6 | import org.springframework.beans.factory.annotation.Value; | 7 | import org.springframework.beans.factory.annotation.Value; |
| @@ -14,13 +15,23 @@ import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; | @@ -14,13 +15,23 @@ import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; | ||
| 14 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | 15 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; |
| 15 | import org.springframework.data.redis.serializer.StringRedisSerializer; | 16 | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| 16 | 17 | ||
| 18 | +import javax.annotation.PostConstruct; | ||
| 19 | + | ||
| 17 | @Configuration | 20 | @Configuration |
| 18 | public class RedisConfig { | 21 | public class RedisConfig { |
| 19 | - @Value("${sys.redis.field:#{'luhui:mqttservice:device:'}") | 22 | + @Value("${sys.redis.field}") |
| 23 | + public String sysRedisField ; //域 | ||
| 20 | public static String FIELD ; //域 | 24 | public static String FIELD ; //域 |
| 21 | public static String DEVICE = "device:"; //存放网关数据 | 25 | public static String DEVICE = "device:"; //存放网关数据 |
| 22 | public static String THINGS_MODEL = "things_model:"; //存放数据模型 | 26 | public static String THINGS_MODEL = "things_model:"; //存放数据模型 |
| 23 | public static String TERMINAL = "terminal:"; //存放终端数据 | 27 | public static String TERMINAL = "terminal:"; //存放终端数据 |
| 28 | + public static String LOCK = "lock:"; //存放设备锁 | ||
| 29 | + | ||
| 30 | + @PostConstruct | ||
| 31 | + public void init() | ||
| 32 | + { | ||
| 33 | + RedisConfig.FIELD = sysRedisField; | ||
| 34 | + } | ||
| 24 | 35 | ||
| 25 | 36 | ||
| 26 | @Bean | 37 | @Bean |
| @@ -44,7 +55,7 @@ public class RedisConfig { | @@ -44,7 +55,7 @@ public class RedisConfig { | ||
| 44 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); | 55 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); |
| 45 | ObjectMapper om = new ObjectMapper(); | 56 | ObjectMapper om = new ObjectMapper(); |
| 46 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | 57 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); |
| 47 | - om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); | 58 | + om.activateDefaultTyping(om.getPolymorphicTypeValidator(),ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_ARRAY); |
| 48 | jackson2JsonRedisSerializer.setObjectMapper(om); | 59 | jackson2JsonRedisSerializer.setObjectMapper(om); |
| 49 | //普通的值采用jackson方式自动序列化 | 60 | //普通的值采用jackson方式自动序列化 |
| 50 | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); | 61 | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); |
| @@ -18,10 +18,14 @@ public class SysParameter { | @@ -18,10 +18,14 @@ public class SysParameter { | ||
| 18 | @Value("${mqtt.topicconfig:/{{roleid}}/{{username}}/{{clientid}}/{{topicType}}/{{messageid}}}") | 18 | @Value("${mqtt.topicconfig:/{{roleid}}/{{username}}/{{clientid}}/{{topicType}}/{{messageid}}}") |
| 19 | public String tempTopicconfig ; //topic 配置 | 19 | public String tempTopicconfig ; //topic 配置 |
| 20 | 20 | ||
| 21 | + @Value("${mqtt.topics") | ||
| 22 | + public String topics ; //topic | ||
| 23 | + | ||
| 21 | public static String topicconfig ; //topic 配置 | 24 | public static String topicconfig ; //topic 配置 |
| 22 | 25 | ||
| 26 | + | ||
| 23 | @PostConstruct | 27 | @PostConstruct |
| 24 | - public static void init() { | 28 | + public void init() { |
| 25 | String service_ip_url = "http://ly.userlogin.yu2le.com/ip"; | 29 | String service_ip_url = "http://ly.userlogin.yu2le.com/ip"; |
| 26 | JSONObject jsonObject = JSONObject.parseObject(HttpUtils.sendGet(service_ip_url)); | 30 | JSONObject jsonObject = JSONObject.parseObject(HttpUtils.sendGet(service_ip_url)); |
| 27 | service_ip = jsonObject.getString("data"); | 31 | service_ip = jsonObject.getString("data"); |
| @@ -32,4 +36,5 @@ public class SysParameter { | @@ -32,4 +36,5 @@ public class SysParameter { | ||
| 32 | { | 36 | { |
| 33 | topicconfig = tempTopicconfig; | 37 | topicconfig = tempTopicconfig; |
| 34 | } | 38 | } |
| 39 | + | ||
| 35 | } | 40 | } |
| @@ -233,7 +233,13 @@ public class BaseDao { | @@ -233,7 +233,13 @@ public class BaseDao { | ||
| 233 | { | 233 | { |
| 234 | Field field = fields[i]; | 234 | Field field = fields[i]; |
| 235 | try { | 235 | try { |
| 236 | - Method method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName())); | 236 | + |
| 237 | + Method method = null; | ||
| 238 | + try { | ||
| 239 | + method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(field.getName())); | ||
| 240 | + } catch (NoSuchMethodException e) { | ||
| 241 | + continue; | ||
| 242 | + } | ||
| 237 | Object value = method.invoke(object); | 243 | Object value = method.invoke(object); |
| 238 | if(null != value) | 244 | if(null != value) |
| 239 | { | 245 | { |
| @@ -241,14 +247,11 @@ public class BaseDao { | @@ -241,14 +247,11 @@ public class BaseDao { | ||
| 241 | { | 247 | { |
| 242 | sql += ","; | 248 | sql += ","; |
| 243 | } | 249 | } |
| 244 | - sql += "`"+changTableNameFromObject(field.getName())+"`"+"=?"; | 250 | + sql += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+"=?"; |
| 245 | j++; | 251 | j++; |
| 246 | valueList.add(value); | 252 | valueList.add(value); |
| 247 | } | 253 | } |
| 248 | - } catch (NoSuchMethodException e) { | ||
| 249 | - | ||
| 250 | - e.printStackTrace(); | ||
| 251 | - } catch (SecurityException e) { | 254 | + } catch (SecurityException e) { |
| 252 | // TODO Auto-generated catch block | 255 | // TODO Auto-generated catch block |
| 253 | e.printStackTrace(); | 256 | e.printStackTrace(); |
| 254 | } catch (IllegalAccessException e) { | 257 | } catch (IllegalAccessException e) { |
| @@ -276,7 +279,7 @@ public class BaseDao { | @@ -276,7 +279,7 @@ public class BaseDao { | ||
| 276 | Method method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(wheres[i])); | 279 | Method method = object.getClass().getMethod("get"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.getName(wheres[i])); |
| 277 | Object value = method.invoke(object); | 280 | Object value = method.invoke(object); |
| 278 | sql += " and "; | 281 | sql += " and "; |
| 279 | - sql += changTableNameFromObject(wheres[i]) + "=?"; | 282 | + sql += com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(wheres[i]) + "=?"; |
| 280 | valueList.add(value); | 283 | valueList.add(value); |
| 281 | } catch (IllegalAccessException e) { | 284 | } catch (IllegalAccessException e) { |
| 282 | // TODO Auto-generated catch block | 285 | // TODO Auto-generated catch block |
| @@ -774,7 +777,6 @@ public class BaseDao { | @@ -774,7 +777,6 @@ public class BaseDao { | ||
| 774 | update += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+"=VALUES("+"`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`)"; | 777 | update += "`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`"+"=VALUES("+"`"+com.zhonglai.luhui.mqtt.comm.util.StringUtils.toUnderScoreCase(field.getName())+"`)"; |
| 775 | } | 778 | } |
| 776 | } catch (NoSuchMethodException e) { | 779 | } catch (NoSuchMethodException e) { |
| 777 | - System.out.println("未找到"+field.getName()+"的get方法"); | ||
| 778 | } catch (SecurityException e) { | 780 | } catch (SecurityException e) { |
| 779 | // TODO Auto-generated catch block | 781 | // TODO Auto-generated catch block |
| 780 | e.printStackTrace(); | 782 | e.printStackTrace(); |
| @@ -5,7 +5,6 @@ import com.zhonglai.luhui.mqtt.comm.factory.Topic; | @@ -5,7 +5,6 @@ import com.zhonglai.luhui.mqtt.comm.factory.Topic; | ||
| 5 | import com.zhonglai.luhui.mqtt.dto.Message; | 5 | import com.zhonglai.luhui.mqtt.dto.Message; |
| 6 | 6 | ||
| 7 | public interface ServerAgreementContent { | 7 | public interface ServerAgreementContent { |
| 8 | - String getClienConnectionId(); | ||
| 9 | byte[] getCommd(); | 8 | byte[] getCommd(); |
| 10 | String getReplyCommdTopic(Topic topic); | 9 | String getReplyCommdTopic(Topic topic); |
| 11 | void setReplyMessage(Message message); | 10 | void setReplyMessage(Message message); |
| 1 | package com.zhonglai.luhui.mqtt.comm.dto; | 1 | package com.zhonglai.luhui.mqtt.comm.dto; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import java.util.List; | ||
| 5 | + | ||
| 4 | public interface ServerDto { | 6 | public interface ServerDto { |
| 5 | ServerAgreementContent getServerAgreementContent(); | 7 | ServerAgreementContent getServerAgreementContent(); |
| 6 | boolean isReplyMessage(); | 8 | boolean isReplyMessage(); |
| 9 | + List<DeviceSensorData> getDeviceSensorData(); | ||
| 10 | + List<LogDeviceOperation> getOperationLog(); | ||
| 7 | } | 11 | } |
lh-mqtt-service/src/main/java/com/zhonglai/luhui/mqtt/comm/dto/iot/IotPermission.java
已删除
100644 → 0
| 1 | -package com.zhonglai.luhui.mqtt.comm.dto.iot; | ||
| 2 | - | ||
| 3 | -import io.swagger.annotations.ApiModel; | ||
| 4 | -import io.swagger.annotations.ApiModelProperty; | ||
| 5 | -import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 6 | -import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * topic权限控制对象 iot_permission | ||
| 10 | - * | ||
| 11 | - * @author 钟来 | ||
| 12 | - * @date 2022-08-26 | ||
| 13 | - */ | ||
| 14 | -@ApiModel("topic权限控制") | ||
| 15 | -public class IotPermission | ||
| 16 | -{ | ||
| 17 | - private static final long serialVersionUID = 1L; | ||
| 18 | - | ||
| 19 | - /** 动作(PUBLISH,SUBSCRIBE,ALL) */ | ||
| 20 | - @ApiModelProperty("动作(PUBLISH,SUBSCRIBE,ALL)") | ||
| 21 | - private String activity; | ||
| 22 | - | ||
| 23 | - /** 创建时间 */ | ||
| 24 | - @ApiModelProperty("创建时间") | ||
| 25 | - private Integer create_time; | ||
| 26 | - | ||
| 27 | - /** 描述 */ | ||
| 28 | - @ApiModelProperty("描述") | ||
| 29 | - private String describe; | ||
| 30 | - | ||
| 31 | - /** 主键 */ | ||
| 32 | - @ApiModelProperty("主键") | ||
| 33 | - private Integer id; | ||
| 34 | - | ||
| 35 | - /** 质量(ZERO,ONE,TWO,ZERO_ONE,ZERO_TWO,ONE_TWO,ALL) */ | ||
| 36 | - @ApiModelProperty("质量(ZERO,ONE,TWO,ZERO_ONE,ZERO_TWO,ONE_TWO,ALL)") | ||
| 37 | - private String qos; | ||
| 38 | - | ||
| 39 | - /** 是否保留(RETAINED,NOT_RETAINED,ALL) */ | ||
| 40 | - @ApiModelProperty("是否保留(RETAINED,NOT_RETAINED,ALL)") | ||
| 41 | - private String retain; | ||
| 42 | - | ||
| 43 | - /** 角色id */ | ||
| 44 | - @ApiModelProperty("角色id") | ||
| 45 | - private Integer role_id; | ||
| 46 | - | ||
| 47 | - /** 共享组 */ | ||
| 48 | - @ApiModelProperty("共享组") | ||
| 49 | - private String shared_group; | ||
| 50 | - | ||
| 51 | - /** 共享订阅(SHARED,NOT_SHARED,ALL) */ | ||
| 52 | - @ApiModelProperty("共享订阅(SHARED,NOT_SHARED,ALL)") | ||
| 53 | - private String shared_subscription; | ||
| 54 | - | ||
| 55 | - /** topic(同一角色有切只有一个) */ | ||
| 56 | - @ApiModelProperty("topic(同一角色有切只有一个)") | ||
| 57 | - private String topic; | ||
| 58 | - | ||
| 59 | - public void setActivity(String activity) | ||
| 60 | - { | ||
| 61 | - this.activity = activity; | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - public String getActivity() | ||
| 65 | - { | ||
| 66 | - return activity; | ||
| 67 | - } | ||
| 68 | - public void setCreate_time(Integer create_time) | ||
| 69 | - { | ||
| 70 | - this.create_time = create_time; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - public Integer getCreate_time() | ||
| 74 | - { | ||
| 75 | - return create_time; | ||
| 76 | - } | ||
| 77 | - public void setDescribe(String describe) | ||
| 78 | - { | ||
| 79 | - this.describe = describe; | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - public String getDescribe() | ||
| 83 | - { | ||
| 84 | - return describe; | ||
| 85 | - } | ||
| 86 | - public void setId(Integer id) | ||
| 87 | - { | ||
| 88 | - this.id = id; | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - public Integer getId() | ||
| 92 | - { | ||
| 93 | - return id; | ||
| 94 | - } | ||
| 95 | - public void setQos(String qos) | ||
| 96 | - { | ||
| 97 | - this.qos = qos; | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - public String getQos() | ||
| 101 | - { | ||
| 102 | - return qos; | ||
| 103 | - } | ||
| 104 | - public void setRetain(String retain) | ||
| 105 | - { | ||
| 106 | - this.retain = retain; | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - public String getRetain() | ||
| 110 | - { | ||
| 111 | - return retain; | ||
| 112 | - } | ||
| 113 | - public void setRole_id(Integer role_id) | ||
| 114 | - { | ||
| 115 | - this.role_id = role_id; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - public Integer getRole_id() | ||
| 119 | - { | ||
| 120 | - return role_id; | ||
| 121 | - } | ||
| 122 | - public void setShared_group(String shared_group) | ||
| 123 | - { | ||
| 124 | - this.shared_group = shared_group; | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - public String getShared_group() | ||
| 128 | - { | ||
| 129 | - return shared_group; | ||
| 130 | - } | ||
| 131 | - public void setShared_subscription(String shared_subscription) | ||
| 132 | - { | ||
| 133 | - this.shared_subscription = shared_subscription; | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - public String getShared_subscription() | ||
| 137 | - { | ||
| 138 | - return shared_subscription; | ||
| 139 | - } | ||
| 140 | - public void setTopic(String topic) | ||
| 141 | - { | ||
| 142 | - this.topic = topic; | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - public String getTopic() | ||
| 146 | - { | ||
| 147 | - return topic; | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - public String toString() { | ||
| 151 | - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||
| 152 | - .append("activity", getActivity()) | ||
| 153 | - .append("create_time", getCreate_time()) | ||
| 154 | - .append("describe", getDescribe()) | ||
| 155 | - .append("id", getId()) | ||
| 156 | - .append("qos", getQos()) | ||
| 157 | - .append("retain", getRetain()) | ||
| 158 | - .append("role_id", getRole_id()) | ||
| 159 | - .append("shared_group", getShared_group()) | ||
| 160 | - .append("shared_subscription", getShared_subscription()) | ||
| 161 | - .append("topic", getTopic()) | ||
| 162 | - .toString(); | ||
| 163 | - } | ||
| 164 | -} |
| 1 | -package com.zhonglai.luhui.mqtt.comm.dto.iot; | ||
| 2 | - | ||
| 3 | -import io.swagger.annotations.ApiModel; | ||
| 4 | -import io.swagger.annotations.ApiModelProperty; | ||
| 5 | -import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 6 | -import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 终端对象 iot_terminal | ||
| 10 | - * | ||
| 11 | - * @author 钟来 | ||
| 12 | - * @date 2022-08-26 | ||
| 13 | - */ | ||
| 14 | -@ApiModel("终端") | ||
| 15 | -public class IotTerminal | ||
| 16 | -{ | ||
| 17 | - private static final long serialVersionUID = 1L; | ||
| 18 | - | ||
| 19 | - /** 网关id */ | ||
| 20 | - @ApiModelProperty("网关id") | ||
| 21 | - private String device_id; | ||
| 22 | - | ||
| 23 | - /** 主键id */ | ||
| 24 | - @ApiModelProperty("主键id") | ||
| 25 | - private String id; | ||
| 26 | - | ||
| 27 | - /** 终端名称 */ | ||
| 28 | - @ApiModelProperty("终端名称") | ||
| 29 | - private String name; | ||
| 30 | - | ||
| 31 | - /** 物模型值 */ | ||
| 32 | - @ApiModelProperty("物模型值") | ||
| 33 | - private String things_model_value; | ||
| 34 | - | ||
| 35 | - /** 更新时间 */ | ||
| 36 | - @ApiModelProperty("更新时间") | ||
| 37 | - private Integer update_time; | ||
| 38 | - | ||
| 39 | - public void setDevice_id(String device_id) | ||
| 40 | - { | ||
| 41 | - this.device_id = device_id; | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - public String getDevice_id() | ||
| 45 | - { | ||
| 46 | - return device_id; | ||
| 47 | - } | ||
| 48 | - public void setId(String id) | ||
| 49 | - { | ||
| 50 | - this.id = id; | ||
| 51 | - } | ||
| 52 | - | ||
| 53 | - public String getId() | ||
| 54 | - { | ||
| 55 | - return id; | ||
| 56 | - } | ||
| 57 | - public void setName(String name) | ||
| 58 | - { | ||
| 59 | - this.name = name; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - public String getName() | ||
| 63 | - { | ||
| 64 | - return name; | ||
| 65 | - } | ||
| 66 | - public void setThings_model_value(String things_model_value) | ||
| 67 | - { | ||
| 68 | - this.things_model_value = things_model_value; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - public String getThings_model_value() | ||
| 72 | - { | ||
| 73 | - return things_model_value; | ||
| 74 | - } | ||
| 75 | - public void setUpdate_time(Integer update_time) | ||
| 76 | - { | ||
| 77 | - this.update_time = update_time; | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - public Integer getUpdate_time() | ||
| 81 | - { | ||
| 82 | - return update_time; | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - public String toString() { | ||
| 86 | - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||
| 87 | - .append("device_id", getDevice_id()) | ||
| 88 | - .append("id", getId()) | ||
| 89 | - .append("name", getName()) | ||
| 90 | - .append("things_model_value", getThings_model_value()) | ||
| 91 | - .append("update_time", getUpdate_time()) | ||
| 92 | - .toString(); | ||
| 93 | - } | ||
| 94 | -} |
| 1 | package com.zhonglai.luhui.mqtt.comm.dto.thingsmodels; | 1 | package com.zhonglai.luhui.mqtt.comm.dto.thingsmodels; |
| 2 | 2 | ||
| 3 | -import com.zhonglai.luhui.mqtt.comm.dto.iot.IotThingsModel; | 3 | + |
| 4 | +import com.ruoyi.system.domain.IotThingsModel; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * 物模型工厂 | 7 | * 物模型工厂 |
| @@ -8,5 +9,8 @@ import com.zhonglai.luhui.mqtt.comm.dto.iot.IotThingsModel; | @@ -8,5 +9,8 @@ import com.zhonglai.luhui.mqtt.comm.dto.iot.IotThingsModel; | ||
| 8 | public interface ThingsModelBase<T> { | 9 | public interface ThingsModelBase<T> { |
| 9 | void conversionThingsModel(IotThingsModel thingsModel); | 10 | void conversionThingsModel(IotThingsModel thingsModel); |
| 10 | void addValue(T t); | 11 | void addValue(T t); |
| 12 | +// @JSONField(serialize=false) | ||
| 11 | String getView(); | 13 | String getView(); |
| 14 | + String getSaveView(); | ||
| 15 | + Object getCmdView(Object value); | ||
| 12 | } | 16 | } |
lh-mqtt-service/src/main/java/com/zhonglai/luhui/mqtt/comm/dto/thingsmodels/ThingsModelItemBase.java
| 1 | package com.zhonglai.luhui.mqtt.comm.dto.thingsmodels; | 1 | package com.zhonglai.luhui.mqtt.comm.dto.thingsmodels; |
| 2 | 2 | ||
| 3 | -import com.zhonglai.luhui.mqtt.comm.dto.iot.IotThingsModel; | 3 | +import com.ruoyi.system.domain.IotThingsModel; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| @@ -26,7 +26,10 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | @@ -26,7 +26,10 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | ||
| 26 | private Integer is_save_log; | 26 | private Integer is_save_log; |
| 27 | /** 模型类别(1-属性,2-功能,3-事件) */ | 27 | /** 模型类别(1-属性,2-功能,3-事件) */ |
| 28 | private Integer mode_type; | 28 | private Integer mode_type; |
| 29 | - | 29 | + /** 模型类别(1-属性,2-功能,3-事件) */ |
| 30 | + private String config_names; | ||
| 31 | + /** 物模型id */ | ||
| 32 | + private Integer mode_id; | ||
| 30 | public void conversionThingsModel(IotThingsModel thingsModel) | 33 | public void conversionThingsModel(IotThingsModel thingsModel) |
| 31 | { | 34 | { |
| 32 | id = thingsModel.getIdentifier(); | 35 | id = thingsModel.getIdentifier(); |
| @@ -36,5 +39,8 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | @@ -36,5 +39,8 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | ||
| 36 | type = thingsModel.getData_type(); | 39 | type = thingsModel.getData_type(); |
| 37 | is_save_log = thingsModel.getIs_save_log(); | 40 | is_save_log = thingsModel.getIs_save_log(); |
| 38 | mode_type = thingsModel.getType(); | 41 | mode_type = thingsModel.getType(); |
| 42 | + config_names = thingsModel.getConfig_names(); | ||
| 43 | + mode_id = thingsModel.getModel_id(); | ||
| 39 | } | 44 | } |
| 45 | + | ||
| 40 | } | 46 | } |
| 1 | package com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.specs; | 1 | package com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.specs; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONArray; | 3 | import com.alibaba.fastjson.JSONArray; |
| 4 | +import com.alibaba.fastjson.annotation.JSONField; | ||
| 4 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; | 5 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; |
| 5 | import lombok.Data; | 6 | import lombok.Data; |
| 6 | 7 | ||
| @@ -16,10 +17,25 @@ public class ArrayModelOutput extends ThingsModelItemBase<JSONArray> | @@ -16,10 +17,25 @@ public class ArrayModelOutput extends ThingsModelItemBase<JSONArray> | ||
| 16 | 17 | ||
| 17 | @Override | 18 | @Override |
| 18 | public String getView() { | 19 | public String getView() { |
| 20 | + | ||
| 19 | if(null != getValue()) | 21 | if(null != getValue()) |
| 20 | { | 22 | { |
| 21 | return JSONArray.toJSONString(getValue()); | 23 | return JSONArray.toJSONString(getValue()); |
| 22 | } | 24 | } |
| 23 | - return ""; | 25 | + return null; |
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public String getSaveView() { | ||
| 30 | + if(null == getValue()) | ||
| 31 | + { | ||
| 32 | + return null; | ||
| 33 | + } | ||
| 34 | + return JSONArray.toJSONString(getValue()); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public Object getCmdView(Object object) { | ||
| 39 | + return object; | ||
| 24 | } | 40 | } |
| 25 | } | 41 | } |
| @@ -16,6 +16,10 @@ public class BoolModelOutput extends ThingsModelItemBase<Boolean> | @@ -16,6 +16,10 @@ public class BoolModelOutput extends ThingsModelItemBase<Boolean> | ||
| 16 | 16 | ||
| 17 | @Override | 17 | @Override |
| 18 | public String getView() { | 18 | public String getView() { |
| 19 | + if(null == getValue()) | ||
| 20 | + { | ||
| 21 | + return null; | ||
| 22 | + } | ||
| 19 | if(getValue()) | 23 | if(getValue()) |
| 20 | { | 24 | { |
| 21 | return trueText; | 25 | return trueText; |
| @@ -24,4 +28,18 @@ public class BoolModelOutput extends ThingsModelItemBase<Boolean> | @@ -24,4 +28,18 @@ public class BoolModelOutput extends ThingsModelItemBase<Boolean> | ||
| 24 | } | 28 | } |
| 25 | 29 | ||
| 26 | } | 30 | } |
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public String getSaveView() { | ||
| 34 | + if(null == getValue()) | ||
| 35 | + { | ||
| 36 | + return null; | ||
| 37 | + } | ||
| 38 | + return getValue().toString(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public Object getCmdView(Object object) { | ||
| 43 | + return object; | ||
| 44 | + } | ||
| 27 | } | 45 | } |
| @@ -20,6 +20,24 @@ public class DecimalModelOutput extends ThingsModelItemBase<BigDecimal> | @@ -20,6 +20,24 @@ public class DecimalModelOutput extends ThingsModelItemBase<BigDecimal> | ||
| 20 | 20 | ||
| 21 | @Override | 21 | @Override |
| 22 | public String getView() { | 22 | public String getView() { |
| 23 | - return getView()+unit; | 23 | + if(null == getValue()) |
| 24 | + { | ||
| 25 | + return null; | ||
| 26 | + } | ||
| 27 | + return getValue().doubleValue()+(null==unit?"":unit); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public String getSaveView() { | ||
| 32 | + if(null == getValue()) | ||
| 33 | + { | ||
| 34 | + return null; | ||
| 35 | + } | ||
| 36 | + return getValue().toString(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public Object getCmdView(Object object) { | ||
| 41 | + return object; | ||
| 24 | } | 42 | } |
| 25 | } | 43 | } |
| @@ -7,24 +7,46 @@ import lombok.Data; | @@ -7,24 +7,46 @@ import lombok.Data; | ||
| 7 | import java.util.List; | 7 | import java.util.List; |
| 8 | 8 | ||
| 9 | @Data | 9 | @Data |
| 10 | -public class EnumModelOutput extends ThingsModelItemBase<String> | 10 | +public class EnumModelOutput extends ThingsModelItemBase<Object> |
| 11 | { | 11 | { |
| 12 | private List<EnumItemOutput> enumList; | 12 | private List<EnumItemOutput> enumList; |
| 13 | 13 | ||
| 14 | @Override | 14 | @Override |
| 15 | - public void addValue(String object) { | 15 | + public void addValue(Object object) { |
| 16 | setValue(object); | 16 | setValue(object); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | @Override | 19 | @Override |
| 20 | public String getView() { | 20 | public String getView() { |
| 21 | + if(null == getValue()) | ||
| 22 | + { | ||
| 23 | + return null; | ||
| 24 | + } | ||
| 25 | + if(null == enumList || enumList.size()==0) | ||
| 26 | + { | ||
| 27 | + return null; | ||
| 28 | + } | ||
| 21 | for(EnumItemOutput enumItemOutput:enumList) | 29 | for(EnumItemOutput enumItemOutput:enumList) |
| 22 | { | 30 | { |
| 23 | - if(enumItemOutput.getValue().equals(getValue())) | 31 | + if(enumItemOutput.getValue().equals(getValue()+"")) |
| 24 | { | 32 | { |
| 25 | return enumItemOutput.getText(); | 33 | return enumItemOutput.getText(); |
| 26 | } | 34 | } |
| 27 | } | 35 | } |
| 28 | - return getValue(); | 36 | + return getValue()+""; |
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public String getSaveView() { | ||
| 41 | + if(null == getValue()) | ||
| 42 | + { | ||
| 43 | + return null; | ||
| 44 | + } | ||
| 45 | + return getValue()+""; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public Object getCmdView(Object object) { | ||
| 50 | + return object; | ||
| 29 | } | 51 | } |
| 30 | } | 52 | } |
| @@ -4,14 +4,17 @@ import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; | @@ -4,14 +4,17 @@ import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; | ||
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | import java.math.BigDecimal; | 6 | import java.math.BigDecimal; |
| 7 | +import java.math.RoundingMode; | ||
| 8 | + | ||
| 7 | 9 | ||
| 8 | @Data | 10 | @Data |
| 9 | public class IntegerModelOutput extends ThingsModelItemBase<Integer> | 11 | public class IntegerModelOutput extends ThingsModelItemBase<Integer> |
| 10 | { | 12 | { |
| 11 | - private BigDecimal min; | ||
| 12 | - private BigDecimal max; | ||
| 13 | - private BigDecimal step; | ||
| 14 | - private String unit; | 13 | + private BigDecimal min; //最大值 |
| 14 | + private BigDecimal max; //最小值 | ||
| 15 | + private BigDecimal step; //步长 | ||
| 16 | + private String unit; //单位 | ||
| 17 | + private Integer acy; //精度 | ||
| 15 | 18 | ||
| 16 | @Override | 19 | @Override |
| 17 | public void addValue(Integer object) { | 20 | public void addValue(Integer object) { |
| @@ -20,6 +23,30 @@ public class IntegerModelOutput extends ThingsModelItemBase<Integer> | @@ -20,6 +23,30 @@ public class IntegerModelOutput extends ThingsModelItemBase<Integer> | ||
| 20 | 23 | ||
| 21 | @Override | 24 | @Override |
| 22 | public String getView() { | 25 | public String getView() { |
| 23 | - return getView()+unit; | 26 | + if(null == getValue()) |
| 27 | + { | ||
| 28 | + return null; | ||
| 29 | + } | ||
| 30 | + return getSaveView()+(null==unit?"":unit); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public String getSaveView() { | ||
| 35 | + if(null == getValue()) | ||
| 36 | + { | ||
| 37 | + return null; | ||
| 38 | + } | ||
| 39 | + BigDecimal bigDecimal = new BigDecimal(getValue().toString()); | ||
| 40 | + return bigDecimal.divide(new BigDecimal(acy),acy.toString().length()-1, RoundingMode.HALF_UP).toString(); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + @Override | ||
| 44 | + public Object getCmdView(Object object) { | ||
| 45 | + if(null == object) | ||
| 46 | + { | ||
| 47 | + return null; | ||
| 48 | + } | ||
| 49 | + BigDecimal bigDecimal = new BigDecimal(object.toString()); | ||
| 50 | + return bigDecimal.multiply(new BigDecimal(acy)).intValue(); | ||
| 24 | } | 51 | } |
| 25 | } | 52 | } |
| @@ -13,11 +13,21 @@ public class StringModelOutput extends ThingsModelItemBase<Object> | @@ -13,11 +13,21 @@ public class StringModelOutput extends ThingsModelItemBase<Object> | ||
| 13 | 13 | ||
| 14 | @Override | 14 | @Override |
| 15 | public void addValue(Object object) { | 15 | public void addValue(Object object) { |
| 16 | - setValue(null!=getValue()?getValue()+"":null); | 16 | + setValue(null!=object?object+"":null); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | @Override | 19 | @Override |
| 20 | public String getView() { | 20 | public String getView() { |
| 21 | return null!=getValue()?getValue()+"":null; | 21 | return null!=getValue()?getValue()+"":null; |
| 22 | } | 22 | } |
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public String getSaveView() { | ||
| 26 | + return getView(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public Object getCmdView(Object object) { | ||
| 31 | + return object; | ||
| 32 | + } | ||
| 23 | } | 33 | } |
| @@ -4,6 +4,7 @@ import com.zhonglai.luhui.mqtt.comm.config.RedisConfig; | @@ -4,6 +4,7 @@ import com.zhonglai.luhui.mqtt.comm.config.RedisConfig; | ||
| 4 | import com.zhonglai.luhui.mqtt.comm.config.SysParameter; | 4 | import com.zhonglai.luhui.mqtt.comm.config.SysParameter; |
| 5 | import com.zhonglai.luhui.mqtt.comm.dto.MyException; | 5 | import com.zhonglai.luhui.mqtt.comm.dto.MyException; |
| 6 | import com.zhonglai.luhui.mqtt.comm.service.MqttCallback; | 6 | import com.zhonglai.luhui.mqtt.comm.service.MqttCallback; |
| 7 | +import com.zhonglai.luhui.mqtt.comm.util.StringUtils; | ||
| 7 | import lombok.Data; | 8 | import lombok.Data; |
| 8 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
| @@ -19,15 +20,40 @@ public class Topic { | @@ -19,15 +20,40 @@ public class Topic { | ||
| 19 | private String username; | 20 | private String username; |
| 20 | private String clientid; | 21 | private String clientid; |
| 21 | private String topicType; | 22 | private String topicType; |
| 22 | - private String redicKey; | ||
| 23 | private String messageid; | 23 | private String messageid; |
| 24 | private String payloadtype; | 24 | private String payloadtype; |
| 25 | + | ||
| 26 | + public Topic() { | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public Topic(String roleid, String username, String clientid, String topicType, String payloadtype) { | ||
| 30 | + this.roleid = roleid; | ||
| 31 | + this.username = username; | ||
| 32 | + this.clientid = clientid; | ||
| 33 | + this.topicType = topicType; | ||
| 34 | + this.payloadtype = payloadtype; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public Topic(String roleid, String username, String clientid, String topicType, String messageid, String payloadtype) { | ||
| 38 | + this.roleid = roleid; | ||
| 39 | + this.username = username; | ||
| 40 | + this.clientid = clientid; | ||
| 41 | + this.topicType = topicType; | ||
| 42 | + this.messageid = messageid; | ||
| 43 | + this.payloadtype = payloadtype; | ||
| 44 | + } | ||
| 45 | + | ||
| 25 | public Topic(String topic) | 46 | public Topic(String topic) |
| 26 | { | 47 | { |
| 27 | topic = Optional.ofNullable(topic).orElseThrow(()->new MyException("topic为空")); | 48 | topic = Optional.ofNullable(topic).orElseThrow(()->new MyException("topic为空")); |
| 28 | String[] sts = topic.split("/"); | 49 | String[] sts = topic.split("/"); |
| 29 | String[] config = SysParameter.topicconfig.split("/"); | 50 | String[] config = SysParameter.topicconfig.split("/"); |
| 30 | - for(int i=1;i<config.length;i++) | 51 | + int number = sts.length; |
| 52 | + if(number>config.length) | ||
| 53 | + { | ||
| 54 | + number = config.length; | ||
| 55 | + } | ||
| 56 | + for(int i=1;i<number;i++) | ||
| 31 | { | 57 | { |
| 32 | String cf = config[i].replace("{{","").replace("}}",""); | 58 | String cf = config[i].replace("{{","").replace("}}",""); |
| 33 | try { | 59 | try { |
| @@ -40,17 +66,72 @@ public class Topic { | @@ -40,17 +66,72 @@ public class Topic { | ||
| 40 | } | 66 | } |
| 41 | } | 67 | } |
| 42 | } | 68 | } |
| 43 | - public String getRedicKey() | 69 | + |
| 70 | + /** | ||
| 71 | + * 生成缓存关键字 | ||
| 72 | + * @return | ||
| 73 | + */ | ||
| 74 | + public String generateRedicKey() | ||
| 44 | { | 75 | { |
| 45 | - if(null == redicKey) | ||
| 46 | - { | ||
| 47 | - return generateRedicKey(); | ||
| 48 | - } | ||
| 49 | - return redicKey; | 76 | + return generate(":"); |
| 50 | } | 77 | } |
| 51 | - private String generateRedicKey() | 78 | + |
| 79 | + /** | ||
| 80 | + * 生成发送消息的topic | ||
| 81 | + * @return | ||
| 82 | + */ | ||
| 83 | + public String generateSendMessageTopic() | ||
| 52 | { | 84 | { |
| 53 | - return RedisConfig.FIELD+roleid+":"+username+":"+clientid; | 85 | + return "/"+generate("/"); |
| 54 | } | 86 | } |
| 55 | 87 | ||
| 88 | + /** | ||
| 89 | + * 生成客户端关键字 | ||
| 90 | + * @return | ||
| 91 | + */ | ||
| 92 | + public String generateClienKey() | ||
| 93 | + { | ||
| 94 | + return "/"+generate("/"); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + private String generate(String division) | ||
| 98 | + { | ||
| 99 | + String str = SysParameter.topicconfig; | ||
| 100 | + if(StringUtils.isEmpty(roleid)) | ||
| 101 | + { | ||
| 102 | + roleid = "2"; | ||
| 103 | + } | ||
| 104 | + str = str.replace("/{{roleid}}",roleid+division); | ||
| 105 | + | ||
| 106 | + if(StringUtils.isEmpty(username)) | ||
| 107 | + { | ||
| 108 | + username = "+"; | ||
| 109 | + } | ||
| 110 | + str = str.replace("/{{username}}",username+division); | ||
| 111 | + | ||
| 112 | + if(StringUtils.isEmpty(clientid)) | ||
| 113 | + { | ||
| 114 | + clientid = "+"; | ||
| 115 | + } | ||
| 116 | + str = str.replace("/{{clientid}}",clientid+division); | ||
| 117 | + | ||
| 118 | + if(StringUtils.isEmpty(payloadtype)) | ||
| 119 | + { | ||
| 120 | + payloadtype = "String"; | ||
| 121 | + } | ||
| 122 | + str = str.replace("/{{payloadtype}}",payloadtype+division); | ||
| 123 | + | ||
| 124 | + if(StringUtils.isEmpty(topicType)) | ||
| 125 | + { | ||
| 126 | + topicType = "PUT"; | ||
| 127 | + } | ||
| 128 | + str = str.replace("/{{topicType}}",topicType+division); | ||
| 129 | + | ||
| 130 | + if(StringUtils.isNotEmpty(messageid)) | ||
| 131 | + { | ||
| 132 | + str = str.replace("/{{messageid}}",messageid); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + return str; | ||
| 136 | + } | ||
| 56 | } | 137 | } |
| 1 | package com.zhonglai.luhui.mqtt.comm.service; | 1 | package com.zhonglai.luhui.mqtt.comm.service; |
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | +import com.ruoyi.system.domain.IotDevice; | ||
| 5 | +import com.ruoyi.system.domain.IotTerminal; | ||
| 6 | +import com.zhonglai.luhui.mqtt.comm.config.SysParameter; | ||
| 7 | +import com.zhonglai.luhui.mqtt.comm.dto.DeviceSensorData; | ||
| 4 | import com.zhonglai.luhui.mqtt.comm.dto.LogDeviceOperation; | 8 | import com.zhonglai.luhui.mqtt.comm.dto.LogDeviceOperation; |
| 5 | -import com.zhonglai.luhui.mqtt.comm.dto.iot.IotDevice; | ||
| 6 | -import com.zhonglai.luhui.mqtt.comm.dto.iot.IotTerminal; | ||
| 7 | import com.zhonglai.luhui.mqtt.comm.factory.Topic; | 9 | import com.zhonglai.luhui.mqtt.comm.factory.Topic; |
| 8 | import com.zhonglai.luhui.mqtt.comm.util.DateUtils; | 10 | import com.zhonglai.luhui.mqtt.comm.util.DateUtils; |
| 11 | +import com.zhonglai.luhui.mqtt.dto.SaveDataDto; | ||
| 9 | import com.zhonglai.luhui.mqtt.dto.topic.AddPostDto; | 12 | import com.zhonglai.luhui.mqtt.dto.topic.AddPostDto; |
| 10 | import com.zhonglai.luhui.mqtt.service.db.DeviceService; | 13 | import com.zhonglai.luhui.mqtt.service.db.DeviceService; |
| 14 | +import org.slf4j.Logger; | ||
| 15 | +import org.slf4j.LoggerFactory; | ||
| 16 | +import org.springframework.beans.BeanUtils; | ||
| 17 | +import org.springframework.beans.BeanWrapper; | ||
| 18 | +import org.springframework.beans.BeanWrapperImpl; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 20 | +import org.springframework.beans.factory.annotation.Value; | ||
| 12 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 13 | 22 | ||
| 14 | -import java.util.ArrayList; | ||
| 15 | -import java.util.List; | 23 | +import java.beans.PropertyDescriptor; |
| 24 | +import java.lang.reflect.Field; | ||
| 25 | +import java.util.*; | ||
| 16 | 26 | ||
| 17 | /** | 27 | /** |
| 18 | * 业务数据更新服务 | 28 | * 业务数据更新服务 |
| 19 | */ | 29 | */ |
| 20 | @Service | 30 | @Service |
| 21 | public class BusinessDataUpdateService { | 31 | public class BusinessDataUpdateService { |
| 32 | + private static final Logger logger = LoggerFactory.getLogger(BusinessDataUpdateService.class); | ||
| 33 | + | ||
| 22 | @Autowired | 34 | @Autowired |
| 23 | private DataModeAnalysisService dataModeAnalysisService ; | 35 | private DataModeAnalysisService dataModeAnalysisService ; |
| 24 | @Autowired | 36 | @Autowired |
| @@ -26,15 +38,24 @@ public class BusinessDataUpdateService { | @@ -26,15 +38,24 @@ public class BusinessDataUpdateService { | ||
| 26 | @Autowired | 38 | @Autowired |
| 27 | private DeviceService deviceService ; | 39 | private DeviceService deviceService ; |
| 28 | 40 | ||
| 41 | + @Value("${server.port}") | ||
| 42 | + private long port; | ||
| 43 | + | ||
| 44 | + @Value("${server.context-path}") | ||
| 45 | + private String contextPath; | ||
| 46 | + | ||
| 47 | + @Value("${sys.isText:false}") | ||
| 48 | + private Boolean isText; | ||
| 29 | /** | 49 | /** |
| 30 | * 更新数据 | 50 | * 更新数据 |
| 31 | * @param type | 51 | * @param type |
| 32 | * @param topic | 52 | * @param topic |
| 33 | * @param data | 53 | * @param data |
| 34 | */ | 54 | */ |
| 35 | - public void updataDta(Type type,Topic topic, JSONObject data) | 55 | + public void updataDta(Type type,Topic topic, JSONObject data,boolean isOperLog,List<LogDeviceOperation> operateHisList, List<DeviceSensorData> list) |
| 36 | { | 56 | { |
| 37 | - List<LogDeviceOperation> operateHisList = new ArrayList<>(); | 57 | + IotDevice olddevice = deviceService.getRedicDevice(topic.getClientid()); |
| 58 | + | ||
| 38 | for(String key:data.keySet()) | 59 | for(String key:data.keySet()) |
| 39 | { | 60 | { |
| 40 | Object o = data.get(key); | 61 | Object o = data.get(key); |
| @@ -43,59 +64,71 @@ public class BusinessDataUpdateService { | @@ -43,59 +64,71 @@ public class BusinessDataUpdateService { | ||
| 43 | JSONObject jsData = data.getJSONObject(key); | 64 | JSONObject jsData = data.getJSONObject(key); |
| 44 | if("0".equals(key)) //主机 | 65 | if("0".equals(key)) //主机 |
| 45 | { | 66 | { |
| 46 | - IotDevice iotDevice = translateDevice(type,topic,jsData,operateHisList); | 67 | + IotDevice iotDevice = translateDevice(type,olddevice,jsData,isOperLog,operateHisList,list); |
| 68 | + if(isText) | ||
| 69 | + { | ||
| 70 | + iotDevice.setListen_service_ip("127.0.0.1"+":"+port+contextPath); | ||
| 71 | + }else{ | ||
| 72 | + iotDevice.setListen_service_ip(SysParameter.service_ip+":"+port+contextPath); | ||
| 73 | + } | ||
| 74 | + logger.info("更新网关数据{}",iotDevice); | ||
| 75 | + if(null== iotDevice.getStatus() || 1 == iotDevice.getStatus() || 4==iotDevice.getStatus()) | ||
| 76 | + { | ||
| 77 | + iotDevice.setStatus(3); | ||
| 78 | + } | ||
| 79 | + iotDevice.setDevice_life(olddevice.getDevice_life()); | ||
| 80 | + iotDevice.setData_update_time(DateUtils.getNowTimeMilly()); | ||
| 81 | + iotDevice.setName(olddevice.getName()); | ||
| 47 | deviceService.updataDevice(iotDevice); | 82 | deviceService.updataDevice(iotDevice); |
| 48 | - | ||
| 49 | }else{ //终端 | 83 | }else{ //终端 |
| 50 | - IotTerminal iotTerminal = translateTerminal(type,key,topic,jsData,operateHisList); | ||
| 51 | - deviceService.updataTerminal(iotTerminal); | 84 | + IotTerminal iotTerminal = translateTerminal(type,key,olddevice,jsData,isOperLog,operateHisList,list); |
| 85 | + logger.info("更新终端数据{}",iotTerminal); | ||
| 86 | + iotTerminal.setData_update_time(DateUtils.getNowTimeMilly()); | ||
| 87 | + deviceService.updataTerminal(iotTerminal,olddevice.getDevice_life()); | ||
| 52 | } | 88 | } |
| 53 | } | 89 | } |
| 54 | } | 90 | } |
| 55 | - | ||
| 56 | - if(null != operateHisList && operateHisList.size() !=0 ) | ||
| 57 | - { | ||
| 58 | - deviceLogService.saveOperationLog(operateHisList); | ||
| 59 | - } | ||
| 60 | } | 91 | } |
| 61 | 92 | ||
| 62 | /** | 93 | /** |
| 63 | * 更新网关 | 94 | * 更新网关 |
| 64 | * @param type | 95 | * @param type |
| 65 | - * @param topic | 96 | + * @param olddevice |
| 66 | * @param jsData | 97 | * @param jsData |
| 67 | * @param operateHisList | 98 | * @param operateHisList |
| 68 | * @return | 99 | * @return |
| 69 | */ | 100 | */ |
| 70 | - private IotDevice translateDevice(Type type,Topic topic , JSONObject jsData, List<LogDeviceOperation> operateHisList) | 101 | + private IotDevice translateDevice(Type type, IotDevice olddevice , JSONObject jsData,boolean isOperLog, List<LogDeviceOperation> operateHisList, List<DeviceSensorData> list) |
| 71 | { | 102 | { |
| 72 | - IotDevice olddevice = deviceService.getRedicDevice(topic.getClientid()); | ||
| 73 | JSONObject summaryObjec = null; | 103 | JSONObject summaryObjec = null; |
| 74 | if(jsData.containsKey("summary") && null != jsData.get("summary") && jsData.get("summary") instanceof JSONObject) | 104 | if(jsData.containsKey("summary") && null != jsData.get("summary") && jsData.get("summary") instanceof JSONObject) |
| 75 | { | 105 | { |
| 76 | summaryObjec = jsData.getJSONObject("summary"); | 106 | summaryObjec = jsData.getJSONObject("summary"); |
| 77 | //记录summary内容变更日志 | 107 | //记录summary内容变更日志 |
| 78 | - operateHisList.add(deviceLogService.newLogDeviceOperation(topic.getClientid(),summaryObjec.toString(),olddevice.getSummary(),"主机本地summary状态更新",jsData.toJSONString())); | 108 | + operateHisList.add(deviceLogService.newLogDeviceOperation(olddevice.getClient_id(),summaryObjec.toString(),olddevice.getSummary(),"主机本地summary状态更新",jsData.toJSONString())); |
| 79 | jsData.remove("summary"); | 109 | jsData.remove("summary"); |
| 80 | } | 110 | } |
| 81 | IotDevice device = JSONObject.parseObject(JSONObject.toJSONString(jsData),IotDevice.class); | 111 | IotDevice device = JSONObject.parseObject(JSONObject.toJSONString(jsData),IotDevice.class); |
| 82 | - device.setClient_id(topic.getClientid()); | ||
| 83 | - device.setUpdate_time(DateUtils.getNowTimeMilly()); | 112 | + device = (IotDevice) mergerData(olddevice,device); |
| 84 | if(null != summaryObjec) | 113 | if(null != summaryObjec) |
| 85 | { | 114 | { |
| 86 | device.setSummary(summaryObjec.toString()); | 115 | device.setSummary(summaryObjec.toString()); |
| 87 | } | 116 | } |
| 88 | 117 | ||
| 89 | - JSONObject saveJson = dataModeAnalysisService.analysisThingsModelValue( topic.getClientid(),topic.getUsername(),jsData,true,"主机本地"); | 118 | + SaveDataDto saveDataDto = dataModeAnalysisService.analysisThingsModelValue( olddevice.getClient_id(),olddevice.getMqtt_username(),jsData,"主机本地",isOperLog,operateHisList,list); |
| 90 | //更新数据 | 119 | //更新数据 |
| 91 | - if(null != olddevice && "ADD".equals(type.name())) | 120 | + if(null != olddevice && ("ADD".equals(type.name())|| "READ".equals(type.name()))) |
| 92 | { | 121 | { |
| 93 | String str = olddevice.getThings_model_value(); | 122 | String str = olddevice.getThings_model_value(); |
| 94 | - String newStr = deviceService.getNewAdddate(str,saveJson).toJSONString(); | 123 | + String newStr = deviceService.getNewAdddate(str,saveDataDto.getData()).toJSONString(); |
| 95 | device.setThings_model_value(newStr); | 124 | device.setThings_model_value(newStr); |
| 96 | }else{ | 125 | }else{ |
| 97 | - device.setThings_model_value(saveJson.toJSONString()); | 126 | + device.setThings_model_value(saveDataDto.getData().toJSONString()); |
| 98 | } | 127 | } |
| 128 | + //配置只做增量 | ||
| 129 | + String str = (null!=olddevice?olddevice.getThings_model_config():null); | ||
| 130 | + String newStr = deviceService.getNewAdddate(str,saveDataDto.getConfig()).toJSONString(); | ||
| 131 | + device.setThings_model_config(newStr); | ||
| 99 | 132 | ||
| 100 | return device; | 133 | return device; |
| 101 | } | 134 | } |
| @@ -104,28 +137,46 @@ public class BusinessDataUpdateService { | @@ -104,28 +137,46 @@ public class BusinessDataUpdateService { | ||
| 104 | * 更新终端 | 137 | * 更新终端 |
| 105 | * @param type "ADD"增量更新,"ALL"全量更新 | 138 | * @param type "ADD"增量更新,"ALL"全量更新 |
| 106 | * @param key | 139 | * @param key |
| 107 | - * @param topic | 140 | + * @param olddevice |
| 108 | * @param jsData | 141 | * @param jsData |
| 109 | * @param operateHisList | 142 | * @param operateHisList |
| 110 | * @return | 143 | * @return |
| 111 | */ | 144 | */ |
| 112 | - private IotTerminal translateTerminal(Type type,String key, Topic topic , JSONObject jsData, List<LogDeviceOperation> operateHisList) | 145 | + private IotTerminal translateTerminal(Type type,String key, IotDevice olddevice , JSONObject jsData,boolean isOperLog, List<LogDeviceOperation> operateHisList, List<DeviceSensorData> list) |
| 113 | { | 146 | { |
| 114 | - String id = topic.getClientid()+"_"+key; | ||
| 115 | - JSONObject saveJson = dataModeAnalysisService.analysisThingsModelValue( id,topic.getUsername(),jsData,true,"终端本地"); | 147 | + String id = olddevice.getClient_id()+"_"+key; |
| 148 | + SaveDataDto saveDataDto = dataModeAnalysisService.analysisThingsModelValue( id,olddevice.getMqtt_username(),jsData,"终端本地",isOperLog,operateHisList,list); | ||
| 116 | IotTerminal terminal = new IotTerminal(); | 149 | IotTerminal terminal = new IotTerminal(); |
| 117 | terminal.setId(id); | 150 | terminal.setId(id); |
| 118 | - terminal.setUpdate_time(DateUtils.getNowTimeMilly()); | ||
| 119 | - | 151 | + terminal.setDevice_id(olddevice.getClient_id()); |
| 152 | + terminal.setProduct_id(olddevice.getProduct_id()); | ||
| 153 | + terminal.setMqtt_username(olddevice.getMqtt_username()); | ||
| 120 | //更新数据 | 154 | //更新数据 |
| 121 | IotTerminal oldterminal = deviceService.getRedicTerminal(id); | 155 | IotTerminal oldterminal = deviceService.getRedicTerminal(id); |
| 122 | - if(null != oldterminal && "ADD".equals(type.name())) | 156 | + if(null == oldterminal) |
| 157 | + { | ||
| 158 | + oldterminal = new IotTerminal(); | ||
| 159 | + oldterminal.setDevice_id(olddevice.getClient_id()); | ||
| 160 | + oldterminal.setId(id); | ||
| 161 | + oldterminal.setMqtt_username(olddevice.getMqtt_username()); | ||
| 162 | + oldterminal.setName(olddevice.getMqtt_username()+"终端"+key); | ||
| 163 | + oldterminal.setProduct_id(olddevice.getProduct_id()); | ||
| 164 | + deviceService.updataTerminal(oldterminal,olddevice.getDevice_life()); | ||
| 165 | + } | ||
| 166 | + if(null != oldterminal && ("ADD".equals(type.name())|| "READ".equals(type.name()))) | ||
| 123 | { | 167 | { |
| 124 | String str = oldterminal.getThings_model_value(); | 168 | String str = oldterminal.getThings_model_value(); |
| 125 | - terminal.setThings_model_value(deviceService.getNewAdddate(str,saveJson).toJSONString()); | 169 | + terminal.setThings_model_value(deviceService.getNewAdddate(str,saveDataDto.getData()).toJSONString()); |
| 126 | }else{ | 170 | }else{ |
| 127 | - terminal.setThings_model_value(saveJson.toJSONString()); | 171 | + terminal.setThings_model_value(saveDataDto.getData().toJSONString()); |
| 172 | + } | ||
| 173 | + if(key.startsWith("1_") && null != saveDataDto.getConfig()) | ||
| 174 | + { | ||
| 175 | + System.out.println(saveDataDto); | ||
| 128 | } | 176 | } |
| 177 | + String str = (null!=oldterminal?oldterminal.getThings_model_config():null); | ||
| 178 | + terminal.setThings_model_config(deviceService.getNewAdddate(str,saveDataDto.getConfig()).toJSONString()); | ||
| 179 | + terminal.setName(oldterminal.getName()); | ||
| 129 | return terminal; | 180 | return terminal; |
| 130 | } | 181 | } |
| 131 | 182 | ||
| @@ -133,4 +184,54 @@ public class BusinessDataUpdateService { | @@ -133,4 +184,54 @@ public class BusinessDataUpdateService { | ||
| 133 | { | 184 | { |
| 134 | ADD,ALL | 185 | ADD,ALL |
| 135 | } | 186 | } |
| 187 | + | ||
| 188 | + public static void main(String[] args) { | ||
| 189 | + IotDevice sourceBean = new IotDevice(); | ||
| 190 | + sourceBean.setName("sss"); | ||
| 191 | + sourceBean.setUpdate_time(21313); | ||
| 192 | + IotDevice targetBean = new IotDevice(); | ||
| 193 | + targetBean.setClient_id("21321"); | ||
| 194 | + targetBean.setName("bbb"); | ||
| 195 | + Object newO = mergerData(sourceBean,targetBean); | ||
| 196 | + System.out.println(JSONObject.toJSONString(newO)); | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + private static Object mergerData(Object sourceBean, Object targetBean) | ||
| 200 | + { | ||
| 201 | + if(null == sourceBean) | ||
| 202 | + { | ||
| 203 | + return targetBean; | ||
| 204 | + } | ||
| 205 | + if(null == targetBean) | ||
| 206 | + { | ||
| 207 | + return sourceBean; | ||
| 208 | + } | ||
| 209 | + Object newtargetBean = BeanUtils.instantiateClass(targetBean.getClass()); | ||
| 210 | + BeanUtils.copyProperties(targetBean,newtargetBean); | ||
| 211 | + BeanUtils.copyProperties(sourceBean,newtargetBean,getNotNullField(newtargetBean)); | ||
| 212 | + return newtargetBean; | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + * 获取属性中为空的字段 | ||
| 217 | + * | ||
| 218 | + * @param target | ||
| 219 | + * @return | ||
| 220 | + */ | ||
| 221 | + private static String[] getNotNullField(Object target) { | ||
| 222 | + BeanWrapper beanWrapper = new BeanWrapperImpl(target); | ||
| 223 | + PropertyDescriptor[] propertyDescriptors = beanWrapper.getPropertyDescriptors(); | ||
| 224 | + Set<String> notNullFieldSet = new HashSet<>(); | ||
| 225 | + if (propertyDescriptors.length > 0) { | ||
| 226 | + for (PropertyDescriptor p : propertyDescriptors) { | ||
| 227 | + String name = p.getName(); | ||
| 228 | + Object value = beanWrapper.getPropertyValue(name); | ||
| 229 | + if (Objects.nonNull(value)) { | ||
| 230 | + notNullFieldSet.add(name); | ||
| 231 | + } | ||
| 232 | + } | ||
| 233 | + } | ||
| 234 | + String[] notNullField = new String[notNullFieldSet.size()]; | ||
| 235 | + return notNullFieldSet.toArray(notNullField); | ||
| 236 | + } | ||
| 136 | } | 237 | } |
| 1 | package com.zhonglai.luhui.mqtt.comm.service; | 1 | package com.zhonglai.luhui.mqtt.comm.service; |
| 2 | 2 | ||
| 3 | +import com.mysql.cj.x.protobuf.MysqlxDatatypes; | ||
| 3 | import com.zhonglai.luhui.mqtt.comm.clien.ClienConnection; | 4 | import com.zhonglai.luhui.mqtt.comm.clien.ClienConnection; |
| 4 | import com.zhonglai.luhui.mqtt.comm.clien.impl.ClienConnectionImpl; | 5 | import com.zhonglai.luhui.mqtt.comm.clien.impl.ClienConnectionImpl; |
| 5 | import com.zhonglai.luhui.mqtt.comm.dto.ServerDto; | 6 | import com.zhonglai.luhui.mqtt.comm.dto.ServerDto; |
| @@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Value; | @@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Value; | ||
| 18 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 19 | 20 | ||
| 20 | import javax.annotation.PostConstruct; | 21 | import javax.annotation.PostConstruct; |
| 22 | +import java.util.Map; | ||
| 21 | import java.util.concurrent.TimeUnit; | 23 | import java.util.concurrent.TimeUnit; |
| 22 | 24 | ||
| 23 | /** | 25 | /** |
| @@ -30,14 +32,14 @@ public class ClienNoticeService { | @@ -30,14 +32,14 @@ public class ClienNoticeService { | ||
| 30 | @Autowired | 32 | @Autowired |
| 31 | private TerminalService terminalService; | 33 | private TerminalService terminalService; |
| 32 | 34 | ||
| 33 | - @Autowired | ||
| 34 | - private TopicsService topicsService; | ||
| 35 | - | ||
| 36 | private ExpiringMap<String, ClienConnection> clienConnectionMap; | 35 | private ExpiringMap<String, ClienConnection> clienConnectionMap; |
| 37 | 36 | ||
| 38 | @Value("${mqtt.client.operationTime}") | 37 | @Value("${mqtt.client.operationTime}") |
| 39 | private long operationTime; //客户端操作时间 | 38 | private long operationTime; //客户端操作时间 |
| 40 | 39 | ||
| 40 | + @Value("#{${mqtt.top_return_map}}") | ||
| 41 | + private Map<String,String> top_return_map; //topic返回的对应关系 | ||
| 42 | + | ||
| 41 | @PostConstruct | 43 | @PostConstruct |
| 42 | public void init() | 44 | public void init() |
| 43 | { | 45 | { |
| @@ -48,46 +50,45 @@ public class ClienNoticeService { | @@ -48,46 +50,45 @@ public class ClienNoticeService { | ||
| 48 | // CREATED: 只在put和replace方法清零过期时间 | 50 | // CREATED: 只在put和replace方法清零过期时间 |
| 49 | // ACCESSED: 在CREATED策略基础上增加, 在还没过期时get方法清零过期时间。 | 51 | // ACCESSED: 在CREATED策略基础上增加, 在还没过期时get方法清零过期时间。 |
| 50 | // 清零过期时间也就是重置过期时间,重新计算过期时间. | 52 | // 清零过期时间也就是重置过期时间,重新计算过期时间. |
| 51 | - clienConnectionMap = ExpiringMap.builder().maxSize(2000).expiration(operationTime, TimeUnit.SECONDS) | 53 | + clienConnectionMap = ExpiringMap.builder().maxSize(20000).expiration(operationTime, TimeUnit.SECONDS) |
| 52 | .asyncExpirationListener((ExpirationListener<String, ClienConnection>) (s, clienConnection) -> clienConnection.close()) | 54 | .asyncExpirationListener((ExpirationListener<String, ClienConnection>) (s, clienConnection) -> clienConnection.close()) |
| 53 | .expirationPolicy(ExpirationPolicy.CREATED).build(); | 55 | .expirationPolicy(ExpirationPolicy.CREATED).build(); |
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | - public Message sendMessage(String imei, MqttMessage mqttMessage, String messageid) throws MqttException, InterruptedException { | 58 | + public Message sendMessage(Topic topic, MqttMessage mqttMessage) throws MqttException, InterruptedException { |
| 57 | //设置通知渠道 | 59 | //设置通知渠道 |
| 58 | ClienConnection clienConnection = new ClienConnectionImpl(); | 60 | ClienConnection clienConnection = new ClienConnectionImpl(); |
| 59 | - clienConnectionMap.put(topicsService.getClienConnectionMapKey(imei,messageid),clienConnection); | 61 | + log.info("{} {} {} {}",topic.generateClienKey(),topic.getTopicType(),top_return_map,clienConnection); |
| 62 | + clienConnectionMap.put(topic.generateClienKey().replace(topic.getTopicType(),top_return_map.get(topic.getTopicType())),clienConnection); | ||
| 60 | 63 | ||
| 61 | - sendMessage(imei,messageid,mqttMessage); | 64 | + sendMessage(topic.generateSendMessageTopic(),mqttMessage); |
| 62 | synchronized(clienConnection) | 65 | synchronized(clienConnection) |
| 63 | { | 66 | { |
| 64 | - log.info("{}等待通知",imei); | 67 | + log.info("{}等待通知",topic.getClientid()); |
| 65 | clienConnection.wait(operationTime*1000+3000l); | 68 | clienConnection.wait(operationTime*1000+3000l); |
| 66 | } | 69 | } |
| 67 | - log.info("{}收到通知{}",imei,clienConnection.getReplyMessage().getMessage()); | 70 | + log.info("{}收到通知{}",topic.getClientid(),clienConnection.getReplyMessage().getMessage()); |
| 68 | Message message = clienConnection.getReplyMessage(); | 71 | Message message = clienConnection.getReplyMessage(); |
| 69 | - log.info("{}返回通知{}",imei,message); | 72 | + log.info("{}返回通知{}",topic.getClientid(),message); |
| 70 | 73 | ||
| 71 | return message; | 74 | return message; |
| 72 | } | 75 | } |
| 73 | 76 | ||
| 74 | /** | 77 | /** |
| 75 | * 发送消息 | 78 | * 发送消息 |
| 76 | - * @param imei | ||
| 77 | * @param mqttMessage | 79 | * @param mqttMessage |
| 78 | * @throws MqttException | 80 | * @throws MqttException |
| 79 | * @throws InterruptedException | 81 | * @throws InterruptedException |
| 80 | */ | 82 | */ |
| 81 | - public void sendMessage(String imei,String messageid, MqttMessage mqttMessage) throws MqttException, InterruptedException { | 83 | + public void sendMessage(String topic,MqttMessage mqttMessage) throws MqttException, InterruptedException { |
| 82 | //发生指令,等待通知 | 84 | //发生指令,等待通知 |
| 83 | - String topic = topicsService.getTopicFromImei(imei,messageid); | ||
| 84 | - System.out.println("发送的消息内容"+ ByteUtil.hexStringToSpace(ByteUtil.toHexString(mqttMessage.getPayload()).toUpperCase())); | 85 | + System.out.println(topic+"发送的消息内容"+ ByteUtil.hexStringToSpace(ByteUtil.toHexString(mqttMessage.getPayload()).toUpperCase())+" 转化为字符串:"+new String(mqttMessage.getPayload())); |
| 85 | terminalService.publish(topic,mqttMessage); | 86 | terminalService.publish(topic,mqttMessage); |
| 86 | } | 87 | } |
| 87 | 88 | ||
| 88 | - public ClienConnection getClienConnection(String imei, String messageid) | 89 | + public ClienConnection getClienConnection(Topic topic) |
| 89 | { | 90 | { |
| 90 | - return clienConnectionMap.get(topicsService.getClienConnectionMapKey(imei,messageid)); | 91 | + return clienConnectionMap.get(topic.generateClienKey()); |
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | public void replySendMessage(Topic topic, ServerDto dto) | 94 | public void replySendMessage(Topic topic, ServerDto dto) |
| @@ -96,7 +97,7 @@ public class ClienNoticeService { | @@ -96,7 +97,7 @@ public class ClienNoticeService { | ||
| 96 | //判断有没有需要回复的客户端,如果有就回复 | 97 | //判断有没有需要回复的客户端,如果有就回复 |
| 97 | if(dto.isReplyMessage()) | 98 | if(dto.isReplyMessage()) |
| 98 | { | 99 | { |
| 99 | - ClienConnection clienConnection = getClienConnection(topic.getClientid(),dto.getServerAgreementContent().getClienConnectionId()); | 100 | + ClienConnection clienConnection = getClienConnection(topic); |
| 100 | if(null != clienConnection) | 101 | if(null != clienConnection) |
| 101 | { | 102 | { |
| 102 | synchronized(clienConnection) | 103 | synchronized(clienConnection) |
| @@ -2,23 +2,24 @@ package com.zhonglai.luhui.mqtt.comm.service; | @@ -2,23 +2,24 @@ package com.zhonglai.luhui.mqtt.comm.service; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | -import com.zhonglai.luhui.mqtt.comm.config.RedisConfig; | 5 | +import com.ruoyi.system.domain.IotThingsModel; |
| 6 | import com.zhonglai.luhui.mqtt.comm.dao.BaseDao; | 6 | import com.zhonglai.luhui.mqtt.comm.dao.BaseDao; |
| 7 | import com.zhonglai.luhui.mqtt.comm.dto.DeviceSensorData; | 7 | import com.zhonglai.luhui.mqtt.comm.dto.DeviceSensorData; |
| 8 | import com.zhonglai.luhui.mqtt.comm.dto.LogDeviceOperation; | 8 | import com.zhonglai.luhui.mqtt.comm.dto.LogDeviceOperation; |
| 9 | -import com.zhonglai.luhui.mqtt.comm.dto.iot.IotThingsModel; | ||
| 10 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelBase; | 9 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelBase; |
| 11 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelDataTypeEnum; | 10 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelDataTypeEnum; |
| 12 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; | 11 | import com.zhonglai.luhui.mqtt.comm.dto.thingsmodels.ThingsModelItemBase; |
| 13 | import com.zhonglai.luhui.mqtt.comm.util.DateUtils; | 12 | import com.zhonglai.luhui.mqtt.comm.util.DateUtils; |
| 13 | +import com.zhonglai.luhui.mqtt.comm.util.StringUtils; | ||
| 14 | +import com.zhonglai.luhui.mqtt.dto.SaveDataDto; | ||
| 15 | +import com.zhonglai.luhui.mqtt.service.db.mode.TerminalDataThingsModeService; | ||
| 16 | +import org.apache.commons.lang3.EnumUtils; | ||
| 14 | import org.slf4j.Logger; | 17 | import org.slf4j.Logger; |
| 15 | import org.slf4j.LoggerFactory; | 18 | import org.slf4j.LoggerFactory; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 18 | 21 | ||
| 19 | -import java.util.ArrayList; | ||
| 20 | import java.util.List; | 22 | import java.util.List; |
| 21 | -import java.util.Map; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * 数据模型解析服务 | 25 | * 数据模型解析服务 |
| @@ -28,52 +29,48 @@ public class DataModeAnalysisService { | @@ -28,52 +29,48 @@ public class DataModeAnalysisService { | ||
| 28 | private static final Logger log = LoggerFactory.getLogger(DataModeAnalysisService.class); | 29 | private static final Logger log = LoggerFactory.getLogger(DataModeAnalysisService.class); |
| 29 | 30 | ||
| 30 | private BaseDao baseDao = new BaseDao(); | 31 | private BaseDao baseDao = new BaseDao(); |
| 31 | - @Autowired | ||
| 32 | - private RedisService redisService ; | ||
| 33 | 32 | ||
| 34 | @Autowired | 33 | @Autowired |
| 35 | private DeviceLogService dviceLogService; | 34 | private DeviceLogService dviceLogService; |
| 36 | 35 | ||
| 36 | + @Autowired | ||
| 37 | + private TerminalDataThingsModeService terminalDataThingsModeService; | ||
| 38 | + | ||
| 37 | /** | 39 | /** |
| 38 | * 初始化物模型数据 | 40 | * 初始化物模型数据 |
| 39 | */ | 41 | */ |
| 40 | - public void initDataThingsMode() | 42 | + public void initDataThingsMode(String roleIds,String usernames) |
| 41 | { | 43 | { |
| 42 | - List<IotThingsModel> list = baseDao.findBysql("select * from `mqtt_broker`.`iot_things_model` where del_flag=0", IotThingsModel.class); | 44 | + String sql = "SELECT a.*,b.mqtt_username mqtt_username FROM `mqtt_broker`.`iot_things_model` a LEFT JOIN `mqtt_broker`.`iot_product` b ON a.`product_id`=b.`id` WHERE a.del_flag=0 "; |
| 45 | + if(StringUtils.isNotEmpty(roleIds)) | ||
| 46 | + { | ||
| 47 | + sql += " AND b.`role_id` IN("+roleIds+")"; | ||
| 48 | + } | ||
| 43 | 49 | ||
| 44 | - if(null != list && list.size() != 0) | 50 | + if(StringUtils.isNotEmpty(usernames)) |
| 45 | { | 51 | { |
| 46 | - for(IotThingsModel thingsModel:list) | ||
| 47 | - { | ||
| 48 | - redisService.hset(RedisConfig.FIELD+RedisConfig.THINGS_MODEL+thingsModel.getUser_name(),thingsModel.getIdentifier(),thingsModel); | ||
| 49 | - } | 52 | + sql += " AND b.`username` IN("+usernames+")"; |
| 50 | } | 53 | } |
| 54 | + List<IotThingsModel> list = baseDao.findBysql(sql, IotThingsModel.class); | ||
| 55 | + terminalDataThingsModeService.saveIotThingsModelToUser(list); | ||
| 51 | } | 56 | } |
| 52 | - public JSONObject analysisThingsModelValue(String id, String userName , JSONObject jsData) | ||
| 53 | - { | ||
| 54 | - return analysisThingsModelValue(id,userName,jsData,false,null); | ||
| 55 | - } | 57 | + |
| 56 | /** | 58 | /** |
| 57 | * 解析物模型数据 | 59 | * 解析物模型数据 |
| 58 | */ | 60 | */ |
| 59 | - public JSONObject analysisThingsModelValue(String id,String userName ,JSONObject jsData,boolean isSaveLog,String controlModel) | 61 | + public SaveDataDto analysisThingsModelValue(String id,String userName ,JSONObject jsData,String controlModel,boolean isOperLog, List<LogDeviceOperation> operateHisList, List<DeviceSensorData> list) |
| 60 | { | 62 | { |
| 61 | if(null != jsData && jsData.size() != 0 ) | 63 | if(null != jsData && jsData.size() != 0 ) |
| 62 | { | 64 | { |
| 63 | - Map<Object, Object> thingsModelMap = redisService.hmget(RedisConfig.FIELD+RedisConfig.THINGS_MODEL+userName); | ||
| 64 | - JSONObject rObjec = new JSONObject(); | 65 | + JSONObject data = new JSONObject(); |
| 65 | 66 | ||
| 66 | - List<DeviceSensorData> list = new ArrayList<>(); | ||
| 67 | - List<LogDeviceOperation> oplist = new ArrayList<>(); | 67 | + JSONObject config = new JSONObject(); |
| 68 | 68 | ||
| 69 | for(String key:jsData.keySet()) | 69 | for(String key:jsData.keySet()) |
| 70 | { | 70 | { |
| 71 | - Object object = thingsModelMap.get(key); | ||
| 72 | - IotThingsModel thingsModel = null; | ||
| 73 | - if(object instanceof IotThingsModel) | 71 | + IotThingsModel thingsModel = terminalDataThingsModeService.getIotThingsModel(userName,key); |
| 72 | + if(null == thingsModel) //没有配置的 都按字符串处理 | ||
| 74 | { | 73 | { |
| 75 | - thingsModel = (IotThingsModel)object; | ||
| 76 | - }else{ //没有配置的 都按字符串处理 | ||
| 77 | thingsModel = new IotThingsModel(); | 74 | thingsModel = new IotThingsModel(); |
| 78 | thingsModel.setData_type(ThingsModelDataTypeEnum.STRING.name()); | 75 | thingsModel.setData_type(ThingsModelDataTypeEnum.STRING.name()); |
| 79 | thingsModel.setIdentifier(key); | 76 | thingsModel.setIdentifier(key); |
| @@ -81,22 +78,29 @@ public class DataModeAnalysisService { | @@ -81,22 +78,29 @@ public class DataModeAnalysisService { | ||
| 81 | thingsModel.setIs_top(0); | 78 | thingsModel.setIs_top(0); |
| 82 | thingsModel.setIs_monitor(0); | 79 | thingsModel.setIs_monitor(0); |
| 83 | thingsModel.setIs_save_log(0); | 80 | thingsModel.setIs_save_log(0); |
| 81 | + thingsModel.setIs_config(0); | ||
| 84 | JSONObject jsonObject = new JSONObject(); | 82 | JSONObject jsonObject = new JSONObject(); |
| 85 | jsonObject.put("maxLength",255); | 83 | jsonObject.put("maxLength",255); |
| 86 | thingsModel.setSpecs(jsonObject.toString()); | 84 | thingsModel.setSpecs(jsonObject.toString()); |
| 87 | } | 85 | } |
| 88 | - Class<ThingsModelBase> aClass = Enum.valueOf(ThingsModelDataTypeEnum.class,thingsModel.getData_type()).getaClass(); | 86 | + String data_type = thingsModel.getData_type().toUpperCase(); |
| 87 | + if(!EnumUtils.isValidEnum(ThingsModelDataTypeEnum.class,data_type)) | ||
| 88 | + { | ||
| 89 | + data_type = ThingsModelDataTypeEnum.STRING.name(); | ||
| 90 | + } | ||
| 91 | + Class<ThingsModelBase> aClass = Enum.valueOf(ThingsModelDataTypeEnum.class,data_type).getaClass(); | ||
| 89 | ThingsModelBase thingsModelBase = JSON.parseObject(thingsModel.getSpecs(),aClass); | 92 | ThingsModelBase thingsModelBase = JSON.parseObject(thingsModel.getSpecs(),aClass); |
| 90 | thingsModelBase.conversionThingsModel(thingsModel); | 93 | thingsModelBase.conversionThingsModel(thingsModel); |
| 94 | + | ||
| 91 | thingsModelBase.addValue(jsData.get(key)); | 95 | thingsModelBase.addValue(jsData.get(key)); |
| 92 | 96 | ||
| 93 | ThingsModelItemBase thingsModelItemBase = (ThingsModelItemBase) thingsModelBase; | 97 | ThingsModelItemBase thingsModelItemBase = (ThingsModelItemBase) thingsModelBase; |
| 94 | //记录数据日志 | 98 | //记录数据日志 |
| 95 | - if(1==thingsModelItemBase.getIs_save_log()) | 99 | + if(1==thingsModelItemBase.getIs_save_log() && null != list) |
| 96 | { | 100 | { |
| 97 | DeviceSensorData sensorData = new DeviceSensorData(); | 101 | DeviceSensorData sensorData = new DeviceSensorData(); |
| 98 | sensorData.setDataType(key); | 102 | sensorData.setDataType(key); |
| 99 | - sensorData.setDataValue(jsData.getString(key)); | 103 | + sensorData.setDataValue(thingsModelBase.getSaveView()); |
| 100 | sensorData.setCreatTime(DateUtils.getNowTimeMilly()); | 104 | sensorData.setCreatTime(DateUtils.getNowTimeMilly()); |
| 101 | sensorData.setDeviceModel(userName); | 105 | sensorData.setDeviceModel(userName); |
| 102 | sensorData.setDeviceInfoId(id); | 106 | sensorData.setDeviceInfoId(id); |
| @@ -104,15 +108,30 @@ public class DataModeAnalysisService { | @@ -104,15 +108,30 @@ public class DataModeAnalysisService { | ||
| 104 | } | 108 | } |
| 105 | 109 | ||
| 106 | //记录操作日志 | 110 | //记录操作日志 |
| 107 | - oplist.add(dviceLogService.newLogDeviceOperation(id,jsData.getString(key),null,controlModel+thingsModelItemBase.getName()+"为"+thingsModelBase.getView(),jsData.toString())); | 111 | + if(isOperLog && null != operateHisList) |
| 112 | + { | ||
| 113 | + operateHisList.add(dviceLogService.newLogDeviceOperation(id,thingsModelBase.getSaveView(),null,controlModel+thingsModelItemBase.getName()+"为"+thingsModelBase.getView(),jsData.toString())); | ||
| 114 | + } | ||
| 108 | 115 | ||
| 109 | - rObjec.put(key,JSONObject.toJSONString(thingsModelBase)); | ||
| 110 | - } | ||
| 111 | 116 | ||
| 112 | - //日志入库 | ||
| 113 | - dviceLogService.saveDeviceSensorDataLog(list); | ||
| 114 | - dviceLogService.saveOperationLog(oplist); | ||
| 115 | - return rObjec; | 117 | + if(null != thingsModel && null != thingsModel.getType() && 2==thingsModel.getType()) |
| 118 | + { | ||
| 119 | + config.put(key,thingsModelBase); | ||
| 120 | + data.put(key,thingsModelBase); | ||
| 121 | + }else | ||
| 122 | + { | ||
| 123 | + if(null != thingsModel && null !=thingsModel.getIs_config() && 1==thingsModel.getIs_config()) | ||
| 124 | + { | ||
| 125 | + config.put(key,thingsModelBase); | ||
| 126 | + }else{ | ||
| 127 | + data.put(key,thingsModelBase); | ||
| 128 | + } | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + SaveDataDto saveDataDto = new SaveDataDto(); | ||
| 132 | + saveDataDto.setConfig(config); | ||
| 133 | + saveDataDto.setData(data); | ||
| 134 | + return saveDataDto; | ||
| 116 | } | 135 | } |
| 117 | return null; | 136 | return null; |
| 118 | } | 137 | } |
| @@ -17,7 +17,6 @@ public abstract class DataPersistenceService { | @@ -17,7 +17,6 @@ public abstract class DataPersistenceService { | ||
| 17 | protected BaseDao baseDao = new BaseDao(); | 17 | protected BaseDao baseDao = new BaseDao(); |
| 18 | 18 | ||
| 19 | public abstract void persistence(Topic topic, ServerDto serverDto); | 19 | public abstract void persistence(Topic topic, ServerDto serverDto); |
| 20 | - public abstract void addDeviceSensorData(Topic topic, ServerDto serverDto); | ||
| 21 | 20 | ||
| 22 | /** | 21 | /** |
| 23 | * 记录操作日志 | 22 | * 记录操作日志 |
-
请 注册 或 登录 后发表评论