浏览代码

修改获取企业微信转译文件的时间

seyason 1 年之前
父节点
当前提交
0c7cfcdb91

+ 13 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -81,14 +82,22 @@ public class ExcelExportServiceImpl implements ExcelExportService {
              * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
              * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
              */
-            while (i < 10) {
-                Thread.sleep(300);
+            long t = System.currentTimeMillis();
+            while (i < 30) {
+                if (i < 10) {
+                    Thread.sleep(300);
+                } else {
+                    Thread.sleep(1000);
+                }
+                System.out.println("i=="+i+", "+LocalDateTime.now());
                 CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
                 if (corpwxJobResult != null) {
                     if (corpwxJobResult.getErrCode() == 0) {
                         syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
                         corpwxJobCenter.remove(jobId);
                     } else {
+                        long t2 = System.currentTimeMillis();
+                        System.out.println("222企业微信转译报错:"+corpwxJobResult.getErrMsg()+",耗时:" + (t2 - t) + "ms");
                         httpRespMsg.setError(corpwxJobResult.getErrMsg());
                         return httpRespMsg;
                     }
@@ -97,6 +106,8 @@ public class ExcelExportServiceImpl implements ExcelExportService {
                 i++;
             }
             if (syncTranslationResult != null) {
+                long t2 = System.currentTimeMillis();
+                System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
                 httpRespMsg.data = syncTranslationResult;
             } else {
                 //httpRespMsg.setError("处理超时...");

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -5061,6 +5061,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     public HttpRespMsg exportReport(@RequestParam String startDate, @RequestParam String endDate, Integer projectId,Integer stateKey,Integer departmentId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         DateFormat timeDf = new SimpleDateFormat("yyyy-MM-dd");
+        long t0 = System.currentTimeMillis();
         try {
             String userId = request.getHeader("Token");
             User user = userMapper.selectById(userId);
@@ -5221,11 +5222,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             }
             else {
                 //看公司所有人的
+                long t1 = System.currentTimeMillis();
                 if (timeType.getShowFillauditTime() == 1) {
                     allReportByDate = reportMapper.getAllReportByDateWithReportLog(startDate, user.getCompanyId(), null, endDate, projectId,stateKey,branchDepartment);
                 } else {
                     allReportByDate = reportMapper.getAllReportByDate(startDate, user.getCompanyId(), null, endDate, projectId,stateKey,branchDepartment);
                 }
+                long t2 = System.currentTimeMillis();
+                System.out.println("查数据库耗时:"+(t2-t1)/1000+"s");
             }
             //获取企业微信考勤数据
             List<UserCorpwxTime> userCorpwxTimeList = new ArrayList<>();
@@ -5557,6 +5561,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             }
             //生成Excel文件
             String fileUrlSuffix = (startDate==null?"":(startDate+MessageUtils.message("leave.to")+endDate))+MessageUtils.message("excel.workReport") + System.currentTimeMillis();
+            long t3 = System.currentTimeMillis();
+            System.out.println("处理数据耗时:"+(t3-t0)+"ms");
             httpRespMsg = excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileUrlSuffix,dataList,path);
         } catch (NullPointerException e) {
             //httpRespMsg.setError("验证失败或缺少数据");