|
|
@ -17,7 +17,14 @@ |
|
|
|
|
|
|
|
|
package com.elink.esua.epdc.modules.screen.controller; |
|
|
package com.elink.esua.epdc.modules.screen.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.utils.excel.handler.FreezeAndFilter; |
|
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|
|
import com.elink.esua.epdc.dto.events.form.ItemDailyStatisFormDTO; |
|
|
import com.elink.esua.epdc.dto.events.form.ItemDailyStatisFormDTO; |
|
|
@ -26,9 +33,12 @@ import com.elink.esua.epdc.dto.screen.form.EventStatisticsFormDTO; |
|
|
import com.elink.esua.epdc.dto.screen.result.BarCategoryResultDTO; |
|
|
import com.elink.esua.epdc.dto.screen.result.BarCategoryResultDTO; |
|
|
import com.elink.esua.epdc.dto.screen.result.EfficiencyEvaluationResultDTO; |
|
|
import com.elink.esua.epdc.dto.screen.result.EfficiencyEvaluationResultDTO; |
|
|
import com.elink.esua.epdc.dto.screen.result.EventStatisticsResultDTO; |
|
|
import com.elink.esua.epdc.dto.screen.result.EventStatisticsResultDTO; |
|
|
|
|
|
import com.elink.esua.epdc.modules.screen.excel.ScreenDataExportExcel; |
|
|
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventEfficiencyService; |
|
|
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventEfficiencyService; |
|
|
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventStatService; |
|
|
import com.elink.esua.epdc.modules.screen.service.ScreenDeptEventStatService; |
|
|
import com.elink.esua.epdc.modules.screen.service.ScreenService; |
|
|
import com.elink.esua.epdc.modules.screen.service.ScreenService; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
@ -36,13 +46,18 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 大屏接口 |
|
|
* 大屏接口 |
|
|
* @author Administrator |
|
|
* @author Administrator |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("screen") |
|
|
@RequestMapping("screen") |
|
|
public class ScreenController { |
|
|
public class ScreenController { |
|
|
@ -83,4 +98,31 @@ public class ScreenController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("export") |
|
|
|
|
|
public void export(@RequestBody EventStatisticsFormDTO formDTO, HttpServletResponse response) { |
|
|
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
|
|
List<ScreenDataExportExcel> exportList = new ArrayList<>(); |
|
|
|
|
|
try { |
|
|
|
|
|
String fileName = "大屏数据导出.xlsx"; |
|
|
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), ScreenDataExportExcel.class).build(); |
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("表格").build(); |
|
|
|
|
|
List<EventStatisticsResultDTO> list = screenDeptEventStatService.getScreenExportData(formDTO); |
|
|
|
|
|
AtomicInteger i = new AtomicInteger(1); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
|
|
exportList = list.stream().map(item -> { |
|
|
|
|
|
ScreenDataExportExcel excel = ConvertUtils.sourceToTarget(item, ScreenDataExportExcel.class); |
|
|
|
|
|
return excel; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
} |
|
|
|
|
|
excelWriter.write(exportList, writeSheet); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("export exception", e); |
|
|
|
|
|
} finally { |
|
|
|
|
|
if (excelWriter != null) { |
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|