소스 검색

20230613 dingtalk_autov1.2

lifuquan 1 년 전
부모
커밋
418bbbf63c

+ 7 - 1
README.md

@@ -2,7 +2,13 @@
 
 nohup java -jar tsl_data-1.5-exec.jar >output.log 2>&1 &
 
-nohup java -jar dingtalk_auto-1.1-exec.jar >output.log 2>&1 &
+nohup java -jar dingtalk_auto-1.2-exec.jar >output.log 2>&1 &
+
+## dingtalk_auto版本说明
+
+### v1.2
+
+1. 修改了每天总结的内容,当万投比全部达标的情况与存在不达标情况时进行区别
 
 ## tsl_data版本说明
 

+ 22 - 28
dingtalk_auto/src/main/java/com/nokia/dingtalk_auto/service/TslTaskService.java

@@ -2,11 +2,9 @@ package com.nokia.dingtalk_auto.service;
 
 import java.io.File;
 import java.io.IOException;
-import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
-import java.util.Date;
 import java.util.List;
 import javax.annotation.Resource;
 
@@ -71,75 +69,64 @@ public class TslTaskService {
         // 5. 发送提醒
         remindDingTalkUtil.sendMarkdownMsgWithRobot(message);
         // 3. 发送文件
-        sendDingTalkMsg(day);
+        // sendDingTalkMsg(day);
         // 4. 发送消息
-        tslTaskDingTalkUtil.sendMarkdownMsgWithRobot(message);
+        // tslTaskDingTalkUtil.sendMarkdownMsgWithRobot(message);
         remindDingTalkUtil.sendTextMsgWithRobot("发送成功==" + day);
     }
 
     public void sendDingTalkMsg(String day) throws DingTalkApiException {
-        DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
         String localPath = localDir + "/" + day;
         File[] files = new File(localPath).listFiles();
-        StringBuffer stringBuffer = new StringBuffer();
         // 分开发送,保证发送文件的顺序
         for (File file : files) {
             if (file.getName().toLowerCase().endsWith("-1-投诉率.png")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "image");
                 tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
         for (File file : files) {
             if (file.getName().toLowerCase().endsWith("-2-重复投诉率.png")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "image");
                 tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
         for (File file : files) {
             if (file.getName().toLowerCase().endsWith("-3-超时工单.png")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "image");
                 tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
         for (File file : files) {
             if (file.getName().toLowerCase().endsWith("-4-处理时长.png")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "image");
                 tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
         for (File file : files) {
             if (file.getName().toLowerCase().endsWith("-5-满意率.png")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "image");
                 tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
         for (File file : files) {
             if (file.getName().toLowerCase().endsWith("-6-解决率.png")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "image");
                 tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
         for (File file : files) {
             if (file.getName().toLowerCase().endsWith("-7-响应率.png")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "image");
                 tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
         for (File file : files) {
             if (file.getName().toLowerCase().equals("投诉清单各地市投诉率" + day + ".xlsx")) {
                 String mediaId = tslTaskDingTalkUtil.upload(file.getAbsolutePath(), "file");
                 tslTaskDingTalkUtil.sendFileMsgWithRobot(mediaId, file.getName());
-                stringBuffer.append(dateFormat.format(new Date())).append(file.getName()).append("发送成功==");
             }
         }
-        remindDingTalkUtil.sendTextMsgWithRobot(stringBuffer.toString());
     }
 
     /**
@@ -160,7 +147,7 @@ public class TslTaskService {
                 .append(calendar.get(Calendar.MONTH) + 1)
                 .append("月截至")
                 .append(dayOfMonth)
-                .append("日移动网投诉情况统计:\n\n管理端-移网质量类:投诉率:<font color=#FF0000>");
+                .append("日移动网投诉情况统计:\n\n管理端-移网质量类:");
         File file = new File(localFile);
         if (!file.exists()) {
             throw new Exception(String.format("文件--%s--不存在", localFile));
@@ -169,30 +156,37 @@ public class TslTaskService {
             Sheet sheet = workbook.getSheet("管理端-移网质量类");
             Row row;
             List<List<Object>> list = new ArrayList<>();
+            List<List<Object>> list0 = new ArrayList<>();
             for (int i = 2; i < 14; i++) {
                 row = sheet.getRow(i);
                 double value = row.getCell(dayOfMonth + 6).getNumericCellValue();
+                List<Object> list2 = new ArrayList<>();
+                list2.add(0, value);
+                list2.add(1, row.getCell(dayOfMonth + 7).getStringCellValue());
                 if (value > 0.0) {
-                    List<Object> list2 = new ArrayList<>();
                     list.add(list2);
-                    list2.add(0, value);
-                    list2.add(1, row.getCell(dayOfMonth + 7).getStringCellValue());
                 }
+                list0.add(list2);
             }
             // 排序
             list.sort((o1, o2) -> Double.compare((double) o2.get(0), (double) o1.get(0)));
-            StringBuffer stringBuffer2 = new StringBuffer();
-            for (int i = 0; i < list.size(); i++) {
-                stringBuffer.append(list.get(i).get(1).toString()).append("、");
-                if (i < 3) {
-                    stringBuffer2.append(list.get(i).get(1).toString()).append("、");
+            list0.sort((o1, o2) -> Double.compare((double) o2.get(0), (double) o1.get(0)));
+            if (list.size() == 0) {
+                stringBuffer.append("投诉率:12个地市均已达标,<font color=#FF0000>");
+            } else {
+                stringBuffer.append("投诉率:<font color=#FF0000>");
+                for (int i = 0; i < list.size(); i++) {
+                    stringBuffer.append(list.get(i).get(1).toString()).append("、");
                 }
+                stringBuffer.deleteCharAt(stringBuffer.length() - 1);
+                stringBuffer.append("</font>未达到目标值,<font color=#FF0000>");
+            }
+            StringBuffer stringBuffer2 = new StringBuffer();
+            for (int i = 0; i < 3; i++) {
+                stringBuffer2.append(list0.get(i).get(1).toString()).append("、");
             }
-            stringBuffer.deleteCharAt(stringBuffer.length() - 1);
             stringBuffer2.deleteCharAt(stringBuffer2.length() - 1);
-            stringBuffer.append("</font>未达到目标值,<font color=#FF0000>")
-                    .append(stringBuffer2.toString())
-                    .append("</font>排名靠后");
+            stringBuffer.append(stringBuffer2.toString()).append("</font>排名靠后");
 
             // 1号忽略重复投诉率
             if (day.endsWith("01")) {

+ 4 - 6
dingtalk_auto/src/test/java/com/nokia/dingtalk_auto/DingTalkAutoTest.java

@@ -4,19 +4,17 @@ import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import com.nokia.common.dingtalk.DingTalkUtil;
-import com.nokia.common.dingtalk.exception.DingTalkApiException;
+import com.nokia.dingtalk_auto.service.TslTaskService;
 
 @SpringBootTest
 public class DingTalkAutoTest {
 
     @Autowired
-    private DingTalkUtil tslTaskDingTalkUtil;
+    private TslTaskService taskService;
 
     @Test
-    void test() throws DingTalkApiException {
-        String mediaId = tslTaskDingTalkUtil.upload("D:/src/20230505-7-响应率.png", "image");
-        tslTaskDingTalkUtil.sendImageMsgWithRobot(mediaId);
+    void test() throws Exception {
+        taskService.runTask("20230611");
     }
 
 }

+ 4 - 4
doc/开发文档/部署环境/手动入库数据.md

@@ -6,7 +6,7 @@
 POST http://192.168.31.10:11111/tsl/task/send HTTP/1.1
 Content-Type:application/json
 
-20230531
+20230612
 ```
 
 > 注意:文件缺失时不需要手动入库和生成报表,当前已经加入了等待,检查的机制。发送的逻辑后续需要修改一下。
@@ -17,7 +17,7 @@ Content-Type:application/json
 POST http://192.168.10.7:29100/tsl/task/report/generate HTTP/1.1
 Content-Type:application/json
 
-20230531
+20230612
 ```
 
 ## 数据手动入库
@@ -28,7 +28,7 @@ Content-Type:application/json
 POST http://192.168.10.7:29100/tsl/task/warahouse HTTP/1.1
 Content-Type:application/json
 
-20230531
+20230612
 ```
 
 - report_auto.he_d_mobile_comp
@@ -37,7 +37,7 @@ Content-Type:application/json
 POST http://192.168.10.7:29100/tsl/task/warahouse/mobilecomp HTTP/1.1
 Content-Type:application/json
 
-20230521
+20230612
 ```
 
 - report_auto.he_d_high_quality

BIN
doc/高品质2.0日明细接口规范(1).docx


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

@@ -66,7 +66,7 @@ public class TslTaskService {
             // 检查数据源
             checkSrcExsit(day);
             // 数据入库 v1.5修改修改了入库的表
-            // tslWaraHouseService.dataWaraHouseTask(day);
+            tslWaraHouseService.dataWaraHouseTask(day);
             // 生成xlsx
             reportGenerateTask(day);
             // 截图

+ 4 - 2
tsl_data/src/main/resources/application-dev.properties

@@ -7,8 +7,10 @@
 # 10.9上PG数据库
 spring.datasource.driver-class-name=org.postgresql.Driver
 spring.datasource.url=jdbc:postgresql://192.168.10.9:5432/sqmmt
-spring.datasource.username=report_auto
-spring.datasource.password=Richr00t!
+# spring.datasource.username=report_auto
+spring.datasource.username=postgres
+# spring.datasource.password=Richr00t!
+spring.datasource.password=Richr00t#
 
 # 生成文件的输出路径,末尾带/
 tslTask.outputPath=D:/src/

+ 4 - 2
tsl_data/src/main/resources/application-pro.properties

@@ -1,8 +1,10 @@
 # 10.9上PG数据库
 spring.datasource.driver-class-name=org.postgresql.Driver
 spring.datasource.url=jdbc:postgresql://192.168.10.9:5432/sqmmt
-spring.datasource.username=report_auto
-spring.datasource.password=Richr00t!
+# spring.datasource.username=report_auto
+spring.datasource.username=postgres
+# spring.datasource.password=Richr00t!
+spring.datasource.password=Richr00t#
 
 tslTask.source.MOBILE_COMP_SQL=insert into report_auto.he_d_mobile_comp_new (month_id,day_id,acct_date,sheet_no,is_online_complete,contact_no,busi_no,serv_content,last_deal_content,deal_depart_name,deal_opinion,serv_type,bus_type,duty_reason,accept_channel,submit_channel,compl_area_local,duty_major,product_name,sp_product_code,pre_repair_name,pre_repair_charges,fault_location,cust_level,satisfaction_in_reply,is_ok_in_reply,accept_time,end_time,proce_time,cust_area,is_cust_serv_complete,is_send_sheet_complete,is_repeat,is_upgrade,is_timeout,gis_city,process_nums,deal_depart_name_1,deal_depart_name_2,deal_depart_name_3,first_call_back_time,proce_remark,duty_major_day,duty_reason_id_day,duty_major_month,duty_reason_id_month,voice_text) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
 # 路径的配置最后一定要带上/

+ 1 - 1
tsl_data/src/main/resources/application.properties

@@ -14,6 +14,6 @@ tslTask.compliance.response=0.99
 tslTask.outputPath=/data/report_auto/output/
 
 # 定时任务
-tslTask.isStarted=false
+tslTask.isStarted=true
 # 定时任务表达式每天应只执行1次,默认每天14点10分执行
 tslTask.cronExpression=0 45 13 * * *

+ 18 - 0
tsl_data/src/test/java/com/nokia/tsl_data/TslDataApplicationTest.java

@@ -1,8 +1,26 @@
 package com.nokia.tsl_data;
 
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
+import com.nokia.tsl_data.dao.TslDao;
+import com.nokia.tsl_data.service.TslTaskService;
+
 @SpringBootTest
 public class TslDataApplicationTest {
 
+    @Autowired
+    private TslTaskService tslTaskService;
+
+    @Autowired
+    private TslDao tslDao;
+
+    @Test
+    void test() {
+        String day = "20230601";
+        String dayId = day.substring(0, 4) + "-" + day.substring(4, 6) + "-" + day.substring(6);
+        int selectQualityCountForDay = tslDao.selectQualityCountForDay(dayId);
+        System.out.println(selectQualityCountForDay);
+    }
 }