瀏覽代碼

日常保存

lifuquan 1 年之前
父節點
當前提交
36c9716161
共有 30 個文件被更改,包括 596 次插入650 次删除
  1. 2 0
      .gitignore
  2. 2 0
      README.md
  3. 15 0
      doc/开发文档.md
  4. 35 0
      doc/接口测试.http
  5. 二進制
      doc/数据订阅/能力商店/河北_CEM高品质2日统计/河北_CEM高品质2日统计_HE_D_HIGH_QUALITY.xlsx
  6. 21 6
      pom.xml
  7. 24 0
      src/main/java/com/nokia/tsl_data/config/TaskSchedulingConfig.java
  8. 101 0
      src/main/java/com/nokia/tsl_data/controller/DataWarehouseController.java
  9. 45 3
      src/main/java/com/nokia/tsl_data/dao/HighQualityCountMapper.java
  10. 96 0
      src/main/java/com/nokia/tsl_data/dao/HighQualityDataMapper.java
  11. 3 0
      src/main/java/com/nokia/tsl_data/dao/HighQualityDataRepository.java
  12. 22 7
      src/main/java/com/nokia/tsl_data/dao/HighQualityListDayMapper.java
  13. 70 2
      src/main/java/com/nokia/tsl_data/dao/MobileComplaintMapper.java
  14. 19 4
      src/main/java/com/nokia/tsl_data/dao/SysDataDictionaryRepository.java
  15. 0 115
      src/main/java/com/nokia/tsl_data/dao/TslMapper.java
  16. 4 0
      src/main/java/com/nokia/tsl_data/entity/HighQualityData.java
  17. 21 4
      src/main/java/com/nokia/tsl_data/service/DataWarehouseService.java
  18. 4 1
      src/main/java/com/nokia/tsl_data/service/HighQualityCountService.java
  19. 29 5
      src/main/java/com/nokia/tsl_data/service/HighQualityDataService.java
  20. 3 3
      src/main/java/com/nokia/tsl_data/service/TaskService.java
  21. 7 10
      src/main/java/com/nokia/tsl_data/service/TslDataService.java
  22. 6 6
      src/main/java/com/nokia/tsl_data/service/TslReportService.java
  23. 13 7
      src/main/resources/application.yml
  24. 1 1
      src/main/resources/logback-spring.xml
  25. 0 18
      src/main/resources/mapper/HighQualityCountMapper.xml
  26. 1 1
      src/main/resources/mapper/HighQualityListDayMapper.xml
  27. 0 181
      src/main/resources/mapper/MobileComplaintMapper.xml
  28. 0 266
      src/main/resources/mapper/TslMapper.xml
  29. 38 3
      src/test/java/com/nokia/tsl_data/MainTest.java
  30. 14 7
      src/test/java/com/nokia/tsl_data/TslDataApplicationTest.java

+ 2 - 0
.gitignore

@@ -19,3 +19,5 @@
 
 # office临时文件
 **/~$*
+# draio临时文件
+**/.$*

+ 2 - 0
README.md

@@ -1 +1,3 @@
 # tsl-data
+
+nohup java -jar /data/tsl-data/tsl-data-exec.jar >/dev/null 2>&1 &

+ 15 - 0
doc/开发文档.md

@@ -2,3 +2,18 @@
 
 ## 需要确认的问题
 
+1. 数据缺失时有无默认处理方式
+
+2. 客户端-战略考核(地市级别) 每日数据 当前是从CEM的高品质统计中的统计值
+
+任务编排
+
+HighQualityCount 数据入库
+
+HighQualityList 数据入库
+
+MobileComplaint 数据入库
+
+生成excel文件
+
+截图

+ 35 - 0
doc/接口测试.http

@@ -0,0 +1,35 @@
+### 入库 mobile_complaint 数据
+POST http://192.168.10.7:22222/tsl_data/warehouse/mobile_complaint
+Content-Type: application/json
+
+20231105
+
+### 删除 mobile_complaint 数据
+POST http://192.168.10.7:22222/tsl_data/delete/mobile_complaint
+Content-Type: application/json
+
+20231028
+
+### 入库 high_quality_count 数据
+POST http://192.168.10.7:22222/tsl_data/warehouse/high_quality_count
+Content-Type: application/json
+
+20231105
+
+### 删除 high_quality_count 数据
+POST http://192.168.10.7:22222/tsl_data/delete/high_quality_count
+Content-Type: application/json
+
+20231028
+
+### 入库 high_quality_list 数据
+POST http://192.168.10.7:22222/tsl_data/warehouse/high_quality_list
+Content-Type: application/json
+
+20231105
+
+### 删除 high_quality_list 数据
+POST http://192.168.10.7:22222/tsl_data/delete/high_quality_list
+Content-Type: application/json
+
+20231028

二進制
doc/数据订阅/能力商店/河北_CEM高品质2日统计/河北_CEM高品质2日统计_HE_D_HIGH_QUALITY.xlsx


+ 21 - 6
pom.xml

@@ -54,12 +54,6 @@
             <artifactId>commons-csv</artifactId>
             <version>1.10.0</version>
         </dependency>
-        <!-- cache-starter -->
-        <dependency>
-            <groupId>com.nokia</groupId>
-            <artifactId>cache-starter</artifactId>
-            <version>1.0.0</version>
-        </dependency>
         <!-- fastjson -->
         <dependency>
             <groupId>com.alibaba</groupId>
@@ -106,4 +100,25 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <finalName>tsl-data</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.6.14</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <classifier>exec</classifier>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

+ 24 - 0
src/main/java/com/nokia/tsl_data/config/TaskSchedulingConfig.java

@@ -0,0 +1,24 @@
+package com.nokia.tsl_data.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+
+/**
+ * 任务调度线程配置
+ */
+public class TaskSchedulingConfig {
+
+    private final int poolSize = 3;
+
+    /**
+     * 调度器,使用默认的ThreadPoolTaskScheduler
+     */
+    @Bean
+    public ThreadPoolTaskScheduler taskScheduler() {
+        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
+        taskScheduler.setPoolSize(poolSize);
+        taskScheduler.setThreadNamePrefix("taskSchedulerThreadPool-");
+        taskScheduler.initialize();
+        return taskScheduler;
+    }
+}

+ 101 - 0
src/main/java/com/nokia/tsl_data/controller/DataWarehouseController.java

@@ -0,0 +1,101 @@
+package com.nokia.tsl_data.controller;
+
+import com.nokia.common.http.vo.R;
+import com.nokia.tsl_data.service.DataWarehouseService;
+import com.nokia.tsl_data.service.TaskService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RestController
+@RequestMapping("tsl_data")
+public class DataWarehouseController {
+
+    private final DataWarehouseService dataWarehouseService;
+    private final TaskService taskService;
+
+    public DataWarehouseController(DataWarehouseService dataWarehouseService, TaskService taskService) {
+        this.dataWarehouseService = dataWarehouseService;
+        this.taskService = taskService;
+    }
+
+    @PostMapping("warehouse/mobile_complaint")
+    public R warehouseMobileComplaint(@RequestBody String day) {
+        try {
+            dataWarehouseService.warehouseMobileComplaintDay(day);
+            return R.ok().message(String.format("管理端详表 MobileComplaint 数据账期 %s 入库成功", day));
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            return R.error().message(String.format("管理端详表 MobileComplaint 数据账期 %s 入库失败: %s", day, e.getMessage()));
+        }
+    }
+
+    @PostMapping("delete/mobile_complaint")
+    public R deleteMobileComplaint(@RequestBody String day) {
+        try {
+            int count = dataWarehouseService.deleteMobileComplaintDay(day);
+            return R.ok().message(String.format("管理端详表 MobileComplaint 数据账期 %s 删除 %s 条", day, count));
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            return R.error().message(String.format("管理端详表 MobileComplaint 数据账期 %s 删除失败: %s", day, e.getMessage()));
+        }
+    }
+
+    @PostMapping("warehouse/high_quality_count")
+    public R warehouseHighQualityCount(@RequestBody String day) {
+        try {
+            dataWarehouseService.warehouseHighQualityCountDay(day);
+            return R.ok().message(String.format("客户端统计 HighQualityCount 数据账期 %s 入库成功", day));
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            return R.error().message(String.format("客户端统计 HighQualityCount 数据账期 %s 入库失败: %s", day, e.getMessage()));
+        }
+    }
+
+    @PostMapping("delete/high_quality_count")
+    public R deleteHighQualityCount(@RequestBody String day) {
+        try {
+            int count = dataWarehouseService.deleteHighQualityCountDay(day);
+            return R.ok().message(String.format("客户端统计 HighQualityCount 数据账期 %s 删除 %s 条", day, count));
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            return R.error().message(String.format("客户端统计 HighQualityCount 数据账期 %s 删除失败: %s", day, e.getMessage()));
+        }
+    }
+
+    @PostMapping("warehouse/high_quality_list")
+    public R warehouseHighQualityList(@RequestBody String day) {
+        try {
+            dataWarehouseService.warehouseHighQualityListDay(day);
+            return R.ok().message(String.format("客户端详表 HighQualityList 数据账期 %s 入库成功", day));
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            return R.error().message(String.format("客户端详表 HighQualityList 数据账期 %s 入库失败: %s", day, e.getMessage()));
+        }
+    }
+
+    @PostMapping("delete/high_quality_list")
+    public R deleteHighQualityList(@RequestBody String day) {
+        try {
+            int count = dataWarehouseService.deleteHighQualityListDay(day);
+            return R.ok().message(String.format("客户端详表 HighQualityList 数据账期 %s 删除 %s 条", day, count));
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            return R.error().message(String.format("客户端详表 HighQualityList 数据账期 %s 删除失败: %s", day, e.getMessage()));
+        }
+    }
+
+    @PostMapping("update/work_flow_basic_data")
+    public R updateWorkFlowBasicData() {
+        try {
+            taskService.updateWorkFlowBasicDataTask();
+            return R.ok().message("工作流基础数据更新成功...");
+        } catch (Exception e) {
+            log.error(e.getMessage());
+            return R.error().message(String.format("工作流基础数据更新失败: %s", e.getMessage()));
+        }
+    }
+}

