Selaa lähdekoodia

可以输出文件了

lifuquan 2 vuotta sitten
vanhempi
commit
e2a4a0bc7d

+ 7 - 1
doc/开发文档/数据库文档/一些语句.sql

@@ -16,4 +16,10 @@ t5 as (select compl_area_local from t1 where is_timeout = '是'),
 t7 as (select '全省' as compl_area_local, count(1) as timeout_num from t5),
 t8 as (select compl_area_local, count(1) as timeout_num from t5 group by compl_area_local),
 t9 as (select * from t7 union select * from t8)
-select t4.compl_area_local, t4.total_num, t9.timeout_num, t9.timeout_num/t4.total_num::numeric as timeout_ratio from t4,t9 where t4.compl_area_local = t9.compl_area_local order by t9.timeout_num/t4.total_num::numeric desc
+select t4.compl_area_local, t4.total_num, t9.timeout_num, t9.timeout_num/t4.total_num::numeric as timeout_ratio from t4,t9 where t4.compl_area_local = t9.compl_area_local order by t9.timeout_num/t4.total_num::numeric desc
+
+-- 超时时间
+with t1 as (select compl_area_local, case when proce_time != '' then (extract('epoch' from to_timestamp(proce_time, 'YYYY-MM-DD HH24:MI:SS')) - extract('epoch' from to_timestamp(accept_time, 'YYYY-MM-DD HH24:MI:SS')))/3600 when is_online_complete = '是' then 0
+else (extract('epoch' from to_timestamp(end_time, 'YYYY-MM-DD HH24:MI:SS')) - extract('epoch' from to_timestamp(accept_time, 'YYYY-MM-DD HH24:MI:SS')))/3600 end as duration
+from report_auto.he_d_mobile_comp hdmc where month_id = substring('20230420' from 1 for 6) and day_id <= substring('20230420' from 7 for 2))
+select compl_area_local, avg(duration) as avg_duration from t1 group by compl_area_local

+ 12 - 1
doc/开发文档/数据库文档/建表.sql

@@ -128,4 +128,15 @@ CREATE TABLE report_auto.target_ts_ratio (
   target_ts_ratio varchar(10) NOT NULL,
   cteate_time timestamp NULL DEFAULT now(),
   CONSTRAINT target_ts_ratio_pkey PRIMARY KEY (id)
-)
+)
+
+-- 每月平均处理时长
+drop table if exists report_auto.avg_duration;
+CREATE TABLE report_auto.avg_duration (
+	id bigserial NOT NULL,
+	month_id varchar(6) NULL,
+	city_name varchar(10) null,
+	avg_duration float8 not null,
+  cteate_time timestamp NULL DEFAULT now(),
+	CONSTRAINT avg_duration_pkey PRIMARY KEY (id)
+);

+ 2 - 0
doc/需求文档/钉钉自动报表需求.md

@@ -25,6 +25,8 @@
 
 #### 2.2.3 最终产出
 
+2023年4月截至23日移动网投诉情况统计:管理端-移网质量类:投诉率:石家庄、承德、雄安、张家口、沧州、衡水、唐山未达到目标值,石家庄、雄安、承德排名靠后;重复投诉率:唐山、沧州、廊坊增长较快。客户端-移网网络体验:投诉问题解决满意率:雄安、张家口、唐山较低,与达标值差距较大;投诉问题解决率:雄安、张家口、唐山较低,与达标值差距较大;投诉问题响应率:雄安、张家口、石家庄较低,与达标值差距较大。投诉处理时长、超时工单概况:超时工单:雄安、石家庄、张家口分公司超时工单占比较高,石家庄、唐山、邯郸超时工单数量较多。平均处理时长:本月相对较长的地市为雄安、石家庄、张家口;与3月比雄安时长增幅较大。
+
 ##### 2.2.3.1 客服投诉清单各地市投诉情况
 
 ##### 2.2.3.2 重复投诉率

+ 1 - 2
tsl_data/pom.xml

