浏览代码

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan 1 年之前
父节点
当前提交
dad436cce2

+ 4 - 3
svr/svr-iot/src/main/java/com/yihu/iot/controller/third/ThirdDataInputController.java

@ -22,7 +22,8 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException;
@RestController
@RequestMapping(IotRequestMapping.Common.openThird)
//@RequestMapping(IotRequestMapping.Common.openThird)
@RequestMapping("open")
@Api(tags = "开放接口-数据上传操作", description = "开放接口-数据上传操作")
public class ThirdDataInputController {
@ -64,7 +65,7 @@ public class ThirdDataInputController {
    }
    @PostMapping(value = "uploadDeviceData")
    @ApiOperation(value = "设备注册", notes = "设备注册")
    @ApiOperation(value = "上传设备数据", notes = "上传设备数据")
    public Envelop uploadDeviceData(@ApiParam(name = "jsonData", value = "", defaultValue = "")
                                    @RequestBody String jsonData){
        try{
@ -73,7 +74,7 @@ public class ThirdDataInputController {
            return Envelop.getError(e.getMessage());
        } catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("设备注册失败");
            return Envelop.getError("上传设备失败");
        }
    }

+ 12 - 5
svr/svr-iot/src/main/java/com/yihu/iot/datainput/service/DataInputService.java

@ -97,12 +97,12 @@ public class DataInputService {
        if(StringUtils.isBlank(categoryName)){
            throw new ServiceException("设备类型名称不能为空");
        }
        int count = iotDeviceService.countByDeviceSn(deviceSn);
        if(count > 0){
            throw new ServiceException("设备唯一码已存在,请检查是否已经上传过,或者换一个编码");
        }
        String result = "";
        try {
            int count = iotDeviceService.countByDeviceSn(deviceSn);
            if(count > 0){
                throw new ServiceException("设备唯一码已存在,请检查是否已经上传过,或者换一个编码");
            }
            IotDeviceDO iotDeviceDO = new IotDeviceDO();
            iotDeviceDO.setDeviceSn(deviceSn);
            iotDeviceDO.setCategoryCode(categoryCode);
@ -127,12 +127,19 @@ public class DataInputService {
        JSONObject jsonObject = JSONObject.parseObject(json);
        String deviceSn = jsonObject.getString("deviceSn");
        String hospital = jsonObject.getString("hospital");
        String data = jsonObject.getJSONArray("data").toJSONString();
        if(StringUtils.isBlank(data)){
            throw new ServiceException("设备数据data不能为空");
        }
        if(data.length()>60000){
            throw new ServiceException("设备数据data超过最大允许字符");
        }
        String categoryCode = jsonObject.getString("categoryCode");
        try {
            IotDeviceUploadRecordDO recordDO = new IotDeviceUploadRecordDO();
            recordDO.setDeviceSn(deviceSn);
            recordDO.setHospital(hospital);
            recordDO.setJsonData(jsonObject.getJSONArray("data").toJSONString());
            recordDO.setJsonData(data);
            recordDO.setCategoryCode(categoryCode);
            recordDO.setStatus(0);
            recordDO.setCreateTime(new Date());

+ 2 - 2
svr/svr-iot/src/main/resources/application.yml

@ -150,7 +150,7 @@ wechat:
spring:
  profiles: jwtest
  datasource:
    url: jdbc:mysql://172.26.0.104/xmiot?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    url: jdbc:mysql://172.26.0.104/xmiot?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: ssgg
    password: ssgg@jkzl2019
#  elasticsearch:
@ -189,7 +189,7 @@ wechat:
spring:
  profiles: iottest
  datasource:
    url: jdbc:mysql://172.26.0.104/xmiot?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    url: jdbc:mysql://172.26.0.104/xmiot?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: ssgg
    password: ssgg@jkzl2019
#  elasticsearch: