|
|
@ -0,0 +1,85 @@
|
|
|
package com.yihu.iot.controller.third;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.iot.dao.healthDevice.HealthDeviceDataDao;
|
|
|
import com.yihu.iot.datainput.service.HealthDeviceDataService;
|
|
|
import com.yihu.iot.datainput.util.DesAndSignIdongUtil;
|
|
|
import com.yihu.jw.entity.iot.healthDevice.HealthDeviceData;
|
|
|
import com.yihu.jw.util.entity.ServiceException;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import static org.springframework.http.MediaType.*;
|
|
|
|
|
|
/**
|
|
|
* 健康一体机设备数据
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("weixin/healthDevice")
|
|
|
@Api(tags = "开放接口-健康一体机设备", description = "开放接口-健康一体机设备")
|
|
|
public class HealthDeviceDataController {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(HealthDeviceDataController.class);
|
|
|
|
|
|
@Autowired
|
|
|
private HealthDeviceDataService healthDeviceDataService;
|
|
|
@Autowired
|
|
|
private HealthDeviceDataDao healthDeviceDataDao;
|
|
|
|
|
|
@PostMapping(value = "uploadHealthHourseData")
|
|
|
@ApiOperation(value = "集美健康小屋设备数据上传", notes = "集美健康小屋设备数据上传")
|
|
|
public JSONObject uploadHealthHourseData(@RequestBody String data){
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
try{
|
|
|
healthDeviceDataService.uploadHealthHourseData(data);
|
|
|
jsonObject.put("success",true);
|
|
|
jsonObject.put("message","上传成功");
|
|
|
return jsonObject;
|
|
|
} catch (Exception e){
|
|
|
jsonObject.put("success",false);
|
|
|
jsonObject.put("message",e.getMessage());
|
|
|
return jsonObject;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "uploadIdongDeviceData")
|
|
|
@ApiOperation(value = "开元体侧设备数据上传", notes = "开元体侧设备数据上传")
|
|
|
public JSONObject uploadIdongDeviceData(String content,String version,Long serNum,String sign){
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
try{
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
String signLocal= DesAndSignIdongUtil.getSign(content,serNum,version);
|
|
|
if (sign.equalsIgnoreCase(signLocal)){
|
|
|
List<HealthDeviceData> healthDeviceDataList = healthDeviceDataDao.selectBySerNum(serNum+"");
|
|
|
if (healthDeviceDataList!=null&&healthDeviceDataList.size()>0){
|
|
|
jsonObject.put("result",4);
|
|
|
jsonObject.put("Msg","重复数据");
|
|
|
return jsonObject;
|
|
|
}
|
|
|
healthDeviceDataService.uploadIdongDeviceData(content,serNum);
|
|
|
}else{
|
|
|
jsonObject.put("result",-1);
|
|
|
jsonObject.put("Msg","程序异常");
|
|
|
return jsonObject;
|
|
|
}
|
|
|
jsonObject.put("result",0);
|
|
|
jsonObject.put("Msg","成功");
|
|
|
return jsonObject;
|
|
|
} catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
jsonObject.put("result",-1);
|
|
|
jsonObject.put("Msg","程序异常");
|
|
|
return jsonObject;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|