正在显示
42 个修改的文件
包含
1097 行增加
和
258 行删除
| @@ -188,4 +188,32 @@ public class ByteUtil { | @@ -188,4 +188,32 @@ public class ByteUtil { | ||
| 188 | crc = crc.substring(2, 4) + crc.substring(0, 2); | 188 | crc = crc.substring(2, 4) + crc.substring(0, 2); |
| 189 | return crc.toUpperCase(); | 189 | return crc.toUpperCase(); |
| 190 | } | 190 | } |
| 191 | + | ||
| 192 | + /** | ||
| 193 | + * 用于从一个 long 值中指定的起始位置和结束位置读取位数据。该方法使用位掩码操作来获取指定位范围内的数据。 | ||
| 194 | + * @param value | ||
| 195 | + * @param startPosition | ||
| 196 | + * @param endPosition | ||
| 197 | + * @return | ||
| 198 | + */ | ||
| 199 | + public static long readBits(long value, int startPosition, int endPosition) { | ||
| 200 | + long mask = (1L << (endPosition - startPosition + 1)) - 1; | ||
| 201 | + return (value >> startPosition) & mask; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + /** | ||
| 205 | + * 用于简化给变量的不同位赋值的操作。该方法接收四个参数:value 是要被赋值的变量,bitValue 是要赋给指定位的值,startPosition 和 endPosition 是指定位的起始位置和结束位置。 | ||
| 206 | + * @param value | ||
| 207 | + * @param bitValue | ||
| 208 | + * @param startPosition | ||
| 209 | + * @param endPosition | ||
| 210 | + * @return | ||
| 211 | + */ | ||
| 212 | + public static int assignBits(int value, int bitValue, int startPosition, int endPosition) { | ||
| 213 | + int mask = ((1 << (endPosition - startPosition + 1)) - 1) << startPosition; | ||
| 214 | + value &= ~mask; | ||
| 215 | + value |= (bitValue << startPosition); | ||
| 216 | + return value; | ||
| 217 | + } | ||
| 218 | + | ||
| 191 | } | 219 | } |
| @@ -161,6 +161,7 @@ public class BusinessDataUpdateService { | @@ -161,6 +161,7 @@ public class BusinessDataUpdateService { | ||
| 161 | { | 161 | { |
| 162 | String id = olddevice.getClient_id()+"_"+key; | 162 | String id = olddevice.getClient_id()+"_"+key; |
| 163 | SaveDataDto saveDataDto = dataModeAnalysisService.analysisThingsModelValue( id,olddevice.getMqtt_username(),jsData,serverDto); | 163 | SaveDataDto saveDataDto = dataModeAnalysisService.analysisThingsModelValue( id,olddevice.getMqtt_username(),jsData,serverDto); |
| 164 | + | ||
| 164 | IotTerminal terminal = new IotTerminal(); | 165 | IotTerminal terminal = new IotTerminal(); |
| 165 | terminal.setId(id); | 166 | terminal.setId(id); |
| 166 | terminal.setDevice_id(olddevice.getClient_id()); | 167 | terminal.setDevice_id(olddevice.getClient_id()); |
| @@ -169,6 +170,11 @@ public class BusinessDataUpdateService { | @@ -169,6 +170,11 @@ public class BusinessDataUpdateService { | ||
| 169 | //更新数据 | 170 | //更新数据 |
| 170 | IotTerminal oldterminal = cacheService.getIotTerminal(id); | 171 | IotTerminal oldterminal = cacheService.getIotTerminal(id); |
| 171 | 172 | ||
| 173 | + if(null == saveDataDto) | ||
| 174 | + { | ||
| 175 | + logger.info("无法解析到入库数据"); | ||
| 176 | + return terminal; | ||
| 177 | + } | ||
| 172 | //记录操作日志 | 178 | //记录操作日志 |
| 173 | if(null != oldterminal && ("ADD".equals(type.name())|| "READ".equals(type.name()))) | 179 | if(null != oldterminal && ("ADD".equals(type.name())|| "READ".equals(type.name()))) |
| 174 | { | 180 | { |
| @@ -184,6 +190,7 @@ public class BusinessDataUpdateService { | @@ -184,6 +190,7 @@ public class BusinessDataUpdateService { | ||
| 184 | String str = (null!=oldterminal?oldterminal.getThings_model_config():null); | 190 | String str = (null!=oldterminal?oldterminal.getThings_model_config():null); |
| 185 | terminal.setThings_model_config(deviceService.getNewAdddate(id,str,saveDataDto.getConfig(),serverDto.getLogDeviceOperationList(),operationType,isLog).toJSONString()); | 191 | terminal.setThings_model_config(deviceService.getNewAdddate(id,str,saveDataDto.getConfig(),serverDto.getLogDeviceOperationList(),operationType,isLog).toJSONString()); |
| 186 | terminal.setName(oldterminal.getName()); | 192 | terminal.setName(oldterminal.getName()); |
| 193 | + | ||
| 187 | return terminal; | 194 | return terminal; |
| 188 | } | 195 | } |
| 189 | 196 |
| @@ -9,7 +9,6 @@ import org.springframework.context.annotation.ComponentScan; | @@ -9,7 +9,6 @@ import org.springframework.context.annotation.ComponentScan; | ||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | @ComponentScan(basePackages = { | 11 | @ComponentScan(basePackages = { |
| 12 | - "com.zhonglai.luhui.mqtt.comm.config", | ||
| 13 | "com.zhonglai.luhui.device.analysis", | 12 | "com.zhonglai.luhui.device.analysis", |
| 14 | "com.zhonglai.luhui.mqtt.comm.service", | 13 | "com.zhonglai.luhui.mqtt.comm.service", |
| 15 | "com.zhonglai.luhui.mqtt.comm.rocketMq", | 14 | "com.zhonglai.luhui.mqtt.comm.rocketMq", |
| @@ -29,6 +29,7 @@ public class TopicUtil { | @@ -29,6 +29,7 @@ public class TopicUtil { | ||
| 29 | String cf = config[i].replace("{{","").replace("}}",""); | 29 | String cf = config[i].replace("{{","").replace("}}",""); |
| 30 | try { | 30 | try { |
| 31 | Field field = topicObject.getClass().getDeclaredField(cf); | 31 | Field field = topicObject.getClass().getDeclaredField(cf); |
| 32 | + field.setAccessible(true); | ||
| 32 | field.set(topicObject,sts[i]); | 33 | field.set(topicObject,sts[i]); |
| 33 | } catch (NoSuchFieldException e) { | 34 | } catch (NoSuchFieldException e) { |
| 34 | log.info("{}生成topic时没有属性{}",topic,cf); | 35 | log.info("{}生成topic时没有属性{}",topic,cf); |
| @@ -46,7 +46,7 @@ mqtt: | @@ -46,7 +46,7 @@ mqtt: | ||
| 46 | clientId: ${random.uuid} | 46 | clientId: ${random.uuid} |
| 47 | #公司id | 47 | #公司id |
| 48 | roleid: 2 | 48 | roleid: 2 |
| 49 | - mqtt_usernames: NWDB_2023 | 49 | + mqtt_usernames: 12_ZNZY |
| 50 | #订阅的topic | 50 | #订阅的topic |
| 51 | topics: ADD_POST,ALL_POST,DB_TOPIC_DISTRIBUTE,GET/+,online,PUT_REQ/+,READ_REQ/+ | 51 | topics: ADD_POST,ALL_POST,DB_TOPIC_DISTRIBUTE,GET/+,online,PUT_REQ/+,READ_REQ/+ |
| 52 | sub_clientid: '+' | 52 | sub_clientid: '+' |
lh-modules/lh-smart-feeder/bin/guard.sh
0 → 100644
| 1 | +#!/bin/bash | ||
| 2 | +# 如果编码格式有问题执行:sed -i 's/\r$//' guard.sh | ||
| 3 | +# 定义要检查的 JAR 文件名和启动命令 | ||
| 4 | +JAR_FILE="lh-smart-feeder.jar" | ||
| 5 | +START_COMMAND="java -jar $JAR_FILE" | ||
| 6 | + | ||
| 7 | +# 检查 JAR 程序是否在运行 | ||
| 8 | +is_running() { | ||
| 9 | + pgrep -f "$JAR_FILE" >/dev/null 2>&1 | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +# 启动 JAR 程序 | ||
| 13 | +start_program() { | ||
| 14 | + /opt/lh-smart-feeder/lh-smart-feeder/start.sh | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +# 检查 JAR 程序是否在运行 | ||
| 18 | +if ! is_running; then | ||
| 19 | + echo "JAR程序未启动,将在3秒后自动启动..." | ||
| 20 | + sleep 3 | ||
| 21 | + start_program | ||
| 22 | +else | ||
| 23 | + echo "JAR程序已启动" | ||
| 24 | +fi |
lh-modules/lh-smart-feeder/bin/start.sh
0 → 100644
| 1 | +#!/bin/bash | ||
| 2 | + | ||
| 3 | +# 设置Java运行环境的路径 | ||
| 4 | +export JAVA_HOME=/opt/lh-smart-feeder/jdk1.8.0_202/ | ||
| 5 | + | ||
| 6 | +# 设置jar文件路径和名称 | ||
| 7 | +JAR_FILE=/opt/lh-smart-feeder/lh-smart-feeder/lh-smart-feeder.jar | ||
| 8 | + | ||
| 9 | +# 配置文件路径和名称 | ||
| 10 | +CONFIG_FILE=/opt/lh-smart-feeder/lh-smart-feeder/application.yml | ||
| 11 | + | ||
| 12 | +# 设置opencv的驱动路径 | ||
| 13 | +OPENCV_JAVA_PATH=/opt/lh-smart-feeder/lh-smart-feeder/libopencv_java451.so | ||
| 14 | + | ||
| 15 | +# 执行jar文件 | ||
| 16 | +$JAVA_HOME/bin/java -jar -Xms1024m -Xmx1024m -Xss512k $JAR_FILE $OPENCV_JAVA_PATH --spring.config.location=$CONFIG_FILE 2>&1 & |
lh-modules/lh-smart-feeder/bin/stop.sh
0 → 100644
| @@ -9,8 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; | @@ -9,8 +9,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| 9 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
| 11 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | 11 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| 12 | -import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
| 13 | -import org.springframework.context.annotation.Bean; | ||
| 14 | import org.springframework.context.annotation.ComponentScan; | 12 | import org.springframework.context.annotation.ComponentScan; |
| 15 | import org.springframework.context.annotation.FilterType; | 13 | import org.springframework.context.annotation.FilterType; |
| 16 | import org.springframework.scheduling.annotation.EnableScheduling; | 14 | import org.springframework.scheduling.annotation.EnableScheduling; |
| @@ -14,18 +14,19 @@ import java.util.ArrayList; | @@ -14,18 +14,19 @@ import java.util.ArrayList; | ||
| 14 | import java.util.List; | 14 | import java.util.List; |
| 15 | 15 | ||
| 16 | 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 | -} | 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 | +// | ||
| 29 | +// converterList.add(new GsonHttpMessageConverter(gson)); | ||
| 30 | +// } | ||
| 31 | +// | ||
| 32 | +//} |
| @@ -52,15 +52,15 @@ public class SwaggerConfig { | @@ -52,15 +52,15 @@ public class SwaggerConfig { | ||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | - * 解决/v2/api-docs返回多了一层value的问题 | ||
| 56 | - * @return | ||
| 57 | - */ | ||
| 58 | - @Bean | ||
| 59 | - public FilterRegistrationBean someFilterRegistration() { | ||
| 60 | - FilterRegistrationBean registration = new FilterRegistrationBean(); | ||
| 61 | - registration.setFilter(new ResponseFilter()); | ||
| 62 | - // 过滤的地址 | ||
| 63 | - registration.addUrlPatterns("/v2/api-docs"); | ||
| 64 | - return registration; | ||
| 65 | - } | 55 | +// * 解决/v2/api-docs返回多了一层value的问题 |
| 56 | +// * @return | ||
| 57 | +// */ | ||
| 58 | +// @Bean | ||
| 59 | +// public FilterRegistrationBean someFilterRegistration() { | ||
| 60 | +// FilterRegistrationBean registration = new FilterRegistrationBean(); | ||
| 61 | +// registration.setFilter(new ResponseFilter()); | ||
| 62 | +// // 过滤的地址 | ||
| 63 | +// registration.addUrlPatterns("/v2/api-docs"); | ||
| 64 | +// return registration; | ||
| 65 | +// } | ||
| 66 | } | 66 | } |
| 1 | package com.zhonglai.luhui.smart.feeder.config.manager; | 1 | package com.zhonglai.luhui.smart.feeder.config.manager; |
| 2 | 2 | ||
| 3 | +import com.zhonglai.luhui.smart.feeder.service.DeviceService; | ||
| 3 | import com.zhonglai.luhui.smart.feeder.service.EhCacheService; | 4 | import com.zhonglai.luhui.smart.feeder.service.EhCacheService; |
| 5 | +import com.zhonglai.luhui.smart.feeder.service.TerminalService; | ||
| 4 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 5 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -21,11 +23,19 @@ public class ShutdownManager | @@ -21,11 +23,19 @@ public class ShutdownManager | ||
| 21 | @Autowired | 23 | @Autowired |
| 22 | private EhCacheService ehCacheService; | 24 | private EhCacheService ehCacheService; |
| 23 | 25 | ||
| 26 | + @Autowired | ||
| 27 | + private DeviceService deviceService; | ||
| 28 | + | ||
| 29 | + @Autowired | ||
| 30 | + private TerminalService terminalService; | ||
| 31 | + | ||
| 24 | @PreDestroy | 32 | @PreDestroy |
| 25 | public void destroy() | 33 | public void destroy() |
| 26 | { | 34 | { |
| 27 | - shutdownAsyncManager(); | 35 | + terminalService.close(); |
| 36 | + deviceService.close(); | ||
| 28 | ehCacheService.shutdown(); | 37 | ehCacheService.shutdown(); |
| 38 | + shutdownAsyncManager(); | ||
| 29 | } | 39 | } |
| 30 | 40 | ||
| 31 | /** | 41 | /** |
| @@ -4,6 +4,8 @@ import com.ruoyi.common.core.domain.AjaxResult; | @@ -4,6 +4,8 @@ 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.ModbusDto; | 5 | import com.zhonglai.luhui.smart.feeder.dto.ModbusDto; |
| 6 | import com.zhonglai.luhui.smart.feeder.service.DeviceService; | 6 | import com.zhonglai.luhui.smart.feeder.service.DeviceService; |
| 7 | +import com.zhonglai.luhui.smart.feeder.util.FeederCommd06ResponseType; | ||
| 8 | +import com.zhonglai.luhui.smart.feeder.util.FeederCommdUtil; | ||
| 7 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| 8 | import io.swagger.annotations.ApiImplicitParam; | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 9 | import io.swagger.annotations.ApiImplicitParams; | 11 | import io.swagger.annotations.ApiImplicitParams; |
| @@ -62,6 +64,20 @@ public class CameraController { | @@ -62,6 +64,20 @@ public class CameraController { | ||
| 62 | return AjaxResult.success(); | 64 | return AjaxResult.success(); |
| 63 | } | 65 | } |
| 64 | 66 | ||
| 67 | + @ApiOperation("强行打开串口") | ||
| 68 | + @ApiImplicitParams({ | ||
| 69 | + @ApiImplicitParam(value = "串口名称",name = "portName"), | ||
| 70 | + @ApiImplicitParam(value = "波特率",name = "baudrate"), | ||
| 71 | + @ApiImplicitParam(value = "数据位",name = "dataBits"), | ||
| 72 | + @ApiImplicitParam(value = "停止位",name = "stopBits"), | ||
| 73 | + @ApiImplicitParam(value = "校验位",name = "parity"), | ||
| 74 | + }) | ||
| 75 | + @GetMapping("/nowOpenSerial") | ||
| 76 | + public AjaxResult nowOpenSerial(String portName, Integer baudrate, Integer dataBits, Integer stopBits,Integer parity) throws Exception { | ||
| 77 | + deviceService.nowOpenSerial(portName,baudrate,dataBits,stopBits,parity); | ||
| 78 | + return AjaxResult.success(); | ||
| 79 | + } | ||
| 80 | + | ||
| 65 | @ApiOperation("串口发送指令") | 81 | @ApiOperation("串口发送指令") |
| 66 | @GetMapping("/sendSerialData") | 82 | @GetMapping("/sendSerialData") |
| 67 | public AjaxResult sendSerialData(String hexStr) throws IOException { | 83 | public AjaxResult sendSerialData(String hexStr) throws IOException { |
| @@ -70,6 +86,13 @@ public class CameraController { | @@ -70,6 +86,13 @@ public class CameraController { | ||
| 70 | return AjaxResult.success(commdDto); | 86 | return AjaxResult.success(commdDto); |
| 71 | } | 87 | } |
| 72 | 88 | ||
| 89 | + @ApiOperation("地址发送指令") | ||
| 90 | + @GetMapping("/controlData") | ||
| 91 | + public AjaxResult controlData(FeederCommd06ResponseType feederCommd06ResponseType,int value) throws IOException { | ||
| 92 | + ModbusDto commdDto = deviceService.sendData(FeederCommdUtil.controlData( feederCommd06ResponseType, value)); | ||
| 93 | + return AjaxResult.success(commdDto); | ||
| 94 | + } | ||
| 95 | + | ||
| 73 | @ApiOperation("获取所有串口") | 96 | @ApiOperation("获取所有串口") |
| 74 | @GetMapping("/getAllSerial") | 97 | @GetMapping("/getAllSerial") |
| 75 | public AjaxResult getAllSerial() { | 98 | public AjaxResult getAllSerial() { |
| @@ -26,71 +26,72 @@ public class RegisterConreoller { | @@ -26,71 +26,72 @@ public class RegisterConreoller { | ||
| 26 | { | 26 | { |
| 27 | List<Register> list = new ArrayList<>(); | 27 | List<Register> list = new ArrayList<>(); |
| 28 | int startaddress = 23; | 28 | int startaddress = 23; |
| 29 | - for(int i=0;i<24;i++) | 29 | + for(int i=0;i<48;i+=2) |
| 30 | { | 30 | { |
| 31 | + int timerNumber = i/2+1; | ||
| 31 | Register register = new Register(); | 32 | Register register = new Register(); |
| 32 | register.setAddress(startaddress+i); | 33 | register.setAddress(startaddress+i); |
| 33 | - register.setClas("java.lang.String"); | 34 | + register.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); |
| 34 | register.setName("开启分钟"); | 35 | register.setName("开启分钟"); |
| 35 | register.setStart_char(0); | 36 | register.setStart_char(0); |
| 36 | register.setChar_lenth(8); | 37 | register.setChar_lenth(8); |
| 37 | - register.setField_name("timer"+(register.getAddress()-22+1)+"_start_m"); | 38 | + register.setField_name("timer"+timerNumber+"_start_m"); |
| 38 | 39 | ||
| 39 | Register register1 = new Register(); | 40 | Register register1 = new Register(); |
| 40 | register1.setAddress(startaddress+i); | 41 | register1.setAddress(startaddress+i); |
| 41 | - register1.setClas("java.lang.String"); | 42 | + register1.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); |
| 42 | register1.setName("开启小时"); | 43 | register1.setName("开启小时"); |
| 43 | register1.setStart_char(8); | 44 | register1.setStart_char(8); |
| 44 | register1.setChar_lenth(6); | 45 | register1.setChar_lenth(6); |
| 45 | - register1.setField_name("timer"+(register1.getAddress()-22+1)+"_start_h"); | 46 | + register1.setField_name("timer"+timerNumber+"_start_h"); |
| 46 | 47 | ||
| 47 | Register register2 = new Register(); | 48 | Register register2 = new Register(); |
| 48 | register2.setAddress(startaddress+i); | 49 | register2.setAddress(startaddress+i); |
| 49 | - register2.setClas("java.lang.Integer"); | 50 | + register2.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); |
| 50 | register2.setName("使能"); | 51 | register2.setName("使能"); |
| 51 | register2.setStart_char(14); | 52 | register2.setStart_char(14); |
| 52 | register2.setChar_lenth(1); | 53 | register2.setChar_lenth(1); |
| 53 | - register2.setField_name("timer"+(register2.getAddress()-22+1)+"_if_start"); | 54 | + register2.setField_name("timer"+timerNumber+"_if_start"); |
| 54 | 55 | ||
| 55 | Register register3 = new Register(); | 56 | Register register3 = new Register(); |
| 56 | register3.setAddress(startaddress+i); | 57 | register3.setAddress(startaddress+i); |
| 57 | - register3.setClas("java.lang.Integer"); | 58 | + register3.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); |
| 58 | register3.setName("有效"); | 59 | register3.setName("有效"); |
| 59 | register3.setStart_char(15); | 60 | register3.setStart_char(15); |
| 60 | register3.setChar_lenth(1); | 61 | register3.setChar_lenth(1); |
| 61 | - register3.setField_name("timer"+(register3.getAddress()-22+1)+"_is_start"); | 62 | + register3.setField_name("timer"+timerNumber+"_is_start"); |
| 62 | 63 | ||
| 63 | Register register4 = new Register(); | 64 | Register register4 = new Register(); |
| 64 | - register4.setAddress(startaddress+i); | ||
| 65 | - register4.setClas("java.lang.String"); | 65 | + register4.setAddress(startaddress+1+i); |
| 66 | + register4.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); | ||
| 66 | register4.setName("关闭分钟"); | 67 | register4.setName("关闭分钟"); |
| 67 | register4.setStart_char(0); | 68 | register4.setStart_char(0); |
| 68 | register4.setChar_lenth(8); | 69 | register4.setChar_lenth(8); |
| 69 | - register4.setField_name("timer"+(register4.getAddress()-22+1)+"_close_m"); | 70 | + register4.setField_name("timer"+timerNumber+"_close_m"); |
| 70 | 71 | ||
| 71 | Register register5 = new Register(); | 72 | Register register5 = new Register(); |
| 72 | - register5.setAddress(startaddress+i); | ||
| 73 | - register5.setClas("java.lang.String"); | 73 | + register5.setAddress(startaddress+1+i); |
| 74 | + register5.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); | ||
| 74 | register5.setName("关闭小时"); | 75 | register5.setName("关闭小时"); |
| 75 | register5.setStart_char(8); | 76 | register5.setStart_char(8); |
| 76 | register5.setChar_lenth(6); | 77 | register5.setChar_lenth(6); |
| 77 | - register5.setField_name("timer"+(register5.getAddress()-22+1)+"_close_h"); | 78 | + register5.setField_name("timer"+timerNumber+"_close_h"); |
| 78 | 79 | ||
| 79 | Register register6 = new Register(); | 80 | Register register6 = new Register(); |
| 80 | - register6.setAddress(startaddress+i); | ||
| 81 | - register6.setClas("java.lang.Integer"); | 81 | + register6.setAddress(startaddress+1+i); |
| 82 | + register6.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); | ||
| 82 | register6.setName("使能"); | 83 | register6.setName("使能"); |
| 83 | register6.setStart_char(14); | 84 | register6.setStart_char(14); |
| 84 | register6.setChar_lenth(1); | 85 | register6.setChar_lenth(1); |
| 85 | - register6.setField_name("timer"+(register6.getAddress()-22+1)+"_if_close"); | 86 | + register6.setField_name("timer"+timerNumber+"_if_close"); |
| 86 | 87 | ||
| 87 | Register register7 = new Register(); | 88 | Register register7 = new Register(); |
| 88 | - register7.setAddress(startaddress+i); | ||
| 89 | - register7.setClas("java.lang.Integer"); | 89 | + register7.setAddress(startaddress+1+i); |
| 90 | + register7.setClas("com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer"); | ||
| 90 | register7.setName("有效"); | 91 | register7.setName("有效"); |
| 91 | register7.setStart_char(15); | 92 | register7.setStart_char(15); |
| 92 | register7.setChar_lenth(1); | 93 | register7.setChar_lenth(1); |
| 93 | - register7.setField_name("timer"+(register7.getAddress()-22+1)+"_is_close"); | 94 | + register7.setField_name("timer"+timerNumber+"_is_close"); |
| 94 | 95 | ||
| 95 | list.add(register); | 96 | list.add(register); |
| 96 | list.add(register1); | 97 | list.add(register1); |
| @@ -8,12 +8,12 @@ import java.util.HashMap; | @@ -8,12 +8,12 @@ import java.util.HashMap; | ||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | public enum ConfigurationParameter { | 10 | public enum ConfigurationParameter { |
| 11 | + ifUpLoadData(false, Boolean.class,"sys_config","是否上报数据",true),//是否上报数据 | ||
| 11 | ifVeiw(false, Boolean.class,"sys_config","是否显示",true),//是否显示 | 12 | ifVeiw(false, Boolean.class,"sys_config","是否显示",true),//是否显示 |
| 12 | captureNumber(0, Integer.class,"sys_config","摄像头编号",true),//摄像头编号 | 13 | captureNumber(0, Integer.class,"sys_config","摄像头编号",true),//摄像头编号 |
| 13 | reflectionThreshold(100, Integer.class,"sys_config","反光阈值",true),//反光阈值 | 14 | reflectionThreshold(100, Integer.class,"sys_config","反光阈值",true),//反光阈值 |
| 14 | kernelSize(3, Integer.class,"sys_config","去噪调整内核大小,用来消除小的物体或噪声",true),//去噪调整内核大小,用来消除小的物体或噪声 | 15 | kernelSize(3, Integer.class,"sys_config","去噪调整内核大小,用来消除小的物体或噪声",true),//去噪调整内核大小,用来消除小的物体或噪声 |
| 15 | maxValue(255, Integer.class,"sys_config","最大反光阈值",true), //最大反光阈值 | 16 | maxValue(255, Integer.class,"sys_config","最大反光阈值",true), //最大反光阈值 |
| 16 | - gear_command (new HashMap<String,String>(),HashMap.class,"gear_command","档位对应的指令",true), //档位对应的指令 | ||
| 17 | absValue_command (new ArrayList<FishCurveControlCondition>(),ArrayList.class,"absValue_command","斜率范围对应的档位",true), //斜率范围对应的档位 | 17 | absValue_command (new ArrayList<FishCurveControlCondition>(),ArrayList.class,"absValue_command","斜率范围对应的档位",true), //斜率范围对应的档位 |
| 18 | VeiwDto_isFrame(false, Boolean.class,"sys_config","是否显示原图",true), //是否显示原图 | 18 | VeiwDto_isFrame(false, Boolean.class,"sys_config","是否显示原图",true), //是否显示原图 |
| 19 | VeiwDto_isBinaryImage(false, Boolean.class,"sys_config","是否显示临时图",true), //是否显示临时图 | 19 | VeiwDto_isBinaryImage(false, Boolean.class,"sys_config","是否显示临时图",true), //是否显示临时图 |
| @@ -21,17 +21,17 @@ public enum ConfigurationParameter { | @@ -21,17 +21,17 @@ public enum ConfigurationParameter { | ||
| 21 | VeiwDto_isAbsValue(false, Boolean.class,"sys_config","是否显示斜率",true), //是否显示斜率 | 21 | VeiwDto_isAbsValue(false, Boolean.class,"sys_config","是否显示斜率",true), //是否显示斜率 |
| 22 | absValue(0.0, Double.class,"sys_config","显示斜率",false), //斜率 | 22 | absValue(0.0, Double.class,"sys_config","显示斜率",false), //斜率 |
| 23 | FishGroupImageRecognition(true, Boolean.class,"sys_config","鱼群图像识别是否开启",true), //鱼群图像识别是否开启 | 23 | FishGroupImageRecognition(true, Boolean.class,"sys_config","鱼群图像识别是否开启",true), //鱼群图像识别是否开启 |
| 24 | - FeedingControl(true, Boolean.class,"sys_config","鱼群图像识别投料控制是否开启",true), //鱼群图像识别投料控制是否开启 | 24 | + FeedingControl(true, Boolean.class,"sys_config","鱼群图像识别控制投料控制是否开启",true), //鱼群图像识别投料控制是否开启 |
| 25 | SerialPortConfig(new SerialPortConfig().defaultSerialPortConfig(),com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig.class,"sys_config","串口配置",true),//串口配置 | 25 | SerialPortConfig(new SerialPortConfig().defaultSerialPortConfig(),com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig.class,"sys_config","串口配置",true),//串口配置 |
| 26 | ; | 26 | ; |
| 27 | 27 | ||
| 28 | - private Object value; | ||
| 29 | - private Class<?> valuType; | ||
| 30 | - private String tableName; | 28 | + private Object value; //值 |
| 29 | + private Class<?> valuType; //数据类型 | ||
| 30 | + private String tableName; //表名 | ||
| 31 | 31 | ||
| 32 | - private String describe; | 32 | + private String describe; //描述 |
| 33 | 33 | ||
| 34 | - private Boolean persistence; | 34 | + private Boolean persistence; //是否需要持久化 |
| 35 | 35 | ||
| 36 | ConfigurationParameter(Object value,Class valuType,String tableName,String describe,Boolean persistence) { | 36 | ConfigurationParameter(Object value,Class valuType,String tableName,String describe,Boolean persistence) { |
| 37 | this.value = value; | 37 | this.value = value; |
| @@ -72,6 +72,10 @@ public enum ConfigurationParameter { | @@ -72,6 +72,10 @@ public enum ConfigurationParameter { | ||
| 72 | case "java.lang.Double": | 72 | case "java.lang.Double": |
| 73 | return o+""; | 73 | return o+""; |
| 74 | case "com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig": | 74 | case "com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig": |
| 75 | + if(o instanceof String) | ||
| 76 | + { | ||
| 77 | + return (String) o; | ||
| 78 | + } | ||
| 75 | return JSONObject.toJSONString(o); | 79 | return JSONObject.toJSONString(o); |
| 76 | default: | 80 | default: |
| 77 | throw new RuntimeException("配置参数类型不正确" + name() + o); | 81 | throw new RuntimeException("配置参数类型不正确" + name() + o); |
| @@ -24,6 +24,11 @@ public class ModbusDto implements Serializable { | @@ -24,6 +24,11 @@ public class ModbusDto implements Serializable { | ||
| 24 | 24 | ||
| 25 | public ModbusDto(Integer address,Integer commdcode,byte[] data) | 25 | public ModbusDto(Integer address,Integer commdcode,byte[] data) |
| 26 | { | 26 | { |
| 27 | + toModbusDto(address,commdcode,data); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + protected void toModbusDto(Integer address,Integer commdcode,byte[] data) | ||
| 31 | + { | ||
| 27 | this.address = address; | 32 | this.address = address; |
| 28 | this.commdcode = commdcode; | 33 | this.commdcode = commdcode; |
| 29 | this.data = data; | 34 | this.data = data; |
| @@ -71,22 +76,11 @@ public class ModbusDto implements Serializable { | @@ -71,22 +76,11 @@ public class ModbusDto implements Serializable { | ||
| 71 | // 计算CRC校验码 | 76 | // 计算CRC校验码 |
| 72 | public static String generateLRC(byte[] data) | 77 | public static String generateLRC(byte[] data) |
| 73 | { | 78 | { |
| 74 | - return ByteUtil.toHexString(ByteUtil.intToBytesASC(getLRC(data),1)); | 79 | + return ByteUtil.getCRC16(data); |
| 75 | } | 80 | } |
| 76 | - public static byte getLRC(byte[] data) { | ||
| 77 | - int tmp = 0; | ||
| 78 | - for (int i = 0; i < data.length; i++) { | ||
| 79 | - tmp = tmp + (byte) data[i]; | ||
| 80 | - } | ||
| 81 | - tmp = ~tmp; | ||
| 82 | - tmp = (tmp & (0xff)); | ||
| 83 | - tmp += 1; | ||
| 84 | - return (byte) tmp; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | 81 | ||
| 88 | public static void main(String[] args) { | 82 | public static void main(String[] args) { |
| 89 | - 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(" ",""); | 83 | + String hexData = "01 03 00 0D 00 01".replace(" ",""); |
| 90 | String crc = ByteUtil.getCRC16(ByteUtil.hexStringToByte(hexData)); | 84 | String crc = ByteUtil.getCRC16(ByteUtil.hexStringToByte(hexData)); |
| 91 | System.out.println(crc); | 85 | System.out.println(crc); |
| 92 | 86 |
| @@ -20,10 +20,10 @@ public class SerialPortConfig implements Serializable { | @@ -20,10 +20,10 @@ public class SerialPortConfig implements Serializable { | ||
| 20 | 20 | ||
| 21 | public SerialPortConfig defaultSerialPortConfig() | 21 | public SerialPortConfig defaultSerialPortConfig() |
| 22 | { | 22 | { |
| 23 | - portName = "COM6"; | ||
| 24 | - baudrate = 9600; | 23 | + portName = "COM3"; |
| 24 | + baudrate = 19200; | ||
| 25 | dataBits = 8; | 25 | dataBits = 8; |
| 26 | - stopBits = 0; | 26 | + stopBits = 1; |
| 27 | parity = 0; | 27 | parity = 0; |
| 28 | return this; | 28 | return this; |
| 29 | } | 29 | } |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/dto/StateData.java
0 → 100644
| 1 | +package com.zhonglai.luhui.smart.feeder.dto; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 状态数据 | ||
| 5 | + */ | ||
| 6 | +public class StateData { | ||
| 7 | + private Integer faultcode; //故障代码 | ||
| 8 | + | ||
| 9 | + private Integer fodderstate; //饲料状态 | ||
| 10 | + | ||
| 11 | + private Integer runmode; //运行模式 | ||
| 12 | + | ||
| 13 | + private Integer runspeed; //投料量 | ||
| 14 | + | ||
| 15 | + private Integer worktime; //投料时间 | ||
| 16 | + | ||
| 17 | + private Integer interval; //间隔时间 | ||
| 18 | + | ||
| 19 | + private Integer switch_status; //开/关 | ||
| 20 | + | ||
| 21 | + private Integer stopfeedcnt; //停投料倒计时 | ||
| 22 | + | ||
| 23 | + public Integer getFaultcode() { | ||
| 24 | + return faultcode; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public void setFaultcode(Integer faultcode) { | ||
| 28 | + this.faultcode = faultcode; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public Integer getFodderstate() { | ||
| 32 | + return fodderstate; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void setFodderstate(Integer fodderstate) { | ||
| 36 | + this.fodderstate = fodderstate; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public Integer getRunmode() { | ||
| 40 | + return runmode; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public void setRunmode(Integer runmode) { | ||
| 44 | + this.runmode = runmode; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public Integer getRunspeed() { | ||
| 48 | + return runspeed; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public void setRunspeed(Integer runspeed) { | ||
| 52 | + this.runspeed = runspeed; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public Integer getWorktime() { | ||
| 56 | + return worktime; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setWorktime(Integer worktime) { | ||
| 60 | + this.worktime = worktime; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public Integer getInterval() { | ||
| 64 | + return interval; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setInterval(Integer interval) { | ||
| 68 | + this.interval = interval; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public Integer getSwitch_status() { | ||
| 72 | + return switch_status; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void setSwitch_status(Integer switch_status) { | ||
| 76 | + this.switch_status = switch_status; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public Integer getStopfeedcnt() { | ||
| 80 | + return stopfeedcnt; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public void setStopfeedcnt(Integer stopfeedcnt) { | ||
| 84 | + this.stopfeedcnt = stopfeedcnt; | ||
| 85 | + } | ||
| 86 | +} |
| @@ -20,4 +20,19 @@ public class FeederCommd03Request implements FeederCommd { | @@ -20,4 +20,19 @@ public class FeederCommd03Request implements FeederCommd { | ||
| 20 | } | 20 | } |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | + public Integer getLenth() { | ||
| 24 | + return lenth; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public void setLenth(Integer lenth) { | ||
| 28 | + this.lenth = lenth; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public Map<Integer, byte[]> getAddressValue() { | ||
| 32 | + return addressValue; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void setAddressValue(Map<Integer, byte[]> addressValue) { | ||
| 36 | + this.addressValue = addressValue; | ||
| 37 | + } | ||
| 23 | } | 38 | } |
| 1 | package com.zhonglai.luhui.smart.feeder.dto.commd; | 1 | package com.zhonglai.luhui.smart.feeder.dto.commd; |
| 2 | 2 | ||
| 3 | - | 3 | +/** |
| 4 | + * 读取用指令对象 | ||
| 5 | + */ | ||
| 4 | public class FeederCommd03Response implements FeederCommd{ | 6 | public class FeederCommd03Response implements FeederCommd{ |
| 5 | - private static final long serialVersionUID = -5498638326172560045L; | 7 | + private static final long serialVersionUID = 7305511069956383139L; |
| 6 | private Integer start_char; | 8 | private Integer start_char; |
| 7 | private Integer char_lenth; | 9 | private Integer char_lenth; |
| 8 | 10 |
| 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.util.HashMap; | ||
| 7 | +import java.util.Map; | ||
| 8 | + | ||
| 9 | +public class FeederCommd06Request implements FeederCommd { | ||
| 10 | + private static final long serialVersionUID = -6014991157685504839L; | ||
| 11 | + private Integer register_address; //寄存器地址位 | ||
| 12 | + private Integer value; //值 | ||
| 13 | + public FeederCommd06Request(byte[] data) | ||
| 14 | + { | ||
| 15 | + register_address = new Long(ByteUtil.bytesToLongDESC(data,0,2)).intValue(); | ||
| 16 | + value = new Long(ByteUtil.bytesToLongDESC(data,2,2)).intValue(); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public Integer getRegister_address() { | ||
| 20 | + return register_address; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setRegister_address(Integer register_address) { | ||
| 24 | + this.register_address = register_address; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public Integer getValue() { | ||
| 28 | + return value; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setValue(Integer value) { | ||
| 32 | + this.value = value; | ||
| 33 | + } | ||
| 34 | +} |
| 1 | +package com.zhonglai.luhui.smart.feeder.dto.commd; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 单个写入用指令对象 | ||
| 5 | + */ | ||
| 6 | +public class FeederCommd06Response implements FeederCommd{ | ||
| 7 | + private static final long serialVersionUID = 3192313530334923453L; | ||
| 8 | + private Integer register_address; //寄存器地址位 | ||
| 9 | + private Integer value; //值 | ||
| 10 | + | ||
| 11 | + public FeederCommd06Response(Integer register_address, Integer value) | ||
| 12 | + { | ||
| 13 | + this.register_address = register_address; | ||
| 14 | + this.value = value; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public Integer getRegister_address() { | ||
| 18 | + return register_address; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public void setRegister_address(Integer register_address) { | ||
| 22 | + this.register_address = register_address; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public Integer getValue() { | ||
| 26 | + return value; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public void setValue(Integer value) { | ||
| 30 | + this.value = value; | ||
| 31 | + } | ||
| 32 | +} |
| 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.util.HashMap; | ||
| 7 | +import java.util.Map; | ||
| 8 | + | ||
| 9 | +public class FeederCommd10Request implements FeederCommd { | ||
| 10 | + private static final long serialVersionUID = -1133094844579154481L; | ||
| 11 | + private Integer start_char; //起始地址位 | ||
| 12 | + private Integer register_number; //寄存器个数 | ||
| 13 | + private Integer byte_lenth; //字节个数 | ||
| 14 | + private byte[] data; //数据 | ||
| 15 | + public FeederCommd10Request(byte[] data) | ||
| 16 | + { | ||
| 17 | + start_char = new Long(ByteUtil.bytesToLongDESC(data,0,2)).intValue(); | ||
| 18 | + register_number = new Long(ByteUtil.bytesToLongDESC(data,2,2)).intValue(); | ||
| 19 | + byte_lenth = new Long(ByteUtil.bytesToLongDESC(data,4,2)).intValue(); | ||
| 20 | + data = ArrayUtils.subarray(data,6,6+byte_lenth); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public Integer getStart_char() { | ||
| 24 | + return start_char; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public void setStart_char(Integer start_char) { | ||
| 28 | + this.start_char = start_char; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public Integer getRegister_number() { | ||
| 32 | + return register_number; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void setRegister_number(Integer register_number) { | ||
| 36 | + this.register_number = register_number; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public Integer getByte_lenth() { | ||
| 40 | + return byte_lenth; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public void setByte_lenth(Integer byte_lenth) { | ||
| 44 | + this.byte_lenth = byte_lenth; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public byte[] getData() { | ||
| 48 | + return data; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public void setData(byte[] data) { | ||
| 52 | + this.data = data; | ||
| 53 | + } | ||
| 54 | +} |
| 1 | +package com.zhonglai.luhui.smart.feeder.dto.commd; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 多个写入用指令对象 | ||
| 5 | + */ | ||
| 6 | +public class FeederCommd10Response implements FeederCommd{ | ||
| 7 | + private static final long serialVersionUID = 7575699996080249797L; | ||
| 8 | + private Integer start_char; //起始地址位 | ||
| 9 | + private Integer register_number; //寄存器个数 | ||
| 10 | + private Integer byte_lenth; //字节个数 | ||
| 11 | + private byte[] data; //数据 | ||
| 12 | + | ||
| 13 | + public FeederCommd10Response(Integer start_char, Integer register_number,Integer byte_lenth,byte[] data) | ||
| 14 | + { | ||
| 15 | + this.start_char = start_char; | ||
| 16 | + this.register_number = register_number; | ||
| 17 | + this.byte_lenth = byte_lenth; | ||
| 18 | + this.data = data; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public Integer getStart_char() { | ||
| 22 | + return start_char; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public void setStart_char(Integer start_char) { | ||
| 26 | + this.start_char = start_char; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public Integer getRegister_number() { | ||
| 30 | + return register_number; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public void setRegister_number(Integer register_number) { | ||
| 34 | + this.register_number = register_number; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public Integer getByte_lenth() { | ||
| 38 | + return byte_lenth; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public void setByte_lenth(Integer byte_lenth) { | ||
| 42 | + this.byte_lenth = byte_lenth; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public byte[] getData() { | ||
| 46 | + return data; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setData(byte[] data) { | ||
| 50 | + this.data = data; | ||
| 51 | + } | ||
| 52 | +} |
| 1 | package com.zhonglai.luhui.smart.feeder.dto.commd; | 1 | package com.zhonglai.luhui.smart.feeder.dto.commd; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.ArrayUtil; | ||
| 4 | +import com.ruoyi.common.utils.ByteUtil; | ||
| 3 | import com.zhonglai.luhui.smart.feeder.dto.ModbusDto; | 5 | import com.zhonglai.luhui.smart.feeder.dto.ModbusDto; |
| 4 | -import lombok.Data; | ||
| 5 | - | ||
| 6 | -import java.util.HashMap; | ||
| 7 | -import java.util.Map; | ||
| 8 | 6 | ||
| 9 | /** | 7 | /** |
| 10 | * 投料机协议Modbus | 8 | * 投料机协议Modbus |
| @@ -12,38 +10,49 @@ import java.util.Map; | @@ -12,38 +10,49 @@ import java.util.Map; | ||
| 12 | public class FeederCommdDto extends ModbusDto { | 10 | public class FeederCommdDto extends ModbusDto { |
| 13 | 11 | ||
| 14 | private static final long serialVersionUID = -2783135648395348130L; | 12 | private static final long serialVersionUID = -2783135648395348130L; |
| 15 | - private Integer quantity; //寄存器数量 | ||
| 16 | - private Map<Integer,byte[]> value = new HashMap<>(); // | ||
| 17 | 13 | ||
| 18 | private FeederCommd feederCommd; | 14 | private FeederCommd feederCommd; |
| 19 | 15 | ||
| 20 | - public static FeederCommdDto initRead(byte[] requesBytes) | ||
| 21 | - { | ||
| 22 | - FeederCommdDto feederCommdDto = new FeederCommdDto(requesBytes); | ||
| 23 | - switch (feederCommdDto.getCommdcode()) | 16 | + public FeederCommdDto(FeederCommd03Response feederCommdResponse) |
| 24 | { | 17 | { |
| 25 | - case 0x03: | ||
| 26 | - feederCommdDto.setFeederCommd(new FeederCommd03Request(feederCommdDto.getData())); | ||
| 27 | - break; | ||
| 28 | - case 0x06: | ||
| 29 | - break; | ||
| 30 | - case 0x10: | ||
| 31 | - break; | ||
| 32 | - } | ||
| 33 | - return feederCommdDto; | 18 | + byte[] start_bytes = ByteUtil.intToBytesDESC(feederCommdResponse.getStart_char(),2); |
| 19 | + byte[] lenth_bytes = ByteUtil.intToBytesDESC( feederCommdResponse.getChar_lenth(),2); | ||
| 20 | + super.toModbusDto(0x01,0x03, ArrayUtil.addAll(start_bytes,lenth_bytes)); | ||
| 21 | + this.feederCommd = feederCommdResponse; | ||
| 34 | } | 22 | } |
| 35 | 23 | ||
| 36 | - public FeederCommdDto initWrite(FeederCommd03Response feederCommdResponse) | 24 | + public FeederCommdDto(FeederCommd06Response feederCommd06Response) |
| 37 | { | 25 | { |
| 38 | - this.feederCommd = feederCommdResponse; | ||
| 39 | - feederCommdResponse.getStart_char(); | ||
| 40 | - feederCommdResponse.getChar_lenth(); | 26 | + byte[] start_bytes = ByteUtil.intToBytesDESC(feederCommd06Response.getRegister_address(),2); |
| 27 | + byte[] lenth_bytes = ByteUtil.intToBytesDESC( feederCommd06Response.getValue(),2); | ||
| 28 | + super.toModbusDto(0x01,0x06, ArrayUtil.addAll(start_bytes,lenth_bytes)); | ||
| 29 | + this.feederCommd = feederCommd06Response; | ||
| 30 | + } | ||
| 41 | 31 | ||
| 42 | - return new FeederCommdDto(requesBytes); | 32 | + public FeederCommdDto(FeederCommd10Response feederCommd10Response) |
| 33 | + { | ||
| 34 | + byte[] start_bytes = ByteUtil.intToBytesDESC(feederCommd10Response.getStart_char(),2); | ||
| 35 | + byte[] number_bytes = ByteUtil.intToBytesDESC( feederCommd10Response.getRegister_number(),2); | ||
| 36 | + byte[] lenth_bytes = ByteUtil.intToBytesDESC( feederCommd10Response.getByte_lenth(),2); | ||
| 37 | + byte[] data = feederCommd10Response.getData(); | ||
| 38 | + super.toModbusDto(0x01,0x10, ArrayUtil.addAll(start_bytes,number_bytes,lenth_bytes,data)); | ||
| 39 | + this.feederCommd = feederCommd10Response; | ||
| 43 | } | 40 | } |
| 44 | 41 | ||
| 45 | public FeederCommdDto(byte[] requesBytes) { | 42 | public FeederCommdDto(byte[] requesBytes) { |
| 46 | super(requesBytes); | 43 | super(requesBytes); |
| 44 | + switch (super.getCommdcode()) | ||
| 45 | + { | ||
| 46 | + case 0x03: | ||
| 47 | + feederCommd = new FeederCommd03Request(super.getData()); | ||
| 48 | + break; | ||
| 49 | + case 0x06: | ||
| 50 | + feederCommd = new FeederCommd06Request(super.getData()); | ||
| 51 | + break; | ||
| 52 | + case 0x10: | ||
| 53 | + feederCommd = new FeederCommd10Request(super.getData()); | ||
| 54 | + break; | ||
| 55 | + } | ||
| 47 | } | 56 | } |
| 48 | 57 | ||
| 49 | public FeederCommdDto() { | 58 | public FeederCommdDto() { |
| @@ -54,22 +63,6 @@ public class FeederCommdDto extends ModbusDto { | @@ -54,22 +63,6 @@ public class FeederCommdDto extends ModbusDto { | ||
| 54 | super(str); | 63 | super(str); |
| 55 | } | 64 | } |
| 56 | 65 | ||
| 57 | - public Integer getQuantity() { | ||
| 58 | - return quantity; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - public void setQuantity(Integer quantity) { | ||
| 62 | - this.quantity = quantity; | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - public Map<Integer, byte[]> getValue() { | ||
| 66 | - return value; | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - public void setValue(Map<Integer, byte[]> value) { | ||
| 70 | - this.value = value; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | public FeederCommd getFeederCommd() { | 66 | public FeederCommd getFeederCommd() { |
| 74 | return feederCommd; | 67 | return feederCommd; |
| 75 | } | 68 | } |
| @@ -77,4 +70,14 @@ public class FeederCommdDto extends ModbusDto { | @@ -77,4 +70,14 @@ public class FeederCommdDto extends ModbusDto { | ||
| 77 | public void setFeederCommd(FeederCommd feederCommd) { | 70 | public void setFeederCommd(FeederCommd feederCommd) { |
| 78 | this.feederCommd = feederCommd; | 71 | this.feederCommd = feederCommd; |
| 79 | } | 72 | } |
| 73 | + | ||
| 74 | + public static void main(String[] args) { | ||
| 75 | + FeederCommdDto feederCommdDto03 = new FeederCommdDto(new FeederCommd03Response(0,71)); | ||
| 76 | + FeederCommdDto feederCommdDto06 = new FeederCommdDto(new FeederCommd06Response(0,1)); | ||
| 77 | +// FeederCommdDto feederCommdDto10 = new FeederCommdDto(new FeederCommd10Response(21,4,8,)); | ||
| 78 | + | ||
| 79 | + System.out.println(feederCommdDto03); | ||
| 80 | + System.out.println(feederCommdDto06); | ||
| 81 | +// System.out.println(feederCommdDto10); | ||
| 82 | + } | ||
| 80 | } | 83 | } |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/dto/commd/FeederTimer.java
0 → 100644
| 1 | +package com.zhonglai.luhui.smart.feeder.dto.commd; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 定时器 | ||
| 5 | + */ | ||
| 6 | +public class FeederTimer { | ||
| 7 | + private Integer timer_start_m; | ||
| 8 | + private Integer timer_start_h; | ||
| 9 | + private Integer timer_if_start; | ||
| 10 | + private Integer timer_is_start; | ||
| 11 | + private Integer timer_close_m; | ||
| 12 | + private Integer timer_close_h; | ||
| 13 | + private Integer timer_if_close; | ||
| 14 | + private Integer timer_is_close; | ||
| 15 | + | ||
| 16 | + public void setObjectValue(String field,long value) | ||
| 17 | + { | ||
| 18 | + switch (field) | ||
| 19 | + { | ||
| 20 | + case "timer_start_m": | ||
| 21 | + timer_start_m = Integer.valueOf(Long.toString(value)); | ||
| 22 | + break; | ||
| 23 | + case "timer_start_h": | ||
| 24 | + timer_start_h =Integer.valueOf(Long.toString(value)); | ||
| 25 | + break; | ||
| 26 | + case "timer_if_start": | ||
| 27 | + timer_if_start =Integer.valueOf(Long.toString(value)); | ||
| 28 | + break; | ||
| 29 | + case "timer_is_start": | ||
| 30 | + timer_is_start =Integer.valueOf(Long.toString(value)); | ||
| 31 | + break; | ||
| 32 | + case "timer_close_m": | ||
| 33 | + timer_close_m =Integer.valueOf(Long.toString(value)); | ||
| 34 | + break; | ||
| 35 | + case "timer_close_h": | ||
| 36 | + timer_close_h =Integer.valueOf(Long.toString(value)); | ||
| 37 | + break; | ||
| 38 | + case "timer_if_close": | ||
| 39 | + timer_if_close =Integer.valueOf(Long.toString(value)); | ||
| 40 | + break; | ||
| 41 | + case "timer_is_close": | ||
| 42 | + timer_is_close =Integer.valueOf(Long.toString(value)); | ||
| 43 | + break; | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public Integer getTimer_start_m() { | ||
| 48 | + return timer_start_m; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public void setTimer_start_m(Integer timer_start_m) { | ||
| 52 | + this.timer_start_m = timer_start_m; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public Integer getTimer_start_h() { | ||
| 56 | + return timer_start_h; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setTimer_start_h(Integer timer_start_h) { | ||
| 60 | + this.timer_start_h = timer_start_h; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public Integer getTimer_if_start() { | ||
| 64 | + return timer_if_start; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setTimer_if_start(Integer timer_if_start) { | ||
| 68 | + this.timer_if_start = timer_if_start; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public Integer getTimer_is_start() { | ||
| 72 | + return timer_is_start; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void setTimer_is_start(Integer timer_is_start) { | ||
| 76 | + this.timer_is_start = timer_is_start; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public Integer getTimer_close_m() { | ||
| 80 | + return timer_close_m; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public void setTimer_close_m(Integer timer_close_m) { | ||
| 84 | + this.timer_close_m = timer_close_m; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public Integer getTimer_close_h() { | ||
| 88 | + return timer_close_h; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public void setTimer_close_h(Integer timer_close_h) { | ||
| 92 | + this.timer_close_h = timer_close_h; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public Integer getTimer_if_close() { | ||
| 96 | + return timer_if_close; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public void setTimer_if_close(Integer timer_if_close) { | ||
| 100 | + this.timer_if_close = timer_if_close; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public Integer getTimer_is_close() { | ||
| 104 | + return timer_is_close; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + public void setTimer_is_close(Integer timer_is_close) { | ||
| 108 | + this.timer_is_close = timer_is_close; | ||
| 109 | + } | ||
| 110 | +} |
| 1 | +package com.zhonglai.luhui.smart.feeder.service; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.bean.BeanUtil; | ||
| 4 | +import com.google.gson.JsonObject; | ||
| 5 | +import com.ruoyi.common.utils.ByteUtil; | ||
| 6 | +import com.zhonglai.luhui.smart.feeder.Main; | ||
| 7 | +import com.zhonglai.luhui.smart.feeder.domain.Register; | ||
| 8 | +import com.zhonglai.luhui.smart.feeder.dto.ModbusDto; | ||
| 9 | +import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommd; | ||
| 10 | +import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommd03Request; | ||
| 11 | +import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommdDto; | ||
| 12 | +import com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer; | ||
| 13 | +import org.slf4j.Logger; | ||
| 14 | +import org.slf4j.LoggerFactory; | ||
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 16 | +import org.springframework.stereotype.Service; | ||
| 17 | + | ||
| 18 | +import java.util.HashMap; | ||
| 19 | +import java.util.List; | ||
| 20 | +import java.util.Map; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * 数据解析服务 | ||
| 24 | + */ | ||
| 25 | +@Service | ||
| 26 | +public class AnalysisDataService { | ||
| 27 | + private static final Logger logger = LoggerFactory.getLogger(AnalysisDataService.class); | ||
| 28 | + | ||
| 29 | + @Autowired | ||
| 30 | + private ConfigurationParameterService configurationParameterService; | ||
| 31 | + | ||
| 32 | + public Map<String,Object> analysis(ModbusDto modbusDto) | ||
| 33 | + { | ||
| 34 | + if(modbusDto instanceof FeederCommdDto) | ||
| 35 | + { | ||
| 36 | + FeederCommdDto feederCommdDto = (FeederCommdDto) modbusDto; | ||
| 37 | + | ||
| 38 | + FeederCommd feederCommd = feederCommdDto.getFeederCommd(); | ||
| 39 | + if (feederCommd instanceof FeederCommd03Request) | ||
| 40 | + { | ||
| 41 | + Map<Integer, List<Register>> configMap = configurationParameterService.getRegisterMap(); | ||
| 42 | + | ||
| 43 | + Map<String,Object> valueMap = new HashMap<>(); | ||
| 44 | + | ||
| 45 | + FeederCommd03Request feederCommd03Request = (FeederCommd03Request) feederCommd; | ||
| 46 | + Map<Integer, byte[]> map = feederCommd03Request.getAddressValue(); | ||
| 47 | + for (Integer adrress:map.keySet()) | ||
| 48 | + { | ||
| 49 | + byte[] bytes = map.get(adrress); | ||
| 50 | + List<Register> registers = configMap.get(adrress); | ||
| 51 | + if(null != registers) | ||
| 52 | + { | ||
| 53 | + for (Register register:registers) | ||
| 54 | + { | ||
| 55 | + try { | ||
| 56 | + registerTo(valueMap,bytes,register); | ||
| 57 | + }catch (Exception e) | ||
| 58 | + { | ||
| 59 | + logger.error("根据字典解析异常",e); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + }else{ | ||
| 64 | + logger.error("未读取到"+adrress+"的地址读取配置"); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + } | ||
| 68 | + return valueMap; | ||
| 69 | + | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + return null; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + private void registerTo(Map<String,Object> valueMap,byte[] bytes,Register register) | ||
| 78 | + { | ||
| 79 | + String field = register.getField_name(); | ||
| 80 | + | ||
| 81 | + long value = ByteUtil.readBits(ByteUtil.bytesToLongDESC(bytes,0,2),register.getStart_char(),register.getChar_lenth()); | ||
| 82 | + | ||
| 83 | + switch (register.getClas()) | ||
| 84 | + { | ||
| 85 | + case "java.lang.Integer": | ||
| 86 | + valueMap.put(field,Integer.valueOf(Long.toString(value))); | ||
| 87 | + break; | ||
| 88 | + case "java.lang.Boolean": | ||
| 89 | + valueMap.put(field,Boolean.valueOf(Long.toString(value))); | ||
| 90 | + break; | ||
| 91 | + case "java.lang.Float": | ||
| 92 | + valueMap.put(field,Float.valueOf(Long.toString(value))); | ||
| 93 | + break; | ||
| 94 | + case "com.zhonglai.luhui.smart.feeder.dto.commd.FeederTimer": | ||
| 95 | + String timerKey = field.split("_")[0]; | ||
| 96 | + FeederTimer feederTimer = (FeederTimer) valueMap.get(timerKey); | ||
| 97 | + if(!valueMap.containsKey(timerKey)) | ||
| 98 | + { | ||
| 99 | + feederTimer = new FeederTimer(); | ||
| 100 | + valueMap.put(timerKey,feederTimer); | ||
| 101 | + } | ||
| 102 | + feederTimer.setObjectValue(field,value); | ||
| 103 | + break; | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | +} |
| 1 | package com.zhonglai.luhui.smart.feeder.service; | 1 | package com.zhonglai.luhui.smart.feeder.service; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | +import com.zhonglai.luhui.smart.feeder.domain.Register; | ||
| 4 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; | 5 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; |
| 5 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; | 6 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; |
| 7 | +import com.zhonglai.luhui.smart.feeder.dto.StateData; | ||
| 6 | import org.ehcache.Cache; | 8 | import org.ehcache.Cache; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| @@ -18,16 +20,20 @@ import java.util.Map; | @@ -18,16 +20,20 @@ import java.util.Map; | ||
| 18 | */ | 20 | */ |
| 19 | @Service | 21 | @Service |
| 20 | public class ConfigurationParameterService { | 22 | public class ConfigurationParameterService { |
| 23 | + | ||
| 24 | + private Map<Integer,List<Register>> registerMap = new HashMap<>(); | ||
| 25 | + | ||
| 21 | @Autowired | 26 | @Autowired |
| 22 | private EhCacheService ehCacheService; | 27 | private EhCacheService ehCacheService; |
| 23 | 28 | ||
| 24 | @Autowired | 29 | @Autowired |
| 25 | private SqliteService sqliteService; | 30 | private SqliteService sqliteService; |
| 26 | 31 | ||
| 27 | - @PostConstruct | 32 | + private StateData stateData; |
| 33 | + | ||
| 28 | public void initConfigurationParameter() | 34 | public void initConfigurationParameter() |
| 29 | { | 35 | { |
| 30 | - | 36 | + //系统配置 |
| 31 | List<Map<String,Object>> sysConfigList = sqliteService.getAllSysConfig(); | 37 | List<Map<String,Object>> sysConfigList = sqliteService.getAllSysConfig(); |
| 32 | if(null != sysConfigList && sysConfigList.size() != 0) | 38 | if(null != sysConfigList && sysConfigList.size() != 0) |
| 33 | { | 39 | { |
| @@ -38,25 +44,30 @@ public class ConfigurationParameterService { | @@ -38,25 +44,30 @@ public class ConfigurationParameterService { | ||
| 38 | } | 44 | } |
| 39 | } | 45 | } |
| 40 | 46 | ||
| 41 | - List<Map<String,Object>> gearCommandList = sqliteService.getAllGearCommand(); | ||
| 42 | - Map<String,String> gearCommandMap = new HashMap<String,String>(); | ||
| 43 | - if(null != gearCommandList && gearCommandList.size() != 0) | ||
| 44 | - { | ||
| 45 | - | ||
| 46 | - for(Map<String,Object> map:gearCommandList) | ||
| 47 | - { | ||
| 48 | - gearCommandMap.put(map.get("gear")+"",(String)map.get("command")); | ||
| 49 | - } | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - ehCacheService.writeToCache(ConfigurationParameter.gear_command,gearCommandMap); | ||
| 53 | - | 47 | + //斜率对应的档位 |
| 54 | List<FishCurveControlCondition> absValueCommandList = sqliteService.getAllAbsValueCommand(); | 48 | List<FishCurveControlCondition> absValueCommandList = sqliteService.getAllAbsValueCommand(); |
| 55 | ehCacheService.writeToCache(ConfigurationParameter.absValue_command,new ArrayList<>()); | 49 | ehCacheService.writeToCache(ConfigurationParameter.absValue_command,new ArrayList<>()); |
| 56 | if(null != absValueCommandList && absValueCommandList.size() != 0) | 50 | if(null != absValueCommandList && absValueCommandList.size() != 0) |
| 57 | { | 51 | { |
| 58 | ehCacheService.writeToCache(ConfigurationParameter.absValue_command,absValueCommandList); | 52 | ehCacheService.writeToCache(ConfigurationParameter.absValue_command,absValueCommandList); |
| 59 | } | 53 | } |
| 54 | + | ||
| 55 | + //数据解析字典 | ||
| 56 | + List<Map<String,Object>> registerList = sqliteService.getAllRegister(); | ||
| 57 | + if(null != registerList && registerList.size() != 0) | ||
| 58 | + { | ||
| 59 | + for (Map<String,Object> map:registerList) | ||
| 60 | + { | ||
| 61 | + Register register = BeanUtil.mapToBean(map,Register.class,false,null); | ||
| 62 | + List<Register> list = registerMap.get(register.getAddress()); | ||
| 63 | + if(null == list) | ||
| 64 | + { | ||
| 65 | + list = new ArrayList<>(); | ||
| 66 | + registerMap.put(register.getAddress(),list); | ||
| 67 | + } | ||
| 68 | + list.add(register); | ||
| 69 | + } | ||
| 70 | + } | ||
| 60 | } | 71 | } |
| 61 | 72 | ||
| 62 | public Cache<String, Object> getAll() | 73 | public Cache<String, Object> getAll() |
| @@ -66,15 +77,8 @@ public class ConfigurationParameterService { | @@ -66,15 +77,8 @@ public class ConfigurationParameterService { | ||
| 66 | 77 | ||
| 67 | public synchronized void setConfig(ConfigurationParameter configurationParameter,Object value) | 78 | public synchronized void setConfig(ConfigurationParameter configurationParameter,Object value) |
| 68 | { | 79 | { |
| 69 | - if(configurationParameter !=configurationParameter.absValue_command && !configurationParameter.getValuType().isInstance(value) ) | ||
| 70 | - { | ||
| 71 | - throw new RuntimeException("配置参数类型不正确"); | ||
| 72 | - } | ||
| 73 | switch (configurationParameter) | 80 | switch (configurationParameter) |
| 74 | { | 81 | { |
| 75 | - case gear_command: | ||
| 76 | - setGearCommandMap((Map<String, String>) value); | ||
| 77 | - break; | ||
| 78 | case absValue_command: | 82 | case absValue_command: |
| 79 | if(value instanceof ArrayList) | 83 | if(value instanceof ArrayList) |
| 80 | { | 84 | { |
| @@ -129,20 +133,6 @@ public class ConfigurationParameterService { | @@ -129,20 +133,6 @@ public class ConfigurationParameterService { | ||
| 129 | sqliteService.updateConfigurationParameter(configurationParameter,value); | 133 | sqliteService.updateConfigurationParameter(configurationParameter,value); |
| 130 | } | 134 | } |
| 131 | 135 | ||
| 132 | - private void setGearCommandMap(Map<String,String> gearCommandMap) | ||
| 133 | - { | ||
| 134 | - Map<String,String> old = (Map<String, String>) ehCacheService.readFromCache(ConfigurationParameter.gear_command); | ||
| 135 | - if(null == old) | ||
| 136 | - { | ||
| 137 | - old = gearCommandMap; | ||
| 138 | - } | ||
| 139 | - for (String key:gearCommandMap.keySet()) | ||
| 140 | - { | ||
| 141 | - sqliteService.updateGearCommand(Integer.parseInt(key),gearCommandMap.get(key)); | ||
| 142 | - old.put(key,gearCommandMap.get(key)); | ||
| 143 | - } | ||
| 144 | - ehCacheService.writeToCache(ConfigurationParameter.gear_command,old); | ||
| 145 | - } | ||
| 146 | 136 | ||
| 147 | private void setabsValueCommandList(List<FishCurveControlCondition> absValueCommandList) | 137 | private void setabsValueCommandList(List<FishCurveControlCondition> absValueCommandList) |
| 148 | { | 138 | { |
| @@ -172,4 +162,16 @@ public class ConfigurationParameterService { | @@ -172,4 +162,16 @@ public class ConfigurationParameterService { | ||
| 172 | sqliteService.updateabsValueCommand(absValueCommand.getGear(),absValueCommand.getSartAbsValue()); | 162 | sqliteService.updateabsValueCommand(absValueCommand.getGear(),absValueCommand.getSartAbsValue()); |
| 173 | 163 | ||
| 174 | } | 164 | } |
| 165 | + | ||
| 166 | + public Map<Integer, List<Register>> getRegisterMap() { | ||
| 167 | + return registerMap; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + public StateData getStateData() { | ||
| 171 | + return stateData; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + public void setStateData(StateData stateData) { | ||
| 175 | + this.stateData = stateData; | ||
| 176 | + } | ||
| 175 | } | 177 | } |
| 1 | package com.zhonglai.luhui.smart.feeder.service; | 1 | package com.zhonglai.luhui.smart.feeder.service; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.bean.BeanUtil; | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | +import com.google.gson.JsonObject; | ||
| 6 | +import com.ruoyi.common.utils.GsonConstructor; | ||
| 3 | import com.zhonglai.luhui.smart.feeder.Main; | 7 | import com.zhonglai.luhui.smart.feeder.Main; |
| 8 | +import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; | ||
| 9 | +import com.zhonglai.luhui.smart.feeder.dto.ModbusDto; | ||
| 10 | +import com.zhonglai.luhui.smart.feeder.dto.StateData; | ||
| 11 | +import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommd03Response; | ||
| 12 | +import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommdDto; | ||
| 13 | +import com.zhonglai.luhui.smart.feeder.util.FeederCommdUtil; | ||
| 4 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
| 5 | import org.slf4j.LoggerFactory; | 15 | import org.slf4j.LoggerFactory; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -8,6 +18,7 @@ import org.springframework.stereotype.Service; | @@ -8,6 +18,7 @@ import org.springframework.stereotype.Service; | ||
| 8 | 18 | ||
| 9 | import javax.annotation.PostConstruct; | 19 | import javax.annotation.PostConstruct; |
| 10 | import java.io.IOException; | 20 | import java.io.IOException; |
| 21 | +import java.util.Map; | ||
| 11 | import java.util.concurrent.ScheduledExecutorService; | 22 | import java.util.concurrent.ScheduledExecutorService; |
| 12 | import java.util.concurrent.TimeUnit; | 23 | import java.util.concurrent.TimeUnit; |
| 13 | 24 | ||
| @@ -23,10 +34,23 @@ public class DateListenService { | @@ -23,10 +34,23 @@ public class DateListenService { | ||
| 23 | @Autowired | 34 | @Autowired |
| 24 | private DeviceService deviceService; | 35 | private DeviceService deviceService; |
| 25 | 36 | ||
| 26 | - @PostConstruct | 37 | + @Autowired |
| 38 | + private AnalysisDataService analysisDataService; | ||
| 39 | + | ||
| 40 | + @Autowired | ||
| 41 | + private TerminalService terminalService; | ||
| 42 | + | ||
| 43 | + @Autowired | ||
| 44 | + private ConfigurationParameterService configurationParameterService; | ||
| 45 | + | ||
| 27 | public void run() | 46 | public void run() |
| 28 | { | 47 | { |
| 29 | scheduledExecutorService.scheduleAtFixedRate(() -> { | 48 | scheduledExecutorService.scheduleAtFixedRate(() -> { |
| 49 | + | ||
| 50 | + if(!(Boolean) configurationParameterService.getConfig(ConfigurationParameter.ifUpLoadData)) | ||
| 51 | + { | ||
| 52 | + return; | ||
| 53 | + } | ||
| 30 | try { | 54 | try { |
| 31 | deviceService.openDefaultSerialPort(); | 55 | deviceService.openDefaultSerialPort(); |
| 32 | } catch (Exception e) { | 56 | } catch (Exception e) { |
| @@ -34,11 +58,21 @@ public class DateListenService { | @@ -34,11 +58,21 @@ public class DateListenService { | ||
| 34 | return; | 58 | return; |
| 35 | } | 59 | } |
| 36 | try { | 60 | try { |
| 37 | - deviceService.sendData("01 03 00 00 00 47 05 F8".replace(" ","").trim()); | 61 | + ModbusDto modbusDto = deviceService.sendData(FeederCommdUtil.readAll()); |
| 62 | + Map<String,Object> data = analysisDataService.analysis(modbusDto); | ||
| 63 | + if(null != data && data.size() != 0) | ||
| 64 | + { | ||
| 65 | + StateData stateData = BeanUtil.mapToBean(data, StateData.class,false,null); | ||
| 66 | + configurationParameterService.setStateData(stateData); | ||
| 38 | 67 | ||
| 68 | + JSONObject jsonObject = new JSONObject(); | ||
| 69 | + jsonObject.put("1",data); | ||
| 70 | + terminalService.scheduledSubmissionData(jsonObject.toJSONString()); | ||
| 71 | + } | ||
| 39 | } catch (Exception e) { | 72 | } catch (Exception e) { |
| 40 | logger.error("数据采集失败",e); | 73 | logger.error("数据采集失败",e); |
| 41 | } | 74 | } |
| 75 | + | ||
| 42 | },1,60, TimeUnit.SECONDS); | 76 | },1,60, TimeUnit.SECONDS); |
| 43 | } | 77 | } |
| 44 | 78 |
| @@ -4,6 +4,8 @@ import com.ruoyi.common.utils.GsonConstructor; | @@ -4,6 +4,8 @@ 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.*; | 5 | import com.zhonglai.luhui.smart.feeder.dto.*; |
| 6 | import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommdDto; | 6 | import com.zhonglai.luhui.smart.feeder.dto.commd.FeederCommdDto; |
| 7 | +import com.zhonglai.luhui.smart.feeder.util.FeederCommd06ResponseType; | ||
| 8 | +import com.zhonglai.luhui.smart.feeder.util.FeederCommdUtil; | ||
| 7 | import com.zhonglai.luhui.smart.feeder.util.serial.SerialTool; | 9 | import com.zhonglai.luhui.smart.feeder.util.serial.SerialTool; |
| 8 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
| @@ -13,6 +15,7 @@ import purejavacomm.SerialPort; | @@ -13,6 +15,7 @@ import purejavacomm.SerialPort; | ||
| 13 | 15 | ||
| 14 | import javax.annotation.PostConstruct; | 16 | import javax.annotation.PostConstruct; |
| 15 | import java.io.IOException; | 17 | import java.io.IOException; |
| 18 | +import java.io.OutputStream; | ||
| 16 | import java.util.*; | 19 | import java.util.*; |
| 17 | import java.util.concurrent.BlockingQueue; | 20 | import java.util.concurrent.BlockingQueue; |
| 18 | import java.util.concurrent.LinkedBlockingQueue; | 21 | import java.util.concurrent.LinkedBlockingQueue; |
| @@ -26,8 +29,6 @@ import java.util.concurrent.TimeUnit; | @@ -26,8 +29,6 @@ import java.util.concurrent.TimeUnit; | ||
| 26 | public class DeviceService { | 29 | public class DeviceService { |
| 27 | private static Logger logger = LoggerFactory.getLogger(DeviceService.class); | 30 | private static Logger logger = LoggerFactory.getLogger(DeviceService.class); |
| 28 | 31 | ||
| 29 | - private SerialPort serialPort; //串口 | ||
| 30 | - | ||
| 31 | // 锁对象 | 32 | // 锁对象 |
| 32 | private final Object lock = new Object(); | 33 | private final Object lock = new Object(); |
| 33 | // 用于存储串口返回的数据,使用线程安全的队列 | 34 | // 用于存储串口返回的数据,使用线程安全的队列 |
| @@ -43,6 +44,10 @@ public class DeviceService { | @@ -43,6 +44,10 @@ public class DeviceService { | ||
| 43 | 44 | ||
| 44 | private Integer nowGear; //当前档位 | 45 | private Integer nowGear; //当前档位 |
| 45 | 46 | ||
| 47 | + private Integer oldGear; //老的档位 | ||
| 48 | + | ||
| 49 | + private Double area; //面积 | ||
| 50 | + | ||
| 46 | @Autowired | 51 | @Autowired |
| 47 | private ConfigurationParameterService configurationParameterService; | 52 | private ConfigurationParameterService configurationParameterService; |
| 48 | 53 | ||
| @@ -52,16 +57,41 @@ public class DeviceService { | @@ -52,16 +57,41 @@ public class DeviceService { | ||
| 52 | @Autowired | 57 | @Autowired |
| 53 | private EhCacheService ehCacheService; | 58 | private EhCacheService ehCacheService; |
| 54 | 59 | ||
| 55 | - @PostConstruct | 60 | + private SerialPort serialPort; |
| 61 | + | ||
| 56 | public void run() | 62 | public void run() |
| 57 | { | 63 | { |
| 58 | //投料控制 | 64 | //投料控制 |
| 59 | scheduledExecutorService.scheduleWithFixedDelay(() -> { | 65 | scheduledExecutorService.scheduleWithFixedDelay(() -> { |
| 60 | if (((Boolean)ehCacheService.readFromCache(ConfigurationParameter.FeedingControl))) { | 66 | if (((Boolean)ehCacheService.readFromCache(ConfigurationParameter.FeedingControl))) { |
| 61 | - Map<Integer,String> map = (Map<Integer, String>) ehCacheService.readFromCache(ConfigurationParameter.gear_command); | ||
| 62 | - if(null != map && StringUtils.isNotEmpty( map.get(nowGear))) | 67 | + logger.info("当前档位{},以前的档位{},斜率{},斜率差值{},面积{},开关是否打开{}",nowGear,oldGear,slope,absValue,area,null == configurationParameterService.getStateData()?"未知":configurationParameterService.getStateData().getSwitch_status()); |
| 68 | + | ||
| 69 | + if(null != nowGear && oldGear != nowGear) | ||
| 63 | { | 70 | { |
| 64 | - send485SerialData(map.get(nowGear)); | 71 | + if(nowGear>0 ) //如果档位有值 |
| 72 | + { | ||
| 73 | + if(null !=configurationParameterService.getStateData() && 1==configurationParameterService.getStateData().getRunmode()) | ||
| 74 | + { | ||
| 75 | + send485SerialData(FeederCommdUtil.controlData(FeederCommd06ResponseType.runmode,0)); //,运行模式改成手动 | ||
| 76 | + } | ||
| 77 | + if(null !=configurationParameterService.getStateData() && 0==configurationParameterService.getStateData().getSwitch_status()) | ||
| 78 | + { | ||
| 79 | + send485SerialData(FeederCommdUtil.controlData(FeederCommd06ResponseType.OnOroff,1)); //,开关是关的就先打开开关 | ||
| 80 | + } | ||
| 81 | + send485SerialData(FeederCommdUtil.controlData(FeederCommd06ResponseType.runspeed,nowGear)); | ||
| 82 | + oldGear = nowGear; | ||
| 83 | + }else{ | ||
| 84 | + if(null !=configurationParameterService.getStateData() && 0==configurationParameterService.getStateData().getRunmode()) | ||
| 85 | + { | ||
| 86 | + send485SerialData(FeederCommdUtil.controlData(FeederCommd06ResponseType.runmode,1)); //,运行模式改成自动 | ||
| 87 | + } | ||
| 88 | + if(null !=configurationParameterService.getStateData() && 1==configurationParameterService.getStateData().getSwitch_status()) | ||
| 89 | + { | ||
| 90 | + send485SerialData(FeederCommdUtil.controlData(FeederCommd06ResponseType.OnOroff,0)); //,开关是关的就先打开开关 | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + | ||
| 65 | } | 95 | } |
| 66 | } | 96 | } |
| 67 | },1,1, TimeUnit.SECONDS); | 97 | },1,1, TimeUnit.SECONDS); |
| @@ -86,6 +116,7 @@ public class DeviceService { | @@ -86,6 +116,7 @@ public class DeviceService { | ||
| 86 | */ | 116 | */ |
| 87 | public double controlDevice(double area) | 117 | public double controlDevice(double area) |
| 88 | { | 118 | { |
| 119 | + this.area = area; | ||
| 89 | if(null == backArea ) | 120 | if(null == backArea ) |
| 90 | { | 121 | { |
| 91 | backArea = area; | 122 | backArea = area; |
| @@ -182,12 +213,33 @@ public class DeviceService { | @@ -182,12 +213,33 @@ public class DeviceService { | ||
| 182 | SerialTool.addListener(serialPortEvent -> { | 213 | SerialTool.addListener(serialPortEvent -> { |
| 183 | try { | 214 | try { |
| 184 | Thread.sleep(500); | 215 | Thread.sleep(500); |
| 185 | - FeederCommdDto commdDto = FeederCommdDto.initRead (SerialTool.readFromPort(serialPort)); | 216 | + FeederCommdDto commdDto = new FeederCommdDto (SerialTool.readFromPort(serialPort)); |
| 217 | + dataQueue.offer(commdDto); // 将数据添加到队列中// 处理串口返回的数据 | ||
| 218 | + } catch (Exception e) { | ||
| 219 | + logger.error("返回数据处理异常",e); | ||
| 220 | + } | ||
| 221 | + }, serialPort); | ||
| 222 | + logger.info("打开串口成功"); | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + public void nowOpenSerial(String portName, Integer baudrate, Integer dataBits, Integer stopBits, | ||
| 226 | + Integer parity) throws Exception { | ||
| 227 | + if(null != serialPort) | ||
| 228 | + { | ||
| 229 | + serialPort.removeEventListener(); | ||
| 230 | + serialPort.close(); | ||
| 231 | + } | ||
| 232 | + serialPort = SerialTool.openPort(portName,baudrate,dataBits,stopBits,parity); | ||
| 233 | + SerialTool.addListener(serialPortEvent -> { | ||
| 234 | + try { | ||
| 235 | + Thread.sleep(500); | ||
| 236 | + FeederCommdDto commdDto = new FeederCommdDto (SerialTool.readFromPort(serialPort)); | ||
| 186 | dataQueue.offer(commdDto); // 将数据添加到队列中// 处理串口返回的数据 | 237 | dataQueue.offer(commdDto); // 将数据添加到队列中// 处理串口返回的数据 |
| 187 | } catch (Exception e) { | 238 | } catch (Exception e) { |
| 188 | logger.error("返回数据处理异常",e); | 239 | logger.error("返回数据处理异常",e); |
| 189 | } | 240 | } |
| 190 | }, serialPort); | 241 | }, serialPort); |
| 242 | + | ||
| 191 | } | 243 | } |
| 192 | 244 | ||
| 193 | public void openDefaultSerialPort() throws Exception { | 245 | public void openDefaultSerialPort() throws Exception { |
| @@ -215,5 +267,14 @@ public class DeviceService { | @@ -215,5 +267,14 @@ public class DeviceService { | ||
| 215 | } | 267 | } |
| 216 | 268 | ||
| 217 | 269 | ||
| 270 | + public void close() | ||
| 271 | + { | ||
| 272 | + dataQueue.clear(); | ||
| 273 | + if(null != serialPort) | ||
| 274 | + { | ||
| 275 | + serialPort.removeEventListener(); | ||
| 276 | + serialPort.close(); | ||
| 277 | + } | ||
| 278 | + } | ||
| 218 | 279 | ||
| 219 | } | 280 | } |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/service/EhCacheService.java
| @@ -33,7 +33,6 @@ public class EhCacheService { | @@ -33,7 +33,6 @@ public class EhCacheService { | ||
| 33 | @Value("${sys.cacheFilePath}") | 33 | @Value("${sys.cacheFilePath}") |
| 34 | private String cacheFilePath; | 34 | private String cacheFilePath; |
| 35 | 35 | ||
| 36 | - @PostConstruct | ||
| 37 | public void instance() | 36 | public void instance() |
| 38 | { | 37 | { |
| 39 | cacheManager = CacheManagerBuilder.newCacheManagerBuilder() | 38 | cacheManager = CacheManagerBuilder.newCacheManagerBuilder() |
| @@ -51,7 +51,6 @@ public class FishGroupImageRecognitionService { | @@ -51,7 +51,6 @@ public class FishGroupImageRecognitionService { | ||
| 51 | private static Boolean isRun = false; | 51 | private static Boolean isRun = false; |
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | - @PostConstruct | ||
| 55 | public void run() | 54 | public void run() |
| 56 | { | 55 | { |
| 57 | scheduledExecutorService.scheduleWithFixedDelay(() -> { | 56 | scheduledExecutorService.scheduleWithFixedDelay(() -> { |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/service/InitService.java
0 → 100644
| 1 | +package com.zhonglai.luhui.smart.feeder.service; | ||
| 2 | + | ||
| 3 | +import org.eclipse.paho.client.mqttv3.MqttException; | ||
| 4 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 5 | +import org.springframework.context.annotation.Configuration; | ||
| 6 | + | ||
| 7 | +import javax.annotation.PostConstruct; | ||
| 8 | +import java.util.concurrent.ScheduledExecutorService; | ||
| 9 | + | ||
| 10 | +@Configuration | ||
| 11 | +public class InitService { | ||
| 12 | + @Autowired | ||
| 13 | + private CameraService cameraService; | ||
| 14 | + | ||
| 15 | + @Autowired | ||
| 16 | + private ConfigurationParameterService configurationParameterService; | ||
| 17 | + | ||
| 18 | + @Autowired | ||
| 19 | + private DateListenService dateListenService; | ||
| 20 | + | ||
| 21 | + @Autowired | ||
| 22 | + private DeviceService deviceService; | ||
| 23 | + | ||
| 24 | + @Autowired | ||
| 25 | + private EhCacheService ehCacheService; | ||
| 26 | + | ||
| 27 | + @Autowired | ||
| 28 | + private FishGroupImageRecognitionService fishGroupImageRecognitionService; | ||
| 29 | + | ||
| 30 | + @Autowired | ||
| 31 | + private SqliteService sqliteService; | ||
| 32 | + | ||
| 33 | + @Autowired | ||
| 34 | + private TerminalService terminalService; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 守护摄像头 | ||
| 38 | + */ | ||
| 39 | + @PostConstruct | ||
| 40 | + private void run() throws MqttException { | ||
| 41 | + //加载缓存 | ||
| 42 | + ehCacheService.instance(); | ||
| 43 | + //持久化初始 | ||
| 44 | + sqliteService.init(); | ||
| 45 | + //配置参数 | ||
| 46 | + configurationParameterService.initConfigurationParameter(); | ||
| 47 | + //摄像头监听 | ||
| 48 | + cameraService.start(); | ||
| 49 | + //鱼群识别 | ||
| 50 | + fishGroupImageRecognitionService.run(); | ||
| 51 | + //鱼群图像识别控制投料控制 | ||
| 52 | + deviceService.run(); | ||
| 53 | + //连接上报终端 | ||
| 54 | + terminalService.init(); | ||
| 55 | + //串口数据上报 | ||
| 56 | + dateListenService.run(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | +} |
| @@ -25,7 +25,7 @@ public class MqttCallback implements MqttCallbackExtended { | @@ -25,7 +25,7 @@ public class MqttCallback implements MqttCallbackExtended { | ||
| 25 | 25 | ||
| 26 | @Override | 26 | @Override |
| 27 | public void messageArrived(String topic, MqttMessage message) throws Exception { | 27 | public void messageArrived(String topic, MqttMessage message) throws Exception { |
| 28 | - | 28 | + log.info("收到消息 {}",message); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | @Override | 31 | @Override |
| @@ -3,6 +3,7 @@ package com.zhonglai.luhui.smart.feeder.service; | @@ -3,6 +3,7 @@ package com.zhonglai.luhui.smart.feeder.service; | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.ruoyi.common.utils.GsonConstructor; | 4 | import com.ruoyi.common.utils.GsonConstructor; |
| 5 | import com.zhonglai.luhui.dao.service.PublicService; | 5 | import com.zhonglai.luhui.dao.service.PublicService; |
| 6 | +import com.zhonglai.luhui.smart.feeder.domain.Register; | ||
| 6 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; | 7 | import com.zhonglai.luhui.smart.feeder.dto.ConfigurationParameter; |
| 7 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; | 8 | import com.zhonglai.luhui.smart.feeder.dto.FishCurveControlCondition; |
| 8 | import com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig; | 9 | import com.zhonglai.luhui.smart.feeder.dto.SerialPortConfig; |
| @@ -34,13 +35,11 @@ public class SqliteService { | @@ -34,13 +35,11 @@ public class SqliteService { | ||
| 34 | @Value("${spring.datasource.druid.master.url}") | 35 | @Value("${spring.datasource.druid.master.url}") |
| 35 | private String masterUrl; | 36 | private String masterUrl; |
| 36 | 37 | ||
| 37 | - @PostConstruct | ||
| 38 | - private void init() | 38 | + public void init() |
| 39 | { | 39 | { |
| 40 | initDb(); | 40 | initDb(); |
| 41 | initSysConfig(); | 41 | initSysConfig(); |
| 42 | initAbsValueCommand(); | 42 | initAbsValueCommand(); |
| 43 | - initGearCommand(); | ||
| 44 | } | 43 | } |
| 45 | 44 | ||
| 46 | /** | 45 | /** |
| @@ -121,20 +120,6 @@ public class SqliteService { | @@ -121,20 +120,6 @@ public class SqliteService { | ||
| 121 | } | 120 | } |
| 122 | } | 121 | } |
| 123 | 122 | ||
| 124 | - private void initGearCommand() { | ||
| 125 | - logger.info("检查档位对应的指令表"); | ||
| 126 | - Long ct = publicService.selectCountBySql("SELECT count(*) ct FROM sqlite_master WHERE type='table' AND name='gear_command'"); | ||
| 127 | - if (0 == ct) | ||
| 128 | - { | ||
| 129 | - logger.info("档位对应的指令不存在自动创建"); | ||
| 130 | - publicService.updateBySql("CREATE TABLE \"gear_command\" (\n" + | ||
| 131 | - " \"gear\" integer NOT NULL,\n" + | ||
| 132 | - " \"command\" TEXT NOT NULL,\n" + | ||
| 133 | - " PRIMARY KEY (\"gear\")\n" + | ||
| 134 | - ")"); | ||
| 135 | - } | ||
| 136 | - } | ||
| 137 | - | ||
| 138 | public List<Map<String,Object>> getAllSysConfig() | 123 | public List<Map<String,Object>> getAllSysConfig() |
| 139 | { | 124 | { |
| 140 | return publicService.getObjectListBySQL("SELECT * FROM sys_config"); | 125 | return publicService.getObjectListBySQL("SELECT * FROM sys_config"); |
| @@ -145,22 +130,15 @@ public class SqliteService { | @@ -145,22 +130,15 @@ public class SqliteService { | ||
| 145 | return absValueCommandMapper.getFishCurveControlConditionList("SELECT * FROM absValue_command"); | 130 | return absValueCommandMapper.getFishCurveControlConditionList("SELECT * FROM absValue_command"); |
| 146 | } | 131 | } |
| 147 | 132 | ||
| 148 | - public List<Map<String,Object>> getAllGearCommand() | 133 | + public List<Map<String,Object>> getAllRegister() |
| 149 | { | 134 | { |
| 150 | - return publicService.getObjectListBySQL("SELECT * FROM gear_command"); | 135 | + return publicService.getObjectListBySQL("SELECT * FROM register"); |
| 151 | } | 136 | } |
| 152 | 137 | ||
| 153 | public void updateConfigurationParameter(ConfigurationParameter key,Object value) | 138 | public void updateConfigurationParameter(ConfigurationParameter key,Object value) |
| 154 | { | 139 | { |
| 155 | switch (key) | 140 | switch (key) |
| 156 | { | 141 | { |
| 157 | - case gear_command: | ||
| 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 | - } | ||
| 163 | - break; | ||
| 164 | case absValue_command: | 142 | case absValue_command: |
| 165 | List<FishCurveControlCondition> list = (List<FishCurveControlCondition>) value; | 143 | List<FishCurveControlCondition> list = (List<FishCurveControlCondition>) value; |
| 166 | for(FishCurveControlCondition fishCurveControlCondition:list) | 144 | for(FishCurveControlCondition fishCurveControlCondition:list) |
| @@ -180,12 +158,6 @@ public class SqliteService { | @@ -180,12 +158,6 @@ public class SqliteService { | ||
| 180 | publicService.updateBySql("insert into sys_config(`parameter_name`,`parameter_value`,`describe`) values ('"+key.name()+"','"+value+"','"+key.getDescribe()+"')"); | 158 | publicService.updateBySql("insert into sys_config(`parameter_name`,`parameter_value`,`describe`) values ('"+key.name()+"','"+value+"','"+key.getDescribe()+"')"); |
| 181 | } | 159 | } |
| 182 | 160 | ||
| 183 | - public void updateGearCommand(Integer gear,String command) | ||
| 184 | - { | ||
| 185 | - publicService.updateBySql("delete from gear_command where gear="+gear+""); | ||
| 186 | - publicService.updateBySql("insert into gear_command(`gear`,`command`) values ("+gear+",'"+command+"')"); | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | public void updateabsValueCommand(Integer gear,Integer sartAbsValue) | 161 | public void updateabsValueCommand(Integer gear,Integer sartAbsValue) |
| 190 | { | 162 | { |
| 191 | publicService.updateBySql("delete from absValue_command where sartAbsValue="+sartAbsValue+""); | 163 | publicService.updateBySql("delete from absValue_command where sartAbsValue="+sartAbsValue+""); |
| @@ -196,4 +168,6 @@ public class SqliteService { | @@ -196,4 +168,6 @@ public class SqliteService { | ||
| 196 | { | 168 | { |
| 197 | publicService.updateBySql("delete from absValue_command "); | 169 | publicService.updateBySql("delete from absValue_command "); |
| 198 | } | 170 | } |
| 171 | + | ||
| 172 | + | ||
| 199 | } | 173 | } |
| 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.ip.IpUtils; | ||
| 3 | import org.eclipse.paho.client.mqttv3.MqttClient; | 5 | import org.eclipse.paho.client.mqttv3.MqttClient; |
| 4 | import org.eclipse.paho.client.mqttv3.MqttConnectOptions; | 6 | import org.eclipse.paho.client.mqttv3.MqttConnectOptions; |
| 5 | import org.eclipse.paho.client.mqttv3.MqttException; | 7 | import org.eclipse.paho.client.mqttv3.MqttException; |
| @@ -13,7 +15,9 @@ import org.springframework.stereotype.Service; | @@ -13,7 +15,9 @@ import org.springframework.stereotype.Service; | ||
| 13 | 15 | ||
| 14 | import javax.annotation.PostConstruct; | 16 | import javax.annotation.PostConstruct; |
| 15 | import java.util.ArrayList; | 17 | import java.util.ArrayList; |
| 18 | +import java.util.HashMap; | ||
| 16 | import java.util.List; | 19 | import java.util.List; |
| 20 | +import java.util.Map; | ||
| 17 | 21 | ||
| 18 | /** | 22 | /** |
| 19 | * 终端服务 | 23 | * 终端服务 |
| @@ -36,15 +40,10 @@ public class TerminalService { | @@ -36,15 +40,10 @@ public class TerminalService { | ||
| 36 | @Value("#{'${mqtt.topics}'.split(',')}") | 40 | @Value("#{'${mqtt.topics}'.split(',')}") |
| 37 | private List<String> topics; | 41 | private List<String> topics; |
| 38 | 42 | ||
| 39 | - @Value("${mqtt.sub_clientid}") | ||
| 40 | - private String sub_clientid; | ||
| 41 | 43 | ||
| 42 | @Value("#{'${mqtt.mqtt_usernames}'.split(',')}") | 44 | @Value("#{'${mqtt.mqtt_usernames}'.split(',')}") |
| 43 | private List<String> mqtt_usernames; | 45 | private List<String> mqtt_usernames; |
| 44 | 46 | ||
| 45 | - @Value("${mqtt.roleid}") | ||
| 46 | - private String roleid; | ||
| 47 | - | ||
| 48 | @Value("${mqtt.username}") | 47 | @Value("${mqtt.username}") |
| 49 | private String username; | 48 | private String username; |
| 50 | @Value("${mqtt.password}") | 49 | @Value("${mqtt.password}") |
| @@ -56,10 +55,19 @@ public class TerminalService { | @@ -56,10 +55,19 @@ public class TerminalService { | ||
| 56 | init(); | 55 | init(); |
| 57 | connect(); | 56 | connect(); |
| 58 | subscribe(); | 57 | subscribe(); |
| 58 | + | ||
| 59 | + Map<String,Object> dmap = new HashMap<>(); | ||
| 60 | + Map<String,Object> map = new HashMap<>(); | ||
| 61 | + dmap.put("summary",map); | ||
| 62 | + map.put("localhostIp",IpUtils.getHostIp()); | ||
| 63 | + JSONObject jsonObject = new JSONObject(); | ||
| 64 | + jsonObject.put("0",dmap); | ||
| 65 | + String topic = "ADD_POST"; | ||
| 66 | + publish(topic,jsonObject.toJSONString()); | ||
| 59 | } | 67 | } |
| 60 | 68 | ||
| 61 | 69 | ||
| 62 | - private void init() throws MqttException { | 70 | + public void init() throws MqttException { |
| 63 | if(null == mqttclient) | 71 | if(null == mqttclient) |
| 64 | { | 72 | { |
| 65 | mqttclient = new MqttClient(broker, clientId, new MemoryPersistence()); | 73 | mqttclient = new MqttClient(broker, clientId, new MemoryPersistence()); |
| @@ -79,34 +87,7 @@ public class TerminalService { | @@ -79,34 +87,7 @@ public class TerminalService { | ||
| 79 | } | 87 | } |
| 80 | 88 | ||
| 81 | public void subscribe() throws MqttException { | 89 | public void subscribe() throws MqttException { |
| 82 | - List<String> ts = getCompletionTopics(); | ||
| 83 | - mqttclient.subscribe(ts.toArray(new String[ts.size()])); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - public List<String> getCompletionTopics() | ||
| 87 | - { | ||
| 88 | - List<String> ts = new ArrayList<>(); | ||
| 89 | - for(String mqtt_username:mqtt_usernames) | ||
| 90 | - { | ||
| 91 | - StringBuffer topic = new StringBuffer(); | ||
| 92 | - topic.append("/"); | ||
| 93 | - topic.append(roleid); | ||
| 94 | - topic.append("/"); | ||
| 95 | - topic.append(mqtt_username); | ||
| 96 | - topic.append("/"); | ||
| 97 | - topic.append(sub_clientid); | ||
| 98 | - topic.append("/"); | ||
| 99 | - topic.append("+"); | ||
| 100 | - for(String tc:topics) | ||
| 101 | - { | ||
| 102 | - StringBuffer t = new StringBuffer(topic); | ||
| 103 | - t.append("/"); | ||
| 104 | - t.append(tc); | ||
| 105 | - | ||
| 106 | - ts.add(t.toString()); | ||
| 107 | - } | ||
| 108 | - } | ||
| 109 | - return ts; | 90 | + mqttclient.subscribe(topics.toArray(new String[topics.size()])); |
| 110 | } | 91 | } |
| 111 | 92 | ||
| 112 | public void publish(String topic, MqttMessage message) throws MqttException { | 93 | public void publish(String topic, MqttMessage message) throws MqttException { |
| @@ -118,4 +99,18 @@ public class TerminalService { | @@ -118,4 +99,18 @@ public class TerminalService { | ||
| 118 | message.setPayload(messageStr.getBytes()); | 99 | message.setPayload(messageStr.getBytes()); |
| 119 | mqttclient.publish(topic,message); | 100 | mqttclient.publish(topic,message); |
| 120 | } | 101 | } |
| 102 | + | ||
| 103 | + public void scheduledSubmissionData(String messageStr) throws MqttException { | ||
| 104 | + String topic = "ALL_POST"; | ||
| 105 | + publish(topic,messageStr); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public void close() | ||
| 109 | + { | ||
| 110 | + try { | ||
| 111 | + mqttclient.close(); | ||
| 112 | + } catch (MqttException e) { | ||
| 113 | + log.error("关闭失败",e); | ||
| 114 | + } | ||
| 115 | + } | ||
| 121 | } | 116 | } |
| 1 | +package com.zhonglai.luhui.smart.feeder.util; | ||
| 2 | + | ||
| 3 | +public enum FeederCommd06ResponseType { | ||
| 4 | + /** | ||
| 5 | + * 运行模式 | ||
| 6 | + */ | ||
| 7 | + runmode(13), | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + *投料量 | ||
| 11 | + */ | ||
| 12 | + runspeed(14), | ||
| 13 | + /** | ||
| 14 | + *投料时间 | ||
| 15 | + */ | ||
| 16 | + worktime(15), | ||
| 17 | + /** | ||
| 18 | + *间隔时间 | ||
| 19 | + */ | ||
| 20 | + interval(16), | ||
| 21 | + /** | ||
| 22 | + * 开/关 | ||
| 23 | + */ | ||
| 24 | + OnOroff(17), | ||
| 25 | + /** | ||
| 26 | + *停投料倒计时 | ||
| 27 | + */ | ||
| 28 | + stopfeedcnt(18); | ||
| 29 | + private Integer number; | ||
| 30 | + FeederCommd06ResponseType(Integer number) { | ||
| 31 | + this.number = number; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public Integer getNumber() { | ||
| 35 | + return number; | ||
| 36 | + } | ||
| 37 | +} |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/util/FeederCommdUtil.java
0 → 100644
| 1 | +package com.zhonglai.luhui.smart.feeder.util; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.util.ArrayUtil; | ||
| 4 | +import com.ruoyi.common.utils.ByteUtil; | ||
| 5 | +import com.zhonglai.luhui.smart.feeder.dto.commd.*; | ||
| 6 | + | ||
| 7 | +public class FeederCommdUtil { | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * 读取所有数据 | ||
| 11 | + * @return | ||
| 12 | + */ | ||
| 13 | + public static String readAll() | ||
| 14 | + { | ||
| 15 | + FeederCommdDto feederCommdDto = new FeederCommdDto(new FeederCommd03Response(0,71)); | ||
| 16 | + return feederCommdDto.getHstr(); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 写运行模式 | ||
| 21 | + * @return | ||
| 22 | + */ | ||
| 23 | + public static String controlData(FeederCommd06ResponseType feederCommd06ResponseType,int value) | ||
| 24 | + { | ||
| 25 | + FeederCommdDto feederCommdDto = new FeederCommdDto(new FeederCommd06Response(feederCommd06ResponseType.getNumber(),value)); | ||
| 26 | + return feederCommdDto.getHstr(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 写定时器 | ||
| 31 | + * @param timerNumber | ||
| 32 | + * @param feederTimer | ||
| 33 | + * @return | ||
| 34 | + */ | ||
| 35 | + public static String controlTimer(Integer timerNumber,FeederTimer feederTimer) | ||
| 36 | + { | ||
| 37 | + int i23 = 0; | ||
| 38 | + if(null != feederTimer.getTimer_close_m()) | ||
| 39 | + { | ||
| 40 | + i23 = ByteUtil.assignBits(i23,feederTimer.getTimer_close_m(),0,7); | ||
| 41 | + } | ||
| 42 | + if(null != feederTimer.getTimer_close_h()) | ||
| 43 | + { | ||
| 44 | + i23 = ByteUtil.assignBits(i23,feederTimer.getTimer_close_h(),8,13); | ||
| 45 | + } | ||
| 46 | + if(null != feederTimer.getTimer_if_start()) | ||
| 47 | + { | ||
| 48 | + i23 = ByteUtil.assignBits(i23,feederTimer.getTimer_if_start(),14,14); | ||
| 49 | + } | ||
| 50 | + if(null != feederTimer.getTimer_is_start()) | ||
| 51 | + { | ||
| 52 | + i23 = ByteUtil.assignBits(i23,feederTimer.getTimer_is_start(),15,15); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + int i24 = 0; | ||
| 56 | + if(null != feederTimer.getTimer_close_m()) | ||
| 57 | + { | ||
| 58 | + i24 = ByteUtil.assignBits(i24,feederTimer.getTimer_close_m(),0,7); | ||
| 59 | + } | ||
| 60 | + if(null != feederTimer.getTimer_close_h()) | ||
| 61 | + { | ||
| 62 | + i24 = ByteUtil.assignBits(i24,feederTimer.getTimer_close_h(),8,13); | ||
| 63 | + } | ||
| 64 | + if(null != feederTimer.getTimer_if_close()) | ||
| 65 | + { | ||
| 66 | + i24 = ByteUtil.assignBits(i24,feederTimer.getTimer_close_h(),14,14); | ||
| 67 | + } | ||
| 68 | + if(null != feederTimer.getTimer_is_close()) | ||
| 69 | + { | ||
| 70 | + i24 = ByteUtil.assignBits(i24,feederTimer.getTimer_is_close(),15,15); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + byte[] data = ArrayUtil.addAll( ByteUtil.intToBytesDESC(i23,2),ByteUtil.intToBytesDESC(i24,2)); | ||
| 74 | + FeederCommdDto feederCommdDto = new FeederCommdDto(new FeederCommd10Response(23+timerNumber-1,4,8,data)); | ||
| 75 | + return feederCommdDto.getHstr(); | ||
| 76 | + } | ||
| 77 | +} |
lh-modules/lh-smart-feeder/src/main/java/com/zhonglai/luhui/smart/feeder/util/serial/SerialTool.java
| @@ -58,7 +58,10 @@ public class SerialTool { | @@ -58,7 +58,10 @@ public class SerialTool { | ||
| 58 | 58 | ||
| 59 | // 通过端口名识别端口 | 59 | // 通过端口名识别端口 |
| 60 | CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); | 60 | CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); |
| 61 | - | 61 | + if(portIdentifier.isCurrentlyOwned()) |
| 62 | + { | ||
| 63 | + throw new RuntimeException("串口已被占用"); | ||
| 64 | + } | ||
| 62 | // 打开端口,并给端口名字和一个timeout(打开操作的超时时间) | 65 | // 打开端口,并给端口名字和一个timeout(打开操作的超时时间) |
| 63 | CommPort commPort = portIdentifier.open(portName, 2000); | 66 | CommPort commPort = portIdentifier.open(portName, 2000); |
| 64 | 67 | ||
| @@ -68,7 +71,6 @@ public class SerialTool { | @@ -68,7 +71,6 @@ public class SerialTool { | ||
| 68 | try { | 71 | try { |
| 69 | // 设置一下串口的波特率等参数 | 72 | // 设置一下串口的波特率等参数 |
| 70 | serialPort.setSerialPortParams(baudrate, dataBits, stopBits, parity); | 73 | serialPort.setSerialPortParams(baudrate, dataBits, stopBits, parity); |
| 71 | - logger.info("串口" + portName + "打开成功"); | ||
| 72 | } catch (UnsupportedCommOperationException e) { | 74 | } catch (UnsupportedCommOperationException e) { |
| 73 | logger.error("设置串口" + portName + "参数失败:" + e.getMessage()); | 75 | logger.error("设置串口" + portName + "参数失败:" + e.getMessage()); |
| 74 | throw e; | 76 | throw e; |
| @@ -144,6 +146,15 @@ public class SerialTool { | @@ -144,6 +146,15 @@ public class SerialTool { | ||
| 144 | } | 146 | } |
| 145 | } | 147 | } |
| 146 | 148 | ||
| 149 | + public static OutputStream getSerialPortStream( SerialPort serialPort) throws IOException { | ||
| 150 | + return serialPort.getOutputStream(); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + public static void sendToPort(byte[] order, OutputStream out) throws IOException { | ||
| 154 | + out.write(order); | ||
| 155 | + out.flush(); | ||
| 156 | + } | ||
| 157 | + | ||
| 147 | /** | 158 | /** |
| 148 | * 往串口发送数据 | 159 | * 往串口发送数据 |
| 149 | * | 160 | * |
| @@ -161,6 +172,10 @@ public class SerialTool { | @@ -161,6 +172,10 @@ public class SerialTool { | ||
| 161 | try { | 172 | try { |
| 162 | 173 | ||
| 163 | out = serialPort.getOutputStream(); | 174 | out = serialPort.getOutputStream(); |
| 175 | + if(null == out) | ||
| 176 | + { | ||
| 177 | + logger.error("窗口未打开" ); | ||
| 178 | + } | ||
| 164 | out.write(order); | 179 | out.write(order); |
| 165 | out.flush(); | 180 | out.flush(); |
| 166 | logger.info("发送数据成功" + serialPort.getName()); | 181 | logger.info("发送数据成功" + serialPort.getName()); |
| @@ -171,7 +186,6 @@ public class SerialTool { | @@ -171,7 +186,6 @@ public class SerialTool { | ||
| 171 | try { | 186 | try { |
| 172 | if (out != null) { | 187 | if (out != null) { |
| 173 | out.close(); | 188 | out.close(); |
| 174 | - out = null; | ||
| 175 | } | 189 | } |
| 176 | } catch (IOException e) { | 190 | } catch (IOException e) { |
| 177 | logger.error("关闭串口对象的输出流出错"); | 191 | logger.error("关闭串口对象的输出流出错"); |
| @@ -240,7 +254,10 @@ public class SerialTool { | @@ -240,7 +254,10 @@ public class SerialTool { | ||
| 240 | public static void addListener(SerialPortEventListener listener, SerialPort serialPort) throws TooManyListenersException { | 254 | public static void addListener(SerialPortEventListener listener, SerialPort serialPort) throws TooManyListenersException { |
| 241 | 255 | ||
| 242 | try { | 256 | try { |
| 243 | - | 257 | + if(null == serialPort) |
| 258 | + { | ||
| 259 | + throw new RuntimeException("端口未初始化"); | ||
| 260 | + } | ||
| 244 | // 给串口添加监听器 | 261 | // 给串口添加监听器 |
| 245 | serialPort.addEventListener(listener); | 262 | serialPort.addEventListener(listener); |
| 246 | // 设置当有数据到达时唤醒监听接收线程 | 263 | // 设置当有数据到达时唤醒监听接收线程 |
| 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 | ||
| 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:/opt/lh-smart-feeder/lh-smart-feeder/html/" cacheFilePath: "E:/opt/lh-smart-feeder/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: 12_ZNZY #订阅的topic topics: PUT/+,GET_REQ/+, READ/+,POST_REQ/+ sub_clientid: '70094a59d1d991d' username: 12_ZNZY password: Luhui586 client: #客户端操作时间 operationTime: 10 |
| @@ -20,7 +20,6 @@ import com.ruoyi.common.core.domain.AjaxResult; | @@ -20,7 +20,6 @@ import com.ruoyi.common.core.domain.AjaxResult; | ||
| 20 | import com.ruoyi.common.enums.BusinessType; | 20 | import com.ruoyi.common.enums.BusinessType; |
| 21 | import com.zhonglai.zl.email.forwarding.domain.RelayDomains; | 21 | import com.zhonglai.zl.email.forwarding.domain.RelayDomains; |
| 22 | import com.zhonglai.zl.email.forwarding.service.IRelayDomainsService; | 22 | import com.zhonglai.zl.email.forwarding.service.IRelayDomainsService; |
| 23 | -import com.zhonglai.luhui.sys.utils.ExcelUtil; | ||
| 24 | import com.ruoyi.common.core.page.TableDataInfo; | 23 | import com.ruoyi.common.core.page.TableDataInfo; |
| 25 | 24 | ||
| 26 | /** | 25 | /** |
| @@ -50,19 +49,6 @@ public class RelayDomainsController extends BaseController | @@ -50,19 +49,6 @@ public class RelayDomainsController extends BaseController | ||
| 50 | } | 49 | } |
| 51 | 50 | ||
| 52 | /** | 51 | /** |
| 53 | - * 导出转发地址管理列表 | ||
| 54 | - */ | ||
| 55 | - @ApiOperation("导出转发地址管理列表") | ||
| 56 | - @Log(title = "转发地址管理", businessType = BusinessType.EXPORT) | ||
| 57 | - @PostMapping("/export") | ||
| 58 | - public void export(HttpServletResponse response, RelayDomains relayDomains) | ||
| 59 | - { | ||
| 60 | - List<RelayDomains> list = relayDomainsService.selectRelayDomainsList(relayDomains); | ||
| 61 | - ExcelUtil<RelayDomains> util = new ExcelUtil<RelayDomains>(RelayDomains.class); | ||
| 62 | - util.exportExcel(response, list, "转发地址管理数据"); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - /** | ||
| 66 | * 获取转发地址管理详细信息 | 52 | * 获取转发地址管理详细信息 |
| 67 | */ | 53 | */ |
| 68 | @ApiOperation("获取转发地址管理详细信息") | 54 | @ApiOperation("获取转发地址管理详细信息") |
-
请 注册 或 登录 后发表评论