@@ -19,8 +19,7 @@
 
     <properties>
         <!-- 跳过测试代码 -->
-        <skipTests>
-            true</skipTests>
+        <skipTests>true</skipTests>
         <!-- 指定java的版本 -->
         <java.version>1.8</java.version>
         <!-- 文件拷贝时的编码 -->

+ 32 - 1
tsl_data/src/main/java/com/nokia/tsl_data/dao/TslDao.java

@@ -9,7 +9,38 @@ import org.apache.ibatis.annotations.Param;
 @Mapper
 public interface TslDao {
 
-    List<Map<String, Object>> selectTimeoutTsDurationForDay(String day);
+    /**
+     * 客户端-投诉问题解决满意度
+     * 客户端-投诉问题解决率
+     * 客户端-投诉问题响应率
+     * 
+     * @param day
+     * @return
+     */
+    List<Map<String, Object>> selectClientRatioForDay(String day);
+
+    /**
+     * 查询历史处理时长
+     * 
+     * @param monthId
+     * @return
+     */
+    List<Map<String, Object>> selectOldTsDurationForMonth(String monthId);
+
+    /**
+     * 存入历史处理时长数据
+     * 
+     * @param map
+     */
+    void insertOldTsDuration(@Param("map") Map<String, Object> map);
+
+    /**
+     * 处理时长统计
+     * 
+     * @param day
+     * @return
+     */
+    List<Map<String, Object>> selectTsDurationForDay(String day);
 
     /**
      * 超时工单统计

+ 211 - 0
tsl_data/src/main/java/com/nokia/tsl_data/service/TslDataService.java

@@ -13,6 +13,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import com.nokia.tsl_data.dao.TslDao;
@@ -27,6 +28,13 @@ public class TslDataService {
 
     private final TslDao tslDao;
 
+    @Value("${tslTask.compliance.satisfied}")
+    private double satisfiedCompliance;
+    @Value("${tslTask.compliance.resolution}")
+    private double resolutionCompliance;
+    @Value("${tslTask.compliance.response}")
+    private double responseCompliance;
+
     @Getter
     private final List<String> areas = new ArrayList<String>() {
         {
@@ -49,6 +57,209 @@ public class TslDataService {
         this.tslDao = tslDao;
     }
 
+    /**
+     * 客户端-投诉问题解决满意度
+     * 客户端-投诉问题解决率
+     * 客户端-投诉问题响应率
+     * 
+     * @param day
+     * @return
+     */
+    public List<List<List<Object>>> getSheet4_6Data(String day) {
+        String realDay = day.substring(0, 4) + "-" + day.substring(4, 6) + "-" + day.substring(6);
+        List<Map<String, Object>> data = tslDao.selectClientRatioForDay(realDay);
+        Map<String, Map<String, Object>> dataMap = new HashMap<>();
+        for (Map<String, Object> map : data) {
+            String key = (String) map.get("businoareaname");
+            if (key.equals("雄安新区")) {
+                dataMap.put("雄安", map);
+            }
+            dataMap.put(key, map);
+        }
+        List<List<List<Object>>> result = new ArrayList<>(3);
+        List<List<Object>> list0;
+        List<Object> list1;
+
+        // 满意度
+        list0 = new ArrayList<>();
+        result.add(list0);
+        // 地市满意度
+        for (String area : areas) {
+            list1 = new ArrayList<>(4);
+            list0.add(list1);
+            // 地市
+            list1.add(0, area);
+            // 满意率
+            list1.add(1, dataMap.get(area).get("complaint_satisfied"));
+            // 达标值
+            list1.add(2, satisfiedCompliance);
+            // 差距
+            list1.add(3, ((BigDecimal) list1.get(1)).doubleValue() - (double) list1.get(2));
+        }
+        // 逆序排序
+        list0.sort((o1, o2) -> Double.compare((double) o2.get(3), (double) o1.get(3)));
+        // 全省满意度
+        list1 = new ArrayList<>(4);
+        list0.add(list1);
+        // 地市
+        list1.add(0, "全省");
+        // 满意率
+        list1.add(1, dataMap.get("全省").get("complaint_satisfied"));
+        // 达标值
+        list1.add(2, satisfiedCompliance);
+        // 差距
+        list1.add(3, ((BigDecimal) list1.get(1)).doubleValue() - (double) list1.get(2));
+
+        // 解决率
+        list0 = new ArrayList<>();
+        result.add(list0);
+        // 地市解决率
+        for (String area : areas) {
+            list1 = new ArrayList<>(4);
+            list0.add(list1);
+            // 地市
+            list1.add(0, area);
+            // 解决率
+            list1.add(1, dataMap.get(area).get("complaint_resolution"));
+            // 达标值
+            list1.add(2, resolutionCompliance);
+            // 差距
+            list1.add(3, ((BigDecimal) list1.get(1)).doubleValue() - (double) list1.get(2));
+        }
+        // 逆序排序
+        list0.sort((o1, o2) -> Double.compare((double) o2.get(3), (double) o1.get(3)));
+        // 全省解决率
+        list1 = new ArrayList<>(4);
+        list0.add(list1);
+        // 地市
+        list1.add(0, "全省");
+        // 解决率
+        list1.add(1, dataMap.get("全省").get("complaint_resolution"));
+        // 达标值
+        list1.add(2, resolutionCompliance);
+        // 差距
+        list1.add(3, ((BigDecimal) list1.get(1)).doubleValue() - (double) list1.get(2));
+
+        // 响应率
+        list0 = new ArrayList<>();
+        result.add(list0);
+        for (String area : areas) {
+            list1 = new ArrayList<>(4);
+            list0.add(list1);
+            // 地市
+            list1.add(0, area);
+            // 解决率
+            list1.add(1, dataMap.get(area).get("complaint_response"));
+            // 达标值
+            list1.add(2, responseCompliance);
+            // 差距
+            list1.add(3, ((BigDecimal) list1.get(1)).doubleValue() - (double) list1.get(2));
+        }
+        // 逆序排序
+        list0.sort((o1, o2) -> Double.compare((double) o2.get(3), (double) o1.get(3)));
+        list1 = new ArrayList<>(4);
+        list0.add(list1);
+        list1.add(0, "全省");
+        // 相应
+        list1.add(1, dataMap.get("全省").get("complaint_response"));
+        // 达标值
+        list1.add(2, responseCompliance);
+        // 差距
+        list1.add(3, ((BigDecimal) list1.get(1)).doubleValue() - (double) list1.get(2));
+
+        return result;
+    }
+
+    /**
+     * 超时工单情况
+     * 
+     * @param day
+     * @return
+     */
+    public List<List<Object>> getSheet3Data1(String day) {
+        List<Map<String, Object>> data = tslDao.selectTimeoutTsCountForDay(day);
+        Map<String, Map<String, Object>> dayMap = new HashMap<>();
+        for (Map<String, Object> map : data) {
+            dayMap.put((String) map.get("compl_area_local"), map);
+        }
+        List<List<Object>> result = new ArrayList<>();
+        // 各地市数据
+        for (String area : areas) {
+            List<Object> list = new ArrayList<>(4);
+            result.add(list);
+            // 地市
+            list.add(0, area);
+            // 工单数
+            list.add(1, dayMap.get(area).get("total_num"));
+            // 超时工单数
+            list.add(2, dayMap.get(area).get("timeout_num"));
+            // 超时工单占比
+            list.add(3, dayMap.get(area).get("timeout_ratio"));
+        }
+        // 逆序排序
+        result.sort((o1, o2) -> {
+            return ((BigDecimal) o2.get(3)).compareTo(((BigDecimal) o1.get(3)));
+        });
+        // 全省数据
+        List<Object> list = new ArrayList<>();
+        result.add(list);
+        // 地市
+        list.add(0, "全省");
+        // 工单数
+        list.add(1, dayMap.get("全省").get("total_num"));
+        // 超时工单数
+        list.add(2, dayMap.get("全省").get("timeout_num"));
+        // 超时工单占比
+        list.add(3, dayMap.get("全省").get("timeout_ratio"));
+        return result;
+    }
+
+    /**
+     * 平均处理时长
+     * 
+     * @param day
+     * @return
+     */
+    public List<List<Object>> getSheet3Data2(String day) {
+        Calendar calendar = Calendar.getInstance(Locale.CHINA);
+        try {
+            calendar.setTime(new SimpleDateFormat("yyyyMMdd").parse(day));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        // 获取上个月的时间
+        calendar.add(Calendar.MONTH, -1);
+        String oldMonthId = new SimpleDateFormat("yyyyMM").format(calendar.getTime());
+        List<Map<String, Object>> oldData = tslDao.selectOldTsDurationForMonth(oldMonthId);
+        List<Map<String, Object>> dayData = tslDao.selectTsDurationForDay(day);
+        // 转化格式方便读取
+        Map<String, Map<String, Object>> dayMap = new HashMap<>();
+        Map<String, Map<String, Object>> preMap = new HashMap<>();
+        for (Map<String, Object> map : dayData) {
+            dayMap.put((String) map.get("compl_area_local"), map);
+        }
+        for (Map<String, Object> map : oldData) {
+            preMap.put((String) map.get("city_name"), map);
+        }
+        List<List<Object>> result = new ArrayList<>();
+        // 各地市数据
+        for (String area : areas) {
+            List<Object> list = new ArrayList<>();
+            result.add(list);
+            // 地市
+            list.add(0, area);
+            // 上月平均处理时长
+            list.add(1, preMap.get(area).get("avg_duration"));
+            // 当月平均处理时长
+            list.add(2, dayMap.get(area).get("avg_duration"));
+            // 涨幅
+            list.add(3, ((double) list.get(2)) - (double) list.get(1));
+        }
+        // 逆序排序
+        result.sort((o1, o2) -> Double.compare((double) o2.get(3), (double) o1.get(3)));
+        return result;
+    }
+
     /**
      * 管理端-重复投诉率
      * 

+ 266 - 0
tsl_data/src/main/java/com/nokia/tsl_data/service/TslReportService.java

@@ -60,6 +60,7 @@ public class TslReportService {
         getSheet1(day);
         getSheet2(day);
         getSheet3(day);
+        getSheet4_6(day);
         try (OutputStream outputStream = new FileOutputStream(path)) {
             workbook.write(outputStream);
             workbook.close();
@@ -69,6 +70,194 @@ public class TslReportService {
         }
     }
 
+    /**
+     * 客户端-投诉问题解决满意度
+     * 客户端-投诉问题解决率
+     * 客户端-投诉问题响应率
+     * 
+     * @param day
+     */
+    private void getSheet4_6(String day) {
+        // 计算时间常数
+        Calendar calendar = Calendar.getInstance(Locale.CHINA);
+        try {
+            calendar.setTime(DAY_FORMAT.parse(day));
+        } catch (ParseException e) {
+            log.error("时间字符串解析失败--{}", day);
+        }
+        int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
+        Sheet sheet4 = getWorkbook().createSheet("客户端-投诉问题解决满意度");
+        Sheet sheet5 = getWorkbook().createSheet("客户端-投诉问题解决率");
+        Sheet sheet6 = getWorkbook().createSheet("客户端-投诉问题响应率");
+        Row row;
+        Cell cell;
+        CellRangeAddress rangeAddress;
+        XSSFDataFormat dataFormat = getWorkbook().createDataFormat();
+        XSSFFont font = getWorkbook().createFont();
+        font.setFontName("等线");
+        font.setFontHeightInPoints((short) 10);
+        // 基本模式 等线 10号字 带全边框 水平居中
+        XSSFCellStyle baseStyle = getWorkbook().createCellStyle();
+        baseStyle.setFont(font);
+        baseStyle.setAlignment(HorizontalAlignment.CENTER);
+        baseStyle.setBorderBottom(BorderStyle.THIN);
+        baseStyle.setBorderTop(BorderStyle.THIN);
+        baseStyle.setBorderLeft(BorderStyle.THIN);
+        baseStyle.setBorderRight(BorderStyle.THIN);
+        // 样式1 与base相同
+        XSSFCellStyle cellStyle1 = baseStyle.copy();
+        // 样式2 百分比 2位小数
+        XSSFCellStyle cellStyle2 = baseStyle.copy();
+        cellStyle2.setDataFormat(dataFormat.getFormat("0.00%"));
+        // 样式3 自动换行 背景色FFE7E6E6
+        XSSFCellStyle cellStyle3 = baseStyle.copy();
+        cellStyle3.setWrapText(true);
+        XSSFColor color = new XSSFColor();
+        color.setARGBHex("FFE7E6E6");
+        cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle3.setFillForegroundColor(color);
+
+        List<List<List<Object>>> sheet4_6Data = tslDataService.getSheet4_6Data(day);
+
+        // 客户端-投诉问题解决满意度 第一行
+        row = sheet4.createRow(0);
+        cell = row.createCell(0);
+        cell.setCellValue(String.format("投诉问题解决满意率(1-%s)", dayOfMonth));
+        cell.setCellStyle(cellStyle3);
+        // 合并单元格 A1 - D1
+        rangeAddress = new CellRangeAddress(0, 0, 0, 3);
+        addMergedRegion(sheet4, rangeAddress);
+        // 客户端-投诉问题解决满意度 第二行
+        row = sheet4.createRow(1);
+        cell = row.createCell(0);
+        cell.setCellValue("地市");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(1);
+        cell.setCellValue("投诉问题解决满意率");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(2);
+        cell.setCellValue("达标值");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(3);
+        cell.setCellValue("与达标值差距");
+        cell.setCellStyle(cellStyle3);
+        int rowNum = 2;
+        for (List<Object> list : sheet4_6Data.get(0)) {
+            row = sheet4.createRow(rowNum++);
+            // 地市
+            cell = row.createCell(0);
+            cell.setCellValue(list.get(0).toString());
+            cell.setCellStyle(cellStyle1);
+            // 投诉问题解决满意率
+            cell = row.createCell(1);
+            cell.setCellValue(((BigDecimal) list.get(1)).doubleValue());
+            cell.setCellStyle(cellStyle2);
+            // 达标值
+            cell = row.createCell(2);
+            cell.setCellValue((double) list.get(2));
+            cell.setCellStyle(cellStyle2);
+            // 与达标值差距
+            cell = row.createCell(3);
+            cell.setCellValue(((double) list.get(3)));
+            cell.setCellStyle(cellStyle2);
+        }
+        // 设置条件格式D3-D14
+        rangeAddress = new CellRangeAddress(2, 13, 3, 3);
+        setConditionalFormatting2(sheet4, rangeAddress);
+
+        // 客户端-投诉问题解决率
+        row = sheet5.createRow(0);
+        cell = row.createCell(0);
+        cell.setCellValue(String.format("投诉问题解决率(1-%s)", dayOfMonth));
+        cell.setCellStyle(cellStyle3);
+        // 合并单元格 A1 - D1
+        rangeAddress = new CellRangeAddress(0, 0, 0, 3);
+        addMergedRegion(sheet5, rangeAddress);
+        // 客户端-投诉问题解决率 第二行
+        row = sheet5.createRow(1);
+        cell = row.createCell(0);
+        cell.setCellValue("地市");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(1);
+        cell.setCellValue("投诉问题解决率");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(2);
+        cell.setCellValue("达标值");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(3);
+        cell.setCellValue("与达标值差距");
+        cell.setCellStyle(cellStyle3);
+        rowNum = 2;
+        for (List<Object> list : sheet4_6Data.get(1)) {
+            row = sheet5.createRow(rowNum++);
+            // 地市
+            cell = row.createCell(0);
+            cell.setCellValue(list.get(0).toString());
+            cell.setCellStyle(cellStyle1);
+            // 投诉问题解决率
+            cell = row.createCell(1);
+            cell.setCellValue(((BigDecimal) list.get(1)).doubleValue());
+            cell.setCellStyle(cellStyle2);
+            // 达标值
+            cell = row.createCell(2);
+            cell.setCellValue((double) list.get(2));
+            cell.setCellStyle(cellStyle2);
+            // 与达标值差距
+            cell = row.createCell(3);
+            cell.setCellValue(((double) list.get(3)));
+            cell.setCellStyle(cellStyle2);
+        }
+        // 设置条件格式D3-D14
+        rangeAddress = new CellRangeAddress(2, 13, 3, 3);
+        setConditionalFormatting2(sheet5, rangeAddress);
+
+        // 客户端-投诉问题响应率
+        row = sheet6.createRow(0);
+        cell = row.createCell(0);
+        cell.setCellValue(String.format("投诉问题相应率(1-%s)", dayOfMonth));
+        cell.setCellStyle(cellStyle3);
+        // 合并单元格 A1 - D1
+        rangeAddress = new CellRangeAddress(0, 0, 0, 3);
+        addMergedRegion(sheet6, rangeAddress);
+        // 客户端-投诉问题相应率 第二行
+        row = sheet6.createRow(1);
+        cell = row.createCell(0);
+        cell.setCellValue("地市");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(1);
+        cell.setCellValue("投诉问题相应率");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(2);
+        cell.setCellValue("达标值");
+        cell.setCellStyle(cellStyle3);
+        cell = row.createCell(3);
+        cell.setCellValue("与达标值差距");
+        cell.setCellStyle(cellStyle3);
+        rowNum = 2;
+        for (List<Object> list : sheet4_6Data.get(2)) {
+            row = sheet6.createRow(rowNum++);
+            // 地市
+            cell = row.createCell(0);
+            cell.setCellValue(list.get(0).toString());
+            cell.setCellStyle(cellStyle1);
+            // 投诉问题解决率
+            cell = row.createCell(1);
+            cell.setCellValue(((BigDecimal) list.get(1)).doubleValue());
+            cell.setCellStyle(cellStyle2);
+            // 达标值
+            cell = row.createCell(2);
+            cell.setCellValue((double) list.get(2));
+            cell.setCellStyle(cellStyle2);
+            // 与达标值差距
+            cell = row.createCell(3);
+            cell.setCellValue(((double) list.get(3)));
+            cell.setCellStyle(cellStyle2);
+        }
+        // 设置条件格式D3-D14
+        rangeAddress = new CellRangeAddress(2, 13, 3, 3);
+        setConditionalFormatting2(sheet6, rangeAddress);
+    }
+
     /**
      * 投诉处理时长、超时工单概况
      * 
@@ -160,6 +349,58 @@ public class TslReportService {
         cell.setCellValue("涨幅");
         cell.setCellStyle(cellStyle3);
 
+        // 写入超时工单情况
+        List<List<Object>> sheet3Data1 = tslDataService.getSheet3Data1(day);
+        int rowNum = 2;
+        for (List<Object> list : sheet3Data1) {
+            row = sheet.createRow(rowNum++);
+            // 地市
+            cell = row.createCell(0);
+            cell.setCellValue(list.get(0).toString());
+            cell.setCellStyle(cellStyle1);
+            // 工单数
+            cell = row.createCell(1);
+            cell.setCellValue((long) list.get(1));
+            cell.setCellStyle(cellStyle1);
+            // 超时工单数
+            cell = row.createCell(2);
+            cell.setCellValue((long) list.get(2));
+            cell.setCellStyle(cellStyle1);
+            // 超时工单占比
+            cell = row.createCell(3);
+            cell.setCellValue(((BigDecimal) list.get(3)).doubleValue());
+            cell.setCellStyle(cellStyle2);
+        }
+        // 设置条件格式D3-D14
+        rangeAddress = new CellRangeAddress(2, 13, 3, 3);
+        setConditionalFormatting(sheet, rangeAddress);
+
+        // 写入平均处理时长
+        List<List<Object>> sheet3Data2 = tslDataService.getSheet3Data2(day);
+        rowNum = 2;
+        for (List<Object> list : sheet3Data2) {
+            row = sheet.getRow(rowNum++);
+            // 地市
+            cell = row.createCell(6);
+            cell.setCellValue(list.get(0).toString());
+            cell.setCellStyle(cellStyle1);
+            // 上月
+            cell = row.createCell(7);
+            cell.setCellValue((double) list.get(1));
+            cell.setCellStyle(cellStyle4);
+            // 当月
+            cell = row.createCell(8);
+            cell.setCellValue((double) list.get(2));
+            cell.setCellStyle(cellStyle4);
+            // 涨幅
+            cell = row.createCell(9);
+            cell.setCellValue((double) list.get(3));
+            cell.setCellStyle(cellStyle4);
+        }
+        // 设置条件格式J3-J14
+        rangeAddress = new CellRangeAddress(2, 13, 9, 9);
+        setConditionalFormatting(sheet, rangeAddress);
+
         // 设置列宽 2048 2276*3 2048*3 2276*2 3612
         sheet.setColumnWidth(0, 2048);
         sheet.setColumnWidth(1, 2276);
@@ -581,4 +822,29 @@ public class TslReportService {
 
         conditionalFormatting.addConditionalFormatting(cellRangeAddresses, rule);
     }
+
+    /**
+     * 条件格式 3色渐变
+     * 绿 FF63BE7B 黄 FFFFEB84 红 FFF8696B
+     * 
+     * @return
+     */
+    private void setConditionalFormatting2(Sheet sheet, CellRangeAddress rangeAddress) {
+        SheetConditionalFormatting conditionalFormatting = sheet.getSheetConditionalFormatting();
+        ConditionalFormattingRule rule = conditionalFormatting.createConditionalFormattingColorScaleRule();
+        XSSFColor[] colors = new XSSFColor[] {
+                new XSSFColor(), new XSSFColor(), new XSSFColor()
+        };
+        colors[0].setARGBHex("FFF8696B");
+        colors[1].setARGBHex("FFFFEB84");
+        colors[2].setARGBHex("FF63BE7B");
+
+        rule.getColorScaleFormatting().setColors(colors);
+
+        CellRangeAddress[] cellRangeAddresses = new CellRangeAddress[] {
+                rangeAddress
+        };
+
+        conditionalFormatting.addConditionalFormatting(cellRangeAddresses, rule);
+    }
 }

+ 5 - 0
tsl_data/src/main/resources/application.properties

@@ -16,3 +16,8 @@ tslTask.source.HIGH_QUALITY_SQL=insert into report_auto.he_d_high_quality (month
 tslTask.source.HIGH_QUALITY_DIR=/data/nenglishangdian/HE_D_HIGH_QUALITY_COUNT_DAY/
 tslTask.source.HIGH_QUALITY_PREFIX=HE_D_HIGH_QUALITY_COUNT_DAY_
 tslTask.source.HIGH_QUALITY_FIELD_NUM=33
+
+# 达标值 满意率92%,解决率85%,响应率99%
+tslTask.compliance.satisfied=0.92
+tslTask.compliance.resolution=0.85
+tslTask.compliance.response=0.99

+ 32 - 1
tsl_data/src/main/resources/mapper/TslDao.xml

@@ -3,6 +3,37 @@
 
 <mapper namespace="com.nokia.tsl_data.dao.TslDao">
 
+    <select id="selectClientRatioForDay" resultType="Map">with t1 as (select businoareaname,
+        complaint_satisfied_list::numeric, complaint_satisfied_count::numeric,
+        complaint_resolution_list::numeric, complaint_resolution_count::numeric,
+        complaint_response_list::numeric, complaint_response_count::numeric from
+        report_auto.he_d_high_quality hdhq where acct_date = #{day} and profes_dep = '网络质量' and
+        big_type_name = '移网网络体验' and small_type_name = '--') select '全省' as businoareaname,
+        sum(complaint_satisfied_list) / sum(complaint_satisfied_count) as complaint_satisfied,
+        sum(complaint_resolution_list) / sum(complaint_resolution_count) as complaint_resolution,
+        sum(complaint_response_list) / sum(complaint_response_count) as complaint_response from t1
+        union select businoareaname, complaint_satisfied_list / complaint_satisfied_count as
+        complaint_satisfied, complaint_resolution_list / complaint_resolution_count as
+        complaint_resolution, complaint_response_list / complaint_response_count as
+        complaint_response from t1</select>
+
+    <select id="selectOldTsDurationForMonth" resultType="Map"> select city_name,avg_duration from
+        report_auto.avg_duration where month_id = #{monthId} </select>
+
+    <insert id="insertOldTsDuration" parameterType="Map"> INSERT INTO report_auto.avg_duration
+        (month_id, city_name, avg_duration) VALUES(#{map.month_id}, #{map.city_name},
+        #{map.avg_duration}); </insert>
+
+    <select id="selectTsDurationForDay" resultType="Map"> with t1 as (select compl_area_local, case
+        when proce_time != '' then (extract('epoch' from to_timestamp(proce_time, 'YYYY-MM-DD
+        HH24:MI:SS')) - extract('epoch' from to_timestamp(accept_time, 'YYYY-MM-DD
+        HH24:MI:SS')))/3600 when is_online_complete = '是' then 0 else (extract('epoch' from
+        to_timestamp(end_time, 'YYYY-MM-DD HH24:MI:SS')) - extract('epoch' from
+        to_timestamp(accept_time, 'YYYY-MM-DD HH24:MI:SS')))/3600 end as duration from
+        report_auto.he_d_mobile_comp hdmc where month_id = substring('20230420' from 1 for 6) and
+        day_id &lt;= substring('20230420' from 7 for 2)) select compl_area_local, avg(duration) as
+        avg_duration from t1 group by compl_area_local </select>
+
     <select id="selectTimeoutTsCountForDay" resultType="Map">with t1 as (select compl_area_local,
         is_timeout from report_auto.he_d_mobile_comp hdmc where month_id = substring(#{day} from 1
         for 6) and day_id &lt;= substring(#{day} from 7 for 2)), t2 as (select '全省' as
@@ -13,7 +44,7 @@
         as timeout_num from t5 group by compl_area_local), t9 as (select * from t7 union select *
         from t8) select t4.compl_area_local, t4.total_num, t9.timeout_num, t9.timeout_num /
         t4.total_num::numeric as timeout_ratio from t4,t9 where t4.compl_area_local =
-        t9.compl_area_local order by t9.timeout_num / t4.total_num::numeric desc</select>
+        t9.compl_area_local</select>
 
     <select id="selectRepeatTsCountForDay" resultType="Map"> with t1 as (select
         compl_area_local,busi_no from report_auto.he_d_mobile_comp hdmc where month_id =

+ 1 - 14
tsl_data/src/test/java/com/nokia/tsl_data/TslDataApplicationTest.java

@@ -1,14 +1,10 @@
 package com.nokia.tsl_data;
 
 import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import com.nokia.tsl_data.dao.TslDao;
 import com.nokia.tsl_data.service.TslReportService;
 
 @SpringBootTest
@@ -19,15 +15,6 @@ public class TslDataApplicationTest {
 
     @Test
     void test() throws IOException {
-        tslReportService.workbookToFile("20230421", "D:/src/cccccc.xlsx");
-    }
-
-    @Autowired
-    private TslDao tslDao;
-
-    @Test
-    void test1() {
-        List<Map<String, Object>> selectTimeoutTsCountForDay = tslDao.selectTimeoutTsCountForDay("20230420");
-        System.out.println(selectTimeoutTsCountForDay);
+        tslReportService.workbookToFile("20230421", "D:/src/dddddd.xlsx");
     }
 }