正在显示
14 个修改的文件
包含
244 行增加
和
159 行删除
| 1 | package ${packageName}.${modlePath}.controller.${moduleName}; | 1 | package ${packageName}.${modlePath}.controller.${moduleName}; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | -import com.ruoyi.common.annotation.DataSource; | ||
| 5 | -import com.ruoyi.common.enums.DataSourceType; | 4 | +import com.zhonglai.luhui.datasource.enums.DataSource; |
| 5 | +import com.zhonglai.luhui.datasource.enums.DataSourceType; | ||
| 6 | import javax.servlet.http.HttpServletResponse; | 6 | import javax.servlet.http.HttpServletResponse; |
| 7 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| 8 | import io.swagger.annotations.ApiOperation; | 8 | import io.swagger.annotations.ApiOperation; |
| @@ -130,6 +130,17 @@ public class IotDevice implements Serializable | @@ -130,6 +130,17 @@ public class IotDevice implements Serializable | ||
| 130 | @ApiModelProperty("操作令牌") | 130 | @ApiModelProperty("操作令牌") |
| 131 | private String operation_token; | 131 | private String operation_token; |
| 132 | 132 | ||
| 133 | + @ApiModelProperty("产品标签") | ||
| 134 | + private String label; | ||
| 135 | + | ||
| 136 | + public String getLabel() { | ||
| 137 | + return label; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public void setLabel(String label) { | ||
| 141 | + this.label = label; | ||
| 142 | + } | ||
| 143 | + | ||
| 133 | public String getOperation_token() { | 144 | public String getOperation_token() { |
| 134 | return operation_token; | 145 | return operation_token; |
| 135 | } | 146 | } |
lh-jar/lh-jar-device-service/src/main/java/com/zhonglai/luhui/device/domain/IotProductLabel.java
0 → 100644
| 1 | +package com.zhonglai.luhui.device.domain; | ||
| 2 | + | ||
| 3 | +import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 4 | +import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import io.swagger.annotations.ApiModelProperty; | ||
| 7 | +import com.ruoyi.common.tool.BaseEntity; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 【请填写功能名称】对象 iot_product_label | ||
| 11 | + * | ||
| 12 | + * @author zhonglai | ||
| 13 | + * @date 2024-07-22 | ||
| 14 | + */ | ||
| 15 | +@ApiModel("【请填写功能名称】") | ||
| 16 | +public class IotProductLabel extends BaseEntity | ||
| 17 | +{ | ||
| 18 | + private static final long serialVersionUID = 1L; | ||
| 19 | + | ||
| 20 | + /** 主键 */ | ||
| 21 | + private Integer id; | ||
| 22 | + | ||
| 23 | + /** 产品id */ | ||
| 24 | + @ApiModelProperty(value="产品id") | ||
| 25 | + private Integer productId; | ||
| 26 | + | ||
| 27 | + /** 标签名称 */ | ||
| 28 | + @ApiModelProperty(value="标签名称") | ||
| 29 | + private String labelName; | ||
| 30 | + | ||
| 31 | + /** 标签key */ | ||
| 32 | + @ApiModelProperty(value="标签key") | ||
| 33 | + private String labelKey; | ||
| 34 | + | ||
| 35 | + public void setId(Integer id) | ||
| 36 | + { | ||
| 37 | + this.id = id; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public Integer getId() | ||
| 41 | + { | ||
| 42 | + return id; | ||
| 43 | + } | ||
| 44 | + public void setProductId(Integer productId) | ||
| 45 | + { | ||
| 46 | + this.productId = productId; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public Integer getProductId() | ||
| 50 | + { | ||
| 51 | + return productId; | ||
| 52 | + } | ||
| 53 | + public void setLabelName(String labelName) | ||
| 54 | + { | ||
| 55 | + this.labelName = labelName; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public String getLabelName() | ||
| 59 | + { | ||
| 60 | + return labelName; | ||
| 61 | + } | ||
| 62 | + public void setLabelKey(String labelKey) | ||
| 63 | + { | ||
| 64 | + this.labelKey = labelKey; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public String getLabelKey() | ||
| 68 | + { | ||
| 69 | + return labelKey; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public String toString() { | ||
| 74 | + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||
| 75 | + .append("id", getId()) | ||
| 76 | + .append("productId", getProductId()) | ||
| 77 | + .append("labelName", getLabelName()) | ||
| 78 | + .append("labelKey", getLabelKey()) | ||
| 79 | + .append("createTime", getCreateTime()) | ||
| 80 | + .toString(); | ||
| 81 | + } | ||
| 82 | +} |
| @@ -35,10 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -35,10 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 35 | <result property="device_life" column="device_life" /> | 35 | <result property="device_life" column="device_life" /> |
| 36 | <result property="data_update_time" column="data_update_time" /> | 36 | <result property="data_update_time" column="data_update_time" /> |
| 37 | <result property="operation_token" column="operation_token" /> | 37 | <result property="operation_token" column="operation_token" /> |
| 38 | + <result property="label" column="label" /> | ||
| 38 | </resultMap> | 39 | </resultMap> |
| 39 | 40 | ||
| 40 | <sql id="selectIotDeviceVo"> | 41 | <sql id="selectIotDeviceVo"> |
| 41 | - select active_time, client_id, completion_auth, create_by, create_time, del_flag, firmware_version, img_url, is_shadow, latitude, location_way, longitude, `name`, network_address, network_ip, remark, rssi, status, summary, things_model_value, update_by, update_time, product_id,mqtt_username,payload_type,things_model_config,listen_service_ip,device_life,data_update_time,mqtt_username,operation_token from iot_device | 42 | + select * from iot_device |
| 42 | </sql> | 43 | </sql> |
| 43 | 44 | ||
| 44 | <select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult"> | 45 | <select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult"> |
| @@ -60,11 +60,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -60,11 +60,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 60 | <result property="listen_service_ip" column="listen_service_ip" /> | 60 | <result property="listen_service_ip" column="listen_service_ip" /> |
| 61 | <result property="device_life" column="device_life" /> | 61 | <result property="device_life" column="device_life" /> |
| 62 | <result property="data_update_time" column="d_data_update_time" /> | 62 | <result property="data_update_time" column="d_data_update_time" /> |
| 63 | - | 63 | + <result property="label" column="label" /> |
| 64 | </resultMap> | 64 | </resultMap> |
| 65 | 65 | ||
| 66 | <sql id="selectIotTerminalVo"> | 66 | <sql id="selectIotTerminalVo"> |
| 67 | - select device_id, id, `name`, things_model_value, update_time,things_model_config,product_id,mqtt_username,data_update_time from iot_terminal | 67 | + select * from iot_terminal |
| 68 | </sql> | 68 | </sql> |
| 69 | 69 | ||
| 70 | <select id="selectIotTerminalList" parameterType="IotTerminal" resultMap="IotTerminalResult"> | 70 | <select id="selectIotTerminalList" parameterType="IotTerminal" resultMap="IotTerminalResult"> |
| @@ -5,9 +5,12 @@ import javax.servlet.http.HttpServletResponse; | @@ -5,9 +5,12 @@ import javax.servlet.http.HttpServletResponse; | ||
| 5 | 5 | ||
| 6 | import com.ruoyi.common.utils.DateUtils; | 6 | import com.ruoyi.common.utils.DateUtils; |
| 7 | import com.zhonglai.luhui.action.BaseController; | 7 | import com.zhonglai.luhui.action.BaseController; |
| 8 | +import com.zhonglai.luhui.dao.service.PublicService; | ||
| 8 | import com.zhonglai.luhui.security.utils.SecurityUtils; | 9 | import com.zhonglai.luhui.security.utils.SecurityUtils; |
| 9 | import com.zhonglai.luhui.sys.utils.ExcelUtil; | 10 | import com.zhonglai.luhui.sys.utils.ExcelUtil; |
| 10 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
| 12 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 13 | +import io.swagger.annotations.ApiImplicitParams; | ||
| 11 | import io.swagger.annotations.ApiOperation; | 14 | import io.swagger.annotations.ApiOperation; |
| 12 | import org.springframework.security.access.prepost.PreAuthorize; | 15 | import org.springframework.security.access.prepost.PreAuthorize; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -39,6 +42,9 @@ public class IotDeviceController extends BaseController | @@ -39,6 +42,9 @@ public class IotDeviceController extends BaseController | ||
| 39 | { | 42 | { |
| 40 | @Autowired | 43 | @Autowired |
| 41 | private IIotDeviceService iotDeviceService; | 44 | private IIotDeviceService iotDeviceService; |
| 45 | + | ||
| 46 | + @Autowired | ||
| 47 | + private PublicService publicService; | ||
| 42 | /** | 48 | /** |
| 43 | * 查询主机/网关列表 | 49 | * 查询主机/网关列表 |
| 44 | */ | 50 | */ |
| @@ -116,4 +122,18 @@ public class IotDeviceController extends BaseController | @@ -116,4 +122,18 @@ public class IotDeviceController extends BaseController | ||
| 116 | { | 122 | { |
| 117 | return toAjax(iotDeviceService.deleteIotDeviceByClient_ids(client_ids)); | 123 | return toAjax(iotDeviceService.deleteIotDeviceByClient_ids(client_ids)); |
| 118 | } | 124 | } |
| 125 | + | ||
| 126 | + @ApiOperation("给主机/网关打标签") | ||
| 127 | + @ApiImplicitParams({ | ||
| 128 | + @ApiImplicitParam(value = "标签(多个英文逗号分割)",name = "label"), | ||
| 129 | + @ApiImplicitParam(value = "设备主键",name = "client_id") | ||
| 130 | + }) | ||
| 131 | + @PreAuthorize("@ss.hasPermi('iot:IotDevice:add')") | ||
| 132 | + @Log(title = "主机/网关", businessType = BusinessType.INSERT) | ||
| 133 | + @PostMapping("tagging/{client_id}") | ||
| 134 | + public AjaxResult tagging(@PathVariable String client_id, String label) | ||
| 135 | + { | ||
| 136 | + int i = publicService.updateBySql("UPDATE `iot_device` SET label='"+label+"' WHERE client_id='"+client_id+"'"); | ||
| 137 | + return toAjax(i); | ||
| 138 | + } | ||
| 119 | } | 139 | } |
| 1 | +package com.zhonglai.luhui.admin.controller.iot; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import com.zhonglai.luhui.datasource.enums.DataSource; | ||
| 5 | +import com.zhonglai.luhui.datasource.enums.DataSourceType; | ||
| 6 | +import javax.servlet.http.HttpServletResponse; | ||
| 7 | +import io.swagger.annotations.Api; | ||
| 8 | +import io.swagger.annotations.ApiOperation; | ||
| 9 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 12 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 15 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 16 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 18 | +import org.springframework.web.bind.annotation.RestController; | ||
| 19 | +import com.ruoyi.common.annotation.Log; | ||
| 20 | +import com.zhonglai.luhui.action.BaseController; | ||
| 21 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 22 | +import com.ruoyi.common.enums.BusinessType; | ||
| 23 | +import com.zhonglai.luhui.dao.service.PublicTemplateService; | ||
| 24 | +import com.zhonglai.luhui.device.domain.IotProductLabel; | ||
| 25 | + | ||
| 26 | +import com.ruoyi.common.core.page.TableDataInfo; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * 产品标签Controller | ||
| 30 | + * | ||
| 31 | + * @author zhonglai | ||
| 32 | + * @date 2024-07-22 | ||
| 33 | + */ | ||
| 34 | +@Api(tags = "产品标签") | ||
| 35 | +@RestController | ||
| 36 | +@RequestMapping("/iot/product_label") | ||
| 37 | +public class IotProductLabelController extends BaseController | ||
| 38 | +{ | ||
| 39 | + @Autowired | ||
| 40 | + private PublicTemplateService publicTemplateService; | ||
| 41 | + | ||
| 42 | + @ApiOperation(value ="查询产品标签列表",notes="\n" + | ||
| 43 | + "公共参数描述:\n" + | ||
| 44 | + "条件参数:\n" + | ||
| 45 | + "timeMap; //时间条件(如:{\"create_time\":[开始时间,结束时间]})\n" + | ||
| 46 | + "keyValue; //模糊匹配的关键字(如:[\"value\",\"name,no\"])\n" + | ||
| 47 | + "queryParams; //字段对应的比较符号(如:{\"id\":\"EQ\"})\n" + | ||
| 48 | + "orderBy; //排序(如:\"id desc,name asc\")\n" + | ||
| 49 | + "\n" + | ||
| 50 | + "分页参数:\n" + | ||
| 51 | + "pageNum; //当前记录起始索引,从1开始\n" + | ||
| 52 | + "pageSize; //每页显示记录数") | ||
| 53 | + @GetMapping("/list/{productId}") | ||
| 54 | + public AjaxResult list(@PathVariable Integer productId) | ||
| 55 | + { | ||
| 56 | + IotProductLabel iotProductLabel = new IotProductLabel(); | ||
| 57 | + iotProductLabel.setProductId(productId); | ||
| 58 | + List<IotProductLabel> list = publicTemplateService.selectTList(iotProductLabel); | ||
| 59 | + return AjaxResult.success(list); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @ApiOperation("获取产品标签详细信息") | ||
| 63 | + @PreAuthorize("@ss.hasPermi('iot:product_label:query')") | ||
| 64 | + @GetMapping(value = "/{id}") | ||
| 65 | + public AjaxResult getInfo(@PathVariable("id") Integer id) | ||
| 66 | + { | ||
| 67 | + return success(publicTemplateService.getTById(id, IotProductLabel.class)); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @ApiOperation("新增产品标签") | ||
| 71 | + @PreAuthorize("@ss.hasPermi('iot:product_label:add')") | ||
| 72 | + @Log(title = "产品标签", businessType = BusinessType.INSERT) | ||
| 73 | + @PostMapping | ||
| 74 | + public AjaxResult add(@RequestBody IotProductLabel iotProductLabel) | ||
| 75 | + { | ||
| 76 | + return toAjax(publicTemplateService.add(iotProductLabel)); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @ApiOperation("修改产品标签") | ||
| 80 | + @PreAuthorize("@ss.hasPermi('iot:product_label:edit')") | ||
| 81 | + @Log(title = "产品标签", businessType = BusinessType.UPDATE) | ||
| 82 | + @PutMapping | ||
| 83 | + public AjaxResult edit(@RequestBody IotProductLabel iotProductLabel) | ||
| 84 | + { | ||
| 85 | + return toAjax(publicTemplateService.edit((iotProductLabel))); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @ApiOperation("删除产品标签") | ||
| 89 | + @PreAuthorize("@ss.hasPermi('iot:product_label:remove')") | ||
| 90 | + @Log(title = "产品标签", businessType = BusinessType.DELETE) | ||
| 91 | + @DeleteMapping("/{ids}") | ||
| 92 | + public AjaxResult remove(@PathVariable Integer[] ids) | ||
| 93 | + { | ||
| 94 | + return toAjax(publicTemplateService.removeByIds(IotProductLabel.class,ids)); | ||
| 95 | + } | ||
| 96 | +} |
lh-modules/lh-admin/src/main/java/com/zhonglai/luhui/admin/service/DataScopeAspect.java
已删除
100644 → 0
| 1 | -package com.zhonglai.luhui.admin.service; | ||
| 2 | - | ||
| 3 | -import com.ruoyi.common.annotation.DataScope; | ||
| 4 | -import com.ruoyi.common.tool.BaseEntity; | ||
| 5 | -import com.ruoyi.system.domain.entity.SysRole; | ||
| 6 | -import com.ruoyi.system.domain.entity.SysUser; | ||
| 7 | -import com.ruoyi.common.utils.StringUtils; | ||
| 8 | -import com.zhonglai.luhui.security.dto.BaseLoginUser; | ||
| 9 | -import com.zhonglai.luhui.security.utils.SecurityUtils; | ||
| 10 | -import org.aspectj.lang.JoinPoint; | ||
| 11 | -import org.aspectj.lang.annotation.Aspect; | ||
| 12 | -import org.aspectj.lang.annotation.Before; | ||
| 13 | -import org.springframework.stereotype.Component; | ||
| 14 | - | ||
| 15 | -/** | ||
| 16 | - * 数据过滤处理 | ||
| 17 | - * | ||
| 18 | - * @author ruoyi | ||
| 19 | - */ | ||
| 20 | -@Aspect | ||
| 21 | -@Component | ||
| 22 | -public class DataScopeAspect | ||
| 23 | -{ | ||
| 24 | - /** | ||
| 25 | - * 全部数据权限 | ||
| 26 | - */ | ||
| 27 | - public static final String DATA_SCOPE_ALL = "1"; | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | - * 自定数据权限 | ||
| 31 | - */ | ||
| 32 | - public static final String DATA_SCOPE_CUSTOM = "2"; | ||
| 33 | - | ||
| 34 | - /** | ||
| 35 | - * 部门数据权限 | ||
| 36 | - */ | ||
| 37 | - public static final String DATA_SCOPE_DEPT = "3"; | ||
| 38 | - | ||
| 39 | - /** | ||
| 40 | - * 部门及以下数据权限 | ||
| 41 | - */ | ||
| 42 | - public static final String DATA_SCOPE_DEPT_AND_CHILD = "4"; | ||
| 43 | - | ||
| 44 | - /** | ||
| 45 | - * 仅本人数据权限 | ||
| 46 | - */ | ||
| 47 | - public static final String DATA_SCOPE_SELF = "5"; | ||
| 48 | - | ||
| 49 | - /** | ||
| 50 | - * 数据权限过滤关键字 | ||
| 51 | - */ | ||
| 52 | - public static final String DATA_SCOPE = "dataScope"; | ||
| 53 | - | ||
| 54 | - @Before("@annotation(controllerDataScope)") | ||
| 55 | - public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable | ||
| 56 | - { | ||
| 57 | - clearDataScope(point); | ||
| 58 | - handleDataScope(point, controllerDataScope); | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) | ||
| 62 | - { | ||
| 63 | - // 获取当前的用户 | ||
| 64 | - BaseLoginUser loginUser = SecurityUtils.getLoginUser(); | ||
| 65 | - if (StringUtils.isNotNull(loginUser)) | ||
| 66 | - { | ||
| 67 | - SysUser currentUser = (SysUser) loginUser.getUser(); | ||
| 68 | - // 如果是超级管理员,则不过滤数据 | ||
| 69 | - if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) | ||
| 70 | - { | ||
| 71 | - dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), | ||
| 72 | - controllerDataScope.userAlias()); | ||
| 73 | - } | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - /** | ||
| 78 | - * 数据范围过滤 | ||
| 79 | - * | ||
| 80 | - * @param joinPoint 切点 | ||
| 81 | - * @param user 用户 | ||
| 82 | - * @param userAlias 别名 | ||
| 83 | - */ | ||
| 84 | - public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) | ||
| 85 | - { | ||
| 86 | - StringBuilder sqlString = new StringBuilder(); | ||
| 87 | - | ||
| 88 | - for (SysRole role : user.getRoles()) | ||
| 89 | - { | ||
| 90 | - String dataScope = role.getDataScope(); | ||
| 91 | - if (DATA_SCOPE_ALL.equals(dataScope)) | ||
| 92 | - { | ||
| 93 | - sqlString = new StringBuilder(); | ||
| 94 | - break; | ||
| 95 | - } | ||
| 96 | - else if (DATA_SCOPE_CUSTOM.equals(dataScope)) | ||
| 97 | - { | ||
| 98 | - sqlString.append(StringUtils.format( | ||
| 99 | - " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias, | ||
| 100 | - role.getRoleId())); | ||
| 101 | - } | ||
| 102 | - else if (DATA_SCOPE_DEPT.equals(dataScope)) | ||
| 103 | - { | ||
| 104 | - sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); | ||
| 105 | - } | ||
| 106 | - else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) | ||
| 107 | - { | ||
| 108 | - sqlString.append(StringUtils.format( | ||
| 109 | - " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", | ||
| 110 | - deptAlias, user.getDeptId(), user.getDeptId())); | ||
| 111 | - } | ||
| 112 | - else if (DATA_SCOPE_SELF.equals(dataScope)) | ||
| 113 | - { | ||
| 114 | - if (StringUtils.isNotBlank(userAlias)) | ||
| 115 | - { | ||
| 116 | - sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId())); | ||
| 117 | - } | ||
| 118 | - else | ||
| 119 | - { | ||
| 120 | - // 数据权限为仅本人且没有userAlias别名不查询任何数据 | ||
| 121 | - sqlString.append(" OR 1=0 "); | ||
| 122 | - } | ||
| 123 | - } | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - if (StringUtils.isNotBlank(sqlString.toString())) | ||
| 127 | - { | ||
| 128 | - Object params = joinPoint.getArgs()[0]; | ||
| 129 | - if (StringUtils.isNotNull(params) && params instanceof BaseEntity) | ||
| 130 | - { | ||
| 131 | - BaseEntity baseEntity = (BaseEntity) params; | ||
| 132 | - baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")"); | ||
| 133 | - } | ||
| 134 | - } | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - /** | ||
| 138 | - * 拼接权限sql前先清空params.dataScope参数防止注入 | ||
| 139 | - */ | ||
| 140 | - private void clearDataScope(final JoinPoint joinPoint) | ||
| 141 | - { | ||
| 142 | - Object params = joinPoint.getArgs()[0]; | ||
| 143 | - if (StringUtils.isNotNull(params) && params instanceof BaseEntity) | ||
| 144 | - { | ||
| 145 | - BaseEntity baseEntity = (BaseEntity) params; | ||
| 146 | - baseEntity.getParams().put(DATA_SCOPE, ""); | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | -} |
| 1 | package com.zhonglai.luhui.device.protocol.factory.service; | 1 | package com.zhonglai.luhui.device.protocol.factory.service; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.bean.BeanUtil; | ||
| 4 | import com.google.gson.JsonObject; | 3 | import com.google.gson.JsonObject; |
| 5 | import com.ruoyi.common.utils.GsonConstructor; | 4 | import com.ruoyi.common.utils.GsonConstructor; |
| 6 | import com.ruoyi.common.utils.StringUtils; | 5 | import com.ruoyi.common.utils.StringUtils; |
| 7 | import com.ruoyi.common.utils.spring.SpringUtils; | 6 | import com.ruoyi.common.utils.spring.SpringUtils; |
| 8 | import com.zhonglai.luhui.device.analysis.comm.dto.DeviceSensorData; | 7 | import com.zhonglai.luhui.device.analysis.comm.dto.DeviceSensorData; |
| 9 | import com.zhonglai.luhui.device.analysis.comm.dto.LogDeviceOperation; | 8 | import com.zhonglai.luhui.device.analysis.comm.dto.LogDeviceOperation; |
| 10 | -import com.zhonglai.luhui.device.analysis.comm.dto.thingsmodels.ThingsModelDataTypeEnum; | ||
| 11 | import com.zhonglai.luhui.device.domain.*; | 9 | import com.zhonglai.luhui.device.domain.*; |
| 12 | import com.zhonglai.luhui.device.protocol.factory.config.DeviceCach; | 10 | import com.zhonglai.luhui.device.protocol.factory.config.DeviceCach; |
| 13 | import com.zhonglai.luhui.device.protocol.factory.dto.ParserDeviceHostDto; | 11 | import com.zhonglai.luhui.device.protocol.factory.dto.ParserDeviceHostDto; |
| @@ -2,11 +2,15 @@ package com.zhonglai.luhui.mqtt.service.proxy; | @@ -2,11 +2,15 @@ package com.zhonglai.luhui.mqtt.service.proxy; | ||
| 2 | 2 | ||
| 3 | import com.zhonglai.luhui.device.analysis.comm.config.CacheConfig; | 3 | import com.zhonglai.luhui.device.analysis.comm.config.CacheConfig; |
| 4 | import com.zhonglai.luhui.device.analysis.comm.config.FastJson2JsonRedisSerializer; | 4 | import com.zhonglai.luhui.device.analysis.comm.config.FastJson2JsonRedisSerializer; |
| 5 | +import com.zhonglai.luhui.mqtt.service.proxy.comm.service.TerminalServiceImpl; | ||
| 5 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 6 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.boot.CommandLineRunner; | ||
| 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 8 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | 11 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| 9 | import org.springframework.boot.builder.SpringApplicationBuilder; | 12 | import org.springframework.boot.builder.SpringApplicationBuilder; |
| 13 | +import org.springframework.context.annotation.Bean; | ||
| 10 | import org.springframework.context.annotation.ComponentScan; | 14 | import org.springframework.context.annotation.ComponentScan; |
| 11 | import org.springframework.context.annotation.FilterType; | 15 | import org.springframework.context.annotation.FilterType; |
| 12 | import org.springframework.core.io.ClassPathResource; | 16 | import org.springframework.core.io.ClassPathResource; |
| @@ -28,7 +32,8 @@ import java.util.Collections; | @@ -28,7 +32,8 @@ import java.util.Collections; | ||
| 28 | @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) | 32 | @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) |
| 29 | public class MqttServiceListenApplication { | 33 | public class MqttServiceListenApplication { |
| 30 | private static Logger log = LoggerFactory.getLogger(MqttServiceListenApplication.class); | 34 | private static Logger log = LoggerFactory.getLogger(MqttServiceListenApplication.class); |
| 31 | - | 35 | + @Autowired |
| 36 | + private TerminalServiceImpl terminalService; | ||
| 32 | public static void main(String[] args) { | 37 | public static void main(String[] args) { |
| 33 | log.info("启动服务"); | 38 | log.info("启动服务"); |
| 34 | String RunInIDEA = checkRunInIDEA(); | 39 | String RunInIDEA = checkRunInIDEA(); |
| @@ -54,4 +59,13 @@ public class MqttServiceListenApplication { | @@ -54,4 +59,13 @@ public class MqttServiceListenApplication { | ||
| 54 | } | 59 | } |
| 55 | } | 60 | } |
| 56 | 61 | ||
| 62 | + @Bean | ||
| 63 | + public CommandLineRunner runAfterStartup() { | ||
| 64 | + return args -> { | ||
| 65 | + // 在这里编写启动后需要执行的逻辑 | ||
| 66 | + System.out.println("Spring Boot 应用已启动完成,执行额外的加载操作..."); | ||
| 67 | + // 执行加载数据库,连接外部服务等操作 | ||
| 68 | + terminalService.startMqttListenerService(); | ||
| 69 | + }; | ||
| 70 | + } | ||
| 57 | } | 71 | } |
| @@ -11,6 +11,7 @@ import lombok.SneakyThrows; | @@ -11,6 +11,7 @@ import lombok.SneakyThrows; | ||
| 11 | import org.eclipse.paho.client.mqttv3.*; | 11 | import org.eclipse.paho.client.mqttv3.*; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.beans.factory.annotation.Value; | 13 | import org.springframework.beans.factory.annotation.Value; |
| 14 | +import org.springframework.core.annotation.Order; | ||
| 14 | import org.springframework.stereotype.Component; | 15 | import org.springframework.stereotype.Component; |
| 15 | 16 | ||
| 16 | import java.util.List; | 17 | import java.util.List; |
| @@ -15,6 +15,7 @@ import org.slf4j.Logger; | @@ -15,6 +15,7 @@ import org.slf4j.Logger; | ||
| 15 | import org.slf4j.LoggerFactory; | 15 | import org.slf4j.LoggerFactory; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.beans.factory.annotation.Value; | 17 | import org.springframework.beans.factory.annotation.Value; |
| 18 | +import org.springframework.core.annotation.Order; | ||
| 18 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 19 | 20 | ||
| 20 | import javax.annotation.PostConstruct; | 21 | import javax.annotation.PostConstruct; |
| @@ -69,7 +70,6 @@ public class TerminalServiceImpl { | @@ -69,7 +70,6 @@ public class TerminalServiceImpl { | ||
| 69 | mqttclient.connect(options); | 70 | mqttclient.connect(options); |
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | - @PostConstruct | ||
| 73 | public void startMqttListenerService() throws MqttException, IOException { | 73 | public void startMqttListenerService() throws MqttException, IOException { |
| 74 | fileChangeListener.onApplicationEvent(); | 74 | fileChangeListener.onApplicationEvent(); |
| 75 | log.info("-----------开始启动mqtt监听服务--------------------"); | 75 | log.info("-----------开始启动mqtt监听服务--------------------"); |
| @@ -5,10 +5,12 @@ import com.alibaba.fastjson.util.IOUtils; | @@ -5,10 +5,12 @@ import com.alibaba.fastjson.util.IOUtils; | ||
| 5 | import com.zhonglai.luhui.device.analysis.comm.util.DateUtils; | 5 | import com.zhonglai.luhui.device.analysis.comm.util.DateUtils; |
| 6 | import com.zhonglai.luhui.device.analysis.dto.Message; | 6 | import com.zhonglai.luhui.device.analysis.dto.Message; |
| 7 | import com.zhonglai.luhui.device.analysis.dto.MessageCode; | 7 | import com.zhonglai.luhui.device.analysis.dto.MessageCode; |
| 8 | +import com.zhonglai.luhui.device.protocol.factory.control.DeviceCommandListenService; | ||
| 8 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| 9 | import io.swagger.annotations.ApiImplicitParam; | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 10 | import io.swagger.annotations.ApiImplicitParams; | 11 | import io.swagger.annotations.ApiImplicitParams; |
| 11 | import io.swagger.annotations.ApiOperation; | 12 | import io.swagger.annotations.ApiOperation; |
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | import org.springframework.stereotype.Controller; | 14 | import org.springframework.stereotype.Controller; |
| 13 | import org.springframework.web.bind.annotation.PathVariable; | 15 | import org.springframework.web.bind.annotation.PathVariable; |
| 14 | import org.springframework.web.bind.annotation.RequestMapping; | 16 | import org.springframework.web.bind.annotation.RequestMapping; |
| @@ -24,6 +26,15 @@ import java.util.zip.ZipFile; | @@ -24,6 +26,15 @@ import java.util.zip.ZipFile; | ||
| 24 | @Controller | 26 | @Controller |
| 25 | @RequestMapping("/log") | 27 | @RequestMapping("/log") |
| 26 | public class LogController { | 28 | public class LogController { |
| 29 | + @Autowired | ||
| 30 | + private DeviceCommandListenService deviceCommandListenService; | ||
| 31 | + @ApiOperation("获取") | ||
| 32 | + @RequestMapping(value = "getOperation_token",method = RequestMethod.GET) | ||
| 33 | + public String getOperation_token() | ||
| 34 | + { | ||
| 35 | + return deviceCommandListenService.getSelectorExpression(); | ||
| 36 | + } | ||
| 37 | + | ||
| 27 | @ApiOperation("获取一天的日志") | 38 | @ApiOperation("获取一天的日志") |
| 28 | @ApiImplicitParams({ | 39 | @ApiImplicitParams({ |
| 29 | @ApiImplicitParam(value = "时间(格式:20230114)",name = "time"), | 40 | @ApiImplicitParam(value = "时间(格式:20230114)",name = "time"), |
-
请 注册 或 登录 后发表评论