+ 45 - 3
src/main/java/com/nokia/tsl_data/dao/HighQualityCountMapper.java

@@ -1,7 +1,9 @@
 package com.nokia.tsl_data.dao;
 
+import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 import java.util.Map;
@@ -13,14 +15,54 @@ import java.util.Map;
 @Mapper
 public interface HighQualityCountMapper {
 
+    /**
+     * 查询河北_CEM高品质2日统计数据量
+     */
+    @Select("select count(1) from tsl_data.high_quality_count_day where acct_date = #{day} ")
+    int selectQualityCountForDay(String day);
+
+    /**
+     * 客户端-投诉问题解决满意度
+     * 客户端-投诉问题解决率
+     * 客户端-投诉问题响应率
+     */
+    @Select("with t1 as (select businoareaname, complaint_satisfied_list::float8, complaint_satisfied_count::float8, " +
+            "complaint_resolution_list::float8, complaint_resolution_count::float8, complaint_response_list::float8, " +
+            "complaint_response_count::float8, complaint::float8 " +
+            "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 + complaint) as complaint_satisfied, " +
+            "   sum(complaint_resolution_list) / sum(complaint_resolution_count + complaint) as complaint_resolution, " +
+            "   sum(complaint_response_list) / sum(complaint_response_count + complaint)  as complaint_response from t1 " +
+            "union select businoareaname, " +
+            "case when (complaint_satisfied_count + complaint) = 0 then 0 " +
+            "  else complaint_satisfied_list / (complaint_satisfied_count + complaint) end as complaint_satisfied, " +
+            "case when (complaint_resolution_count + complaint) = 0 then 0 " +
+            "  else complaint_resolution_list / (complaint_resolution_count + complaint) end as complaint_resolution, " +
+            "case when (complaint_response_count + complaint) = 0 then 0 " +
+            "  else complaint_response_list / (complaint_response_count + complaint) end     as complaint_response from t1")
+    List<Map<String, Object>> selectClientRatioForDay(String day);
+
     /**
      * 查询某个日期各个地市的客户端总数(总投诉量(办结量))(所得结果是当月0日到当天的一个累加量)
      */
-    List<Map<String, Object>> selectTotalComplaintsForDay(String day);
+    default List<Map<String, Object>> selectTotalComplaintsForDay(String day) {
+        return selectTotalComplaintsForMonthIdAndDay(day.substring(0, 6), day.substring(6));
+    }
 
     /**
      * 查询某个日期各个地市的客户端总数(总投诉量(办结量))(所得结果是当月0日到当天的一个累加量)
      */
-    List<Map<String, Object>> selectTotalComplaintsForMonthIdAndDay(@Param("monthId") String monthId,
-                                                                    @Param("day") String day);
+    @Select("select businoareaname, total_complaints from tsl_data.high_quality_count_day " +
+            "where month_id = #{month_id} and day_id = #{day_id} and profes_dep = '网络质量' " +
+            "and big_type_name = '移网网络体验' and small_type_name = '--'")
+    List<Map<String, Object>> selectTotalComplaintsForMonthIdAndDay(@Param("month_id") String monthId,
+                                                                    @Param("day_id") String day);
+
+    @Delete("delete from tsl_data.high_quality_count_day where month_id = #{month_id} and day_id = #{day_id}")
+    int deleteHighQualityCountForMonthIdAndDayId(@Param("month_id") String monthId, @Param("day_id") String dayId);
+
+    default int deleteHighQualityCountForDay(String day) {
+        return deleteHighQualityCountForMonthIdAndDayId(day.substring(0, 6), day.substring(6));
+    }
 }

+ 96 - 0
src/main/java/com/nokia/tsl_data/dao/HighQualityDataMapper.java

@@ -0,0 +1,96 @@
+package com.nokia.tsl_data.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface HighQualityDataMapper {
+
+    /**
+     * 依据工单流转的信息更新HighQualityData的地市信息
+     */
+    @Update("update tsl_data.high_quality_data t1\n" +
+            "set checked_city = t2.city, checked_city_reason = 'work_flow', last_update_date = now() \n" +
+            "from (select w.kfsn as kfsn, s.real_name as city from tsl_data.work_flow_basic_data w, \n" +
+            " tsl_data.sys_data_dictionary s where s.type = 'work_flow_city' and s.nick_code = w.city_id) t2\n" +
+            "where t2.kfsn = t1.sheet_no and t1.day_id = #{day}")
+    int updateHighQualityDataCityFromWorkFlowBasicData(String day);
+
+    /**
+     * 依据工单流转的信息更新HighQualityData的区县信息
+     */
+    @Update("update tsl_data.high_quality_data t1\n" +
+            "set checked_region  = t2.region, checked_region_reason = 'work_flow', last_update_date = now()\n" +
+            "from (select w.kfsn as kfsn, s.real_name as region from tsl_data.work_flow_basic_data w,\n" +
+            "tsl_data.sys_data_dictionary s where s.type = 'work_flow_region' and s.nick_code = w.region_id) t2\n" +
+            "where t2.kfsn = t1.sheet_no and t1.day_id = #{day}")
+    int updateHighQualityDataRegionFromWorkFlowBasicData(String day);
+
+    /**
+     * 依据高品质工单详表信息更新HighQualityData的地市信息
+     */
+    @Update("update tsl_data.high_quality_data t1\n" +
+            "set checked_city = t2.real_name, checked_city_reason = 'high_quality_list', last_update_date = now()\n" +
+            "from (select nick_code, real_name from tsl_data.sys_data_dictionary where type = 'high_quality_list_city') t2\n" +
+            "where t2.nick_code = t1.area_id and t1.checked_city is null and t1.day_id = #{day}")
+    int updateHighQualityDataCityFromHighQualityListDay(String day);
+
+    /**
+     * 依据高品质工单详表信息更新HighQualityData的区县信息
+     */
+    @Update("update tsl_data.high_quality_data t1\n" +
+            "set checked_region = t2.real_name, checked_region_reason = 'high_quality_list', last_update_date = now()\n" +
+            "from (select nick_code, real_name from tsl_data.sys_data_dictionary where type = 'high_quality_list_region') t2\n" +
+            "where t2.nick_code = t1.city_id and t1.checked_region is null and t1.day_id = #{day}")
+    int updateHighQualityDataRegionFromHighQualityListDay(String day);
+
+    /**
+     * 根据默认规则更新HighQualityData的区县信息
+     */
+    @Update("update tsl_data.high_quality_data t1\n" +
+            "set checked_region = concat(checked_city, '市区'), checked_region_reason = 'default', last_update_date = now()\n" +
+            "where t1.checked_region is null and t1.day_id = #{day}")
+    int updateHighQualityDataRegionFromDefault(String day);
+
+    /**
+     * 按照日期查询区县的响应率
+     */
+    @Select("select checked_city, checked_region, count(cp_timely_contact = '是' or null)::float / count(1) as rate, count(cp_timely_contact = '否' or null) as not_timely_contact_count \n" +
+            "from tsl_data.high_quality_data hqd \n" +
+            "where day_id = #{day} and (cp_timely_contact in ('是', '否') or no_visit_tag = '未回访')\n" +
+            "group by checked_city, checked_region \n" +
+            "order by count(cp_timely_contact = '是' or null)::float / count(1)")
+    List<Map<String, Object>> selectRegionTimelyContactRate(String day);
+
+    /**
+     * 查询某日期月累计未响应工单数量
+     */
+    @Select("select checked_city, checked_region, count(cp_timely_contact = '否' or null) as not_timely_contact_count \n" +
+            "from tsl_data.high_quality_data hqd \n" +
+            "where day_id = #{day} and (cp_timely_contact in ('是', '否') or no_visit_tag = '未回访')\n" +
+            "group by checked_city, checked_region \n" +
+            "order by count(cp_timely_contact = '是' or null)::float / count(1)")
+    List<Map<String, Object>> selectRegionNotTimelyContactCount(String day);
+
+    /**
+     * 按照日期查询区县的满意率
+     */
+    @Select("select checked_city, checked_region, count(1) as total, count(cp_satisfaction in ('满意', '一般') or null) as satisfaction, count(cp_satisfaction in ('满意', '一般') or null)::float / count(1) as rate \n" +
+            "from tsl_data.high_quality_data hqd \n" +
+            "where day_id = #{day} and (cp_satisfaction in ('满意', '一般', '不满意') or no_visit_tag = '未回访')\n" +
+            "group by checked_city, checked_region")
+    List<Map<String, Object>> selectRegionSatisfactionRate(String day);
+
+    /**
+     * 按照日期查询解决率
+     */
+    @Select("select checked_city, checked_region, count(1) as total, count(cp_is_ok = '解决' or null) as is_ok, count(cp_is_ok = '解决' or null)::float / count(1) as rate \n" +
+            "from tsl_data.high_quality_data hqd \n" +
+            "where day_id = #{day} and (cp_is_ok in ('解决', '未解决') or no_visit_tag = '未回访') \n" +
+            "group by checked_city, checked_region")
+    List<Map<String, Object>> selectRegionIsOkRate(String day);
+}

