|
@ -16,17 +16,22 @@ import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
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.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
//@RequestMapping(IotRequestMapping.Common.openThird)
|
|
|
|
@RequestMapping("open")
|
|
|
|
|
|
@RequestMapping(IotRequestMapping.Common.openThird)
|
|
|
|
//@RequestMapping("open")
|
|
@Api(tags = "开放接口-数据上传操作", description = "开放接口-数据上传操作")
|
|
@Api(tags = "开放接口-数据上传操作", description = "开放接口-数据上传操作")
|
|
public class ThirdDataInputController {
|
|
public class ThirdDataInputController {
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ThirdDataInputController.class);
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private DataInputService dataInputService;
|
|
private DataInputService dataInputService;
|
|
@Autowired
|
|
@Autowired
|
|
@ -54,6 +59,13 @@ public class ThirdDataInputController {
|
|
public Envelop deviceRegistration(@ApiParam(name = "jsonData", value = "", defaultValue = "")
|
|
public Envelop deviceRegistration(@ApiParam(name = "jsonData", value = "", defaultValue = "")
|
|
@RequestBody String jsonData){
|
|
@RequestBody String jsonData){
|
|
try{
|
|
try{
|
|
|
|
logger.info("jsonData="+jsonData);
|
|
|
|
if(StringUtils.isNotBlank(jsonData)){
|
|
|
|
String decodedString = URLDecoder.decode(jsonData, "UTF-8");
|
|
|
|
if (!decodedString.equals(jsonData)) {
|
|
|
|
jsonData = decodedString;
|
|
|
|
}
|
|
|
|
}
|
|
dataInputService.deviceRegistration(jsonData);
|
|
dataInputService.deviceRegistration(jsonData);
|
|
return Envelop.getSuccess("设备注册成功");
|
|
return Envelop.getSuccess("设备注册成功");
|
|
} catch (ServiceException e){
|
|
} catch (ServiceException e){
|
|
@ -69,6 +81,12 @@ public class ThirdDataInputController {
|
|
public Envelop uploadDeviceData(@ApiParam(name = "jsonData", value = "", defaultValue = "")
|
|
public Envelop uploadDeviceData(@ApiParam(name = "jsonData", value = "", defaultValue = "")
|
|
@RequestBody String jsonData){
|
|
@RequestBody String jsonData){
|
|
try{
|
|
try{
|
|
|
|
if(StringUtils.isNotBlank(jsonData)){
|
|
|
|
String decodedString = URLDecoder.decode(jsonData, "UTF-8");
|
|
|
|
if (!decodedString.equals(jsonData)) {
|
|
|
|
jsonData = decodedString;
|
|
|
|
}
|
|
|
|
}
|
|
return Envelop.getSuccess(dataInputService.uploadDeviceData(jsonData));
|
|
return Envelop.getSuccess(dataInputService.uploadDeviceData(jsonData));
|
|
} catch (ServiceException e){
|
|
} catch (ServiceException e){
|
|
return Envelop.getError(e.getMessage());
|
|
return Envelop.getError(e.getMessage());
|
|
@ -78,6 +96,25 @@ public class ThirdDataInputController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping(value = "uploadDeviceInfo")
|
|
|
|
@ApiOperation(value = "设备状态信息上传", notes = "设备状态信息上传")
|
|
|
|
public Envelop uploadDeviceInfo(@ApiParam(name = "jsonData", value = "", defaultValue = "")
|
|
|
|
@RequestBody String jsonData){
|
|
|
|
try{
|
|
|
|
if(StringUtils.isNotBlank(jsonData)){
|
|
|
|
String decodedString = URLDecoder.decode(jsonData, "UTF-8");
|
|
|
|
if (!decodedString.equals(jsonData)) {
|
|
|
|
jsonData = decodedString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Envelop.getSuccess(dataInputService.uploadDeviceInfo(jsonData));
|
|
|
|
} catch (ServiceException e){
|
|
|
|
return Envelop.getError(e.getMessage());
|
|
|
|
} catch (Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
return Envelop.getError("上传设备失败");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/************************************************************************/
|
|
/************************************************************************/
|
|
|
|
|