Browse Source

代码修改

LAPTOP-KB9HII50\70708 1 year ago
parent
commit
1b609732f1

+ 4 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DeviceUploadController.java

@ -7,7 +7,10 @@ import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

+ 22 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/iot/service/IotDeviceService.java

@ -48,6 +48,28 @@ public class IotDeviceService {
    private static String iotHospital = "350211A1049";
    private static String iotHospitalName = "厦门医学院附属海沧医院";
    //设备状态信息上传
    @Transactional
    public String uploadDeviceThird(String jsonData,String type){
        Map<String,String> header = new HashMap<>();
//        String jsonData = "{\"deviceSn\":\"xty_hcyy\",\"deviceModel\":\"测试\",\"name\":\"血糖仪TEST\",\"hospital\":\""+iotHospital+"\"," +
//                "\"hospitalName\":\""+iotHospitalName+"\",\"categoryCode\":\"2\",\"categoryName\":\" 血糖仪\",\"commonName\":\" 血糖仪\"," +
//                "\"combinationMethod\":\"1\",\"networkTransmission\":\" 11\",\"deviceUse\":\"2\",\"dropLocation\":\"2\",\"dataAcquisition\":" +
//                "\"IoT_equipment_blood_glucose_mete\",\"companyName\":\"血糖仪厂商名称\",\"companyType\":\"3\"}";
        Map<String,String> params = new HashMap<>();
        params.put("jsonData",jsonData);
        header.put("accesstoken",getAccessToken());
        String content = "";
        if("uploadDeviceInfo".equals(type)){
            content = "设备状态信息上传";
        }else if("uploadDeviceData".equals(type)){
            content = "设备业务数据信息上传";
        }else if("deviceRegistration".equals(type)){
            content = "设备相关基础信息注册";
        }
        String response = sdkRunnerService.post("wlw/"+type,content,params,header,true,true);
        return response;
    }
    //设备状态信息上传
    @Transactional

+ 43 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/third/IotDeviceThirdController.java

@ -0,0 +1,43 @@
package com.yihu.jw.hospital.module.third;
import com.yihu.jw.hospital.module.iot.service.IotDeviceService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2024/2/19.
 */
@RestController
@RequestMapping(value ="/open/gc/iotDevice")
@Api(value = "物联网设备-对外", description = "物联网设备-对外", tags = {"物联网设备-对外"})
public class IotDeviceThirdController extends EnvelopRestEndpoint {
    @Autowired
    private IotDeviceService iotDeviceService;
    @PostMapping(value = "/uploadDeviceThird")
    @ApiOperation(value = "设备状态信息上传物联网平台")
    public Envelop uploadDeviceThird(String jsonData,String type) {
        try {
            if(StringUtils.isBlank(type)){
                return Envelop.getError("参数错误,type不能为空");
            }
            if(jsonData==null){
                return Envelop.getError("参数错误,jsonData不能为空");
            }
            return success(iotDeviceService.uploadDeviceThird(jsonData,type));
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("上传失败");
        }
    }
}