+ 3 - 0
src/main/java/com/nokia/tsl_data/dao/HighQualityDataRepository.java

@@ -6,4 +6,7 @@ import org.springframework.stereotype.Repository;
 
 @Repository
 public interface HighQualityDataRepository extends JpaRepository<HighQualityData, Long> {
+    void findByDayId(String dayId);
+
+    int countByDayId(String dayId);
 }

+ 22 - 7
src/main/java/com/nokia/tsl_data/dao/HighQualityListDayMapper.java

@@ -1,12 +1,13 @@
 package com.nokia.tsl_data.dao;
 
 import com.nokia.tsl_data.entity.HighQualityData;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.ResultMap;
-import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.*;
 
 import java.util.List;
 
+/**
+ * 高品质详表数据库交互
+ */
 @Mapper
 public interface HighQualityListDayMapper {
 
@@ -15,8 +16,22 @@ public interface HighQualityListDayMapper {
 
     @ResultMap("highQualityDataResultMap")
     @Select("select concat(month_id, day_id) as day_id, sheet_no, cp_satisfaction, cp_is_ok,"
-            + " cp_timely_contact, cp_timely_contact, area_id, area_name, city_id, city_name"
-            + " from tsl_data.high_quality_list_day "
-            + "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)")
-    List<HighQualityData> findHighQualityDataOfDay(String day);
+            + " cp_timely_contact, cp_timely_contact, area_id, area_name, city_id, city_name,"
+            + " novisit_tag from tsl_data.high_quality_list_day "
+            + " where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)"
+            + " and novisit_tag in ('已回访', '未回访')")
+    List<HighQualityData> selectHighQualityDataOfDay(String day);
+
+    /**
+     * 按照month_id和day_id字段删除数据
+     */
+    @Delete("delete from tsl_data.high_quality_list_day where month_id = #{month_id} and day_id = #{day_id}")
+    int deleteHighQualityListForMonthIdAndDayId(@Param("month_id") String monthId, @Param("day_id") String dayId);
+
+    /**
+     * 用于删除某天已入库的高品质详表数据
+     */
+    default int deleteHighQualityListForDay(String day) {
+        return deleteHighQualityListForMonthIdAndDayId(day.substring(0, 6), day.substring(6));
+    }
 }

+ 70 - 2
src/main/java/com/nokia/tsl_data/dao/MobileComplaintMapper.java

@@ -1,6 +1,6 @@
 package com.nokia.tsl_data.dao;
 
-import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.*;
 
 import java.util.List;
 import java.util.Map;
@@ -10,50 +10,118 @@ public interface MobileComplaintMapper {
     /**
      * 统计某天入库工单数量
      */
+    @Select("select count(1) from tsl_data.high_quality_list_day " +
+            "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)")
     int selectCompCountForDay(String day);
 
     /**
      * 超时工单统计
      */
+    @Select("with t1 as (select compl_area_local, is_timeout from tsl_data.high_quality_list_day hdmc " +
+            " where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)), " +
+            "t2 as (select '全省' as compl_area_local, count(1) as total_num from t1), " +
+            "t3 as (select compl_area_local, count(1) as total_num from t1 group by compl_area_local), " +
+            "t4 as (select * from t2 union select * from t3), " +
+            "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::float8 as timeout_ratio " +
+            "from t4, t9 where t4.compl_area_local = t9.compl_area_local")
     List<Map<String, Object>> selectTimeoutTsCountForDay(String day);
 
     /**
      * 处理时长统计
      */
+    @Select("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 tsl_data.high_quality_list_day hdmc " +
+            "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)) " +
+            "select compl_area_local, avg(duration) as avg_duration from t1 group by compl_area_local")
     List<Map<String, Object>> selectTsDurationForDay(String day);
 
     /**
      * 重复工单
      */
+    @Select("with t1 as (select compl_area_local, busi_no from tsl_data.high_quality_list_day hdmc " +
+            " where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)), " +
+            "t2 as (select distinct * from t1), " +
+            "t3 as (select compl_area_local, count(1) as total_num from t1 group by compl_area_local), " +
+            "t4 as (select compl_area_local, count(1) as distinct_num from t2 group by compl_area_local), " +
+            "t5 as (select t3.compl_area_local, t3.total_num, t3.total_num - t4.distinct_num::float8 as repeat_num, " +
+            "       (t3.total_num - t4.distinct_num) / t3.total_num::float8 as repeat_ratio from T3, t4 " +
+            "       where t3.compl_area_local = t4.compl_area_local) " +
+            "select '全省' as compl_area_local, sum(total_num) as total_num, sum(repeat_num) as repeat_num, " +
+            "sum(repeat_num) / sum(total_num)::float8 as repeat_ratio from t5 union select * from t5 ")
     List<Map<String, Object>> selectRepeatTsCountForDay(String day);
 
     /**
      * 投诉清单按日按地市计数
      */
+    @Select("select compl_area_local, substring(acct_date from 7 for 2) as day_id, count(1) as num " +
+            " from tsl_data.high_quality_list_day hdmc where month_id = substring(#{day} from 1 for 6) " +
+            " and day_id = substring(#{day} from 7 for 2) group by compl_area_local, substring(acct_date from 7 for 2) " +
+            " order by compl_area_local, substring(acct_date from 7 for 2)")
     List<Map<String, Object>> selectCityTslForMonth(String day);
 
     /**
      * 投诉清单全省计数
      */
+    @Select("select substring(acct_date from 7 for 2) as day_id, count(1) as num " +
+            "from tsl_data.high_quality_list_day hdmc where month_id = substring(#{day} from 1 for 6) " +
+            "and day_id = substring(#{day} from 7 for 2) group by substring(acct_date from 7 for 2) " +
+            "order by substring(acct_date from 7 for 2)")
     List<Map<String, Object>> selectAllTslForMonth(String day);
 
     /**
      * 投诉清单地市总数
      */
+    @Select("select compl_area_local, count(1) as num from tsl_data.high_quality_list_day hdmc " +
+            "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2) " +
+            " group by compl_area_local order by compl_area_local")
     List<Map<String, Object>> selectCityAllForMonth(String day);
 
     /**
      * 投诉清单按月计算总数
      */
+    @Select("select count(1) as num from tsl_data.high_quality_list_day hdmc " +
+            "where month_id = substring(#{day} from 1 for 6) and day_id = substring(#{day} from 7 for 2)")
     int selectAllForMonth(String day);
 
+    @Delete("delete from tsl_data.mobile_complaint_day where month_id = #{month_id}  and day_id = #{day_id}")
+    int deleteMobileComplaintForMonthIdAndDayId(@Param("month_id") String monthId, @Param("day_id") String dayId);
+
     /**
      * 删除某天的管理端投诉清单
      */
-    void deleteMobileCompForDay(String day);
+    default int deleteMobileCompForDay(String day) {
+        return deleteMobileComplaintForMonthIdAndDayId(day.substring(0, 6), day.substring(6));
+    }
 
     /**
      * 插入上月的平均处理时长
      */
+    @Insert("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 tsl_data.high_quality_list_day hdmc where month_id = #{month_id} " +
+            "and day_id::float8 = extract('day' from to_timestamp(#{month_id}, 'YYYYMM') + interval '1 month' - interval '1 day')) " +
+            "insert into tsl_data.avg_duration (month_id, city_name, avg_duration) " +
+            "select #{month_id} as month_id, compl_area_local as city_name, avg(duration) as avg_duration " +
+            "from t1 group by compl_area_local ")
     void insertOldTsDurationForMonth(String monthId);
+
+    /**
+     * 查询历史处理时长
+     */
+    @Select("select city_name, avg_duration from tsl_data.avg_duration where month_id = #{monthId}")
+    List<Map<String, Object>> selectOldTsDurationForMonth(String monthId);
 }

