wenhongquan 1 год назад
Родитель
Сommit
aecfb4f5f1

+ 1 - 1
ruoyi-admin/src/main/resources/application-dev.yml

@@ -96,7 +96,7 @@ spring.data:
     # 端口,默认为6379
     port: 6379
     # 数据库索引
-    database: 0
+    database: 11
     # 密码(如没有密码请注释掉)
     # password:
     # 连接超时时间

+ 1 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/domain/vo/TblCarInfoVo.java

@@ -108,6 +108,7 @@ public class TblCarInfoVo implements Serializable {
     private String ext2;
 
     private Object location;
+    private Object lastCountTime;
 
     private Map<String,Object> others;
 

+ 3 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/service/impl/TblCarInfoServiceImpl.java

@@ -76,6 +76,9 @@ public class TblCarInfoServiceImpl implements ITblCarInfoService {
                     if(deviceInfo.getStr("type").equals("gps")){
                         carInfoVo.setLocation(RedisUtils.getCacheObject(StringUtils.format("gps_{}", deviceInfo.getStr("code"))));
                     }
+                    if(deviceInfo.getStr("type").equals("people_count")){
+                        carInfoVo.setLastCountTime(RedisUtils.getCacheObject(StringUtils.format("count_{}", deviceInfo.getStr("code"))));
+                    }
                 });
             });
         }catch (Exception e){}

+ 3 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/service/impl/TblCarPathServiceImpl.java

@@ -67,6 +67,9 @@ public class TblCarPathServiceImpl implements ITblCarPathService {
         lqw.eq(bo.getAttendantInfo() != null, TblCarPath::getAttendantInfo, bo.getAttendantInfo());
         lqw.eq(StringUtils.isNotBlank(bo.getExt1()), TblCarPath::getExt1, bo.getExt1());
         lqw.eq(StringUtils.isNotBlank(bo.getExt2()), TblCarPath::getExt2, bo.getExt2());
+        if(bo.getParams()!=null && bo.getParams().get("station")!=null){
+            lqw.like(TblCarPath::getStationList, bo.getParams().get("station"));
+        }
         return lqw;
     }
 

+ 60 - 45
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/util/CamelDataUtil.java

@@ -21,6 +21,7 @@ import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.json.utils.JsonUtils;
 import org.dromara.common.redis.utils.CacheUtils;
 import org.dromara.common.redis.utils.RedisUtils;
+import org.dromara.netty.NettyChannelHandlerContextMapCache;
 import org.dromara.netty.pojo.NettyChannelHandlerContext;
 import org.dromara.sms4j.api.universal.RedisUtil;
 import org.dromara.system.domain.CountData;
