二维码扫描功能废弃
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
package com;
|
package com;
|
||||||
|
|
||||||
import com.sv.netty.config.SpringContextHolder;
|
import com.sv.netty.config.SpringContextHolder;
|
||||||
import com.sv.netty.netty.BootService;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
@@ -17,7 +15,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@MapperScan(value = {"com.sv.mapper"})
|
@MapperScan(value = {"com.sv.mapper"})
|
||||||
public class NettyWeiXinApplication {
|
public class WeiXinApplication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动项目
|
* 启动项目
|
||||||
@@ -25,11 +23,8 @@ public class NettyWeiXinApplication {
|
|||||||
* @param args 启动参数
|
* @param args 启动参数
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ConfigurableApplicationContext context = SpringApplication.run(NettyWeiXinApplication.class, args);
|
ConfigurableApplicationContext context = SpringApplication.run(WeiXinApplication.class, args);
|
||||||
SpringContextHolder.setContext(context);
|
SpringContextHolder.setContext(context);
|
||||||
//启动netty
|
|
||||||
BootService bootService = (BootService) context.getBean("bootService");
|
|
||||||
bootService.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -108,12 +108,4 @@ public class AppVenueLessonController {
|
|||||||
return venueItems;
|
return venueItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询远程配置项目,可以让APP联网可配置
|
|
||||||
*/
|
|
||||||
@RequestMapping(value = "/getRemoteConfig", method = {RequestMethod.GET,RequestMethod.POST})
|
|
||||||
public Map<String,String> getRemoteConfig() {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,56 +20,56 @@ import javax.annotation.Resource;
|
|||||||
/**
|
/**
|
||||||
* 小程序二维码进场Controller
|
* 小程序二维码进场Controller
|
||||||
*/
|
*/
|
||||||
@RestController
|
//@RestController
|
||||||
public class QREnterController extends BaseApiController {
|
public class QREnterController extends BaseApiController {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(QREnterController.class);
|
private final Logger logger = LoggerFactory.getLogger(QREnterController.class);
|
||||||
@Resource
|
// @Resource
|
||||||
private QRCodeService qrCodeService;
|
private QRCodeService qrCodeService;
|
||||||
@Resource
|
// @Resource
|
||||||
private MessageService messageService;
|
private MessageService messageService;
|
||||||
/**
|
/**
|
||||||
* 进场指令发布
|
* 进场指令发布
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/qrCode/enter", method = RequestMethod.GET)
|
// @RequestMapping(value = "/qrCode/enter", method = RequestMethod.GET)
|
||||||
public ResponseDTO enter(@RequestParam("deviceId") String deviceId) {
|
// public ResponseDTO enter(@RequestParam("deviceId") String deviceId) {
|
||||||
Integer memberId = getMemberIdByAccessToken();
|
// Integer memberId = getMemberIdByAccessToken();
|
||||||
Integer venueId = getVenueId(deviceId);
|
// Integer venueId = getVenueId(deviceId);
|
||||||
String deviceName = getDeviceName(deviceId);
|
// String deviceName = getDeviceName(deviceId);
|
||||||
DeviceType enterOrOut = getEnterOrOut(deviceId);
|
// DeviceType enterOrOut = getEnterOrOut(deviceId);
|
||||||
Venue venue = qrCodeService.initEnter(venueId, deviceName,enterOrOut,memberId);
|
// Venue venue = qrCodeService.initEnter(venueId, deviceName,enterOrOut,memberId);
|
||||||
qrCodeService.unBindMember(venueId, deviceName, enterOrOut);
|
// qrCodeService.unBindMember(venueId, deviceName, enterOrOut);
|
||||||
if (venue!=null){
|
// if (venue!=null){
|
||||||
if (DeviceType.OUT == enterOrOut){
|
// if (DeviceType.OUT == enterOrOut){
|
||||||
// 出场
|
// // 出场
|
||||||
messageService.outVenue(deviceName,venueId,memberId,venue);
|
// messageService.outVenue(deviceName,venueId,memberId,venue);
|
||||||
}else{
|
// }else{
|
||||||
// 进场
|
// // 进场
|
||||||
messageService.enterVenue(deviceName,venueId,memberId,venue);
|
// messageService.enterVenue(deviceName,venueId,memberId,venue);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return ResponseDTO.ok();
|
// return ResponseDTO.ok();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫码结果页初始化
|
* 扫码结果页初始化
|
||||||
* 需要进场的场馆信息
|
* 需要进场的场馆信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/qrCode/init", method = RequestMethod.GET)
|
// @RequestMapping(value = "/qrCode/init", method = RequestMethod.GET)
|
||||||
public ResponseDTO initEnter(@RequestParam("deviceId")String deviceId) {
|
// public ResponseDTO initEnter(@RequestParam("deviceId")String deviceId) {
|
||||||
try {
|
// try {
|
||||||
Integer memberId = getMemberIdByAccessToken();
|
// Integer memberId = getMemberIdByAccessToken();
|
||||||
Integer venueId = getVenueId(deviceId);
|
// Integer venueId = getVenueId(deviceId);
|
||||||
String deviceName = getDeviceName(deviceId);
|
// String deviceName = getDeviceName(deviceId);
|
||||||
DeviceType enterOrOut = getEnterOrOut(deviceId);
|
// DeviceType enterOrOut = getEnterOrOut(deviceId);
|
||||||
Venue venue = qrCodeService.initEnter(venueId, deviceName, enterOrOut,memberId);
|
// Venue venue = qrCodeService.initEnter(venueId, deviceName, enterOrOut,memberId);
|
||||||
qrCodeService.bindMember(venueId, deviceName, enterOrOut,memberId);
|
// qrCodeService.bindMember(venueId, deviceName, enterOrOut,memberId);
|
||||||
messageService.sendLoading(deviceName, venueId, enterOrOut, memberId);
|
// messageService.sendLoading(deviceName, venueId, enterOrOut, memberId);
|
||||||
return ResponseDTO.ok().addAttribute("venueInit", venue);
|
// return ResponseDTO.ok().addAttribute("venueInit", venue);
|
||||||
}catch(ServiceException e){
|
// }catch(ServiceException e){
|
||||||
return ResponseDTO.ok().addAttribute("InitError",e.getMessage());
|
// return ResponseDTO.ok().addAttribute("InitError",e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,58 +77,58 @@ public class QREnterController extends BaseApiController {
|
|||||||
* @param deviceId
|
* @param deviceId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Integer getVenueId(String deviceId){
|
// private Integer getVenueId(String deviceId){
|
||||||
String venueId = "0";
|
// String venueId = "0";
|
||||||
if (deviceId!=null && deviceId.contains(Constant.SPIT_WORD)){
|
// if (deviceId!=null && deviceId.contains(Constant.SPIT_WORD)){
|
||||||
venueId = deviceId.split(Constant.SPIT_WORD)[1];
|
// venueId = deviceId.split(Constant.SPIT_WORD)[1];
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
return Integer.parseInt(venueId);
|
// return Integer.parseInt(venueId);
|
||||||
}catch (Exception e){
|
// }catch (Exception e){
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字符串获取设备号
|
* 根据字符串获取设备号
|
||||||
* @param deviceId
|
* @param deviceId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getDeviceName(String deviceId){
|
// private String getDeviceName(String deviceId){
|
||||||
if (deviceId!=null){
|
// if (deviceId!=null){
|
||||||
return deviceId.split(Constant.SPIT_WORD)[0];
|
// return deviceId.split(Constant.SPIT_WORD)[0];
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字符串获取门禁类型
|
* 根据字符串获取门禁类型
|
||||||
* @param deviceId
|
* @param deviceId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private DeviceType getEnterOrOut(String deviceId){
|
// private DeviceType getEnterOrOut(String deviceId){
|
||||||
DeviceType returnType = DeviceType.ENTER;
|
// DeviceType returnType = DeviceType.ENTER;
|
||||||
if (deviceId!=null && deviceId.contains(Constant.SPIT_WORD)){
|
// if (deviceId!=null && deviceId.contains(Constant.SPIT_WORD)){
|
||||||
String temp = deviceId.split(Constant.SPIT_WORD)[1];
|
// String temp = deviceId.split(Constant.SPIT_WORD)[1];
|
||||||
if (temp!=null && temp.contains(Constant.SPIT_WORD)){
|
// if (temp!=null && temp.contains(Constant.SPIT_WORD)){
|
||||||
returnType = DeviceType.valueOf(temp.split(Constant.SPIT_WORD)[1]);
|
// returnType = DeviceType.valueOf(temp.split(Constant.SPIT_WORD)[1]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return returnType;
|
// return returnType;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检验客户端读取能力
|
* 检验客户端读取能力
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/checkAlive")
|
// @RequestMapping("/checkAlive")
|
||||||
public ResponseDTO checkAlive(@RequestParam String id) {
|
// public ResponseDTO checkAlive(@RequestParam String id) {
|
||||||
Integer venueId = getVenueId(id);
|
// Integer venueId = getVenueId(id);
|
||||||
String deviceName = getDeviceName(id);
|
// String deviceName = getDeviceName(id);
|
||||||
DeviceType enterOrOut = getEnterOrOut(id);
|
// DeviceType enterOrOut = getEnterOrOut(id);
|
||||||
logger.info("验证设备"+ id + "通讯情况");
|
// logger.info("验证设备"+ id + "通讯情况");
|
||||||
messageService.testLoad(deviceName,venueId,enterOrOut);
|
// messageService.testLoad(deviceName,venueId,enterOrOut);
|
||||||
return ResponseDTO.ok();
|
// return ResponseDTO.ok();
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.concurrent.Executors;
|
|||||||
* @Author peakren
|
* @Author peakren
|
||||||
* @Date 03/05/2017 6:18 PM
|
* @Date 03/05/2017 6:18 PM
|
||||||
*/
|
*/
|
||||||
@Component
|
//@Component
|
||||||
public class BootService {
|
public class BootService {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(BootService.class);
|
private Logger logger = LoggerFactory.getLogger(BootService.class);
|
||||||
@@ -40,25 +40,25 @@ public class BootService {
|
|||||||
/**
|
/**
|
||||||
* 下面几个是由spring注入
|
* 下面几个是由spring注入
|
||||||
*/
|
*/
|
||||||
@Value("${netty.port}")
|
// @Value("${netty.port}")
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
@Value("${so.keepalive}")
|
// @Value("${so.keepalive}")
|
||||||
private Boolean keepalive;
|
private Boolean keepalive;
|
||||||
|
|
||||||
@Value("${so.backlog}")
|
// @Value("${so.backlog}")
|
||||||
private int backlog;
|
private int backlog;
|
||||||
|
|
||||||
@Value("${tcp_nodelay}")
|
// @Value("${tcp_nodelay}")
|
||||||
private boolean nodelay;
|
private boolean nodelay;
|
||||||
|
|
||||||
@Value("${so.reuseaddr}")
|
// @Value("${so.reuseaddr}")
|
||||||
private boolean reuseaddr;
|
private boolean reuseaddr;
|
||||||
|
|
||||||
@Value("${boss.thread.count}")
|
// @Value("${boss.thread.count}")
|
||||||
private int bossCount;
|
private int bossCount;
|
||||||
|
|
||||||
@Value("${worker.thread.count}")
|
// @Value("${worker.thread.count}")
|
||||||
private int workerCount;
|
private int workerCount;
|
||||||
|
|
||||||
private Map<ChannelOption, Object> channelOptions;
|
private Map<ChannelOption, Object> channelOptions;
|
||||||
@@ -108,7 +108,6 @@ public class BootService {
|
|||||||
* 开启单独的线程运行netty服务,避免和spring mvc冲突
|
* 开启单独的线程运行netty服务,避免和spring mvc冲突
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
// messageExecutor = Executors.newFixedThreadPool(1);
|
|
||||||
messageExecutor = Executors.newSingleThreadExecutor();
|
messageExecutor = Executors.newSingleThreadExecutor();
|
||||||
messageExecutor.execute(() -> init());
|
messageExecutor.execute(() -> init());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import java.util.Set;
|
|||||||
* @author ranfi
|
* @author ranfi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ChannelHandler.Sharable
|
//@ChannelHandler.Sharable
|
||||||
public class ServerHandler extends SimpleChannelInboundHandler<String> {
|
public class ServerHandler extends SimpleChannelInboundHandler<String> {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ServerHandler.class);
|
private static Logger logger = LoggerFactory.getLogger(ServerHandler.class);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* @Author peakren
|
* @Author peakren
|
||||||
* @Date 09/05/2017 5:19 PM
|
* @Date 09/05/2017 5:19 PM
|
||||||
*/
|
*/
|
||||||
@Component
|
//@Component
|
||||||
public class ServerProtocolInitializer extends ChannelInitializer<SocketChannel> {
|
public class ServerProtocolInitializer extends ChannelInitializer<SocketChannel> {
|
||||||
|
|
||||||
private final int IDLE_TIME = 120; //连接检测空闲时间
|
private final int IDLE_TIME = 120; //连接检测空闲时间
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @Author peakren
|
* @Author peakren
|
||||||
* @Date 08/05/2017 10:43 PM
|
* @Date 08/05/2017 10:43 PM
|
||||||
*/
|
*/
|
||||||
@Service("messageService")
|
//@Service("messageService")
|
||||||
public class AppMessageHandlerAdapter implements MessageService {
|
public class AppMessageHandlerAdapter implements MessageService {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(AppMessageHandlerAdapter.class);
|
private Logger logger = LoggerFactory.getLogger(AppMessageHandlerAdapter.class);
|
||||||
@@ -49,25 +49,25 @@ public class AppMessageHandlerAdapter implements MessageService {
|
|||||||
*/
|
*/
|
||||||
private ConcurrentMap<String, Channel> links = PlatformDependent.newConcurrentHashMap();
|
private ConcurrentMap<String, Channel> links = PlatformDependent.newConcurrentHashMap();
|
||||||
|
|
||||||
@Resource
|
// @Resource
|
||||||
private MemberService memberService;
|
private MemberService memberService;
|
||||||
|
|
||||||
@Resource
|
// @Resource
|
||||||
private VenueService venueService;
|
private VenueService venueService;
|
||||||
|
|
||||||
@Resource
|
// @Resource
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
|
|
||||||
@Resource
|
// @Resource
|
||||||
private ConfigService configService;
|
private ConfigService configService;
|
||||||
|
|
||||||
@Resource(name = "scheduledExecutorService")
|
// @Resource(name = "scheduledExecutorService")
|
||||||
private ScheduledExecutorService scheduledExecutorService;
|
private ScheduledExecutorService scheduledExecutorService;
|
||||||
|
|
||||||
@Resource
|
// @Resource
|
||||||
private MemberEnterVenueLogService memberEnterVenueLogService;
|
private MemberEnterVenueLogService memberEnterVenueLogService;
|
||||||
|
|
||||||
@Resource
|
// @Resource
|
||||||
private RestTemplate restTemplate;
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* 小程序扫二维码处理
|
* 小程序扫二维码处理
|
||||||
*/
|
*/
|
||||||
@Service("qrCodeService")
|
//@Service("qrCodeService")
|
||||||
@Transactional(readOnly = true)
|
//@Transactional(readOnly = true)
|
||||||
public class QRCodeService {
|
public class QRCodeService {
|
||||||
private final Logger logger = LoggerFactory.getLogger(ProtocolService.class);
|
private final Logger logger = LoggerFactory.getLogger(ProtocolService.class);
|
||||||
|
|
||||||
@Resource
|
// @Resource
|
||||||
private VenueMapper venueMapper;
|
private VenueMapper venueMapper;
|
||||||
@Resource
|
// @Resource
|
||||||
private DeviceMapper deviceMapper;
|
private DeviceMapper deviceMapper;
|
||||||
|
|
||||||
public Venue initEnter(Integer venueId,String deviceName,DeviceType deviceType,Integer memberId) throws ServiceException{
|
public Venue initEnter(Integer venueId,String deviceName,DeviceType deviceType,Integer memberId) throws ServiceException{
|
||||||
|
|||||||
Reference in New Issue
Block a user