Commit be730734 authored by AfirSraftGarrier's avatar AfirSraftGarrier

绑定完善

parent e4d2d03d
......@@ -9,7 +9,11 @@ import iot.sixiang.license.model.dto.ReportErrorMsgDTO;
import iot.sixiang.license.model.dto.TerminalDevieBindDTO;
import iot.sixiang.license.service.TerminalDeviceService;
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
@RequestMapping("/iot_license/terminal_device")
......@@ -33,6 +37,6 @@ public class TerminalDeviceController {
@PostMapping("/bind")
@ApiOperation(value = "终端设备绑定接口", notes = "终端设备绑定接口")
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;
import org.springframework.stereotype.Component;
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
@Slf4j
public class DeviceManager {
private Map<String, SessionContext> sessionContexts = null;
private DeviceChannelInitializer channelInitializer;
private TcpServer server = null;
......
......@@ -11,5 +11,5 @@ public interface TerminalDeviceService {
BaseResult reportErrorMsg(ReportErrorMsgDTO reportErrorMsgDTO);
BaseResult terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO);
BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO);
}
package iot.sixiang.license.service.impl;
import iot.sixiang.license.auth.AuthManager;
import iot.sixiang.license.device.DeviceManager;
import iot.sixiang.license.handler.IotLicenseException;
import iot.sixiang.license.jwt.JwtUtil;
import iot.sixiang.license.jwt.LoginUser;
......@@ -17,6 +18,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Slf4j
@Service
public class TerminalDeviceServiceImpl implements TerminalDeviceService {
......@@ -26,6 +29,8 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
private DeviceService deviceService;
@Autowired
private PmsUseService pmsUseService;
@Resource
private DeviceManager deviceManager;
@Override
public ResResult getToken(GetTerminalDeviceTokenDTO getTerminalDeviceTokenDTO) {
......@@ -68,7 +73,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
}
@Override
public BaseResult terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO) {
public BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO) {
String sn = terminalDevieBindDTO.getSn();
String snBind = terminalDevieBindDTO.getSnBind();
if (StringUtils.isEmpty(sn) || StringUtils.isEmpty(snBind)) {
......@@ -76,6 +81,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService {
}
Boolean res = deviceService.terminalDevieBind(terminalDevieBindDTO);
if (res) {
deviceManager.initDevices();
return BaseResult.success();
} else {
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