|
@@ -1,10 +1,15 @@
|
|
|
package com.zcxk.rmcp.web.controller;
|
|
|
|
|
|
+import com.zcxk.core.common.exception.BusinessException;
|
|
|
import com.zcxk.core.common.pojo.AjaxMessage;
|
|
|
import com.zcxk.core.mysql.pageing.Pagination;
|
|
|
import com.zcxk.core.utils.export.EasyExcelUtil;
|
|
|
import com.zcxk.rmcp.api.dto.devicecommand.DeviceCommandPageDto;
|
|
|
+import com.zcxk.rmcp.api.dto.readrate.ReadRateDto;
|
|
|
+import com.zcxk.rmcp.api.enums.ReadRateEnum;
|
|
|
+import com.zcxk.rmcp.api.enums.RmcpErrorEnum;
|
|
|
import com.zcxk.rmcp.api.vo.DeviceCommandVo;
|
|
|
+import com.zcxk.rmcp.api.vo.ReadRateVo;
|
|
|
import com.zcxk.rmcp.web.service.DeviceCommandService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -14,6 +19,7 @@ import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -43,14 +49,18 @@ public class DeviceCommandController extends BaseController{
|
|
|
return AjaxMessage.success(deviceCommandService.findDeviceCommand(id));
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value="export/excel" , method = RequestMethod.POST)
|
|
|
+
|
|
|
+ @RequestMapping(value="export/excel" , method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "excel导出")
|
|
|
- public AjaxMessage<String> exportExcel(@RequestBody @Valid DeviceCommandPageDto deviceCommandPageDto) {
|
|
|
+ public void exportExcel(DeviceCommandPageDto deviceCommandPageDto, HttpServletResponse response) {
|
|
|
List<DeviceCommandVo> list = deviceCommandService.listDeviceCommand(deviceCommandPageDto);
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
- return AjaxMessage.success(null);
|
|
|
+ throw BusinessException.builder(RmcpErrorEnum.RMCP_NOT_FOUND);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ EasyExcelUtil.excelWrite(response, DeviceCommandVo.class, "阀控管理记录", list);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw BusinessException.builder(RmcpErrorEnum.RMCP_DOWNLOAD_ERROR);
|
|
|
}
|
|
|
- String filePath = EasyExcelUtil.excelWrite(baseDir, DeviceCommandVo.class, "阀控管理记录", list);
|
|
|
- return AjaxMessage.success(filePath);
|
|
|
}
|
|
|
}
|