Browse Source

Merge remote-tracking branch 'origin/dev_v3.1.0' into dev_v3.1.0

wangliang 3 years ago
parent
commit
7447699658

+ 2 - 2
distributed-print/src/main/resources/application-dev.properties

@@ -12,9 +12,9 @@ spring.application.name=distributed-print
 #\u6570\u636E\u6E90\u914D\u7F6E
 db.host=localhost
 db.port=3306
-db.name=distributed-v3.1.0
+db.name=distributed-v3.0.2
 db.username=root
-db.password=123456789
+db.password=88888888
 
 #redis\u6570\u636E\u6E90\u914D\u7F6E
 com.qmth.redis.host=${db.host}

+ 94 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/printOpen/PaperConfig.java

@@ -0,0 +1,94 @@
+package com.qmth.teachcloud.report.business.bean.dto.printOpen;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+
+import java.math.BigDecimal;
+
+/**
+ * @Description: 分布式印刷开放接口 - 试卷配置
+ * @Author: CaoZixuan
+ * @Date: 2022-06-08
+ */
+public class PaperConfig {
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    private String paperType;
+
+    private Long startTime;
+
+    private Long endTime;
+
+    private BigDecimal coefficient;
+
+    private BigDecimal totalScore;
+
+    private BigDecimal passScore;
+
+    private String scoreType;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public Long getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Long startTime) {
+        this.startTime = startTime;
+    }
+
+    public Long getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Long endTime) {
+        this.endTime = endTime;
+    }
+
+    public BigDecimal getCoefficient() {
+        return coefficient;
+    }
+
+    public void setCoefficient(BigDecimal coefficient) {
+        this.coefficient = coefficient;
+    }
+
+    public BigDecimal getTotalScore() {
+        return totalScore;
+    }
+
+    public void setTotalScore(BigDecimal totalScore) {
+        this.totalScore = totalScore;
+    }
+
+    public BigDecimal getPassScore() {
+        return passScore;
+    }
+
+    public void setPassScore(BigDecimal passScore) {
+        this.passScore = passScore;
+    }
+
+    public String getScoreType() {
+        return scoreType;
+    }
+
+    public void setScoreType(String scoreType) {
+        this.scoreType = scoreType;
+    }
+}

+ 11 - 2
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/CallPrintOpenApiService.java

@@ -1,7 +1,8 @@
 package com.qmth.teachcloud.report.business.service;
 
-import java.util.List;
-import java.util.Map;
+import com.qmth.teachcloud.report.business.bean.dto.printOpen.PaperConfig;
+
+import java.io.IOException;
 
 /**
  * @Description: 请求知学知考开放接口
@@ -9,4 +10,12 @@ import java.util.Map;
  * @Date: 2022-06-07
  */
 public interface CallPrintOpenApiService {
+    /**
+     * 请求分布式印刷试卷基础配置查询接口
+     * @param thirdExamId 考试id
+     * @param gradeCourseCode 科目编号
+     * @return 结果
+     */
+    PaperConfig callPaperConfig(Long thirdExamId,String gradeCourseCode) throws IOException;
+
 }

+ 56 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/CallPrintOpenApiServiceImpl.java

@@ -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;
+    }
+}

+ 41 - 0
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/TestCallPrintOpenApiController.java

@@ -0,0 +1,41 @@
+package com.qmth.teachcloud.report.api;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.annotation.BOOL;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.teachcloud.report.business.service.CallPrintOpenApiService;
+import io.swagger.annotations.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+
+/**
+ * @Description:
+ * @Author: CaoZixuan
+ * @Date:
+ */
+@Api(tags = "测试请求分布式印刷开放接口Controller")
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/test/call")
+@Validated
+public class TestCallPrintOpenApiController {
+    @Resource
+    CallPrintOpenApiService callPrintOpenApiService;
+
+    @ApiOperation(value = "试卷配置")
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷配置", response = Object.class)})
+    @RequestMapping(value = "/paper_config", method = RequestMethod.POST)
+    @Aac(auth = BOOL.FALSE)
+    public Result paperConfig(@ApiParam(value = "考试id", required = true) @RequestParam Long thirdExamId,
+                              @ApiParam(value = "科目编号", required = true) @RequestParam String courseCode) throws IOException {
+        callPrintOpenApiService.callPaperConfig(thirdExamId,courseCode);
+        return ResultUtil.ok();
+    }
+}

+ 7 - 7
teachcloud-report/src/main/resources/application-dev.properties

@@ -13,10 +13,10 @@ spring.application.name=teachcloud-report
 #db.host=192.168.10.136
 db.host=localhost
 db.port=3306
-db.name=teachcloud-report-v3.1.0
+db.name=teachcloud_report_v3.0.2
 #db.name=teachcloud-report
 db.username=root
-db.password=123456789
+db.password=88888888
 
 #redis\u6570\u636E\u6E90\u914D\u7F6E
 com.qmth.redis.host=${db.host}
@@ -140,11 +140,11 @@ yun.mark.studentScoreApi=/api/exam/student/score
 print.open.hostUrl=http://127.0.0.1:7001
 print.open.callbackUrlApi=/api/admin/print/notify/analysis/progress
 print.open.callbackPwd=123456
-print.open.paperConfig=/api/admin/open/paper_config
-print.open.paperDimension=/api/admin/open/paper_dimension
-print.open.paperStructure=/api/admin/open/paper_structure
-print.open.paperEvaluation=/api/admin/open/paper_evaluation
-print.open.examStudentScore=/api/admin/open/exam_student_score
+print.open.paperConfig=/api/admin/print/open/paper_config
+print.open.paperDimension=/api/admin/print/open/paper_dimension
+print.open.paperStructure=/api/admin/print/open/paper_structure
+print.open.paperEvaluation=/api/admin/print/open/paper_evaluation
+print.open.examStudentScore=/api/admin/print/open/exam_student_score
 
 #============================================================================
 # \u914D\u7F6EJobStore

+ 27 - 0
teachcloud-report/src/test/java/com/qmth/teachcloud/report/report/CallPrintOpenApiServiceTest.java

@@ -0,0 +1,27 @@
+package com.qmth.teachcloud.report.report;
+
+import com.qmth.teachcloud.report.business.service.CallPrintOpenApiService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+
+/**
+ * @Description: 分布式印刷开放接口测试类
+ * @Author: CaoZixuan
+ * @Date: 2022-06-08
+ */
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class CallPrintOpenApiServiceTest {
+    @Resource
+    private CallPrintOpenApiService callPrintOpenApiService;
+
+    @Test
+    public void callPaperConfig() throws IOException {
+        callPrintOpenApiService.callPaperConfig(1L,"1001");
+    }
+}