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