Răsfoiți Sursa

新增学校管理

wangliang 2 ani în urmă
părinte
comite
c439ce11c4

+ 98 - 0
server/src/main/java/com/qmth/jkserver/controller/system/BasicSchoolController.java

@@ -0,0 +1,98 @@
+package com.qmth.jkserver.controller.system;
+
+import com.qmth.jkserver.constant.SystemConstant;
+import com.qmth.jkserver.core.exception.JkServerException;
+import com.qmth.jkserver.dto.SchoolDto;
+import com.qmth.jkserver.dto.SysAdminSetParam;
+import com.qmth.jkserver.dto.result.SysConfigResult;
+import com.qmth.jkserver.enums.ExceptionResultEnum;
+import com.qmth.jkserver.model.SysConfig;
+import com.qmth.jkserver.service.BasicSchoolService;
+import com.qmth.jkserver.service.CommonCacheService;
+import com.qmth.jkserver.service.SysConfigService;
+import com.qmth.jkserver.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * <p>
+ * 学校表 前端控制器
+ * </p>
+ *
+ * @author xf
+ * @since 2021-03-23
+ */
+@Api(tags = "学校Controller")
+@RestController
+@RequestMapping(SystemConstant.PREFIX_URL_COMMON + "/school")
+public class BasicSchoolController {
+
+    @Autowired
+    private BasicSchoolService basicSchoolService;
+
+    @Resource
+    CommonCacheService commonCacheService;
+
+    @Resource
+    SysConfigService sysConfigService;
+
+    /**
+     * 学校查询
+     *
+     * @return
+     */
+    @ApiOperation(value = "查询")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    public Object list() {
+        List<SchoolDto> list = basicSchoolService.listSchool();
+        return list;
+    }
+
+    @ApiOperation(value = "同步配置查询")
+    @ApiResponses({@ApiResponse(code = 200, message = "同步配置信息", response = SysConfigResult.class)})
+    @RequestMapping(value = "/sync/select", method = RequestMethod.POST)
+    public Object sysadminSyncSelect(@ApiParam(value = "学校id ", required = true) @RequestParam Long schoolId) {
+        SysConfig sysConfigCloudmarkHostUrl = commonCacheService.addSysConfigCache(schoolId, SystemConstant.CLOUDMARK_HOST_URL);
+        List<SysConfigResult> sysConfigResultList = new ArrayList<>();
+        if (Objects.nonNull(sysConfigCloudmarkHostUrl)) {
+            sysConfigResultList.add(new SysConfigResult(sysConfigCloudmarkHostUrl));
+        } else {
+            sysConfigResultList.add(new SysConfigResult(null, SystemConstant.CLOUDMARK_HOST_URL, "云阅卷地址", "", 1));
+        }
+        return sysConfigResultList;
+    }
+
+    @ApiOperation(value = "同步配置保存")
+    @ApiResponses({@ApiResponse(code = 200, message = "同步配置信息", response = Object.class)})
+    @RequestMapping(value = "/sync/save", method = RequestMethod.POST)
+    @Transactional
+    public Object sysadminSyncSave(@Valid @RequestBody SysAdminSetParam sysAdminSetParam, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        Optional.ofNullable(sysAdminSetParam.getParam()).orElseThrow(() -> new JkServerException("同步配置地址不能为空"));
+
+        List<SysConfigResult> sysConfigResultList = sysAdminSetParam.getParam();
+        List<SysConfig> sysConfigList = new ArrayList<>();
+        for (SysConfigResult s : sysConfigResultList) {
+            sysConfigList.add(new SysConfig(sysAdminSetParam.getSchoolId(), s));
+        }
+        sysConfigService.saveOrUpdateBatch(sysConfigList);
+
+        for (SysConfigResult s : sysConfigResultList) {
+            commonCacheService.updateSysConfigCache(sysAdminSetParam.getSchoolId(), s.getCode());
+        }
+        return ResultUtil.ok(true);
+    }
+}
+

