正在显示
20 个修改的文件
包含
663 行增加
和
52 行删除
| @@ -11,6 +11,7 @@ import org.springframework.context.annotation.ComponentScan; | @@ -11,6 +11,7 @@ import org.springframework.context.annotation.ComponentScan; | ||
| 11 | "com.ruoyi.framework", | 11 | "com.ruoyi.framework", |
| 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.service", | ||
| 14 | "com.zhonglai.luhui.admin.controller", | 15 | "com.zhonglai.luhui.admin.controller", |
| 15 | "com.zhonglai.luhui.mqtt.comm.service.redis", | 16 | "com.zhonglai.luhui.mqtt.comm.service.redis", |
| 16 | "com.zhonglai.luhui.mqtt.service.db.mode" | 17 | "com.zhonglai.luhui.mqtt.service.db.mode" |
| @@ -177,27 +177,8 @@ public class IotDeviceControlController { | @@ -177,27 +177,8 @@ public class IotDeviceControlController { | ||
| 177 | @ResponseBody | 177 | @ResponseBody |
| 178 | @PostMapping("/delIotTerminal/{imei}/{number}") | 178 | @PostMapping("/delIotTerminal/{imei}/{number}") |
| 179 | public String delIotTerminal(HttpServletResponse response,@PathVariable String imei,@PathVariable String number) { | 179 | public String delIotTerminal(HttpServletResponse response,@PathVariable String imei,@PathVariable String number) { |
| 180 | - IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 181 | - iIotTerminalService.deleteIotTerminalById(imei+"_"+number); | ||
| 182 | response.setCharacterEncoding("UTF-8"); | 180 | response.setCharacterEncoding("UTF-8"); |
| 183 | - if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 184 | - { | ||
| 185 | - return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 186 | - } | ||
| 187 | - String url = "http://"+iotDevice.getListen_service_ip()+"device/delIotTerminal/"+imei+"/"+number; | ||
| 188 | - | ||
| 189 | - String str = null; | ||
| 190 | - try { | ||
| 191 | - str = HttpUtils.getResponseString(HttpUtils.postFromBody(url, builder -> { | ||
| 192 | - }, formBody -> { | ||
| 193 | - })); | ||
| 194 | - } catch (IOException e) { | ||
| 195 | - } | ||
| 196 | - if(null != str) | ||
| 197 | - { | ||
| 198 | - return str; | ||
| 199 | - } | ||
| 200 | - return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | 181 | + return iIotTerminalService.deleteIotTerminalById(imei,number); |
| 201 | } | 182 | } |
| 202 | 183 | ||
| 203 | @ApiOperation(value = "读取属性") | 184 | @ApiOperation(value = "读取属性") |
| @@ -323,5 +304,4 @@ public class IotDeviceControlController { | @@ -323,5 +304,4 @@ public class IotDeviceControlController { | ||
| 323 | return response1.body().string(); | 304 | return response1.body().string(); |
| 324 | } | 305 | } |
| 325 | 306 | ||
| 326 | - | ||
| 327 | } | 307 | } |
| @@ -44,7 +44,7 @@ public class SysProfileController extends BaseController | @@ -44,7 +44,7 @@ public class SysProfileController extends BaseController | ||
| 44 | @GetMapping | 44 | @GetMapping |
| 45 | public AjaxResult profile() | 45 | public AjaxResult profile() |
| 46 | { | 46 | { |
| 47 | - SysLoginUser loginUser = getLoginUser(); | 47 | + SysLoginUser loginUser = (SysLoginUser) getLoginUser(); |
| 48 | SysUser user = loginUser.getUser(); | 48 | SysUser user = loginUser.getUser(); |
| 49 | AjaxResult ajax = AjaxResult.success(user); | 49 | AjaxResult ajax = AjaxResult.success(user); |
| 50 | ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); | 50 | ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); |
| @@ -60,7 +60,7 @@ public class SysProfileController extends BaseController | @@ -60,7 +60,7 @@ public class SysProfileController extends BaseController | ||
| 60 | @PutMapping | 60 | @PutMapping |
| 61 | public AjaxResult updateProfile(@RequestBody SysUser user) | 61 | public AjaxResult updateProfile(@RequestBody SysUser user) |
| 62 | { | 62 | { |
| 63 | - SysLoginUser loginUser = getLoginUser(); | 63 | + SysLoginUser loginUser = (SysLoginUser) getLoginUser(); |
| 64 | SysUser sysUser = loginUser.getUser(); | 64 | SysUser sysUser = loginUser.getUser(); |
| 65 | user.setUserName(sysUser.getUserName()); | 65 | user.setUserName(sysUser.getUserName()); |
| 66 | if (StringUtils.isNotEmpty(user.getPhonenumber()) | 66 | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| @@ -96,7 +96,7 @@ public class SysProfileController extends BaseController | @@ -96,7 +96,7 @@ public class SysProfileController extends BaseController | ||
| 96 | @PutMapping("/updatePwd") | 96 | @PutMapping("/updatePwd") |
| 97 | public AjaxResult updatePwd(String oldPassword, String newPassword) | 97 | public AjaxResult updatePwd(String oldPassword, String newPassword) |
| 98 | { | 98 | { |
| 99 | - SysLoginUser loginUser = getLoginUser(); | 99 | + SysLoginUser loginUser = (SysLoginUser) getLoginUser(); |
| 100 | String userName = loginUser.getUsername(); | 100 | String userName = loginUser.getUsername(); |
| 101 | String password = loginUser.getPassword(); | 101 | String password = loginUser.getPassword(); |
| 102 | if (!SecurityUtils.matchesPassword(oldPassword, password)) | 102 | if (!SecurityUtils.matchesPassword(oldPassword, password)) |
| @@ -127,7 +127,7 @@ public class SysProfileController extends BaseController | @@ -127,7 +127,7 @@ public class SysProfileController extends BaseController | ||
| 127 | { | 127 | { |
| 128 | if (!file.isEmpty()) | 128 | if (!file.isEmpty()) |
| 129 | { | 129 | { |
| 130 | - SysLoginUser loginUser = getLoginUser(); | 130 | + SysLoginUser loginUser = (SysLoginUser) getLoginUser(); |
| 131 | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); | 131 | String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); |
| 132 | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) | 132 | if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) |
| 133 | { | 133 | { |
| @@ -127,7 +127,7 @@ public class SysRoleController extends BaseController | @@ -127,7 +127,7 @@ public class SysRoleController extends BaseController | ||
| 127 | if (roleService.updateRole(role) > 0) | 127 | if (roleService.updateRole(role) > 0) |
| 128 | { | 128 | { |
| 129 | // 更新缓存用户权限 | 129 | // 更新缓存用户权限 |
| 130 | - SysLoginUser loginUser = getLoginUser(); | 130 | + SysLoginUser loginUser = (SysLoginUser) getLoginUser(); |
| 131 | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) | 131 | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) |
| 132 | { | 132 | { |
| 133 | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); | 133 | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
| 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 | ||
| 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 rediskey: lh-admin # 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 |
| @@ -110,7 +110,7 @@ | @@ -110,7 +110,7 @@ | ||
| 110 | 生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/ | 110 | 生成的manifest中classpath的前缀,因为要把第三方jar放到lib目录下,所以classpath的前缀是lib/ |
| 111 | --> | 111 | --> |
| 112 | <classpathPrefix>lib/</classpathPrefix> | 112 | <classpathPrefix>lib/</classpathPrefix> |
| 113 | - <mainClass>com.zhonglai.luhui.admin.AdminApplication</mainClass> | 113 | + <mainClass>com.zhonglai.luhui.api.LhApiApplication</mainClass> |
| 114 | </manifest> | 114 | </manifest> |
| 115 | </archive> | 115 | </archive> |
| 116 | </configuration> | 116 | </configuration> |
lh-api/src/main/java/com/zhonglai/luhui/api/controller/iot/IotDeviceControlController.java
0 → 100644
| 1 | +package com.zhonglai.luhui.api.controller.iot; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.ruoyi.common.annotation.Log; | ||
| 5 | +import com.ruoyi.common.core.domain.Message; | ||
| 6 | +import com.ruoyi.common.core.domain.MessageCode; | ||
| 7 | +import com.ruoyi.common.enums.BusinessType; | ||
| 8 | +import com.ruoyi.common.utils.StringUtils; | ||
| 9 | +import com.ruoyi.common.utils.html.HttpUtils; | ||
| 10 | +import com.ruoyi.system.domain.IotDevice; | ||
| 11 | +import com.ruoyi.system.service.IIotDeviceService; | ||
| 12 | +import com.ruoyi.system.service.IIotTerminalService; | ||
| 13 | +import io.swagger.annotations.Api; | ||
| 14 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 15 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 16 | +import io.swagger.annotations.ApiOperation; | ||
| 17 | +import okhttp3.Response; | ||
| 18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 19 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 20 | +import org.springframework.stereotype.Controller; | ||
| 21 | +import org.springframework.transaction.annotation.Transactional; | ||
| 22 | +import org.springframework.web.bind.annotation.*; | ||
| 23 | + | ||
| 24 | +import javax.servlet.http.HttpServletResponse; | ||
| 25 | +import java.io.IOException; | ||
| 26 | +import java.util.HashMap; | ||
| 27 | +import java.util.Map; | ||
| 28 | + | ||
| 29 | +@Api(tags = "设备控制") | ||
| 30 | +@Controller | ||
| 31 | +@RequestMapping("/iot/iotDeviceControl") | ||
| 32 | +public class IotDeviceControlController { | ||
| 33 | + @Autowired | ||
| 34 | + private IIotDeviceService iotDeviceService; | ||
| 35 | + @Autowired | ||
| 36 | + private IIotTerminalService iIotTerminalService; | ||
| 37 | + private String getServiceAdrres(HttpServletResponse response,String imei) throws IOException { | ||
| 38 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 39 | + response.setCharacterEncoding("UTF-8"); | ||
| 40 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 41 | + { | ||
| 42 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 43 | + return null; | ||
| 44 | + } | ||
| 45 | + return "http://"+iotDevice.getListen_service_ip()+"device/control/"+imei; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @ApiOperation("固件版本更新") | ||
| 49 | + @ApiImplicitParams({ | ||
| 50 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 51 | + @ApiImplicitParam(value = "版本号",name = "firmwareVersion") | ||
| 52 | + }) | ||
| 53 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:firmwareUp')") | ||
| 54 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 55 | + @ResponseBody | ||
| 56 | + @PostMapping("/firmwareUp/{imei}") | ||
| 57 | + public String firmwareUp(HttpServletResponse response,@PathVariable String imei,String firmwareVersion,Integer code) throws IOException { | ||
| 58 | + String url = getServiceAdrres(response,imei); | ||
| 59 | + if(null == url) | ||
| 60 | + { | ||
| 61 | + return null; | ||
| 62 | + } | ||
| 63 | + Map<String,Object> map = new HashMap<>(); | ||
| 64 | + Map<String,Object> valueMap = new HashMap<>(); | ||
| 65 | + valueMap.put("firmwareVersion",firmwareVersion); | ||
| 66 | + valueMap.put("code",code); | ||
| 67 | + Response response1 = HttpUtils.postJsonBody(url, formBody -> { | ||
| 68 | + formBody.put("0", valueMap); | ||
| 69 | + }); | ||
| 70 | + return response1.body().string(); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @ApiOperation("设备重启") | ||
| 74 | + @ApiImplicitParams({ | ||
| 75 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 76 | + @ApiImplicitParam(value = "restart 1重启,2复位,3恢复出厂值",name = "restart"), | ||
| 77 | + }) | ||
| 78 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:restart')") | ||
| 79 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 80 | + @ResponseBody | ||
| 81 | + @PostMapping("/restart/{imei}/{restart}") | ||
| 82 | + public String restart(HttpServletResponse response,@PathVariable String imei ,@PathVariable Integer restart) throws IOException { | ||
| 83 | + String url = getServiceAdrres(response,imei); | ||
| 84 | + if(null == url) | ||
| 85 | + { | ||
| 86 | + return null; | ||
| 87 | + } | ||
| 88 | + Map<String,Object> valueMap = new HashMap<>(); | ||
| 89 | + valueMap.put("restart",restart); | ||
| 90 | + Response response1 = HttpUtils.postJsonBody(url, formBody -> { | ||
| 91 | + formBody.put("0",valueMap); | ||
| 92 | + }); | ||
| 93 | + return response1.body().string(); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + @ApiOperation("获取指定设备版本信息") | ||
| 97 | + @ApiImplicitParams({ | ||
| 98 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 99 | + }) | ||
| 100 | + @ResponseBody | ||
| 101 | + @PostMapping("/getFirmwareVersion/{imei}") | ||
| 102 | + public String getFirmwareVersion(HttpServletResponse response,@PathVariable String imei) throws IOException { | ||
| 103 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 104 | + response.setCharacterEncoding("UTF-8"); | ||
| 105 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 106 | + { | ||
| 107 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 108 | + return null; | ||
| 109 | + } | ||
| 110 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/getFirmwareVersion/"+iotDevice.getMqtt_username(); | ||
| 111 | + | ||
| 112 | + Response response1 = HttpUtils.postFromBody(url, builder -> { | ||
| 113 | + }, formBody -> { | ||
| 114 | + }); | ||
| 115 | + return response1.body().string(); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + @ApiOperation("强行断开链接") | ||
| 119 | + @ApiImplicitParams({ | ||
| 120 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 121 | + }) | ||
| 122 | + @ResponseBody | ||
| 123 | + @PostMapping("/closeSession/{imei}") | ||
| 124 | + public String closeSession(HttpServletResponse response,@PathVariable String imei) throws IOException { | ||
| 125 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 126 | + response.setCharacterEncoding("UTF-8"); | ||
| 127 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 128 | + { | ||
| 129 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 130 | + return null; | ||
| 131 | + } | ||
| 132 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/closeSession/"+imei; | ||
| 133 | + | ||
| 134 | + Response response1 = HttpUtils.postFromBody(url, builder -> { | ||
| 135 | + }, formBody -> { | ||
| 136 | + }); | ||
| 137 | + return response1.body().string(); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + @ApiOperation("删除主机") | ||
| 141 | + @ApiImplicitParams({ | ||
| 142 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 143 | + }) | ||
| 144 | + @Transactional | ||
| 145 | + @ResponseBody | ||
| 146 | + @PostMapping("/delIotDevice/{imei}") | ||
| 147 | + public String delIotDevice(HttpServletResponse response,@PathVariable String imei) { | ||
| 148 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 149 | + iotDeviceService.deleteIotDeviceByClient_id(imei); | ||
| 150 | + iIotTerminalService.deleteIotTerminalByDeviceId(imei); | ||
| 151 | + response.setCharacterEncoding("UTF-8"); | ||
| 152 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 153 | + { | ||
| 154 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 155 | + } | ||
| 156 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/delIotDevice/"+imei; | ||
| 157 | + | ||
| 158 | + try { | ||
| 159 | + String str = HttpUtils.getResponseString(HttpUtils.postFromBody(url, builder -> { | ||
| 160 | + }, formBody -> { | ||
| 161 | + })); | ||
| 162 | + if(null != str) | ||
| 163 | + { | ||
| 164 | + return str; | ||
| 165 | + } | ||
| 166 | + } catch (IOException e) { | ||
| 167 | + } | ||
| 168 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 169 | + | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + @ApiOperation("删除终端") | ||
| 173 | + @ApiImplicitParams({ | ||
| 174 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 175 | + }) | ||
| 176 | + @ResponseBody | ||
| 177 | + @PostMapping("/delIotTerminal/{imei}/{number}") | ||
| 178 | + public String delIotTerminal(@PathVariable String imei,@PathVariable String number) { | ||
| 179 | + return iIotTerminalService.deleteIotTerminalById(imei,number); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + @ApiOperation(value = "读取属性") | ||
| 183 | + @ApiImplicitParams({ | ||
| 184 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 185 | + @ApiImplicitParam(value = "传感器编号(0,1_1,10_1)",name = "sensor_number"), | ||
| 186 | + @ApiImplicitParam(value = "属性集合(id1,id2,id3)",name = "attributes"), | ||
| 187 | + }) | ||
| 188 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:upSummary')") | ||
| 189 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 190 | + @ResponseBody | ||
| 191 | + @PostMapping("/readAttribute/{imei}/{sensor_number}") | ||
| 192 | + public String readAttribute(HttpServletResponse response,@PathVariable String imei,@PathVariable String sensor_number,String attributes) throws IOException { | ||
| 193 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 194 | + response.setCharacterEncoding("UTF-8"); | ||
| 195 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 196 | + { | ||
| 197 | + response.getWriter().print(new Message(MessageCode.DEFAULT_FAIL_CODE,"未找到设备监听服务地址")); | ||
| 198 | + return null; | ||
| 199 | + } | ||
| 200 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/read/"+imei; | ||
| 201 | + Map<String,Object> map = new HashMap<>(); | ||
| 202 | + map.put(sensor_number,attributes); | ||
| 203 | + Response response1 = HttpUtils.postJsonBody(url, jsonObject -> jsonObject.putAll(map)); | ||
| 204 | + return response1.body().string(); | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + @ApiOperation(value = "设置主机自定义参数",notes = "自定义数据模型:\n" + | ||
| 208 | + "{\n" + | ||
| 209 | + " \t \"name\": \"wumei-smart\",\n" + | ||
| 210 | + " \t \"chip\": \"esp8266\",\n" + | ||
| 211 | + " \t \"author\": \"kerwincui\",\n" + | ||
| 212 | + " \t \"version\": 1.2,\n" + | ||
| 213 | + " \t \"createTime\": \"2022-06-06\"\n" + | ||
| 214 | + " }") | ||
| 215 | + @ApiImplicitParams({ | ||
| 216 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 217 | + @ApiImplicitParam(value = "自定义数据json字符串",name = "summary") | ||
| 218 | + }) | ||
| 219 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:upSummary')") | ||
| 220 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 221 | + @ResponseBody | ||
| 222 | + @PostMapping("/upSummary/{imei}") | ||
| 223 | + public String upSummary(HttpServletResponse response,@PathVariable String imei,String summary) throws IOException { | ||
| 224 | + String url = getServiceAdrres(response,imei); | ||
| 225 | + if(null == url) | ||
| 226 | + { | ||
| 227 | + return null; | ||
| 228 | + } | ||
| 229 | + Map<String,Object> valueMap = new HashMap<>(); | ||
| 230 | + valueMap.put("summary",JSONObject.parseObject(summary)); | ||
| 231 | + Response response1 = HttpUtils.postJsonBody(url,formBody -> { | ||
| 232 | + formBody.put("0", valueMap); | ||
| 233 | + }); | ||
| 234 | + return response1.body().string(); | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + @ApiOperation(value = "修改指定终端属性",notes = "配置参数模型:\n" + | ||
| 238 | + "{\n" + | ||
| 239 | + " \"id1\":\"value1\",\n" + | ||
| 240 | + " \"id2\":\"value2\",\n" + | ||
| 241 | + " \"id3\":\"value3\"\n" + | ||
| 242 | + " }") | ||
| 243 | + @ApiImplicitParams({ | ||
| 244 | + @ApiImplicitParam(value = "主机imei",name = "imei"), | ||
| 245 | + @ApiImplicitParam(value = "终端编号(如:1_1)",name = "number"), | ||
| 246 | + @ApiImplicitParam(value = "配置参数json字符串",name = "config") | ||
| 247 | + }) | ||
| 248 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:upTerminalConfig')") | ||
| 249 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 250 | + @ResponseBody | ||
| 251 | + @PostMapping("/upTerminalConfig/{imei}/{number}") | ||
| 252 | + public String upTerminalConfig(HttpServletResponse response, @PathVariable String imei,@PathVariable String number,@RequestBody Map<String,Object> config) throws IOException { | ||
| 253 | + String url = getServiceAdrres(response,imei); | ||
| 254 | + if(null == url) | ||
| 255 | + { | ||
| 256 | + return null; | ||
| 257 | + } | ||
| 258 | + Map<String,Object> map = new HashMap<>(); | ||
| 259 | + map.put(number,config); | ||
| 260 | + Response response1 = HttpUtils.postJsonBody(url, jsonObject -> jsonObject.putAll(map)); | ||
| 261 | + return response1.body().string(); | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + @ApiOperation(value = "批量修改终端属性",notes = "批量数据模型:\n" + | ||
| 265 | + "{\n" + | ||
| 266 | + " \"1\":{\n" + | ||
| 267 | + " \"id1\":\"value1\",\n" + | ||
| 268 | + " \"id2\":\"value2\",\n" + | ||
| 269 | + " \"id3\":\"value3\"\n" + | ||
| 270 | + " },\n" + | ||
| 271 | + " \"3\":{\n" + | ||
| 272 | + " \"id1\":\"value1\",\n" + | ||
| 273 | + " \"id2\":\"value2\",\n" + | ||
| 274 | + " \"id3\":\"value3\"\n" + | ||
| 275 | + " },\n" + | ||
| 276 | + " \"4\":{\n" + | ||
| 277 | + " \"id1\":\"value1\",\n" + | ||
| 278 | + " \"id2\":\"value2\",\n" + | ||
| 279 | + " \"id3\":\"value3\"\n" + | ||
| 280 | + " }\n" + | ||
| 281 | + "}") | ||
| 282 | + @ApiImplicitParam(value = "批量数据json字符串",name = "map") | ||
| 283 | + @PreAuthorize("@ss.hasPermi('iot:iotDeviceControl:batchUpTerminalConfig')") | ||
| 284 | + @Log(title = "设备控制", businessType = BusinessType.UPDATE) | ||
| 285 | + @ResponseBody | ||
| 286 | + @PostMapping("/batchUpTerminalConfig/{imei}") | ||
| 287 | + public String batchUpTerminalConfig(HttpServletResponse response,@PathVariable String imei,@RequestBody Map<String,Object> map) throws IOException { | ||
| 288 | + String url = getServiceAdrres(response,imei); | ||
| 289 | + if(null == url) | ||
| 290 | + { | ||
| 291 | + return null; | ||
| 292 | + } | ||
| 293 | + Response response1 = HttpUtils.postJsonBody(url, builder -> { | ||
| 294 | + | ||
| 295 | + }, formBody -> { | ||
| 296 | + for (String key:map.keySet()) | ||
| 297 | + { | ||
| 298 | + formBody.put(key, map.get(key)); | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + }); | ||
| 302 | + return response1.body().string(); | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + | ||
| 306 | +} |
| 1 | +package com.zhonglai.luhui.api.controller.iot; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.annotation.Log; | ||
| 4 | +import com.ruoyi.common.core.controller.BaseController; | ||
| 5 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 6 | +import com.ruoyi.common.core.page.TableDataInfo; | ||
| 7 | +import com.ruoyi.common.enums.BusinessType; | ||
| 8 | +import com.ruoyi.common.utils.DateUtils; | ||
| 9 | +import com.ruoyi.common.utils.poi.ExcelUtil; | ||
| 10 | +import com.ruoyi.system.domain.IotTerminal; | ||
| 11 | +import com.ruoyi.system.domain.UserTerminalGroupRelation; | ||
| 12 | +import com.ruoyi.system.service.IIotTerminalService; | ||
| 13 | +import com.ruoyi.system.service.IUserTerminalGroupRelationService; | ||
| 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 org.springframework.beans.factory.annotation.Autowired; | ||
| 19 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 20 | +import org.springframework.web.bind.annotation.*; | ||
| 21 | +import org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor; | ||
| 22 | + | ||
| 23 | +import javax.servlet.http.HttpServletResponse; | ||
| 24 | +import java.util.List; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * 终端Controller | ||
| 28 | + * | ||
| 29 | + * @author 钟来 | ||
| 30 | + * @date 2022-08-26 | ||
| 31 | + */ | ||
| 32 | +@Api(tags = "终端") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/iot/IotTerminal") | ||
| 35 | +public class IotTerminalController extends BaseController | ||
| 36 | +{ | ||
| 37 | + @Autowired | ||
| 38 | + private IIotTerminalService iotTerminalService; | ||
| 39 | + | ||
| 40 | + @Autowired | ||
| 41 | + private IUserTerminalGroupRelationService userTerminalGroupRelationService; | ||
| 42 | + | ||
| 43 | + @ApiOperation("查询终端列表") | ||
| 44 | + @PreAuthorize("@ss.hasPermi('iot:IotTerminal:list')") | ||
| 45 | + @GetMapping("/list") | ||
| 46 | + public TableDataInfo list(IotTerminal iotTerminal) | ||
| 47 | + { | ||
| 48 | + startPage(); | ||
| 49 | + List<IotTerminal> list = iotTerminalService.selectIotTerminalList(iotTerminal); | ||
| 50 | + return getDataTable(list); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @ApiOperation("获取终端详细信息") | ||
| 54 | + @ApiImplicitParam(value = "终端id",name = "id") | ||
| 55 | + @PreAuthorize("@ss.hasPermi('iot:IotTerminal:getInfo')") | ||
| 56 | + @GetMapping(value = "/{id}") | ||
| 57 | + public AjaxResult getInfo(@PathVariable("id") String id) | ||
| 58 | + { | ||
| 59 | + return AjaxResult.success(iotTerminalService.selectIotTerminalById(id)); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @ApiOperation("根据网关获取未分配终端") | ||
| 63 | + @ApiImplicitParam(value = "网关id",name = "imei") | ||
| 64 | + @PreAuthorize("@ss.hasPermi('iot:IotTerminal:getListByDevice')") | ||
| 65 | + @GetMapping(value = "/getListByDevice{imei}") | ||
| 66 | + public AjaxResult getListByDevice(@PathVariable("imei") String imei) | ||
| 67 | + { | ||
| 68 | + List<IotTerminal> list = iotTerminalService.selectNotUserIotTerminalListByImei(imei); | ||
| 69 | + return AjaxResult.success(list); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @ApiOperation("修改终端") | ||
| 73 | + @ApiImplicitParams({ | ||
| 74 | + @ApiImplicitParam(value = "终端id",name = "id"), | ||
| 75 | + @ApiImplicitParam(value = "终端名称",name = "name"), | ||
| 76 | + }) | ||
| 77 | + @PreAuthorize("@ss.hasPermi('iot:IotTerminal:editName')") | ||
| 78 | + @Log(title = "终端", businessType = BusinessType.UPDATE) | ||
| 79 | + @PostMapping("/editName") | ||
| 80 | + public AjaxResult editName(String id,String name) | ||
| 81 | + { | ||
| 82 | + IotTerminal iotTerminal = new IotTerminal(); | ||
| 83 | + iotTerminal.setName(name); | ||
| 84 | + iotTerminal.setId(id); | ||
| 85 | + iotTerminal.setUpdate_time(DateUtils.getNowTimeMilly()); | ||
| 86 | + return toAjax(iotTerminalService.updateIotTerminal(iotTerminal)); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @ApiOperation("分组终端") | ||
| 90 | + @ApiImplicitParams({ | ||
| 91 | + @ApiImplicitParam(value = "终端id集合",name = "ids"), | ||
| 92 | + @ApiImplicitParam(value = "分组id",name = "iot_terminal_group_id"), | ||
| 93 | + }) | ||
| 94 | + @PreAuthorize("@ss.hasPermi('iot:IotTerminal:groupTerminal')") | ||
| 95 | + @Log(title = "终端", businessType = BusinessType.UPDATE) | ||
| 96 | + @PostMapping("/groupTerminal") | ||
| 97 | + public AjaxResult groupTerminal(Integer iot_terminal_group_id,@RequestBody List<String> ids) | ||
| 98 | + { | ||
| 99 | + Integer userid= getUserId().intValue(); | ||
| 100 | + | ||
| 101 | + List<UserTerminalGroupRelation> list = userTerminalGroupRelationService.selectListByTerminalIds(ids.toArray(new String[ids.size()])); | ||
| 102 | + if( null != list && list.size() != 0) //判断是否有权限删除 | ||
| 103 | + { | ||
| 104 | + StringBuffer iot_terminal_ids = new StringBuffer(); | ||
| 105 | + for (UserTerminalGroupRelation userTerminalGroupRelation:list) | ||
| 106 | + { | ||
| 107 | + if(userTerminalGroupRelation.getUser_info_id()-userid != 0) | ||
| 108 | + { | ||
| 109 | + iot_terminal_ids.append(userTerminalGroupRelation.getIot_terminal_id()+" "); | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + if(iot_terminal_ids.length()!=0) | ||
| 113 | + { | ||
| 114 | + return AjaxResult.error("无权操作设备"+iot_terminal_ids.toString()); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + return toAjax( userTerminalGroupRelationService.groupTerminal(iot_terminal_group_id,ids,userid)); | ||
| 118 | + } | ||
| 119 | +} |
| @@ -6,9 +6,12 @@ import com.ruoyi.common.core.domain.AjaxResult; | @@ -6,9 +6,12 @@ import com.ruoyi.common.core.domain.AjaxResult; | ||
| 6 | import com.ruoyi.common.utils.StringUtils; | 6 | import com.ruoyi.common.utils.StringUtils; |
| 7 | import com.ruoyi.system.login.service.LoginService; | 7 | import com.ruoyi.system.login.service.LoginService; |
| 8 | import io.swagger.annotations.Api; | 8 | import io.swagger.annotations.Api; |
| 9 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 10 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 9 | import io.swagger.annotations.ApiOperation; | 11 | import io.swagger.annotations.ApiOperation; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.web.bind.annotation.PostMapping; | 13 | import org.springframework.web.bind.annotation.PostMapping; |
| 14 | +import org.springframework.web.bind.annotation.RequestHeader; | ||
| 12 | import org.springframework.web.bind.annotation.RequestMapping; | 15 | import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | import org.springframework.web.bind.annotation.RestController; | 16 | import org.springframework.web.bind.annotation.RestController; |
| 14 | 17 | ||
| @@ -23,6 +26,10 @@ public class ApiLoginController extends BaseController { | @@ -23,6 +26,10 @@ public class ApiLoginController extends BaseController { | ||
| 23 | private LoginService loginService; | 26 | private LoginService loginService; |
| 24 | 27 | ||
| 25 | @ApiOperation("账号密码登陆") | 28 | @ApiOperation("账号密码登陆") |
| 29 | + @ApiImplicitParams({ | ||
| 30 | + @ApiImplicitParam(value = "账号",name = "user"), | ||
| 31 | + @ApiImplicitParam(value = "密码",name = "pass"), | ||
| 32 | + }) | ||
| 26 | @PostMapping("/userpassLogin") | 33 | @PostMapping("/userpassLogin") |
| 27 | public AjaxResult userpassLogin(String user,String pass) | 34 | public AjaxResult userpassLogin(String user,String pass) |
| 28 | { | 35 | { |
| @@ -34,10 +41,10 @@ public class ApiLoginController extends BaseController { | @@ -34,10 +41,10 @@ public class ApiLoginController extends BaseController { | ||
| 34 | } | 41 | } |
| 35 | 42 | ||
| 36 | @ApiOperation("鱼儿乐token登陆") | 43 | @ApiOperation("鱼儿乐token登陆") |
| 44 | + @ApiImplicitParam(value = "鱼儿乐token",name = "loginToken") | ||
| 37 | @PostMapping("/yu2leTokenLogin") | 45 | @PostMapping("/yu2leTokenLogin") |
| 38 | - public AjaxResult yu2leTokenLogin(HttpServletRequest request) | 46 | + public AjaxResult yu2leTokenLogin(@RequestHeader String loginToken) |
| 39 | { | 47 | { |
| 40 | - String loginToken = request.getHeader(YU2LE_LOGIN_TOKEN_KEY); | ||
| 41 | if(StringUtils.isEmpty(loginToken)) | 48 | if(StringUtils.isEmpty(loginToken)) |
| 42 | { | 49 | { |
| 43 | return AjaxResult.error("请输入鱼儿乐令牌"); | 50 | return AjaxResult.error("请输入鱼儿乐令牌"); |
| @@ -3,7 +3,10 @@ package com.zhonglai.luhui.api.controller.user; | @@ -3,7 +3,10 @@ package com.zhonglai.luhui.api.controller.user; | ||
| 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; | ||
| 6 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| 8 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 9 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 7 | import io.swagger.annotations.ApiOperation; | 10 | import io.swagger.annotations.ApiOperation; |
| 8 | import org.springframework.security.access.prepost.PreAuthorize; | 11 | import org.springframework.security.access.prepost.PreAuthorize; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -52,20 +55,6 @@ public class UserTerminalGroupController extends BaseController | @@ -52,20 +55,6 @@ public class UserTerminalGroupController extends BaseController | ||
| 52 | return getDataTable(list); | 55 | return getDataTable(list); |
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | - /** | ||
| 56 | - * 导出终端分组列表 | ||
| 57 | - */ | ||
| 58 | - @ApiOperation("导出终端分组列表") | ||
| 59 | - @PreAuthorize("@ss.hasPermi('user:UserTerminalGroup:export')") | ||
| 60 | - @Log(title = "终端分组", businessType = BusinessType.EXPORT) | ||
| 61 | - @PostMapping("/export") | ||
| 62 | - public void export(HttpServletResponse response, UserTerminalGroup userTerminalGroup) | ||
| 63 | - { | ||
| 64 | - userTerminalGroup.setUser_info_id(getUserId().intValue()); | ||
| 65 | - List<UserTerminalGroup> list = userTerminalGroupService.selectUserTerminalGroupList(userTerminalGroup); | ||
| 66 | - ExcelUtil<UserTerminalGroup> util = new ExcelUtil<UserTerminalGroup>(UserTerminalGroup.class); | ||
| 67 | - util.exportExcel(response, list, "终端分组数据"); | ||
| 68 | - } | ||
| 69 | 58 | ||
| 70 | /** | 59 | /** |
| 71 | * 获取终端分组详细信息 | 60 | * 获取终端分组详细信息 |
| @@ -87,6 +76,8 @@ public class UserTerminalGroupController extends BaseController | @@ -87,6 +76,8 @@ public class UserTerminalGroupController extends BaseController | ||
| 87 | @PostMapping | 76 | @PostMapping |
| 88 | public AjaxResult add(@RequestBody UserTerminalGroup userTerminalGroup) | 77 | public AjaxResult add(@RequestBody UserTerminalGroup userTerminalGroup) |
| 89 | { | 78 | { |
| 79 | + userTerminalGroup.setUser_info_id(getUserId().intValue()); | ||
| 80 | + userTerminalGroup.setCreate_time(DateUtils.getNowTimeMilly()); | ||
| 90 | return toAjax(userTerminalGroupService.insertUserTerminalGroup(userTerminalGroup)); | 81 | return toAjax(userTerminalGroupService.insertUserTerminalGroup(userTerminalGroup)); |
| 91 | } | 82 | } |
| 92 | 83 | ||
| @@ -94,11 +85,18 @@ public class UserTerminalGroupController extends BaseController | @@ -94,11 +85,18 @@ public class UserTerminalGroupController extends BaseController | ||
| 94 | * 修改终端分组 | 85 | * 修改终端分组 |
| 95 | */ | 86 | */ |
| 96 | @ApiOperation("修改终端分组") | 87 | @ApiOperation("修改终端分组") |
| 88 | + @ApiImplicitParams({ | ||
| 89 | + @ApiImplicitParam(value = "分组名称",name = "name"), | ||
| 90 | + @ApiImplicitParam(value = "分组id",name = "id"), | ||
| 91 | + }) | ||
| 97 | @PreAuthorize("@ss.hasPermi('user:UserTerminalGroup:edit')") | 92 | @PreAuthorize("@ss.hasPermi('user:UserTerminalGroup:edit')") |
| 98 | @Log(title = "终端分组", businessType = BusinessType.UPDATE) | 93 | @Log(title = "终端分组", businessType = BusinessType.UPDATE) |
| 99 | @PutMapping | 94 | @PutMapping |
| 100 | - public AjaxResult edit(@RequestBody UserTerminalGroup userTerminalGroup) | 95 | + public AjaxResult edit(String name,Integer id) |
| 101 | { | 96 | { |
| 97 | + UserTerminalGroup userTerminalGroup = new UserTerminalGroup(); | ||
| 98 | + userTerminalGroup.setId(id); | ||
| 99 | + userTerminalGroup.setName(name); | ||
| 102 | return toAjax(userTerminalGroupService.updateUserTerminalGroup(userTerminalGroup)); | 100 | return toAjax(userTerminalGroupService.updateUserTerminalGroup(userTerminalGroup)); |
| 103 | } | 101 | } |
| 104 | 102 |
| 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 rediskey: lh-api # 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/ApiLogin/* | ||
| 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: 18080 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 rediskey: lh-api # 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/ApiLogin/* |
lh-api/src/main/resources/package.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | + | ||
| 3 | +<assembly> | ||
| 4 | + <id>bin</id> | ||
| 5 | + <!-- 最终打包成一个用于发布的zip文件 --> | ||
| 6 | + <formats> | ||
| 7 | + <format>zip</format> | ||
| 8 | + </formats> | ||
| 9 | + | ||
| 10 | + <!-- Adds dependencies to zip package under lib directory --> | ||
| 11 | + <dependencySets> | ||
| 12 | + <dependencySet> | ||
| 13 | + <!-- | ||
| 14 | + 不使用项目的artifact,第三方jar不要解压,打包进zip文件的lib目录 | ||
| 15 | + --> | ||
| 16 | + <useProjectArtifact>false</useProjectArtifact> | ||
| 17 | + <outputDirectory>lib</outputDirectory> | ||
| 18 | + <unpack>false</unpack> | ||
| 19 | + </dependencySet> | ||
| 20 | + </dependencySets> | ||
| 21 | + | ||
| 22 | + <fileSets> | ||
| 23 | + <!-- 把项目相关的说明文件,打包进zip文件的根目录 --> | ||
| 24 | + <fileSet> | ||
| 25 | + <directory>${project.basedir}</directory> | ||
| 26 | + <outputDirectory>/</outputDirectory> | ||
| 27 | + <includes> | ||
| 28 | + <include>README*</include> | ||
| 29 | + <include>LICENSE*</include> | ||
| 30 | + <include>NOTICE*</include> | ||
| 31 | + </includes> | ||
| 32 | + </fileSet> | ||
| 33 | + | ||
| 34 | + <!-- 把项目的配置文件,打包进zip文件的config目录 --> | ||
| 35 | + <fileSet> | ||
| 36 | + <directory>${project.basedir}\src\main\resources\configs</directory> | ||
| 37 | + <outputDirectory>../configs</outputDirectory> | ||
| 38 | + <includes> | ||
| 39 | + <include>*.properties</include> | ||
| 40 | + </includes> | ||
| 41 | + </fileSet> | ||
| 42 | + | ||
| 43 | + <!-- 把项目的配置文件,提出来 --> | ||
| 44 | + <fileSet> | ||
| 45 | + <directory>${project.basedir}\src\main\resources</directory> | ||
| 46 | + <outputDirectory>/</outputDirectory> | ||
| 47 | + <includes> | ||
| 48 | + <include>*.properties</include> | ||
| 49 | + <include>*.yml</include> | ||
| 50 | + </includes> | ||
| 51 | + </fileSet> | ||
| 52 | + | ||
| 53 | + <!-- 把项目的脚本文件目录( src/main/scripts )中的启动脚本文件,打包进zip文件的跟目录 --> | ||
| 54 | + <fileSet> | ||
| 55 | + <directory>${project.basedir}\bin</directory> | ||
| 56 | + <outputDirectory></outputDirectory> | ||
| 57 | + <includes> | ||
| 58 | + <include>start.*</include> | ||
| 59 | + <include>stop.*</include> | ||
| 60 | + </includes> | ||
| 61 | + </fileSet> | ||
| 62 | + | ||
| 63 | + <!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 --> | ||
| 64 | + <fileSet> | ||
| 65 | + <directory>${project.build.directory}</directory> | ||
| 66 | + <outputDirectory></outputDirectory> | ||
| 67 | + <includes> | ||
| 68 | + <include>*.jar</include> | ||
| 69 | + </includes> | ||
| 70 | + </fileSet> | ||
| 71 | + </fileSets> | ||
| 72 | +</assembly> |
| 1 | package com.ruoyi.system.mapper; | 1 | package com.ruoyi.system.mapper; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | +import java.util.Map; | ||
| 5 | + | ||
| 4 | import com.ruoyi.system.domain.IotTerminal; | 6 | import com.ruoyi.system.domain.IotTerminal; |
| 5 | 7 | ||
| 6 | /** | 8 | /** |
| @@ -59,4 +61,7 @@ public interface IotTerminalMapper | @@ -59,4 +61,7 @@ public interface IotTerminalMapper | ||
| 59 | */ | 61 | */ |
| 60 | public int deleteIotTerminalByIds(String[] ids); | 62 | public int deleteIotTerminalByIds(String[] ids); |
| 61 | int deleteIotTerminalByDeviceId(String deviceId); | 63 | int deleteIotTerminalByDeviceId(String deviceId); |
| 64 | + | ||
| 65 | + List<IotTerminal> selectNotUserIotTerminalListByImei(String device_id); | ||
| 66 | + | ||
| 62 | } | 67 | } |
| @@ -58,4 +58,6 @@ public interface UserTerminalGroupRelationMapper | @@ -58,4 +58,6 @@ public interface UserTerminalGroupRelationMapper | ||
| 58 | * @return 结果 | 58 | * @return 结果 |
| 59 | */ | 59 | */ |
| 60 | public int deleteUserTerminalGroupRelationByIds(Integer[] ids); | 60 | public int deleteUserTerminalGroupRelationByIds(Integer[] ids); |
| 61 | + | ||
| 62 | + List<UserTerminalGroupRelation> selectListByTerminalIds(String[] iot_terminal_ids); | ||
| 61 | } | 63 | } |
| 1 | package com.ruoyi.system.service; | 1 | package com.ruoyi.system.service; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | +import java.util.Map; | ||
| 5 | + | ||
| 4 | import com.ruoyi.system.domain.IotTerminal; | 6 | import com.ruoyi.system.domain.IotTerminal; |
| 7 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 5 | 8 | ||
| 6 | /** | 9 | /** |
| 7 | * nullService接口 | 10 | * nullService接口 |
| @@ -35,6 +38,8 @@ public interface IIotTerminalService | @@ -35,6 +38,8 @@ public interface IIotTerminalService | ||
| 35 | */ | 38 | */ |
| 36 | public int insertIotTerminal(IotTerminal iotTerminal); | 39 | public int insertIotTerminal(IotTerminal iotTerminal); |
| 37 | 40 | ||
| 41 | + int addIotTerminals(Integer userId, List<String> ids); | ||
| 42 | + | ||
| 38 | /** | 43 | /** |
| 39 | * 修改null | 44 | * 修改null |
| 40 | * | 45 | * |
| @@ -54,10 +59,11 @@ public interface IIotTerminalService | @@ -54,10 +59,11 @@ public interface IIotTerminalService | ||
| 54 | /** | 59 | /** |
| 55 | * 删除null信息 | 60 | * 删除null信息 |
| 56 | * | 61 | * |
| 57 | - * @param id null主键 | ||
| 58 | * @return 结果 | 62 | * @return 结果 |
| 59 | */ | 63 | */ |
| 60 | - public int deleteIotTerminalById(String id); | 64 | + public String deleteIotTerminalById(String imei, String number); |
| 61 | 65 | ||
| 62 | int deleteIotTerminalByDeviceId(String deviceId); | 66 | int deleteIotTerminalByDeviceId(String deviceId); |
| 67 | + | ||
| 68 | + List<IotTerminal> selectNotUserIotTerminalListByImei(String device_id); | ||
| 63 | } | 69 | } |
| @@ -2,6 +2,8 @@ package com.ruoyi.system.service; | @@ -2,6 +2,8 @@ package com.ruoyi.system.service; | ||
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | import com.ruoyi.system.domain.UserTerminalGroupRelation; | 4 | import com.ruoyi.system.domain.UserTerminalGroupRelation; |
| 5 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 5 | 7 | ||
| 6 | /** | 8 | /** |
| 7 | * 终端分组关系Service接口 | 9 | * 终端分组关系Service接口 |
| @@ -58,4 +60,6 @@ public interface IUserTerminalGroupRelationService | @@ -58,4 +60,6 @@ public interface IUserTerminalGroupRelationService | ||
| 58 | * @return 结果 | 60 | * @return 结果 |
| 59 | */ | 61 | */ |
| 60 | public int deleteUserTerminalGroupRelationById(Integer id); | 62 | public int deleteUserTerminalGroupRelationById(Integer id); |
| 63 | + List<UserTerminalGroupRelation> selectListByTerminalIds(String[] iot_terminal_ids); | ||
| 64 | + int groupTerminal(Integer iot_terminal_group_id, List<String> ids,Integer userId); | ||
| 61 | } | 65 | } |
| 1 | package com.ruoyi.system.service.impl; | 1 | package com.ruoyi.system.service.impl; |
| 2 | 2 | ||
| 3 | +import java.io.IOException; | ||
| 3 | import java.util.List; | 4 | import java.util.List; |
| 5 | +import java.util.Map; | ||
| 4 | 6 | ||
| 7 | +import com.alibaba.fastjson.JSONObject; | ||
| 8 | +import com.ruoyi.common.core.domain.Message; | ||
| 9 | +import com.ruoyi.common.core.domain.MessageCode; | ||
| 5 | import com.ruoyi.common.utils.DateUtils; | 10 | import com.ruoyi.common.utils.DateUtils; |
| 11 | +import com.ruoyi.common.utils.StringUtils; | ||
| 12 | +import com.ruoyi.common.utils.html.HttpUtils; | ||
| 13 | +import com.ruoyi.system.domain.IotDevice; | ||
| 14 | +import com.ruoyi.system.service.IIotDeviceService; | ||
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 8 | import com.ruoyi.system.mapper.IotTerminalMapper; | 17 | import com.ruoyi.system.mapper.IotTerminalMapper; |
| @@ -20,7 +29,8 @@ public class IotTerminalServiceImpl implements IIotTerminalService | @@ -20,7 +29,8 @@ public class IotTerminalServiceImpl implements IIotTerminalService | ||
| 20 | { | 29 | { |
| 21 | @Autowired | 30 | @Autowired |
| 22 | private IotTerminalMapper iotTerminalMapper; | 31 | private IotTerminalMapper iotTerminalMapper; |
| 23 | - | 32 | + @Autowired |
| 33 | + private IIotDeviceService iotDeviceService; | ||
| 24 | /** | 34 | /** |
| 25 | * 查询null | 35 | * 查询null |
| 26 | * | 36 | * |
| @@ -57,6 +67,12 @@ public class IotTerminalServiceImpl implements IIotTerminalService | @@ -57,6 +67,12 @@ public class IotTerminalServiceImpl implements IIotTerminalService | ||
| 57 | return iotTerminalMapper.insertIotTerminal(iotTerminal); | 67 | return iotTerminalMapper.insertIotTerminal(iotTerminal); |
| 58 | } | 68 | } |
| 59 | 69 | ||
| 70 | + @Override | ||
| 71 | + public int addIotTerminals(Integer userId, List<String> ids) { | ||
| 72 | + | ||
| 73 | + return 0; | ||
| 74 | + } | ||
| 75 | + | ||
| 60 | /** | 76 | /** |
| 61 | * 修改null | 77 | * 修改null |
| 62 | * | 78 | * |
| @@ -84,17 +100,41 @@ public class IotTerminalServiceImpl implements IIotTerminalService | @@ -84,17 +100,41 @@ public class IotTerminalServiceImpl implements IIotTerminalService | ||
| 84 | /** | 100 | /** |
| 85 | * 删除null信息 | 101 | * 删除null信息 |
| 86 | * | 102 | * |
| 87 | - * @param id null主键 | ||
| 88 | * @return 结果 | 103 | * @return 结果 |
| 89 | */ | 104 | */ |
| 90 | @Override | 105 | @Override |
| 91 | - public int deleteIotTerminalById(String id) | 106 | + public String deleteIotTerminalById(String imei, String number) |
| 107 | + { | ||
| 108 | + IotDevice iotDevice = iotDeviceService.selectIotDeviceByClient_id(imei); | ||
| 109 | + | ||
| 110 | + if(StringUtils.isEmpty(iotDevice.getListen_service_ip())) | ||
| 92 | { | 111 | { |
| 93 | - return iotTerminalMapper.deleteIotTerminalById(id); | 112 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); |
| 113 | + } | ||
| 114 | + String url = "http://"+iotDevice.getListen_service_ip()+"device/delIotTerminal/"+imei+"/"+number; | ||
| 115 | + | ||
| 116 | + String str = null; | ||
| 117 | + try { | ||
| 118 | + str = HttpUtils.getResponseString(HttpUtils.postFromBody(url, builder -> { | ||
| 119 | + }, formBody -> { | ||
| 120 | + })); | ||
| 121 | + } catch (IOException e) { | ||
| 122 | + } | ||
| 123 | + iotTerminalMapper.deleteIotTerminalById(imei+"_"+number); | ||
| 124 | + if(null != str) | ||
| 125 | + { | ||
| 126 | + return str; | ||
| 127 | + } | ||
| 128 | + return JSONObject.toJSONString(new Message(MessageCode.DEFAULT_SUCCESS_CODE,"删除成功")); | ||
| 94 | } | 129 | } |
| 95 | 130 | ||
| 96 | @Override | 131 | @Override |
| 97 | public int deleteIotTerminalByDeviceId(String deviceId) { | 132 | public int deleteIotTerminalByDeviceId(String deviceId) { |
| 98 | return iotTerminalMapper.deleteIotTerminalByDeviceId(deviceId); | 133 | return iotTerminalMapper.deleteIotTerminalByDeviceId(deviceId); |
| 99 | } | 134 | } |
| 135 | + | ||
| 136 | + @Override | ||
| 137 | + public List<IotTerminal> selectNotUserIotTerminalListByImei(String device_id) { | ||
| 138 | + return iotTerminalMapper.selectNotUserIotTerminalListByImei(device_id); | ||
| 139 | + } | ||
| 100 | } | 140 | } |
| 1 | package com.ruoyi.system.service.impl; | 1 | package com.ruoyi.system.service.impl; |
| 2 | 2 | ||
| 3 | +import java.util.ArrayList; | ||
| 3 | import java.util.List; | 4 | import java.util.List; |
| 5 | + | ||
| 6 | +import com.ruoyi.common.utils.DateUtils; | ||
| 7 | +import com.ruoyi.system.domain.UserTerminalGroup; | ||
| 8 | +import com.ruoyi.system.service.IUserTerminalGroupService; | ||
| 9 | +import com.ruoyi.system.service.PublicService; | ||
| 4 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 5 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 6 | import com.ruoyi.system.mapper.UserTerminalGroupRelationMapper; | 12 | import com.ruoyi.system.mapper.UserTerminalGroupRelationMapper; |
| 7 | import com.ruoyi.system.domain.UserTerminalGroupRelation; | 13 | import com.ruoyi.system.domain.UserTerminalGroupRelation; |
| 8 | import com.ruoyi.system.service.IUserTerminalGroupRelationService; | 14 | import com.ruoyi.system.service.IUserTerminalGroupRelationService; |
| 15 | +import org.springframework.transaction.annotation.Transactional; | ||
| 9 | 16 | ||
| 10 | /** | 17 | /** |
| 11 | * 终端分组关系Service业务层处理 | 18 | * 终端分组关系Service业务层处理 |
| @@ -19,6 +26,11 @@ public class UserTerminalGroupRelationServiceImpl implements IUserTerminalGroupR | @@ -19,6 +26,11 @@ public class UserTerminalGroupRelationServiceImpl implements IUserTerminalGroupR | ||
| 19 | @Autowired | 26 | @Autowired |
| 20 | private UserTerminalGroupRelationMapper userTerminalGroupRelationMapper; | 27 | private UserTerminalGroupRelationMapper userTerminalGroupRelationMapper; |
| 21 | 28 | ||
| 29 | + @Autowired | ||
| 30 | + private PublicService publicService; | ||
| 31 | + | ||
| 32 | + @Autowired | ||
| 33 | + private IUserTerminalGroupService userTerminalGroupService; | ||
| 22 | /** | 34 | /** |
| 23 | * 查询终端分组关系 | 35 | * 查询终端分组关系 |
| 24 | * | 36 | * |
| @@ -90,4 +102,52 @@ public class UserTerminalGroupRelationServiceImpl implements IUserTerminalGroupR | @@ -90,4 +102,52 @@ public class UserTerminalGroupRelationServiceImpl implements IUserTerminalGroupR | ||
| 90 | { | 102 | { |
| 91 | return userTerminalGroupRelationMapper.deleteUserTerminalGroupRelationById(id); | 103 | return userTerminalGroupRelationMapper.deleteUserTerminalGroupRelationById(id); |
| 92 | } | 104 | } |
| 105 | + | ||
| 106 | + @Override | ||
| 107 | + public List<UserTerminalGroupRelation> selectListByTerminalIds(String[] iot_terminal_ids) { | ||
| 108 | + return userTerminalGroupRelationMapper.selectListByTerminalIds(iot_terminal_ids); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @Override | ||
| 112 | + @Transactional | ||
| 113 | + public int groupTerminal(Integer iot_terminal_group_id, List<String> ids,Integer userId) { | ||
| 114 | + UserTerminalGroup userTerminalGroup = null; | ||
| 115 | + if(null != iot_terminal_group_id) | ||
| 116 | + { | ||
| 117 | + userTerminalGroup = userTerminalGroupService.selectUserTerminalGroupById(iot_terminal_group_id); | ||
| 118 | + if(null == userTerminalGroup) | ||
| 119 | + { | ||
| 120 | + throw new RuntimeException("分组不存在"); | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + List<UserTerminalGroupRelation > saveList = new ArrayList<>(); | ||
| 125 | + StringBuffer inids = new StringBuffer(); | ||
| 126 | + for(String id:ids) | ||
| 127 | + { | ||
| 128 | + if(inids.length() !=0) | ||
| 129 | + { | ||
| 130 | + inids.append(","); | ||
| 131 | + } | ||
| 132 | + inids.append("'"+id+"'"); | ||
| 133 | + | ||
| 134 | + UserTerminalGroupRelation userTerminalGroupRelation = new UserTerminalGroupRelation(); | ||
| 135 | + userTerminalGroupRelation.setIot_terminal_id(id); | ||
| 136 | + userTerminalGroupRelation.setUser_info_id(userId); | ||
| 137 | + userTerminalGroupRelation.setCreate_time(DateUtils.getNowTimeMilly()); | ||
| 138 | + if(null != userTerminalGroup) | ||
| 139 | + { | ||
| 140 | + userTerminalGroupRelation.setIot_terminal_group_id(userTerminalGroup.getId()); | ||
| 141 | + userTerminalGroupRelation.setIot_terminal_group_name(userTerminalGroup.getName()); | ||
| 142 | + } | ||
| 143 | + saveList.add(userTerminalGroupRelation); | ||
| 144 | + } | ||
| 145 | + publicService.updateBySql("delete from user_terminal_group_relation where iot_terminal_id in("+inids.toString()+")"); | ||
| 146 | + | ||
| 147 | + if(null != saveList && saveList.size() != 0) | ||
| 148 | + { | ||
| 149 | + return publicService.insertAll(saveList); | ||
| 150 | + } | ||
| 151 | + return 0; | ||
| 152 | + } | ||
| 93 | } | 153 | } |
| @@ -98,4 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -98,4 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 98 | #{id} | 98 | #{id} |
| 99 | </foreach> | 99 | </foreach> |
| 100 | </delete> | 100 | </delete> |
| 101 | + <select id="selectNotUserIotTerminalListByImei" parameterType="String" resultMap="IotTerminalResult"> | ||
| 102 | + SELECT a.* FROM `iot_terminal` a LEFT JOIN `user_terminal_group_relation` b ON a.`id`=b.`iot_terminal_id` WHERE b.user_info_id is not null AND a.`device_id`= #{device_id} | ||
| 103 | + </select> | ||
| 104 | + | ||
| 101 | </mapper> | 105 | </mapper> |
| @@ -68,4 +68,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -68,4 +68,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 68 | #{id} | 68 | #{id} |
| 69 | </foreach> | 69 | </foreach> |
| 70 | </delete> | 70 | </delete> |
| 71 | + | ||
| 72 | + <select id="selectListByTerminalIds" parameterType="String" resultMap="UserTerminalGroupRelationResult"> | ||
| 73 | + select * from `user_terminal_group_relation` where iot_terminal_id in | ||
| 74 | + <foreach item="id" collection="array" open="(" separator="," close=")"> | ||
| 75 | + #{id} | ||
| 76 | + </foreach> | ||
| 77 | + </select> | ||
| 71 | </mapper> | 78 | </mapper> |
-
请 注册 或 登录 后发表评论