+ 19 - 4
src/main/java/com/nokia/tsl_data/dao/SysDataDictionaryRepository.java

@@ -4,10 +4,7 @@ import com.nokia.tsl_data.entity.SysDataDictionary;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 @Repository
 public interface SysDataDictionaryRepository extends JpaRepository<SysDataDictionary, Long> {
@@ -35,4 +32,22 @@ public interface SysDataDictionaryRepository extends JpaRepository<SysDataDictio
         }
         return result;
     }
+
+    default Map<String, String> findHighQualityListCityMap() {
+        Map<String, String> result = new HashMap<>();
+        List<SysDataDictionary> cities = findByTypeOrderByOrd("high_quality_list_city");
+        for (SysDataDictionary city : cities) {
+            result.put(city.getNickCode(), city.getRealName());
+        }
+        return result;
+    }
+
+    default Map<String, String> findHighQualityListRegionMap() {
+        Map<String, String> result = new HashMap<>();
+        List<SysDataDictionary> regions = findByTypeOrderByOrd("high_quality_list_region");
+        for (SysDataDictionary region : regions) {
+            result.put(region.getNickCode(), region.getRealName());
+        }
+        return result;
+    }
 }

+ 0 - 115
src/main/java/com/nokia/tsl_data/dao/TslMapper.java

@@ -1,115 +0,0 @@
-package com.nokia.tsl_data.dao;
-
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-@Mapper
-public interface TslMapper {
-    /**
-     * 查询某天的河北_CEM移网质量投诉明细数据量
-     * v1.5废弃
-     */
-    @Deprecated
-    int selectCompCountForDay(String day);
-
-    /**
-     * 查询河北_CEM高品质2日统计数据量
-     */
-    int selectQualityCountForDay(String day);
-
-    /**
-     * 客户端-投诉问题解决满意度
-     * 客户端-投诉问题解决率
-     * 客户端-投诉问题响应率
-     */
-    List<Map<String, Object>> selectClientRatioForDay(String day);
-
-    /**
-     * 查询历史处理时长
-     */
-    List<Map<String, Object>> selectOldTsDurationForMonth(String monthId);
-
-    @Deprecated
-    void insertOldTsDurationForMonth(String monthId);
-
-    /**
-     * 存入历史处理时长数据
-     */
-    void insertOldTsDuration(@Param("map") Map<String, Object> map);
-
-    /**
-     * 处理时长统计
-     */
-    @Deprecated
-    List<Map<String, Object>> selectTsDurationForDay(String day);
-
-    /**
-     * 超时工单统计
-     * v1.5废弃
-     */
-    @Deprecated
-    List<Map<String, Object>> selectTimeoutTsCountForDay(String day);
-
-    /**
-     * 重复工单数和比例按截止日期和地市查询
-     * v1.5废弃
-     */
-    @Deprecated
-    List<Map<String, Object>> selectRepeatTsCountForDay(String day);
-
-    /**
-     * 投诉清单按日按地市计数
-     * v1.5废弃
-     */
-    @Deprecated
-    List<Map<String, Object>> selectCityTslForMonth(String day);
-
-    /**
-     * 投诉清单全省计数
-     * v1.5废弃
-     */
-    @Deprecated
-    List<Map<String, Object>> selectAllTslForMonth(String day);
-
-    /**
-     * 投诉清单地市总数
-     * v1.5废弃
-     */
-    @Deprecated
-    List<Map<String, Object>> selectCityAllForMonth(String day);
-
-    /**
-     * 投诉清单按月计算总数
-     * v1.5废弃
-     */
-    @Deprecated
-    int selectAllForMonth(String day);
-
-    /**
-     * 查询用户数
-     */
-    @Deprecated
-    List<Map<String, Object>> selectUserCountForMonth(String monthId);
-
-    /**
-     * 查询期望万投率
-     */
-    @Deprecated
-    List<Map<String, Object>> selectTargetTsRatioForMonth(String monthId);
-
-
-    /**
-     * 删除某天的客户端数据
-     */
-    void deleteHighQualityForDay(String day);
-
-    /**
-     * 删除某天的管理端投诉清单
-     * v1.5废弃
-     */
-    @Deprecated
-    void deleteMobileCompForDay(String day);
-}

+ 4 - 0
src/main/java/com/nokia/tsl_data/entity/HighQualityData.java

