kongzy
2024-10-12 2ceb5cc35cdbe61a738b2864db5411a4ddc5da50
优化
已修改4个文件
114 ■■■■■ 文件已修改
exam-system/src/main/java/com/gkhy/exam/institutionalaccess/model/query/ThCertQuery.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/serviceImpl/TripartiteInterfaceServiceImpl.java 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/resources/mapper/institutionaccess/ThCertMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/institutionalaccess/model/query/ThCertQuery.java
@@ -10,10 +10,10 @@
    private String institutionName;
    //证书生成开始时间
    private LocalDateTime startTime;
    private String startTime;
    //证书生成结束时间
    private LocalDateTime endTime;
    private String endTime;
    //机构代码
    private String trainOrgName;
exam-system/src/main/java/com/gkhy/exam/institutionalaccess/service/serviceImpl/TripartiteInterfaceServiceImpl.java
@@ -71,34 +71,14 @@
    @Override
    public boolean receiveQuestionBank(JSONObject jsonObject) throws Exception {
        InstitutionUser institutionUser = ThreeInContextHolder.getContext();
        String data = jsonObject.getString("data");
        if(StringUtils.isEmpty(data)){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        ThQuestionBankReqDTO questionBankReqDTO =   decryptData(jsonObject, new TypeReference<ThQuestionBankReqDTO>() {});
        if(questionBankReqDTO==null){
            throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"题库数据不可为空");
        }
        //解密
        String decrypt = "";
        try {
            decrypt = AESUtils.decrypt(data);
        }catch (Exception e){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        }
        //反序列化
        ThQuestionBankReqDTO questionBankReqDTO = null;
        try {
            questionBankReqDTO = JSONObject.parseObject(decrypt, new TypeReference<ThQuestionBankReqDTO>() {});
        }catch (Exception e){
            logger.error("组卷反序列化失败!");
            throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
        }
        String valdateMessage=ValidatorUtils.validateFast(questionBankReqDTO);
        if(!StringUtils.isEmpty(valdateMessage)){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,valdateMessage);
        }
        //根据uuid查询数据
        ThQuestionBank qb = questionBankService.getQuestionInfoByUuid(questionBankReqDTO.getUuid());
        boolean i = true;
@@ -1815,26 +1795,7 @@
    @Override
    public AjaxResult receiveBatchEnd(JSONObject jsonObject) {
        InstitutionUser institutionUser = ThreeInContextHolder.getContext();
        String data = jsonObject.getString("data");
        if(StringUtils.isEmpty(data)){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        }
        //解密
        String decrypt = "";
        try {
            decrypt = AESUtils.decrypt(data);
        }catch (Exception e){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        }
        //反序列化
        ThBatchEndReqDTO thBatchEndReqDTO = null;
        try {
            thBatchEndReqDTO = JSONObject.parseObject(decrypt, new TypeReference<ThBatchEndReqDTO>() {});
        }catch (Exception e){
            logger.error("班级结束反序列化失败!");
            throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
        }
        ThBatchEndReqDTO thBatchEndReqDTO = decryptData(jsonObject, new TypeReference<ThBatchEndReqDTO>() {});
        if(thBatchEndReqDTO == null){
            throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次(班级)不可为空");
        }
@@ -1857,36 +1818,16 @@
    @Override
    public AjaxResult receiveCerts(JSONObject jsonObject) throws Exception {
        InstitutionUser institutionUser = ThreeInContextHolder.getContext();
        String data = jsonObject.getString("data");
        if(StringUtils.isEmpty(data)){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        }
        //解密
        String decrypt = "";
        try {
            decrypt = AESUtils.decrypt(data);
        }catch (Exception e){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        }
        //反序列化
        List<ThCertReqDTO> thCertReqDTOs = null;
        try {
            thCertReqDTOs = JSONObject.parseObject(decrypt, new TypeReference<List<ThCertReqDTO>>() {});
        }catch (Exception e){
            logger.error("学时证书反序列化失败!");
            throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
        }
        List<ThCertReqDTO> thCertReqDTOs = decryptData(jsonObject, new TypeReference<List<ThCertReqDTO>>() {});
        if(thCertReqDTOs.isEmpty() ||thCertReqDTOs.size()>50){
            throw new BusinessException(this.getClass(), ResultConstants.RECORD_OVER_MAX);
        }
        //错误
        List<ThErrorDataRespDTO> errorDataRespDTOS = new ArrayList<>();
        List<ThCertReqDTO> saveCertReqDTOList = new ArrayList<>();
        List<String> batchUuidList=thCertReqDTOs.stream().map(ThCertReqDTO::getBatchUuid).filter(batchUuid -> !StringUtils.isEmpty(batchUuid)).distinct().collect(Collectors.toList());
        //获取批次
        List<ThBatch> batchList = batchService.getByUuids(batchUuidList);
        for(ThCertReqDTO thCertReqDTO : thCertReqDTOs){
            String validateMessage=ValidatorUtils.validateFast(thCertReqDTO);
            if(!StringUtils.isEmpty(validateMessage)){
@@ -1900,7 +1841,6 @@
            }
            saveCertReqDTOList.add(thCertReqDTO);
        }
        List<ThCert> saveCertList = new ArrayList<>();
        List<ThCert> updateCertList = new ArrayList<>();
        for (ThCertReqDTO thCertReqDTO : saveCertReqDTOList) {
@@ -1939,8 +1879,31 @@
        return AjaxResult.success(errorDataRespDTOS);
    }
    private void validate(){
    /**
     * 解密数据
     * @param jsonObject
     * @param typeReference
     * @return
     * @param <T>
     */
    private <T> T decryptData(JSONObject jsonObject,TypeReference<T> typeReference){
        String data = jsonObject.getString("data");
        if(StringUtils.isEmpty(data)){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        }
        //解密
        String decrypt = "";
        try {
            decrypt = AESUtils.decrypt(data);
        }catch (Exception e){
            throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
        }
        try {
            return JSONObject.parseObject(decrypt,typeReference);
        }catch (Exception e){
            logger.error("学时证书反序列化失败!");
            throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
        }
    }
exam-system/src/main/resources/mapper/institutionaccess/ThCertMapper.xml
@@ -12,10 +12,10 @@
                 and a.institution_name =#{institutionName}
            </if>
            <if test="startTime!=null and startTime!=''">
                and a.cert_ime &gt;= #{startTime}
                and a.cert_time &gt;= #{startTime}
            </if>
            <if test="endTime!=null and endTime!=''">
                and a.cert_ime &lt;= #{endTime}
                and a.cert_time &lt;= #{endTime}
            </if>
            <if test="trainOrgName!=null and trainOrgName!=''">
                and a.train_org_name =#{trainOrgName}
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java
@@ -1,7 +1,13 @@
package com.ruoyi.framework.config;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.TimeZone;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -19,12 +25,15 @@
@MapperScan({"com.ruoyi.**.mapper","com.gkhy.**.mapper"})
public class ApplicationConfig
{
    @Value("${spring.jackson.date-format:yyyy-MM-dd HH:mm:ss}")
    private String pattern;
    /**
     * 时区配置
     */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization()
    {
        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
    }
}