|
@@ -1,25 +1,25 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.management.platform.entity.CompanyDingding;
|
|
import com.management.platform.entity.CorpwxJobResult;
|
|
import com.management.platform.entity.CorpwxJobResult;
|
|
|
|
+import com.management.platform.entity.User;
|
|
import com.management.platform.entity.WxCorpInfo;
|
|
import com.management.platform.entity.WxCorpInfo;
|
|
import com.management.platform.mapper.CorpwxJobResultMapper;
|
|
import com.management.platform.mapper.CorpwxJobResultMapper;
|
|
|
|
+import com.management.platform.mapper.UserMapper;
|
|
|
|
+import com.management.platform.service.DingDingService;
|
|
import com.management.platform.service.ExcelExportService;
|
|
import com.management.platform.service.ExcelExportService;
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
import com.management.platform.util.ExcelUtil;
|
|
import com.management.platform.util.ExcelUtil;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.MessageUtils;
|
|
import com.management.platform.util.MessageUtils;
|
|
-import org.apache.poi.hssf.usermodel.*;
|
|
|
|
-import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
|
-import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
-import org.apache.poi.ss.usermodel.FillPatternType;
|
|
|
|
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.core.io.FileSystemResource;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -29,11 +29,20 @@ import java.util.Map;
|
|
public class ExcelExportServiceImpl implements ExcelExportService {
|
|
public class ExcelExportServiceImpl implements ExcelExportService {
|
|
//用于控制线程锁
|
|
//用于控制线程锁
|
|
public static HashMap<String, CorpwxJobResult> corpwxJobCenter = new HashMap();
|
|
public static HashMap<String, CorpwxJobResult> corpwxJobCenter = new HashMap();
|
|
|
|
+ public static HashMap<String, Integer> corpddJobCenter = new HashMap();
|
|
@Resource
|
|
@Resource
|
|
private WxCorpInfoService wxCorpInfoService;
|
|
private WxCorpInfoService wxCorpInfoService;
|
|
|
|
+ @Resource
|
|
|
|
+ private DingDingService dingDingService;
|
|
|
|
+ @Resource
|
|
|
|
+ private HttpServletRequest request;
|
|
|
|
+ @Resource
|
|
|
|
+ private UserMapper userMapper;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private CorpwxJobResultMapper corpwxJobResultMapper;
|
|
private CorpwxJobResultMapper corpwxJobResultMapper;
|
|
|
|
+ @Value("${upload.path}")
|
|
|
|
+ private String path;
|
|
|
|
|
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
|
public void testRead(String jobId) {
|
|
public void testRead(String jobId) {
|
|
@@ -61,7 +70,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
|
|
|
+ public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
if (title.contains("/")) {
|
|
if (title.contains("/")) {
|
|
//文件名不能含有路径,得替换掉
|
|
//文件名不能含有路径,得替换掉
|
|
@@ -74,9 +83,33 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(title, list, downloadPath);
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(title, list, downloadPath);
|
|
String fileUrlSuffix = title + ".xlsx";
|
|
String fileUrlSuffix = title + ".xlsx";
|
|
if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
|
+ FileSystemResource fileSystemResource = new FileSystemResource(path+fileUrlSuffix);
|
|
|
|
+// String md5 = DigestUtils.md5Hex(FileUtil.readBytes(fileSystemResource.getFile()));
|
|
|
|
+
|
|
|
|
+ Long checkSize = 20L*1024*1024;
|
|
|
|
+ if(fileSystemResource.getFile().length() >= checkSize){
|
|
|
|
+ httpRespMsg.setError("文件过大,请缩短查询日期范围");
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+ String jobId = "";
|
|
String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
|
|
String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
|
|
- String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
|
|
|
|
|
|
+ jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
|
|
|
|
+// if(fileSystemResource.getFile().length() >= checkSize){
|
|
|
|
+// String tmpFileJobId = wxCorpInfoService.getTranslationJobId(fileUrlSuffix,md5,wxCorpInfo);
|
|
|
|
+// if(!StringUtils.isEmpty(tmpFileJobId)){
|
|
|
|
+// String mediaId = wxCorpInfoService.getAsyncJobResult(tmpFileJobId,wxCorpInfo);
|
|
|
|
+// jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
|
|
|
|
+// }
|
|
|
|
+// }else{
|
|
|
|
+// String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
|
|
|
|
+// jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
|
|
|
|
+// }
|
|
|
|
+
|
|
System.out.println("上传待转译文件到企业微信, jobId==" + jobId);
|
|
System.out.println("上传待转译文件到企业微信, jobId==" + jobId);
|
|
|
|
+// if(StringUtils.isEmpty(jobId)){
|
|
|
|
+// httpRespMsg.setError("转义jobId为空,请联系管理员");
|
|
|
|
+// return httpRespMsg;
|
|
|
|
+// }
|
|
int i = 0;
|
|
int i = 0;
|
|
String syncTranslationResult = null;
|
|
String syncTranslationResult = null;
|
|
/**
|
|
/**
|
|
@@ -84,7 +117,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
* 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
* 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
*/
|
|
*/
|
|
long t = System.currentTimeMillis();
|
|
long t = System.currentTimeMillis();
|
|
- while (i < 30) {
|
|
|
|
|
|
+ while (i < 40) {
|
|
if (i < 10) {
|
|
if (i < 10) {
|
|
Thread.sleep(300);
|
|
Thread.sleep(300);
|
|
} else if (i < 20){
|
|
} else if (i < 20){
|
|
@@ -94,26 +127,176 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
}
|
|
}
|
|
System.out.println("i=="+i+", "+LocalDateTime.now());
|
|
System.out.println("i=="+i+", "+LocalDateTime.now());
|
|
CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
|
|
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;
|
|
|
|
+ }
|
|
|
|
+ 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 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;
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
- syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
|
|
|
|
- if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
|
|
|
|
- long t2 = System.currentTimeMillis();
|
|
|
|
- System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
|
|
|
|
- httpRespMsg.data = syncTranslationResult;
|
|
|
|
- return httpRespMsg;
|
|
|
|
|
|
+ public HttpRespMsg exportGeneralExcelByTitleAndListNew(String userId,WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ if (title.contains("/")) {
|
|
|
|
+ //文件名不能含有路径,得替换掉
|
|
|
|
+ title = title.replace("/", "@");
|
|
|
|
+ }
|
|
|
|
+ if (title.contains("\\")) {
|
|
|
|
+ //文件名不能含有路径,得替换掉
|
|
|
|
+ title = title.replace("\\", "@");
|
|
|
|
+ }
|
|
|
|
+ String resp = ExcelUtil.exportGeneralExcelByTitleAndList(title, list, downloadPath);
|
|
|
|
+ String fileUrlSuffix = title + ".xlsx";
|
|
|
|
+ if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
|
+ String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
|
|
|
|
+ String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
|
|
|
|
+ System.out.println("上传待转译文件到企业微信, jobId==" + jobId);
|
|
|
|
+ int i = 0;
|
|
|
|
+ String syncTranslationResult = null;
|
|
|
|
+ /**
|
|
|
|
+ * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
|
|
|
|
+ * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
|
+ */
|
|
|
|
+ long t = System.currentTimeMillis();
|
|
|
|
+ while (i < 40) {
|
|
|
|
+ if (i < 10) {
|
|
|
|
+ Thread.sleep(300);
|
|
|
|
+ } else if (i < 20){
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
+ } else {
|
|
|
|
+ Thread.sleep(3000);
|
|
|
|
+ }
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+ if (syncTranslationResult != null) {
|
|
|
|
+ long t2 = System.currentTimeMillis();
|
|
|
|
+ System.out.println("企业微信转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
|
|
|
|
+ httpRespMsg.data = syncTranslationResult;
|
|
|
|
+ wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,userId,syncTranslationResult, null, WxCorpInfoServiceImpl.TEXT_CARD_MSG__ASYNC_DWONLOAD);
|
|
|
|
+ } else {
|
|
|
|
+ //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++;
|
|
i++;
|
|
}
|
|
}
|
|
|
|
+ if (syncTranslationResult != null) {
|
|
|
|
+ long t2 = System.currentTimeMillis();
|
|
|
|
+ System.out.println("钉钉转译文件后地址是:"+syncTranslationResult+",耗时:" + (t2 - t) + "ms");
|
|
|
|
+ httpRespMsg.data = syncTranslationResult;
|
|
|
|
+ } else {
|
|
//httpRespMsg.setError("处理超时...");
|
|
//httpRespMsg.setError("处理超时...");
|
|
- httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
|
|
|
+ httpRespMsg.setError(MessageUtils.message("request.outTime"));
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
httpRespMsg.data = resp;
|
|
httpRespMsg.data = resp;
|
|
}
|
|
}
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, List<Map> mapList, String downloadPath) throws Exception {
|
|
|
|
|
|
+
|
|
|
|
+ public HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, List<Map> mapList, String downloadPath) throws Exception {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
if (title.contains("/")) {
|
|
if (title.contains("/")) {
|
|
//文件名不能含有路径,得替换掉
|
|
//文件名不能含有路径,得替换掉
|
|
@@ -149,7 +332,35 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
- if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
|
|
|
|
|
|
+ if (syncTranslationResult != null) {
|
|
|
|
+ httpRespMsg.data = syncTranslationResult;
|
|
|
|
+ } else {
|
|
|
|
+ //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;
|
|
httpRespMsg.data = syncTranslationResult;
|
|
} else {
|
|
} else {
|
|
//httpRespMsg.setError("处理超时...");
|
|
//httpRespMsg.setError("处理超时...");
|
|
@@ -161,7 +372,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
|
|
|
|
+ public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, CompanyDingding dingding, String title, List<List<String>> list, String downloadPath) throws Exception {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList2(title, list, downloadPath);
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList2(title, list, downloadPath);
|
|
if (title.contains("/")) {
|
|
if (title.contains("/")) {
|
|
@@ -197,7 +408,35 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
- if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
|
|
|
|
|
|
+ if (syncTranslationResult != null) {
|
|
|
|
+ httpRespMsg.data = syncTranslationResult;
|
|
|
|
+ } else {
|
|
|
|
+ //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;
|
|
httpRespMsg.data = syncTranslationResult;
|
|
} else {
|
|
} else {
|
|
//httpRespMsg.setError("处理超时...");
|
|
//httpRespMsg.setError("处理超时...");
|
|
@@ -210,7 +449,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception {
|
|
|
|
|
|
+ public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndList(title,multiSheetList, downloadPath,sheetsName);
|
|
String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndList(title,multiSheetList, downloadPath,sheetsName);
|
|
if (title.contains("/")) {
|
|
if (title.contains("/")) {
|
|
@@ -246,7 +485,112 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
- if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
|
|
|
|
|
|
+ if (syncTranslationResult != null) {
|
|
|
|
+ httpRespMsg.data = syncTranslationResult;
|
|
|
|
+ } else {
|
|
|
|
+ //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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndListNew(WxCorpInfo wxCorpInfo, CompanyDingding dingding, 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("/")) {
|
|
|
|
+ //文件名不能含有路径,得替换掉
|
|
|
|
+ title = title.replace("/", "@");
|
|
|
|
+ }
|
|
|
|
+ if (title.contains("\\")) {
|
|
|
|
+ //文件名不能含有路径,得替换掉
|
|
|
|
+ title = title.replace("\\", "@");
|
|
|
|
+ }
|
|
|
|
+ String fileUrlSuffix = title + ".xlsx";
|
|
|
|
+ if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
|
+ String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
|
|
|
|
+ String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
|
|
|
|
+ int i = 0;
|
|
|
|
+ String syncTranslationResult = null;
|
|
|
|
+ /**
|
|
|
|
+ * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
|
|
|
|
+ * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
|
|
|
|
+ */
|
|
|
|
+ while (i < 10) {
|
|
|
|
+ Thread.sleep(300);
|
|
|
|
+ CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
|
|
|
|
+ if (corpwxJobResult != null) {
|
|
|
|
+ if (corpwxJobResult.getErrCode() == 0) {
|
|
|
|
+ syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
|
|
|
|
+ corpwxJobCenter.remove(jobId);
|
|
|
|
+ } else {
|
|
|
|
+ httpRespMsg.setError(corpwxJobResult.getErrMsg());
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+ if (syncTranslationResult != null) {
|
|
|
|
+ httpRespMsg.data = syncTranslationResult;
|
|
|
|
+ } else {
|
|
|
|
+ //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;
|
|
httpRespMsg.data = syncTranslationResult;
|
|
} else {
|
|
} else {
|
|
//httpRespMsg.setError("处理超时...");
|
|
//httpRespMsg.setError("处理超时...");
|
|
@@ -258,7 +602,7 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
- public HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo,String title) throws Exception {
|
|
|
|
|
|
+ public HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo, CompanyDingding dingding,String title) throws Exception {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
if (title.contains("/")) {
|
|
if (title.contains("/")) {
|
|
//文件名不能含有路径,得替换掉
|
|
//文件名不能含有路径,得替换掉
|
|
@@ -293,7 +637,35 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
- if (syncTranslationResult != null && !syncTranslationResult.equals("")) {
|
|
|
|
|
|
+ if (syncTranslationResult != null) {
|
|
|
|
+ httpRespMsg.data = syncTranslationResult;
|
|
|
|
+ } else {
|
|
|
|
+ //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;
|
|
httpRespMsg.data = syncTranslationResult;
|
|
} else {
|
|
} else {
|
|
//httpRespMsg.setError("处理超时...");
|
|
//httpRespMsg.setError("处理超时...");
|