From a56fef3eda8d3088e1123691311e95e909fadaa1 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Fri, 25 Apr 2025 09:07:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=A6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=BB=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stu/IndustryDemandAnalysisController.java | 49 ++++++++++++++++++- .../entity/dto/StuIndustryAnalysisDTO.java | 16 ++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java b/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java index 2213df2..a47ac8c 100644 --- a/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java +++ b/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java @@ -1,5 +1,6 @@ package com.sztzjy.linkCommerce.controller.stu; +import cn.hutool.core.convert.Convert; import cn.hutool.core.util.IdUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; @@ -12,6 +13,7 @@ import com.sztzjy.linkCommerce.entity.dto.YearCakeIndexDto; import com.sztzjy.linkCommerce.mapper.HyxqfxAnswerMapper; import com.sztzjy.linkCommerce.mapper.HyxqfxDataMapper; import com.sztzjy.linkCommerce.mapper.HyxqfxStuAnswerMapper; +import com.sztzjy.linkCommerce.mapper.StuGradeMapper; import com.sztzjy.linkCommerce.service.IndustryDemandAnalysisService; import com.sztzjy.linkCommerce.util.ResultEntity; import com.sztzjy.linkCommerce.util.excel.DataListener; @@ -28,6 +30,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.math.BigDecimal; import java.util.*; /** @@ -49,6 +52,9 @@ public class IndustryDemandAnalysisController { @Autowired private HyxqfxStuAnswerMapper hyxqfxStuAnswerMapper; + @Autowired + private StuGradeMapper stuGradeMapper; + @@ -68,8 +74,7 @@ public class IndustryDemandAnalysisController { return new ResultEntity<>(HttpStatus.OK); } - //读取文件内容 批量导入excel中 以文件名区分\ - + //读取文件内容 批量导入excel中 以文件名区分 Map yearMap = new HashMap<>(); yearMap.put("2018年",0.28); yearMap.put("2019年",0.25); @@ -125,6 +130,8 @@ public class IndustryDemandAnalysisController { hyxqfxStuAnswerMapper.insertSelective(hyxqfxStuAnswer); + + //插入主观题 SubjectiveQuestions subjectiveQuestions = new SubjectiveQuestions(); subjectiveQuestions.setId(IdUtil.randomUUID()); @@ -135,6 +142,44 @@ public class IndustryDemandAnalysisController { subjectiveQuestions.setSubjectiveContent(analysisDTO.getContext()); subjectiveQuestions.setSubjectiveContent(analysisDTO.getContext()); + + //查询是否已经有成绩 + StuGradeExample stuGradeExample = new StuGradeExample(); + stuGradeExample.createCriteria().andUserIdEqualTo(analysisDTO.getUserId()).andProjectEqualTo("市场需求挖掘").andModuleEqualTo("行业需求分析"); + List stuGradeList = stuGradeMapper.selectByExample(stuGradeExample); + if (!CollectionUtils.isEmpty(stuGradeList)) { + StuGrade stuGrade = stuGradeList.get(0); + BigDecimal score = stuGrade.getScore(); + BigDecimal error = Convert.toBigDecimal(count); + score = score.subtract(error); + + + if (score.compareTo(BigDecimal.valueOf(100)) > 0) + { + stuGrade.setScore(BigDecimal.valueOf(100)); + }else { + stuGrade.setScore(score); + } + stuGradeMapper.updateByPrimaryKeySelective(stuGrade); + + }else { + //将分数写入成绩表 + StuGrade stuGrade = new StuGrade(); + stuGrade.setId(IdUtil.randomUUID()); + stuGrade.setUserId(analysisDTO.getUserId()); + stuGrade.setCreateTime(new Date()); + stuGrade.setModule("行业需求分析"); + stuGrade.setProject("市场需求挖掘"); + stuGrade.setClassName(analysisDTO.getClassName()); + stuGrade.setContent(analysisDTO.getContext()); + stuGrade.setName(analysisDTO.getName()); + stuGrade.setSchoolId(analysisDTO.getSchoolId()); + stuGrade.setScore(BigDecimal.valueOf(100-count)); + stuGradeMapper.insertSelective(stuGrade); + + } + + return new ResultEntity<>(HttpStatus.OK, "上传成功"); } diff --git a/src/main/java/com/sztzjy/linkCommerce/entity/dto/StuIndustryAnalysisDTO.java b/src/main/java/com/sztzjy/linkCommerce/entity/dto/StuIndustryAnalysisDTO.java index c7f408a..bfd724a 100644 --- a/src/main/java/com/sztzjy/linkCommerce/entity/dto/StuIndustryAnalysisDTO.java +++ b/src/main/java/com/sztzjy/linkCommerce/entity/dto/StuIndustryAnalysisDTO.java @@ -27,4 +27,20 @@ import java.util.List; @ApiModelProperty(notes = "主观题") private String context; + @ApiModelProperty(notes = "班级名称") + private String className; + + @ApiModelProperty(notes = "班级ID") + private String classId; + + @ApiModelProperty(notes = "姓名") + private String name; + + + @ApiModelProperty(notes = "学校ID") + private String schoolId; + + + + }