正在显示
67 个修改的文件
包含
1501 行增加
和
338 行删除
| @@ -44,10 +44,5 @@ | @@ -44,10 +44,5 @@ | ||
| 44 | <artifactId>mapper-spring-boot-starter</artifactId> | 44 | <artifactId>mapper-spring-boot-starter</artifactId> |
| 45 | </dependency> | 45 | </dependency> |
| 46 | 46 | ||
| 47 | - <!-- Mysql驱动包 --> | ||
| 48 | - <dependency> | ||
| 49 | - <groupId>mysql</groupId> | ||
| 50 | - <artifactId>mysql-connector-java</artifactId> | ||
| 51 | - </dependency> | ||
| 52 | </dependencies> | 47 | </dependencies> |
| 53 | </project> | 48 | </project> |
| @@ -28,10 +28,6 @@ public class DataSourceAspect | @@ -28,10 +28,6 @@ public class DataSourceAspect | ||
| 28 | { | 28 | { |
| 29 | protected Logger logger = LoggerFactory.getLogger(getClass()); | 29 | protected Logger logger = LoggerFactory.getLogger(getClass()); |
| 30 | 30 | ||
| 31 | - { | ||
| 32 | - System.out.println("数据源拦截"); | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | @Pointcut("@annotation(com.zhonglai.luhui.datasource.enums.DataSource)" | 31 | @Pointcut("@annotation(com.zhonglai.luhui.datasource.enums.DataSource)" |
| 36 | + "|| @within(com.zhonglai.luhui.datasource.enums.DataSource)") | 32 | + "|| @within(com.zhonglai.luhui.datasource.enums.DataSource)") |
| 37 | public void dsPointCut() | 33 | public void dsPointCut() |
| @@ -34,7 +34,6 @@ public abstract class JwtAuthenticationTokenFilter extends OncePerRequestFilter | @@ -34,7 +34,6 @@ public abstract class JwtAuthenticationTokenFilter extends OncePerRequestFilter | ||
| 34 | UsernamePasswordAuthenticationToken authenticationToken = getUsernamePasswordAuthenticationToken(loginUser); | 34 | UsernamePasswordAuthenticationToken authenticationToken = getUsernamePasswordAuthenticationToken(loginUser); |
| 35 | authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); | 35 | authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); |
| 36 | SecurityContextHolder.getContext().setAuthentication(authenticationToken); | 36 | SecurityContextHolder.getContext().setAuthentication(authenticationToken); |
| 37 | - chain.doFilter(request, response); | ||
| 38 | } | 37 | } |
| 39 | chain.doFilter(request, response); | 38 | chain.doFilter(request, response); |
| 40 | } | 39 | } |
| @@ -24,7 +24,6 @@ public abstract class AdminDetailsService implements UserDetailsService | @@ -24,7 +24,6 @@ public abstract class AdminDetailsService implements UserDetailsService | ||
| 24 | { | 24 | { |
| 25 | private static final Logger log = LoggerFactory.getLogger(AdminDetailsService.class); | 25 | private static final Logger log = LoggerFactory.getLogger(AdminDetailsService.class); |
| 26 | 26 | ||
| 27 | - | ||
| 28 | @Override | 27 | @Override |
| 29 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException | 28 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException |
| 30 | { | 29 | { |
| @@ -162,4 +162,9 @@ public class AjaxResult extends HashMap<String, Object> | @@ -162,4 +162,9 @@ public class AjaxResult extends HashMap<String, Object> | ||
| 162 | super.put(key, value); | 162 | super.put(key, value); |
| 163 | return this; | 163 | return this; |
| 164 | } | 164 | } |
| 165 | + | ||
| 166 | + @Override | ||
| 167 | + public String toString() { | ||
| 168 | + return super.toString(); | ||
| 169 | + } | ||
| 165 | } | 170 | } |
| @@ -15,6 +15,6 @@ public class GsonConstructor { | @@ -15,6 +15,6 @@ public class GsonConstructor { | ||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | static { | 17 | static { |
| 18 | - gson = (new GsonBuilder()).setVersion(1.0D).disableInnerClassSerialization().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).setDateFormat("yyyy-MM-dd").setPrettyPrinting().create(); | 18 | + gson = (new GsonBuilder()).setVersion(1.0D).disableInnerClassSerialization().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY).setDateFormat("yyyy-MM-dd").create(); |
| 19 | } | 19 | } |
| 20 | } | 20 | } |
| @@ -33,26 +33,41 @@ public class ResourcesConfig implements WebMvcConfigurer | @@ -33,26 +33,41 @@ public class ResourcesConfig implements WebMvcConfigurer | ||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | - /** | ||
| 37 | - * 跨域配置 | ||
| 38 | - */ | 36 | +// /** |
| 37 | +// * 跨域配置 | ||
| 38 | +// */ | ||
| 39 | +// @Bean | ||
| 40 | +// public CorsFilter corsFilter() | ||
| 41 | +// { | ||
| 42 | +// CorsConfiguration config = new CorsConfiguration(); | ||
| 43 | +// config.setAllowCredentials(true); | ||
| 44 | +// // 设置访问源地址 | ||
| 45 | +// config.addAllowedOriginPattern("*"); | ||
| 46 | +// // 设置访问源请求头 | ||
| 47 | +// config.addAllowedHeader("*"); | ||
| 48 | +// // 设置访问源请求方法 | ||
| 49 | +// config.addAllowedMethod("*"); | ||
| 50 | +// // 有效期 1800秒 | ||
| 51 | +// config.setMaxAge(1800L); | ||
| 52 | +// // 添加映射路径,拦截一切请求 | ||
| 53 | +// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
| 54 | +// source.registerCorsConfiguration("/**", config); | ||
| 55 | +// // 返回新的CorsFilter | ||
| 56 | +// return new CorsFilter(source); | ||
| 57 | +// } | ||
| 58 | + | ||
| 59 | + private CorsConfiguration buildConfig() { | ||
| 60 | + CorsConfiguration corsConfiguration = new CorsConfiguration(); | ||
| 61 | + corsConfiguration.addAllowedOrigin("*"); // 1允许任何域名使用 | ||
| 62 | + corsConfiguration.addAllowedHeader("*"); // 2允许任何头 | ||
| 63 | + corsConfiguration.addAllowedMethod("*"); // 3允许任何方法(post、get等) | ||
| 64 | + return corsConfiguration; | ||
| 65 | + } | ||
| 66 | + | ||
| 39 | @Bean | 67 | @Bean |
| 40 | - public CorsFilter corsFilter() | ||
| 41 | - { | ||
| 42 | - CorsConfiguration config = new CorsConfiguration(); | ||
| 43 | - config.setAllowCredentials(true); | ||
| 44 | - // 设置访问源地址 | ||
| 45 | - config.addAllowedOriginPattern("*"); | ||
| 46 | - // 设置访问源请求头 | ||
| 47 | - config.addAllowedHeader("*"); | ||
| 48 | - // 设置访问源请求方法 | ||
| 49 | - config.addAllowedMethod("*"); | ||
| 50 | - // 有效期 1800秒 | ||
| 51 | - config.setMaxAge(1800L); | ||
| 52 | - // 添加映射路径,拦截一切请求 | 68 | + public CorsFilter corsFilter() { |
| 53 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | 69 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); |
| 54 | - source.registerCorsConfiguration("/**", config); | ||
| 55 | - // 返回新的CorsFilter | 70 | + source.registerCorsConfiguration("/**", buildConfig()); // 4 |
| 56 | return new CorsFilter(source); | 71 | return new CorsFilter(source); |
| 57 | } | 72 | } |
| 58 | } | 73 | } |
| @@ -78,5 +78,9 @@ | @@ -78,5 +78,9 @@ | ||
| 78 | <groupId>tk.mybatis</groupId> | 78 | <groupId>tk.mybatis</groupId> |
| 79 | <artifactId>mapper-spring-boot-starter</artifactId> | 79 | <artifactId>mapper-spring-boot-starter</artifactId> |
| 80 | </dependency> | 80 | </dependency> |
| 81 | + <dependency> | ||
| 82 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 83 | + <artifactId>lh-common-datasource</artifactId> | ||
| 84 | + </dependency> | ||
| 81 | </dependencies> | 85 | </dependencies> |
| 82 | </project> | 86 | </project> |
| @@ -5,7 +5,6 @@ import javax.validation.Valid; | @@ -5,7 +5,6 @@ import javax.validation.Valid; | ||
| 5 | import javax.validation.constraints.NotBlank; | 5 | import javax.validation.constraints.NotBlank; |
| 6 | 6 | ||
| 7 | import com.ruoyi.common.annotation.PublicSQLConfig; | 7 | import com.ruoyi.common.annotation.PublicSQLConfig; |
| 8 | -import com.zhonglai.luhui.datasource.enums.DataSourceType; | ||
| 9 | import org.apache.commons.lang3.ArrayUtils; | 8 | import org.apache.commons.lang3.ArrayUtils; |
| 10 | import com.ruoyi.common.constant.GenConstants; | 9 | import com.ruoyi.common.constant.GenConstants; |
| 11 | import com.ruoyi.common.tool.BaseEntity; | 10 | import com.ruoyi.common.tool.BaseEntity; |
| @@ -21,7 +21,7 @@ import com.ruoyi.common.core.domain.AjaxResult; | @@ -21,7 +21,7 @@ import com.ruoyi.common.core.domain.AjaxResult; | ||
| 21 | import com.ruoyi.common.enums.BusinessType; | 21 | import com.ruoyi.common.enums.BusinessType; |
| 22 | import ${packageName}.domain.${ClassName}; | 22 | import ${packageName}.domain.${ClassName}; |
| 23 | import ${packageName}.service.I${ClassName}Service; | 23 | import ${packageName}.service.I${ClassName}Service; |
| 24 | -import com.zhonglai.luhui.sys.utils.ExcelUtil; | 24 | +##import com.zhonglai.luhui.sys.utils.ExcelUtil; |
| 25 | #if($table.crud || $table.sub) | 25 | #if($table.crud || $table.sub) |
| 26 | import com.ruoyi.common.core.page.TableDataInfo; | 26 | import com.ruoyi.common.core.page.TableDataInfo; |
| 27 | #elseif($table.tree) | 27 | #elseif($table.tree) |
| @@ -62,19 +62,19 @@ public class ${ClassName}Controller extends BaseController | @@ -62,19 +62,19 @@ public class ${ClassName}Controller extends BaseController | ||
| 62 | } | 62 | } |
| 63 | #end | 63 | #end |
| 64 | 64 | ||
| 65 | - /** | ||
| 66 | - * 导出${functionName}列表 | ||
| 67 | - */ | ||
| 68 | - @ApiOperation("导出${functionName}列表") | ||
| 69 | -## @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") | ||
| 70 | - @Log(title = "${functionName}", businessType = BusinessType.EXPORT) | ||
| 71 | - @PostMapping("/export") | ||
| 72 | - public void export(HttpServletResponse response, ${ClassName} ${className}) | ||
| 73 | - { | ||
| 74 | - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); | ||
| 75 | - ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); | ||
| 76 | - util.exportExcel(response, list, "${functionName}数据"); | ||
| 77 | - } | 65 | +## /** |
| 66 | +## * 导出${functionName}列表 | ||
| 67 | +## */ | ||
| 68 | +## @ApiOperation("导出${functionName}列表") | ||
| 69 | +#### @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") | ||
| 70 | +## @Log(title = "${functionName}", businessType = BusinessType.EXPORT) | ||
| 71 | +## @PostMapping("/export") | ||
| 72 | +## public void export(HttpServletResponse response, ${ClassName} ${className}) | ||
| 73 | +## { | ||
| 74 | +## List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); | ||
| 75 | +## ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); | ||
| 76 | +## util.exportExcel(response, list, "${functionName}数据"); | ||
| 77 | +## } | ||
| 78 | 78 | ||
| 79 | /** | 79 | /** |
| 80 | * 获取${functionName}详细信息 | 80 | * 获取${functionName}详细信息 |
| @@ -10,6 +10,9 @@ | @@ -10,6 +10,9 @@ | ||
| 10 | </parent> | 10 | </parent> |
| 11 | 11 | ||
| 12 | <artifactId>lh-jar-action</artifactId> | 12 | <artifactId>lh-jar-action</artifactId> |
| 13 | + <description> | ||
| 14 | + action的公告方法 | ||
| 15 | + </description> | ||
| 13 | 16 | ||
| 14 | <properties> | 17 | <properties> |
| 15 | <maven.compiler.source>8</maven.compiler.source> | 18 | <maven.compiler.source>8</maven.compiler.source> |
| @@ -18,9 +21,10 @@ | @@ -18,9 +21,10 @@ | ||
| 18 | </properties> | 21 | </properties> |
| 19 | 22 | ||
| 20 | <dependencies> | 23 | <dependencies> |
| 24 | + <!-- 模型--> | ||
| 21 | <dependency> | 25 | <dependency> |
| 22 | <groupId>com.zhonglai.luhui</groupId> | 26 | <groupId>com.zhonglai.luhui</groupId> |
| 23 | - <artifactId>lh-jar-sys-service</artifactId> | 27 | + <artifactId>ruoyi-common</artifactId> |
| 24 | </dependency> | 28 | </dependency> |
| 25 | </dependencies> | 29 | </dependencies> |
| 26 | </project> | 30 | </project> |
| 1 | +package com.zhonglai.luhui.device.analysis.comm.config; | ||
| 2 | + | ||
| 3 | +import org.springframework.beans.factory.annotation.Value; | ||
| 4 | +import org.springframework.context.annotation.Configuration; | ||
| 5 | + | ||
| 6 | +import javax.annotation.PostConstruct; | ||
| 7 | + | ||
| 8 | +@Configuration | ||
| 9 | +public class CacheConfig { | ||
| 10 | + @Value("${sys.redis.field: null}") | ||
| 11 | + public String sysRedisField ; //域 | ||
| 12 | + public static String FIELD ; //域 | ||
| 13 | + public static String DEVICE = "device:"; //存放网关数据 | ||
| 14 | + public static String THINGS_MODEL = "things_model:"; //存放数据模型 | ||
| 15 | + public static String TERMINAL = "terminal:"; //存放终端数据 | ||
| 16 | + public static String LOCK = "lock:"; //存放设备锁 | ||
| 17 | + | ||
| 18 | + @PostConstruct | ||
| 19 | + public void init() | ||
| 20 | + { | ||
| 21 | + CacheConfig.FIELD = sysRedisField; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | +} |
| 1 | -package com.zhonglai.luhui.device.analysis.comm.config; | ||
| 2 | - | ||
| 3 | -import org.springframework.context.annotation.Bean; | ||
| 4 | -import org.springframework.context.annotation.Configuration; | ||
| 5 | -import org.springframework.web.cors.CorsConfiguration; | ||
| 6 | -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
| 7 | -import org.springframework.web.filter.CorsFilter; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 跨域配置,需要和WebMvcConfigurerAdapter的addCorsMappings配合使用 | ||
| 11 | - */ | ||
| 12 | -@Configuration | ||
| 13 | -public class CorsConfig { | ||
| 14 | - private CorsConfiguration buildConfig() { | ||
| 15 | - CorsConfiguration corsConfiguration = new CorsConfiguration(); | ||
| 16 | - corsConfiguration.addAllowedOrigin("*"); // 1允许任何域名使用 | ||
| 17 | - corsConfiguration.addAllowedHeader("*"); // 2允许任何头 | ||
| 18 | - corsConfiguration.addAllowedMethod("*"); // 3允许任何方法(post、get等) | ||
| 19 | - return corsConfiguration; | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - @Bean | ||
| 23 | - public CorsFilter corsFilter() { | ||
| 24 | - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
| 25 | - source.registerCorsConfiguration("/**", buildConfig()); // 4 | ||
| 26 | - return new CorsFilter(source); | ||
| 27 | - } | ||
| 28 | -} |
| 1 | -package com.zhonglai.luhui.device.analysis.comm.config; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.parser.ParserConfig; | ||
| 4 | -import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
| 5 | -import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
| 6 | -import com.fasterxml.jackson.annotation.PropertyAccessor; | ||
| 7 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 8 | -import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; | ||
| 9 | -import org.springframework.beans.factory.annotation.Value; | ||
| 10 | -import org.springframework.context.annotation.Bean; | ||
| 11 | -import org.springframework.context.annotation.Configuration; | ||
| 12 | -import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
| 13 | -import org.springframework.data.redis.core.RedisTemplate; | ||
| 14 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
| 15 | - | ||
| 16 | -import javax.annotation.PostConstruct; | ||
| 17 | - | ||
| 18 | -@Configuration | ||
| 19 | -public class RedisConfig { | ||
| 20 | - @Value("${sys.redis.field}") | ||
| 21 | - public String sysRedisField ; //域 | ||
| 22 | - public static String FIELD ; //域 | ||
| 23 | - public static String DEVICE = "device:"; //存放网关数据 | ||
| 24 | - public static String THINGS_MODEL = "things_model:"; //存放数据模型 | ||
| 25 | - public static String TERMINAL = "terminal:"; //存放终端数据 | ||
| 26 | - public static String LOCK = "lock:"; //存放设备锁 | ||
| 27 | - | ||
| 28 | - @PostConstruct | ||
| 29 | - public void init() | ||
| 30 | - { | ||
| 31 | - RedisConfig.FIELD = sysRedisField; | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - @Bean | ||
| 35 | - @SuppressWarnings(value = { "unchecked", "rawtypes" }) | ||
| 36 | - public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) | ||
| 37 | - { | ||
| 38 | - RedisTemplate<Object, Object> template = new RedisTemplate<>(); | ||
| 39 | - template.setConnectionFactory(connectionFactory); | ||
| 40 | - | ||
| 41 | - //配置 | ||
| 42 | - ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | ||
| 43 | - FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); | ||
| 44 | - | ||
| 45 | - ObjectMapper mapper = new ObjectMapper(); | ||
| 46 | - mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | ||
| 47 | - mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); | ||
| 48 | - serializer.setObjectMapper(mapper); | ||
| 49 | - | ||
| 50 | - // 使用StringRedisSerializer来序列化和反序列化redis的key值 | ||
| 51 | - template.setKeySerializer(new StringRedisSerializer()); | ||
| 52 | - template.setValueSerializer(serializer); | ||
| 53 | - | ||
| 54 | - // Hash的key也采用StringRedisSerializer的序列化方式 | ||
| 55 | - template.setHashKeySerializer(new StringRedisSerializer()); | ||
| 56 | - template.setHashValueSerializer(serializer); | ||
| 57 | - | ||
| 58 | - template.afterPropertiesSet(); | ||
| 59 | - return template; | ||
| 60 | - } | ||
| 61 | -// @Bean | ||
| 62 | -// public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){ | ||
| 63 | -// RedisTemplate<String,Object> redisTemplate = new RedisTemplate<>(); | ||
| 64 | -// //设置工厂链接 | ||
| 65 | -// redisTemplate.setConnectionFactory(redisConnectionFactory); | ||
| 66 | -// //设置自定义序列化方式 | ||
| 67 | -// setSerializeConfig(redisTemplate, redisConnectionFactory); | ||
| 68 | -// return redisTemplate; | ||
| 69 | -// } | ||
| 70 | -// | ||
| 71 | -// private void setSerializeConfig(RedisTemplate<String, Object> redisTemplate, RedisConnectionFactory redisConnectionFactory) { | ||
| 72 | -// //对字符串采取普通的序列化方式 适用于key 因为我们一般采取简单字符串作为key | ||
| 73 | -// StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); | ||
| 74 | -// //普通的string类型的key采用 普通序列化方式 | ||
| 75 | -// redisTemplate.setKeySerializer(stringRedisSerializer); | ||
| 76 | -// //普通hash类型的key也使用 普通序列化方式 | ||
| 77 | -// redisTemplate.setHashKeySerializer(stringRedisSerializer); | ||
| 78 | -// //解决查询缓存转换异常的问题 大家不能理解就直接用就可以了 这是springboot自带的jackson序列化类,但是会有一定问题 | ||
| 79 | -// Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); | ||
| 80 | -// ObjectMapper om = new ObjectMapper(); | ||
| 81 | -// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | ||
| 82 | -// om.activateDefaultTyping(om.getPolymorphicTypeValidator(),ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_ARRAY); | ||
| 83 | -// jackson2JsonRedisSerializer.setObjectMapper(om); | ||
| 84 | -// //普通的值采用jackson方式自动序列化 | ||
| 85 | -// redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); | ||
| 86 | -// //hash类型的值也采用jackson方式序列化 | ||
| 87 | -// redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); | ||
| 88 | -// //属性设置完成afterPropertiesSet就会被调用,可以对设置不成功的做一些默认处理 | ||
| 89 | -// redisTemplate.afterPropertiesSet(); | ||
| 90 | -// } | ||
| 91 | - | ||
| 92 | -} |
| @@ -44,7 +44,7 @@ public class BusinessDataUpdateService { | @@ -44,7 +44,7 @@ public class BusinessDataUpdateService { | ||
| 44 | @Value("${server.port}") | 44 | @Value("${server.port}") |
| 45 | private long port; | 45 | private long port; |
| 46 | 46 | ||
| 47 | - @Value("${server.context-path}") | 47 | + @Value("${server.servlet.context-path}") |
| 48 | private String contextPath; | 48 | private String contextPath; |
| 49 | 49 | ||
| 50 | @Value("${sys.isText:false}") | 50 | @Value("${sys.isText:false}") |
| @@ -3,7 +3,7 @@ package com.zhonglai.luhui.device.analysis.comm.service; | @@ -3,7 +3,7 @@ package com.zhonglai.luhui.device.analysis.comm.service; | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.zhonglai.luhui.device.domain.IotDevice; | 4 | import com.zhonglai.luhui.device.domain.IotDevice; |
| 5 | import com.zhonglai.luhui.device.domain.IotTerminal; | 5 | import com.zhonglai.luhui.device.domain.IotTerminal; |
| 6 | -import com.zhonglai.luhui.device.analysis.comm.config.RedisConfig; | 6 | +import com.zhonglai.luhui.device.analysis.comm.config.CacheConfig; |
| 7 | import com.zhonglai.luhui.device.analysis.comm.dao.BaseDao; | 7 | import com.zhonglai.luhui.device.analysis.comm.dao.BaseDao; |
| 8 | import com.zhonglai.luhui.device.analysis.comm.dto.ServerDto; | 8 | import com.zhonglai.luhui.device.analysis.comm.dto.ServerDto; |
| 9 | import com.zhonglai.luhui.device.analysis.comm.factory.Topic; | 9 | import com.zhonglai.luhui.device.analysis.comm.factory.Topic; |
| @@ -215,7 +215,7 @@ public class CacheServiceImpl implements CacheService { | @@ -215,7 +215,7 @@ public class CacheServiceImpl implements CacheService { | ||
| 215 | */ | 215 | */ |
| 216 | public Set<String> getRedicTerminalFromClientId(String client_id) | 216 | public Set<String> getRedicTerminalFromClientId(String client_id) |
| 217 | { | 217 | { |
| 218 | - Set<String> keys = redisService.keys(RedisConfig.FIELD+RedisConfig.TERMINAL+client_id+"*"); | 218 | + Set<String> keys = redisService.keys(CacheConfig.FIELD+ CacheConfig.TERMINAL+client_id+"*"); |
| 219 | return keys; | 219 | return keys; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| @@ -225,7 +225,7 @@ public class CacheServiceImpl implements CacheService { | @@ -225,7 +225,7 @@ public class CacheServiceImpl implements CacheService { | ||
| 225 | */ | 225 | */ |
| 226 | private String getRedicDeviceKeyPath() | 226 | private String getRedicDeviceKeyPath() |
| 227 | { | 227 | { |
| 228 | - return RedisConfig.FIELD+RedisConfig.DEVICE; | 228 | + return CacheConfig.FIELD+ CacheConfig.DEVICE; |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | /** | 231 | /** |
| @@ -244,7 +244,7 @@ public class CacheServiceImpl implements CacheService { | @@ -244,7 +244,7 @@ public class CacheServiceImpl implements CacheService { | ||
| 244 | */ | 244 | */ |
| 245 | private String getRedicTerminalKeyPath() | 245 | private String getRedicTerminalKeyPath() |
| 246 | { | 246 | { |
| 247 | - return RedisConfig.FIELD+RedisConfig.TERMINAL; | 247 | + return CacheConfig.FIELD+ CacheConfig.TERMINAL; |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | private String keyspaceNotificationsConfigParameter = "KEA"; | 250 | private String keyspaceNotificationsConfigParameter = "KEA"; |
lh-jar/lh-jar-order-service/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 | + <modelVersion>4.0.0</modelVersion> | ||
| 6 | + <parent> | ||
| 7 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 8 | + <artifactId>lh-jar</artifactId> | ||
| 9 | + <version>1.0-SNAPSHOT</version> | ||
| 10 | + </parent> | ||
| 11 | + | ||
| 12 | + <artifactId>lh-jar-order-service</artifactId> | ||
| 13 | + | ||
| 14 | + <properties> | ||
| 15 | + <maven.compiler.source>8</maven.compiler.source> | ||
| 16 | + <maven.compiler.target>8</maven.compiler.target> | ||
| 17 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 18 | + </properties> | ||
| 19 | + <dependencies> | ||
| 20 | + <!-- 通用工具--> | ||
| 21 | + <dependency> | ||
| 22 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 23 | + <artifactId>lh-domain</artifactId> | ||
| 24 | + </dependency> | ||
| 25 | + | ||
| 26 | + <dependency> | ||
| 27 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 28 | + <artifactId>lh-public-dao</artifactId> | ||
| 29 | + </dependency> | ||
| 30 | + <dependency> | ||
| 31 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 32 | + <artifactId>lh-common-datasource</artifactId> | ||
| 33 | + </dependency> | ||
| 34 | + <dependency> | ||
| 35 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 36 | + <artifactId>lh-jar-action</artifactId> | ||
| 37 | + </dependency> | ||
| 38 | + | ||
| 39 | + </dependencies> | ||
| 40 | +</project> |
| 1 | +package com.zhonglai.luhui.order.service.controller; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import javax.servlet.http.HttpServletResponse; | ||
| 5 | + | ||
| 6 | +import com.ruoyi.common.utils.DateUtils; | ||
| 7 | +import io.swagger.annotations.Api; | ||
| 8 | +import io.swagger.annotations.ApiOperation; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 11 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 12 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 15 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 16 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 17 | +import org.springframework.web.bind.annotation.RestController; | ||
| 18 | +import com.ruoyi.common.annotation.Log; | ||
| 19 | +import com.zhonglai.luhui.action.BaseController; | ||
| 20 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 21 | +import com.ruoyi.common.enums.BusinessType; | ||
| 22 | +import com.zhonglai.luhui.order.service.domain.ContentGroupManagement; | ||
| 23 | +import com.zhonglai.luhui.order.service.service.IContentGroupManagementService; | ||
| 24 | +import com.ruoyi.common.core.page.TableDataInfo; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * 分组内容管理Controller | ||
| 28 | + * | ||
| 29 | + * @author 钟来 | ||
| 30 | + * @date 2023-08-30 | ||
| 31 | + */ | ||
| 32 | +@Api(tags = "分组内容管理") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/content/ContentGroupManagement") | ||
| 35 | +public class ContentGroupManagementController extends BaseController | ||
| 36 | +{ | ||
| 37 | + @Autowired | ||
| 38 | + private IContentGroupManagementService contentGroupManagementService; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 查询分组内容管理列表 | ||
| 42 | + */ | ||
| 43 | + @ApiOperation("查询分组内容管理列表") | ||
| 44 | + @GetMapping("/list") | ||
| 45 | + public TableDataInfo list(ContentGroupManagement contentGroupManagement) | ||
| 46 | + { | ||
| 47 | + startPage(); | ||
| 48 | + List<ContentGroupManagement> list = contentGroupManagementService.selectContentGroupManagementList(contentGroupManagement); | ||
| 49 | + return getDataTable(list); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 获取分组内容管理详细信息 | ||
| 54 | + */ | ||
| 55 | + @ApiOperation("获取分组内容管理详细信息") | ||
| 56 | + @GetMapping(value = "/{id}") | ||
| 57 | + public AjaxResult getInfo(@PathVariable("id") Integer id) | ||
| 58 | + { | ||
| 59 | + return AjaxResult.success(contentGroupManagementService.selectContentGroupManagementById(id)); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 新增分组内容管理 | ||
| 64 | + */ | ||
| 65 | + @ApiOperation("新增分组内容管理") | ||
| 66 | + @Log(title = "分组内容管理", businessType = BusinessType.INSERT) | ||
| 67 | + @PostMapping | ||
| 68 | + public AjaxResult add(@RequestBody ContentGroupManagement contentGroupManagement) | ||
| 69 | + { | ||
| 70 | + contentGroupManagement.setCreate_time(DateUtils.getNowTimeMilly()); | ||
| 71 | + return toAjax(contentGroupManagementService.insertContentGroupManagement(contentGroupManagement)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * 修改分组内容管理 | ||
| 76 | + */ | ||
| 77 | + @ApiOperation("修改分组内容管理") | ||
| 78 | + @Log(title = "分组内容管理", businessType = BusinessType.UPDATE) | ||
| 79 | + @PutMapping | ||
| 80 | + public AjaxResult edit(@RequestBody ContentGroupManagement contentGroupManagement) | ||
| 81 | + { | ||
| 82 | + return toAjax(contentGroupManagementService.updateContentGroupManagement(contentGroupManagement)); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 删除分组内容管理 | ||
| 87 | + */ | ||
| 88 | + @ApiOperation("删除分组内容管理") | ||
| 89 | + @Log(title = "分组内容管理", businessType = BusinessType.DELETE) | ||
| 90 | + @DeleteMapping("/{ids}") | ||
| 91 | + public AjaxResult remove(@PathVariable Integer[] ids) | ||
| 92 | + { | ||
| 93 | + return toAjax(contentGroupManagementService.deleteContentGroupManagementByIds(ids)); | ||
| 94 | + } | ||
| 95 | +} |
| 1 | +package com.zhonglai.luhui.order.service.domain; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.annotation.Excel; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import com.ruoyi.common.annotation.PublicSQLConfig; | ||
| 7 | +import com.ruoyi.common.tool.BaseEntity; | ||
| 8 | +import org.apache.commons.lang3.builder.ToStringBuilder; | ||
| 9 | +import org.apache.commons.lang3.builder.ToStringStyle; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 分组内容管理对象 content_group_management | ||
| 13 | + * | ||
| 14 | + * @author 钟来 | ||
| 15 | + * @date 2023-08-30 | ||
| 16 | + */ | ||
| 17 | +@ApiModel("分组内容管理") | ||
| 18 | +public class ContentGroupManagement extends BaseEntity | ||
| 19 | +{ | ||
| 20 | + @PublicSQLConfig(isSelect=false) | ||
| 21 | + private static final long serialVersionUID = 1L; | ||
| 22 | + | ||
| 23 | + /** 内容 */ | ||
| 24 | + @ApiModelProperty("内容") | ||
| 25 | + private String content; | ||
| 26 | + | ||
| 27 | + /** 创建时间 */ | ||
| 28 | + @ApiModelProperty("创建时间") | ||
| 29 | + private Integer create_time; | ||
| 30 | + | ||
| 31 | + /** 分组名称 */ | ||
| 32 | + @ApiModelProperty("分组名称") | ||
| 33 | + private String group_name; | ||
| 34 | + | ||
| 35 | + /** 主键 */ | ||
| 36 | + @ApiModelProperty("主键") | ||
| 37 | + private Integer id; | ||
| 38 | + | ||
| 39 | + /** 排序 */ | ||
| 40 | + @ApiModelProperty("排序") | ||
| 41 | + private Integer sort; | ||
| 42 | + | ||
| 43 | + public void setContent(String content) | ||
| 44 | + { | ||
| 45 | + this.content = content; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public String getContent() | ||
| 49 | + { | ||
| 50 | + return content; | ||
| 51 | + } | ||
| 52 | + public void setCreate_time(Integer create_time) | ||
| 53 | + { | ||
| 54 | + this.create_time = create_time; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public Integer getCreate_time() | ||
| 58 | + { | ||
| 59 | + return create_time; | ||
| 60 | + } | ||
| 61 | + public void setGroup_name(String group_name) | ||
| 62 | + { | ||
| 63 | + this.group_name = group_name; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public String getGroup_name() | ||
| 67 | + { | ||
| 68 | + return group_name; | ||
| 69 | + } | ||
| 70 | + public void setId(Integer id) | ||
| 71 | + { | ||
| 72 | + this.id = id; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public Integer getId() | ||
| 76 | + { | ||
| 77 | + return id; | ||
| 78 | + } | ||
| 79 | + public void setSort(Integer sort) | ||
| 80 | + { | ||
| 81 | + this.sort = sort; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public Integer getSort() | ||
| 85 | + { | ||
| 86 | + return sort; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @Override | ||
| 90 | + public String toString() { | ||
| 91 | + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | ||
| 92 | + .append("content", getContent()) | ||
| 93 | + .append("create_time", getCreate_time()) | ||
| 94 | + .append("group_name", getGroup_name()) | ||
| 95 | + .append("id", getId()) | ||
| 96 | + .append("sort", getSort()) | ||
| 97 | + .toString(); | ||
| 98 | + } | ||
| 99 | +} |
| 1 | +package com.zhonglai.luhui.order.service.mapper; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import com.zhonglai.luhui.order.service.domain.ContentGroupManagement; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 分组内容管理Mapper接口 | ||
| 8 | + * | ||
| 9 | + * @author 钟来 | ||
| 10 | + * @date 2023-08-30 | ||
| 11 | + */ | ||
| 12 | +public interface ContentGroupManagementMapper | ||
| 13 | +{ | ||
| 14 | + /** | ||
| 15 | + * 查询分组内容管理 | ||
| 16 | + * | ||
| 17 | + * @param id 分组内容管理主键 | ||
| 18 | + * @return 分组内容管理 | ||
| 19 | + */ | ||
| 20 | + public ContentGroupManagement selectContentGroupManagementById(Integer id); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 查询分组内容管理列表 | ||
| 24 | + * | ||
| 25 | + * @param contentGroupManagement 分组内容管理 | ||
| 26 | + * @return 分组内容管理集合 | ||
| 27 | + */ | ||
| 28 | + public List<ContentGroupManagement> selectContentGroupManagementList(ContentGroupManagement contentGroupManagement); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 新增分组内容管理 | ||
| 32 | + * | ||
| 33 | + * @param contentGroupManagement 分组内容管理 | ||
| 34 | + * @return 结果 | ||
| 35 | + */ | ||
| 36 | + public int insertContentGroupManagement(ContentGroupManagement contentGroupManagement); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 修改分组内容管理 | ||
| 40 | + * | ||
| 41 | + * @param contentGroupManagement 分组内容管理 | ||
| 42 | + * @return 结果 | ||
| 43 | + */ | ||
| 44 | + public int updateContentGroupManagement(ContentGroupManagement contentGroupManagement); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 删除分组内容管理 | ||
| 48 | + * | ||
| 49 | + * @param id 分组内容管理主键 | ||
| 50 | + * @return 结果 | ||
| 51 | + */ | ||
| 52 | + public int deleteContentGroupManagementById(Integer id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 批量删除分组内容管理 | ||
| 56 | + * | ||
| 57 | + * @param ids 需要删除的数据主键集合 | ||
| 58 | + * @return 结果 | ||
| 59 | + */ | ||
| 60 | + public int deleteContentGroupManagementByIds(Integer[] ids); | ||
| 61 | +} |
| 1 | +package com.zhonglai.luhui.order.service.service; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | +import com.zhonglai.luhui.order.service.domain.ContentGroupManagement; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 分组内容管理Service接口 | ||
| 8 | + * | ||
| 9 | + * @author 钟来 | ||
| 10 | + * @date 2023-08-30 | ||
| 11 | + */ | ||
| 12 | +public interface IContentGroupManagementService | ||
| 13 | +{ | ||
| 14 | + /** | ||
| 15 | + * 查询分组内容管理 | ||
| 16 | + * | ||
| 17 | + * @param id 分组内容管理主键 | ||
| 18 | + * @return 分组内容管理 | ||
| 19 | + */ | ||
| 20 | + public ContentGroupManagement selectContentGroupManagementById(Integer id); | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 查询分组内容管理列表 | ||
| 24 | + * | ||
| 25 | + * @param contentGroupManagement 分组内容管理 | ||
| 26 | + * @return 分组内容管理集合 | ||
| 27 | + */ | ||
| 28 | + public List<ContentGroupManagement> selectContentGroupManagementList(ContentGroupManagement contentGroupManagement); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 新增分组内容管理 | ||
| 32 | + * | ||
| 33 | + * @param contentGroupManagement 分组内容管理 | ||
| 34 | + * @return 结果 | ||
| 35 | + */ | ||
| 36 | + public int insertContentGroupManagement(ContentGroupManagement contentGroupManagement); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 修改分组内容管理 | ||
| 40 | + * | ||
| 41 | + * @param contentGroupManagement 分组内容管理 | ||
| 42 | + * @return 结果 | ||
| 43 | + */ | ||
| 44 | + public int updateContentGroupManagement(ContentGroupManagement contentGroupManagement); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 批量删除分组内容管理 | ||
| 48 | + * | ||
| 49 | + * @param ids 需要删除的分组内容管理主键集合 | ||
| 50 | + * @return 结果 | ||
| 51 | + */ | ||
| 52 | + public int deleteContentGroupManagementByIds(Integer[] ids); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 删除分组内容管理信息 | ||
| 56 | + * | ||
| 57 | + * @param id 分组内容管理主键 | ||
| 58 | + * @return 结果 | ||
| 59 | + */ | ||
| 60 | + public int deleteContentGroupManagementById(Integer id); | ||
| 61 | +} |
| 1 | +package com.zhonglai.luhui.order.service.service.impl; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +import com.zhonglai.luhui.datasource.enums.DataSource; | ||
| 6 | +import com.zhonglai.luhui.datasource.enums.DataSourceType; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | +import com.zhonglai.luhui.order.service.mapper.ContentGroupManagementMapper; | ||
| 10 | +import com.zhonglai.luhui.order.service.domain.ContentGroupManagement; | ||
| 11 | +import com.zhonglai.luhui.order.service.service.IContentGroupManagementService; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 分组内容管理Service业务层处理 | ||
| 15 | + * | ||
| 16 | + * @author 钟来 | ||
| 17 | + * @date 2023-08-30 | ||
| 18 | + */ | ||
| 19 | +@Service | ||
| 20 | +public class ContentGroupManagementServiceImpl implements IContentGroupManagementService | ||
| 21 | +{ | ||
| 22 | + @Autowired | ||
| 23 | + private ContentGroupManagementMapper contentGroupManagementMapper; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 查询分组内容管理 | ||
| 27 | + * | ||
| 28 | + * @param id 分组内容管理主键 | ||
| 29 | + * @return 分组内容管理 | ||
| 30 | + */ | ||
| 31 | + @DataSource(DataSourceType.MASTER) | ||
| 32 | + @Override | ||
| 33 | + public ContentGroupManagement selectContentGroupManagementById(Integer id) | ||
| 34 | + { | ||
| 35 | + return contentGroupManagementMapper.selectContentGroupManagementById(id); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 查询分组内容管理列表 | ||
| 40 | + * | ||
| 41 | + * @param contentGroupManagement 分组内容管理 | ||
| 42 | + * @return 分组内容管理 | ||
| 43 | + */ | ||
| 44 | + @DataSource(DataSourceType.MASTER) | ||
| 45 | + @Override | ||
| 46 | + public List<ContentGroupManagement> selectContentGroupManagementList(ContentGroupManagement contentGroupManagement) | ||
| 47 | + { | ||
| 48 | + return contentGroupManagementMapper.selectContentGroupManagementList(contentGroupManagement); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 新增分组内容管理 | ||
| 53 | + * | ||
| 54 | + * @param contentGroupManagement 分组内容管理 | ||
| 55 | + * @return 结果 | ||
| 56 | + */ | ||
| 57 | + @DataSource(DataSourceType.MASTER) | ||
| 58 | + @Override | ||
| 59 | + public int insertContentGroupManagement(ContentGroupManagement contentGroupManagement) | ||
| 60 | + { | ||
| 61 | + return contentGroupManagementMapper.insertContentGroupManagement(contentGroupManagement); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 修改分组内容管理 | ||
| 66 | + * | ||
| 67 | + * @param contentGroupManagement 分组内容管理 | ||
| 68 | + * @return 结果 | ||
| 69 | + */ | ||
| 70 | + @DataSource(DataSourceType.MASTER) | ||
| 71 | + @Override | ||
| 72 | + public int updateContentGroupManagement(ContentGroupManagement contentGroupManagement) | ||
| 73 | + { | ||
| 74 | + return contentGroupManagementMapper.updateContentGroupManagement(contentGroupManagement); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 批量删除分组内容管理 | ||
| 79 | + * | ||
| 80 | + * @param ids 需要删除的分组内容管理主键 | ||
| 81 | + * @return 结果 | ||
| 82 | + */ | ||
| 83 | + @DataSource(DataSourceType.MASTER) | ||
| 84 | + @Override | ||
| 85 | + public int deleteContentGroupManagementByIds(Integer[] ids) | ||
| 86 | + { | ||
| 87 | + return contentGroupManagementMapper.deleteContentGroupManagementByIds(ids); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * 删除分组内容管理信息 | ||
| 92 | + * | ||
| 93 | + * @param id 分组内容管理主键 | ||
| 94 | + * @return 结果 | ||
| 95 | + */ | ||
| 96 | + @DataSource(DataSourceType.MASTER) | ||
| 97 | + @Override | ||
| 98 | + public int deleteContentGroupManagementById(Integer id) | ||
| 99 | + { | ||
| 100 | + return contentGroupManagementMapper.deleteContentGroupManagementById(id); | ||
| 101 | + } | ||
| 102 | +} |
lh-jar/lh-jar-order-service/src/main/resources/mapper/content/ContentGroupManagementMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
| 2 | +<!DOCTYPE mapper | ||
| 3 | +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 4 | +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 5 | +<mapper namespace="com.zhonglai.luhui.order.service.mapper.ContentGroupManagementMapper"> | ||
| 6 | + | ||
| 7 | + <resultMap type="ContentGroupManagement" id="ContentGroupManagementResult"> | ||
| 8 | + <result property="content" column="content" /> | ||
| 9 | + <result property="create_time" column="create_time" /> | ||
| 10 | + <result property="group_name" column="group_name" /> | ||
| 11 | + <result property="id" column="id" /> | ||
| 12 | + <result property="sort" column="sort" /> | ||
| 13 | + </resultMap> | ||
| 14 | + | ||
| 15 | + <sql id="selectContentGroupManagementVo"> | ||
| 16 | + select `content`, `create_time`, `group_name`, `id`, `sort` from content_group_management | ||
| 17 | + </sql> | ||
| 18 | + | ||
| 19 | + <select id="selectContentGroupManagementList" parameterType="ContentGroupManagement" resultMap="ContentGroupManagementResult"> | ||
| 20 | + <include refid="selectContentGroupManagementVo"/> | ||
| 21 | + <where> | ||
| 22 | + <if test="params.beginCreate_time != null and params.beginCreate_time != '' and params.endCreate_time != null and params.endCreate_time != ''"> and create_time between #{params.beginCreate_time} and #{params.endCreate_time}</if> | ||
| 23 | + <if test="group_name != null and group_name != ''"> and group_name like concat('%', #{group_name}, '%')</if> | ||
| 24 | + <if test="id != null "> and id = #{id}</if> | ||
| 25 | + <if test="sort != null "> and sort = #{sort}</if> | ||
| 26 | + </where> | ||
| 27 | + </select> | ||
| 28 | + | ||
| 29 | + <select id="selectContentGroupManagementById" parameterType="Integer" resultMap="ContentGroupManagementResult"> | ||
| 30 | + <include refid="selectContentGroupManagementVo"/> | ||
| 31 | + where id = #{id} | ||
| 32 | + </select> | ||
| 33 | + | ||
| 34 | + <insert id="insertContentGroupManagement" parameterType="ContentGroupManagement" useGeneratedKeys="true" keyProperty="id"> | ||
| 35 | + insert into content_group_management | ||
| 36 | + <trim prefix="(" suffix=")" suffixOverrides=","> | ||
| 37 | + <if test="content != null and content != ''">content,</if> | ||
| 38 | + <if test="create_time != null">create_time,</if> | ||
| 39 | + <if test="group_name != null and group_name != ''">group_name,</if> | ||
| 40 | + <if test="sort != null">sort,</if> | ||
| 41 | + </trim> | ||
| 42 | + <trim prefix="values (" suffix=")" suffixOverrides=","> | ||
| 43 | + <if test="content != null and content != ''">#{content},</if> | ||
| 44 | + <if test="create_time != null">#{create_time},</if> | ||
| 45 | + <if test="group_name != null and group_name != ''">#{group_name},</if> | ||
| 46 | + <if test="sort != null">#{sort},</if> | ||
| 47 | + </trim> | ||
| 48 | + </insert> | ||
| 49 | + | ||
| 50 | + <update id="updateContentGroupManagement" parameterType="ContentGroupManagement"> | ||
| 51 | + update content_group_management | ||
| 52 | + <trim prefix="SET" suffixOverrides=","> | ||
| 53 | + <if test="content != null and content != ''">content = #{content},</if> | ||
| 54 | + <if test="create_time != null">create_time = #{create_time},</if> | ||
| 55 | + <if test="group_name != null and group_name != ''">group_name = #{group_name},</if> | ||
| 56 | + <if test="sort != null">sort = #{sort},</if> | ||
| 57 | + </trim> | ||
| 58 | + where id = #{id} | ||
| 59 | + </update> | ||
| 60 | + | ||
| 61 | + <delete id="deleteContentGroupManagementById" parameterType="Integer"> | ||
| 62 | + delete from content_group_management where id = #{id} | ||
| 63 | + </delete> | ||
| 64 | + | ||
| 65 | + <delete id="deleteContentGroupManagementByIds" parameterType="String"> | ||
| 66 | + delete from content_group_management where id in | ||
| 67 | + <foreach item="id" collection="array" open="(" separator="," close=")"> | ||
| 68 | + #{id} | ||
| 69 | + </foreach> | ||
| 70 | + </delete> | ||
| 71 | +</mapper> |
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | <module>lh-jar-device-service</module> | 17 | <module>lh-jar-device-service</module> |
| 18 | <module>lh-jar-rocketmq</module> | 18 | <module>lh-jar-rocketmq</module> |
| 19 | <module>lh-jar-sys-service</module> | 19 | <module>lh-jar-sys-service</module> |
| 20 | + <module>lh-jar-order-service</module> | ||
| 20 | </modules> | 21 | </modules> |
| 21 | 22 | ||
| 22 | <properties> | 23 | <properties> |
| @@ -89,6 +89,10 @@ | @@ -89,6 +89,10 @@ | ||
| 89 | <groupId>com.zhonglai.luhui</groupId> | 89 | <groupId>com.zhonglai.luhui</groupId> |
| 90 | <artifactId>lh-jar-device-service</artifactId> | 90 | <artifactId>lh-jar-device-service</artifactId> |
| 91 | </dependency> | 91 | </dependency> |
| 92 | + <dependency> | ||
| 93 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 94 | + <artifactId>ruoyi-common-security</artifactId> | ||
| 95 | + </dependency> | ||
| 92 | </dependencies> | 96 | </dependencies> |
| 93 | 97 | ||
| 94 | <build> | 98 | <build> |
| @@ -21,7 +21,6 @@ import org.springframework.context.annotation.ComponentScan; | @@ -21,7 +21,6 @@ import org.springframework.context.annotation.ComponentScan; | ||
| 21 | "com.zhonglai.luhui.firewall", | 21 | "com.zhonglai.luhui.firewall", |
| 22 | "com.zhonglai.luhui.admin", | 22 | "com.zhonglai.luhui.admin", |
| 23 | "com.zhonglai.luhui.device.analysis.comm.service.redis", | 23 | "com.zhonglai.luhui.device.analysis.comm.service.redis", |
| 24 | - "com.zhonglai.luhui.mqtt.service.db.mode" | ||
| 25 | }) | 24 | }) |
| 26 | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) | 25 | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) |
| 27 | public class AdminApplication { | 26 | public class AdminApplication { |
lh-modules/lh-admin/src/main/java/com/zhonglai/luhui/admin/config/AdminConfigurerAdapter.java
0 → 100644
| 1 | +package com.zhonglai.luhui.admin.config; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.tool.SysLogininforType; | ||
| 4 | +import com.ruoyi.common.utils.spring.SpringUtils; | ||
| 5 | +import com.zhonglai.luhui.security.config.DefaultSecurityConfig; | ||
| 6 | +import com.zhonglai.luhui.security.service.AdminDetailsService; | ||
| 7 | +import com.zhonglai.luhui.security.service.SecurityConfigService; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.context.annotation.Configuration; | ||
| 10 | +import org.springframework.core.annotation.Order; | ||
| 11 | +import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
| 12 | +import org.springframework.security.core.userdetails.UserDetailsService; | ||
| 13 | +import org.springframework.security.crypto.password.PasswordEncoder; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * app接口安全策略. 没有{@link Order}注解优先级比上面低 | ||
| 17 | + */ | ||
| 18 | +@Configuration | ||
| 19 | +@Order(1) | ||
| 20 | +public class AdminConfigurerAdapter extends DefaultSecurityConfig { | ||
| 21 | + | ||
| 22 | + @Autowired | ||
| 23 | + private AdminDetailsService adminDetailsService; | ||
| 24 | + | ||
| 25 | + @Autowired | ||
| 26 | + private SecurityConfigService securityConfigService; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public UserDetailsService getUserDetailsService() { | ||
| 31 | + return adminDetailsService; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public void configHttpSecurity(HttpSecurity httpSecurity) throws Exception { | ||
| 36 | + httpSecurity.antMatcher("/sysLogin/**"); | ||
| 37 | + securityConfigService.configHttpSecurity(httpSecurity); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public PasswordEncoder bCryptPasswordEncoder() { | ||
| 42 | + return SpringUtils.getBean("bCryptPasswordEncoder"); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public SysLogininforType sysLogininforType() { | ||
| 47 | + return SysLogininforType.lhAdmin; | ||
| 48 | + } | ||
| 49 | +} |
| 1 | +package com.zhonglai.luhui.admin.config; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.utils.StringUtils; | ||
| 4 | +import com.zhonglai.luhui.security.dto.BaseLoginUser; | ||
| 5 | +import com.zhonglai.luhui.security.filter.JwtAuthenticationTokenFilter; | ||
| 6 | +import com.zhonglai.luhui.security.service.TokenService; | ||
| 7 | +import com.zhonglai.luhui.security.utils.SecurityUtils; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
| 10 | +import org.springframework.stereotype.Component; | ||
| 11 | + | ||
| 12 | +import javax.servlet.http.HttpServletRequest; | ||
| 13 | + | ||
| 14 | +@Component | ||
| 15 | +public class JwtAuthenticationTokenFilterImpl extends JwtAuthenticationTokenFilter { | ||
| 16 | + @Autowired | ||
| 17 | + private TokenService tokenService; | ||
| 18 | + | ||
| 19 | + @Override | ||
| 20 | + public BaseLoginUser getBaseLoginUser(HttpServletRequest request) { | ||
| 21 | + return tokenService.getLoginUser(request); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public boolean verifyToken(BaseLoginUser baseLoginUser) { | ||
| 26 | + if (StringUtils.isNotNull(baseLoginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) | ||
| 27 | + { | ||
| 28 | + tokenService.verifyToken(baseLoginUser); | ||
| 29 | + return true; | ||
| 30 | + } | ||
| 31 | + return false; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public UsernamePasswordAuthenticationToken getUsernamePasswordAuthenticationToken(BaseLoginUser loginUser) { | ||
| 36 | + return new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities()); | ||
| 37 | + } | ||
| 38 | +} |
| @@ -12,69 +12,49 @@ | @@ -12,69 +12,49 @@ | ||
| 12 | <artifactId>lh-api</artifactId> | 12 | <artifactId>lh-api</artifactId> |
| 13 | 13 | ||
| 14 | <dependencies> | 14 | <dependencies> |
| 15 | - <!-- spring-boot-devtools --> | 15 | + <!-- 核心模块--> |
| 16 | <dependency> | 16 | <dependency> |
| 17 | - <groupId>org.springframework.boot</groupId> | ||
| 18 | - <artifactId>spring-boot-devtools</artifactId> | ||
| 19 | - <optional>true</optional> <!-- 表示依赖不会传递 --> | ||
| 20 | - </dependency> | ||
| 21 | - <!-- SpringBoot Web容器 --> | ||
| 22 | - <dependency> | ||
| 23 | - <groupId>org.springframework.boot</groupId> | ||
| 24 | - <artifactId>spring-boot-starter-web</artifactId> | 17 | + <groupId>com.zhonglai.luhui</groupId> |
| 18 | + <artifactId>ruoyi-framework</artifactId> | ||
| 25 | </dependency> | 19 | </dependency> |
| 26 | - <!-- Spring框架基本的核心工具 --> | 20 | + <!-- 权限 --> |
| 27 | <dependency> | 21 | <dependency> |
| 28 | - <groupId>org.springframework</groupId> | ||
| 29 | - <artifactId>spring-context-support</artifactId> | 22 | + <groupId>com.zhonglai.luhui</groupId> |
| 23 | + <artifactId>ruoyi-common-security</artifactId> | ||
| 30 | </dependency> | 24 | </dependency> |
| 31 | - <!-- SpringWeb模块 --> | 25 | + <!-- 文档 --> |
| 32 | <dependency> | 26 | <dependency> |
| 33 | - <groupId>org.springframework</groupId> | ||
| 34 | - <artifactId>spring-web</artifactId> | 27 | + <groupId>com.zhonglai.luhui</groupId> |
| 28 | + <artifactId>lh-common-swagger</artifactId> | ||
| 35 | </dependency> | 29 | </dependency> |
| 30 | + <!-- 控制模块公共方法 --> | ||
| 36 | <dependency> | 31 | <dependency> |
| 37 | <groupId>com.zhonglai.luhui</groupId> | 32 | <groupId>com.zhonglai.luhui</groupId> |
| 38 | - <artifactId>ruoyi-framework</artifactId> | 33 | + <artifactId>lh-jar-action</artifactId> |
| 39 | </dependency> | 34 | </dependency> |
| 40 | 35 | ||
| 41 | - <!-- Mysql驱动包 --> | 36 | + <!-- 设备管理 --> |
| 42 | <dependency> | 37 | <dependency> |
| 43 | - <groupId>mysql</groupId> | ||
| 44 | - <artifactId>mysql-connector-java</artifactId> | ||
| 45 | - </dependency> | ||
| 46 | - <!-- 文档 --> | ||
| 47 | - <dependency > | ||
| 48 | - <groupId>io.springfox</groupId> | ||
| 49 | - <artifactId>springfox-swagger2</artifactId> | ||
| 50 | - <version>${swagger.version}</version> | ||
| 51 | - <exclusions> | ||
| 52 | - <exclusion> | ||
| 53 | - <groupId>io.swagger</groupId> | ||
| 54 | - <artifactId>swagger-models</artifactId> | ||
| 55 | - </exclusion> | ||
| 56 | - <exclusion> | ||
| 57 | - <groupId>com.google.guava</groupId> | ||
| 58 | - <artifactId>guava</artifactId> | ||
| 59 | - </exclusion> | ||
| 60 | - </exclusions> | 38 | + <groupId>com.zhonglai.luhui</groupId> |
| 39 | + <artifactId>lh-jar-device-service</artifactId> | ||
| 61 | </dependency> | 40 | </dependency> |
| 62 | - <!--https://mvnrepository.com/artifact/io.swagger/swagger-models--> | 41 | + |
| 42 | + <!-- 登录模块 --> | ||
| 63 | <dependency> | 43 | <dependency> |
| 64 | - <groupId>io.swagger</groupId> | ||
| 65 | - <artifactId>swagger-models</artifactId> | ||
| 66 | - <version>${swagger-models.version}</version> | 44 | + <groupId>com.zhonglai.luhui</groupId> |
| 45 | + <artifactId>lh-login</artifactId> | ||
| 67 | </dependency> | 46 | </dependency> |
| 47 | + | ||
| 48 | + <!-- 其它模块 --> | ||
| 68 | <dependency> | 49 | <dependency> |
| 69 | - <groupId>io.springfox</groupId> | ||
| 70 | - <artifactId>springfox-swagger-ui</artifactId> | ||
| 71 | - <version>${swagger.version}</version> | 50 | + <groupId>com.zhonglai.luhui</groupId> |
| 51 | + <artifactId>lh-jar-order-service</artifactId> | ||
| 72 | </dependency> | 52 | </dependency> |
| 73 | - <!--<!– https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui –>--> | 53 | + |
| 54 | + <!-- 数据库驱动 --> | ||
| 74 | <dependency> | 55 | <dependency> |
| 75 | - <groupId>com.github.xiaoymin</groupId> | ||
| 76 | - <artifactId>swagger-bootstrap-ui</artifactId> | ||
| 77 | - <version>${swagger-ui.version}</version> | 56 | + <groupId>mysql</groupId> |
| 57 | + <artifactId>mysql-connector-java</artifactId> | ||
| 78 | </dependency> | 58 | </dependency> |
| 79 | 59 | ||
| 80 | <dependency> | 60 | <dependency> |
| @@ -85,26 +65,6 @@ | @@ -85,26 +65,6 @@ | ||
| 85 | <groupId>org.aspectj</groupId> | 65 | <groupId>org.aspectj</groupId> |
| 86 | <artifactId>aspectjrt</artifactId> | 66 | <artifactId>aspectjrt</artifactId> |
| 87 | </dependency> | 67 | </dependency> |
| 88 | - <dependency> | ||
| 89 | - <groupId>com.zhonglai.luhui</groupId> | ||
| 90 | - <artifactId>ruoyi-common-security</artifactId> | ||
| 91 | - </dependency> | ||
| 92 | - <dependency> | ||
| 93 | - <groupId>com.zhonglai.luhui</groupId> | ||
| 94 | - <artifactId>lh-jar-action</artifactId> | ||
| 95 | - </dependency> | ||
| 96 | - <dependency> | ||
| 97 | - <groupId>com.zhonglai.luhui</groupId> | ||
| 98 | - <artifactId>lh-jar-rocketmq</artifactId> | ||
| 99 | - </dependency> | ||
| 100 | - <dependency> | ||
| 101 | - <groupId>com.zhonglai.luhui</groupId> | ||
| 102 | - <artifactId>lh-jar-device-service</artifactId> | ||
| 103 | - </dependency> | ||
| 104 | - <dependency> | ||
| 105 | - <groupId>com.zhonglai.luhui</groupId> | ||
| 106 | - <artifactId>lh-login</artifactId> | ||
| 107 | - </dependency> | ||
| 108 | </dependencies> | 68 | </dependencies> |
| 109 | 69 | ||
| 110 | <build> | 70 | <build> |
| @@ -19,6 +19,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; | @@ -19,6 +19,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; | ||
| 19 | "com.zhonglai.luhui.security", | 19 | "com.zhonglai.luhui.security", |
| 20 | "com.zhonglai.luhui.login.service", | 20 | "com.zhonglai.luhui.login.service", |
| 21 | "com.zhonglai.luhui.api", | 21 | "com.zhonglai.luhui.api", |
| 22 | + "com.zhonglai.luhui.order.service", | ||
| 22 | }) | 23 | }) |
| 23 | @EnableAspectJAutoProxy(proxyTargetClass=true) | 24 | @EnableAspectJAutoProxy(proxyTargetClass=true) |
| 24 | @SpringBootApplication | 25 | @SpringBootApplication |
| @@ -22,7 +22,7 @@ import java.util.Map; | @@ -22,7 +22,7 @@ import java.util.Map; | ||
| 22 | public class IotDeviceControlController { | 22 | public class IotDeviceControlController { |
| 23 | @Autowired | 23 | @Autowired |
| 24 | private DeviceControlService deviceControlService; | 24 | private DeviceControlService deviceControlService; |
| 25 | - | 25 | + |
| 26 | @ApiOperation("固件版本更新") | 26 | @ApiOperation("固件版本更新") |
| 27 | @ApiImplicitParams({ | 27 | @ApiImplicitParams({ |
| 28 | @ApiImplicitParam(value = "主机imei",name = "imei"), | 28 | @ApiImplicitParam(value = "主机imei",name = "imei"), |
| @@ -7,6 +7,7 @@ import com.ruoyi.common.enums.BusinessType; | @@ -7,6 +7,7 @@ import com.ruoyi.common.enums.BusinessType; | ||
| 7 | import com.ruoyi.common.utils.DateUtils; | 7 | import com.ruoyi.common.utils.DateUtils; |
| 8 | import com.ruoyi.system.domain.user.UserTerminalGroupRelation; | 8 | import com.ruoyi.system.domain.user.UserTerminalGroupRelation; |
| 9 | import com.zhonglai.luhui.action.BaseController; | 9 | import com.zhonglai.luhui.action.BaseController; |
| 10 | +import com.zhonglai.luhui.api.controller.test.TestDto; | ||
| 10 | import com.zhonglai.luhui.device.domain.IotTerminal; | 11 | import com.zhonglai.luhui.device.domain.IotTerminal; |
| 11 | import com.zhonglai.luhui.device.service.IIotTerminalService; | 12 | import com.zhonglai.luhui.device.service.IIotTerminalService; |
| 12 | import com.zhonglai.luhui.device.service.IUserTerminalGroupRelationService; | 13 | import com.zhonglai.luhui.device.service.IUserTerminalGroupRelationService; |
| @@ -22,7 +23,7 @@ import java.util.List; | @@ -22,7 +23,7 @@ import java.util.List; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * 终端Controller | 25 | * 终端Controller |
| 25 | - * | 26 | + * |
| 26 | * @author 钟来 | 27 | * @author 钟来 |
| 27 | * @date 2022-08-26 | 28 | * @date 2022-08-26 |
| 28 | */ | 29 | */ |
| @@ -48,6 +49,13 @@ public class IotTerminalController extends BaseController | @@ -48,6 +49,13 @@ public class IotTerminalController extends BaseController | ||
| 48 | return getDataTable(list); | 49 | return getDataTable(list); |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 52 | + @ApiOperation("测试") | ||
| 53 | + @GetMapping("/t1") | ||
| 54 | + public TestDto t1() | ||
| 55 | + { | ||
| 56 | + return new TestDto(); | ||
| 57 | + } | ||
| 58 | + | ||
| 51 | @ApiOperation("获取终端详细信息") | 59 | @ApiOperation("获取终端详细信息") |
| 52 | @ApiImplicitParam(value = "终端id",name = "id") | 60 | @ApiImplicitParam(value = "终端id",name = "id") |
| 53 | @GetMapping(value = "/{id}") | 61 | @GetMapping(value = "/{id}") |
lh-modules/lh-api/src/main/java/com/zhonglai/luhui/api/controller/test/TestController.java
0 → 100644
| 1 | +package com.zhonglai.luhui.api.controller.test; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 4 | +import io.swagger.annotations.Api; | ||
| 5 | +import io.swagger.annotations.ApiOperation; | ||
| 6 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 8 | +import org.springframework.web.bind.annotation.RestController; | ||
| 9 | + | ||
| 10 | +@Api(tags = "测试") | ||
| 11 | +@RestController | ||
| 12 | +@RequestMapping("/test") | ||
| 13 | +public class TestController { | ||
| 14 | + @ApiOperation("账号密码登陆") | ||
| 15 | + @GetMapping("/t1") | ||
| 16 | + public AjaxResult t1() | ||
| 17 | + { | ||
| 18 | + return AjaxResult.success(new TestDto()); | ||
| 19 | + } | ||
| 20 | +} |
| 1 | +package com.zhonglai.luhui.api.controller.test; | ||
| 2 | + | ||
| 3 | +public class TestDto { | ||
| 4 | + private String msg; | ||
| 5 | + | ||
| 6 | + public String getMsg() { | ||
| 7 | + return msg; | ||
| 8 | + } | ||
| 9 | + | ||
| 10 | + public void setMsg(String msg) { | ||
| 11 | + this.msg = msg; | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + @Override | ||
| 15 | + public String toString() { | ||
| 16 | + return "TestDto{" + | ||
| 17 | + "msg='" + msg + '\'' + | ||
| 18 | + '}'; | ||
| 19 | + } | ||
| 20 | +} |
| 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,com.zhonglai.**.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/* # NameServer地址 rocketmq: name-server: 47.115.144.179:9876 # 默认的消息组 producer: group: deviceCommand send-message-timeout: 30000 send-topic: lh-mqtt-service-deviceCommand-test send-tags: 1 | ||
| 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,com.zhonglai.**.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/*,/content/**,/test/** # NameServer地址 rocketmq: name-server: 47.115.144.179:9876 # 默认的消息组 producer: group: deviceCommand send-message-timeout: 30000 send-topic: lh-mqtt-service-deviceCommand-test send-tags: 1 |
lh-modules/lh-smart-feeder/README.md
0 → 100644
| 1 | +opencv源码编译过程: | ||
| 2 | + | ||
| 3 | +1、首先,确保你的 Armbian 系统已经安装好了基本的编译工具和依赖库。可以通过运行以下命令来安装它们: | ||
| 4 | +sudo apt-get update | ||
| 5 | +sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev | ||
| 6 | + | ||
| 7 | +2、下载 OpenCV 的源码。你可以从 OpenCV 官方网站(https://opencv.org/releases/)下载最新版本的源码,也可以使用 Git 克隆 OpenCV 的仓库: | ||
| 8 | +git clone https://github.com/opencv/opencv.git | ||
| 9 | + | ||
| 10 | +3、创建一个用于编译的目录,并进入该目录: | ||
| 11 | +cd opencv | ||
| 12 | +mkdir build | ||
| 13 | +cd build | ||
| 14 | + | ||
| 15 | +4、使用 CMake 配置编译选项,并启用 Java 支持: | ||
| 16 | +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_GENERATE_JAVA_WRAPPER=ON .. | ||
| 17 | +这个命令将配置编译选项,包括编译类型、安装目录,并启用 Java 支持。 | ||
| 18 | + | ||
| 19 | +5、执行 make 命令编译源码: | ||
| 20 | +make -j8 | ||
| 21 | +这个过程可能需要一些时间,取决于你的硬件性能。 | ||
| 22 | + | ||
| 23 | +6、安装编译好的 OpenCV: | ||
| 24 | +sudo make install | ||
| 25 | +这个命令将会安装编译好的 OpenCV 到指定的安装目录。 | ||
| 26 | + | ||
| 27 | +生成 libopencv_javaX.so 文件。在编译完成后,你可以在 build/lib 目录下找到生成的 libopencv_javaX.so 文件。 |
| @@ -97,6 +97,20 @@ | @@ -97,6 +97,20 @@ | ||
| 97 | <artifactId>sqlite-jdbc</artifactId> | 97 | <artifactId>sqlite-jdbc</artifactId> |
| 98 | <version>3.21.0.1</version> | 98 | <version>3.21.0.1</version> |
| 99 | </dependency> | 99 | </dependency> |
| 100 | +<!-- <dependency>--> | ||
| 101 | +<!-- <groupId>mysql</groupId>--> | ||
| 102 | +<!-- <artifactId>mysql-connector-java</artifactId>--> | ||
| 103 | +<!-- </dependency>--> | ||
| 104 | + | ||
| 105 | + <!-- mqtt --> | ||
| 106 | + <dependency> | ||
| 107 | + <groupId>org.eclipse.paho</groupId> | ||
| 108 | + <artifactId>org.eclipse.paho.client.mqttv3</artifactId> | ||
| 109 | + </dependency> | ||
| 110 | + <dependency> | ||
| 111 | + <groupId>cn.hutool</groupId> | ||
| 112 | + <artifactId>hutool-all</artifactId> | ||
| 113 | + </dependency> | ||
| 100 | </dependencies> | 114 | </dependencies> |
| 101 | 115 | ||
| 102 | <build> | 116 | <build> |
| @@ -2,6 +2,8 @@ package com.zhonglai.luhui.smart.feeder; | @@ -2,6 +2,8 @@ package com.zhonglai.luhui.smart.feeder; | ||
| 2 | 2 | ||
| 3 | import com.ruoyi.framework.config.ResourcesConfig; | 3 | import com.ruoyi.framework.config.ResourcesConfig; |
| 4 | import com.zhonglai.luhui.smart.feeder.config.OpenCVConfig; | 4 | import com.zhonglai.luhui.smart.feeder.config.OpenCVConfig; |
| 5 | +import com.zhonglai.luhui.smart.feeder.controller.CameraController; | ||
| 6 | +import com.zhonglai.luhui.smart.feeder.controller.ConfigController; | ||
| 5 | import org.springframework.boot.SpringApplication; | 7 | import org.springframework.boot.SpringApplication; |
| 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 7 | 9 | ||
| @@ -17,9 +19,10 @@ import org.springframework.scheduling.annotation.EnableScheduling; | @@ -17,9 +19,10 @@ import org.springframework.scheduling.annotation.EnableScheduling; | ||
| 17 | "com.ruoyi.framework", | 19 | "com.ruoyi.framework", |
| 18 | "com.zhonglai.luhui.datasource", | 20 | "com.zhonglai.luhui.datasource", |
| 19 | "com.zhonglai.luhui.dao", | 21 | "com.zhonglai.luhui.dao", |
| 20 | - "com.zhonglai.luhui.smart.feeder", | 22 | + "com.zhonglai.luhui.smart.feeder.controller", |
| 23 | + "com.zhonglai.luhui.smart.feeder.config", | ||
| 21 | } | 24 | } |
| 22 | - ,excludeFilters = {@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE,classes = {ResourcesConfig.class})} | 25 | + ,excludeFilters = {@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE,classes = {ResourcesConfig.class, CameraController.class, ConfigController.class})} |
| 23 | ) | 26 | ) |
| 24 | @EnableScheduling | 27 | @EnableScheduling |
| 25 | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class}) | 28 | @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class}) |
| 1 | +//package com.zhonglai.luhui.smart.feeder.config; | ||
| 2 | +// | ||
| 3 | +// | ||
| 4 | +//import com.google.gson.Gson; | ||
| 5 | +//import com.ruoyi.common.utils.GsonConstructor; | ||
| 6 | +//import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +//import org.springframework.boot.autoconfigure.http.HttpMessageConverters; | ||
| 8 | +//import org.springframework.context.annotation.Configuration; | ||
| 9 | +//import org.springframework.http.converter.HttpMessageConverter; | ||
| 10 | +//import org.springframework.http.converter.json.GsonHttpMessageConverter; | ||
| 11 | +//import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | ||
| 12 | +// | ||
| 13 | +//import java.util.ArrayList; | ||
| 14 | +//import java.util.List; | ||
| 15 | +// | ||
| 16 | +// | ||
| 17 | +//@Configuration | ||
| 18 | +//public class HttpMessageConverterConfig { | ||
| 19 | +// @Autowired | ||
| 20 | +// public void configureHttpMessageConverters(HttpMessageConverters converters, Gson gson) { | ||
| 21 | +// List<HttpMessageConverter<?>> converterList = new ArrayList<>(converters.getConverters()); | ||
| 22 | +// for (HttpMessageConverter<?> converter : converterList) { | ||
| 23 | +// if (converter instanceof MappingJackson2HttpMessageConverter) { | ||
| 24 | +// converterList.remove(converter); | ||
| 25 | +// break; | ||
| 26 | +// } | ||
| 27 | +// } | ||
| 28 | +// converterList.add(new GsonHttpMessageConverter(gson)); | ||
| 29 | +// } | ||
| 30 | +// | ||
| 31 | +//} |
| @@ -2,11 +2,8 @@ package com.zhonglai.luhui.smart.feeder.controller; | @@ -2,11 +2,8 @@ package com.zhonglai.luhui.smart.feeder.controller; | ||
| 2 | 2 | ||
| 3 | import com.ruoyi.common.core.domain.AjaxResult; | 3 | import com.ruoyi.common.core.domain.AjaxResult; |
| 4 | import com.zhonglai.luhui.smart.feeder.config.WebSocketClien; | 4 | import com.zhonglai.luhui.smart.feeder.config.WebSocketClien; |
| 5 | -import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; | ||
| 6 | -import com.zhonglai.luhui.smart.feeder.dto.VeiwType; | ||
| 7 | -import com.zhonglai.luhui.smart.feeder.service.ConfigurationParameterService; | 5 | +import com.zhonglai.luhui.smart.feeder.dto.ModbusDto; |
| 8 | import com.zhonglai.luhui.smart.feeder.service.DeviceService; | 6 | import com.zhonglai.luhui.smart.feeder.service.DeviceService; |
| 9 | -import com.zhonglai.luhui.smart.feeder.service.FishGroupImageRecognitionService; | ||
| 10 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
| 11 | import io.swagger.annotations.ApiImplicitParam; | 8 | import io.swagger.annotations.ApiImplicitParam; |
| 12 | import io.swagger.annotations.ApiImplicitParams; | 9 | import io.swagger.annotations.ApiImplicitParams; |
| @@ -68,7 +65,9 @@ public class CameraController { | @@ -68,7 +65,9 @@ public class CameraController { | ||
| 68 | @ApiOperation("串口发送指令") | 65 | @ApiOperation("串口发送指令") |
| 69 | @GetMapping("/sendSerialData") | 66 | @GetMapping("/sendSerialData") |
| 70 | public AjaxResult sendSerialData(String hexStr) throws IOException { | 67 | public AjaxResult sendSerialData(String hexStr) throws IOException { |
| 71 | - return AjaxResult.success().put("data",deviceService.sendData(hexStr)); | 68 | + hexStr = hexStr.replace(" ","").trim(); |
| 69 | + ModbusDto commdDto = deviceService.sendData(hexStr); | ||
| 70 | + return AjaxResult.success(commdDto); | ||
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | @ApiOperation("获取所有串口") | 73 | @ApiOperation("获取所有串口") |
| @@ -77,4 +76,5 @@ public class CameraController { | @@ -77,4 +76,5 @@ public class CameraController { | ||
| 77 | return AjaxResult.success().put("data",deviceService.getAllSerial()); | 76 | return AjaxResult.success().put("data",deviceService.getAllSerial()); |
| 78 | } | 77 | } |
| 79 | 78 | ||
| 79 | + | ||
| 80 | } | 80 | } |
| 1 | +package com.zhonglai.luhui.smart.feeder.controller; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 4 | +import com.zhonglai.luhui.dao.service.PublicService; | ||
| 5 | +import com.zhonglai.luhui.smart.feeder.domain.Register; | ||
| 6 | +import io.swagger.annotations.Api; | ||
| 7 | +import io.swagger.annotations.ApiOperation; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 11 | +import org.springframework.web.bind.annotation.RestController; | ||
| 12 | + | ||
| 13 | +import java.util.ArrayList; | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +@Api(tags = "寄存器管理") | ||
| 17 | +@RestController | ||
| 18 | +@RequestMapping("/register") | ||
| 19 | +public class RegisterConreoller { | ||
| 20 | + @Autowired | ||
| 21 | + private PublicService publicService; | ||
| 22 | + | ||
| 23 | + @ApiOperation("初始化定时器解析规则") | ||
| 24 | + @GetMapping("/iniTimer") | ||
| 25 | + public AjaxResult iniTimer() | ||
| 26 | + { | ||
| 27 | + List<Register> list = new ArrayList<>(); | ||
| 28 | + int startaddress = 23; | ||
| 29 | + for(int i=0;i<24;i++) | ||
| 30 | + { | ||
| 31 | + Register register = new Register(); | ||
| 32 | + register.setAddress(startaddress+i); | ||
| 33 | + register.setClas("java.lang.String"); | ||
| 34 | + register.setName("开启分钟"); | ||
| 35 | + register.setStart_char(0); | ||
| 36 | + register.setChar_lenth(8); | ||
| 37 | + register.setField_name("timer"+(register.getAddress()-22+1)+"_start_m"); | ||
| 38 | + | ||
| 39 | + Register register1 = new Register(); | ||
| 40 | + register1.setAddress(startaddress+i); | ||
| 41 | + register1.setClas("java.lang.String"); | ||
| 42 | + register1.setName("开启小时"); | ||
| 43 | + register1.setStart_char(8); | ||
| 44 | + register1.setChar_lenth(6); | ||
| 45 | + register1.setField_name("timer"+(register.getAddress()-22+1)+"_start_h"); | ||
| 46 | + | ||
| 47 | + Register register2 = new Register(); | ||
| 48 | + register2.setAddress(startaddress+i); | ||
| 49 | + register2.setClas("java.lang.Integer"); | ||
| 50 | + register2.setName("使能"); | ||
| 51 | + register2.setStart_char(14); | ||
| 52 | + register2.setChar_lenth(1); | ||
| 53 | + register2.setField_name("timer"+(register.getAddress()-22+1)+"_if_start"); | ||
| 54 | + | ||
| 55 | + Register register3 = new Register(); | ||
| 56 | + register3.setAddress(startaddress+i); | ||
| 57 | + register3.setClas("java.lang.Integer"); | ||
| 58 | + register3.setName("有效"); | ||
| 59 | + register3.setStart_char(15); | ||
| 60 | + register3.setChar_lenth(1); | ||
| 61 | + register3.setField_name("timer"+(register.getAddress()-22+1)+"_is_start"); | ||
| 62 | + | ||
| 63 | + Register register4 = new Register(); | ||
| 64 | + register4.setAddress(startaddress+i); | ||
| 65 | + register4.setClas("java.lang.String"); | ||
| 66 | + register4.setName("关闭分钟"); | ||
| 67 | + register4.setStart_char(0); | ||
| 68 | + register4.setChar_lenth(8); | ||
| 69 | + register4.setField_name("timer"+(register.getAddress()-22+1)+"_close_m"); | ||
| 70 | + | ||
| 71 | + Register register5 = new Register(); | ||
| 72 | + register5.setAddress(startaddress+i); | ||
| 73 | + register5.setClas("java.lang.String"); | ||
| 74 | + register5.setName("关闭小时"); | ||
| 75 | + register5.setStart_char(8); | ||
| 76 | + register5.setChar_lenth(6); | ||
| 77 | + register5.setField_name("timer"+(register.getAddress()-22+1)+"_close_h"); | ||
| 78 | + | ||
| 79 | + Register register6 = new Register(); | ||
| 80 | + register6.setAddress(startaddress+i); | ||
| 81 | + register6.setClas("java.lang.Integer"); | ||
| 82 | + register6.setName("使能"); | ||
| 83 | + register6.setStart_char(14); | ||
| 84 | + register6.setChar_lenth(1); | ||
| 85 | + register6.setField_name("timer"+(register.getAddress()-22+1)+"_if_close"); | ||
| 86 | + | ||
| 87 | + Register register7 = new Register(); | ||
| 88 | + register7.setAddress(startaddress+i); | ||
| 89 | + register7.setClas("java.lang.Integer"); | ||
| 90 | + register7.setName("有效"); | ||
| 91 | + register7.setStart_char(15); | ||
| 92 | + register7.setChar_lenth(1); | ||
| 93 | + register7.setField_name("timer"+(register.getAddress()-22+1)+"_is_close"); | ||
| 94 | + | ||
| 95 | + list.add(register); | ||
| 96 | + list.add(register1); | ||
| 97 | + list.add(register2); | ||
| 98 | + list.add(register3); | ||
| 99 | + list.add(register4); | ||
| 100 | + list.add(register5); | ||
| 101 | + list.add(register6); | ||
| 102 | + list.add(register7); | ||
| 103 | + | ||
| 104 | + } | ||
| 105 | + return AjaxResult.success(publicService.insertAll(list)); | ||
| 106 | + } | ||
| 107 | +} |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/domain/Register.java
0 → 100644
| 1 | +package com.zhonglai.luhui.smart.feeder.domain; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 寄存器 | ||
| 7 | + */ | ||
| 8 | +@Data | ||
| 9 | +public class Register { | ||
| 10 | + private Integer address; | ||
| 11 | + private String name; | ||
| 12 | + private Integer start_char; | ||
| 13 | + public Integer char_lenth; | ||
| 14 | + public String field_name; | ||
| 15 | + public String clas; | ||
| 16 | +} |
| @@ -2,8 +2,11 @@ package com.zhonglai.luhui.smart.feeder.dto; | @@ -2,8 +2,11 @@ package com.zhonglai.luhui.smart.feeder.dto; | ||
| 2 | 2 | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | +import java.io.Serializable; | ||
| 6 | + | ||
| 5 | @Data | 7 | @Data |
| 6 | -public class ConfigDto { | 8 | +public class ConfigDto implements Serializable { |
| 9 | + private static final long serialVersionUID = 4437689065039524585L; | ||
| 7 | private ConfigurationParameter configurationParameter; | 10 | private ConfigurationParameter configurationParameter; |
| 8 | private Object value; | 11 | private Object value; |
| 9 | } | 12 | } |
| 1 | package com.zhonglai.luhui.smart.feeder.dto; | 1 | package com.zhonglai.luhui.smart.feeder.dto; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | + | ||
| 4 | import java.util.ArrayList; | 6 | import java.util.ArrayList; |
| 5 | import java.util.HashMap; | 7 | import java.util.HashMap; |
| 6 | 8 | ||
| 9 | + | ||
| 7 | public enum ConfigurationParameter { | 10 | public enum ConfigurationParameter { |
| 8 | - ifVeiw(false, Boolean.class,"sys_config"),//是否显示 | ||
| 9 | - captureNumber(0, Integer.class,"sys_config"),//摄像头编号 | ||
| 10 | - reflectionThreshold(100, Integer.class,"sys_config"),//反光阈值 | ||
| 11 | - kernelSize(3, Integer.class,"sys_config"),//去噪调整内核大小,用来消除小的物体或噪声 | ||
| 12 | - maxValue(255.0, Double.class,"sys_config"), //最大反光阈值 | ||
| 13 | - gear_command (new HashMap<Integer,String>(),HashMap.class,"gear_command"), //档位对应的指令 | ||
| 14 | - absValue_command (new ArrayList<FishCurveControlCondition>(),ArrayList.class,"absValue_command"), //斜率范围对应的档位 | ||
| 15 | - VeiwDto_isFrame(false, Boolean.class,"sys_config"), //是否显示原图 | ||
| 16 | - VeiwDto_isBinaryImage(false, Boolean.class,"sys_config"), //是否显示临时图 | ||
| 17 | - VeiwDto_isSize(false, Boolean.class,"sys_config"), //是否显示面积 | ||
| 18 | - VeiwDto_isAbsValue(false, Boolean.class,"sys_config"), //是否显示斜率 | ||
| 19 | - absValue(0.0, Double.class,"sys_config"), //显示斜率 | ||
| 20 | - FishGroupImageRecognition(true, Boolean.class,"sys_config"), //鱼群图像识别是否开启 | ||
| 21 | - FeedingControl(true, Boolean.class,"sys_config"), //鱼群图像识别投料控制是否开启 | ||
| 22 | - SerialPortConfig(new SerialPortConfig().defaultSerialPortConfig(),com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig.class,"sys_config"),//串口配置 | 11 | + ifVeiw(false, Boolean.class,"sys_config","是否显示"),//是否显示 |
| 12 | + captureNumber(0, Integer.class,"sys_config","摄像头编号"),//摄像头编号 | ||
| 13 | + reflectionThreshold(100, Integer.class,"sys_config","反光阈值"),//反光阈值 | ||
| 14 | + kernelSize(3, Integer.class,"sys_config","去噪调整内核大小,用来消除小的物体或噪声"),//去噪调整内核大小,用来消除小的物体或噪声 | ||
| 15 | + maxValue(255, Integer.class,"sys_config","最大反光阈值"), //最大反光阈值 | ||
| 16 | + gear_command (new HashMap<String,String>(),HashMap.class,"gear_command","档位对应的指令"), //档位对应的指令 | ||
| 17 | + absValue_command (new ArrayList<FishCurveControlCondition>(),ArrayList.class,"absValue_command","斜率范围对应的档位"), //斜率范围对应的档位 | ||
| 18 | + VeiwDto_isFrame(false, Boolean.class,"sys_config","是否显示原图"), //是否显示原图 | ||
| 19 | + VeiwDto_isBinaryImage(false, Boolean.class,"sys_config","是否显示临时图"), //是否显示临时图 | ||
| 20 | + VeiwDto_isSize(false, Boolean.class,"sys_config","是否显示面积"), //是否显示面积 | ||
| 21 | + VeiwDto_isAbsValue(false, Boolean.class,"sys_config","是否显示斜率"), //是否显示斜率 | ||
| 22 | + absValue(0.0, Double.class,"sys_config","显示斜率"), //显示斜率 | ||
| 23 | + FishGroupImageRecognition(true, Boolean.class,"sys_config","鱼群图像识别是否开启"), //鱼群图像识别是否开启 | ||
| 24 | + FeedingControl(true, Boolean.class,"sys_config","鱼群图像识别投料控制是否开启"), //鱼群图像识别投料控制是否开启 | ||
| 25 | + SerialPortConfig(new SerialPortConfig().defaultSerialPortConfig(),com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig.class,"sys_config","串口配置"),//串口配置 | ||
| 23 | ; | 26 | ; |
| 24 | 27 | ||
| 25 | private Object value; | 28 | private Object value; |
| 26 | private Class<?> valuType; | 29 | private Class<?> valuType; |
| 27 | private String tableName; | 30 | private String tableName; |
| 28 | 31 | ||
| 29 | - ConfigurationParameter(Object value,Class valuType,String tableName) { | 32 | + private String describe; |
| 33 | + | ||
| 34 | + ConfigurationParameter(Object value,Class valuType,String tableName,String describe) { | ||
| 30 | this.value = value; | 35 | this.value = value; |
| 31 | this.valuType = valuType; | 36 | this.valuType = valuType; |
| 32 | this.tableName = tableName; | 37 | this.tableName = tableName; |
| 38 | + this.describe = describe; | ||
| 33 | } | 39 | } |
| 34 | 40 | ||
| 35 | public Object getValue() | 41 | public Object getValue() |
| @@ -44,4 +50,25 @@ public enum ConfigurationParameter { | @@ -44,4 +50,25 @@ public enum ConfigurationParameter { | ||
| 44 | public String getTableName() { | 50 | public String getTableName() { |
| 45 | return tableName; | 51 | return tableName; |
| 46 | } | 52 | } |
| 53 | + | ||
| 54 | + public String getDescribe() { | ||
| 55 | + return describe; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public String valueToString(Object o) | ||
| 59 | + { | ||
| 60 | + switch (getValuType().getName()) { | ||
| 61 | + case "java.lang.Boolean": | ||
| 62 | + return ((Boolean)o).toString(); | ||
| 63 | + case "java.lang.Integer": | ||
| 64 | + return o+""; | ||
| 65 | + case "java.lang.Double": | ||
| 66 | + return o+""; | ||
| 67 | + case "com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig": | ||
| 68 | + return JSONObject.toJSONString(o); | ||
| 69 | + default: | ||
| 70 | + throw new RuntimeException("配置参数类型不正确" + name() + o); | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 47 | } | 74 | } |
| 1 | package com.zhonglai.luhui.smart.feeder.dto; | 1 | package com.zhonglai.luhui.smart.feeder.dto; |
| 2 | 2 | ||
| 3 | +import java.io.Serializable; | ||
| 4 | + | ||
| 3 | /** | 5 | /** |
| 4 | * 斜率范围对应的档位 | 6 | * 斜率范围对应的档位 |
| 5 | */ | 7 | */ |
| 6 | -public class FishCurveControlCondition { | 8 | +public class FishCurveControlCondition implements Serializable { |
| 9 | + private static final long serialVersionUID = 1690616650540655976L; | ||
| 7 | private Integer sartAbsValue; //开始斜率 | 10 | private Integer sartAbsValue; //开始斜率 |
| 8 | private Integer gear; //档位 | 11 | private Integer gear; //档位 |
| 9 | 12 |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/dto/ModbusDto.java
0 → 100644
| 1 | +package com.zhonglai.luhui.smart.feeder.dto; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.core.JsonProcessingException; | ||
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 5 | +import com.ruoyi.common.utils.ByteUtil; | ||
| 6 | +import com.ruoyi.common.utils.GsonConstructor; | ||
| 7 | +import lombok.Data; | ||
| 8 | +import org.apache.commons.lang3.ArrayUtils; | ||
| 9 | + | ||
| 10 | +import java.io.Serializable; | ||
| 11 | +import java.util.HashMap; | ||
| 12 | +import java.util.Map; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * Modbus协议 | ||
| 16 | + */ | ||
| 17 | +@Data | ||
| 18 | +public class ModbusDto implements Serializable { | ||
| 19 | + private static final long serialVersionUID = -6008279428004571734L; | ||
| 20 | + protected String hstr; | ||
| 21 | + protected Integer address; //地址位 | ||
| 22 | + protected Integer commdcode; //功能码 | ||
| 23 | + protected byte[] data; //数据 | ||
| 24 | + protected String crc; //16CRC 码 | ||
| 25 | + public ModbusDto() | ||
| 26 | + { | ||
| 27 | + | ||
| 28 | + } | ||
| 29 | + public ModbusDto(byte[] bytes) | ||
| 30 | + { | ||
| 31 | + this.hstr = ByteUtil.toHexString(bytes); | ||
| 32 | + byte[] headAndData = ArrayUtils.subarray(bytes,0,bytes.length-2); | ||
| 33 | + byte[] crcByte = ArrayUtils.subarray(bytes,bytes.length-2,bytes.length); | ||
| 34 | + this.crc = ByteUtil.toHexString(crcByte).toUpperCase(); | ||
| 35 | + // 校验CRC | ||
| 36 | + if (!ByteUtil.getCRC16(headAndData).equals(crc)) { | ||
| 37 | + System.out.println("CRC校验失败"); | ||
| 38 | + return ; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + this.address = Math.toIntExact(ByteUtil.bytesToLongDESC(headAndData, 0, 1)); | ||
| 42 | + this.commdcode = Math.toIntExact(ByteUtil.bytesToLongDESC(headAndData, 1, 1)); | ||
| 43 | + this.data = ArrayUtils.subarray(headAndData,2,headAndData.length);; | ||
| 44 | + | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public ModbusDto(String str) { | ||
| 48 | + new ModbusDto(ByteUtil.hexStringToByte(str)); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + // 计算CRC校验码 | ||
| 52 | + public static String generateLRC(byte[] data) | ||
| 53 | + { | ||
| 54 | + return ByteUtil.toHexString(ByteUtil.intToBytesASC(getLRC(data),1)); | ||
| 55 | + } | ||
| 56 | + public static byte getLRC(byte[] data) { | ||
| 57 | + int tmp = 0; | ||
| 58 | + for (int i = 0; i < data.length; i++) { | ||
| 59 | + tmp = tmp + (byte) data[i]; | ||
| 60 | + } | ||
| 61 | + tmp = ~tmp; | ||
| 62 | + tmp = (tmp & (0xff)); | ||
| 63 | + tmp += 1; | ||
| 64 | + return (byte) tmp; | ||
| 65 | + } | ||
| 66 | + public static void main(String[] args) { | ||
| 67 | + String hexData = "01 03 8E 00 01 00 04 FF E0 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 07 00 03 00 00 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00".replace(" ",""); | ||
| 68 | + String crc = ByteUtil.getCRC16(ByteUtil.hexStringToByte(hexData)); | ||
| 69 | + System.out.println(crc); | ||
| 70 | + | ||
| 71 | + Map<Integer,String> map = new HashMap<>(); | ||
| 72 | + map.put(1,"ssss"); | ||
| 73 | + map.put(2,"eae"); | ||
| 74 | + try { | ||
| 75 | + System.out.println(new ObjectMapper().writeValueAsString(map)); | ||
| 76 | + } catch (JsonProcessingException e) { | ||
| 77 | + throw new RuntimeException(e); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | +} |
| @@ -2,7 +2,10 @@ package com.zhonglai.luhui.smart.feeder.dto; | @@ -2,7 +2,10 @@ package com.zhonglai.luhui.smart.feeder.dto; | ||
| 2 | 2 | ||
| 3 | import org.opencv.core.Mat; | 3 | import org.opencv.core.Mat; |
| 4 | 4 | ||
| 5 | -public class VeiwDto { | 5 | +import java.io.Serializable; |
| 6 | + | ||
| 7 | +public class VeiwDto implements Serializable { | ||
| 8 | + private static final long serialVersionUID = -6059514681715227839L; | ||
| 6 | private Mat frame; //原始图像 | 9 | private Mat frame; //原始图像 |
| 7 | private Mat binaryImage; //临时图像 | 10 | private Mat binaryImage; //临时图像 |
| 8 | private Integer size; //面积大小 | 11 | private Integer size; //面积大小 |
| 1 | +package com.zhonglai.luhui.smart.feeder.dto.commd; | ||
| 2 | + | ||
| 3 | +import com.ruoyi.common.utils.ByteUtil; | ||
| 4 | +import org.apache.commons.lang3.ArrayUtils; | ||
| 5 | + | ||
| 6 | +import java.io.Serializable; | ||
| 7 | +import java.util.HashMap; | ||
| 8 | +import java.util.Map; | ||
| 9 | + | ||
| 10 | +public class FeederCommd03Request implements FeederCommd { | ||
| 11 | + private static final long serialVersionUID = 200980498094314547L; | ||
| 12 | + private Integer lenth; | ||
| 13 | + private Map<Integer,byte[]> addressValue = new HashMap<>(); | ||
| 14 | + public FeederCommd03Request(byte[] data) | ||
| 15 | + { | ||
| 16 | + lenth = new Long(ByteUtil.bytesToLongDESC(data,0,1)).intValue()/2; | ||
| 17 | + for (int i=0;i<lenth;i++) | ||
| 18 | + { | ||
| 19 | + byte[] bytes = ArrayUtils.subarray(data,1+2*i,1+2*i+2); | ||
| 20 | + addressValue.put(i, bytes); | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | +} |
| 1 | +package com.zhonglai.luhui.smart.feeder.dto.commd; | ||
| 2 | + | ||
| 3 | +import com.zhonglai.luhui.smart.feeder.dto.ModbusDto; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.io.Serializable; | ||
| 7 | +import java.util.HashMap; | ||
| 8 | +import java.util.Map; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 投料机协议Modbus | ||
| 12 | + */ | ||
| 13 | +@Data | ||
| 14 | +public class FeederCommdDto extends ModbusDto { | ||
| 15 | + | ||
| 16 | + private static final long serialVersionUID = -2783135648395348130L; | ||
| 17 | + private Integer quantity; //寄存器数量 | ||
| 18 | + private Map<Integer,byte[]> value = new HashMap<>(); // | ||
| 19 | + | ||
| 20 | + private FeederCommd feederCommd; | ||
| 21 | + | ||
| 22 | + public FeederCommdDto(byte[] bytes) { | ||
| 23 | + super(bytes); | ||
| 24 | + | ||
| 25 | + switch (commdcode) | ||
| 26 | + { | ||
| 27 | + case 0x03: | ||
| 28 | + feederCommd = new FeederCommd03Request(this.data); | ||
| 29 | + break; | ||
| 30 | + case 0x06: | ||
| 31 | + break; | ||
| 32 | + case 0x10: | ||
| 33 | + break; | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public FeederCommdDto() { | ||
| 38 | + super(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public FeederCommdDto(String str) { | ||
| 42 | + super(str); | ||
| 43 | + } | ||
| 44 | +} |
| 1 | package com.zhonglai.luhui.smart.feeder.service; | 1 | package com.zhonglai.luhui.smart.feeder.service; |
| 2 | 2 | ||
| 3 | -import com.ruoyi.common.utils.StringUtils; | 3 | +import cn.hutool.core.bean.BeanUtil; |
| 4 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; | 4 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; |
| 5 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; | 5 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; |
| 6 | import org.ehcache.Cache; | 6 | import org.ehcache.Cache; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
| 9 | -import org.springframework.transaction.annotation.Transactional; | ||
| 10 | 9 | ||
| 11 | import javax.annotation.PostConstruct; | 10 | import javax.annotation.PostConstruct; |
| 12 | import java.util.ArrayList; | 11 | import java.util.ArrayList; |
| @@ -40,13 +39,13 @@ public class ConfigurationParameterService { | @@ -40,13 +39,13 @@ public class ConfigurationParameterService { | ||
| 40 | } | 39 | } |
| 41 | 40 | ||
| 42 | List<Map<String,Object>> gearCommandList = sqliteService.getAllGearCommand(); | 41 | List<Map<String,Object>> gearCommandList = sqliteService.getAllGearCommand(); |
| 43 | - Map<Integer,String> gearCommandMap = new HashMap<Integer,String>(); | 42 | + Map<String,String> gearCommandMap = new HashMap<String,String>(); |
| 44 | if(null != gearCommandList && gearCommandList.size() != 0) | 43 | if(null != gearCommandList && gearCommandList.size() != 0) |
| 45 | { | 44 | { |
| 46 | 45 | ||
| 47 | for(Map<String,Object> map:gearCommandList) | 46 | for(Map<String,Object> map:gearCommandList) |
| 48 | { | 47 | { |
| 49 | - gearCommandMap.put((Integer) map.get("gear"),(String)map.get("command")); | 48 | + gearCommandMap.put(map.get("gear")+"",(String)map.get("command")); |
| 50 | } | 49 | } |
| 51 | } | 50 | } |
| 52 | 51 | ||
| @@ -74,12 +73,26 @@ public class ConfigurationParameterService { | @@ -74,12 +73,26 @@ public class ConfigurationParameterService { | ||
| 74 | switch (configurationParameter) | 73 | switch (configurationParameter) |
| 75 | { | 74 | { |
| 76 | case gear_command: | 75 | case gear_command: |
| 77 | - setGearCommandMap((Map<Integer, String>) value); | 76 | + setGearCommandMap((Map<String, String>) value); |
| 78 | break; | 77 | break; |
| 79 | case absValue_command: | 78 | case absValue_command: |
| 80 | if(value instanceof ArrayList) | 79 | if(value instanceof ArrayList) |
| 81 | { | 80 | { |
| 82 | - setabsValueCommandList((List<FishCurveControlCondition>) value); | 81 | + List<FishCurveControlCondition> slist = new ArrayList<>(); |
| 82 | + for(Object object:(List) value) | ||
| 83 | + { | ||
| 84 | + if(object instanceof FishCurveControlCondition) | ||
| 85 | + { | ||
| 86 | + slist = (List) value; | ||
| 87 | + break; | ||
| 88 | + }else if (object instanceof HashMap) | ||
| 89 | + { | ||
| 90 | + FishCurveControlCondition fishCurveControlCondition = BeanUtil.mapToBean((HashMap)object,FishCurveControlCondition.class,false,null); | ||
| 91 | + slist.add(fishCurveControlCondition); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + setabsValueCommandList(slist); | ||
| 83 | }else if(value instanceof FishCurveControlCondition) | 96 | }else if(value instanceof FishCurveControlCondition) |
| 84 | { | 97 | { |
| 85 | setabsValueCommand((FishCurveControlCondition) value); | 98 | setabsValueCommand((FishCurveControlCondition) value); |
| @@ -88,44 +101,51 @@ public class ConfigurationParameterService { | @@ -88,44 +101,51 @@ public class ConfigurationParameterService { | ||
| 88 | } | 101 | } |
| 89 | break; | 102 | break; |
| 90 | default: | 103 | default: |
| 91 | - ehCacheService.writeToCache(configurationParameter,value); | ||
| 92 | - sqliteService.updateConfigurationParameter(configurationParameter,value); | 104 | + setDefaultCommandMap(configurationParameter,value); |
| 105 | + | ||
| 93 | } | 106 | } |
| 94 | 107 | ||
| 95 | } | 108 | } |
| 96 | 109 | ||
| 110 | + | ||
| 97 | public Object getConfig(ConfigurationParameter configurationParameter) | 111 | public Object getConfig(ConfigurationParameter configurationParameter) |
| 98 | { | 112 | { |
| 99 | return ehCacheService.readFromCache(configurationParameter); | 113 | return ehCacheService.readFromCache(configurationParameter); |
| 100 | } | 114 | } |
| 101 | 115 | ||
| 102 | - private void setGearCommandMap(Map<Integer,String> gearCommandMap) | 116 | + private void setDefaultCommandMap(ConfigurationParameter configurationParameter,Object value) |
| 117 | + { | ||
| 118 | + ehCacheService.writeToCache(configurationParameter,value); | ||
| 119 | + sqliteService.updateConfigurationParameter(configurationParameter,value); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + private void setGearCommandMap(Map<String,String> gearCommandMap) | ||
| 103 | { | 123 | { |
| 104 | - Map<Integer,String> old = (Map<Integer, String>) ehCacheService.readFromCache(ConfigurationParameter.gear_command); | 124 | + Map<String,String> old = (Map<String, String>) ehCacheService.readFromCache(ConfigurationParameter.gear_command); |
| 105 | if(null == old) | 125 | if(null == old) |
| 106 | { | 126 | { |
| 107 | old = gearCommandMap; | 127 | old = gearCommandMap; |
| 108 | } | 128 | } |
| 109 | - for (Integer key:gearCommandMap.keySet()) | 129 | + for (String key:gearCommandMap.keySet()) |
| 110 | { | 130 | { |
| 111 | - sqliteService.updateGearCommand(key,gearCommandMap.get(key)); | 131 | + sqliteService.updateGearCommand(Integer.parseInt(key),gearCommandMap.get(key)); |
| 132 | + old.put(key,gearCommandMap.get(key)); | ||
| 112 | } | 133 | } |
| 113 | ehCacheService.writeToCache(ConfigurationParameter.gear_command,old); | 134 | ehCacheService.writeToCache(ConfigurationParameter.gear_command,old); |
| 114 | } | 135 | } |
| 115 | 136 | ||
| 116 | private void setabsValueCommandList(List<FishCurveControlCondition> absValueCommandList) | 137 | private void setabsValueCommandList(List<FishCurveControlCondition> absValueCommandList) |
| 117 | { | 138 | { |
| 118 | - List<FishCurveControlCondition> old = (List<FishCurveControlCondition>) ehCacheService.readFromCache(ConfigurationParameter.absValue_command); | ||
| 119 | - if(null == old) | ||
| 120 | - { | ||
| 121 | - old = absValueCommandList; | ||
| 122 | - } | ||
| 123 | - ehCacheService.writeToCache(ConfigurationParameter.absValue_command,old); | 139 | + |
| 140 | + sqliteService.deleteabsValueCommandAll(); | ||
| 141 | + ehCacheService.readFromCache(ConfigurationParameter.absValue_command); | ||
| 124 | 142 | ||
| 125 | for (FishCurveControlCondition fishCurveControlCondition:absValueCommandList) | 143 | for (FishCurveControlCondition fishCurveControlCondition:absValueCommandList) |
| 126 | { | 144 | { |
| 127 | sqliteService.updateabsValueCommand(fishCurveControlCondition.getGear(),fishCurveControlCondition.getSartAbsValue()); | 145 | sqliteService.updateabsValueCommand(fishCurveControlCondition.getGear(),fishCurveControlCondition.getSartAbsValue()); |
| 128 | } | 146 | } |
| 147 | + | ||
| 148 | + ehCacheService.writeToCache(ConfigurationParameter.absValue_command,absValueCommandList); | ||
| 129 | } | 149 | } |
| 130 | 150 | ||
| 131 | private void setabsValueCommand(FishCurveControlCondition absValueCommand) | 151 | private void setabsValueCommand(FishCurveControlCondition absValueCommand) |
| 1 | +package com.zhonglai.luhui.smart.feeder.service; | ||
| 2 | + | ||
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 4 | +import org.springframework.stereotype.Service; | ||
| 5 | + | ||
| 6 | +import javax.annotation.PostConstruct; | ||
| 7 | +import java.util.concurrent.ScheduledExecutorService; | ||
| 8 | +import java.util.concurrent.TimeUnit; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 数据监听服务 | ||
| 12 | + */ | ||
| 13 | +@Service | ||
| 14 | +public class DateListenService { | ||
| 15 | + @Autowired | ||
| 16 | + private ScheduledExecutorService scheduledExecutorService; | ||
| 17 | + | ||
| 18 | + @PostConstruct | ||
| 19 | + public void run() | ||
| 20 | + { | ||
| 21 | + scheduledExecutorService.scheduleAtFixedRate(new Runnable() { | ||
| 22 | + @Override | ||
| 23 | + public void run() { | ||
| 24 | + | ||
| 25 | + } | ||
| 26 | + },1,60, TimeUnit.SECONDS); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +} |
| @@ -2,16 +2,14 @@ package com.zhonglai.luhui.smart.feeder.service; | @@ -2,16 +2,14 @@ package com.zhonglai.luhui.smart.feeder.service; | ||
| 2 | 2 | ||
| 3 | import com.ruoyi.common.utils.GsonConstructor; | 3 | import com.ruoyi.common.utils.GsonConstructor; |
| 4 | import com.ruoyi.common.utils.StringUtils; | 4 | import com.ruoyi.common.utils.StringUtils; |
| 5 | -import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; | ||
| 6 | -import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; | ||
| 7 | -import com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig; | 5 | +import com.zhonglai.luhui.smart.feeder.dto.*; |
| 6 | +import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommdDto; | ||
| 8 | import com.zhonglai.luhui.smart.feeder.util.serial.SerialTool; | 7 | import com.zhonglai.luhui.smart.feeder.util.serial.SerialTool; |
| 9 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 13 | import purejavacomm.SerialPort; | 12 | import purejavacomm.SerialPort; |
| 14 | -import purejavacomm.SerialPortEvent; | ||
| 15 | 13 | ||
| 16 | import javax.annotation.PostConstruct; | 14 | import javax.annotation.PostConstruct; |
| 17 | import java.io.IOException; | 15 | import java.io.IOException; |
| @@ -33,7 +31,7 @@ public class DeviceService { | @@ -33,7 +31,7 @@ public class DeviceService { | ||
| 33 | // 锁对象 | 31 | // 锁对象 |
| 34 | private final Object lock = new Object(); | 32 | private final Object lock = new Object(); |
| 35 | // 用于存储串口返回的数据,使用线程安全的队列 | 33 | // 用于存储串口返回的数据,使用线程安全的队列 |
| 36 | - private BlockingQueue<String> dataQueue = new LinkedBlockingQueue<>(); | 34 | + private BlockingQueue<ModbusDto> dataQueue = new LinkedBlockingQueue<>(); |
| 37 | 35 | ||
| 38 | private Double backArea; //上一个大小 | 36 | private Double backArea; //上一个大小 |
| 39 | 37 | ||
| @@ -182,25 +180,12 @@ public class DeviceService { | @@ -182,25 +180,12 @@ public class DeviceService { | ||
| 182 | } | 180 | } |
| 183 | serialPort = SerialTool.openPort(portName,baudrate,dataBits,stopBits,parity); | 181 | serialPort = SerialTool.openPort(portName,baudrate,dataBits,stopBits,parity); |
| 184 | SerialTool.addListener(serialPortEvent -> { | 182 | SerialTool.addListener(serialPortEvent -> { |
| 185 | - switch (serialPortEvent.getEventType()) | ||
| 186 | - { | ||
| 187 | - case SerialPortEvent.DATA_AVAILABLE: | ||
| 188 | - byte[] readBuffer = null; | ||
| 189 | - int availableBytes = 0; | ||
| 190 | - try { | ||
| 191 | - availableBytes = serialPort.getInputStream().available(); | ||
| 192 | - if (availableBytes > 0) { | ||
| 193 | - try { | ||
| 194 | - readBuffer = SerialTool.readFromPort(serialPort); | ||
| 195 | - String data = SerialTool.bytesToHexString(readBuffer); | ||
| 196 | - dataQueue.offer(data); // 将数据添加到队列中// 处理串口返回的数据 | ||
| 197 | - } catch (Exception e) { | ||
| 198 | - logger.error("读取推送信息异常!"+e); | ||
| 199 | - } | ||
| 200 | - } | ||
| 201 | - } catch (IOException e) { | ||
| 202 | - logger.error("读取流信息异常!"+e); | ||
| 203 | - } | 183 | + try { |
| 184 | + Thread.sleep(500); | ||
| 185 | + FeederCommdDto commdDto = new FeederCommdDto(SerialTool.readFromPort(serialPort)); | ||
| 186 | + dataQueue.offer(commdDto); // 将数据添加到队列中// 处理串口返回的数据 | ||
| 187 | + } catch (Exception e) { | ||
| 188 | + logger.error("返回数据处理异常",e); | ||
| 204 | } | 189 | } |
| 205 | }, serialPort); | 190 | }, serialPort); |
| 206 | } | 191 | } |
| @@ -210,12 +195,12 @@ public class DeviceService { | @@ -210,12 +195,12 @@ public class DeviceService { | ||
| 210 | * @param hexStr | 195 | * @param hexStr |
| 211 | * @throws IOException | 196 | * @throws IOException |
| 212 | */ | 197 | */ |
| 213 | - public String sendData(String hexStr) throws IOException { | 198 | + public ModbusDto sendData(String hexStr) throws IOException { |
| 214 | synchronized (lock) | 199 | synchronized (lock) |
| 215 | { | 200 | { |
| 216 | SerialTool.sendToPort(SerialTool.HexString2Bytes(hexStr),serialPort); | 201 | SerialTool.sendToPort(SerialTool.HexString2Bytes(hexStr),serialPort); |
| 217 | try { | 202 | try { |
| 218 | - String reStr = dataQueue.take(); | 203 | + ModbusDto reStr = dataQueue.poll(15,TimeUnit.SECONDS); |
| 219 | return reStr; | 204 | return reStr; |
| 220 | } catch (InterruptedException e) { | 205 | } catch (InterruptedException e) { |
| 221 | logger.error("等待串口返回数据异常!" + e); | 206 | logger.error("等待串口返回数据异常!" + e); |
| @@ -224,4 +209,6 @@ public class DeviceService { | @@ -224,4 +209,6 @@ public class DeviceService { | ||
| 224 | return null; | 209 | return null; |
| 225 | } | 210 | } |
| 226 | 211 | ||
| 212 | + | ||
| 213 | + | ||
| 227 | } | 214 | } |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/service/EhCacheService.java
| @@ -70,7 +70,6 @@ public class EhCacheService { | @@ -70,7 +70,6 @@ public class EhCacheService { | ||
| 70 | myCache.put(key.name(), cls.cast(value)); | 70 | myCache.put(key.name(), cls.cast(value)); |
| 71 | }else if(value instanceof String) | 71 | }else if(value instanceof String) |
| 72 | { | 72 | { |
| 73 | - | ||
| 74 | switch (cls.getName()) | 73 | switch (cls.getName()) |
| 75 | { | 74 | { |
| 76 | case "java.lang.Boolean": | 75 | case "java.lang.Boolean": |
| @@ -141,9 +141,15 @@ public class FishGroupImageRecognitionService { | @@ -141,9 +141,15 @@ public class FishGroupImageRecognitionService { | ||
| 141 | // 逐帧处理视频 | 141 | // 逐帧处理视频 |
| 142 | Mat frame = new Mat(); | 142 | Mat frame = new Mat(); |
| 143 | scheduledExecutorService.scheduleWithFixedDelay(() -> { | 143 | scheduledExecutorService.scheduleWithFixedDelay(() -> { |
| 144 | - if (((Boolean)configurationParameterService.getConfig(ConfigurationParameter.FishGroupImageRecognition)) && videoCapture.read(frame)) { | ||
| 145 | - identify(frame,largestContour); | 144 | + try { |
| 145 | + if (((Boolean)configurationParameterService.getConfig(ConfigurationParameter.FishGroupImageRecognition)) && videoCapture.read(frame)) { | ||
| 146 | + identify(frame,largestContour); | ||
| 147 | + } | ||
| 148 | + }catch (Exception e) | ||
| 149 | + { | ||
| 150 | + logger.error("检测摄像头异常",e); | ||
| 146 | } | 151 | } |
| 152 | + | ||
| 147 | },0,1, TimeUnit.SECONDS); | 153 | },0,1, TimeUnit.SECONDS); |
| 148 | 154 | ||
| 149 | } | 155 | } |
| @@ -238,7 +244,7 @@ public class FishGroupImageRecognitionService { | @@ -238,7 +244,7 @@ public class FishGroupImageRecognitionService { | ||
| 238 | // 检测反光 | 244 | // 检测反光 |
| 239 | Mat binaryImage = new Mat(); | 245 | Mat binaryImage = new Mat(); |
| 240 | 246 | ||
| 241 | - Imgproc.threshold(grayImage, binaryImage, reflectionThreshold, (Double) configurationParameterService.getConfig(ConfigurationParameter.maxValue), Imgproc.THRESH_BINARY); | 247 | + Imgproc.threshold(grayImage, binaryImage, reflectionThreshold, (Integer) configurationParameterService.getConfig(ConfigurationParameter.maxValue), Imgproc.THRESH_BINARY); |
| 242 | 248 | ||
| 243 | // 进行形态学操作,去除噪点 | 249 | // 进行形态学操作,去除噪点 |
| 244 | Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((Integer) configurationParameterService.getConfig(ConfigurationParameter.kernelSize),(Integer) configurationParameterService.getConfig(ConfigurationParameter.kernelSize))); | 250 | Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size((Integer) configurationParameterService.getConfig(ConfigurationParameter.kernelSize),(Integer) configurationParameterService.getConfig(ConfigurationParameter.kernelSize))); |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/service/MqttCallback.java
0 → 100644
| 1 | +package com.zhonglai.luhui.smart.feeder.service; | ||
| 2 | + | ||
| 3 | +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; | ||
| 4 | +import org.eclipse.paho.client.mqttv3.MqttCallbackExtended; | ||
| 5 | +import org.eclipse.paho.client.mqttv3.MqttException; | ||
| 6 | +import org.eclipse.paho.client.mqttv3.MqttMessage; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.stereotype.Component; | ||
| 10 | + | ||
| 11 | +@Component | ||
| 12 | +public class MqttCallback implements MqttCallbackExtended { | ||
| 13 | + | ||
| 14 | + private static final Logger log = LoggerFactory.getLogger(MqttCallback.class); | ||
| 15 | + | ||
| 16 | + @Override | ||
| 17 | + public void connectComplete(boolean b, String s) { | ||
| 18 | + log.info("连接成功"); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + @Override | ||
| 22 | + public void connectionLost(Throwable cause) { | ||
| 23 | + log.error("连接丢失",cause); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public void messageArrived(String topic, MqttMessage message) throws Exception { | ||
| 28 | + | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public void deliveryComplete(IMqttDeliveryToken token) { | ||
| 33 | + // 成功发出消息 | ||
| 34 | + try { | ||
| 35 | + log.info("成功发出消息 messageid{}",token.getMessage()); | ||
| 36 | + } catch (MqttException e) { | ||
| 37 | + e.printStackTrace(); | ||
| 38 | + } | ||
| 39 | + } | ||
| 40 | +} |
| 1 | package com.zhonglai.luhui.smart.feeder.service; | 1 | package com.zhonglai.luhui.smart.feeder.service; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.ruoyi.common.utils.GsonConstructor; | ||
| 3 | import com.zhonglai.luhui.dao.service.PublicService; | 5 | import com.zhonglai.luhui.dao.service.PublicService; |
| 4 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; | 6 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; |
| 5 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; | 7 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; |
| @@ -153,14 +155,21 @@ public class SqliteService { | @@ -153,14 +155,21 @@ public class SqliteService { | ||
| 153 | switch (key) | 155 | switch (key) |
| 154 | { | 156 | { |
| 155 | case gear_command: | 157 | case gear_command: |
| 156 | - Map<Integer,String> map = (Map<Integer, String>) value; | ||
| 157 | -// publicService.updateBySql("update set ") | 158 | + Map<String,String> map = (Map<String, String>) value; |
| 159 | + for(String gear:map.keySet()) | ||
| 160 | + { | ||
| 161 | + updateGearCommand(Integer.parseInt(gear),map.get(gear)); | ||
| 162 | + } | ||
| 158 | break; | 163 | break; |
| 159 | case absValue_command: | 164 | case absValue_command: |
| 160 | - | 165 | + List<FishCurveControlCondition> list = (List<FishCurveControlCondition>) value; |
| 166 | + for(FishCurveControlCondition fishCurveControlCondition:list) | ||
| 167 | + { | ||
| 168 | + updateabsValueCommand(fishCurveControlCondition.getGear(),fishCurveControlCondition.getSartAbsValue()); | ||
| 169 | + } | ||
| 161 | break; | 170 | break; |
| 162 | default: | 171 | default: |
| 163 | - | 172 | + updateSysConfig(key, key.valueToString(value)); |
| 164 | break; | 173 | break; |
| 165 | } | 174 | } |
| 166 | } | 175 | } |
| @@ -168,19 +177,23 @@ public class SqliteService { | @@ -168,19 +177,23 @@ public class SqliteService { | ||
| 168 | public void updateSysConfig(ConfigurationParameter key,String value) | 177 | public void updateSysConfig(ConfigurationParameter key,String value) |
| 169 | { | 178 | { |
| 170 | publicService.updateBySql("delete from sys_config where parameter_name='"+key.name()+"'"); | 179 | publicService.updateBySql("delete from sys_config where parameter_name='"+key.name()+"'"); |
| 171 | - publicService.updateBySql("insert into sys_config('"+key.name()+"','"+value+"')"); | 180 | + publicService.updateBySql("insert into sys_config(`parameter_name`,`parameter_value`,`describe`) values ('"+key.name()+"','"+value+"','"+key.getDescribe()+"')"); |
| 172 | } | 181 | } |
| 173 | 182 | ||
| 174 | public void updateGearCommand(Integer gear,String command) | 183 | public void updateGearCommand(Integer gear,String command) |
| 175 | { | 184 | { |
| 176 | publicService.updateBySql("delete from gear_command where gear="+gear+""); | 185 | publicService.updateBySql("delete from gear_command where gear="+gear+""); |
| 177 | - publicService.updateBySql("insert into gear_command("+gear+",'"+command+"')"); | 186 | + publicService.updateBySql("insert into gear_command(`gear`,`command`) values ("+gear+",'"+command+"')"); |
| 178 | } | 187 | } |
| 179 | 188 | ||
| 180 | public void updateabsValueCommand(Integer gear,Integer sartAbsValue) | 189 | public void updateabsValueCommand(Integer gear,Integer sartAbsValue) |
| 181 | { | 190 | { |
| 182 | - publicService.updateBySql("delete from absValue_command where gear="+gear+""); | ||
| 183 | - publicService.updateBySql("insert into absValue_command("+gear+",'"+sartAbsValue+"')"); | 191 | + publicService.updateBySql("delete from absValue_command where sartAbsValue="+sartAbsValue+""); |
| 192 | + publicService.updateBySql("insert into absValue_command(`gear`,`sartAbsValue`) values ("+gear+",'"+sartAbsValue+"')"); | ||
| 184 | } | 193 | } |
| 185 | 194 | ||
| 195 | + public void deleteabsValueCommandAll() | ||
| 196 | + { | ||
| 197 | + publicService.updateBySql("delete from absValue_command "); | ||
| 198 | + } | ||
| 186 | } | 199 | } |
| 1 | +package com.zhonglai.luhui.smart.feeder.service; | ||
| 2 | + | ||
| 3 | +import org.eclipse.paho.client.mqttv3.MqttClient; | ||
| 4 | +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; | ||
| 5 | +import org.eclipse.paho.client.mqttv3.MqttException; | ||
| 6 | +import org.eclipse.paho.client.mqttv3.MqttMessage; | ||
| 7 | +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; | ||
| 8 | +import org.slf4j.Logger; | ||
| 9 | +import org.slf4j.LoggerFactory; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.beans.factory.annotation.Value; | ||
| 12 | +import org.springframework.stereotype.Service; | ||
| 13 | + | ||
| 14 | +import javax.annotation.PostConstruct; | ||
| 15 | +import java.util.ArrayList; | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 终端服务 | ||
| 20 | + */ | ||
| 21 | +@Service | ||
| 22 | +public class TerminalService { | ||
| 23 | + private static final Logger log = LoggerFactory.getLogger(TerminalService.class); | ||
| 24 | + | ||
| 25 | + private MqttClient mqttclient; | ||
| 26 | + private MqttConnectOptions options; | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + private MqttCallback mqttCallback; | ||
| 30 | + | ||
| 31 | + @Value("${mqtt.broker}") | ||
| 32 | + private String broker; | ||
| 33 | + @Value("${mqtt.clientId}") | ||
| 34 | + private String clientId; | ||
| 35 | + | ||
| 36 | + @Value("#{'${mqtt.topics}'.split(',')}") | ||
| 37 | + private List<String> topics; | ||
| 38 | + | ||
| 39 | + @Value("${mqtt.sub_clientid}") | ||
| 40 | + private String sub_clientid; | ||
| 41 | + | ||
| 42 | + @Value("#{'${mqtt.mqtt_usernames}'.split(',')}") | ||
| 43 | + private List<String> mqtt_usernames; | ||
| 44 | + | ||
| 45 | + @Value("${mqtt.roleid}") | ||
| 46 | + private String roleid; | ||
| 47 | + | ||
| 48 | + @Value("${mqtt.username}") | ||
| 49 | + private String username; | ||
| 50 | + @Value("${mqtt.password}") | ||
| 51 | + private String password; | ||
| 52 | + | ||
| 53 | + @PostConstruct | ||
| 54 | + public void startMqttListenerService() throws MqttException{ | ||
| 55 | + log.info("-----------开始启动mqtt监听服务--------------------"); | ||
| 56 | + init(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + private void init() throws MqttException { | ||
| 61 | + if(null == mqttclient) | ||
| 62 | + { | ||
| 63 | + mqttclient = new MqttClient(broker, clientId, new MemoryPersistence()); | ||
| 64 | + } | ||
| 65 | + options = new MqttConnectOptions(); | ||
| 66 | + options.setCleanSession(true); | ||
| 67 | + options.setConnectionTimeout(15); | ||
| 68 | + //设置断开后重新连接 | ||
| 69 | + options.setAutomaticReconnect(true); | ||
| 70 | + mqttclient.setCallback(mqttCallback); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + private void connect() throws MqttException { | ||
| 74 | + options.setUserName(username); | ||
| 75 | + options.setPassword(password.toCharArray()); | ||
| 76 | + mqttclient.connect(options); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void subscribe() throws MqttException { | ||
| 80 | + List<String> ts = getCompletionTopics(); | ||
| 81 | + mqttclient.subscribe(ts.toArray(new String[ts.size()])); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public List<String> getCompletionTopics() | ||
| 85 | + { | ||
| 86 | + List<String> ts = new ArrayList<>(); | ||
| 87 | + for(String mqtt_username:mqtt_usernames) | ||
| 88 | + { | ||
| 89 | + StringBuffer topic = new StringBuffer(); | ||
| 90 | + topic.append("/"); | ||
| 91 | + topic.append(roleid); | ||
| 92 | + topic.append("/"); | ||
| 93 | + topic.append(mqtt_username); | ||
| 94 | + topic.append("/"); | ||
| 95 | + topic.append(sub_clientid); | ||
| 96 | + topic.append("/"); | ||
| 97 | + topic.append("+"); | ||
| 98 | + for(String tc:topics) | ||
| 99 | + { | ||
| 100 | + StringBuffer t = new StringBuffer(topic); | ||
| 101 | + t.append("/"); | ||
| 102 | + t.append(tc); | ||
| 103 | + | ||
| 104 | + ts.add(t.toString()); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + return ts; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + public void publish(String topic, MqttMessage message) throws MqttException { | ||
| 111 | + mqttclient.publish(topic,message); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + public void publish(String topic, String messageStr) throws MqttException { | ||
| 115 | + MqttMessage message = new MqttMessage(); | ||
| 116 | + message.setPayload(messageStr.getBytes()); | ||
| 117 | + mqttclient.publish(topic,message); | ||
| 118 | + } | ||
| 119 | +} |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/service/WebSocketSever.java
| 1 | package com.zhonglai.luhui.smart.feeder.service; | 1 | package com.zhonglai.luhui.smart.feeder.service; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.ruoyi.common.core.domain.AjaxResult; | ||
| 3 | import com.ruoyi.common.utils.GsonConstructor; | 5 | import com.ruoyi.common.utils.GsonConstructor; |
| 4 | import com.ruoyi.common.utils.StringUtils; | 6 | import com.ruoyi.common.utils.StringUtils; |
| 5 | import com.zhonglai.luhui.smart.feeder.config.WebSocketClien; | 7 | import com.zhonglai.luhui.smart.feeder.config.WebSocketClien; |
| @@ -47,6 +49,7 @@ public class WebSocketSever { | @@ -47,6 +49,7 @@ public class WebSocketSever { | ||
| 47 | WebSocketClien.webSocketSet.add(this); | 49 | WebSocketClien.webSocketSet.add(this); |
| 48 | WebSocketClien.sessionPool.put(userId, session); | 50 | WebSocketClien.sessionPool.put(userId, session); |
| 49 | log.info("建立连接完成,当前在线人数为:{}", WebSocketClien.webSocketSet.size()); | 51 | log.info("建立连接完成,当前在线人数为:{}", WebSocketClien.webSocketSet.size()); |
| 52 | + sendMessageByUser(userId,AjaxResult.success("链接成功").toString()); | ||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | /** | 55 | /** |
| @@ -114,7 +117,7 @@ public class WebSocketSever { | @@ -114,7 +117,7 @@ public class WebSocketSever { | ||
| 114 | { | 117 | { |
| 115 | webSocketVO.setStateData(deviceService.getState()); | 118 | webSocketVO.setStateData(deviceService.getState()); |
| 116 | } | 119 | } |
| 117 | - session.getBasicRemote().sendText(GsonConstructor.get().toJson(webSocketVO)); | 120 | + session.getBasicRemote().sendText(JSONObject.toJSONString(webSocketVO)); |
| 118 | } catch (IOException e) { | 121 | } catch (IOException e) { |
| 119 | log.error("推送消息到指定用户发生错误:" + e.getMessage(), e); | 122 | log.error("推送消息到指定用户发生错误:" + e.getMessage(), e); |
| 120 | } | 123 | } |
| 1 | -# 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8064 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 # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # 防止XSS攻击 xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* sys: staticPath: "file:E:/work/idea/Luhui/lh-modules/lh-smart-feeder/src/main/resources/static/" cacheFilePath: "E:/work/idea/Luhui/lh-modules/lh-smart-feeder/cache/" # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain,com.zhonglai.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # 数据源配置 spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: org.sqlite.JDBC druid: # 主库数据源 master: url: jdbc:sqlite:db/my.db username: password: # 从库数据源 slave: # 从数据源开关/默认关闭 enabled: false url: username: password: # 初始连接数 initialSize: 5 # 最小连接池数量 minIdle: 10 # 最大连接池数量 maxActive: 20 # 配置获取连接等待超时的时间 maxWait: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 timeBetweenEvictionRunsMillis: 60000 # 配置一个连接在池中最小生存的时间,单位是毫秒 minEvictableIdleTimeMillis: 300000 # 配置一个连接在池中最大生存的时间,单位是毫秒 maxEvictableIdleTimeMillis: 900000 # 配置检测连接是否有效 validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false webStatFilter: enabled: true statViewServlet: enabled: true # 设置白名单,不填则允许所有访问 allow: url-pattern: /druid/* # 控制台管理用户名和密码 login-username: ruoyi login-password: 123456 filter: stat: enabled: true # 慢SQL记录 log-slow-sql: true slow-sql-millis: 1000 merge-sql: true wall: config: multi-statement-allow: true | ||
| 1 | +# 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8064 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 # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # 防止XSS攻击 xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* sys: staticPath: "file:E:/work/idea/Luhui/lh-modules/lh-smart-feeder/src/main/resources/static/" cacheFilePath: "E:/work/idea/Luhui/lh-modules/lh-smart-feeder/cache/" # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain,com.zhonglai.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # 数据源配置 spring: autoconfigure: exclude: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: org.sqlite.JDBC druid: # 主库数据源 master: url: jdbc:sqlite:db/my.db username: password: # 从库数据源 slave: # 从数据源开关/默认关闭 enabled: false url: username: password: # 初始连接数 initialSize: 5 # 最小连接池数量 minIdle: 10 # 最大连接池数量 maxActive: 20 # 配置获取连接等待超时的时间 maxWait: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 timeBetweenEvictionRunsMillis: 60000 # 配置一个连接在池中最小生存的时间,单位是毫秒 minEvictableIdleTimeMillis: 300000 # 配置一个连接在池中最大生存的时间,单位是毫秒 maxEvictableIdleTimeMillis: 900000 # 配置检测连接是否有效 validationQuery: SELECT 1 testWhileIdle: true testOnBorrow: false testOnReturn: false webStatFilter: enabled: true statViewServlet: enabled: true # 设置白名单,不填则允许所有访问 allow: url-pattern: /druid/* # 控制台管理用户名和密码 login-username: ruoyi login-password: 123456 filter: stat: enabled: true # 慢SQL记录 log-slow-sql: true slow-sql-millis: 1000 merge-sql: true wall: config: multi-statement-allow: true ## 数据源配置 #spring: # datasource: # type: com.alibaba.druid.pool.DruidDataSource # driverClassName: com.mysql.cj.jdbc.Driver # druid: # # 主库数据源 # master: # url: jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # username: luhui # password: Luhui586 # # 从库数据源 # slave: # # 从数据源开关/默认关闭 # enabled: true # url: jdbc:mysql://119.23.218.181:3306/lh-server-ops?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # username: luhui # password: Luhui586 # # 初始连接数 # initialSize: 5 # # 最小连接池数量 # minIdle: 10 # # 最大连接池数量 # maxActive: 20 # # 配置获取连接等待超时的时间 # maxWait: 60000 # # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 # timeBetweenEvictionRunsMillis: 60000 # # 配置一个连接在池中最小生存的时间,单位是毫秒 # minEvictableIdleTimeMillis: 300000 # # 配置一个连接在池中最大生存的时间,单位是毫秒 # maxEvictableIdleTimeMillis: 900000 # # 配置检测连接是否有效 # validationQuery: SELECT 1 FROM DUAL # testWhileIdle: true # testOnBorrow: false # testOnReturn: false # webStatFilter: # enabled: true # statViewServlet: # enabled: true # # 设置白名单,不填则允许所有访问 # allow: # url-pattern: /druid/* # # 控制台管理用户名和密码 # login-username: ruoyi # login-password: 123456 # filter: # stat: # enabled: true # # 慢SQL记录 # log-slow-sql: true # slow-sql-millis: 1000 # merge-sql: true # wall: # config: # multi-statement-allow: true mqtt: #链接地址 broker: tcp://175.24.61.68:1883 #唯一标识 clientId: 70094a59d1d991d #公司id roleid: 2 mqtt_usernames: NWDB_2023 #订阅的topic topics: ADD_POST,ALL_POST,DB_TOPIC_DISTRIBUTE,GET/+,online,PUT_REQ/+,READ_REQ/+ sub_clientid: '70094a59d1d991d' topicconfig: "/{{roleid}}/{{username}}/{{clientid}}/{{payloadtype}}/{{topicType}}/{{messageid}}" top_return_map: '{"PUT":"PUT_REQ","READ":"READ_REQ"}' username: sysuser password: "!@#1qaz" client: #客户端操作时间 operationTime: 10 |
| @@ -340,6 +340,12 @@ | @@ -340,6 +340,12 @@ | ||
| 340 | <version>${ruoyi.version}</version> | 340 | <version>${ruoyi.version}</version> |
| 341 | </dependency> | 341 | </dependency> |
| 342 | 342 | ||
| 343 | + <dependency> | ||
| 344 | + <groupId>com.zhonglai.luhui</groupId> | ||
| 345 | + <artifactId>lh-jar-order-service</artifactId> | ||
| 346 | + <version>${ruoyi.version}</version> | ||
| 347 | + </dependency> | ||
| 348 | + | ||
| 343 | <!-- 支持data --> | 349 | <!-- 支持data --> |
| 344 | <dependency> | 350 | <dependency> |
| 345 | <groupId>org.projectlombok</groupId> | 351 | <groupId>org.projectlombok</groupId> |
-
请 注册 或 登录 后发表评论