| | |
| | | <select id="getSmsOrderList" resultType="com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar"> |
| | | SELECT |
| | | o.id, |
| | | o.getoffTime, |
| | | o.travelTime, |
| | | o.smsTime,o.smsNumber,o.userId,o.orderMoney, |
| | | u.phone passengersPhone |
| | | FROM |
| | |
| | | import com.stylefeng.guns.modular.system.service.IOrderService; |
| | | import com.stylefeng.guns.modular.system.util.GDMapElectricFenceUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushMinistryOfTransportUtil; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | for(OrderPrivateCar order : orderList){ |
| | | if(order.getSmsTime()==null ){ |
| | | if(order.getGetoffTime().getTime()+24*60*60*1000L<day.getTime()){ |
| | | if((order.getTravelTime().getTime()+24*60*60*1000L)<day.getTime()){ |
| | | order.setSmsNumber(order.getSmsNumber()+1); |
| | | order.setSmsTime(day); |
| | | //发送短信 |
| | |
| | | systemNoticeService.addSystemNotice(1, "有一笔订单未付款,请前往支付!", order.getUserId()); |
| | | } |
| | | }else{ |
| | | if(order.getSmsTime().getTime()+24*60*60*1000L<day.getTime()){ |
| | | if((order.getSmsTime().getTime()+24*60*60*1000L)<day.getTime()){ |
| | | order.setSmsNumber(order.getSmsNumber()+1); |
| | | order.setSmsTime(day); |
| | | //发送短信 |
| | |
| | | |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | public boolean unlock(){ |
| | | return unlock("redis"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加地理空间索引坐标 |
| | | * @param k |
| | | * @param lon |
| | | * @param lat |
| | | * @param object |
| | | */ |
| | | public void addGeo(String k, Double lon, Double lat, String object){ |
| | | Point point = new Point(lon, lat); |
| | | redisTemplate.opsForGeo().add(k, point, object); |
| | | } |
| | | } |
| | |
| | | public void taskMinute(){ |
| | | try { |
| | | //修改满足活动条件的数据(在线时长,订单量) |
| | | driverService.taskMinute(); |
| | | // driverService.taskMinute(); |
| | | // 处理车载端断电后的自动下班 |
| | | // driverService.taskOffWork(); |
| | | // 处理结束订单后30分钟解绑小号功能 |
| | |
| | | public void taskFiveMinute(){ |
| | | try { |
| | | //处理未支付订单发送短信通知 |
| | | // orderService.taskSmsSend(); |
| | | for (Integer id: driverIds){ |
| | | orderService.taskSmsSend(); |
| | | // for (Integer id: driverIds){ |
| | | // jgPushUtil.push(1, "您的预约订单出行时间就要到了,请尽快前往预约地点接乘客", "DRIVER" + id); |
| | | } |
| | | // } |
| | | this.driverIds.clear(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | package com.sinata.push.util; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | public boolean unlock(){ |
| | | return unlock("redis"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加地理空间索引坐标 |
| | | * @param k |
| | | * @param lon |
| | | * @param lat |
| | | * @param object |
| | | */ |
| | | public void addGeo(String k, Double lon, Double lat, String object){ |
| | | Point point = new Point(lon, lat); |
| | | redisTemplate.opsForGeo().add(k, point, object); |
| | | } |
| | | } |
| | |
| | | if(StringUtil.isNotEmpty(token)){ |
| | | String token_ = redisUtil.getValue("USER_" + userId1);//获取缓存中最新的数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向其他设备发送数据 |
| | | ChannelHandlerContext context = NettyChannelMap.getData("Applets" + userId1); |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(context, msg_.toJSONString()); |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove(context); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // ChannelHandlerContext context = NettyChannelMap.getData("Applets" + userId1); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(context, msg_.toJSONString()); |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove(context); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | } |
| | | if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("USER_" + userId1, token); |
| | |
| | | if(StringUtil.isNotEmpty(token)){ |
| | | String token_ = redisUtil.getValue("USER_" + userId1);//获取缓存中最新的数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向其他设备发送数据 |
| | | ChannelHandlerContext context = NettyChannelMap.getData("USER" + userId1); |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(context, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove(context); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // ChannelHandlerContext context = NettyChannelMap.getData("USER" + userId1); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(context, msg_.toJSONString());//给当前通道发送消息 |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove(context); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | } |
| | | if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("USER_" + userId1, token); |
| | |
| | | String token_ = redisUtil.getValue("DRIVER_" + userId1);//缓存中拿最新数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token_.equals(token)){ |
| | | //如果是车载端登录,则将其它端都强迫下线 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove(ctx); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | } |
| | | if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("DRIVER_" + userId1, token); |
| | |
| | | if(StringUtil.isNotEmpty(token) && StringUtil.isEmpty(value)){//APP端登录的操作 |
| | | String token_ = redisUtil.getValue("DRIVER_" + userId1);//缓存中拿最新数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向当前设备发送数据 |
| | | ChannelHandlerContext context = NettyChannelMap.getData("DRIVER" + userId1); |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(context, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove(context); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // ChannelHandlerContext context = NettyChannelMap.getData("DRIVER" + userId1); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(context, msg_.toJSONString());//给当前通道发送消息 |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove(context); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | } |
| | | if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("DRIVER_" + userId1, token); |
| | |
| | | } |
| | | System.out.println("id:" + driverId + "---lon" + lon + "---lat" + lat); |
| | | redisUtil.setStrValue("DRIVER" + driverId, lon + "," + lat, 300);//实时位置存入redis中 |
| | | redisUtil.addGeo("DRIVER_POSITION", lon, lat, driverId.toString()); |
| | | }else{ |
| | | NettyServerController.sendMsgToClient(ctx, "__error__" + msg.toString()); |
| | | } |
| | |
| | | List<Driver> queryIdleDriver(@Param("type") Integer type, @Param("companyId") Integer companyId); |
| | | |
| | | |
| | | List<Driver> queryIdleDriverByIds(@Param("type") Integer type, @Param("ids") List<String> ids); |
| | | |
| | | |
| | | /** |
| | | * 获取当前已上班type业务类型、设置了可以接此类型的单据、服务车型匹配且空闲的司机 |
| | | * @param type |
| | |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="queryIdleDriverByIds" resultType="Driver"> |
| | | select * |
| | | from t_driver |
| | | where flag != 3 and state = 2 and authState = 2 and id in |
| | | <foreach collection="ids" index="index" item="item" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | and id in(select driverId from t_driver_work where startTime < now() and state = 1 and `type` like CONCAT('%', #{type}, '%')) |
| | | and id in (select driverId from t_driver_orders where `type` = #{type}) |
| | | </select> |
| | | |
| | | <select id="queryIdleDriver_" resultType="Driver"> |
| | | select |
| | |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.GeoResult; |
| | | import org.springframework.data.redis.connection.RedisGeoCommands; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<Driver> queryDriverLimitTen(Integer type, Double lon, Double lat) { |
| | | List<Driver> drivers = driverMapper.queryIdleDriver(type, null); |
| | | if(CollectionUtils.isEmpty(drivers)){ |
| | | List<GeoResult<RedisGeoCommands.GeoLocation<String>>> driverPosition = redisUtil.getNearGeoSortAscending("DRIVER_POSITION", lon, lat, 5000D); |
| | | if(CollectionUtils.isEmpty(driverPosition)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | List<RedisGeoCommands.GeoLocation<String>> geoLocations = driverPosition.stream().map(GeoResult::getContent).collect(Collectors.toList()); |
| | | driverPosition.stream().map(GeoResult::getContent).collect(Collectors.toList()); |
| | | List<String> dis = geoLocations.stream().map(RedisGeoCommands.GeoLocation::getName).collect(Collectors.toList()); |
| | | List<Driver> drivers = driverMapper.queryIdleDriverByIds(type, dis); |
| | | Iterator<Driver> iterator = drivers.iterator(); |
| | | while (iterator.hasNext()){ |
| | | Driver driver = iterator.next(); |
| | |
| | | Map<String, String> map1 = null; |
| | | String body1 = null; |
| | | try { |
| | | String certPath = "D:\\app\\cert\\weixin\\1716524249\\apiclient_cert.p12"; |
| | | String certPath = "D:\\app\\cert\\weixin\\1602881362\\apiclient_cert.p12"; |
| | | body1 = httpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | // 一个商户号只能初始化一个配置,否则会因为重复的下载任务报错 |
| | | Config config = new RSAAutoCertificateConfig.Builder() |
| | | .merchantId(mchId) |
| | | .privateKeyFromPath("D:\\app\\cert\\weixin\\1716524249\\apiclient_key.pem") |
| | | .privateKeyFromPath("D:\\app\\cert\\weixin\\1602881362\\apiclient_key.pem") |
| | | .merchantSerialNumber("5410CEAE9C7E9CDFCB58B88E1C607D2841F62437") |
| | | .apiV3Key("FCB58B88E1C607D2841F62437QIGZOdM") |
| | | .build(); |
| | |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String certPath = "D:\\app\\cert\\weixin\\1716524249\\apiclient_cert.p12";//证书地址 |
| | | String certPath = "D:\\app\\cert\\weixin\\1602881362\\apiclient_cert.p12";//证书地址 |
| | | String body1 = httpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | |
| | | xmlString.append("</xml>"); |
| | | |
| | | Map<String, String> map1 = null; |
| | | String certPath = "D:\\app\\cert\\weixin\\1716524249\\apiclient_cert.p12";//证书地址 |
| | | String certPath = "D:\\app\\cert\\weixin\\1602881362\\apiclient_cert.p12";//证书地址 |
| | | String body1 = httpClientUtil.pushHttpsRequsetXml(url, xmlString.toString(), new HashMap<>(), mchId, certPath, "PKCS12"); |
| | | //将结果xml解析成map |
| | | body1 = body1.replaceAll("<!\\[CDATA\\[",""); |
| | |
| | | |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.geo.Circle; |
| | | import org.springframework.data.geo.GeoResult; |
| | | import org.springframework.data.geo.GeoResults; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.redis.connection.RedisGeoCommands; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | public boolean unlock(){ |
| | | return unlock("redis"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 检索坐标为中心直径范围内的数据,单位米 |
| | | * @param k |
| | | * @param lon |
| | | * @param lat |
| | | * @param radius |
| | | * @return |
| | | */ |
| | | public List<GeoResult<RedisGeoCommands.GeoLocation<String>>> getNearGeo(String k, Double lon, Double lat, Double radius){ |
| | | Circle within = new Circle(lon, lat, radius); |
| | | GeoResults<RedisGeoCommands.GeoLocation<String>> geoResults = redisTemplate.opsForGeo().radius(k, within); |
| | | return geoResults.getContent(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 检索坐标为中心直径范围内的数据,单位米,由近到远排序 |
| | | * @param k |
| | | * @param lon |
| | | * @param lat |
| | | * @param radius |
| | | * @return |
| | | */ |
| | | public List<GeoResult<RedisGeoCommands.GeoLocation<String>>> getNearGeoSortAscending(String k, Double lon, Double lat, Double radius){ |
| | | Circle within = new Circle(lon, lat, radius); |
| | | RedisGeoCommands.GeoRadiusCommandArgs geoRadiusCommandArgs = RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs(); |
| | | geoRadiusCommandArgs.sortAscending(); |
| | | GeoResults<RedisGeoCommands.GeoLocation<String>> geoResults = redisTemplate.opsForGeo().radius(k, within, geoRadiusCommandArgs); |
| | | return geoResults.getContent(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加地理空间索引坐标 |
| | | * @param k |
| | | * @param lon |
| | | * @param lat |
| | | * @param object |
| | | */ |
| | | public void addGeo(String k, Double lon, Double lat, String object){ |
| | | Point point = new Point(lon, lat); |
| | | redisTemplate.opsForGeo().add(k, point, object); |
| | | } |
| | | } |
| | |
| | | appletsAppSecret: 4d966de14ab6c6a5137ad44ee67c5307 #应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 |
| | | appid: 1 #小程序APPid |
| | | appSecret: 1 # |
| | | mchId: 1716524249 #微信支付分配的商户号 |
| | | key: FCB58B88E1C607D2841F62437QIGZOdM #key为商户平台设置的密钥key: |
| | | mchId: 1602881362 #微信支付分配的商户号 |
| | | key: xMCkkqlmQO3VEHwV5BgTSfdMIGZewO5I #key为商户平台设置的密钥key: |
| | | |
| | | --- |
| | | |
| | |
| | | //package com.stylefeng.guns; |
| | | // |
| | | //import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | //import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | //import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | //import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | //import org.junit.Test; |
| | | //import org.junit.runner.RunWith; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.boot.test.context.SpringBootTest; |
| | | //import org.springframework.data.geo.GeoResult; |
| | | //import org.springframework.data.redis.connection.RedisGeoCommands; |
| | | //import org.springframework.test.context.junit4.SpringRunner; |
| | | // |
| | | //import java.util.Map; |
| | | //import java.util.List; |
| | | // |
| | | ///** |
| | | // * @author zhibing.pu |
| | | // * @Date 2024/9/24 9:24 |
| | | // */ |
| | |
| | | //public class GunsApplicationTest { |
| | | // |
| | | // @Autowired |
| | | // private PayMoneyUtil payMoneyUtil; |
| | | // |
| | | // @Autowired |
| | | // private IOrderPrivateCarService orderPrivateCarService; |
| | | // private RedisUtil redisUtil; |
| | | // |
| | | // |
| | | // @Test |
| | | // public void test(){ |
| | | // try { |
| | | // orderPrivateCarService.payPrivateCarOrder(1, 37630, null, 1); |
| | | // } catch (Exception e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // List<GeoResult<RedisGeoCommands.GeoLocation<String>>> driverPosition = redisUtil.getNearGeo("DRIVER_POSITION", 104.5615D, 30.456275D, 50000D); |
| | | // System.err.println(driverPosition); |
| | | // } |
| | | //} |
| | |
| | | NettyChannelMap.update_(token.substring(0, 23), ctx);//存储单点登录的通道 |
| | | String token_ = redisUtil.getValue("USER_" + userId1);//获取缓存中最新的数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向其他设备发送数据 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString()); |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove_(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(ctx, msg_.toJSONString()); |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove_(ctx); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | } |
| | | if(StringUtil.isEmpty(token_)){//确保登录的时候存储token失败的情况 |
| | | redisUtil.setStrValue("USER_" + userId1, token); |
| | |
| | | if(StringUtil.isNotEmpty(token)){ |
| | | String token_ = redisUtil.getValue("USER_" + userId1);//获取缓存中最新的数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向其他设备发送数据 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove_(ctx); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove_(ctx); |
| | | // NettyChannelMap.remove(ctx); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | }else{ |
| | | NettyChannelMap.update_(token.substring(0, 23), ctx); |
| | | NettyChannelMap.update("USER" + userId1, ctx); |
| | |
| | | String token_ = redisUtil.getValue("DRIVER_" + userId1);//缓存中拿最新数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token_.equals(token)){ |
| | | //如果是车载端登录,则将其它端都强迫下线 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove_(ctx); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove_(ctx); |
| | | // NettyChannelMap.remove(ctx); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | }else{ |
| | | System.err.println("开始存储司机通道" + userId1); |
| | | NettyChannelMap.update("DRIVER" + userId1, ctx); |
| | |
| | | if(StringUtil.isNotEmpty(token) && StringUtil.isEmpty(device) && StringUtil.isEmpty(value)){//APP端登录的操作 |
| | | String token_ = redisUtil.getValue("DRIVER_" + userId1);//缓存中拿最新数据 |
| | | if(StringUtil.isNotEmpty(token_) && !token.equals(token_)){//不在同一设备上登录,向当前设备发送数据 |
| | | JSONObject msg_ = new JSONObject(); |
| | | msg_.put("code", 200); |
| | | msg_.put("msg", "SUCCESS"); |
| | | msg_.put("method", "OFFLINE"); |
| | | msg_.put("data", new Object()); |
| | | this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | TimerTask timerTask = new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | NettyChannelMap.remove_(ctx); |
| | | NettyChannelMap.remove(ctx); |
| | | } |
| | | }; |
| | | Timer timer = new Timer(); |
| | | timer.schedule(timerTask, 3000); |
| | | timer.cancel(); |
| | | // JSONObject msg_ = new JSONObject(); |
| | | // msg_.put("code", 200); |
| | | // msg_.put("msg", "SUCCESS"); |
| | | // msg_.put("method", "OFFLINE"); |
| | | // msg_.put("data", new Object()); |
| | | // this.sendMsgToClient(ctx, msg_.toJSONString());//给当前通道发送消息 |
| | | // TimerTask timerTask = new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // NettyChannelMap.remove_(ctx); |
| | | // NettyChannelMap.remove(ctx); |
| | | // } |
| | | // }; |
| | | // Timer timer = new Timer(); |
| | | // timer.schedule(timerTask, 3000); |
| | | // timer.cancel(); |
| | | }else{ |
| | | System.err.println("开始存储司机通道" + userId1); |
| | | NettyChannelMap.update("DRIVER" + userId1, ctx); |