添加时间统计

master
whb 7 months ago
parent b8d0b92a51
commit c45ccd7ef2

@ -8,7 +8,11 @@ import org.springframework.stereotype.Component;
@Component
public class Constant {
public static final String ZSGY_TCHMODULE = "知识概要";
public static final String ZYXX_TCHMODULE = "资源学习";
public static final String XXCP_TCHMODULE = "学习测评";
public static final String SYSX_TCHMODULE = "实验实训";
public static final String SYBG_TCHMODULE = "实验报告";
public static final String JUPYTERHUB_API_URL = "http://120.78.220.29:8000/hub/api";
public static final String ADMIN_TOKEN = "170bed30b34242cfb3fda3171e1a111d"; // 替换为你的JupyterHub管理员API令牌

@ -6,10 +6,7 @@ import com.nimbusds.jose.shaded.gson.Gson;
import com.sztzjy.marketing.annotation.AnonymousAccess;
import com.sztzjy.marketing.config.security.TokenProvider;
import com.sztzjy.marketing.entity.StuPracticalTrainingReport;
import com.sztzjy.marketing.entity.StuResources;
import com.sztzjy.marketing.entity.StuResourcesExample;
import com.sztzjy.marketing.entity.StuScoreDetails;
import com.sztzjy.marketing.entity.*;
import com.sztzjy.marketing.entity.dto.StuAssessmentQuestionDetailsDTO;
import com.sztzjy.marketing.entity.dto.StuBlockProductWithDTO;
import com.sztzjy.marketing.entity.dto.StuLearningAssessmentScoreDTO;
@ -185,4 +182,15 @@ public class StuConceptBlockController {
return ResponseEntity.notFound().build();
}
@AnonymousAccess
@ApiOperation("哈希函数资源学习分数统计")
@PostMapping("/hashWatchScore")
public ResultDataEntity<StuScoreDetails> hashWatchScore(@RequestBody JSONObject jsonObject) {
StuScoreDetailsDTO stuScoreDetailsDTO = jsonObject.getObject("stuScoreDetailsDTO", StuScoreDetailsDTO.class);
stuConceptBlockService.hashWatchScore(stuScoreDetailsDTO);
return new ResultDataEntity<>(HttpStatus.OK);
}
}

@ -0,0 +1,59 @@
package com.sztzjy.marketing.entity;
import com.sztzjy.marketing.config.Constant;
import lombok.Data;
/**
* @author tz
* @date 2023/9/2 13:34
*/
@Data
public class StuScoreDetailsDTO {
private String id;
private String learningProjects; //学习项目
private String assessmentItems; //考核项目
private String scoringCriteria; //计分标准
private Double scoreWeight; //成绩权重
private int viewingTime;
private Double scoreProject; //项目得分
private String module; //归属模块
private String userId; //用户id
private String completionStatus; //完成情况
public StuScoreDetailsDTO() {
}
public StuScoreDetailsDTO(StuScoreDetails stuScoreDetails, TchModuleWeith tchConceptualTechnologyWeight) {
this.id=stuScoreDetails.getId();
this.learningProjects=stuScoreDetails.getLearningProjects();
this.assessmentItems=stuScoreDetails.getAssessmentItems();
//根据学习项目判断获取的权重类型
if (Constant.ZSGY_TCHMODULE.equals(stuScoreDetails.getLearningProjects())){
this.scoringCriteria= String.valueOf(tchConceptualTechnologyWeight.getSummaryOfKnowledgeScore());
this.scoreWeight=tchConceptualTechnologyWeight.getSummaryOfKnowledgeWeight().doubleValue();
}else if (Constant.ZYXX_TCHMODULE.equals(stuScoreDetails.getLearningProjects())){
this.scoringCriteria= String.valueOf(tchConceptualTechnologyWeight.getResourceLearningScore());
this.scoreWeight=tchConceptualTechnologyWeight.getResourceLearningWeight().doubleValue();
}else if (Constant.XXCP_TCHMODULE.equals(stuScoreDetails.getLearningProjects())){
this.scoringCriteria= String.valueOf(tchConceptualTechnologyWeight.getLearningAssessmentScore());
this.scoreWeight=tchConceptualTechnologyWeight.getLearningAssessmentWeight().doubleValue();
}else if (Constant.SYSX_TCHMODULE.equals(stuScoreDetails.getLearningProjects())){
this.scoringCriteria= String.valueOf(tchConceptualTechnologyWeight.getExperimentalTrainingScore());
this.scoreWeight=tchConceptualTechnologyWeight.getExperimentalTrainingWeight().doubleValue();
}else if(Constant.SYBG_TCHMODULE.equals(stuScoreDetails.getLearningProjects())){
this.scoreWeight=tchConceptualTechnologyWeight.getReportWeight().doubleValue();
}
this.completionStatus=stuScoreDetails.getCompletionStatus();
this.scoreProject=stuScoreDetails.getScoreProject();
}
}

@ -4,6 +4,7 @@ package com.sztzjy.marketing.service;
import com.sztzjy.marketing.entity.StuPracticalTrainingReport;
import com.sztzjy.marketing.entity.StuResources;
import com.sztzjy.marketing.entity.StuScoreDetailsDTO;
import com.sztzjy.marketing.entity.dto.StuAssessmentQuestionDetailsDTO;
import com.sztzjy.marketing.entity.dto.StuBlockProductWithDTO;
import com.sztzjy.marketing.entity.dto.StuLearningAssessmentScoreDTO;
@ -41,4 +42,5 @@ public interface StuConceptBlockService {
void OutPdf( HttpServletResponse response, String context);
void hashWatchScore(StuScoreDetailsDTO stuScoreDetailsDTO);
}

@ -114,23 +114,23 @@ public class QianFanBigModuleServiceImpl implements QianFanBigModuleService {
@Override
public Flux<String> createArticleByMessage(List<Message> messageList) {
int count = 0;
for (Message message : messageList) {
int length = message.getContent().length();
count += length;
}
System.out.println(count);
StuAiLimitExample limitExample = new StuAiLimitExample();
limitExample.createCriteria().andUserIdEqualTo(messageList.get(0).getUserId());
List<StuAiLimit> stuAiLimits = stuAiLimitMapper.selectByExample(limitExample);
if (stuAiLimits.get(0).getLimitState()== (byte) 1 || 30 < stuAiLimits.get(0).getWordNumber()) {
throw new RuntimeException("您的使用已达到今日限额,请明日再试。");
}
stuAiLimits.get(0).setWordNumber(stuAiLimits.get(0).getWordNumber() + count);
stuAiLimitMapper.updateByPrimaryKeySelective(stuAiLimits.get(0));
// int count = 0;
// for (Message message : messageList) {
// int length = message.getContent().length();
// count += length;
// }
// System.out.println(count);
//
// StuAiLimitExample limitExample = new StuAiLimitExample();
// limitExample.createCriteria().andUserIdEqualTo(messageList.get(0).getUserId());
// List<StuAiLimit> stuAiLimits = stuAiLimitMapper.selectByExample(limitExample);
//
//
// if (stuAiLimits.get(0).getLimitState()== (byte) 1 || 30 < stuAiLimits.get(0).getWordNumber()) {
// throw new RuntimeException("您的使用已达到今日限额,请明日再试。");
// }
// stuAiLimits.get(0).setWordNumber(stuAiLimits.get(0).getWordNumber() + count);
// stuAiLimitMapper.updateByPrimaryKeySelective(stuAiLimits.get(0));
String accesstoken = null;

@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.marketing.config.Constant;
import com.sztzjy.marketing.config.exception.handler.ServiceException;
import com.sztzjy.marketing.entity.*;
import com.sztzjy.marketing.entity.dto.StuAssessmentQuestionDetailsDTO;
@ -13,10 +14,12 @@ import com.sztzjy.marketing.entity.dto.StuLearningAssessmentDTO;
import com.sztzjy.marketing.entity.dto.StuLearningAssessmentScoreDTO;
import com.sztzjy.marketing.mapper.*;
import com.sztzjy.marketing.service.StuConceptBlockService;
import com.sztzjy.marketing.util.BigDecimalUtils;
import com.sztzjy.marketing.util.ConvertUtil;
import com.sztzjy.marketing.util.PdfUtil;
import com.sztzjy.marketing.util.compute.ScoringUtil;
import com.sztzjy.marketing.util.file.IFileUtil;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
@ -79,6 +82,8 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService {
@Resource
ScoringUtil scoringUtil;
@Resource
BigDecimalUtils bigDecimalUtils;
//区块链学习资源查看
@Override
@ -550,5 +555,78 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService {
return tempFile;
}
/**
*
*
* @param stuScoreDetailsDTO DTO
*/
@Override
public void hashWatchScore(StuScoreDetailsDTO stuScoreDetailsDTO) {
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andUserIdEqualTo(stuScoreDetailsDTO.getUserId());
List<StuUser> stuUsers = stuUserMapper.selectByExample(stuUserExample);
StuUser stuUser = stuUsers.get(0);
TchModuleWeithExample example = new TchModuleWeithExample();
example.createCriteria().andSchoolIdEqualTo(stuUser.getSchoolId());
List<TchModuleWeith> tchConceptualTechnologyWeights = tchModuleWeithMapper.selectByExample(example);
if(tchConceptualTechnologyWeights.size()==0){
TchModuleWeith tchConceptualTechnologyWeight=new TchModuleWeith(stuUser.getSchoolId());
tchModuleWeithMapper.insert(tchConceptualTechnologyWeight);
tchConceptualTechnologyWeights.add(tchConceptualTechnologyWeight);
}
TchModuleWeith tchConceptualTechnologyWeight = tchConceptualTechnologyWeights.get(0);
//时间转换成分钟
double i = (double) stuScoreDetailsDTO.getViewingTime() / 60;
double floor = Math.floor(i);
double stuResourcesScoring = scoringUtil.getStuResourcesScoring(floor, Double.parseDouble(String.valueOf(tchConceptualTechnologyWeight.getResourceLearningScore())));
stuScoreDetailsDTO.setScoringCriteria(String.valueOf(tchConceptualTechnologyWeight.getResourceLearningScore()));
stuScoreDetailsDTO.setScoreWeight(Double.parseDouble(String.valueOf(tchConceptualTechnologyWeight.getResourceLearningWeight())));
//将DTO转为Entity
StuScoreDetails stuScoreDetails = convertUtil.DTOToEntity(stuScoreDetailsDTO, StuScoreDetails.class);
stuScoreDetails.setScoreProject(stuResourcesScoring);
stuScoreDetails.setCompletionStatus(String.valueOf(floor));
stuScoreDetails.setSerialNumber(2);
stuScoreDetails.setLearningProjects("资源学习");
stuScoreDetails.setAssessmentItems("观看资源");
//判断数据是否存在
StuScoreDetailsExample example1 = new StuScoreDetailsExample();
StuScoreDetailsExample.Criteria criteria1 = example1.createCriteria();
criteria1.andUserIdEqualTo(stuScoreDetailsDTO.getUserId())
.andLearningProjectsEqualTo(stuScoreDetails.getLearningProjects());
List<StuScoreDetails> scoreDetailsList1 = stuScoreDetailsMapper.selectByExample(example1);
if (scoreDetailsList1.size() == 0) {
//不存在则添加数据
stuScoreDetails.setId(UUID.randomUUID().toString());
stuScoreDetailsMapper.insert(stuScoreDetails);
} else {
//分数累加
Double scoreProject = scoreDetailsList1.get(0).getScoreProject();
Double scoreProject1 = stuScoreDetails.getScoreProject();
BigDecimal add = bigDecimalUtils.add(scoreProject.toString(), scoreProject1.toString());
//时间累加
String completionStatus = scoreDetailsList1.get(0).getCompletionStatus();
String completionStatus1 = stuScoreDetails.getCompletionStatus();
BigDecimal add1 = bigDecimalUtils.add(completionStatus, completionStatus1);
stuScoreDetails.setScoreProject(Double.parseDouble(add.toString()));
stuScoreDetails.setCompletionStatus(add1.toString());
stuScoreDetailsMapper.updateByExampleSelective(stuScoreDetails, example1);
}
//
// //将分数统计到学生表中
// this.personalScoreEntry(stuScoreDetailsDTO.getUserId(),stuScoreDetailsDTO.getModule());
}
}

Loading…
Cancel
Save