Commit 7f5f31d6 authored by 马33's avatar 马33
parents 76c12b3f ea51d299
...@@ -4,7 +4,7 @@ CREATE TABLE `pms_use_log` ...@@ -4,7 +4,7 @@ CREATE TABLE `pms_use_log`
( (
`id` int(10) NOT NULL AUTO_INCREMENT, `id` int(10) NOT NULL AUTO_INCREMENT,
`sn` varchar(30) DEFAULT NULL COMMENT '设备编号', `sn` varchar(30) DEFAULT NULL COMMENT '设备编号',
`status` int(1) DEFAULT '0' COMMENT '状态 1:成功,0:失败', `status` int(1) DEFAULT '1' COMMENT '状态 1:成功,0:失败',
`error_code` varchar(10) DEFAULT NULL COMMENT '如果失败,则这是失败的代号', `error_code` varchar(10) DEFAULT NULL COMMENT '如果失败,则这是失败的代号',
`message` varchar(200) DEFAULT NULL COMMENT '如果失败,则这里是失败的信息', `message` varchar(200) DEFAULT NULL COMMENT '如果失败,则这里是失败的信息',
`create_time` datetime DEFAULT NULL COMMENT '创建时间', `create_time` datetime DEFAULT NULL COMMENT '创建时间',
...@@ -16,7 +16,7 @@ CREATE TABLE `pms_use_log` ...@@ -16,7 +16,7 @@ CREATE TABLE `pms_use_log`
DEFAULT CHARSET = utf8 COMMENT ='使用记录表'; DEFAULT CHARSET = utf8 COMMENT ='使用记录表';
ALTER TABLE `device` ALTER TABLE `device`
ADD COLUMN `status` int(1) NULL DEFAULT '0' COMMENT '状态 0:未使用,1:已使用,2:失效' AFTER `app_id`; ADD COLUMN `status` int(1) NULL DEFAULT NULL COMMENT '状态 0:未使用,1:已使用,2:失效' AFTER `app_id`;
ALTER TABLE `device` ALTER TABLE `device`
ADD COLUMN `sn_bind` varchar(30) NULL DEFAULT NULL COMMENT '绑定的SN' AFTER `status`; ADD COLUMN `sn_bind` varchar(30) NULL DEFAULT NULL COMMENT '绑定的SN' AFTER `status`;
\ No newline at end of file
...@@ -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;
import java.util.List; import java.util.List;
...@@ -35,6 +39,6 @@ public class TerminalDeviceController { ...@@ -35,6 +39,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;
......
...@@ -13,5 +13,5 @@ public interface TerminalDeviceService { ...@@ -13,5 +13,5 @@ public interface TerminalDeviceService {
BaseResult reportErrorMsg(List<ReportErrorMsgDTO> reportErrorMsgDTO); BaseResult reportErrorMsg(List<ReportErrorMsgDTO> reportErrorMsgDTO);
BaseResult terminalDevieBind(TerminalDevieBindDTO terminalDevieBindDTO); BaseResult terminalDeviceBind(TerminalDevieBindDTO terminalDevieBindDTO);
} }
...@@ -35,7 +35,7 @@ public class PmsUseServiceImpl implements PmsUseService { ...@@ -35,7 +35,7 @@ public class PmsUseServiceImpl implements PmsUseService {
@Override @Override
public void createFailUseLog(String sn, String message) { public void createFailUseLog(String sn, String message) {
PmsUseLog pmsUseLog = getPmsUseLog(sn); PmsUseLog pmsUseLog = getPmsUseLog(sn);
pmsUseLog.setStatus(0); // pmsUseLog.setStatus(0);
pmsUseLog.setMessage(message); pmsUseLog.setMessage(message);
pmsUseLogMapper.insert(pmsUseLog); pmsUseLogMapper.insert(pmsUseLog);
} }
......
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,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -17,6 +18,7 @@ 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;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
...@@ -29,6 +31,8 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -29,6 +31,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) {
...@@ -89,7 +93,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -89,7 +93,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)) {
...@@ -97,6 +101,7 @@ public class TerminalDeviceServiceImpl implements TerminalDeviceService { ...@@ -97,6 +101,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