|
@@ -28,8 +28,11 @@ import org.apache.poi.xssf.usermodel.XSSFColor;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFDataFormat;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFFont;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import com.nokia.tsl_data.dao.AreaInfoDao;
|
|
|
+
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
/**
|
|
@@ -39,27 +42,42 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@Service
|
|
|
public class TslReportService {
|
|
|
|
|
|
- private final TslDataService tslDataService;
|
|
|
+ @Autowired
|
|
|
+ private TslDataService tslDataService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AreaInfoDao areaInfoDao;
|
|
|
|
|
|
private XSSFWorkbook workbook = null;
|
|
|
|
|
|
private static final DateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
|
- public TslReportService(TslDataService tslDataService) {
|
|
|
- this.tslDataService = tslDataService;
|
|
|
- }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 写入workbook
|
|
|
+ *
|
|
|
+ * @param day
|
|
|
+ * @param path 应为带文件名的完整路径
|
|
|
+ */
|
|
|
public void workbookToFile(String day, String path) {
|
|
|
+ // 每次需要重置workbook
|
|
|
+ workbook = new XSSFWorkbook();
|
|
|
+ // 按照顺序写入各个sheet
|
|
|
+ // 管理端-移网质量类
|
|
|
getSheet1(day);
|
|
|
+ // 客户端-战略考核
|
|
|
+ getSheet1_1(day);
|
|
|
+ // 管理端-重复投诉率
|
|
|
getSheet2(day);
|
|
|
+ // 投诉处理时长、超时工单概况
|
|
|
getSheet3(day);
|
|
|
+ // 客户端-投诉问题解决满意度 客户端-投诉问题解决率 客户端-投诉问题响应率
|
|
|
getSheet4_6(day);
|
|
|
try (OutputStream outputStream = new FileOutputStream(path)) {
|
|
|
workbook.write(outputStream);
|
|
|
workbook.close();
|
|
|
workbook = null;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("写入失败。。。");
|
|
|
+ log.error("写入失败。。。" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -163,10 +181,6 @@ public class TslReportService {
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
sheet4.setColumnWidth(i, 2848);
|
|
|
}
|
|
|
- // sheet4.setColumnWidth(0, 2048);
|
|
|
- // sheet4.setColumnWidth(1, 2304);
|
|
|
- // sheet4.setColumnWidth(2, 2048);
|
|
|
- // sheet4.setColumnWidth(3, 2804);
|
|
|
|
|
|
// 设置行高 15.0 15.0...
|
|
|
for (int i = 0; i < 15; i++) {
|
|
@@ -223,10 +237,6 @@ public class TslReportService {
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
sheet5.setColumnWidth(i, 2848);
|
|
|
}
|
|
|
- // sheet5.setColumnWidth(0, 2048);
|
|
|
- // sheet5.setColumnWidth(1, 2304);
|
|
|
- // sheet5.setColumnWidth(2, 2048);
|
|
|
- // sheet5.setColumnWidth(3, 2804);
|
|
|
|
|
|
// 设置行高 15.0 15.0...
|
|
|
for (int i = 0; i < 15; i++) {
|
|
@@ -619,6 +629,175 @@ public class TslReportService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 20230627新增 客户端-战略考核
|
|
|
+ *
|
|
|
+ * @param day
|
|
|
+ */
|
|
|
+ private void getSheet1_1(String day) {
|
|
|
+ Sheet sheet = getWorkbook().createSheet("客户端-战略考核");
|
|
|
+
|
|
|
+ // 计算天数
|
|
|
+ LocalDate date = LocalDate.parse(day, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
+ int dayOfMonth = date.getDayOfMonth();
|
|
|
+
|
|
|
+ Row row;
|
|
|
+ Cell cell;
|
|
|
+ CellRangeAddress rangeAddress;
|
|
|
+ XSSFFont font;
|
|
|
+ XSSFDataFormat dataFormat = getWorkbook().createDataFormat();
|
|
|
+
|
|
|
+ // 基本模式 微软雅黑 10号字 带全边框 水平居中
|
|
|
+ XSSFCellStyle baseStyle = getWorkbook().createCellStyle();
|
|
|
+ font = getWorkbook().createFont();
|
|
|
+ font.setFontName("微软雅黑");
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
+ baseStyle.setFont(font);
|
|
|
+ baseStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ baseStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ baseStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ baseStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ baseStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ baseStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+ // 基础模式
|
|
|
+ XSSFCellStyle cellStyle1 = baseStyle.copy();
|
|
|
+ // 2位小数
|
|
|
+ XSSFCellStyle cellStyle2 = baseStyle.copy();
|
|
|
+ cellStyle2.setDataFormat(dataFormat.getFormat("0.00"));
|
|
|
+ // 微软雅黑 10号 加粗
|
|
|
+ XSSFCellStyle cellStyle3 = baseStyle.copy();
|
|
|
+ font = getWorkbook().createFont();
|
|
|
+ font.setFontName("微软雅黑");
|
|
|
+ font.setBold(true);
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
+ cellStyle3.setFont(font);
|
|
|
+
|
|
|
+ // 第一行 标题栏
|
|
|
+ cell = sheet.createRow(0).createCell(0);
|
|
|
+ cell.setCellValue(day.substring(0, 4) + "年客服投诉清单各地市投诉率情况(管理端-移网质量类)");
|
|
|
+ cell.setCellStyle(cellStyle3);
|
|
|
+ // 合并单元格
|
|
|
+ rangeAddress = new CellRangeAddress(0, 0, 0, dayOfMonth + 7);
|
|
|
+ sheet.addMergedRegion(rangeAddress);
|
|
|
+ // 设置合并单元格的边框
|
|
|
+ RegionUtil.setBorderBottom(BorderStyle.THIN, rangeAddress, sheet);
|
|
|
+ RegionUtil.setBorderTop(BorderStyle.THIN, rangeAddress, sheet);
|
|
|
+ RegionUtil.setBorderLeft(BorderStyle.THIN, rangeAddress, sheet);
|
|
|
+ RegionUtil.setBorderRight(BorderStyle.THIN, rangeAddress, sheet);
|
|
|
+
|
|
|
+ // 第二行 列名
|
|
|
+ row = sheet.createRow(1);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue("地市");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ for (int i = 1; i <= dayOfMonth; i++) {
|
|
|
+ cell = row.createCell(i);
|
|
|
+ cell.setCellValue(i + "日");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ }
|
|
|
+ cell = row.createCell(dayOfMonth + 1);
|
|
|
+ cell.setCellValue("投诉总量");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ cell = row.createCell(dayOfMonth + 2);
|
|
|
+ cell.setCellValue("用户数");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ cell = row.createCell(dayOfMonth + 3);
|
|
|
+ cell.setCellValue("目前万投率");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ cell = row.createCell(dayOfMonth + 4);
|
|
|
+ cell.setCellValue("本月预测");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ cell = row.createCell(dayOfMonth + 5);
|
|
|
+ cell.setCellValue("目标值");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ cell = row.createCell(dayOfMonth + 6);
|
|
|
+ cell.setCellValue("与目标差距");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ cell = row.createCell(dayOfMonth + 7);
|
|
|
+ cell.setCellValue("地市");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+
|
|
|
+ // 获取数据
|
|
|
+ Map<String, List<Object>> seet1_1Data = tslDataService.getSheet1_1Data(day);
|
|
|
+
|
|
|
+ int rowNum = 2;
|
|
|
+ int cellNum = 0;
|
|
|
+ // 写入各地市数据
|
|
|
+ for (String area : areaInfoDao.getAllCityName()) {
|
|
|
+ row = sheet.createRow(rowNum++);
|
|
|
+ // 写入A列的地市
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue(area);
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ for (Object obj : seet1_1Data.get(area)) {
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue(Double.parseDouble(obj.toString()));
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ }
|
|
|
+ // 写入最后一列的地市
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue(area);
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ // cellNum复位
|
|
|
+ cellNum = 0;
|
|
|
+ }
|
|
|
+ // 写入全省数据
|
|
|
+ row = sheet.createRow(rowNum);
|
|
|
+ // 写入A列的地市
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue("全省");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ for (Object obj : seet1_1Data.get("全省")) {
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue(Double.parseDouble(obj.toString()));
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+ }
|
|
|
+ // 写入最后一列的地市
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue("全省");
|
|
|
+ cell.setCellStyle(cellStyle1);
|
|
|
+
|
|
|
+ // 3-15行(2-14)dayOfMonth+2 - dayofMonth+6是浮点数,设置为显示小数点后2位
|
|
|
+ for (int i = 2; i <= 14; i++) {
|
|
|
+ row = sheet.getRow(i);
|
|
|
+ for (int j = dayOfMonth + 2; j <= dayOfMonth + 6; j++) {
|
|
|
+ cell = row.getCell(j);
|
|
|
+ cell.setCellStyle(cellStyle2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加条件格式B15-V15
|
|
|
+ rangeAddress = new CellRangeAddress(rowNum, rowNum, 1, dayOfMonth);
|
|
|
+ setConditionalFormatting(sheet, rangeAddress);
|
|
|
+ // 添加条件格式(dayOfMonth+3)(3-14)
|
|
|
+ rangeAddress = new CellRangeAddress(2, 13, dayOfMonth + 3, dayOfMonth + 3);
|
|
|
+ setConditionalFormatting(sheet, rangeAddress);
|
|
|
+ // 添加条件格式Z3-Z14
|
|
|
+ rangeAddress = new CellRangeAddress(2, 13, dayOfMonth + 4, dayOfMonth + 4);
|
|
|
+ setConditionalFormatting(sheet, rangeAddress);
|
|
|
+ // 添加条件格式AB3-AB14
|
|
|
+ rangeAddress = new CellRangeAddress(2, 13, dayOfMonth + 6, dayOfMonth + 6);
|
|
|
+ setConditionalFormatting(sheet, rangeAddress);
|
|
|
+
|
|
|
+ // 设置sheet的列宽
|
|
|
+ sheet.setColumnWidth(0, 1500);
|
|
|
+ for (int i = 1; i <= dayOfMonth; i++) {
|
|
|
+ sheet.setColumnWidth(i, 1100);
|
|
|
+ }
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 1, 1700);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 2, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 3, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 4, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 5, 1700);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 6, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 7, 1500);
|
|
|
+
|
|
|
+ // 设置行高 15
|
|
|
+ for (int i = 0; i < rowNum; i++) {
|
|
|
+ sheet.getRow(i).setHeightInPoints(15F);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 管理端-移网质量类
|
|
|
*
|
|
@@ -640,7 +819,7 @@ public class TslReportService {
|
|
|
XSSFFont font = getWorkbook().createFont();
|
|
|
font.setFontName("微软雅黑");
|
|
|
font.setBold(false);
|
|
|
- font.setFontHeightInPoints((short) 9);
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
cellStyle1.setFont(font);
|
|
|
cellStyle1.setBorderBottom(BorderStyle.THIN);
|
|
|
cellStyle1.setBorderTop(BorderStyle.THIN);
|
|
@@ -662,7 +841,7 @@ public class TslReportService {
|
|
|
font = getWorkbook().createFont();
|
|
|
font.setFontName("微软雅黑");
|
|
|
font.setBold(true);
|
|
|
- font.setFontHeightInPoints((short) 9);
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
cellStyle2.setFont(font);
|
|
|
cellStyle2.setBorderBottom(BorderStyle.THIN);
|
|
|
cellStyle2.setBorderTop(BorderStyle.THIN);
|
|
@@ -671,7 +850,7 @@ public class TslReportService {
|
|
|
|
|
|
// 第一行 标题栏
|
|
|
cell = sheet.createRow(0).createCell(0);
|
|
|
- cell.setCellValue("2023年客服投诉清单各地市投诉率情况(管理端-移网质量类)");
|
|
|
+ cell.setCellValue(day.substring(0, 4) + "年客服投诉清单各地市投诉率情况(管理端-移网质量类)");
|
|
|
cell.setCellStyle(cellStyle2);
|
|
|
// 合并单元格
|
|
|
CellRangeAddress range = new CellRangeAddress(0, 0, 0, dayOfMonth + 7);
|
|
@@ -720,7 +899,7 @@ public class TslReportService {
|
|
|
int rowNum = 2;
|
|
|
int cellNum = 0;
|
|
|
// 写入各地市数据
|
|
|
- for (String area : tslDataService.getAreas()) {
|
|
|
+ for (String area : areaInfoDao.getAllCityName()) {
|
|
|
row = sheet.createRow(rowNum++);
|
|
|
// 写入A列的地市
|
|
|
cell = row.createCell(cellNum++);
|
|
@@ -776,22 +955,22 @@ public class TslReportService {
|
|
|
rangeAddress = new CellRangeAddress(2, 13, dayOfMonth + 6, dayOfMonth + 6);
|
|
|
setConditionalFormatting(sheet, rangeAddress);
|
|
|
|
|
|
- // 设置sheet的列宽 1409, 876, 876, ..., 876, 1792, 1665, 2177, 2844, 1409, 2177, 1409
|
|
|
- sheet.setColumnWidth(0, 1409);
|
|
|
+ // 设置sheet的列宽
|
|
|
+ sheet.setColumnWidth(0, 1500);
|
|
|
for (int i = 1; i <= dayOfMonth; i++) {
|
|
|
- sheet.setColumnWidth(i, 876);
|
|
|
+ sheet.setColumnWidth(i, 1100);
|
|
|
}
|
|
|
- sheet.setColumnWidth(dayOfMonth + 1, 1792);
|
|
|
- sheet.setColumnWidth(dayOfMonth + 2, 1665);
|
|
|
- sheet.setColumnWidth(dayOfMonth + 3, 2177);
|
|
|
- sheet.setColumnWidth(dayOfMonth + 4, 2844);
|
|
|
- sheet.setColumnWidth(dayOfMonth + 5, 1409);
|
|
|
- sheet.setColumnWidth(dayOfMonth + 6, 2177);
|
|
|
- sheet.setColumnWidth(dayOfMonth + 7, 1409);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 1, 1700);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 2, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 3, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 4, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 5, 1700);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 6, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 7, 1500);
|
|
|
|
|
|
- // 设置行高 12
|
|
|
+ // 设置行高 15
|
|
|
for (int i = 0; i < rowNum; i++) {
|
|
|
- sheet.getRow(i).setHeightInPoints(12F);
|
|
|
+ sheet.getRow(i).setHeightInPoints(15F);
|
|
|
}
|
|
|
}
|
|
|
|