| | |
| | | @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; |
| | |
| | | @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,"批次(班级)不可为空"); |
| | | } |
| | |
| | | @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)){ |
| | |
| | | } |
| | | saveCertReqDTOList.add(thCertReqDTO); |
| | | } |
| | | |
| | | List<ThCert> saveCertList = new ArrayList<>(); |
| | | List<ThCert> updateCertList = new ArrayList<>(); |
| | | for (ThCertReqDTO thCertReqDTO : saveCertReqDTOList) { |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |