Commit be730734 authored by AfirSraftGarrier's avatar AfirSraftGarrier

绑定完善

parent e4d2d03d
...@@ -9,7 +9,11 @@ import iot.sixiang.license.model.dto.ReportErrorMsgDTO; ...@@ -9,7 +9,11 @@ import iot.sixiang.license.model.dto.ReportErrorMsgDTO;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO; import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.service.TerminalDeviceService; import iot.sixiang.license.service.TerminalDeviceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/iot_license/terminal_device") @RequestMapping("/iot_license/terminal_device")
...@@ -33,6 +37,6 @@ public class TerminalDeviceController { ...@@ -33,6 +37,6 @@ public class TerminalDeviceController {
@PostMapping("/bind") @PostMapping("/bind")
@ApiOperation(value = "终端设备绑定接口", notes = "终端设备绑定接口") @ApiOperation(value = "终端设备绑定接口", notes = "终端设备绑定接口")
public BaseResult terminalDevieBind(@RequestBody TerminalDevieBindDTO terminalDevieBindDTO) { public BaseResult terminalDevieBind(@RequestBody TerminalDevieBindDTO terminalDevieBindDTO) {
return terminalDeviceService.terminalDevieBind(terminalDevieBindDTO); return terminalDeviceService.terminalDeviceBind(terminalDevieBindDTO);
} }
} }
...@@ -13,14 +13,16 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -13,14 +13,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@Component @Component
@Slf4j @Slf4j
public class DeviceManager { public class DeviceManager {
private Map<String, SessionContext> sessionContexts = null; private Map<String, SessionContext> sessionContexts = null;
private DeviceChannelInitializer channelInitializer; private DeviceChannelInitializer channelInitializer;
private TcpServer server = null; private TcpServer server = null;
......
...@@ -11,5 +11,5 @@ public interface TerminalDeviceService { ...@@ -11,5 +11,5 @@ public interface TerminalDeviceService {
BaseResult reportErrorMsg(ReportErrorMsgDTO reportErrorMsgDTO); BaseResult reportErrorMsg(ReportErrorMsgDTO reportErrorMsgDTO);
BaseResult terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO); BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO);
} }
package iot.sixiang.license.service.impl; package iot.sixiang.license.service.impl;
import iot.sixiang.license.auth.AuthManager; import iot.sixiang.license.auth.AuthManager;
import iot.sixiang.license.device.DeviceManager;
import iot.sixiang.license.handler.IotLicenseException; import iot.sixiang.license.handler.IotLicenseException;
import iot.sixiang.license.jwt.JwtUtil; import iot.sixiang.license.jwt.JwtUtil;
import iot.sixiang.license.jwt.LoginUser; import iot.sixiang.license.jwt.LoginUser;
...@@ -17,6 +18,8 @@ import org.apache.commons.lang3.StringUtils; ...@@ -17,6 +18,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Slf4j @Slf4j
@Service @Service
public class TerminalDeviceServiceImpl implements TerminalDeviceService { public class TerminalDeviceServiceImpl implements TerminalDeviceService {
...@@ -26,6 +29,8 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -26,6 +29,8 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
private DeviceService deviceService; private DeviceService deviceService;
@Autowired @Autowired
private PmsUseService pmsUseService; private PmsUseService pmsUseService;
@Resource
private DeviceManager deviceManager;
@Override @Override
public ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO) { public ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO) {
...@@ -68,7 +73,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -68,7 +73,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
} }
@Override @Override
public BaseResult terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO) { public BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO) {
String sn = terminalDevieBindDTO.getSn(); String sn = terminalDevieBindDTO.getSn();
String snBind = terminalDevieBindDTO.getSnBind(); String snBind = terminalDevieBindDTO.getSnBind();
if (StringUtils.isEmpty(sn) || StringUtils.isEmpty(snBind)) { if (StringUtils.isEmpty(sn) || StringUtils.isEmpty(snBind)) {
...@@ -76,6 +81,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -76,6 +81,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
} }
Boolean res = deviceService.terminalDevieBind(terminalDevieBindDTO); Boolean res = deviceService.terminalDevieBind(terminalDevieBindDTO);
if (res) { if (res) {
deviceManager.initDevices();
return BaseResult.success(); return BaseResult.success();
} else { } else {
return BaseResult.failed(); return BaseResult.failed();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment