|
@@ -3,16 +3,19 @@ package com.management.platform.util;
|
|
|
import com.management.platform.entity.CorpwxJobResult;
|
|
|
import com.management.platform.entity.WxCorpInfo;
|
|
|
import com.management.platform.mapper.CorpwxJobResultMapper;
|
|
|
+import com.management.platform.service.CorpwxJobResultService;
|
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.util.List;
|
|
|
|
|
|
+@Component
|
|
|
public class ExcelUtil {
|
|
|
/**
|
|
|
* 简单Excel导出
|
|
@@ -21,16 +24,21 @@ public class ExcelUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
|
|
|
- private static WxCorpInfoService wxCorpInfoService;
|
|
|
- private static CorpwxJobResultMapper corpwxJobResultMapper;
|
|
|
+ @Autowired
|
|
|
+ private WxCorpInfoService wxCorpInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CorpwxJobResultService corpwxJobResultService;
|
|
|
+
|
|
|
+ public ExcelUtil(){}
|
|
|
+ public static ExcelUtil ExcelUtil;
|
|
|
+
|
|
|
@PostConstruct
|
|
|
- public void init() {
|
|
|
- wxCorpInfoService = wxCorpInfoService;
|
|
|
- corpwxJobResultMapper = corpwxJobResultMapper;
|
|
|
+ public void init(){
|
|
|
+ ExcelUtil = this;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
public static String exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo,String title, List<List<String>> list, String downloadPath) {
|
|
|
String result="系统提示:Excel文件导出成功!";
|
|
|
String fileName= title+".xls";
|
|
@@ -160,8 +168,8 @@ public class ExcelUtil {
|
|
|
os.flush();
|
|
|
os.close();
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
- String mediaId = wxCorpInfoService.getTranslationMediaId(fileName);
|
|
|
- String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileName, null);
|
|
|
+ String mediaId =ExcelUtil.wxCorpInfoService.getTranslationMediaId(fileName);
|
|
|
+ String jobId = ExcelUtil.wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileName, null);
|
|
|
/*if(jobId!=null&&!jobId.equals("")){
|
|
|
File file=new File(path + fileUrlSuffix);
|
|
|
if(file.exists()){
|
|
@@ -176,10 +184,10 @@ public class ExcelUtil {
|
|
|
*/
|
|
|
while (i < 10) {
|
|
|
Thread.sleep(300);
|
|
|
- CorpwxJobResult corpwxJobResult = corpwxJobResultMapper.selectById(jobId);
|
|
|
+ CorpwxJobResult corpwxJobResult = ExcelUtil.corpwxJobResultService.getById(jobId);
|
|
|
if (corpwxJobResult != null) {
|
|
|
if (corpwxJobResult.getErrCode() == 0) {
|
|
|
- syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
|
|
|
+ syncTranslationResult = ExcelUtil.wxCorpInfoService.getSyncTranslationResult(jobId);
|
|
|
} else {
|
|
|
return corpwxJobResult.getErrMsg();
|
|
|
}
|