|
@@ -1,61 +1,150 @@
|
|
package com.nokia.tsl_data;
|
|
package com.nokia.tsl_data;
|
|
|
|
|
|
-import java.io.FileInputStream;
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.io.InputStreamReader;
|
|
|
|
-import java.io.Reader;
|
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
-import org.apache.commons.csv.CSVFormat;
|
|
|
|
-import org.apache.commons.csv.CSVParser;
|
|
|
|
-import org.apache.commons.csv.CSVRecord;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
+import org.apache.poi.ss.util.RegionUtil;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFFont;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
-import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
|
+
|
|
|
|
+import com.nokia.tsl_data.dao.TslDao;
|
|
|
|
|
|
@SpringBootTest
|
|
@SpringBootTest
|
|
public class TslDataApplicationTest {
|
|
public class TslDataApplicationTest {
|
|
@Autowired
|
|
@Autowired
|
|
- private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ private TslDao tslDao;
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ void test1() {
|
|
|
|
+ LocalDateTime dateTime = LocalDateTime.now();
|
|
|
|
+ System.out.println(dateTime.getDayOfMonth());
|
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- void test() {
|
|
|
|
- String path = "D:/hb_cuc_code/report_auto/doc/开发文档/样本数据/输入/HE_D_MOBILE_COMPLAINT_DETAILS_DAY_20230409-src.csv";
|
|
|
|
-
|
|
|
|
- //
|
|
|
|
- String sql = "insert into report_auto.he_d_mobile_comp (month_id,day_id,acct_date,sheet_no,is_online_complete,contact_no,busi_no,serv_content,last_deal_content,deal_depart_name,deal_opinion,serv_type,bus_type,duty_reason,accept_channel,submit_channel,compl_area_local,duty_major,product_name,sp_product_code,pre_repair_name,pre_repair_charges,fault_location,cust_level,satisfaction_in_reply,is_ok_in_reply,accept_time,end_time,proce_time,cust_area,is_cust_serv_complete,is_send_sheet_complete,is_repeat,is_upgrade,is_timeout,gis_city,process_nums,deal_depart_name_1,deal_depart_name_2,deal_depart_name_3,first_call_back_time,proce_remark,duty_major_day,duty_reason_id_day,duty_major_month,duty_reason_id_month,voice_text) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
|
|
|
-
|
|
|
|
- // String sql = "insert into report_auto.he_d_mobile_comp (month_id,day_id,acct_date) values (?,?,?)";
|
|
|
|
- try (Reader reader = new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8)) {
|
|
|
|
-
|
|
|
|
- CSVParser parser = CSVFormat.DEFAULT.builder()
|
|
|
|
- .setRecordSeparator("\n")
|
|
|
|
- .setQuote(null)
|
|
|
|
- .setDelimiter("||")
|
|
|
|
- .setSkipHeaderRecord(false)
|
|
|
|
- .build().parse(reader);
|
|
|
|
-
|
|
|
|
- List<CSVRecord> records = parser.getRecords();
|
|
|
|
- List<Object[]> list = new ArrayList<>();
|
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
|
- // Object[] ps = new String[] { "202304", "09", "20230409" };
|
|
|
|
- Object[] ps = new Object[47];
|
|
|
|
- list.add(ps);
|
|
|
|
- for (int j = 0; j < ps.length; j++) {
|
|
|
|
- ps[j] = records.get(i).get(j);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int[] batchUpdate = jdbcTemplate.batchUpdate(sql, list);
|
|
|
|
- System.out.println(Arrays.toString(batchUpdate));
|
|
|
|
-
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- // TODO Auto-generated catch block
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ void test() throws IOException {
|
|
|
|
+ // List<Map<String, Object>> result = tslDao.selectTslforMonth("202304");
|
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
|
+ Sheet sheet = workbook.createSheet("管理端-移网质量类");
|
|
|
|
+ Row row;
|
|
|
|
+ Cell cell;
|
|
|
|
+
|
|
|
|
+ LocalDateTime dateTime = LocalDateTime.now();
|
|
|
|
+ int dayOfMonth = dateTime.getDayOfMonth();
|
|
|
|
+
|
|
|
|
+ cell = sheet.createRow(0).createCell(0);
|
|
|
|
+ cell.setCellValue("2023年客服投诉清单各地市投诉率情况(管理端-移网质量类)");
|
|
|
|
+ cell.setCellStyle(getStyle2(workbook));
|
|
|
|
+
|
|
|
|
+ CellRangeAddress range = new CellRangeAddress(0, 0, 0, dayOfMonth + 7);
|
|
|
|
+ sheet.addMergedRegion(range);
|
|
|
|
+
|
|
|
|
+ RegionUtil.setBorderBottom(BorderStyle.THIN, range, sheet);
|
|
|
|
+ RegionUtil.setBorderTop(BorderStyle.THIN, range, sheet);
|
|
|
|
+ RegionUtil.setBorderLeft(BorderStyle.THIN, range, sheet);
|
|
|
|
+ RegionUtil.setBorderRight(BorderStyle.THIN, range, sheet);
|
|
|
|
+
|
|
|
|
+ row = sheet.createRow(1);
|
|
|
|
+ cell = row.createCell(0);
|
|
|
|
+ cell.setCellValue("地市");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(0);
|
|
|
|
+
|
|
|
|
+ for (int i = 1; i <= dayOfMonth; i++) {
|
|
|
|
+ cell = row.createCell(i);
|
|
|
|
+ cell.setCellValue((i) + "日");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(i);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ cell = row.createCell(dayOfMonth + 1);
|
|
|
|
+ cell.setCellValue("投诉总量");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(dayOfMonth + 1);
|
|
|
|
+
|
|
|
|
+ cell = row.createCell(dayOfMonth + 2);
|
|
|
|
+ cell.setCellValue("用户数");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(dayOfMonth + 2);
|
|
|
|
+
|
|
|
|
+ cell = row.createCell(dayOfMonth + 3);
|
|
|
|
+ cell.setCellValue("目前万投率");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(dayOfMonth + 3);
|
|
|
|
+
|
|
|
|
+ cell = row.createCell(dayOfMonth + 4);
|
|
|
|
+ cell.setCellValue("本月预测");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(dayOfMonth + 4);
|
|
|
|
+
|
|
|
|
+ cell = row.createCell(dayOfMonth + 5);
|
|
|
|
+ cell.setCellValue("目标值");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(dayOfMonth + 5);
|
|
|
|
+
|
|
|
|
+ cell = row.createCell(dayOfMonth + 6);
|
|
|
|
+ cell.setCellValue("与目标差距");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(dayOfMonth + 6);
|
|
|
|
+
|
|
|
|
+ cell = row.createCell(dayOfMonth + 7);
|
|
|
|
+ cell.setCellValue("地市");
|
|
|
|
+ cell.setCellStyle(getStyle1(workbook));
|
|
|
|
+ sheet.autoSizeColumn(dayOfMonth + 7);
|
|
|
|
+
|
|
|
|
+ File file = new File("D:/src/test.xlsx");
|
|
|
|
+
|
|
|
|
+ FileOutputStream fout = new FileOutputStream(file);
|
|
|
|
+ workbook.write(fout);
|
|
|
|
+ fout.close();
|
|
|
|
+ workbook.close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private XSSFFont getFont1(XSSFWorkbook workbook) {
|
|
|
|
+ XSSFFont font = workbook.createFont();
|
|
|
|
+ font.setFontName("等线");
|
|
|
|
+ font.setFontHeightInPoints((short) 9);
|
|
|
|
+ return font;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private CellStyle getStyle1(XSSFWorkbook workbook) {
|
|
|
|
+ XSSFCellStyle cellStyle = workbook.createCellStyle();
|
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ cellStyle.setFont(getFont1(workbook));
|
|
|
|
+ cellStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
|
+ cellStyle.setBorderTop(BorderStyle.THIN);
|
|
|
|
+ cellStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
|
+ cellStyle.setBorderRight(BorderStyle.THIN);
|
|
|
|
+ return cellStyle;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private XSSFFont getFont2(XSSFWorkbook workbook) {
|
|
|
|
+ XSSFFont font = workbook.createFont();
|
|
|
|
+ font.setFontName("等线");
|
|
|
|
+ font.setBold(true);
|
|
|
|
+ font.setFontHeightInPoints((short) 9);
|
|
|
|
+ return font;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private CellStyle getStyle2(XSSFWorkbook workbook) {
|
|
|
|
+ XSSFCellStyle cellStyle = workbook.createCellStyle();
|
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ cellStyle.setFont(getFont2(workbook));
|
|
|
|
+ cellStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
|
+ cellStyle.setBorderTop(BorderStyle.THIN);
|
|
|
|
+ cellStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
|
+ cellStyle.setBorderRight(BorderStyle.THIN);
|
|
|
|
+ return cellStyle;
|
|
}
|
|
}
|
|
}
|
|
}
|