+ 5 - 0
server/src/main/java/com/qmth/jkserver/controller/system/ExamTaskController.java

@@ -126,6 +126,11 @@ public class ExamTaskController extends BaseSystemController {
             throw new JkServerException("考试编码" + examCode + "的考试不存在");
         }
         Map<String, Object> map = new HashMap<>();
+        Long schoolId = (Long) ServletUtil.getRequestHeaderSchoolId();
+        if (Objects.nonNull(schoolId) && schoolId.longValue() == -1L) {
+            throw new JkServerException("超级管理员不能推送");
+        }
+        map.put(SystemConstant.SCHOOL_ID, schoolId);
         if (Objects.nonNull(examPlan.getExamTaskId())) {
             ExamTask examTask = examTaskService.getById(examPlan.getExamTaskId());
             if (examTask.getStatus() == TaskStatusEnum.FINISH && Objects.nonNull(examTask.getResult()) && examTask.getResult() == TaskResultEnum.SUCCESS) {

+ 4 - 0
server/src/main/java/com/qmth/jkserver/dao/BasicSchoolDao.java

@@ -1,8 +1,11 @@
 package com.qmth.jkserver.dao;
 
 import com.qmth.jkserver.base.CustomBaseMapper;
+import com.qmth.jkserver.dto.SchoolDto;
 import com.qmth.jkserver.model.BasicSchool;
 
+import java.util.List;
+
 /**
  * <p>
  * 学校表 Mapper 接口
@@ -13,4 +16,5 @@ import com.qmth.jkserver.model.BasicSchool;
  */
 public interface BasicSchoolDao extends CustomBaseMapper<BasicSchool> {
 
+    List<SchoolDto> listSchool();
 }

+ 75 - 0
server/src/main/java/com/qmth/jkserver/dto/SchoolDto.java

@@ -0,0 +1,75 @@
+package com.qmth.jkserver.dto;
+
+/**
+ * @Date: 2021/4/2.
+ */
+public class SchoolDto {
+
+    private String id;
+
+    private String code;
+    private String name;
+    private Boolean enable;
+
+    private String accessKey;
+
+    private String accessSecret;
+
+    private String logo;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public String getAccessKey() {
+        return accessKey;
+    }
+
+    public void setAccessKey(String accessKey) {
+        this.accessKey = accessKey;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+
+    public String getLogo() {
+        return logo;
+    }
+
+    public void setLogo(String logo) {
+        this.logo = logo;
+    }
+}

+ 46 - 0
server/src/main/java/com/qmth/jkserver/dto/SysAdminSetParam.java

@@ -0,0 +1,46 @@
+package com.qmth.jkserver.dto;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.jkserver.dto.result.SysConfigResult;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description: 学校自定义菜单 param
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/10/30
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class SysAdminSetParam implements Serializable {
+
+    @ApiModelProperty(value = "参数")
+    List<SysConfigResult> param;
+
+    @ApiModelProperty(value = "学校id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "学校id不能为空")
+    private Long schoolId;
+
+    public List<SysConfigResult> getParam() {
+        return param;
+    }
+
+    public void setParam(List<SysConfigResult> param) {
+        this.param = param;
+    }
+
+    public Long getSchoolId() {
+        return schoolId;
+    }
+
+    public void setSchoolId(Long schoolId) {
+        this.schoolId = schoolId;
+    }
+}

+ 120 - 0
server/src/main/java/com/qmth/jkserver/dto/result/SysConfigResult.java

@@ -0,0 +1,120 @@
+package com.qmth.jkserver.dto.result;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.jkserver.model.SysConfig;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description: 系统参数result
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/11/30
+ */
+public class SysConfigResult implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "主键")
+    private Long id;
+
+    @ApiModelProperty(value = "参数编码")
+    private String code;
+
+    @ApiModelProperty(value = "参数名称")
+    private String name;
+
+    @ApiModelProperty(value = "参数值")
+    private Object value;
+
+    @ApiModelProperty(value = "启用/禁用,ture:启用,false:禁用,默认启用")
+    private Boolean enable = true;
+
+    @ApiModelProperty(value = "排序")
+    private Integer sort = 1;
+
+    private List<SysConfigResultOption> options;
+
+    public SysConfigResult() {
+
+    }
+
+    public SysConfigResult(Long id, String code, String name, Object value, Integer sort) {
+        this.id = id;
+        this.code = code;
+        this.name = name;
+        this.value = value;
+        this.sort = sort;
+    }
+
+    public SysConfigResult(SysConfig sysConfig) {
+        this.id = sysConfig.getId();
+        this.code = sysConfig.getConfigKey();
+        this.name = sysConfig.getConfigName();
+        this.value = sysConfig.getConfigValue();
+        this.enable = sysConfig.getEnable();
+        this.sort = sysConfig.getSort();
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public List<SysConfigResultOption> getOptions() {
+        return options;
+    }
+
+    public void setOptions(List<SysConfigResultOption> options) {
+        this.options = options;
+    }
+
+}

+ 30 - 0
server/src/main/java/com/qmth/jkserver/dto/result/SysConfigResultOption.java

@@ -0,0 +1,30 @@
+package com.qmth.jkserver.dto.result;
+
+public class SysConfigResultOption {
+    private String label;
+    private String value;
+
+    public SysConfigResultOption() {
+    }
+
+    public SysConfigResultOption(String label, String value) {
+        this.label = label;
+        this.value = value;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

+ 38 - 0
server/src/main/java/com/qmth/jkserver/model/SysConfig.java

@@ -6,9 +6,12 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.jkserver.base.BaseEntity;
+import com.qmth.jkserver.constant.SystemConstant;
+import com.qmth.jkserver.dto.result.SysConfigResult;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * <p>
@@ -53,6 +56,41 @@ public class SysConfig extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "排序")
     private Integer sort = 1;
 
+    public SysConfig() {
+
+    }
+
+    public SysConfig(SysConfigResult sysConfigResult) {
+        if (Objects.isNull(sysConfigResult.getId())) {
+            setId(SystemConstant.getDbUuid());
+        } else {
+            setId(sysConfigResult.getId());
+        }
+        this.configKey = sysConfigResult.getCode();
+        this.configName = sysConfigResult.getName();
+        this.configValue = String.valueOf(sysConfigResult.getValue());
+        this.enable = sysConfigResult.getEnable();
+        this.sort = sysConfigResult.getSort();
+        setCreateId(1L);
+        setCreateTime(System.currentTimeMillis());
+    }
+
+    public SysConfig(Long schoolId, SysConfigResult sysConfigResult) {
+        if (Objects.isNull(sysConfigResult.getId())) {
+            setId(SystemConstant.getDbUuid());
+        } else {
+            setId(sysConfigResult.getId());
+        }
+        this.schoolId = schoolId;
+        this.configKey = sysConfigResult.getCode();
+        this.configName = sysConfigResult.getName();
+        this.configValue = String.valueOf(sysConfigResult.getValue());
+        this.enable = sysConfigResult.getEnable();
+        this.sort = sysConfigResult.getSort();
+        setCreateId(1L);
+        setCreateTime(System.currentTimeMillis());
+    }
+
     public Boolean getEnable() {
         return enable;
     }

+ 4 - 2
server/src/main/java/com/qmth/jkserver/service/BasicSchoolService.java

@@ -1,8 +1,10 @@
 package com.qmth.jkserver.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.jkserver.dto.SchoolDto;
 import com.qmth.jkserver.model.BasicSchool;
-import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
 
 /**
  * <p>
@@ -14,5 +16,5 @@ import org.springframework.web.multipart.MultipartFile;
  */
 public interface BasicSchoolService extends IService<BasicSchool> {
 
-    boolean updateSchool(Long id, String code, String name, MultipartFile logo, String logoMd5);
+    List<SchoolDto> listSchool();
 }

+ 10 - 6
server/src/main/java/com/qmth/jkserver/service/CallYunMarkApiService.java

@@ -18,38 +18,42 @@ public interface CallYunMarkApiService {
     /**
      * 根据考试id或考试编码调用云阅卷学生成绩接口
      *
-     * @param examId 考试id
+     * @param examId   考试id
      * @param examCode 考试编号
      * @return 学生成绩
      */
-    List<Map> callStudentScoreApi(Long examId, String examCode, Map<String,String> secretMap) throws IOException;
+    List<Map> callStudentScoreApi(Long examId, String examCode, Map<String, String> secretMap, Long schoolId) throws IOException;
 
     /**
      * 根据机考数据中心考试计划参数调用云阅卷考试创建接口
+     *
      * @param saveExamParams 保存考试参数
      * @return 考试id
      */
-    int callExamSaveApi(SaveExamParams saveExamParams,Map<String,String> secretMap) throws IOException, IllegalAccessException;
+    int callExamSaveApi(SaveExamParams saveExamParams, Map<String, String> secretMap, Long schoolId) throws IOException, IllegalAccessException;
 
     /**
      * 根据机考数据中心考生数据提取的科目参数调用云阅卷科目创建接口
+     *
      * @param saveSubjectParams 新增/编辑项目参数
      * @return 更新的时间
      */
-    String callSubjectSaveApi(SaveSubjectParams saveSubjectParams,Map<String,String> secretMap) throws IOException, IllegalAccessException;
+    String callSubjectSaveApi(SaveSubjectParams saveSubjectParams, Map<String, String> secretMap, Long schoolId) throws IOException, IllegalAccessException;
 
     /**
      * 根据机考数据中心考生数据提供的考生参数调用云阅卷考生创建/编辑接口
+     *
      * @param saveStudentParams 新增/编辑考生数据
      * @return 更新的时间
      */
-    String callStudentSaveApi(SaveStudentParams saveStudentParams,Map<String,String> secretMap) throws IOException, IllegalAccessException;
+    String callStudentSaveApi(SaveStudentParams saveStudentParams, Map<String, String> secretMap, Long schoolId) throws IOException, IllegalAccessException;
 
     /**
      * 根据机考数据中心数据和所传的对象类型,对应上传云阅卷的各种附件
+     *
      * @param obj 参数对象
      * @return 是否成功
      */
-    boolean callFileUploadApi(Object obj,Map<String,String> secretMap) throws IllegalAccessException, IOException;
+    boolean callFileUploadApi(Object obj, Map<String, String> secretMap, Long schoolId) throws IllegalAccessException, IOException;
 
 }

+ 5 - 30
server/src/main/java/com/qmth/jkserver/service/impl/BasicSchoolServiceImpl.java

@@ -1,20 +1,16 @@
 package com.qmth.jkserver.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.jkserver.config.DictionaryConfig;
-import com.qmth.jkserver.constant.SystemConstant;
 import com.qmth.jkserver.dao.BasicSchoolDao;
+import com.qmth.jkserver.dto.SchoolDto;
 import com.qmth.jkserver.model.BasicSchool;
 import com.qmth.jkserver.service.BasicSchoolService;
-import com.qmth.jkserver.service.CommonCacheService;
-import com.qmth.jkserver.util.FileStoreUtil;
 import org.springframework.context.annotation.Scope;
 import org.springframework.context.annotation.ScopedProxyMode;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.util.Base64;
+import java.util.List;
 
 /**
  * <p>
@@ -29,31 +25,10 @@ import java.util.Base64;
 public class BasicSchoolServiceImpl extends ServiceImpl<BasicSchoolDao, BasicSchool> implements BasicSchoolService {
 
     @Resource
-    DictionaryConfig dictionaryConfig;
-
-    @Resource
-    FileStoreUtil fileStoreUtil;
-
-    @Resource
-    CommonCacheService commonCacheService;
+    BasicSchoolDao basicSchoolDao;
 
     @Override
-    public boolean updateSchool(Long id, String code, String name, MultipartFile logo, String logoMd5) {
-        BasicSchool basicSchool = this.getById(id);
-        basicSchool.setCode(code);
-        basicSchool.setName(name);
-
-        if (logo != null) {
-            try {
-                String toBase64 = "data:image/png;base64," + new String(Base64.getEncoder().encode(logo.getBytes()), SystemConstant.CHARSET);
-                basicSchool.setLogo(toBase64);
-            } catch (Exception e) {
-                log.error(SystemConstant.LOG_ERROR, e);
-            } finally {
-                commonCacheService.removeSchoolCache(basicSchool.getCode());
-                commonCacheService.removeSchoolCache(basicSchool.getId());
-            }
-        }
-        return this.updateById(basicSchool);
+    public List<SchoolDto> listSchool() {
+        return basicSchoolDao.listSchool();
     }
 }

+ 10 - 10
server/src/main/java/com/qmth/jkserver/service/impl/CallYunMarkApiServiceImpl.java

@@ -47,8 +47,8 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public List<Map> callStudentScoreApi(Long examId, String examCode, Map<String, String> secretMap) throws IOException {
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.CLOUDMARK_HOST_URL);
+    public List<Map> callStudentScoreApi(Long examId, String examCode, Map<String, String> secretMap, Long schoolId) throws IOException {
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.CLOUDMARK_HOST_URL);
         Optional.ofNullable(sysConfig).orElseThrow(() -> new JkServerException("未配置云阅卷地址"));
         String url = sysConfig.getConfigValue() + SystemConstant.CLOUD_MARK_STUDENT_SCORE_API;
         Map<String, Object> params = new HashMap<>();
@@ -90,7 +90,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public int callExamSaveApi(SaveExamParams saveExamParams, Map<String, String> secretMap) throws IOException, IllegalAccessException {
+    public int callExamSaveApi(SaveExamParams saveExamParams, Map<String, String> secretMap, Long schoolId) throws IOException, IllegalAccessException {
         VerifyResultParams verifyResultParams = SystemConstant.verifyDBFields(saveExamParams, saveExamParams.getClass());
         if (!verifyResultParams.getStatus()) {
             throw new JkServerException(verifyResultParams.getMessage());
@@ -108,7 +108,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
             paramMap.remove("id");
         }
 
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.CLOUDMARK_HOST_URL);
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.CLOUDMARK_HOST_URL);
         Optional.ofNullable(sysConfig).orElseThrow(() -> new JkServerException("未配置云阅卷地址"));
         String url = sysConfig.getConfigValue() + SystemConstant.CLOUD_MARK_EXAM_SAVE_API;
 
@@ -127,7 +127,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public String callSubjectSaveApi(SaveSubjectParams saveSubjectParams, Map<String, String> secretMap) throws IOException, IllegalAccessException {
+    public String callSubjectSaveApi(SaveSubjectParams saveSubjectParams, Map<String, String> secretMap, Long schoolId) throws IOException, IllegalAccessException {
         VerifyResultParams verifyResultParams = SystemConstant.verifyDBFields(saveSubjectParams, saveSubjectParams.getClass());
         if (!verifyResultParams.getStatus()) {
             throw new JkServerException(verifyResultParams.getMessage());
@@ -141,7 +141,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
 
         // 请求参数
         long timestamp = System.currentTimeMillis();
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.CLOUDMARK_HOST_URL);
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.CLOUDMARK_HOST_URL);
         Optional.ofNullable(sysConfig).orElseThrow(() -> new JkServerException("未配置云阅卷地址"));
         String url = sysConfig.getConfigValue() + SystemConstant.CLOUD_MARK_SUBJECT_SAVE_API;
         String accessToken = SignatureInfo.build(SignatureType.SECRET, SystemConstant.METHOD, SystemConstant.CLOUD_MARK_SUBJECT_SAVE_API, timestamp, secretMap.get(SystemConstant.ACCESS_KEY), secretMap.get(SystemConstant.ACCESS_SECRET));
@@ -156,7 +156,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public String callStudentSaveApi(SaveStudentParams saveStudentParams, Map<String, String> secretMap) throws IOException, IllegalAccessException {
+    public String callStudentSaveApi(SaveStudentParams saveStudentParams, Map<String, String> secretMap, Long schoolId) throws IOException, IllegalAccessException {
         VerifyResultParams verifyResultParams = SystemConstant.verifyDBFields(saveStudentParams, saveStudentParams.getClass());
         if (!verifyResultParams.getStatus()) {
             throw new JkServerException(verifyResultParams.getMessage());
@@ -169,7 +169,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
 
         // 请求参数
         long timestamp = System.currentTimeMillis();
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.CLOUDMARK_HOST_URL);
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.CLOUDMARK_HOST_URL);
         Optional.ofNullable(sysConfig).orElseThrow(() -> new JkServerException("未配置云阅卷地址"));
         String url = sysConfig.getConfigValue() + SystemConstant.CLOUD_MARK_STUDENT_SAVE_API;
         String accessToken = SignatureInfo.build(SignatureType.SECRET, SystemConstant.METHOD, SystemConstant.CLOUD_MARK_STUDENT_SAVE_API, timestamp, secretMap.get(SystemConstant.ACCESS_KEY), secretMap.get(SystemConstant.ACCESS_SECRET));
@@ -184,7 +184,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public boolean callFileUploadApi(Object obj, Map<String, String> secretMap) throws IllegalAccessException, IOException {
+    public boolean callFileUploadApi(Object obj, Map<String, String> secretMap, Long schoolId) throws IllegalAccessException, IOException {
         // 参数
         Map<String, Object> paramMap = JSON.parseObject(JSON.toJSONString(obj), Map.class);
         File file = new File(String.valueOf(paramMap.get("file")));
@@ -195,7 +195,7 @@ public class CallYunMarkApiServiceImpl implements CallYunMarkApiService {
         String type = this.verifyAndGetParamType(obj);
 
         // api
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.CLOUDMARK_HOST_URL);
+        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.CLOUDMARK_HOST_URL);
         Optional.ofNullable(sysConfig).orElseThrow(() -> new JkServerException("未配置云阅卷地址"));
         String host = sysConfig.getConfigValue();
         String api = SystemConstant.CLOUD_MARK_FILE_UPLOAD_API;

+ 5 - 4
server/src/main/java/com/qmth/jkserver/service/impl/CommonCacheServiceImpl.java

@@ -68,6 +68,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     @Override
 //    @CachePut(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", condition = "#result != null")
     public User updateUserCache(Long userId) {
+        cacheService.evict(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId));
         return userCacheCommon(userId);
     }
 
@@ -176,6 +177,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     @Override
 //    @CachePut(value = SystemConstant.SCHOOL_CACHE, key = "#p0", condition = "#result != null")
     public BasicSchool updateSchoolCache(Long schoolId) {
+        cacheService.evict(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
         return schoolCacheCommon(schoolId);
     }
 
@@ -188,6 +190,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     @Override
 //    @CachePut(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0", condition = "#result != null")
     public BasicSchool updateSchoolCache(String code) {
+        cacheService.evict(SystemConstant.SCHOOL_CODE_CACHE, code);
         return schoolCacheCommon(code);
     }
 
@@ -243,8 +246,6 @@ public class CommonCacheServiceImpl implements CommonCacheService {
             sysConfig = sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
             if (Objects.nonNull(sysConfig)) {
                 cacheService.put(SystemConstant.SYS_CONFIG_CACHE, key, sysConfig);
-            } else {
-                throw new JkServerException("key[" + key + "]系统参数不存在");
             }
         }
         return sysConfig;
@@ -271,6 +272,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     @Override
 //    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", condition = "#result != null")
     public SysConfig updateSysConfigCache(String key) {
+        cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, key);
         return sysConfigCacheCommon(key);
     }
 
@@ -309,8 +311,6 @@ public class CommonCacheServiceImpl implements CommonCacheService {
             sysConfig = sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getSchoolId, schoolId).eq(SysConfig::getConfigKey, key));
             if (Objects.nonNull(sysConfig)) {
                 cacheService.put(SystemConstant.SYS_CONFIG_CACHE, schoolId + "_" + key, sysConfig);
-            } else {
-                throw new JkServerException("schoolId,key[" + schoolId + "," + key + "]系统参数不存在");
             }
         }
         return sysConfig;
@@ -339,6 +339,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     @Override
 //    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", condition = "#result != null")
     public SysConfig updateSysConfigCache(Long schoolId, String key) {
+        cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, schoolId + "_" + key);
         return sysConfigCacheCommon(schoolId, key);
     }
 

+ 10 - 6
server/src/main/java/com/qmth/jkserver/service/impl/JointFlowSimulationServiceImpl.java

@@ -65,7 +65,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
         ExamTask examTask = (ExamTask) map.get(SystemConstant.TASK);
         User user = (User) map.get(SystemConstant.USER);
         String jkExamCode = examTask.getExamCode();
-
+        Long schoolId = (Long) map.get(SystemConstant.SCHOOL_ID);
 
         List<ExamPlan> examPlanDatasource = examPlanService.findExamPlanAllByTask();
         List<ExamPlan> examPlanList = examPlanDatasource.stream().filter(e -> jkExamCode.equals(e.getExamCode())).collect(Collectors.toList());
@@ -81,7 +81,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
 //        saveExamParams.setExamTime(DateFormatUtils.format(jkStartTime, SystemConstant.DEFAULT_DATE_PATTERN));
         saveExamParams.setExamTime(DateFormatUtils.format(new Date(jkStartTime), SystemConstant.DEFAULT_DATE_PATTERN));
         saveExamParams.setType(YunExamTypeEnum.MULTI_MEDIA.getCode());
-        int yunExamId = callYunMarkApiService.callExamSaveApi(saveExamParams, this.searchKeyAndSecretByJKExamCode(jkExamCode));
+        int yunExamId = callYunMarkApiService.callExamSaveApi(saveExamParams, this.searchKeyAndSecretByJKExamCode(jkExamCode), schoolId);
         if (yunExamId == 0) {
             // 云阅卷考试保存失败 : 不需要处理
             throw new JkServerException("调用云阅卷保存考试失败");
@@ -97,6 +97,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
     public Map<String, Object> saveYunSubject(Map<String, Object> map) throws Exception {
         ExamTask examTask = (ExamTask) map.get(SystemConstant.TASK);
         User user = (User) map.get(SystemConstant.USER);
+        Long schoolId = (Long) map.get(SystemConstant.SCHOOL_ID);
         BigDecimal totalProgress = examTask.getTotalProgress();
         AtomicInteger completeProgress;
 
@@ -138,7 +139,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
             saveSubjectParams.setExamId(yunExamId);
             saveSubjectParams.setCode(yunSubjectCode);
             saveSubjectParams.setName(courseName);
-            String updateTime = callYunMarkApiService.callSubjectSaveApi(saveSubjectParams, this.searchKeyAndSecretByJKExamCode(jkExamCode));
+            String updateTime = callYunMarkApiService.callSubjectSaveApi(saveSubjectParams, this.searchKeyAndSecretByJKExamCode(jkExamCode), schoolId);
             if (updateTime != null && updateTime.length() > 0 && !updateTime.equals("null")) {
                 List<File> paperFileList = paperAndAnswerFileDatasource.stream()
                         .filter(e -> (yunSubjectCode + SystemConstant.JSON_PREFIX).equals(e.getName())).collect(Collectors.toList());
@@ -218,6 +219,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
     public Map<String, Object> saveYunExamStudent(Map<String, Object> map, int yunExamId, List<ExamStudentAnswer> examStudentAnswerList, List<File> studentAnswerFileDatasource) throws IOException, IllegalAccessException {
         ExamTask examTask = (ExamTask) map.get(SystemConstant.TASK);
         String jkExamCode = examTask.getExamCode();
+        Long schoolId = (Long) map.get(SystemConstant.SCHOOL_ID);
 
         for (ExamStudentAnswer examStudentAnswer : examStudentAnswerList) {
             ExamStudent examStudent = examStudentService.getById(examStudentAnswer.getStudentId());
@@ -250,7 +252,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
             saveStudentParams.setSubjectName(courseName);
             saveStudentParams.setExamSite(placeCode);
             saveStudentParams.setExamRoom(roomCode);
-            String updateTime = callYunMarkApiService.callStudentSaveApi(saveStudentParams, this.searchKeyAndSecretByJKExamCode(jkExamCode));
+            String updateTime = callYunMarkApiService.callStudentSaveApi(saveStudentParams, this.searchKeyAndSecretByJKExamCode(jkExamCode), schoolId);
 
             if (updateTime != null && updateTime.length() > 0 && !updateTime.equals("null")) {
                 if (!isAbsent && studentAnswerFileDatasource != null && studentAnswerFileDatasource.size() > 0) {
@@ -282,6 +284,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
     @Override
     public Map<String, Object> savePaperAndAnswer(Map<String, Object> map, int yunExamId, String subjectCode, File file) throws IOException, IllegalAccessException {
         ExamTask examTask = (ExamTask) map.get(SystemConstant.TASK);
+        Long schoolId = (Long) map.get(SystemConstant.SCHOOL_ID);
         String jkExamCode = examTask.getExamCode();
 
         PaperFileParams paperFileParams = new PaperFileParams();
@@ -290,13 +293,14 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
         paperFileParams.setFile(file);
         paperFileParams.setFormat("json");
         // 调用云阅卷上传附件接口
-        callYunMarkApiService.callFileUploadApi(paperFileParams, this.searchKeyAndSecretByJKExamCode(jkExamCode));
+        callYunMarkApiService.callFileUploadApi(paperFileParams, this.searchKeyAndSecretByJKExamCode(jkExamCode), schoolId);
         return map;
     }
 
     @Override
     public Map<String, Object> saveStudentJson(Map<String, Object> map, int yunExamId, String examNumber, File file) throws IOException, IllegalAccessException {
         ExamTask examTask = (ExamTask) map.get(SystemConstant.TASK);
+        Long schoolId = (Long) map.get(SystemConstant.SCHOOL_ID);
         String jkExamCode = examTask.getExamCode();
 
         JsonFileParams jsonFileParams = new JsonFileParams();
@@ -304,7 +308,7 @@ public class JointFlowSimulationServiceImpl implements JointFlowSimulationServic
         jsonFileParams.setExamNumber(examNumber);
         jsonFileParams.setFile(file);
         // 调用云阅卷上传附件接口
-        callYunMarkApiService.callFileUploadApi(jsonFileParams, this.searchKeyAndSecretByJKExamCode(jkExamCode));
+        callYunMarkApiService.callFileUploadApi(jsonFileParams, this.searchKeyAndSecretByJKExamCode(jkExamCode), schoolId);
 
         AtomicInteger completeProgress = new AtomicInteger(examTask.getCompleteProgress());
         completeProgress.incrementAndGet();

+ 3 - 0
server/src/main/resources/mapper/BasicSchoolMapper.xml

@@ -2,4 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.jkserver.dao.BasicSchoolDao">
 
+    <select id="listSchool" resultType="com.qmth.jkserver.dto.SchoolDto">
+        select id, code, name, enable, access_key accessKey, access_secret accessSecret, logo from basic_school where enable = true order by create_time desc
+    </select>
 </mapper>