From 3bcaba9c74eb6aee93ec5743250f5f07f698d7c9 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Fri, 25 Apr 2025 11:12:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=AE=9E=E8=AE=AD=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stu/IndustryDemandAnalysisController.java | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 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 9463e76..d42f8ac 100644 --- a/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java +++ b/src/main/java/com/sztzjy/linkCommerce/controller/stu/IndustryDemandAnalysisController.java @@ -62,15 +62,6 @@ public class IndustryDemandAnalysisController { @Transactional(rollbackFor = Exception.class) public ResultEntity uploadExcel(@RequestBody StuIndustryAnalysisDTO analysisDTO) { - //查询数据 - HyxqfxStuAnswerExample example = new HyxqfxStuAnswerExample(); - example.createCriteria().andUserIdEqualTo(analysisDTO.getUserId()); - - List hyxqfxStuAnswerList = hyxqfxStuAnswerMapper.selectByExample(example); - if (!CollectionUtils.isEmpty(hyxqfxStuAnswerList)) { - return new ResultEntity<>(HttpStatus.OK); - } - //读取文件内容 批量导入excel中 以文件名区分 Map yearMap = new HashMap<>(); yearMap.put("2018年",0.28); @@ -116,37 +107,44 @@ public class IndustryDemandAnalysisController { count ++; } } + BigDecimal subtract = BigDecimal.ZERO; + //查询数据 + HyxqfxStuAnswerExample example = new HyxqfxStuAnswerExample(); + example.createCriteria().andUserIdEqualTo(analysisDTO.getUserId()); - //学生答案 - String jsonString = JSONObject.toJSONString(analysisDTO); - HyxqfxStuAnswer hyxqfxStuAnswer = new HyxqfxStuAnswer(); - hyxqfxStuAnswer.setId(IdUtil.randomUUID()); - hyxqfxStuAnswer.setUserId(analysisDTO.getUserId()); - hyxqfxStuAnswer.setAnswer(jsonString); - hyxqfxStuAnswer.setErrorNumber(count); - - hyxqfxStuAnswerMapper.insertSelective(hyxqfxStuAnswer); - - BigDecimal subtract = BigDecimal.valueOf(100).subtract(Convert.toBigDecimal(count)); - + List hyxqfxStuAnswerList = hyxqfxStuAnswerMapper.selectByExample(example); + if (!CollectionUtils.isEmpty(hyxqfxStuAnswerList)) { - scoreService.selectByUserId(analysisDTO.getUserId(), Constant.PRO_SCXQWJ,Constant.MODULE_HYXQFX,subtract,analysisDTO.getContext()); + HyxqfxStuAnswer hyxqfxStuAnswer = hyxqfxStuAnswerList.get(0); + hyxqfxStuAnswer.setErrorNumber(count); + String jsonString = JSONObject.toJSONString(analysisDTO); + hyxqfxStuAnswer.setAnswer(jsonString); + hyxqfxStuAnswerMapper.updateByPrimaryKeyWithBLOBs(hyxqfxStuAnswer); -// StuGrade stuGrade = new StuGrade(Constant.PRO_SCXQWJ, -// Constant.MODULE_HYXQFX, -// Convert.toBigDecimal(subtract), -// analysisDTO.getSchoolId(), -// analysisDTO.getUserId(), -// analysisDTO.getName(), -// analysisDTO.getClassId(), -// analysisDTO.getClassName(), -// analysisDTO.getContext()); + }else { + //学生答案 + String jsonString = JSONObject.toJSONString(analysisDTO); + HyxqfxStuAnswer hyxqfxStuAnswer = new HyxqfxStuAnswer(); + hyxqfxStuAnswer.setId(IdUtil.randomUUID()); + hyxqfxStuAnswer.setUserId(analysisDTO.getUserId()); + hyxqfxStuAnswer.setAnswer(jsonString); + hyxqfxStuAnswer.setErrorNumber(count); + + hyxqfxStuAnswerMapper.insertSelective(hyxqfxStuAnswer); + } + subtract = BigDecimal.valueOf(100).subtract(Convert.toBigDecimal(count)); + 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){ + return new ResultEntity<>(HttpStatus.OK, "提交成功"); + }else { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败"); + } - return new ResultEntity<>(HttpStatus.OK, "上传成功"); } @@ -170,15 +168,17 @@ public class IndustryDemandAnalysisController { } - public void jiaoYanCodeSize(String code){ - String[] strings = code.split(","); - if (strings.length>=20) - { - //计分规则 - + @ApiOperation("重新实训") + @GetMapping("/restartExperment") + @AnonymousAccess + public ResultEntity restartExperment(@ApiParam("用户ID") String userId) { - } + //查询学生答题数据,删除成绩 + HyxqfxStuAnswerExample example = new HyxqfxStuAnswerExample(); + example.createCriteria().andUserIdEqualTo(userId); + hyxqfxStuAnswerMapper.deleteByExample(example); + return null; }