|
|
|
@ -7,6 +7,7 @@ import com.xydl.cac.model.ConditionModel;
|
|
|
|
|
import com.xydl.cac.model.Response;
|
|
|
|
|
import com.xydl.cac.model.SensorDetail;
|
|
|
|
|
import com.xydl.cac.model.SensorUpdateModel;
|
|
|
|
|
import com.xydl.cac.repository.NSensorRepository;
|
|
|
|
|
import com.xydl.cac.service.NSensorService;
|
|
|
|
|
import com.xydl.cac.service.ParamBindService;
|
|
|
|
|
import com.xydl.cac.service.ReportService;
|
|
|
|
@ -16,6 +17,7 @@ import io.swagger.annotations.ApiParam;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.repository.query.Param;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
@ -24,6 +26,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -39,6 +42,8 @@ public class NSensorController extends BasicController {
|
|
|
|
|
ReportService reportService;
|
|
|
|
|
@Resource
|
|
|
|
|
ParamBindService bindService;
|
|
|
|
|
@Resource
|
|
|
|
|
NSensorRepository sensorRepository;
|
|
|
|
|
|
|
|
|
|
@GetMapping("getTrunk")
|
|
|
|
|
@ApiOperation("查询树干")
|
|
|
|
@ -137,18 +142,38 @@ public class NSensorController extends BasicController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("export")
|
|
|
|
|
@ApiOperation("导出单个装置采集到的数据")
|
|
|
|
|
@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());
|
|
|
|
|
|
|
|
|
|
if (model.getTypeId() != null) {
|
|
|
|
|
String typename = "";
|
|
|
|
|
List<NSensor> list = sensorRepository.findByTypeId(model.getTypeId());
|
|
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
throw new BusinessException("未找到该类型的装置");
|
|
|
|
|
}
|
|
|
|
|
List<SensorDetail<Map<String, Object>>> detailList = new ArrayList<>();
|
|
|
|
|
for (NSensor sensor : list) {
|
|
|
|
|
model.setId(sensor.getId());
|
|
|
|
|
SensorDetail<Map<String, Object>> detail = service.getDetail(model);
|
|
|
|
|
typename = detail.getSensor().getTypeName();
|
|
|
|
|
detailList.add(detail);
|
|
|
|
|
}
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="
|
|
|
|
|
+ URLEncoder.encode(typename + ".xlsx", "UTF-8"));
|
|
|
|
|
reportService.exportSensorList(detailList, response.getOutputStream());
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
SensorDetail<Map<String, Object>> detail = service.getDetail(model);
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="
|
|
|
|
|
+ URLEncoder.encode(detail.getSensor().getName() + ".xlsx", "UTF-8"));
|
|
|
|
|
reportService.exportSensor(detail, response.getOutputStream());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("importFromModev")
|
|
|
|
|