diff --git a/src/main/java/com/sztzjy/marketing/controller/tch/SummaryOfGradesController.java b/src/main/java/com/sztzjy/marketing/controller/tch/SummaryOfGradesController.java index e7593e2..038a171 100644 --- a/src/main/java/com/sztzjy/marketing/controller/tch/SummaryOfGradesController.java +++ b/src/main/java/com/sztzjy/marketing/controller/tch/SummaryOfGradesController.java @@ -11,6 +11,7 @@ import com.sztzjy.marketing.entity.tchdto.TchGeneralViewWeightDTO; import com.sztzjy.marketing.entity.tchdto.tchScoreViewShowDTO; import com.sztzjy.marketing.mapper.StuPracticalTrainingReportMapper; import com.sztzjy.marketing.mapper.StuScoreDetailsMapper; +import com.sztzjy.marketing.mapper.StuUserMapper; import com.sztzjy.marketing.mapper.TchModuleWeithMapper; import com.sztzjy.marketing.service.TchUserService; import com.sztzjy.marketing.util.ResultEntity; @@ -20,11 +21,15 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; /** * @author 17803 @@ -46,6 +51,11 @@ public class SummaryOfGradesController { @Autowired private StuScoreDetailsMapper stuScoreDetailsMapper; + @Autowired + private StuUserMapper userMapper; + + + @PostMapping("/getGeneralViewList") @ApiOperation("成绩总览展示 (条件查询)") //@AnonymousAccess @@ -61,7 +71,7 @@ public class SummaryOfGradesController { @ApiOperation("成绩总览导出") @GetMapping("/generalViewExport") - //@AnonymousAccess + @AnonymousAccess public void generalViewExport(HttpServletResponse response, @RequestParam String schoolId) { //导出的表名 String title = IdUtil.simpleUUID(); @@ -181,19 +191,101 @@ public class SummaryOfGradesController { */ @PostMapping("/ratingAndComment") @ApiOperation("老师输入评语和打分") + @Transactional(rollbackFor = Exception.class) + @AnonymousAccess public void ratingAndComment(@RequestBody StuPracticalTrainingReport practicalTrainingReport) { - stuPracticalTrainingReportMapper.updateByPrimaryKeySelective(practicalTrainingReport); - if (practicalTrainingReport.getRating() != null) { + + StuPracticalTrainingReport stuPracticalTrainingReport = stuPracticalTrainingReportMapper.selectByPrimaryKey(practicalTrainingReport.getId()); + stuPracticalTrainingReport.setRating(practicalTrainingReport.getRating()); + stuPracticalTrainingReport.setTeacherComments(practicalTrainingReport.getTeacherComments()); + stuPracticalTrainingReportMapper.updateByPrimaryKeySelective(stuPracticalTrainingReport); + + if (stuPracticalTrainingReport.getRating() != null) { + + String userid = stuPracticalTrainingReport.getUserid(); + + StuPracticalTrainingReportExample example = new StuPracticalTrainingReportExample(); + example.createCriteria().andUseridEqualTo(userid); + List stuPracticalTrainingReportList = stuPracticalTrainingReportMapper.selectByExample(example); + + List arrayList = new ArrayList<>(7); + arrayList.add("AI文生图"); + arrayList.add("AI修图"); + arrayList.add("AI视频"); + arrayList.add("AI写作"); + arrayList.add("AI数据分析"); + arrayList.add("BI可视化分析"); + + double avg = 0.0; + int times = 0; + + for (String module : arrayList) { + + //获取当前用户 已评分 对应model的报告数量 + List collect = stuPracticalTrainingReportList.stream() + .filter(item -> item.getModule().equals(module)).filter(item->item.getRating()!=null) + .collect(Collectors.toList()); + if (collect.isEmpty()) + { + continue; + } + + //当前模块总分 + double sum = collect.stream().mapToDouble(item -> item.getRating()).sum(); + + + //四舍五入 + double count = sum / collect.size(); + double roundedCount = Math.round(count * 100.0) / 100.0; + + + avg = avg + roundedCount; + + times ++ ; + } + + //所有模块平均分 + + //四舍五入 + double avgAllModule = avg / 6; + double avgScore = Math.round(avgAllModule * 100.0) / 100.0; + + + //获取当前模块的所有实验报告 StuScoreDetailsExample stuScoreDetailsExample =new StuScoreDetailsExample(); stuScoreDetailsExample.createCriteria().andUserIdEqualTo(practicalTrainingReport.getUserid()).andSerialNumberEqualTo(5); List stuScoreDetails = stuScoreDetailsMapper.selectByExample(stuScoreDetailsExample); if (!stuScoreDetails.isEmpty()){ StuScoreDetails stuScoreDetails1 = stuScoreDetails.get(0); - stuScoreDetails1.setScoreProject(practicalTrainingReport.getRating()); + stuScoreDetails1.setScoreProject(avgScore); stuScoreDetailsMapper.updateByPrimaryKey(stuScoreDetails1); } + + StuUser stuUserList = userMapper.selectByPrimaryKey(userid); + if (stuUserList != null){ + stuUserList.setTestReportSocre(BigDecimal.valueOf(avgScore)); + userMapper.updateByPrimaryKeySelective(stuUserList); + + } + + } + + } + + @GetMapping("/getReportFileURLByUserIdAndModule") + @ApiOperation("单条学生报告") + @AnonymousAccess + public ResultEntity getReportFileURLByUserIdAndModule(@RequestParam Integer reportId){ + + StuPracticalTrainingReport stuPracticalTrainingReport = stuPracticalTrainingReportMapper.selectByPrimaryKey(reportId); + if (stuPracticalTrainingReport==null) { + return new ResultEntity<>(HttpStatus.OK,"实验报告不存在!"); + } + + return new ResultEntity<>(HttpStatus.OK,"获取成功",stuPracticalTrainingReport.getUrl()); + } diff --git a/src/main/java/com/sztzjy/marketing/entity/dto/TchrePortPresentationDTO.java b/src/main/java/com/sztzjy/marketing/entity/dto/TchrePortPresentationDTO.java index 8c68cda..1edeede 100644 --- a/src/main/java/com/sztzjy/marketing/entity/dto/TchrePortPresentationDTO.java +++ b/src/main/java/com/sztzjy/marketing/entity/dto/TchrePortPresentationDTO.java @@ -26,4 +26,10 @@ public class TchrePortPresentationDTO { @ApiModelProperty("文件大小") private Double fileSize; private String ascription; + @ApiModelProperty("教师评分") + private Double rating; + private Integer reportId; + @ApiModelProperty("用户id") + private String userId; + } diff --git a/src/main/java/com/sztzjy/marketing/entity/tchdto/TchGeneralViewInfoDTO.java b/src/main/java/com/sztzjy/marketing/entity/tchdto/TchGeneralViewInfoDTO.java index 1f14d0c..e07dafc 100644 --- a/src/main/java/com/sztzjy/marketing/entity/tchdto/TchGeneralViewInfoDTO.java +++ b/src/main/java/com/sztzjy/marketing/entity/tchdto/TchGeneralViewInfoDTO.java @@ -71,25 +71,31 @@ public class TchGeneralViewInfoDTO { this.className=stuUser.getClassName(); //知识概要 - this.summaryKnowledgeScore=stuUser.getSummaryKnowledgeScore().multiply(resultsOverviewWeight.getSummaryOfKnowledgeWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.summaryKnowledgeScore=stuUser.getSummaryKnowledgeScore() + .multiply(resultsOverviewWeight.getSummaryOfKnowledgeWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); this.summaryKnowledgeWeight=resultsOverviewWeight.getSummaryOfKnowledgeWeight(); //资源学习 - this.resourceScore=stuUser.getResourceScore().multiply(resultsOverviewWeight.getResourceLearningWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.resourceScore=stuUser.getResourceScore() + .multiply(resultsOverviewWeight.getResourceLearningWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); this.resourceWeiht=resultsOverviewWeight.getResourceLearningWeight(); //学习测评 - this.learningAssessmentScore=stuUser.getLearningAssessmentScore().multiply(resultsOverviewWeight.getLearningAssessmentWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.learningAssessmentScore=stuUser.getLearningAssessmentScore() + .multiply(resultsOverviewWeight.getLearningAssessmentWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); this.learningAssessmentWeiht=resultsOverviewWeight.getLearningAssessmentWeight(); //实验实训 - this.experimentTrainingScore=stuUser.getExperimentTrainingScore().multiply(resultsOverviewWeight.getExperimentalTrainingWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); - this.learningAssessmentWeiht=resultsOverviewWeight.getExperimentalTrainingWeight(); + this.experimentTrainingScore=stuUser.getExperimentTrainingScore() + .multiply(resultsOverviewWeight.getExperimentalTrainingWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.experimentTrainingWeith=resultsOverviewWeight.getExperimentalTrainingWeight(); + //实验报告 - this.testReportSocre=stuUser.getTestReportSocre().multiply(resultsOverviewWeight.getReportWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); + this.testReportSocre=stuUser.getTestReportSocre() + .multiply(resultsOverviewWeight.getReportWeight()).setScale(2,BigDecimal.ROUND_HALF_UP); this.testReportWeith=resultsOverviewWeight.getReportWeight(); diff --git a/src/main/java/com/sztzjy/marketing/service/impl/TchUserServiceImpl.java b/src/main/java/com/sztzjy/marketing/service/impl/TchUserServiceImpl.java index 2746bb9..752afc2 100644 --- a/src/main/java/com/sztzjy/marketing/service/impl/TchUserServiceImpl.java +++ b/src/main/java/com/sztzjy/marketing/service/impl/TchUserServiceImpl.java @@ -153,8 +153,6 @@ public class TchUserServiceImpl implements TchUserService { PageHelper.startPage(page,size); - - List tchrePortPresentationDTOList = stuPracticalTrainingReportMapper.selectInfoBySchoolId(schoolId); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 907248d..4c4fdbb 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -1,10 +1,19 @@ +#spring: +# datasource: +# druid: +# db-type: mysql +# url: jdbc:mysql://${DB_HOST:118.31.7.2}:${DB_PORT:3306}/${DB_NAME:tz_digital_marketing}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true&allowPublicKeyRetrieval=true&allowMultiQueries=true +# username: ${DB_USER:root} +# password: ${DB_PWD:sztzjy2017} +# driver-class-name: com.mysql.cj.jdbc.Driver + spring: datasource: druid: db-type: mysql - url: jdbc:mysql://${DB_HOST:118.31.7.2}:${DB_PORT:3306}/${DB_NAME:tz_digital_marketing}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true&allowPublicKeyRetrieval=true&allowMultiQueries=true + url: jdbc:mysql://${DB_HOST:120.79.54.255}:${DB_PORT:3306}/${DB_NAME:tz_digital_marketing}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&useInformationSchema=true&allowPublicKeyRetrieval=true&allowMultiQueries=true username: ${DB_USER:root} - password: ${DB_PWD:sztzjy2017} + password: ${DB_PWD:Sztzjy506} driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1ba3296..bc9d045 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -5,6 +5,12 @@ server: tomcat: max-connections: 5000 relaxedQueryChars: <,>, [,],^,`,{,|,} + ssl: + key-store: classpath:szyx.sztzjy.com.pfx + key-store-password: u15a19un + key-store-type: PKCS12 + enabled: true + client-auth: none spring: application: name: digital_marketing diff --git a/src/main/resources/mappers/StuPracticalTrainingReportMapper.xml b/src/main/resources/mappers/StuPracticalTrainingReportMapper.xml index c488220..1415fe0 100644 --- a/src/main/resources/mappers/StuPracticalTrainingReportMapper.xml +++ b/src/main/resources/mappers/StuPracticalTrainingReportMapper.xml @@ -348,8 +348,8 @@