@@ -62,6 +62,10 @@ public class HighQualityData {
     @Column(name = "checked_city", columnDefinition = "varchar(50)")
     private String checkedCity;
 
+    // 确认地市的原因
+    @Column(name = "checked_city_reason", columnDefinition = "varchar(50)")
+    private String checkedCityReason;
+
     // 最后确认的区县
     @Column(name = "checked_region", columnDefinition = "varchar(50)")
     private String checkedRegion;

+ 21 - 4
src/main/java/com/nokia/tsl_data/service/DataWarehouseService.java

@@ -2,8 +2,7 @@ package com.nokia.tsl_data.service;
 
 import com.nokia.common.codec.MD5Util;
 import com.nokia.common.io.TextUtil;
-import com.nokia.tsl_data.dao.SysDataDictionaryRepository;
-import com.nokia.tsl_data.dao.TslDataDao;
+import com.nokia.tsl_data.dao.*;
 import com.nokia.tsl_data.properties.DataWarehouseProperties;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
@@ -26,14 +25,20 @@ import java.util.Set;
 public class DataWarehouseService {
 
     private final TslDataDao tslDataDao;
+    private final MobileComplaintMapper mobileComplaintMapper;
+    private final HighQualityCountMapper highQualityCountMapper;
+    private final HighQualityListDayMapper highQualityListDayMapper;
     private final SysDataDictionaryRepository sysDataDictionaryRepository;
     private final DataWarehouseProperties dataWarehouseProperties;
     private final MessageService messageService;
     // 重试等待时间
     private final Long delayForRetry = 1800L;
 
-    public DataWarehouseService(TslDataDao tslDataDao, SysDataDictionaryRepository sysDataDictionaryRepository, DataWarehouseProperties dataWarehouseProperties, MessageService messageService) {
+    public DataWarehouseService(TslDataDao tslDataDao, MobileComplaintMapper mobileComplaintMapper, HighQualityCountMapper highQualityCountMapper, HighQualityListDayMapper highQualityListDayMapper, SysDataDictionaryRepository sysDataDictionaryRepository, DataWarehouseProperties dataWarehouseProperties, MessageService messageService) {
         this.tslDataDao = tslDataDao;
+        this.mobileComplaintMapper = mobileComplaintMapper;
+        this.highQualityCountMapper = highQualityCountMapper;
+        this.highQualityListDayMapper = highQualityListDayMapper;
         this.sysDataDictionaryRepository = sysDataDictionaryRepository;
         this.dataWarehouseProperties = dataWarehouseProperties;
         this.messageService = messageService;
@@ -100,7 +105,7 @@ public class DataWarehouseService {
 
     private File getHighQualityCountDayFile(String day) {
         String fileName = dataWarehouseProperties.getPrefixOfHighQualityCountDay() + day + ".csv";
-        return Paths.get(dataWarehouseProperties.getDirOfHighQualityListDay(), fileName).toFile();
+        return Paths.get(dataWarehouseProperties.getDirOfHighQualityCountDay(), fileName).toFile();
     }
 
     /**
@@ -215,4 +220,16 @@ public class DataWarehouseService {
             throw new RuntimeException("河北_CEM高品质2日统计数据入库失败..." + e.getMessage());
         }
     }
+
+    public int deleteMobileComplaintDay(String day) {
+        return mobileComplaintMapper.deleteMobileCompForDay(day);
+    }
+
+    public int deleteHighQualityCountDay(String day) {
+        return highQualityCountMapper.deleteHighQualityCountForDay(day);
+    }
+
+    public int deleteHighQualityListDay(String day) {
+        return  highQualityListDayMapper.deleteHighQualityListForDay(day);
+    }
 }

+ 4 - 1
src/main/java/com/nokia/tsl_data/service/HighQualityCountService.java

@@ -23,7 +23,7 @@ public class HighQualityCountService {
     }
 
     /**
-     * 根据日期查询当月从1日起每天每个地市的客户端统计数据
+     *
      */
     public Map<String, int[]> getComplaintsForDay(String day) {
         // 预处理时间
@@ -44,6 +44,9 @@ public class HighQualityCountService {
             // 这里有一个查询操作
             List<Map<String, Object>> totalComplaintsForDay = highQualityCountDao
                     .selectTotalComplaintsForDay(newDay);
+            if (totalComplaintsForDay.size() == 0) {
+                throw new RuntimeException(String.format("HighQualityCount 缺少 %s 账期数据", newDay));
+            }
             int provinceAll = 0;
             for (Map<String, Object> map : totalComplaintsForDay) {
                 String city = map.get("businoareaname").toString();

+ 29 - 5
src/main/java/com/nokia/tsl_data/service/HighQualityDataService.java

@@ -1,18 +1,29 @@
 package com.nokia.tsl_data.service;
 
+import com.nokia.tsl_data.dao.HighQualityDataMapper;
 import com.nokia.tsl_data.dao.HighQualityDataRepository;
+import com.nokia.tsl_data.dao.HighQualityListDayMapper;
+import com.nokia.tsl_data.entity.HighQualityData;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 根据高质量明细表生产数据
  */
+@Slf4j
 @Service
 public class HighQualityDataService {
 
     private final HighQualityDataRepository highQualityDataRepository;
+    private final HighQualityDataMapper highQualityDataMapper;
+    private final HighQualityListDayMapper highQualityListDayMapper;
 
-    public HighQualityDataService(HighQualityDataRepository highQualityDataRepository) {
+    public HighQualityDataService(HighQualityDataRepository highQualityDataRepository, HighQualityDataMapper highQualityDataMapper, HighQualityListDayMapper highQualityListDayMapper) {
         this.highQualityDataRepository = highQualityDataRepository;
+        this.highQualityDataMapper = highQualityDataMapper;
+        this.highQualityListDayMapper = highQualityListDayMapper;
     }
 
     /**
@@ -20,11 +31,24 @@ public class HighQualityDataService {
      */
     public void generateHighQualityData(String day) {
         // 1. 获取数据
-
+        int countByDayId = highQualityDataRepository.countByDayId(day);
+        if (countByDayId != 0) {
+            throw new RuntimeException("已存在数据,需要先清除才能重新计算...");
+        }
+        List<HighQualityData> highQualityData = highQualityListDayMapper.selectHighQualityDataOfDay(day);
+        // 保存到 high_quality_data 表
+        highQualityDataRepository.saveAll(highQualityData);
+        log.debug("HighQualityData {} 账期插入 {} 条数据...", day, highQualityData.size());
         // 2. 从 WorkFlowBasicData 更新地市/区县信息
-
-        // 3. 补充数据
-
+        int countOfCityUpdated = highQualityDataMapper.updateHighQualityDataCityFromWorkFlowBasicData(day);
+        int countOfRegionUpdated = highQualityDataMapper.updateHighQualityDataRegionFromWorkFlowBasicData(day);
+        log.debug("根据 workflow 信息更新地市 {} 条, 更新区县 {} 条...", countOfCityUpdated, countOfRegionUpdated);
+        // 3. 按照HighQualityList 更新地市/区县信息
+        int countOfCityUpdated2 = highQualityDataMapper.updateHighQualityDataCityFromHighQualityListDay(day);
+        int countOfRegionUpdated2 = highQualityDataMapper.updateHighQualityDataRegionFromHighQualityListDay(day);
+        log.debug("根据 HighQualityList 信息更新地市 {} 条, 更新区县 {} 条...", countOfCityUpdated2, countOfRegionUpdated2);
         // 4. 仍无数据的配置默认值
+        int countOfCityUpdated3 = highQualityDataMapper.updateHighQualityDataRegionFromDefault(day);
+        log.debug("根据 默认规则 更新区县 {} 条...", countOfCityUpdated3);
     }
 }

+ 3 - 3
src/main/java/com/nokia/tsl_data/service/CronTaskService.java → src/main/java/com/nokia/tsl_data/service/TaskService.java

@@ -19,7 +19,7 @@ import java.util.List;
  */
 @Slf4j
 @Service
-public class CronTaskService {
+public class TaskService {
 
     private final TslDataDao tslDataDao;
     private final TaskRecordRepository taskRecordRepository;
@@ -28,7 +28,7 @@ public class CronTaskService {
     private final MessageService messageService;
     private final TslReportService tslReportService;
 
-    public CronTaskService(WorkFlowService workFlowService, DataWarehouseService dataWarehouseService, MessageService messageService, TslDataDao tslDataDao, TaskRecordRepository taskRecordRepository, TslReportService tslReportService) {
+    public TaskService(WorkFlowService workFlowService, DataWarehouseService dataWarehouseService, MessageService messageService, TslDataDao tslDataDao, TaskRecordRepository taskRecordRepository, TslReportService tslReportService) {
         this.workFlowService = workFlowService;
         this.dataWarehouseService = dataWarehouseService;
         this.messageService = messageService;
@@ -66,7 +66,7 @@ public class CronTaskService {
      * 从工单系统定时更新数据
      * 调度周期每小时
      */
-    public void updateWorkFlowBasicDataCronTask() {
+    public void updateWorkFlowBasicDataTask() {
         Instant start = taskRecordRepository.findLastSuccessUpdateWorkFlowBasicDataTaskEndInstant();
         Instant end = Instant.now();
         TaskRecord taskRecord = workFlowService.updateWorkFlowBasicData(start, end);

+ 7 - 10
src/main/java/com/nokia/tsl_data/service/TslDataService.java

@@ -1,9 +1,6 @@
 package com.nokia.tsl_data.service;
 
-import com.nokia.tsl_data.dao.MobileComplaintMapper;
-import com.nokia.tsl_data.dao.SysDataDictionaryRepository;
-import com.nokia.tsl_data.dao.TargetTsRatioRepository;
-import com.nokia.tsl_data.dao.TslMapper;
+import com.nokia.tsl_data.dao.*;
 import com.nokia.tsl_data.entity.TargetTsRatio;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -19,9 +16,9 @@ import java.util.Map.Entry;
 @Service
 public class TslDataService {
 
-    private final TslMapper tslMapper;
     private final MobileComplaintMapper mobileComplaintMapper;
     private final SysDataDictionaryRepository sysDataDictionaryRepository;
+    private final HighQualityCountMapper highQualityCountMapper;
     private final HighQualityCountService highQualityCountService;
     private final UserCountService userCountService;
     private final TargetTsRatioRepository targetTsRatioRepository;
@@ -33,10 +30,10 @@ public class TslDataService {
     @Value("${tslTask.compliance.response:0.99}")
     private double responseCompliance;
 
-    public TslDataService(TslMapper tslMapper, MobileComplaintMapper mobileComplaintMapper, SysDataDictionaryRepository sysDataDictionaryRepository, HighQualityCountService highQualityCountService, UserCountService userCountService, TargetTsRatioRepository targetTsRatioRepository) {
-        this.tslMapper = tslMapper;
+    public TslDataService(MobileComplaintMapper mobileComplaintMapper, SysDataDictionaryRepository sysDataDictionaryRepository, HighQualityCountMapper highQualityCountMapper, HighQualityCountService highQualityCountService, UserCountService userCountService, TargetTsRatioRepository targetTsRatioRepository) {
         this.mobileComplaintMapper = mobileComplaintMapper;
         this.sysDataDictionaryRepository = sysDataDictionaryRepository;
+        this.highQualityCountMapper = highQualityCountMapper;
         this.highQualityCountService = highQualityCountService;
         this.userCountService = userCountService;
         this.targetTsRatioRepository = targetTsRatioRepository;
@@ -49,7 +46,7 @@ public class TslDataService {
      */
     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 = tslMapper.selectClientRatioForDay(realDay);
+        List<Map<String, Object>> data = highQualityCountMapper.selectClientRatioForDay(realDay);
         Map<String, Map<String, Object>> dataMap = new HashMap<>();
         for (Map<String, Object> map : data) {
             String key = (String) map.get("businoareaname");
@@ -210,11 +207,11 @@ public class TslDataService {
         // 获取上个月的时间
         calendar.add(Calendar.MONTH, -1);
         String oldMonthId = new SimpleDateFormat("yyyyMM").format(calendar.getTime());
-        List<Map<String, Object>> oldData = tslMapper.selectOldTsDurationForMonth(oldMonthId);
+        List<Map<String, Object>> oldData = mobileComplaintMapper.selectOldTsDurationForMonth(oldMonthId);
         // 如果上月的平均处理时长数据不存在,需要插入
         if (oldData.size() == 0) {
             mobileComplaintMapper.insertOldTsDurationForMonth(oldMonthId);
-            oldData = tslMapper.selectOldTsDurationForMonth(oldMonthId);
+            oldData = mobileComplaintMapper.selectOldTsDurationForMonth(oldMonthId);
         }
         List<Map<String, Object>> dayData = mobileComplaintMapper.selectTsDurationForDay(day);
         // 转化格式方便读取

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

@@ -2,9 +2,9 @@ package com.nokia.tsl_data.service;
 
 import com.nokia.common.io.excel.entity.CellRect;
 import com.nokia.common.io.excel.poi.PoiUtil;
+import com.nokia.tsl_data.dao.HighQualityCountMapper;
 import com.nokia.tsl_data.dao.MobileComplaintMapper;
 import com.nokia.tsl_data.dao.SysDataDictionaryRepository;
-import com.nokia.tsl_data.dao.TslMapper;
 import com.nokia.tsl_data.properties.OutputProperties;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.EncryptedDocumentException;
@@ -40,7 +40,7 @@ public class TslReportService {
 
     private final TslDataService tslDataService;
     private final OutputProperties outputProperties;
-    private final TslMapper tslMapper;
+    private final HighQualityCountMapper highQualityCountMapper;
     private final MobileComplaintMapper mobileComplaintMapper;
     private final SysDataDictionaryRepository sysDataDictionaryRepository;
 
@@ -48,10 +48,10 @@ public class TslReportService {
 
     private static final DateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd");
 
-    public TslReportService(TslDataService tslDataService, OutputProperties outputProperties, TslMapper tslMapper, MobileComplaintMapper mobileComplaintMapper, SysDataDictionaryRepository sysDataDictionaryRepository) {
+    public TslReportService(TslDataService tslDataService, OutputProperties outputProperties, HighQualityCountMapper highQualityCountMapper, MobileComplaintMapper mobileComplaintMapper, SysDataDictionaryRepository sysDataDictionaryRepository) {
         this.tslDataService = tslDataService;
         this.outputProperties = outputProperties;
-        this.tslMapper = tslMapper;
+        this.highQualityCountMapper = highQualityCountMapper;
         this.mobileComplaintMapper = mobileComplaintMapper;
         this.sysDataDictionaryRepository = sysDataDictionaryRepository;
     }
@@ -65,7 +65,7 @@ public class TslReportService {
         if (!file.exists()) {
             throw new RuntimeException(String.format("无法截图,文件%s不存在", file.getAbsolutePath()));
         }
-        try (Workbook workbook = WorkbookFactory.create(file);) {
+        try (Workbook workbook = WorkbookFactory.create(file)) {
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(new SimpleDateFormat("yyyyMMdd").parse(day));
             int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
@@ -121,7 +121,7 @@ public class TslReportService {
             System.out.println(mkdirs);
         }
         String dayId = day.substring(0, 4) + "-" + day.substring(4, 6) + "-" + day.substring(6);
-        int qualityCountForDay = tslMapper.selectQualityCountForDay(dayId);
+        int qualityCountForDay = highQualityCountMapper.selectQualityCountForDay(dayId);
         if (qualityCountForDay == 0) {
             throw new RuntimeException("he_d_high_quality表缺少数据");
         }

+ 13 - 7
src/main/resources/application.yml

@@ -3,10 +3,15 @@ server:
 
 Spring:
   profiles:
-    active: dev
+    active: pro
   jpa:
     hibernate:
       ddl-auto: update
+  datasource:
+    driver-class-name: org.postgresql.Driver
+    url: jdbc:postgresql://192.168.10.9:5432/sqmmt
+    username: postgres
+    password: Richr00t#
 
 mybatis:
   mapper-locations: classpath:mapper/**.xml
@@ -23,15 +28,16 @@ logging:
     com:
       nokia: DEBUG
 
+---
+spring:
+  profiles: pro
+
 ---
 spring:
   profiles: dev
-  datasource:
-    driver-class-name: org.postgresql.Driver
-    url: jdbc:postgresql://192.168.10.9:5432/sqmmt
-    username: postgres
-    password: Richr00t#
 
 tsl:
   source:
-    dirOfHighQualityListDay: D:/src/high_quality_list_day/
+    dirOfHighQualityListDay: D:/src/20231028
+    dirOfHighQualityCountDay: D:/src/20231028
+    dirOfMobileComplaint: D:/src/20231028

+ 1 - 1
src/main/resources/logback-spring.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <property name="PATH" value="./log"/>
-    <property name="APP_NAME" value="tal-data" />
+    <property name="APP_NAME" value="tsl-data" />
     <!-- 用于在console输出日志 -->
     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
         <encoder>

+ 0 - 18
src/main/resources/mapper/HighQualityCountMapper.xml

@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.nokia.tsl_data.dao.HighQualityCountMapper">
-
-    <!-- 从客户端统计表获取某日的总投诉量(办结量) -->
-    <select id="selectTotalComplaintsForDay" resultType="map">select businoareaname,
-        total_complaints from report_auto.he_d_high_quality hdhq where month_id = substring(#{day}
-        from 1 for 6) and day_id = substring(#{day} from 7 for 2) and profes_dep = '网络质量' and
-        big_type_name = '移网网络体验' and small_type_name = '--'</select>
-
-    <!-- 从客户端统计表获取某日的总投诉量(办结量) 入参 monthId dayId -->
-    <select id="selectTotalComplaintsForMonthIdAndDay" resultType="map">select businoareaname,
-        total_complaints from report_auto.he_d_high_quality hdhq where month_id = #{monthId} and
-        day_id = #{day} and profes_dep = '网络质量' and big_type_name = '移网网络体验' and small_type_name =
-        '--'</select>
-
-</mapper>

+ 1 - 1
src/main/resources/mapper/HighQualityListDayMapper.xml

@@ -9,7 +9,7 @@
         <result property="cpSatisfaction" column="cp_satisfaction" />
         <result property="cpIsOk" column="cp_is_ok" />
         <result property="cpTimelyContact" column="cp_timely_contact" />
-        <result property="noVisitTag" column="cp_timely_contact" />
+        <result property="noVisitTag" column="novisit_tag" />
         <result property="areaId" column="area_id" />
         <result property="areaName" column="area_name" />
         <result property="cityId" column="city_id" />

+ 0 - 181
src/main/resources/mapper/MobileComplaintMapper.xml

@@ -1,181 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.nokia.tsl_data.dao.MobileComplaintMapper">
-
-    <select id="selectCompCountForDay" resultType="int"> select count(1)
-                                                         from report_auto.he_d_mobile_comp_new
-                                                         where month_id = substring(#{day} from 1 for 6)
-                                                           and day_id
-                                                             = substring(#{day} from 7 for 2) </select>
-
-    <!-- 从现有数据获取上月处理时长(按上月最后一天处理)并插入数据表 -->
-    <insert id="insertOldTsDurationForMonth">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_new hdmc
-                                                         where month_id = #{month_id}
-                                                           and day_id::float8 =
-                                                               extract('day' from
-                                                                       to_timestamp(#{month_id}, 'YYYYMM') + interval '1 month' -
-                                                                       interval '1
-        day'))
-                                             insert
-                                             into report_auto.avg_duration (month_id, city_name, avg_duration)
-                                             select #{month_id}      as month_id,
-                                                    compl_area_local as city_name,
-                                                    avg(duration)    as avg_duration
-                                             from t1
-                                             group by compl_area_local </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_new hdmc
-                                                                      where month_id = substring(#{day} from 1 for 6)
-                                                                        and day_id = substring(#{day} 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_new hdmc
-                                                                         where month_id = substring(#{day} from
-                                                                                                    1 for 6)
-                                                                           and day_id = substring(#{day} from 7 for 2)),
-                                                                  t2 as (select '全省'     as
-                                                                                            compl_area_local,
-                                                                                count(1) as total_num
-                                                                         from t1),
-                                                                  t3 as (select compl_area_local,
-                                                                                count(1)
-                                                                                    as total_num
-                                                                         from t1
-                                                                         group by compl_area_local),
-                                                                  t4 as (select *
-                                                                         from t2
-                                                                         union
-                                                                         select *
-                                                                         from t3),
-                                                                  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::float8 as timeout_ratio
-                                                             from t4,
-                                                                  t9
-                                                             where t4.compl_area_local =
-                                                                   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_new hdmc
-                                                                         where month_id = substring(#{day} from 1
-                                                                                                    for 6)
-                                                                           and day_id = substring(#{day} from 7 for 2)),
-                                                                  t2 as (select distinct * from t1),
-                                                                  t3
-                                                                      as (select compl_area_local, count(1) as total_num
-                                                                          from t1
-                                                                          group by compl_area_local),
-                                                                  t4 as
-                                                                      (select compl_area_local, count(1) as distinct_num
-                                                                       from t2
-                                                                       group by compl_area_local),
-                                                                  t5 as
-                                                                      (select t3.compl_area_local,
-                                                                              t3.total_num,
-                                                                              t3.total_num - t4.distinct_num::float8                  as
-                                                                                                                                         repeat_num,
-                                                                              (t3.total_num - t4.distinct_num) / t3.total_num::float8 as repeat_ratio
-                                                                       from T3,
-                                                                            t4
-                                                                       where t3.compl_area_local = t4.compl_area_local)
-                                                             select '全省'                         as compl_area_local,
-                                                                    sum(total_num)               as total_num,
-                                                                    sum(repeat_num)              as repeat_num,
-                                                                    sum(repeat_num)
-                                                                        / sum(total_num)::float8 as repeat_ratio
-                                                             from t5
-                                                             union
-                                                             select *
-                                                             from t5 </select>
-
-    <select id="selectCityTslForMonth" resultType="Map"> select compl_area_local,
-                                                                substring(acct_date from 7 for 2) as day_id,
-                                                                count(1)                          as num
-                                                         from report_auto.he_d_mobile_comp_new hdmc
-                                                         where month_id = substring(#{day} from 1 for 6)
-                                                           and day_id = substring(#{day} from 7 for 2)
-                                                         group by compl_area_local,
-                                                                  substring(acct_date from
-                                                                            7 for 2)
-                                                         order by compl_area_local, substring(acct_date from 7 for 2) </select>
-
-    <select id="selectAllTslForMonth" resultType="Map"> select substring(acct_date from 7 for 2) as
-                                                                                                    day_id,
-                                                               count(1)                          as num
-                                                        from report_auto.he_d_mobile_comp_new hdmc
-                                                        where month_id =
-                                                              substring(#{day} from 1 for 6)
-                                                          and day_id = substring(#{day} from 7 for 2)
-                                                        group by substring(acct_date from 7 for 2)
-                                                        order by substring(acct_date from 7 for 2) </select>
-
-    <select id="selectCityAllForMonth" resultType="Map">select compl_area_local, count(1) as num
-                                                        from report_auto.he_d_mobile_comp_new hdmc
-                                                        where month_id = substring(#{day} from 1 for 6)
-                                                          and day_id = substring(#{day} from 7 for 2)
-                                                        group by compl_area_local
-                                                        order by compl_area_local </select>
-
-    <select id="selectAllForMonth" resultType="int">select count(1) as num
-                                                    from report_auto.he_d_mobile_comp_new hdmc
-                                                    where month_id = substring(#{day} from 1 for 6)
-                                                      and day_id = substring(#{day} from 7 for 2)</select>
-
-    <delete id="deleteMobileCompForDay" parameterType="string">delete
-                                                               from report_auto.he_d_mobile_comp_new hdmc
-                                                               where month_id = substring(#{day} from 1 for 6)
-                                                                 and day_id = substring(#{day} from 7 for 2)</delete>
-</mapper>

+ 0 - 266
src/main/resources/mapper/TslMapper.xml

@@ -1,266 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.nokia.tsl_data.dao.TslMapper">
-
-    <!-- V1.5废弃 -->
-    <select id="selectCompCountForDay" resultType="int"> select count(1)
-                                                         from report_auto.he_d_mobile_comp
-                                                         where acct_date = #{day} </select>
-
-    <select id="selectQualityCountForDay" resultType="int"> select count(1)
-                                                            from report_auto.he_d_high_quality
-                                                            where acct_date = #{day} </select>
-
-    <!-- 满意率 -->
-    <select id="selectClientRatioForDay" resultType="Map">with t1 as (select businoareaname,
-                                                                             complaint_satisfied_list::float8,
-                                                                             complaint_satisfied_count::float8,
-                                                                             complaint_resolution_list::float8,
-                                                                             complaint_resolution_count::float8,
-                                                                             complaint_response_list::float8,
-                                                                             complaint_response_count::float8,
-                                                                             complaint::float8
-                                                                      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 + complaint) as
-                                                                                                               complaint_satisfied,
-                                                                 sum(complaint_resolution_list) /
-                                                                 sum(complaint_resolution_count +
-                                                                     complaint)                             as complaint_resolution,
-                                                                 sum(complaint_response_list) /
-                                                                 sum(complaint_response_count + complaint)  as complaint_response
-                                                          from t1
-                                                          union
-                                                          select businoareaname,
-                                                                 case
-                                                                     when (complaint_satisfied_count + complaint) = 0
-                                                                         then 0
-                                                                     else
-                                                                         complaint_satisfied_list / (complaint_satisfied_count + complaint) end   as
-                                                                                                                                                     complaint_satisfied,
-                                                                 case
-                                                                     when (complaint_resolution_count + complaint) = 0
-                                                                         then 0
-                                                                     else
-                                                                         complaint_resolution_list / (complaint_resolution_count + complaint) end as
-                                                                                                                                                     complaint_resolution,
-                                                                 case
-                                                                     when (complaint_response_count + complaint) = 0
-                                                                         then 0
-                                                                     else
-                                                                         complaint_response_list / (complaint_response_count + complaint) end     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>
-
-    <!-- V1.5废弃 -->
-    <!-- 从现有数据获取上月处理时长并插入数据表 -->
-    <insert id="insertOldTsDurationForMonth">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 = #{month_id}
-                                                           and day_id::float8 &lt;=
-                                                               extract('day' from
-                                                                       to_timestamp(#{month_id}, 'YYYYMM') + interval '1 month' -
-                                                                       interval '1
-        day'))
-                                             insert
-                                             into report_auto.avg_duration (month_id, city_name, avg_duration)
-                                             select #{month_id}      as month_id,
-                                                    compl_area_local as city_name,
-                                                    avg(duration)    as avg_duration
-                                             from t1
-                                             group by compl_area_local </insert>
-
-    <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>
-
-    <!-- V1.5废弃 -->
-    <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(#{day} from 1 for 6)
-                                                                        and day_id
-                                                                          &lt;= substring(#{day} from 7 for 2))
-                                                          select compl_area_local, avg(duration) as avg_duration
-                                                          from t1
-                                                          group by compl_area_local </select>
-
-    <!-- V1.5废弃 -->
-    <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
-                                                                                            compl_area_local,
-                                                                                count(1) as total_num
-                                                                         from t1),
-                                                                  t3 as (select compl_area_local,
-                                                                                count(1)
-                                                                                    as total_num
-                                                                         from t1
-                                                                         group by compl_area_local),
-                                                                  t4 as (select *
-                                                                         from t2
-                                                                         union
-                                                                         select *
-                                                                         from t3),
-                                                                  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::float8 as timeout_ratio
-                                                             from t4,
-                                                                  t9
-                                                             where t4.compl_area_local =
-                                                                   t9.compl_area_local</select>
-
-    <!-- V1.5废弃 -->
-    <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 = substring(#{day} from 1 for
-                                                                                                    6)
-                                                                           and day_id &lt;= substring(#{day} from 7 for 2)),
-                                                                  t2 as (select distinct * from t1),
-                                                                  t3
-                                                                      as (select compl_area_local, count(1) as total_num
-                                                                          from t1
-                                                                          group by compl_area_local),
-                                                                  t4 as
-                                                                      (select compl_area_local, count(1) as distinct_num
-                                                                       from t2
-                                                                       group by compl_area_local),
-                                                                  t5 as
-                                                                      (select t3.compl_area_local,
-                                                                              t3.total_num,
-                                                                              t3.total_num - t4.distinct_num::float8                  as
-                                                                                                                                         repeat_num,
-                                                                              (t3.total_num - t4.distinct_num) / t3.total_num::float8 as repeat_ratio
-                                                                       from T3,
-                                                                            t4
-                                                                       where t3.compl_area_local = t4.compl_area_local)
-                                                             select '全省'                         as compl_area_local,
-                                                                    sum(total_num)               as total_num,
-                                                                    sum(repeat_num)              as repeat_num,
-                                                                    sum(repeat_num)
-                                                                        / sum(total_num)::float8 as repeat_ratio
-                                                             from t5
-                                                             union
-                                                             select *
-                                                             from t5 </select>
-
-    <!-- V1.5废弃 -->
-    <select id="selectCityTslForMonth" resultType="Map"> select compl_area_local,
-                                                                day_id,
-                                                                count(1)
-                                                                    as num
-                                                         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)
-                                                         group by compl_area_local, day_id
-                                                         order by compl_area_local, day_id </select>
-
-    <!-- V1.5废弃 -->
-    <select id="selectAllTslForMonth" resultType="Map"> select day_id, count(1) as num
-                                                        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)
-                                                        group by day_id
-                                                        order by day_id </select>
-
-    <!-- V1.5废弃 -->
-    <select id="selectCityAllForMonth" resultType="Map">select compl_area_local, count(1) as num
-                                                        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)
-                                                        group by compl_area_local
-                                                        order by compl_area_local </select>
-
-    <!-- V1.5废弃 -->
-    <select id="selectAllForMonth" resultType="int">select count(1) as num
-                                                    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)</select>
-
-    <select id="selectUserCountForMonth" resultType="Map">select city_name, user_count
-                                                          from report_auto.user_count
-                                                          where month_id = #{monthId}</select>
-
-    <select id="selectTargetTsRatioForMonth" resultType="Map">select city_name, target_ts_ratio
-                                                              from report_auto.target_ts_ratio
-                                                              where month_id = #{monthId}</select>
-
-    <insert id="insertUserCount" parameterType="map"> INSERT INTO report_auto.user_count (month_id,
-                                                                                          city_name, user_count)
-                                                      VALUES (#{map.monthId}, #{map.cityName}, #{map.userCount})</insert>
-
-    <insert id="insertTargetTsRatio" parameterType="map">INSERT INTO report_auto.target_ts_ratio
-                                                             (month_id, city_name, target_ts_ratio)
-                                                         VALUES (#{map.monthId}, #{map.cityName},
-                                                                 #{map.targetTsRatio}); </insert>
-
-    <delete id="deleteHighQualityForDay" parameterType="string">delete
-                                                                from report_auto.he_d_high_quality hdhq
-                                                                where acct_date = #{day}</delete>
-
-    <!-- V1.5废弃 -->
-    <delete id="deleteMobileCompForDay" parameterType="string">delete
-                                                               from report_auto.he_d_mobile_comp hdmc
-                                                               where acct_date = #{day}</delete>
-
-</mapper>

+ 38 - 3
src/test/java/com/nokia/tsl_data/MainTest.java

@@ -1,10 +1,12 @@
 package com.nokia.tsl_data;
 
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVParser;
 import org.apache.commons.csv.CSVPrinter;
 import org.apache.commons.csv.CSVRecord;
 import org.junit.jupiter.api.Test;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
 
 import java.io.*;
 import java.text.DateFormat;
@@ -14,7 +16,10 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
 
+@Slf4j
 public class MainTest {
 
     @Test
@@ -30,9 +35,7 @@ public class MainTest {
 
         CSVParser parse1 = csvFormat.parse(new InputStreamReader(new FileInputStream(path1), "gbk"));
         CSVParser parse2 = csvFormat.parse(new InputStreamReader(new FileInputStream(path2), "gbk"));
-        parse2.getHeaderMap().forEach((k, v) -> {
-            System.out.println(k + "===" + v);
-        });
+        parse2.getHeaderMap().forEach((k, v) -> System.out.println(k + "===" + v));
 
         // 存储2表对应关系
         Map<String, CSVRecord> map2 = new HashMap<>();
@@ -70,4 +73,36 @@ public class MainTest {
             }
         });
     }
+
+    @Test
+    void test1() throws ExecutionException, InterruptedException {
+        // 线程池
+        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
+        taskScheduler.setPoolSize(3);
+        taskScheduler.setThreadNamePrefix("taskSchedulerThreadPool-");
+        taskScheduler.initialize();
+        // 数据入库1
+        CompletableFuture<Void> task1 = CompletableFuture.runAsync(() -> {
+            log.info("数据入库1===");
+            throw new RuntimeException("数据入库1出错");
+        }, taskScheduler).exceptionally(e -> {
+            throw new RuntimeException("数据入库1出错===");
+        });
+        // 数据入库2
+        CompletableFuture<Void> task2 = CompletableFuture.runAsync(() -> {
+            log.info("数据入库2===");
+            throw new RuntimeException("数据入库2出错");
+        }, taskScheduler);
+        // 数据入库3
+        CompletableFuture<Void> task3 = CompletableFuture.runAsync(() -> {
+            log.info("数据入库3===");
+            throw new RuntimeException("数据入库3出错");
+        }, taskScheduler);
+        CompletableFuture.allOf(task1, task2, task3).thenRunAsync(() -> log.info("入库完成......")).exceptionally(e -> {
+            e.printStackTrace();
+            log.info("exceptionally......");
+            return null;
+        }).get();
+        log.info("done!");
+    }
 }

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

@@ -1,7 +1,7 @@
 package com.nokia.tsl_data;
 
-import com.nokia.tsl_data.dao.HighQualityListDayMapper;
-import com.nokia.tsl_data.entity.HighQualityData;
+import com.nokia.tsl_data.dao.HighQualityDataMapper;
+import com.nokia.tsl_data.service.DataWarehouseService;
 import com.nokia.tsl_data.service.UserCountService;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,6 +12,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.List;
+import java.util.Map;
 
 @SpringBootTest
 class TslDataApplicationTest {
@@ -48,13 +49,19 @@ class TslDataApplicationTest {
     }
 
     @Autowired
-    private HighQualityListDayMapper highQualityListDayMapper;
+    private HighQualityDataMapper highQualityDataMapper;
 
     @Test
     void test() {
-        List<HighQualityData> highQualityDataOfDay = highQualityListDayMapper.findHighQualityDataOfDay("20231014");
-        for (HighQualityData highQualityData : highQualityDataOfDay) {
-            System.out.println(highQualityData);
-        }
+        List<Map<String, Object>> maps = highQualityDataMapper.selectRegionTimelyContactRate("20231014");
+        maps.forEach(System.out::println);
+    }
+
+    @Autowired
+    private DataWarehouseService dataWarehouseService;
+
+    @Test
+    void test3() {
+        dataWarehouseService.warehouseHighQualityCountDay("20231101");
     }
 }