# 任务特点分析 ## 自动报表 定时任务特点分析 1. 每天运行1次 2. 以月为边界,每天执行的任务要求前一天的数据必须完整,中间不能间隔 3. 数据源不是特别稳定 因为第2、3点特点,需要: 1. 运行时先检查前一天的数据入库是否完整,如果完整 2. 运行时需要检查当天数据是否完备,如果不完备进入循环等待,每个一个时间间隔进行一次检查,每次检查如果缺少数据都需要发送一次提醒。 先搞定第2步,第1个问题暂时未遇到 ```java /** * 模拟检查等待 * * @throws Exception */ @Test void test() throws Exception { String filePath = "D:/src/投诉清单各地市投诉率20230503.xlsx"; File file = new File(filePath); while (!file.exists()) { // 发送提醒 System.out.println("检查发现:文件" + filePath + "不存在"); // 等待5秒后再次检查 Thread.sleep(1000 * 5); } // 完成任务 System.out.println("done!"); } ``` ## 一些sql - 查询 high_quality_count_day 帐期数据 ```sql select acct_date, count(1) from tsl_data.high_quality_count_day group by acct_date order by acct_date; ``` - management_detail ```sql select stat_day_id, count(1) from tsl_data.management_detail md group by stat_day_id ``` ## 接口测试记录 ```http ### 任务调度==查询全部 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/list/all Content-Type: application/json ### 任务调度==查询正在调度的任务 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/list/scheduled Content-Type: application/json ### 任务调度-每天定时出报表 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 211648899235057664 }, "status": "ON", "scheduledType": "CRON", "scheduledParameter": { "cronExpression": "0 45 13 * * *" }, "description": "每天定时出报表" } ### 任务调度-每天定时清理临时表 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 211598274090635264 }, "status": "ON", "scheduledType": "CRON", "scheduledParameter": { "cronExpression": "0 15 14 * * *" }, "description": "每天定时清理临时表" } ### 任务调度-每小时从工单系统更新数据 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 211598274090635264 }, "status": "ON", "scheduledType": "CRON", "scheduledParameter": { "cronExpression": "0 5 * * * *" }, "description": "每小时从工单系统更新数据" } ### 任务注册-查询列表 POST http://127.0.0.1:22222/common/scheduling/task/registered/list/all Content-Type: application/json ### 任务注册-清理临时表 POST http://127.0.0.1:22222/common/scheduling/task/registered/add Content-Type: application/json { "beanName": "taskService", "methodName": "tempTableCleanCronTask", "withParameter": false, "description": "清理临时表" } ### 任务注册-从工单系统更新数据 POST http://127.0.0.1:22222/common/scheduling/task/registered/add Content-Type: application/json { "beanName": "taskService", "methodName": "updateWorkFlowBasicDataTask", "withParameter": false, "description": "从工单系统更新数据" } ### 任务注册- 入库-生成报表-截图 单次任务 POST http://127.0.0.1:22222/common/scheduling/task/registered/add Content-Type: application/json { "beanName": "taskService", "methodName": "wareHouseTask", "withParameter": true, "description": "入库-生成报表-截图" } ### 任务注册- 入库-生成报表-截图 定时任务 POST http://127.0.0.1:22222/common/scheduling/task/registered/add Content-Type: application/json { "beanName": "taskService", "methodName": "dailyWarehouseTask", "withParameter": false, "description": "入库-生成报表-截图 定时任务" } ``` ```http ### 任务注册-查询列表 POST http://127.0.0.1:9999/common/scheduling/task/registered/list/all Content-Type: application/json ### 任务注册-新增 POST http://127.0.0.1:9999/common/scheduling/task/registered/add Content-Type: application/json { "beanName": "demoService", "methodName": "test1", "withParameter": false, "description": "测试用..." } ### 任务注册-删除 POST http://127.0.0.1:22222/common/scheduling/task/registered/delete Content-Type: application/json 211340469899235328 ``` ```http ### 任务调度==查询全部 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/list/all Content-Type: application/json ### 任务调度==查询正在调度的任务 POST http://127.0.0.1:9999/common/scheduling/task/scheduled/list/scheduled Content-Type: application/json ### 任务调度==删除 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/delete Content-Type: application/json 211537692419297280 ### 任务调度==更新 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/update Content-Type: application/json { "id": 211596024697982976, "registeredTask": { "id": 211593346244808704 }, "status": "ON", "description": "abc" } ### 任务调度==新增 1. 新增马上调度 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 211528578876182528 }, "status": "ON", "scheduledType": "IMMEDIATELY", "description": "测试用..." } ### 2. 新增单次调度 POST http://127.0.0.1:9999/demo/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 2 }, "status": "ON", "scheduledType": "ONCE", "methodParameter": "abc", "scheduledParameter": { "startTime": "2023-11-27 17:04:00" } } ### 2. 新增单次调度2 POST http://127.0.0.1:9999/common/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 213707591296094208 }, "status": "ON", "scheduledType": "ONCE", "methodParameter": "abc", "scheduledParameter": { "delayOfSeconds": 5 } } ### 3. 新增定时调度 POST http://127.0.0.1:22222/common/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 211593346244808704 }, "status": "ON", "scheduledType": "CRON", "scheduledParameter": { "cronExpression": "0 15 14 * * *" } } ### 4. 新增周期调度 POST http://127.0.0.1:9999/demo/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 1 }, "status": "ON", "scheduledType": "INTERVAL", "scheduledParameter": { "periodOfSeconds": 15 } } ### 5. 新增固定延时调度 POST http://127.0.0.1:9999/common/scheduling/task/scheduled/add Content-Type: application/json { "registeredTask": { "id": 213707591296094208 }, "status": "ON", "scheduledType": "FIXED_DELAY", "scheduledParameter": { "delayOfSeconds": 15 } } ```