فهرست منبع

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

yeshijie 6 سال پیش
والد
کامیت
fd6f99f484
1فایلهای تغییر یافته به همراه30 افزوده شده و 20 حذف شده
  1. 30 20
      svr/svr-iot/src/main/java/com/yihu/iot/controller/analyzer/IotAnalyzerController.java

+ 30 - 20
svr/svr-iot/src/main/java/com/yihu/iot/controller/analyzer/IotAnalyzerController.java

@ -3,26 +3,23 @@ package com.yihu.iot.controller.analyzer;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.service.DataInputService;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.datainput.util.ConstantUtils;
import com.yihu.iot.service.company.IotCompanyCertificateService;
import com.yihu.iot.service.company.IotCompanyService;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.restmodel.iot.company.IotCompanyVO;
import com.yihu.jw.restmodel.iot.device.IotOrderVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.DataRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
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.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.HashMap;
@ -43,27 +40,33 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    ObjectMapper objectMapper;
    ObjectMapper objectMapper;
    @Autowired
    private FastDFSUtil fastDFSHelper;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastDfsPublicServers;
    /**
    /**
     * 基于奕拓小屋上传的体征数据,进行解析入库
     * 基于奕拓小屋上传的体征数据,进行解析入库
     * @param dataJson
     * @param jsonData
     * @return
     * @return
     */
     */
    @GetMapping(value = "/yitouxiaowu")
    @ApiOperation(value = "基于传入的JSON串采集数据,进行解析并入库", notes = "JSON串采集数据解析入库")
    public String findCompanyPage(
            @ApiParam(name = "dataJson", value = "采集数据JSON串", defaultValue = "")
            @RequestParam(value = "dataJson", required = false) String dataJson){
    @PostMapping(value = "/yitouxiaowu" ,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "奕拓体征数据解析入库", notes = "奕拓体征数据解析入库")
    public String updateDeviceDataTest(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData){
        Envelop envelop = new Envelop();
        Envelop envelop = new Envelop();
        String str = "";
        String str = "";
        String strResult = "";
        String strResult = "";
        //1. 基础数据初始化
        //1. 基础数据初始化
        String accessToken  = "yitouxiaowu";  // 奕拓小屋
        String accessToken  = "yitouxiaowu";  // 奕拓小屋
        try {
        try {
            //JSON数据解析
            //JSON数据解析
            Map dataDetail = objectMapper.readValue(dataJson, HashMap.class);
            Map dataDetail = objectMapper.readValue(jsonData, HashMap.class);
            // 用户信息
            // 用户信息
            LinkedHashMap memberMap = (LinkedHashMap)dataDetail.get("Member");
            LinkedHashMap memberMap = (LinkedHashMap)dataDetail.get("Member");
            // 身高体重
            // 身高体重
@ -188,6 +191,13 @@ public class IotAnalyzerController extends EnvelopRestEndpoint {
            if (ecgMap != null) {
            if (ecgMap != null) {
                data.put("ecg",ecgMap.get("Hr") == null? "": ecgMap.get("Hr").toString());
                data.put("ecg",ecgMap.get("Hr") == null? "": ecgMap.get("Hr").toString());
                data.put("ecg_unit","次/分");
                data.put("ecg_unit","次/分");
                if(!(ecgMap.get("EcgImg") == null)){
                    String ecgData = ecgMap.get("EcgImg").toString();
                    byte[] imgByte = Base64.decodeBase64(ecgData);
                    ObjectNode objectNode = fastDFSHelper.upload(imgByte,"png","");
                    String resPath = fastDfsPublicServers + objectNode.get("fileId").toString().replaceAll("\"", "");
                    data.put("filepath",resPath);
                }
            }
            }
            data.put("hbalc","");
            data.put("hbalc","");
            data.put("hbalc_unit","");
            data.put("hbalc_unit","");