|
|
@@ -2,9 +2,12 @@ package com.xunmei.mediator.api.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
-import com.xunmei.mediator.api.service.*;
|
|
|
+import com.xunmei.mediator.api.service.IIotDeviceService;
|
|
|
+import com.xunmei.mediator.api.service.IIotDvrChannelService;
|
|
|
+import com.xunmei.mediator.api.service.IotDeviceDetectionService;
|
|
|
+import com.xunmei.mediator.api.service.IotSensorService;
|
|
|
import com.xunmei.system.api.RemoteDeviceService;
|
|
|
+import com.xunmei.system.api.RemoteFileService;
|
|
|
import com.xunmei.system.api.dto.DataPageDto;
|
|
|
import com.xunmei.system.api.dto.SensorDto;
|
|
|
import com.xunmei.system.api.dto.SensorStatusDto;
|
|
|
@@ -12,13 +15,19 @@ import com.xunmei.system.api.dto.device.DeviceDto;
|
|
|
import com.xunmei.system.api.dto.protection.NetworkDeviceDetectionEditDto;
|
|
|
import com.xunmei.system.api.dto.protection.ReceiveErrorDto;
|
|
|
import com.xunmei.system.api.util.LogUtils;
|
|
|
+import feign.Response;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.BufferedInputStream;
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -109,7 +118,6 @@ public class DataController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@ApiOperation(value = "传感器通用设备信息同步", notes = "直连主机传感器,每个完整的包为一个机构机构数据,非所有机构数据")
|
|
|
@PostMapping({"/api/data/sensorCommonList"})
|
|
|
public ReceiveErrorDto sensor(String msgId, @RequestBody DataPageDto<SensorDto> sensors) {
|
|
|
@@ -168,4 +176,28 @@ public class DataController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RemoteFileService fileService;
|
|
|
+
|
|
|
+ @ApiOperation("传感器通用设备信息同步")
|
|
|
+ @PostMapping({"/api/test/{path}"})
|
|
|
+ public void sensor(@PathVariable String path, HttpServletResponse response) throws IOException {
|
|
|
+ Response result = fileService.readFile(path);
|
|
|
+ Response.Body body = result.body();
|
|
|
+ InputStream inputStream = body.asInputStream();
|
|
|
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
|
|
+ response.setHeader("Content-Disposition", result.headers().get("Content-Disposition").toString().replace("[", "").replace("]", ""));
|
|
|
+ BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(response.getOutputStream());
|
|
|
+ int length = 0;
|
|
|
+ byte[] temp = new byte[1024 * 10];
|
|
|
+ while ((length = bufferedInputStream.read(temp)) != -1) {
|
|
|
+ bufferedOutputStream.write(temp, 0, length);
|
|
|
+ }
|
|
|
+ bufferedOutputStream.flush();
|
|
|
+ bufferedOutputStream.close();
|
|
|
+ bufferedInputStream.close();
|
|
|
+ inputStream.close();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|