|
@@ -3,7 +3,15 @@ package com.rongwei.bscommon.sys.service.impl;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.aspose.cells.*;
|
|
|
+import com.aspose.cells.BorderType;
|
|
|
+import com.aspose.cells.Style;
|
|
|
import com.aspose.words.*;
|
|
|
+import com.aspose.words.Cell;
|
|
|
+import com.aspose.words.Range;
|
|
|
+import com.aspose.words.Row;
|
|
|
+import com.aspose.words.SaveFormat;
|
|
|
+import com.aspose.words.SaveOptions;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -24,6 +32,7 @@ import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import com.rongwei.rwcommoncomponent.excel.aspose.ExcelExportUtil;
|
|
|
+import com.rongwei.rwcommoncomponent.excel.aspose.ExcelUtils;
|
|
|
import com.rongwei.rwcommoncomponent.excel.utils.WordHelpUtils;
|
|
|
import com.rongwei.rwcommoncomponent.excel.vo.FormData;
|
|
|
import com.rongwei.rwcommoncomponent.file.service.SysFileItemService;
|
|
@@ -66,12 +75,15 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
|
|
|
private SysOrganizationService sysOrganizationService;
|
|
|
@Autowired
|
|
|
private ZhcxDeptPeopleCountService zhcxDeptPeopleCountService;
|
|
|
+ @Autowired
|
|
|
+ private ExcelUtils excelUtils;
|
|
|
|
|
|
@Value("${wz-provider.syncWzDataUrl}")
|
|
|
private String syncWzDataUrl;
|
|
|
|
|
|
private static final String DEPT_CODE = "0900";
|
|
|
-
|
|
|
+ private static final Color[] COLORS = {Color.fromArgb(205, 223, 242),
|
|
|
+ Color.fromArgb(249, 214, 194)};
|
|
|
@Override
|
|
|
public void wordExport(Map<String, Object> map, HttpServletResponse response) {
|
|
|
Object periodObj = map.get("period");
|
|
@@ -517,6 +529,124 @@ public class ZhcxPersistentManageServiceImpl extends ServiceImpl<ZhcxPersistentM
|
|
|
zhcxDeptPeopleCountService.saveOrUpdateBatch(list);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void downloadReportData(Map<String, Object> map, HttpServletResponse response) {
|
|
|
+ Object yearObj = map.get("year");
|
|
|
+ Object monthObj = map.get("month");
|
|
|
+ String year = (String) yearObj;
|
|
|
+ String month = (String) monthObj;
|
|
|
+ List<ZhcxPersistentReportDto> dtos = this.reportData(map);
|
|
|
+ if(!excelUtils.GetLicense()) {
|
|
|
+ throw new CustomException("获取license异常");
|
|
|
+ }
|
|
|
+ Workbook workbook = new Workbook();
|
|
|
+ WorksheetCollection worksheets = workbook.getWorksheets();
|
|
|
+ Worksheet worksheet = worksheets.get(0);
|
|
|
+ Cells cells = worksheet.getCells();
|
|
|
+ com.aspose.cells.Style commonStyle = workbook.createStyle();
|
|
|
+ commonStyle.setHorizontalAlignment(TextAlignmentType.CENTER);
|
|
|
+ commonStyle.setVerticalAlignment(TextAlignmentType.CENTER);
|
|
|
+ commonStyle.setBorder(com.aspose.cells.BorderType.TOP_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
+ commonStyle.setBorder(com.aspose.cells.BorderType.BOTTOM_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
+ commonStyle.setBorder(com.aspose.cells.BorderType.LEFT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
+ commonStyle.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, Color.getBlack());
|
|
|
+ //设置列头
|
|
|
+ buildHeader(cells);
|
|
|
+ int dataStartRow = 2;
|
|
|
+ for (int i = 0; i < dtos.size(); i++) {
|
|
|
+ int row = dataStartRow + i;
|
|
|
+ fillDataRow(cells, row, dtos.get(i));
|
|
|
+ }
|
|
|
+ int totalRows = dtos.size() + dataStartRow;
|
|
|
+
|
|
|
+ for (int i = 0; i < 9; i++) {
|
|
|
+ for (int x = 0; x < totalRows; x++) {
|
|
|
+ Style cellStyle = cells.get(x, i).getStyle();
|
|
|
+ commonStyle.setPattern(BackgroundType.SOLID);
|
|
|
+ commonStyle.setForegroundColor(cellStyle.getForegroundColor());
|
|
|
+ commonStyle.getFont().setColor(cellStyle.getFont().getColor());
|
|
|
+ cells.get(x, i).setStyle(commonStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ worksheet.autoFitColumns();
|
|
|
+ worksheet.setName(year+"-"+month+"-顽症统计");
|
|
|
+ response.addHeader("Pargam", "no-cache");
|
|
|
+ response.addHeader("Cache-Control", "no-cache");
|
|
|
+ response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=整改清单.xlsx");
|
|
|
+ workbook.save(response.getOutputStream(), com.aspose.cells.SaveFormat.XLSX);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导出错误", e);
|
|
|
+ }finally {
|
|
|
+ workbook.dispose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void buildHeader(Cells cells) {
|
|
|
+ cells.merge(0, 0, 2, 1);
|
|
|
+ cells.get(0, 0).setValue("月份");
|
|
|
+
|
|
|
+ cells.merge(0, 1, 2, 1);
|
|
|
+ cells.get(0, 1).setValue("二级部门");
|
|
|
+
|
|
|
+ cells.merge(0, 2, 2, 1);
|
|
|
+ cells.get(0, 2).setValue("人数");
|
|
|
+
|
|
|
+ cells.merge(0, 3, 1, 2);
|
|
|
+ cells.get(0, 3).setValue("检查情况");
|
|
|
+ cells.get(1, 3).setValue("检查条数");
|
|
|
+ cells.get(1, 4).setValue("人均条数");
|
|
|
+
|
|
|
+ cells.merge(0, 5, 1, 2);
|
|
|
+ cells.get(0, 5).setValue("处罚情况");
|
|
|
+ cells.get(1, 5).setValue("处罚条数");
|
|
|
+ cells.get(1, 6).setValue("人均条数");
|
|
|
+
|
|
|
+ cells.merge(0, 7, 2, 1);
|
|
|
+ cells.get(0, 7).setValue("处罚总额(元)");
|
|
|
+
|
|
|
+ cells.merge(0, 8, 2, 1);
|
|
|
+ cells.get(0, 8).setValue("人均处罚总额(元)");
|
|
|
+ for(int i = 3;i<7;i++){
|
|
|
+ for(int j = 0;j<2;j++){
|
|
|
+ if(j == 0 && !(i % 2 != 0)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Style style = cells.get(j, i).getStyle();
|
|
|
+ style.setPattern(BackgroundType.SOLID);
|
|
|
+ if (i <5) {
|
|
|
+ style.setForegroundColor(COLORS[0]);
|
|
|
+ }else{
|
|
|
+ style.setForegroundColor(COLORS[1]);
|
|
|
+ }
|
|
|
+ cells.get(j, i).setStyle(style);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillDataRow(Cells cells, int row, ZhcxPersistentReportDto dto) {
|
|
|
+ cells.get(row, 0).setValue(dto.getMonth());
|
|
|
+ cells.get(row, 1).setValue(dto.getSecondOrgName());
|
|
|
+ cells.get(row, 2).setValue(dto.getNumber());
|
|
|
+ cells.get(row, 3).setValue(dto.getCheckNumber() == null ? 0 : dto.getCheckNumber());
|
|
|
+ cells.get(row, 4).setValue(dto.getCheckNumberPer() == null ? 0 : dto.getCheckNumberPer());
|
|
|
+ cells.get(row, 5).setValue(dto.getPunishNumber() == null ? 0 : dto.getPunishNumber());
|
|
|
+ cells.get(row, 6).setValue(dto.getPunishNumberPer() == null ? 0 : dto.getPunishNumberPer());
|
|
|
+ cells.get(row, 7).setValue(dto.getPunishTotalAmount() == null ? 0 : dto.getPunishTotalAmount());
|
|
|
+ cells.get(row, 8).setValue(dto.getPunishTotalAmountPer() == null ? 0 : dto.getPunishTotalAmountPer());
|
|
|
+ for(int i = 3;i<7;i++){
|
|
|
+ Style style = cells.get(row, i).getStyle();
|
|
|
+ style.setPattern(BackgroundType.SOLID);
|
|
|
+ if (i <5) {
|
|
|
+ style.setForegroundColor(COLORS[0]);
|
|
|
+ }else{
|
|
|
+ style.setForegroundColor(COLORS[1]);
|
|
|
+ }
|
|
|
+ cells.get(row, i).setStyle(style);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 处理部门用户统计数据
|
|
|
private void processDeptUserCount(String year, String month, Map<String, PersistentVo> reportDataMap, List<ZhcxPersistentReportDto> reportList) {
|
|
|
List<OrganizationVo> deptUserCount = zhcxPersistentManageDao.getDeptUserCount(year, month, DEPT_CODE);
|