@@ -380,61 +381,75 @@ public class CamelDataUtil {
         if(StrUtil.isNotEmpty(countdatastr.toString())){
             try{
                 this.SendData("direct:senddev", countdatastr.toString(), "devtype","-");
-
             }catch (Exception e){
 
             }
-            JSONObject countdata = JsonUtils.parseObject(countdatastr.toString(), JSONObject.class);
-
-            String sn = countdata.getStr("sn");
-            String type = countdata.getStr("type");
-            Long time = countdata.getLong("time");
-            Integer in = 0;
-            Integer out = 0;
-            Long iCreatedTime = 0L;
-            if(type.equals("count")){
-                //获取数据in out
-               JSONArray inoutarry =  ((JSONObject)(countdata.getJSONArray("data").get(0))).getJSONArray("count");
-                for (int i = 0; i < inoutarry.size(); i++) {
-                    if(((JSONObject)inoutarry.get(i)).getStr("name").equals("d1")){
-                        in = ((JSONObject)inoutarry.get(i)).getInt("in");
-                        out = ((JSONObject)inoutarry.get(i)).getInt("out");
-                        break;
+            try{
+                JSONObject countdata = JsonUtils.parseObject(countdatastr.toString(), JSONObject.class);
+
+                String sn = countdata.getStr("sn");
+                String type = countdata.getStr("type");
+                Long time = countdata.getLong("time");
+                try {
+                    NettyChannelHandlerContext topic = NettyChannelHandlerContextMapCache.ChannelMapCache.get(((ChannelHandlerContext) (exchange.getIn().getHeader("CamelNettyChannelHandlerContext"))).channel().toString());
+                    if (topic != null) {
+                        topic.setTag(sn);
                     }
-                }
-                iCreatedTime = ((JSONObject)(countdata.getJSONArray("data").get(0))).getLong("iCreatedTime");
-                if(iCreatedTime*1000>DateUtil.current()-24*3600*1000  && iCreatedTime*1000<DateUtil.current()+24*3600*1000){
-                    //正确的时间
-                    CountData countData = new CountData();
-                    countData.setIncount(in);
-                    countData.setOutcount(out);
-                    countData.setDevicecode(sn);
-                    countData.setTslong(iCreatedTime*1000);
-                    countDataService.insertData(countData);
-                }else{
-                    log.error("{}:时间错误",iCreatedTime);
+                    RedisUtils.setCacheObject(StringUtils.format("count_{}", sn), DateUtil.now());
+
+                }catch (Exception e){
 
                 }
-                //存储数据
+                Integer in = 0;
+                Integer out = 0;
+                Long iCreatedTime = 0L;
+                if(type.equals("count")){
+                    //获取数据in out
+                    JSONArray inoutarry =  ((JSONObject)(countdata.getJSONArray("data").get(0))).getJSONArray("count");
+                    for (int i = 0; i < inoutarry.size(); i++) {
+                        if(((JSONObject)inoutarry.get(i)).getStr("name").equals("d1")){
+                            in = ((JSONObject)inoutarry.get(i)).getInt("in");
+                            out = ((JSONObject)inoutarry.get(i)).getInt("out");
+                            break;
+                        }
+                    }
+                    iCreatedTime = ((JSONObject)(countdata.getJSONArray("data").get(0))).getLong("iCreatedTime");
+                    if(iCreatedTime*1000>DateUtil.current()-24*3600*1000  && iCreatedTime*1000<DateUtil.current()+24*3600*1000){
+                        //正确的时间
+                        CountData countData = new CountData();
+                        countData.setIncount(in);
+                        countData.setOutcount(out);
+                        countData.setDevicecode(sn);
+                        countData.setTslong(iCreatedTime*1000);
+                        countDataService.insertData(countData);
+                    }else{
+                        log.error("{}:时间错误",iCreatedTime);
+
+                    }
+                    //存储数据
 //                log.info("{},{},{},{},{}",sn,type,in,out,iCreatedTime);
-            }
+                }
+                //组织返回数据
+                JSONObject result = new JSONObject();
+                result.put( "sn" , sn) ;
+                result.put("type", type) ;
+                if(type.equals("heart")){
+                    JSONObject sub = new JSONObject() ;
+                    sub.put("time", time) ;
+                    result.put("data", sub ) ;
+                }else{
+                    result.put("time", time  ) ;
+                }
+
+                NettyChannelHandlerContext ctx = ChannelMapCache.get(((ChannelHandlerContext)exchange.getIn().getHeader("CamelNettyChannelHandlerContext")).channel().toString());
+                ByteBuf buf = Unpooled.copiedBuffer(JsonUtils.toJsonString(result).getBytes(CharsetUtil.UTF_8));
+                ctx.getChannelHandlerContext().writeAndFlush(buf);
+
+            }catch (Exception e){}
+
 
 
-            //组织返回数据
-            JSONObject result = new JSONObject();
-            result.put( "sn" , sn) ;
-            result.put("type", type) ;
-            if(type.equals("heart")){
-                JSONObject sub = new JSONObject() ;
-                sub.put("time", time) ;
-                result.put("data", sub ) ;
-            }else{
-                result.put("time", time  ) ;
-            }
 
-            NettyChannelHandlerContext ctx = ChannelMapCache.get(((ChannelHandlerContext)exchange.getIn().getHeader("CamelNettyChannelHandlerContext")).channel().toString());
-            ByteBuf buf = Unpooled.copiedBuffer(JsonUtils.toJsonString(result).getBytes(CharsetUtil.UTF_8));
-            ctx.getChannelHandlerContext().writeAndFlush(buf);
         }