|
@@ -1,5 +1,7 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
|
|
+import com.management.platform.controller.TaskController;
|
|
|
|
+import com.management.platform.controller.UserController;
|
|
import com.management.platform.entity.CorpwxJobResult;
|
|
import com.management.platform.entity.CorpwxJobResult;
|
|
import com.management.platform.entity.User;
|
|
import com.management.platform.entity.User;
|
|
import com.management.platform.entity.WxCorpInfo;
|
|
import com.management.platform.entity.WxCorpInfo;
|
|
@@ -11,6 +13,9 @@ 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 com.management.platform.util.RedisUtil;
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.core.io.FileSystemResource;
|
|
import org.springframework.core.io.FileSystemResource;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -42,6 +47,8 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
private CorpwxJobResultMapper corpwxJobResultMapper;
|
|
private CorpwxJobResultMapper corpwxJobResultMapper;
|
|
@Value("${upload.path}")
|
|
@Value("${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisUtil redisUtil;
|
|
|
|
|
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
|
@Transactional(isolation = Isolation.READ_COMMITTED)
|
|
public void testRead(String jobId) {
|
|
public void testRead(String jobId) {
|
|
@@ -125,18 +132,34 @@ public class ExcelExportServiceImpl implements ExcelExportService {
|
|
Thread.sleep(3000);
|
|
Thread.sleep(3000);
|
|
}
|
|
}
|
|
System.out.println("i=="+i+", "+LocalDateTime.now());
|
|
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;
|
|
|
|
|
|
+ //直接循环调用接口,后面需要改成通过redis获取jobId对应的消息,再去调用接口
|
|
|
|
+ Object map = redisUtil.getString("corpwxJobCenter"+jobId);
|
|
|
|
+ JSONObject jsonObject = new JSONObject(map.toString());
|
|
|
|
+ System.out.println("通过redis获取到企业微信上传回调的数据=="+jsonObject);
|
|
|
|
+ String infoType = jsonObject.getString("InfoType");
|
|
|
|
+ if ("batch_job_result".equals(infoType)) {
|
|
|
|
+ org.json.JSONObject batchJob = jsonObject.getJSONObject("BatchJob");
|
|
|
|
+ String jobType = batchJob.getString("JobType");
|
|
|
|
+ String authCorpId = jsonObject.getString("AuthCorpId");
|
|
|
|
+ CorpwxJobResult corpwxJobResult = new CorpwxJobResult();
|
|
|
|
+ corpwxJobResult.setAuthCorpId(authCorpId);
|
|
|
|
+ corpwxJobResult.setErrCode(batchJob.getInt("ErrCode"));
|
|
|
|
+ corpwxJobResult.setErrMsg(batchJob.getString("ErrMsg"));
|
|
|
|
+ corpwxJobResult.setJobId(jobId);
|
|
|
|
+ corpwxJobResult.setJobType(jobType);
|
|
|
|
+ corpwxJobResultMapper.insert(corpwxJobResult);
|
|
|
|
+ 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;
|
|
}
|
|
}
|
|
- break;
|
|
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|