|
@@ -1,6 +1,5 @@
|
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
-import com.management.platform.entity.CompanyDingding;
|
|
|
import com.management.platform.entity.CorpwxJobResult;
|
|
|
import com.management.platform.entity.User;
|
|
|
import com.management.platform.entity.WxCorpInfo;
|
|
@@ -70,7 +69,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
+ public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
if (title.contains("/")) {
|
|
|
//文件名不能含有路径,得替换掉
|
|
@@ -149,52 +148,13 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
//httpRespMsg.setError("处理超时...");
|
|
|
httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
}
|
|
|
- }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
|
|
|
- String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
|
|
|
- System.out.println("上传待转译文件到钉钉, jobId==" + jobId);
|
|
|
- int i = 0;
|
|
|
- String syncTranslationResult = null;
|
|
|
- /**
|
|
|
- * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
|
|
|
- * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
- */
|
|
|
- long t = System.currentTimeMillis();
|
|
|
- while (i < 30) {
|
|
|
- if (i < 10) {
|
|
|
- Thread.sleep(300);
|
|
|
- } else if (i < 20){
|
|
|
- Thread.sleep(1000);
|
|
|
- } else {
|
|
|
- Thread.sleep(3000);
|
|
|
- }
|
|
|
- System.out.println("i=="+i+", "+LocalDateTime.now());
|
|
|
- Integer status = corpddJobCenter.get(jobId);
|
|
|
- if (status != null) {
|
|
|
- if (status == 1) {
|
|
|
- syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
|
|
|
- corpddJobCenter.remove(jobId);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- if (syncTranslationResult != null) {
|
|
|
- long t2 = System.currentTimeMillis();
|
|
|
- System.out.println("钉钉转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
- } else {
|
|
|
- //httpRespMsg.setError("处理超时...");
|
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
- }
|
|
|
}else {
|
|
|
httpRespMsg.data = resp;
|
|
|
}
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportGeneralExcelByTitleAndListNew(String userId,WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
+ public HttpRespMsg exportGeneralExcelByTitleAndListNew(String userId,WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
if (title.contains("/")) {
|
|
|
//文件名不能含有路径,得替换掉
|
|
@@ -250,53 +210,14 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
//httpRespMsg.setError("处理超时...");
|
|
|
httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
}
|
|
|
- }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
|
|
|
- String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
|
|
|
- System.out.println("上传待转译文件到钉钉, jobId==" + jobId);
|
|
|
- int i = 0;
|
|
|
- String syncTranslationResult = null;
|
|
|
- /**
|
|
|
- * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
|
|
|
- * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
- */
|
|
|
- long t = System.currentTimeMillis();
|
|
|
- while (i < 30) {
|
|
|
- if (i < 10) {
|
|
|
- Thread.sleep(300);
|
|
|
- } else if (i < 20){
|
|
|
- Thread.sleep(1000);
|
|
|
- } else {
|
|
|
- Thread.sleep(3000);
|
|
|
- }
|
|
|
- System.out.println("i=="+i+", "+LocalDateTime.now());
|
|
|
- Integer status = corpddJobCenter.get(jobId);
|
|
|
- if (status != null) {
|
|
|
- if (status == 1) {
|
|
|
- syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
|
|
|
- corpddJobCenter.remove(jobId);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- if (syncTranslationResult != null) {
|
|
|
- long t2 = System.currentTimeMillis();
|
|
|
- System.out.println("钉钉转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
- } else {
|
|
|
- //httpRespMsg.setError("处理超时...");
|
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
- }
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
httpRespMsg.data = resp;
|
|
|
}
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, List<Map> mapList, String downloadPath) throws Exception {
|
|
|
+ public HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, List<Map> mapList, String downloadPath) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
if (title.contains("/")) {
|
|
|
//文件名不能含有路径,得替换掉
|
|
@@ -338,41 +259,13 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
//httpRespMsg.setError("处理超时...");
|
|
|
httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
}
|
|
|
- }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
|
|
|
- String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
|
|
|
- int i = 0;
|
|
|
- String syncTranslationResult = null;
|
|
|
- /**
|
|
|
- * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
|
|
|
- * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
- */
|
|
|
- while (i < 10) {
|
|
|
- Thread.sleep(300);
|
|
|
- Integer status = corpddJobCenter.get(jobId);
|
|
|
- if (status != null) {
|
|
|
- if (status == 1) {
|
|
|
- syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
|
|
|
- corpddJobCenter.remove(jobId);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- if (syncTranslationResult != null) {
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
- } else {
|
|
|
- //httpRespMsg.setError("处理超时...");
|
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
- }
|
|
|
}else {
|
|
|
httpRespMsg.data = resp;
|
|
|
}
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
+ public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList2(title, list, downloadPath);
|
|
|
if (title.contains("/")) {
|
|
@@ -414,34 +307,6 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
//httpRespMsg.setError("处理超时...");
|
|
|
httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
}
|
|
|
- }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
|
|
|
- String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix, user.getDingdingUnionid(),dingding);
|
|
|
- int i = 0;
|
|
|
- String syncTranslationResult = null;
|
|
|
- /**
|
|
|
- * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
|
|
|
- * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
- */
|
|
|
- while (i < 10) {
|
|
|
- Thread.sleep(300);
|
|
|
- Integer status = corpddJobCenter.get(jobId);
|
|
|
- if (status != null) {
|
|
|
- if (status == 1) {
|
|
|
- syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
|
|
|
- corpddJobCenter.remove(jobId);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- if (syncTranslationResult != null) {
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
- } else {
|
|
|
- //httpRespMsg.setError("处理超时...");
|
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
- }
|
|
|
}else {
|
|
|
httpRespMsg.data = resp;
|
|
|
}
|
|
@@ -449,7 +314,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception {
|
|
|
+ public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndList(title,multiSheetList, downloadPath,sheetsName);
|
|
|
if (title.contains("/")) {
|
|
@@ -491,34 +356,6 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
//httpRespMsg.setError("处理超时...");
|
|
|
httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
}
|
|
|
- }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
|
|
|
- String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix,user.getDingdingUnionid(), dingding);
|
|
|
- int i = 0;
|
|
|
- String syncTranslationResult = null;
|
|
|
- /**
|
|
|
- * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
|
|
|
- * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
- */
|
|
|
- while (i < 10) {
|
|
|
- Thread.sleep(300);
|
|
|
- Integer status = corpddJobCenter.get(jobId);
|
|
|
- if (status != null) {
|
|
|
- if (status == 1) {
|
|
|
- syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
|
|
|
- corpddJobCenter.remove(jobId);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- if (syncTranslationResult != null) {
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
- } else {
|
|
|
- //httpRespMsg.setError("处理超时...");
|
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
- }
|
|
|
}else {
|
|
|
httpRespMsg.data = resp;
|
|
|
}
|
|
@@ -526,7 +363,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndListNew(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>>[] multiSheetList, String downloadPath, String[] sheetsName) throws Exception {
|
|
|
+ public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndListNew(WxCorpInfo wxCorpInfo, String title, List<List<String>>[] multiSheetList, String downloadPath, String[] sheetsName) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndListNew(title,multiSheetList, downloadPath,sheetsName);
|
|
|
if (title.contains("/")) {
|
|
@@ -568,41 +405,13 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
//httpRespMsg.setError("处理超时...");
|
|
|
httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
}
|
|
|
- }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
|
|
|
- String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix,user.getDingdingUnionid(), dingding);
|
|
|
- int i = 0;
|
|
|
- String syncTranslationResult = null;
|
|
|
- /**
|
|
|
- * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
|
|
|
- * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
- */
|
|
|
- while (i < 10) {
|
|
|
- Thread.sleep(300);
|
|
|
- Integer status = corpddJobCenter.get(jobId);
|
|
|
- if (status != null) {
|
|
|
- if (status == 1) {
|
|
|
- syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
|
|
|
- corpddJobCenter.remove(jobId);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- if (syncTranslationResult != null) {
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
- } else {
|
|
|
- //httpRespMsg.setError("处理超时...");
|
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
- }
|
|
|
}else {
|
|
|
httpRespMsg.data = resp;
|
|
|
}
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title) throws Exception {
|
|
|
+ public HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo, String title) throws Exception {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
if (title.contains("/")) {
|
|
|
//文件名不能含有路径,得替换掉
|
|
@@ -643,34 +452,6 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
|
//httpRespMsg.setError("处理超时...");
|
|
|
httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
}
|
|
|
- }else if(dingding != null && dingding.getContactNeedTranslate() == 1){
|
|
|
- User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- String mediaId = dingDingService.getTranslationMediaId(fileUrlSuffix,dingding);
|
|
|
- String jobId = dingDingService.syncTranslation(mediaId,fileUrlSuffix,user.getDingdingUnionid(), dingding);
|
|
|
- int i = 0;
|
|
|
- String syncTranslationResult = null;
|
|
|
- /**
|
|
|
- * 异步上传转译文件的任务完成时会触发回调,在DingDingController中的callback实现了对回调的处理,存储到corpddJobCenter缓存中
|
|
|
- * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
- */
|
|
|
- while (i < 10) {
|
|
|
- Thread.sleep(300);
|
|
|
- Integer status = corpddJobCenter.get(jobId);
|
|
|
- if (status != null) {
|
|
|
- if (status == 1) {
|
|
|
- syncTranslationResult = dingDingService.getSyncTranslationResult(jobId,dingding);
|
|
|
- corpddJobCenter.remove(jobId);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- if (syncTranslationResult != null) {
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
- } else {
|
|
|
- //httpRespMsg.setError("处理超时...");
|
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
- }
|
|
|
}
|
|
|
return httpRespMsg;
|
|
|
}
|