|
|
|
@ -1,19 +1,28 @@
|
|
|
|
|
package com.xydl.cac.controller;
|
|
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.Bdz;
|
|
|
|
|
import com.xydl.cac.entity.NSensor;
|
|
|
|
|
import com.xydl.cac.exception.BusinessException;
|
|
|
|
|
import com.xydl.cac.model.ConditionModel;
|
|
|
|
|
import com.xydl.cac.model.Response;
|
|
|
|
|
import com.xydl.cac.model.SensorDetail;
|
|
|
|
|
import com.xydl.cac.service.NSensorService;
|
|
|
|
|
import com.xydl.cac.service.ParamBindService;
|
|
|
|
|
import com.xydl.cac.service.ReportService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.data.repository.query.Param;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@Api(tags = {"监测设备相关接口"})
|
|
|
|
@ -23,6 +32,24 @@ public class NSensorController extends BasicController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
NSensorService service;
|
|
|
|
|
@Resource
|
|
|
|
|
ReportService reportService;
|
|
|
|
|
@Resource
|
|
|
|
|
ParamBindService bindService;
|
|
|
|
|
|
|
|
|
|
@GetMapping("getTrunk")
|
|
|
|
|
@ApiOperation("查询树干")
|
|
|
|
|
public Response<List<Bdz>> getTrunk() throws Exception {
|
|
|
|
|
List<Bdz> result = bindService.getTrunk();
|
|
|
|
|
return Response.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("getTree")
|
|
|
|
|
@ApiOperation("查询树")
|
|
|
|
|
public Response<List<Bdz>> getTree() throws Exception {
|
|
|
|
|
List<Bdz> result = bindService.getTree();
|
|
|
|
|
return Response.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("listAll")
|
|
|
|
|
@ApiOperation("查询列表")
|
|
|
|
@ -55,11 +82,15 @@ public class NSensorController extends BasicController {
|
|
|
|
|
return Response.success("OK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("detail")
|
|
|
|
|
@ApiOperation("详情")
|
|
|
|
|
public Response<NSensor> detail(@Validated @NotNull(message = "ID不能为空!") Integer id) throws Exception {
|
|
|
|
|
NSensor detail = service.detail(id);
|
|
|
|
|
return Response.success(detail);
|
|
|
|
|
@GetMapping("detail")
|
|
|
|
|
@ApiOperation("查询单个装置采集到的数据")
|
|
|
|
|
public Response<SensorDetail> getDetail(@Validated ConditionModel model) throws Exception {
|
|
|
|
|
if (model.getPageNum() != null || model.getPageSize() != null) {
|
|
|
|
|
model.setPageNum(this.initPageNum(model.getPageNum()));
|
|
|
|
|
model.setPageSize(this.initPageSize(model.getPageSize()));
|
|
|
|
|
}
|
|
|
|
|
SensorDetail result = service.getDetail(model);
|
|
|
|
|
return Response.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("bindicd")
|
|
|
|
@ -73,4 +104,30 @@ public class NSensorController extends BasicController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("importCac")
|
|
|
|
|
@ApiOperation("导入CAC")
|
|
|
|
|
public Response<String> importCac(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
|
|
if (file != null && file.getInputStream() != null) {
|
|
|
|
|
reportService.importCac(file.getInputStream());
|
|
|
|
|
return Response.success("OK");
|
|
|
|
|
} else {
|
|
|
|
|
return Response.fail("缺少上传文件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("export")
|
|
|
|
|
@ApiOperation("导出单个装置采集到的数据")
|
|
|
|
|
public void export(@Validated ConditionModel model, HttpServletResponse response) throws Exception {
|
|
|
|
|
if (model.getPageNum() != null || model.getPageSize() != null) {
|
|
|
|
|
model.setPageNum(this.initPageNum(model.getPageNum()));
|
|
|
|
|
model.setPageSize(this.initPageSize(model.getPageSize()));
|
|
|
|
|
}
|
|
|
|
|
SensorDetail<Map<String, Object>> detail = service.getDetail(model);
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="
|
|
|
|
|
+ URLEncoder.encode(detail.getSensor().getName() + ".xlsx", "UTF-8"));
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
|
reportService.exportSensor(detail, response.getOutputStream());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|