wwh hace 2 semanas
padre
commit
e00db84814

+ 1 - 1
app-admin/src/main/java/com/ruoyi/RuoYiApplication.java

@@ -23,6 +23,6 @@ public class RuoYiApplication
         ApplicationContext applicationContext = SpringApplication.run(RuoYiApplication.class, args);
 //        applicationContext.getBean(NFIDServer.class).start();
         // EnvInputServer
-        //applicationContext.getBean(EnvInputServer.class).run();
+        applicationContext.getBean(EnvInputServer.class).run();
     }
 }

+ 1 - 1
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/impl/JsDrugCheckServiceImpl.java

@@ -402,7 +402,7 @@ public class JsDrugCheckServiceImpl extends ServiceImpl<JsDrugCheckMapper, JsDru
                         //抽检头数
                         checkAmount = checkAmount + jsDrugCheck.getCheckAmount();
                         //合格头数
-                        if ("性".equals(jsDrugCheck.getResult())) {
+                        if ("性".equals(jsDrugCheck.getResult())) {
                             resultAmount = resultAmount + jsDrugCheck.getCheckAmount();
                         }
 

+ 17 - 11
app-admin/src/main/resources/application.yml

@@ -18,7 +18,7 @@ ruoyi:
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
-  port: 8088
+  port: 8089
   servlet:
     # 应用的访问路径
     context-path: /
@@ -76,7 +76,7 @@ spring:
     # 数据库索引
     database: 10
     # 密码
-#    password: hm123456
+    password: hm123456
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -99,14 +99,14 @@ token:
   # 令牌有效期(默认30分钟)
   expireTime: 30
 
-# MyBatis配置
-mybatis:
-  # 搜索指定包别名
-  typeAliasesPackage: com.ruoyi.**.domain
-  # 配置mapper的扫描,找到所有的mapper.xml映射文件
-  mapperLocations: classpath*:mapper/**/*Mapper.xml
-  # 加载全局的配置文件
-  configLocation: classpath:mybatis/mybatis-config.xml
+## MyBatis配置
+#mybatis:
+#  # 搜索指定包别名
+#  typeAliasesPackage: com.ruoyi.**.domain
+#  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+#  mapperLocations: classpath*:mapper/**/*Mapper.xml
+#  # 加载全局的配置文件
+#  configLocation: classpath:mybatis/mybatis-config.xml
 
 
 # PageHelper分页插件
@@ -141,8 +141,14 @@ xss:
 #  password: admin
 
 
+# MyBatis Plus配置
 mybatis-plus:
-  mapper-locations: classpath*:mapper/*.xml
+  # 搜索指定包别名
+  typeAliasesPackage: com.ruoyi.**.domain
+  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+  mapperLocations: classpath*:mapper/**/*Mapper.xml
+  # 加载全局的配置文件
+  configLocation: classpath:mybatis/mybatis-config.xml
 
 img:
   url: https://img.ifarmcloud.com/images/

+ 6 - 0
app-common/pom.xml

@@ -17,6 +17,12 @@
 
     <dependencies>
 
+        <!-- ruoyi-springboot2 / mybatis-plus 配置 -->
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.1</version>
+        </dependency>
         <!-- Spring框架基本的核心工具 -->
         <dependency>
             <groupId>org.springframework</groupId>

+ 1 - 82
app-common/src/main/java/com/ruoyi/common/server/EnvInputServerHandler.java

@@ -67,88 +67,7 @@ public class EnvInputServerHandler extends ChannelInboundHandlerAdapter {
     @Override
     public  void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
 
-        ByteBuf byteBuf = (ByteBuf) msg;
-        byte[] bytes = new byte[byteBuf.readableBytes()];
-        byteBuf.readBytes(bytes);
-        String str = ModBusUtils.bytes2HexString(bytes);
-        System.out.println("收到的数据:"+str);
-        if (!str.startsWith("5A 00")){
-            System.out.println("数据错误:"+str);
-            return;
-        }
-
-        if (bytes.length >80 &&  bytes.length<90){
-            int startIndex = 9;
-            int length = 20;
-            char[] asciiChars = new char[length];
-            for (int i = startIndex; i <  startIndex + length; i++) {
-                asciiChars[i - startIndex] = (char) (bytes[i] & 0xFF); // 使用 & 0xFF 来确保正确处理可能的负值
-            }
-            String asciiString = new String(asciiChars);
-            // 输出结果
-            System.out.println("ASCII String: " + asciiString);
-            String key = ctx.channel().id().asLongText();
-            channelMap.put(key,asciiString);
-            return;
-        }
-
-        //Netty需要用ByteBuf传输
-        ByteBuf bufff = Unpooled.buffer();
-        if (bytes.length < 20 &&bytes.length > 9 ){
-            bufff.writeBytes(hexString2Bytes("5A0001021000080000000"+INDEX+"01020006ED08"));
-            INDEX++;
-            if (INDEX > 4){
-                INDEX =1;
-            }
-        }
-        ctx.writeAndFlush(bufff);
-        String mapKey = ctx.channel().id().asLongText();
-        String clientip = channelMap.get(mapKey);
-        System.out.println(clientip + "-clientip");
-        if(bytes.length   > 49){
-            Date now = new Date();
-            String[] s = str.split(" ");
-            StringBuilder epc = new StringBuilder();
-            for (int i = 9; i < 9 + Integer.parseInt(s[8], 16); i++) {
-                epc.append(s[i]);
-            }
-            //String tian = s[23];
-            String key = DEVICE_PREFIX + epc;
-            System.out.println(epc + "-epc");
-            long timeDifferenceMillis ;
-            if (redisTemplate.hasKey(key)) {
-                String storedTimestampStr = redisTemplate.opsForValue().get(key);
-                if (storedTimestampStr != null) {
-                    long storedTimeMillis = Long.parseLong(storedTimestampStr);
-                    // 计算时间差(毫秒)
-                     timeDifferenceMillis = System.currentTimeMillis() - storedTimeMillis;
-                    //小于一分钟,更新时间戳
-                    if (timeDifferenceMillis < 60 * 1000) {
-                        redisTemplate.opsForValue().set(key, String.valueOf(System.currentTimeMillis()));
-                        redisTemplate.expire(key,6,TimeUnit.HOURS);
-                        System.out.println("时间小于一分钟,更新时间戳");
-                        return;
-                    }else {
-                        redisTemplate.delete(key);
-                    }
-                } else {
-                    // 如果键不存在,可以抛出一个异常或者返回一个特定的值
-                    throw new RuntimeException("Timestamp key not found in Redis");
-                }
-
-            } else {
-
-                System.out.println("存储");
-                return;
-            }
-
-
-            }
-
-
-        //停止读卡
-//        bufff.writeBytes(hexString2Bytes("5A000102FF0000885A"));
-//        ctx.writeAndFlush(bufff);
+        System.out.println("收到的数据:"+msg);
 
         super.channelRead(ctx, msg);
     }

+ 137 - 137
app-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java

@@ -1,137 +1,137 @@
-package com.ruoyi.framework.config;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import javax.sql.DataSource;
-
-import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
-import org.apache.ibatis.io.VFS;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.mybatis.spring.SqlSessionFactoryBean;
-import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import org.springframework.core.io.DefaultResourceLoader;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
-import org.springframework.core.type.classreading.MetadataReader;
-import org.springframework.core.type.classreading.MetadataReaderFactory;
-import org.springframework.util.ClassUtils;
-import com.ruoyi.common.utils.StringUtils;
-
-/**
- * Mybatis支持*匹配扫描包
- * 
- * @author ruoyi
- */
-@Configuration
-public class MyBatisConfig
-{
-    @Autowired
-    private Environment env;
-
-    static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
-
-    public static String setTypeAliasesPackage(String typeAliasesPackage)
-    {
-        ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
-        MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
-        List<String> allResult = new ArrayList<String>();
-        try
-        {
-            for (String aliasesPackage : typeAliasesPackage.split(","))
-            {
-                List<String> result = new ArrayList<String>();
-                aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
-                        + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
-                Resource[] resources = resolver.getResources(aliasesPackage);
-                if (resources != null && resources.length > 0)
-                {
-                    MetadataReader metadataReader = null;
-                    for (Resource resource : resources)
-                    {
-                        if (resource.isReadable())
-                        {
-                            metadataReader = metadataReaderFactory.getMetadataReader(resource);
-                            try
-                            {
-                                result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
-                            }
-                            catch (ClassNotFoundException e)
-                            {
-                                e.printStackTrace();
-                            }
-                        }
-                    }
-                }
-                if (result.size() > 0)
-                {
-                    HashSet<String> hashResult = new HashSet<String>(result);
-                    allResult.addAll(hashResult);
-                }
-            }
-            if (allResult.size() > 0)
-            {
-                typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
-            }
-            else
-            {
-                throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
-            }
-        }
-        catch (IOException e)
-        {
-            e.printStackTrace();
-        }
-        return typeAliasesPackage;
-    }
-
-    public Resource[] resolveMapperLocations(String[] mapperLocations)
-    {
-        ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
-        List<Resource> resources = new ArrayList<Resource>();
-        if (mapperLocations != null)
-        {
-            for (String mapperLocation : mapperLocations)
-            {
-                try
-                {
-                    Resource[] mappers = resourceResolver.getResources(mapperLocation);
-                    resources.addAll(Arrays.asList(mappers));
-                }
-                catch (IOException e)
-                {
-                    // ignore
-                }
-            }
-        }
-        return resources.toArray(new Resource[resources.size()]);
-    }
-
-    @Bean
-    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
-    {
-        String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
-        String mapperLocations = env.getProperty("mybatis.mapperLocations");
-        String configLocation = env.getProperty("mybatis.configLocation");
-        typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
-        VFS.addImplClass(SpringBootVFS.class);
-
-        //final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
-        // SqlSessionFactoryBean 替换为 ⬇ MybatisSqlSessionFactoryBean
-        final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
-        sessionFactory.setDataSource(dataSource);
-        sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
-        sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
-        sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
-        return sessionFactory.getObject();
-    }
-
-}
+//package com.ruoyi.framework.config;
+//
+//import java.io.IOException;
+//import java.util.ArrayList;
+//import java.util.Arrays;
+//import java.util.HashSet;
+//import java.util.List;
+//import javax.sql.DataSource;
+//
+//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
+//import org.apache.ibatis.io.VFS;
+//import org.apache.ibatis.session.SqlSessionFactory;
+//import org.mybatis.spring.SqlSessionFactoryBean;
+//import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.core.env.Environment;
+//import org.springframework.core.io.DefaultResourceLoader;
+//import org.springframework.core.io.Resource;
+//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+//import org.springframework.core.io.support.ResourcePatternResolver;
+//import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
+//import org.springframework.core.type.classreading.MetadataReader;
+//import org.springframework.core.type.classreading.MetadataReaderFactory;
+//import org.springframework.util.ClassUtils;
+//import com.ruoyi.common.utils.StringUtils;
+//
+///**
+// * Mybatis支持*匹配扫描包
+// *
+// * @author ruoyi
+// */
+//@Configuration
+//public class MyBatisConfig
+//{
+//    @Autowired
+//    private Environment env;
+//
+//    static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
+//
+//    public static String setTypeAliasesPackage(String typeAliasesPackage)
+//    {
+//        ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
+//        MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
+//        List<String> allResult = new ArrayList<String>();
+//        try
+//        {
+//            for (String aliasesPackage : typeAliasesPackage.split(","))
+//            {
+//                List<String> result = new ArrayList<String>();
+//                aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
+//                        + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
+//                Resource[] resources = resolver.getResources(aliasesPackage);
+//                if (resources != null && resources.length > 0)
+//                {
+//                    MetadataReader metadataReader = null;
+//                    for (Resource resource : resources)
+//                    {
+//                        if (resource.isReadable())
+//                        {
+//                            metadataReader = metadataReaderFactory.getMetadataReader(resource);
+//                            try
+//                            {
+//                                result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
+//                            }
+//                            catch (ClassNotFoundException e)
+//                            {
+//                                e.printStackTrace();
+//                            }
+//                        }
+//                    }
+//                }
+//                if (result.size() > 0)
+//                {
+//                    HashSet<String> hashResult = new HashSet<String>(result);
+//                    allResult.addAll(hashResult);
+//                }
+//            }
+//            if (allResult.size() > 0)
+//            {
+//                typeAliasesPackage = String.join(",", (String[]) allResult.toArray(new String[0]));
+//            }
+//            else
+//            {
+//                throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
+//            }
+//        }
+//        catch (IOException e)
+//        {
+//            e.printStackTrace();
+//        }
+//        return typeAliasesPackage;
+//    }
+//
+//    public Resource[] resolveMapperLocations(String[] mapperLocations)
+//    {
+//        ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
+//        List<Resource> resources = new ArrayList<Resource>();
+//        if (mapperLocations != null)
+//        {
+//            for (String mapperLocation : mapperLocations)
+//            {
+//                try
+//                {
+//                    Resource[] mappers = resourceResolver.getResources(mapperLocation);
+//                    resources.addAll(Arrays.asList(mappers));
+//                }
+//                catch (IOException e)
+//                {
+//                    // ignore
+//                }
+//            }
+//        }
+//        return resources.toArray(new Resource[resources.size()]);
+//    }
+//
+//    @Bean
+//    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
+//    {
+//        String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
+//        String mapperLocations = env.getProperty("mybatis.mapperLocations");
+//        String configLocation = env.getProperty("mybatis.configLocation");
+//        typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
+//        VFS.addImplClass(SpringBootVFS.class);
+//
+//        //final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
+//        // SqlSessionFactoryBean 替换为 ⬇ MybatisSqlSessionFactoryBean
+//        final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
+//        sessionFactory.setDataSource(dataSource);
+//        sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
+//        sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
+//        sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
+//        return sessionFactory.getObject();
+//    }
+//
+//}