|
@@ -0,0 +1,56 @@
|
|
|
+package com.qmth.teachcloud.report.business.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.qmth.boot.tools.signature.SignatureEntity;
|
|
|
+import com.qmth.boot.tools.signature.SignatureType;
|
|
|
+import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
+import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
|
+import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
|
+import com.qmth.teachcloud.common.util.HttpUtil;
|
|
|
+import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.printOpen.PaperConfig;
|
|
|
+import com.qmth.teachcloud.report.business.service.CallPrintOpenApiService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: 请求分布式印刷服务实现类
|
|
|
+ * @Author: CaoZixuan
|
|
|
+ * @Date: 2022-06-08
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CallPrintOpenApiServiceImpl implements CallPrintOpenApiService {
|
|
|
+ @Resource
|
|
|
+ CommonCacheService commonCacheService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ DictionaryConfig dictionaryConfig;
|
|
|
+
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(CallPrintOpenApiServiceImpl.class);
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PaperConfig callPaperConfig(Long thirdExamId, String gradeCourseCode) throws IOException {
|
|
|
+// Long schoolId = SystemConstant.getHeadOrUserSchoolId();
|
|
|
+ Long schoolId = 2L;
|
|
|
+ BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
|
|
|
+ log.info("请求分布式印刷试卷配置");
|
|
|
+ JSONObject printOpenParams = new JSONObject();
|
|
|
+ printOpenParams.put("thirdExamId", thirdExamId);
|
|
|
+ printOpenParams.put("gradeCourseCode", gradeCourseCode);
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+
|
|
|
+ String accessToken = SignatureEntity.build(SignatureType.SECRET, SystemConstant.METHOD, dictionaryConfig.printOpenDomain().getPaperConfig(), timestamp, basicSchool.getAccessKey(), basicSchool.getAccessSecret());
|
|
|
+ String result = HttpUtil.postJson(dictionaryConfig.reportOpenDomain().getHostUrl() + dictionaryConfig.printOpenDomain().getPaperConfig(), JacksonUtil.parseJson(printOpenParams), accessToken, timestamp);
|
|
|
+ if (Objects.nonNull(result)) {
|
|
|
+ log.info("result:{}", JacksonUtil.parseJson(result));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|