From 22ec5921392284a695768cafa56d42cca1e82078 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Fri, 25 Apr 2025 13:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AE=9E=E8=AE=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9F=A5=E8=AF=A2=E3=80=81=E4=B8=8B=E8=BD=BD=E3=80=81?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E7=BB=93=E6=9E=9C=E5=9B=9E=E6=98=BE=E3=80=81?= =?UTF-8?q?=E5=88=86=E6=9E=90=E5=9B=9E=E6=98=BE=E3=80=81=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E3=80=81=E9=87=8D=E6=96=B0=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stu/IndustryDemandAnalysisController.java | 174 ++++++++++++------ .../entity/dto/CompetitiveEnvDTO.java | 20 ++ 2 files changed, 140 insertions(+), 54 deletions(-) create mode 100644 src/main/java/com/sztzjy/linkCommerce/entity/dto/CompetitiveEnvDTO.java 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 d42f8ac..d905c62 100644 --- a/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java +++ b/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java @@ -6,11 +6,13 @@ import com.alibaba.fastjson.JSONObject; import com.sztzjy.linkCommerce.annotation.AnonymousAccess; import com.sztzjy.linkCommerce.config.Constant; import com.sztzjy.linkCommerce.entity.*; +import com.sztzjy.linkCommerce.entity.dto.CompetitiveEnvDTO; import com.sztzjy.linkCommerce.entity.dto.MonthlyCakeIndex; import com.sztzjy.linkCommerce.entity.dto.StuIndustryAnalysisDTO; import com.sztzjy.linkCommerce.entity.dto.YearCakeIndexDto; import com.sztzjy.linkCommerce.mapper.HyxqfxDataMapper; import com.sztzjy.linkCommerce.mapper.HyxqfxStuAnswerMapper; +import com.sztzjy.linkCommerce.mapper.JzhyfxStuAnswerMapper; import com.sztzjy.linkCommerce.mapper.StuGradeMapper; import com.sztzjy.linkCommerce.service.IndustryDemandAnalysisService; import com.sztzjy.linkCommerce.service.ScoreService; @@ -36,25 +38,13 @@ import java.util.*; @RequestMapping("api/industryAnalysis") public class IndustryDemandAnalysisController { - - @Autowired - private IndustryDemandAnalysisService service; - - @Autowired - private HyxqfxDataMapper hyxqfxDataMapper; - @Autowired private HyxqfxStuAnswerMapper hyxqfxStuAnswerMapper; - @Autowired - private StuGradeMapper stuGradeMapper; - @Autowired private ScoreService scoreService; - - //数据查询 @ApiOperation("行业需求分析提交") @PostMapping("/analysisSubmit") @@ -64,28 +54,28 @@ public class IndustryDemandAnalysisController { //读取文件内容 批量导入excel中 以文件名区分 Map yearMap = new HashMap<>(); - yearMap.put("2018年",0.28); - yearMap.put("2019年",0.25); - yearMap.put("2020年",0.24); - yearMap.put("2021年",0.22); - yearMap.put("2022年",0.21); - yearMap.put("2023年",0.22); - yearMap.put("2024年",0.20); + yearMap.put("2018年", 0.28); + yearMap.put("2019年", 0.25); + yearMap.put("2020年", 0.24); + yearMap.put("2021年", 0.22); + yearMap.put("2022年", 0.21); + yearMap.put("2023年", 0.22); + yearMap.put("2024年", 0.20); Map monthMap = new HashMap<>(); - monthMap.put("2024年4月",0.21); - monthMap.put("2024年5月",0.20); - monthMap.put("2024年6月",0.20); - monthMap.put("2024年7月",0.22); - monthMap.put("2024年8月",0.33); - monthMap.put("2024年9月",0.30); - monthMap.put("2024年10月",0.33); - - monthMap.put("2024年11月",0.23); - monthMap.put("2024年12月",0.22); - monthMap.put("2025年1月",0.22); - monthMap.put("2025年2月",0.15); - monthMap.put("2025年3月",0.27); + monthMap.put("2024年4月", 0.21); + monthMap.put("2024年5月", 0.20); + monthMap.put("2024年6月", 0.20); + monthMap.put("2024年7月", 0.22); + monthMap.put("2024年8月", 0.33); + monthMap.put("2024年9月", 0.30); + monthMap.put("2024年10月", 0.33); + + monthMap.put("2024年11月", 0.23); + monthMap.put("2024年12月", 0.22); + monthMap.put("2025年1月", 0.22); + monthMap.put("2025年2月", 0.15); + monthMap.put("2025年3月", 0.27); int count = 0; @@ -94,7 +84,7 @@ public class IndustryDemandAnalysisController { for (YearCakeIndexDto yearCakeIndexDto : yearCakeIndexDtoList) { Double v = yearMap.get(yearCakeIndexDto.getYear()); if (yearCakeIndexDto.getYearAnswer() == null || v != yearCakeIndexDto.getYearAnswer()) { - count ++; + count++; } } @@ -104,7 +94,7 @@ public class IndustryDemandAnalysisController { for (MonthlyCakeIndex yearCakeIndexDto : monthlyCakeIndexList) { Double v = monthMap.get(yearCakeIndexDto.getYear()); if (yearCakeIndexDto.getMonthAnswer() == null || v != yearCakeIndexDto.getMonthAnswer()) { - count ++; + count++; } } BigDecimal subtract = BigDecimal.ZERO; @@ -115,15 +105,9 @@ public class IndustryDemandAnalysisController { List hyxqfxStuAnswerList = hyxqfxStuAnswerMapper.selectByExample(example); if (!CollectionUtils.isEmpty(hyxqfxStuAnswerList)) { - HyxqfxStuAnswer hyxqfxStuAnswer = hyxqfxStuAnswerList.get(0); - hyxqfxStuAnswer.setErrorNumber(count); - String jsonString = JSONObject.toJSONString(analysisDTO); - hyxqfxStuAnswer.setAnswer(jsonString); - - hyxqfxStuAnswerMapper.updateByPrimaryKeyWithBLOBs(hyxqfxStuAnswer); + return new ResultEntity<>(HttpStatus.ACCEPTED,"请勿重复提交!"); - - }else { + } else { //学生答案 String jsonString = JSONObject.toJSONString(analysisDTO); HyxqfxStuAnswer hyxqfxStuAnswer = new HyxqfxStuAnswer(); @@ -137,11 +121,11 @@ public class IndustryDemandAnalysisController { subtract = BigDecimal.valueOf(100).subtract(Convert.toBigDecimal(count)); - Boolean aBoolean = scoreService.insertScore(analysisDTO.getUserId(), Constant.PRO_SCXQWJ,Constant.MODULE_HYXQFX,subtract,analysisDTO.getContext()); + Boolean aBoolean = scoreService.insertScore(analysisDTO.getUserId(), Constant.PRO_SCXQWJ, Constant.MODULE_HYXQFX, subtract, analysisDTO.getContext()); // scoreService.insertScore(userId, Constant.PRO_GYQDGL, Constant.MODULE_CGXQYC, BigDecimal.valueOf(100 - errorCount), null); - if(aBoolean){ + if (aBoolean) { return new ResultEntity<>(HttpStatus.OK, "提交成功"); - }else { + } else { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败"); } @@ -151,7 +135,7 @@ public class IndustryDemandAnalysisController { @ApiOperation("行业需求分析根据用户ID查询") @GetMapping("/selectByUserId") @AnonymousAccess - public ResultEntity selectByUserId(@ApiParam("用户ID") String userId) { + public ResultEntity selectByUserId(@ApiParam("用户ID") String userId) { //读取文件内容 批量导入excel中 以文件名区分\ HyxqfxStuAnswerExample hyxqfxStuAnswer = new HyxqfxStuAnswerExample(); @@ -160,27 +144,109 @@ public class IndustryDemandAnalysisController { List hyxqfxStuAnswersList = hyxqfxStuAnswerMapper.selectByExampleWithBLOBs(hyxqfxStuAnswer); if (CollectionUtils.isEmpty(hyxqfxStuAnswersList)) { return new ResultEntity<>(HttpStatus.OK); - }else { + } else { JSONObject jsonObject = JSONObject.parseObject(hyxqfxStuAnswersList.get(0).getAnswer()); - return new ResultEntity<>(HttpStatus.OK,jsonObject); + return new ResultEntity<>(HttpStatus.OK, jsonObject); } } - @ApiOperation("重新实训") + @ApiOperation("重新实训接口") @GetMapping("/restartExperment") @AnonymousAccess - public ResultEntity restartExperment(@ApiParam("用户ID") String userId) { + public ResultEntity restartExperment(@ApiParam("用户ID") String userId, @ApiParam("小模块") String module) { + Boolean b = false; + if (Constant.MODULE_HYXQFX.equals(module)) { + //查询学生答题数据,删除成绩 + HyxqfxStuAnswerExample example = new HyxqfxStuAnswerExample(); + example.createCriteria().andUserIdEqualTo(userId); + hyxqfxStuAnswerMapper.deleteByExample(example); + b = scoreService.deleteScore(userId, Constant.PRO_SCXQWJ, Constant.MODULE_HYXQFX); + } - //查询学生答题数据,删除成绩 - HyxqfxStuAnswerExample example = new HyxqfxStuAnswerExample(); + if (Constant.MODULE_JZHJFX.equals(module)) { + //查询学生答题数据,删除成绩 + JzhyfxStuAnswerExample jzhyfxStuAnswerExample = new JzhyfxStuAnswerExample(); + jzhyfxStuAnswerExample.createCriteria().andUserIdEqualTo(userId); + jzhyfxStuAnswerMapper.deleteByExample(jzhyfxStuAnswerExample); + b = scoreService.deleteScore(userId, Constant.PRO_SCXQWJ, Constant.MODULE_JZHJFX); + } + if (b) { + return new ResultEntity<>(HttpStatus.OK, "重新实训成功!"); + } else { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "重新实训失败!"); + } + } + + + @Autowired + private JzhyfxStuAnswerMapper jzhyfxStuAnswerMapper; + + + @ApiOperation("竞争环境分析提交") + @PostMapping("/competitiveEnvSubmit") + @AnonymousAccess + public ResultEntity competitiveEnvSubmit(@RequestBody CompetitiveEnvDTO competitiveEnvDTO) { + + //校验答案是否正确 + + Double answer = 0.116; + Double stuAnswer = competitiveEnvDTO.getAnswer(); + int count = 0; + + if (answer!=stuAnswer) { + count ++ ; + } + + + //查询数据库 是否已经答过题 + JzhyfxStuAnswerExample example = new JzhyfxStuAnswerExample(); + example.createCriteria().andUserIdEqualTo(competitiveEnvDTO.getUserId()); + List stuAnswerList = jzhyfxStuAnswerMapper.selectByExample(example); + if (!CollectionUtils.isEmpty(stuAnswerList)) { + return new ResultEntity(HttpStatus.ACCEPTED,"请勿重复答题!"); + } + + //首次提交 + JzhyfxStuAnswer jzhyfxStuAnswer = new JzhyfxStuAnswer(); + jzhyfxStuAnswer.setUserId(competitiveEnvDTO.getUserId()); + jzhyfxStuAnswer.setAnswer(stuAnswer.toString()); + jzhyfxStuAnswer.setId(IdUtil.randomUUID()); + jzhyfxStuAnswerMapper.insertSelective(jzhyfxStuAnswer); + + + + Boolean aBoolean = scoreService.insertScore(competitiveEnvDTO.getUserId(), Constant.PRO_SCXQWJ, Constant.MODULE_JZHJFX, BigDecimal.valueOf(100 - count), null); + // scoreService.insertScore(userId, Constant.PRO_GYQDGL, Constant.MODULE_CGXQYC, BigDecimal.valueOf(100 - errorCount), null); + if (aBoolean) { + return new ResultEntity<>(HttpStatus.OK, "提交成功"); + } else { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败"); + } + + } + + @ApiOperation("竞争环境分析根据用户ID查询") + @GetMapping("/competitiveEnvSubmitByUserId") + @AnonymousAccess + public ResultEntity competitiveEnvSubmitByUserId(@ApiParam("用户ID") String userId) { + //读取文件内容 批量导入excel中 以文件名区分\ + + //查询数据库 是否已经答过题 + JzhyfxStuAnswerExample example = new JzhyfxStuAnswerExample(); example.createCriteria().andUserIdEqualTo(userId); - hyxqfxStuAnswerMapper.deleteByExample(example); + List stuAnswerList = jzhyfxStuAnswerMapper.selectByExample(example); + if (CollectionUtils.isEmpty(stuAnswerList)) { + return new ResultEntity<>(HttpStatus.OK); + } else { + return new ResultEntity<>(HttpStatus.OK, stuAnswerList.get(0)); + } - return null; } + + } diff --git a/src/main/java/com/sztzjy/linkCommerce/entity/dto/CompetitiveEnvDTO.java b/src/main/java/com/sztzjy/linkCommerce/entity/dto/CompetitiveEnvDTO.java new file mode 100644 index 0000000..8c2caf8 --- /dev/null +++ b/src/main/java/com/sztzjy/linkCommerce/entity/dto/CompetitiveEnvDTO.java @@ -0,0 +1,20 @@ +package com.sztzjy.linkCommerce.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 17803 + * @date 2025-04-25 13:20 + */ + +@Data +public class CompetitiveEnvDTO { + + @ApiModelProperty("用户ID") + private String userId; + + @ApiModelProperty("学生答案") + private Double answer; + +}