From 3a8618dac7a03d1ab8edc05d529057e381fd9b1a Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Wed, 21 Aug 2024 10:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stu/StuConceptBlockController.java | 109 +++--- .../marketing/entity/StuMachineLearning.java | 33 +- .../entity/dto/StuBlockProductWithDTO.java | 1 + .../entity/dto/TchrePortPresentationDTO.java | 1 + .../mapper/StuUploadImgAiMapper.java | 22 +- .../service/StuConceptBlockService.java | 2 +- .../impl/StuConceptBlockServiceImpl.java | 321 +++++------------- .../impl/StuFiveGTrainingServiceImpl.java | 186 ++++------ .../StuUserProfileDatabaseServiceImpl.java | 195 +++++------ .../UserBehaviorProfilingAnaServiceImpl.java | 54 ++- .../mappers/StuMachineLearningMapper.xml | 59 +++- .../mappers/StuUploadImgAiMapper.xml | 26 +- 12 files changed, 470 insertions(+), 539 deletions(-) diff --git a/src/main/java/com/sztzjy/marketing/controller/stu/StuConceptBlockController.java b/src/main/java/com/sztzjy/marketing/controller/stu/StuConceptBlockController.java index 227577e..66c5802 100644 --- a/src/main/java/com/sztzjy/marketing/controller/stu/StuConceptBlockController.java +++ b/src/main/java/com/sztzjy/marketing/controller/stu/StuConceptBlockController.java @@ -104,20 +104,6 @@ public class StuConceptBlockController { - - - @GetMapping("/getReport") - @ApiOperation("获取实训报告详情") - //@AnonymousAccess - public ResultEntity getReport(String userId) { - - List report = stuConceptBlockService.getReport(userId); - return new ResultEntity<>(HttpStatus.OK, report); - - } - - - @PostMapping("/upload") @ApiOperation("上传实训报告") @AnonymousAccess @@ -128,43 +114,88 @@ public class StuConceptBlockController { StuBlockProductWithDTO stuBlockProductWithBLOBs = gson.fromJson(stuBlockProduct, StuBlockProductWithDTO.class); - StuPracticalTrainingReport report = stuConceptBlockService.upload(file, stuBlockProductWithBLOBs); return new ResultDataEntity<>(HttpStatus.OK, report); } + @GetMapping("/getReport") + @ApiOperation("获取实训报告详情") + //@AnonymousAccess + public ResultEntity getReport(String userId) { - - @PostMapping("/newUpload") - @ApiOperation("新版上传实训报告") - @AnonymousAccess - public ResultEntity newUpload(@RequestParam(required = false) @RequestPart MultipartFile file, - @RequestParam(required = false) String stuBlockProduct) { - - Gson gson = new Gson(); - StuBlockProductWithDTO stuBlockProductWithBLOBs = gson.fromJson(stuBlockProduct, StuBlockProductWithDTO.class); - - - - // StuPracticalTrainingReport report = stuConceptBlockService.upload(file, stuBlockProductWithBLOBs); - return stuConceptBlockService.newUpload(file, stuBlockProductWithBLOBs); - + List report = stuConceptBlockService.getReport(userId); + return new ResultEntity<>(HttpStatus.OK, report); } - @GetMapping("/downReportByZip") - @ApiOperation("新版上传实训报告下载ZIP") - @AnonymousAccess - public ResultEntity downReportByZip(HttpServletResponse response,String userId,String module,String reportName) { - - - return stuConceptBlockService.downReportByZip(response,userId,module,reportName); - } - +// @PostMapping("/upload") +// @ApiOperation("上传实训报告") +// @AnonymousAccess +// public ResultDataEntity upload(@RequestParam(required = false) @RequestPart MultipartFile file, +// @RequestParam(required = false) String stuBlockProduct) { +// +// Gson gson = new Gson(); +// StuBlockProductWithDTO stuBlockProductWithBLOBs = gson.fromJson(stuBlockProduct, StuBlockProductWithDTO.class); +// +// +// +// StuPracticalTrainingReport report = stuConceptBlockService.upload(file, stuBlockProductWithBLOBs); +// +// return new ResultDataEntity<>(HttpStatus.OK, report); +// +// } +// +// +// +// @PostMapping("/newUpload") +// @ApiOperation("新版上传实训报告") +// @AnonymousAccess +// public ResultEntity newUpload(@RequestParam(required = false) @RequestPart MultipartFile file, +// @RequestParam(required = false) String stuBlockProduct) { +// +// Gson gson = new Gson(); +// StuBlockProductWithDTO stuBlockProductWithBLOBs = gson.fromJson(stuBlockProduct, StuBlockProductWithDTO.class); +// +// +// +// // StuPracticalTrainingReport report = stuConceptBlockService.upload(file, stuBlockProductWithBLOBs); +// return stuConceptBlockService.newUpload(file, stuBlockProductWithBLOBs); +// +// +// } +// +// @GetMapping("/downReportByZip") +// @ApiOperation("新版上传实训报告下载ZIP") +// @AnonymousAccess +// public ResultEntity downReportByZip(HttpServletResponse response,String userId,String module,String reportName) { +// +// +// return stuConceptBlockService.downReportByZip(response,userId,module,reportName); +// +// +// } +// +// +// @PostMapping("/newUpload") +// @ApiOperation("新版上传实训报告") +// @AnonymousAccess +// public ResultEntity newUpload(@RequestParam(required = false) @RequestPart MultipartFile file, +// @RequestParam(required = false) String stuBlockProduct) { +// +// Gson gson = new Gson(); +// StuBlockProductWithDTO stuBlockProductWithBLOBs = gson.fromJson(stuBlockProduct, StuBlockProductWithDTO.class); +// +// +// +// // StuPracticalTrainingReport report = stuConceptBlockService.upload(file, stuBlockProductWithBLOBs); +// return stuConceptBlockService.newUpload(file, stuBlockProductWithBLOBs); +// +// +// } /* diff --git a/src/main/java/com/sztzjy/marketing/entity/StuMachineLearning.java b/src/main/java/com/sztzjy/marketing/entity/StuMachineLearning.java index e14bd5a..7f4f2a5 100644 --- a/src/main/java/com/sztzjy/marketing/entity/StuMachineLearning.java +++ b/src/main/java/com/sztzjy/marketing/entity/StuMachineLearning.java @@ -1,6 +1,5 @@ package com.sztzjy.marketing.entity; -import java.io.Serializable; import java.util.Date; import java.util.List; @@ -15,7 +14,7 @@ import lombok.Data; * stu_machine_learning */ @Data -public class StuMachineLearning implements Serializable { +public class StuMachineLearning { @ApiModelProperty("id") private Integer id; @@ -234,8 +233,12 @@ public class StuMachineLearning implements Serializable { @ApiModelProperty("活跃用户分析") private String activeUserAnalysis; - private List stuMachineLearningInfoDTOList; + private String stepechartlist1; + + private String stepechartlist2; + + private String stepechartlist3; public Integer getId() { return id; @@ -820,4 +823,28 @@ public class StuMachineLearning implements Serializable { public void setActiveUserAnalysis(String activeUserAnalysis) { this.activeUserAnalysis = activeUserAnalysis == null ? null : activeUserAnalysis.trim(); } + + public String getStepechartlist1() { + return stepechartlist1; + } + + public void setStepechartlist1(String stepechartlist1) { + this.stepechartlist1 = stepechartlist1 == null ? null : stepechartlist1.trim(); + } + + public String getStepechartlist2() { + return stepechartlist2; + } + + public void setStepechartlist2(String stepechartlist2) { + this.stepechartlist2 = stepechartlist2 == null ? null : stepechartlist2.trim(); + } + + public String getStepechartlist3() { + return stepechartlist3; + } + + public void setStepechartlist3(String stepechartlist3) { + this.stepechartlist3 = stepechartlist3 == null ? null : stepechartlist3.trim(); + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/entity/dto/StuBlockProductWithDTO.java b/src/main/java/com/sztzjy/marketing/entity/dto/StuBlockProductWithDTO.java index 906e58e..1b6ecb6 100644 --- a/src/main/java/com/sztzjy/marketing/entity/dto/StuBlockProductWithDTO.java +++ b/src/main/java/com/sztzjy/marketing/entity/dto/StuBlockProductWithDTO.java @@ -13,5 +13,6 @@ public class StuBlockProductWithDTO { private String schoolId; private String userId; private String module; + private String count; } 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 9dbcdfd..8c68cda 100644 --- a/src/main/java/com/sztzjy/marketing/entity/dto/TchrePortPresentationDTO.java +++ b/src/main/java/com/sztzjy/marketing/entity/dto/TchrePortPresentationDTO.java @@ -25,4 +25,5 @@ public class TchrePortPresentationDTO { @ApiModelProperty("文件大小") private Double fileSize; + private String ascription; } diff --git a/src/main/java/com/sztzjy/marketing/mapper/StuUploadImgAiMapper.java b/src/main/java/com/sztzjy/marketing/mapper/StuUploadImgAiMapper.java index 0e18130..28b5b0f 100644 --- a/src/main/java/com/sztzjy/marketing/mapper/StuUploadImgAiMapper.java +++ b/src/main/java/com/sztzjy/marketing/mapper/StuUploadImgAiMapper.java @@ -38,16 +38,16 @@ public interface StuUploadImgAiMapper { int updateByPrimaryKey(StuUploadImgAi record); - @Select(" select s.name as name , s.student_id as studentId, s.class_name as className,\n" + - " i.module as module ,i.file_name as fileName ,i.create_time as createTime ,i.file_size as fileSize\n" + - " from stu_upload_img_ai i\n" + - " join\n" + - " stu_user s\n" + - " on\n" + - " i.user_id = s.user_id\n" + - " where\n" + - " s.school_id = #{schoolId}\n" + - " order by\n" + - " i.create_time asc") +// @Select(" select s.name as name , s.student_id as studentId, s.class_name as className,\n" + +// " i.module as module ,i.file_name as fileName ,i.create_time as createTime ,i.file_size as fileSize\n" + +// " from stu_upload_img_ai i\n" + +// " join\n" + +// " stu_user s\n" + +// " on\n" + +// " i.user_id = s.user_id\n" + +// " where\n" + +// " s.school_id = #{schoolId}\n" + +// " order by\n" + +// " i.create_time asc") List selectInfoBySchoolId(String schoolId); } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/marketing/service/StuConceptBlockService.java b/src/main/java/com/sztzjy/marketing/service/StuConceptBlockService.java index 5c786cb..fc0229f 100644 --- a/src/main/java/com/sztzjy/marketing/service/StuConceptBlockService.java +++ b/src/main/java/com/sztzjy/marketing/service/StuConceptBlockService.java @@ -31,7 +31,7 @@ public interface StuConceptBlockService { void download(Integer id, HttpServletResponse response); - List getReport(String userId); + List getReport(String userId); /** * 区块链知识笔记导出为pdf diff --git a/src/main/java/com/sztzjy/marketing/service/impl/StuConceptBlockServiceImpl.java b/src/main/java/com/sztzjy/marketing/service/impl/StuConceptBlockServiceImpl.java index 4987ea1..a2589b4 100644 --- a/src/main/java/com/sztzjy/marketing/service/impl/StuConceptBlockServiceImpl.java +++ b/src/main/java/com/sztzjy/marketing/service/impl/StuConceptBlockServiceImpl.java @@ -30,6 +30,7 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; +import org.ujmp.core.util.R; import util.convertPDF.PDFConvertUtil; @@ -49,14 +50,12 @@ import java.util.zip.ZipOutputStream; public class StuConceptBlockServiceImpl implements StuConceptBlockService { - @Autowired private IFileUtil fileUtil; @Resource StuPracticalTrainingReportMapper stuPracticalTrainingReportMapper; - @Resource private StuScoreDetailsMapper stuScoreDetailsMapper; @@ -93,7 +92,6 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { ScoringUtil scoringUtil; - //区块链学习资源查看 @Override public List getConceptBlockResources() { @@ -105,17 +103,14 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { } - - /** * 学习测评查看 * - * * @return */ @Override - public List getLearningAssessment( String userId) { - StuAssessmentQuestionDetailsExample detailsExample=new StuAssessmentQuestionDetailsExample(); + public List getLearningAssessment(String userId) { + StuAssessmentQuestionDetailsExample detailsExample = new StuAssessmentQuestionDetailsExample(); detailsExample.createCriteria().andUserIdEqualTo(userId); List stuAssessmentQuestionDetails = stuAssessmentQuestionDetailsMapper.selectByExample(detailsExample); @@ -124,10 +119,10 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { criteria.andLogicEqualTo(1); List stuLearningAssessments = stuLearningAssessmentMapper.selectByExample(example); List stuAssessmentQuestionDetailsDTOS = convertUtil.entityToDTOList(stuLearningAssessments, StuAssessmentQuestionDetailsDTO.class); - if(stuAssessmentQuestionDetails.size()!=0){ + if (stuAssessmentQuestionDetails.size() != 0) { for (int i = 0; i < stuAssessmentQuestionDetails.size(); i++) { for (int j = 0; j < stuAssessmentQuestionDetailsDTOS.size(); j++) { - if(stuAssessmentQuestionDetails.get(i).getTopicId().equals(stuLearningAssessments.get(j).getTopicId())){ + if (stuAssessmentQuestionDetails.get(i).getTopicId().equals(stuLearningAssessments.get(j).getTopicId())) { String rightOrWrong = stuAssessmentQuestionDetails.get(i).getRightOrWrong(); String studentAnswer = stuAssessmentQuestionDetails.get(i).getStudentAnswer(); stuAssessmentQuestionDetailsDTOS.get(j).setRightOrWrong(rightOrWrong); @@ -290,194 +285,47 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { throw new RuntimeException("模块或用户ID不能为空"); } + //查询是否已有分数 StuPracticalTrainingReportExample stuPracticalTrainingReportExample = new StuPracticalTrainingReportExample(); - stuPracticalTrainingReportExample.createCriteria().andUseridEqualTo(stuBlockProductWithBLOBs.getUserId()); + stuPracticalTrainingReportExample.createCriteria().andUseridEqualTo(stuBlockProductWithBLOBs.getUserId()) + .andModuleEqualTo(stuBlockProductWithBLOBs.getModule()).andAscriptionEqualTo(stuBlockProductWithBLOBs.getCount()); List stuPracticalTrainingReports = stuPracticalTrainingReportMapper.selectByExample(stuPracticalTrainingReportExample); - String originalFilename = file.getOriginalFilename(); - - if (stuPracticalTrainingReports.size()>0) - { - if (stuPracticalTrainingReports.get(0).getRating()!=null) - { - throw new RuntimeException("老师已评分,请勿再次提交报告"); - } - } - - - String name = originalFilename.substring(0, originalFilename.lastIndexOf(".")); - - - String fileExtension = originalFilename.substring(originalFilename.lastIndexOf(".")).toLowerCase(); - //上传实验报告后写入学习成绩 - TchModuleWeithExample weightExample = new TchModuleWeithExample(); - weightExample.createCriteria().andSchoolIdEqualTo(stuBlockProductWithBLOBs.getSchoolId()); - List weights = tchModuleWeithMapper.selectByExample(weightExample); - String id = UUID.randomUUID().toString().replaceAll("-", ""); - - if (".pdf".equals(fileExtension)) { - //第一次上传 - if (stuPracticalTrainingReports.size() == 0) { - StuPracticalTrainingReport stuPracticalTrainingReport = new StuPracticalTrainingReport(); - - long fileSize = file.getSize() / 1024; - String url = localFileUtil.upload(file); - int i = UUID.randomUUID().hashCode(); - int info = i > 0 ? i : -i; - stuPracticalTrainingReport.setId(info); - stuPracticalTrainingReport.setReportName(name + ".pdf"); - stuPracticalTrainingReport.setSize((int) fileSize); - stuPracticalTrainingReport.setUploadTime(new Date()); - stuPracticalTrainingReport.setUrl(url); - stuPracticalTrainingReport.setUserid(stuBlockProductWithBLOBs.getUserId()); - stuPracticalTrainingReport.setSchoolId(stuBlockProductWithBLOBs.getSchoolId()); - stuPracticalTrainingReportMapper.insert(stuPracticalTrainingReport); - - - if (weights.isEmpty()) { - throw new RuntimeException("没有查询到实验报告权重信息"); - } - - - TchModuleWeith tchConceptualTechnologyWeight = weights.get(0); - if (tchConceptualTechnologyWeight != null) { - //获取权重信息 - BigDecimal reportWeight = tchConceptualTechnologyWeight.getReportWeight(); - if (reportWeight != null) { - StuScoreDetails scoreDetails = new StuScoreDetails(); - scoreDetails.setUserId(stuBlockProductWithBLOBs.getUserId()); -// - scoreDetails.setScoreWeight(reportWeight.doubleValue()); - scoreDetails.setId(id); - scoreDetails.setLearningProjects("实训报告"); - scoreDetails.setSerialNumber(5); - scoreDetails.setCompletionStatus("已提交"); - stuScoreDetailsMapper.insert(scoreDetails); - } + if (!CollectionUtils.isEmpty(stuPracticalTrainingReports)) { + for (StuPracticalTrainingReport report : stuPracticalTrainingReports) { + if (report.getRating() != null) { + throw new RuntimeException("老师已评分,请勿再次提交报告"); } - return stuPracticalTrainingReport; } - //多次上传 - StuPracticalTrainingReport TrainingReport = stuPracticalTrainingReports.get(0); -// String fileName = file.getOriginalFilename(); - long fileSize = file.getSize() / 1024; - String url = localFileUtil.upload(file); - TrainingReport.setReportName(name + ".pdf"); - TrainingReport.setSize((int) fileSize); - TrainingReport.setUploadTime(new Date()); - TrainingReport.setUrl(url); - - - - StuScoreDetailsExample stuScoreDetailsExample = new StuScoreDetailsExample(); - stuScoreDetailsExample.createCriteria().andUserIdEqualTo(stuBlockProductWithBLOBs.getUserId()); - List stuScoreDetails = stuScoreDetailsMapper.selectByExample(stuScoreDetailsExample); - if (stuScoreDetails.size() != 0) { - if (stuScoreDetails.get(0).getScoreWeight() != (weights.get(0).getReportWeight().doubleValue())) { - stuScoreDetails.get(0).setScoreWeight(weights.get(0).getReportWeight().doubleValue()); - stuScoreDetailsMapper.updateByPrimaryKeySelective(stuScoreDetails.get(0)); - } - } - stuPracticalTrainingReportMapper.updateByPrimaryKeySelective(TrainingReport); - return TrainingReport; + StuPracticalTrainingReport report = stuPracticalTrainingReports.get(0); + //更新操作 + String upload = fileUtil.upload(file); + report.setUrl(upload); + report.setUploadTime(new Date()); + report.setSize((int) file.getSize()); + report.setReportName(file.getOriginalFilename()); + stuPracticalTrainingReportMapper.updateByPrimaryKey(report); + return report; } else { + //第一次上传 + String upload = fileUtil.upload(file); + StuPracticalTrainingReport report = new StuPracticalTrainingReport(); + report.setId((int) IdUtil.getSnowflakeNextId()); + report.setUrl(upload); + report.setAscription(stuBlockProductWithBLOBs.getCount()); + report.setUploadTime(new Date()); + report.setModule(stuBlockProductWithBLOBs.getModule()); + report.setUserid(stuBlockProductWithBLOBs.getUserId()); + report.setSize((int) file.getSize()); + report.setSchoolId(stuBlockProductWithBLOBs.getSchoolId()); + report.setReportName(file.getOriginalFilename()); + stuPracticalTrainingReportMapper.insertSelective(report); + return report; - //格式不为pdf,转换 - try { - - BufferedInputStream inputStream = FileUtil.getInputStream(convertMultipartFileToFile(file)); - - - - String s = IdUtil.simpleUUID(); - - File file1 = new File(filePath + "/pdf"); - if (!file1.exists()){ - file1.mkdir(); - } - - FileOutputStream fileOutputStream = new FileOutputStream(filePath+"/pdf/"+s+".pdf"); - - PDFConvertUtil.convertToPDFByFileNameSuffix(originalFilename, inputStream, fileOutputStream); - - FileInputStream fileInputStream = new FileInputStream(filePath+"/pdf/"+s+".pdf"); - - MultipartFile multipartFile = new MockMultipartFile( - "example.txt", // 文件名 - s + ".pdf", // 原始文件名 - "pdf", // 文件类型 - fileInputStream - ); - String upload = localFileUtil.upload(multipartFile); - fileInputStream.close(); - fileOutputStream.close(); - if (stuPracticalTrainingReports.size() == 0) { - StuPracticalTrainingReport stuPracticalTrainingReport = new StuPracticalTrainingReport(); - //文件大小 - long fileSize = multipartFile.getSize() / 1024; - int i = UUID.randomUUID().hashCode(); - int info = i > 0 ? i : -i; - stuPracticalTrainingReport.setId(info); - stuPracticalTrainingReport.setReportName(name + ".pdf"); - stuPracticalTrainingReport.setSize((int) fileSize); - stuPracticalTrainingReport.setUploadTime(new Date()); - stuPracticalTrainingReport.setUrl(upload); - stuPracticalTrainingReport.setUserid(stuBlockProductWithBLOBs.getUserId()); - stuPracticalTrainingReport.setSchoolId(stuBlockProductWithBLOBs.getSchoolId()); - stuPracticalTrainingReportMapper.insert(stuPracticalTrainingReport); - - - //上传实验报告后写入学习成绩 - - if (weights.isEmpty()) { - throw new RuntimeException("没有查询到实验报告权重信息"); - } - TchModuleWeith tchConceptualTechnologyWeight = weights.get(0); - if (tchConceptualTechnologyWeight != null) { - //获取权重信息 - BigDecimal reportWeight = tchConceptualTechnologyWeight.getReportWeight(); - if (reportWeight != null) { - StuScoreDetails scoreDetails = new StuScoreDetails(); - scoreDetails.setUserId(stuBlockProductWithBLOBs.getUserId()); - scoreDetails.setScoreWeight(reportWeight.doubleValue()); - scoreDetails.setId(id); - scoreDetails.setLearningProjects("实训报告"); - scoreDetails.setSerialNumber(5); - scoreDetails.setCompletionStatus("已提交"); - stuScoreDetailsMapper.insert(scoreDetails); - } - } + } - return stuPracticalTrainingReport; - } else { - StuPracticalTrainingReport TrainingReport = stuPracticalTrainingReports.get(0); - long fileSize = multipartFile.getSize() / 1024; - TrainingReport.setReportName(name + ".pdf"); - TrainingReport.setSize((int) fileSize); - TrainingReport.setUploadTime(new Date()); - TrainingReport.setUrl(upload); - - - StuScoreDetailsExample stuScoreDetailsExample = new StuScoreDetailsExample(); - stuScoreDetailsExample.createCriteria().andUserIdEqualTo(stuBlockProductWithBLOBs.getUserId()); - List stuScoreDetails = stuScoreDetailsMapper.selectByExample(stuScoreDetailsExample); - if (stuScoreDetails.size() != 0) { - if (stuScoreDetails.get(0).getScoreWeight() != (weights.get(0).getReportWeight().doubleValue())) { - stuScoreDetails.get(0).setScoreWeight(weights.get(0).getReportWeight().doubleValue()); - stuScoreDetailsMapper.updateByPrimaryKeySelective(stuScoreDetails.get(0)); - } - } - stuPracticalTrainingReportMapper.updateByPrimaryKeySelective(TrainingReport); - return TrainingReport; - } - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } - } } /* @@ -489,17 +337,14 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { @Override public void download(Integer id, HttpServletResponse response) { - StuUploadImgAi stuUploadImgAi = stuUploadImgAiMapper.selectByPrimaryKey(id); + StuPracticalTrainingReport report = stuPracticalTrainingReportMapper.selectByPrimaryKey(id); - Assert.isTrue(stuUploadImgAi != null && stuUploadImgAi.getFilePath() != null, "文件不存在"); - - fileUtil.download(response, stuUploadImgAi.getFileName(), stuUploadImgAi.getFilePath()); + Assert.isTrue(report != null && report.getUrl() != null, "文件不存在"); + fileUtil.download(response, report.getReportName(), report.getUrl()); } - @Autowired - private StuUploadImgAiMapper stuUploadImgAiMapper; /** * 获取实验报告 @@ -508,32 +353,29 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { * @return */ @Override - public List getReport(String userId) { + public List getReport(String userId) { - //获取实验报告 - StuUploadImgAiExample export = new StuUploadImgAiExample(); - export.createCriteria().andUserIdEqualTo(userId); + StuPracticalTrainingReportExample stuPracticalTrainingReportExample = new StuPracticalTrainingReportExample(); + stuPracticalTrainingReportExample.createCriteria().andUseridEqualTo(userId); - List stuUploadImgAiList = stuUploadImgAiMapper.selectByExampleWithBLOBs(export); - if (CollectionUtils.isEmpty(stuUploadImgAiList)){ + List stuUploadImgAiList = stuPracticalTrainingReportMapper.selectByExample(stuPracticalTrainingReportExample); + if (CollectionUtils.isEmpty(stuUploadImgAiList)) { return null; - }else { + } else { return stuUploadImgAiList; } } - - @Override public void OutPdf(HttpServletResponse response, String context) { try { String s = IdUtil.simpleUUID(); - FileOutputStream fileOutputStream = new FileOutputStream(filePath+"/pdf/"+s+".pdf"); - PdfUtil.htmlStringToPdf(context,fileOutputStream); - fileUtil.download(response, s+".pdf", "/pdf/"+s+".pdf"); + FileOutputStream fileOutputStream = new FileOutputStream(filePath + "/pdf/" + s + ".pdf"); + PdfUtil.htmlStringToPdf(context, fileOutputStream); + fileUtil.download(response, s + ".pdf", "/pdf/" + s + ".pdf"); } catch (FileNotFoundException e) { throw new RuntimeException(e); @@ -541,7 +383,6 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { } - /** * 计算资源学习得分 * @@ -557,8 +398,8 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { TchModuleWeithExample example = new TchModuleWeithExample(); example.createCriteria().andSchoolIdEqualTo(stuUser.getSchoolId()); List tchModuleWeiths = tchModuleWeithMapper.selectByExample(example); - if(tchModuleWeiths.size()==0){ - TchModuleWeith tchConceptualTechnologyWeight=new TchModuleWeith(stuUser.getSchoolId()); + if (tchModuleWeiths.size() == 0) { + TchModuleWeith tchConceptualTechnologyWeight = new TchModuleWeith(stuUser.getSchoolId()); tchModuleWeithMapper.insert(tchConceptualTechnologyWeight); tchModuleWeiths.add(tchConceptualTechnologyWeight); } @@ -595,8 +436,8 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { Double scoreProject1 = stuScoreDetails.getScoreProject(); BigDecimal add = bigDecimalUtils.add(scoreProject.toString(), scoreProject1.toString()); - if(add.compareTo(BigDecimal.valueOf(100))==1){ - add=BigDecimal.valueOf(100); + if (add.compareTo(BigDecimal.valueOf(100)) == 1) { + add = BigDecimal.valueOf(100); } //时间累加 @@ -612,19 +453,18 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { //查询出学生成绩信息更新到学生列表 - StuScoreDetailsExample stuScoreDetailsExample=new StuScoreDetailsExample(); + StuScoreDetailsExample stuScoreDetailsExample = new StuScoreDetailsExample(); stuScoreDetailsExample.createCriteria().andUserIdEqualTo(stuScoreDetailsDTO.getUserId()); List stuScoreDetailsList = stuScoreDetailsMapper.selectByExample(stuScoreDetailsExample); //将分数统计到学生表中 - anaService.personalScoreEntry(stuScoreDetailsList,tchConceptualTechnologyWeight); + anaService.personalScoreEntry(stuScoreDetailsList, tchConceptualTechnologyWeight); } - /** * 计算知识概要得分 * @@ -640,8 +480,8 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { TchModuleWeithExample example = new TchModuleWeithExample(); example.createCriteria().andSchoolIdEqualTo(stuUser.getSchoolId()); List tchModuleWeiths = tchModuleWeithMapper.selectByExample(example); - if(tchModuleWeiths.isEmpty()){ - TchModuleWeith tchConceptualTechnologyWeight=new TchModuleWeith(stuUser.getSchoolId()); + if (tchModuleWeiths.isEmpty()) { + TchModuleWeith tchConceptualTechnologyWeight = new TchModuleWeith(stuUser.getSchoolId()); tchModuleWeithMapper.insert(tchConceptualTechnologyWeight); tchModuleWeiths.add(tchConceptualTechnologyWeight); } @@ -681,8 +521,8 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { Double scoreProject1 = stuScoreDetails.getScoreProject(); BigDecimal add = bigDecimalUtils.add(scoreProject.toString(), scoreProject1.toString()); - if(add.compareTo(BigDecimal.valueOf(100))==1){ - add=BigDecimal.valueOf(100); + if (add.compareTo(BigDecimal.valueOf(100)) == 1) { + add = BigDecimal.valueOf(100); } //时间累加 @@ -698,31 +538,28 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { } //查询出学生成绩信息更新到学生列表 - StuScoreDetailsExample stuScoreDetailsExample=new StuScoreDetailsExample(); + StuScoreDetailsExample stuScoreDetailsExample = new StuScoreDetailsExample(); stuScoreDetailsExample.createCriteria().andUserIdEqualTo(stuScoreDetailsDTO.getUserId()); List stuScoreDetailsList = stuScoreDetailsMapper.selectByExample(stuScoreDetailsExample); //将分数统计到学生表中 - anaService.personalScoreEntry(stuScoreDetailsList,tchConceptualTechnologyWeight); + anaService.personalScoreEntry(stuScoreDetailsList, tchConceptualTechnologyWeight); } //上传实验报告 @Override @Transactional(rollbackFor = Exception.class) public ResultEntity newUpload(MultipartFile file, StuBlockProductWithDTO stuBlockProductWithBLOBs) { - if (!StringUtils.hasText(stuBlockProductWithBLOBs.getSchoolId())) - { + if (!StringUtils.hasText(stuBlockProductWithBLOBs.getSchoolId())) { throw new RuntimeException("学校ID不能为空"); } - if (!StringUtils.hasText(stuBlockProductWithBLOBs.getUserId())) - { + if (!StringUtils.hasText(stuBlockProductWithBLOBs.getUserId())) { throw new RuntimeException("用户ID不能为空"); } - if (!StringUtils.hasText(stuBlockProductWithBLOBs.getModule())) - { + if (!StringUtils.hasText(stuBlockProductWithBLOBs.getModule())) { throw new RuntimeException("模块不能为空"); } @@ -731,9 +568,9 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { String sp = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); - String [] array = {"docx","doc", "pdf", "jpg", "png", "mp4", "avi"}; + String[] array = {"docx", "doc", "pdf", "jpg", "png", "mp4", "avi"}; List collect = Arrays.stream(array).collect(Collectors.toList()); - if (!collect.contains(sp)){ + if (!collect.contains(sp)) { throw new RuntimeException("上传格式仅支持:Word,PDF,图片,视频"); } @@ -744,43 +581,43 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { .andUseridEqualTo(stuBlockProductWithBLOBs.getUserId()); List stuPracticalTrainingReportList = stuPracticalTrainingReportMapper.selectByExample(example); - if (CollectionUtils.isEmpty(stuPracticalTrainingReportList)){ + if (CollectionUtils.isEmpty(stuPracticalTrainingReportList)) { //第一次上传 - StuPracticalTrainingReport stuPracticalTrainingReport = uploadByReport(file,stuBlockProductWithBLOBs); + StuPracticalTrainingReport stuPracticalTrainingReport = uploadByReport(file, stuBlockProductWithBLOBs); stuPracticalTrainingReport.setAscription(String.valueOf(1)); stuPracticalTrainingReportMapper.insertSelective(stuPracticalTrainingReport); stuPracticalTrainingReportList.add(stuPracticalTrainingReport); - return new ResultEntity<>(HttpStatus.OK,stuPracticalTrainingReportList); + return new ResultEntity<>(HttpStatus.OK, stuPracticalTrainingReportList); - }else if (stuPracticalTrainingReportList.size() == 1){ + } else if (stuPracticalTrainingReportList.size() == 1) { - StuPracticalTrainingReport stuPracticalTrainingReport = uploadByReport(file,stuBlockProductWithBLOBs); + StuPracticalTrainingReport stuPracticalTrainingReport = uploadByReport(file, stuBlockProductWithBLOBs); stuPracticalTrainingReport.setAscription(String.valueOf(2)); stuPracticalTrainingReportMapper.insertSelective(stuPracticalTrainingReport); stuPracticalTrainingReportList.add(stuPracticalTrainingReport); - return new ResultEntity<>(HttpStatus.OK,stuPracticalTrainingReportList); + return new ResultEntity<>(HttpStatus.OK, stuPracticalTrainingReportList); - }else if (stuPracticalTrainingReportList.size() == 2){ + } else if (stuPracticalTrainingReportList.size() == 2) { - StuPracticalTrainingReport stuPracticalTrainingReport = uploadByReport(file,stuBlockProductWithBLOBs); + StuPracticalTrainingReport stuPracticalTrainingReport = uploadByReport(file, stuBlockProductWithBLOBs); stuPracticalTrainingReport.setAscription(String.valueOf(3)); stuPracticalTrainingReportMapper.insertSelective(stuPracticalTrainingReport); stuPracticalTrainingReportList.add(stuPracticalTrainingReport); - return new ResultEntity<>(HttpStatus.OK,stuPracticalTrainingReportList); - }else { - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"系统允许您上传至多三份实验报告!",stuPracticalTrainingReportList); + return new ResultEntity<>(HttpStatus.OK, stuPracticalTrainingReportList); + } else { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "系统允许您上传至多三份实验报告!", stuPracticalTrainingReportList); } } @Override - public ResultEntity downReportByZip(HttpServletResponse response,String userId,String module,String reportName) { + public ResultEntity downReportByZip(HttpServletResponse response, String userId, String module, String reportName) { StuPracticalTrainingReportExample example = new StuPracticalTrainingReportExample(); StuPracticalTrainingReportExample.Criteria criteria = example.createCriteria() .andModuleEqualTo(module) @@ -839,8 +676,6 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { } - - return null; } @@ -864,7 +699,7 @@ public class StuConceptBlockServiceImpl implements StuConceptBlockService { } - public File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException { + public File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException { // 创建一个临时文件 File tempFile = File.createTempFile("temp", null); diff --git a/src/main/java/com/sztzjy/marketing/service/impl/StuFiveGTrainingServiceImpl.java b/src/main/java/com/sztzjy/marketing/service/impl/StuFiveGTrainingServiceImpl.java index b52ff92..043226a 100644 --- a/src/main/java/com/sztzjy/marketing/service/impl/StuFiveGTrainingServiceImpl.java +++ b/src/main/java/com/sztzjy/marketing/service/impl/StuFiveGTrainingServiceImpl.java @@ -65,7 +65,6 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { StuDigitalConfirmationMapper stuDigitalConfirmationMapper; - /** * Hadoop实验实训 * @@ -91,7 +90,6 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { map.put("非关系型数据库", "HBase"); map.put("文件存储", "HDFS"); map.put("数据传递", "Sqoop"); - map.put("日志收集", "Flume"); map.put("消息队列", "Kafka"); map.put("数据平台配置和调度", "ZooKeeper"); @@ -110,13 +108,12 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { //答案 String info = temp.replaceAll("[12]", ""); - // String s1 = context.replaceAll("[12]", ""); + // String s1 = context.replaceAll("[12]", ""); //查询有无数据 有数据插入更新状态为1 //没有则插入 //不是第一次做题 - if (stuHadoopTrains!=null && stuHadoopTrains.size()>0) - { + if (stuHadoopTrains != null && stuHadoopTrains.size() > 0) { String append = stuHadoopTrains.get(0).getAppend(); @@ -125,22 +122,18 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { //判断是否做过改题目 String[] split = parsed.split(","); //判断够不够16个 - if (split.length==16){ + if (split.length == 16) { //判断是否包含 - if (Arrays.asList(split).contains(context)){ + if (Arrays.asList(split).contains(context)) { return info; } - - - //判断完成状态 - if (stuHadoopTrains.get(0).getState()==0) - { + if (stuHadoopTrains.get(0).getState() == 0) { - String Info = parsed + context +","; + String Info = parsed + context + ","; String jsonString = JSON.toJSONString(Info); stuHadoopTrains.get(0).setAppend(jsonString); @@ -151,34 +144,23 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { //提交答题错误 Integer anInt = Convert.toInt(stuHadoopTrains.get(0).getWrongDetail()); // stuDigitalIndustrializationService.practicalTrainingSubmission(userId,"大数据","Hadoop",anInt); - } - return info; } - if (Arrays.asList(split).contains(context)){ - - return info; - + if (Arrays.asList(split).contains(context)) { + return info; } - - String Info = parsed + context +","; - + String Info = parsed + context + ","; String jsonString = JSON.toJSONString(Info); stuHadoopTrains.get(0).setAppend(jsonString); stuHadoopTrainMapper.updateByPrimaryKeySelective(stuHadoopTrains.get(0)); return info; - }else { - - + } else { String currentInfo = context + ","; - String jsonString = JSON.toJSONString(currentInfo); - - StuHadoopTrain stuHadoopTrain = new StuHadoopTrain(); stuHadoopTrain.setId((int) IdUtil.getSnowflakeNextId()); stuHadoopTrain.setAppend(jsonString); @@ -191,17 +173,14 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { return info; } else { //不相同 查看有无数据 - - if (stuHadoopTrains!=null && stuHadoopTrains.size()>0) - { + if (stuHadoopTrains != null && stuHadoopTrains.size() > 0) { StuHadoopTrain stuHadoopTrain = stuHadoopTrains.get(0); String wrongDetail = stuHadoopTrain.getWrongDetail(); - - int count = Convert.toInt(wrongDetail)+ 1; + int count = Convert.toInt(wrongDetail) + 1; stuHadoopTrain.setWrongDetail(String.valueOf(count)); stuHadoopTrainMapper.updateByPrimaryKeySelective(stuHadoopTrain); - }else { + } else { StuHadoopTrain stuHadoopTrain = new StuHadoopTrain(); stuHadoopTrain.setId((int) IdUtil.getSnowflakeNextId()); stuHadoopTrain.setAppend("1"); @@ -219,7 +198,6 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } - /** * 下载文档 */ @@ -321,7 +299,7 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { stuDigServiceTradeMapper.updateByPrimaryKeySelective(stuDigServiceTrades.get(0)); } else { int i = UUID.randomUUID().hashCode(); - int id= i > 0 ? i : -i; + int id = i > 0 ? i : -i; StuDigServiceTrade build = StuDigServiceTrade.builder().id(id).domeLicense(url).userId(userId).build(); @@ -347,7 +325,7 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { stuDigServiceTradeMapper.updateByPrimaryKeySelective(stuDigServiceTrades.get(0)); } else { int i = UUID.randomUUID().hashCode(); - int id= i > 0 ? i : -i; + int id = i > 0 ? i : -i; StuDigServiceTrade build = StuDigServiceTrade.builder().id(id).abroadBusReg(url).userId(userId).build(); @@ -367,7 +345,7 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { List stuImageRecognitionList = stuImageRecognitionTrainingMapper.selectByExample(Stuexample); - if (stuImageRecognitionList.size()==2){ + if (stuImageRecognitionList.size() == 2) { List collect = stuImageRecognitionList.stream().sorted(Comparator.comparing(StuImageRecognitionTraining::getStemContent).reversed()).collect(Collectors.toList()); return collect; @@ -429,19 +407,18 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { if (stuImageRecognitionList.size() > 0) { List collect = stuImageRecognitionList.stream().filter(item -> item.getStemContent().equals("请选择一种最优的方法先获得文章的图片。")).collect(Collectors.toList()); - if (collect.size() > 0 ) { - if (collect.get(0).getStudentAnswer().equals("B")){ + if (collect.size() > 0) { + if (collect.get(0).getStudentAnswer().equals("B")) { - if ("A".equals(answer) ){ + if ("A".equals(answer)) { return "选择错误!"; } return "提交成功"; } - if ("A".equals(answer) ) - { + if ("A".equals(answer)) { throw new InvoceTException(HttpStatus.ACCEPTED, "选择错误"); - }else { + } else { collect.get(0).setStudentAnswer("B"); stuImageRecognitionTrainingMapper.updateByPrimaryKey(collect.get(0)); return "选择正确!"; @@ -510,25 +487,23 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { String[] select = answer.split(","); Arrays.sort(select); - String arr[] = {"A","B","C","D","E"}; + String arr[] = {"A", "B", "C", "D", "E"}; - if (stuImageRecognitionList.size() > 0 ) { + if (stuImageRecognitionList.size() > 0) { List collect = stuImageRecognitionList.stream().filter(item -> item.getStemContent().equals("以下选项属于图片预处理方法的是?")).collect(Collectors.toList()); - if (collect.size() > 0 ) { - if (collect.get(0).getStudentAnswer().equals("A,B,C,D,E")){ - if (!Arrays.equals(arr, select)) - { + if (collect.size() > 0) { + if (collect.get(0).getStudentAnswer().equals("A,B,C,D,E")) { + if (!Arrays.equals(arr, select)) { return "选择错误!"; } - return "提交成功"; + return "提交成功"; } - if (!Arrays.equals(arr, select)) - { + if (!Arrays.equals(arr, select)) { return "选择错误!"; - }else { + } else { collect.get(0).setStudentAnswer(answer); stuImageRecognitionTrainingMapper.updateByPrimaryKey(collect.get(0)); return "选择正确!"; @@ -540,7 +515,6 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } - String[] stuAnswer = answer.split(","); StuImageRecognitionTrainingExample example = new StuImageRecognitionTrainingExample(); @@ -581,7 +555,8 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } /** - *机器人:获取题目 + * 机器人:获取题目 + * * @param userId * @return */ @@ -606,23 +581,21 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { ArrayList arrayList = new ArrayList<>(); - if (lastRecognitionTrainingList.size()>0) - { + if (lastRecognitionTrainingList.size() > 0) { //用户可能未做题,需要返回题目和已做题目和结果 for (int i = 0; i < firstRecognitionTrainingLists.size(); i++) { for (int j = 0; j < lastRecognitionTrainingList.size(); j++) { //查询出已做题目 根据题目判断 - if (firstRecognitionTrainingLists.get(i).getOptionF().equals(lastRecognitionTrainingList.get(j).getOptionF())){ + if (firstRecognitionTrainingLists.get(i).getOptionF().equals(lastRecognitionTrainingList.get(j).getOptionF())) { arrayList.add(lastRecognitionTrainingList.get(j)); continue; - }else { + } else { firstCollect.removeAll(lastCollect); for (int z = 0; z < firstCollect.size(); z++) { - if (firstRecognitionTrainingLists.get(i).getOptionF().equals(firstCollect.get(z))) - { + if (firstRecognitionTrainingLists.get(i).getOptionF().equals(firstCollect.get(z))) { arrayList.add(firstRecognitionTrainingLists.get(i)); - break; + break; } } @@ -631,17 +604,16 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } - Collections.sort(arrayList,Comparator.comparing(StuImageRecognitionTraining::getOptionF)); - arrayList.forEach(item->{ + Collections.sort(arrayList, Comparator.comparing(StuImageRecognitionTraining::getOptionF)); + arrayList.forEach(item -> { item.setOptionF(null); item.setModel(null); }); return arrayList; - }else { - if (firstRecognitionTrainingLists.size()>0) - { + } else { + if (firstRecognitionTrainingLists.size() > 0) { //不返回正确答案 - firstRecognitionTrainingLists.forEach(item->{ + firstRecognitionTrainingLists.forEach(item -> { item.setCorrectAnswer(null); item.setModel(null); item.setOptionF(null); @@ -649,40 +621,36 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { ); return firstRecognitionTrainingLists; - }else { - throw new InvoceTException(HttpStatus.ACCEPTED,"未查询到题目"); + } else { + throw new InvoceTException(HttpStatus.ACCEPTED, "未查询到题目"); } } } /** - * 机器人:提交题目 - * @param robotTitleSubDTO - * @return - */ + * 机器人:提交题目 + * + * @param robotTitleSubDTO + * @return + */ @Override public Integer robotTitleSub(robotTitleSubDTO robotTitleSubDTO) { - - //判断是否多次提交 StuImageRecognitionTrainingExample example = new StuImageRecognitionTrainingExample(); example.createCriteria().andUserIdEqualTo(robotTitleSubDTO.getUserId()).andModelEqualTo("机器人"); List lists = stuImageRecognitionTrainingMapper.selectByExample(example); //第n次提交 - if (lists.size()>0 && lists != null) - { - + if (lists.size() > 0 && lists != null) { return -10; } - //记录错误次数 int sum = 0; //获取所有结果 @@ -690,19 +658,19 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { firstExample.createCriteria().andUserIdIsNull().andModelEqualTo("机器人"); List firstRecognitionTrainingLists = stuImageRecognitionTrainingMapper.selectByExample(firstExample); - Map strings = new HashMap<>(); + Map strings = new HashMap<>(); - strings.put("步骤一",robotTitleSubDTO.getFirstTitle()); - strings.put("步骤二",robotTitleSubDTO.getSecondTitle()); - strings.put("步骤三",robotTitleSubDTO.getThirdTitle()); + strings.put("步骤一", robotTitleSubDTO.getFirstTitle()); + strings.put("步骤二", robotTitleSubDTO.getSecondTitle()); + strings.put("步骤三", robotTitleSubDTO.getThirdTitle()); - if (firstRecognitionTrainingLists.size()>0){ + if (firstRecognitionTrainingLists.size() > 0) { //获取三个题目的结果判断对错 // 第一题 for (int i = 0; i < firstRecognitionTrainingLists.size(); i++) { - // for (Map.Entry entry : strings.entrySet()) { + // for (Map.Entry entry : strings.entrySet()) { Iterator> iterator = strings.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = iterator.next(); @@ -713,9 +681,9 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { sum++; //用户答案为空 也是错误 StuImageRecognitionTraining stuImageRecognitionTraining = new StuImageRecognitionTraining(); - BeanUtils.copyProperties( firstRecognitionTrainingLists.get(i),stuImageRecognitionTraining); + BeanUtils.copyProperties(firstRecognitionTrainingLists.get(i), stuImageRecognitionTraining); stuImageRecognitionTraining.setUserId(robotTitleSubDTO.getUserId()); - stuImageRecognitionTraining.setId((int)IdUtil.getSnowflakeNextId()); + stuImageRecognitionTraining.setId((int) IdUtil.getSnowflakeNextId()); stuImageRecognitionTraining.setStudentAnswer("该题未做"); stuImageRecognitionTraining.setRightOrWrong(0); @@ -724,8 +692,7 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } - - if (key.equals(firstRecognitionTrainingLists.get(i).getOptionF())){ + if (key.equals(firstRecognitionTrainingLists.get(i).getOptionF())) { //比较答案判断对错 //用户答案 String[] stuFirst = value.split(","); @@ -736,18 +703,17 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { boolean equals = Arrays.equals(stuFirst, correctAnswer); StuImageRecognitionTraining stuImageRecognitionTraining = new StuImageRecognitionTraining(); - BeanUtils.copyProperties( firstRecognitionTrainingLists.get(i),stuImageRecognitionTraining); + BeanUtils.copyProperties(firstRecognitionTrainingLists.get(i), stuImageRecognitionTraining); stuImageRecognitionTraining.setUserId(robotTitleSubDTO.getUserId()); - stuImageRecognitionTraining.setId((int)IdUtil.getSnowflakeNextId()); + stuImageRecognitionTraining.setId((int) IdUtil.getSnowflakeNextId()); stuImageRecognitionTraining.setStudentAnswer(value); - if (!equals) - { + if (!equals) { stuImageRecognitionTraining.setRightOrWrong(0); sum++; - }else { + } else { stuImageRecognitionTraining.setRightOrWrong(1); @@ -762,8 +728,8 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } - }else { - throw new InvoceTException(HttpStatus.ACCEPTED,"题目不存在"); + } else { + throw new InvoceTException(HttpStatus.ACCEPTED, "题目不存在"); } return sum; } @@ -777,12 +743,12 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { StuHadoopTrainExample stuHadoopTrainExample = new StuHadoopTrainExample(); stuHadoopTrainExample.createCriteria().andUserIdEqualTo(userId); List stuHadoopTrainList = stuHadoopTrainMapper.selectByExample(stuHadoopTrainExample); - if (!stuHadoopTrainList.isEmpty()) - { String appendOne = stuHadoopTrainList.get(0).getAppend(); + if (!stuHadoopTrainList.isEmpty()) { + String appendOne = stuHadoopTrainList.get(0).getAppend(); String parsedOne = JSON.parseObject(appendOne, String.class); //判断是否做过改题目 String[] split = parsedOne.split(","); - if (split.length!=17){ + if (split.length != 17) { stuHadoopTrainMapper.deleteByPrimaryKey(stuHadoopTrainList.get(0).getId()); @@ -792,9 +758,6 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } - - - } @Override @@ -805,8 +768,7 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { StuHadoopTrainExample stuHadoopTrainExample = new StuHadoopTrainExample(); stuHadoopTrainExample.createCriteria().andUserIdEqualTo(userId); List stuHadoopTrainList = stuHadoopTrainMapper.selectByExample(stuHadoopTrainExample); - if (!stuHadoopTrainList.isEmpty()) - { + if (!stuHadoopTrainList.isEmpty()) { StuHadoopTrain stuHadoopTrain = stuHadoopTrainList.get(0); Integer state = stuHadoopTrain.getState(); return state; @@ -817,18 +779,6 @@ public class StuFiveGTrainingServiceImpl implements StuFiveGTrainingService { } - - - - - - - - - - - - // //自然语言处理:获取题目 // @Override // public List getTitles(String userId) { diff --git a/src/main/java/com/sztzjy/marketing/service/impl/StuUserProfileDatabaseServiceImpl.java b/src/main/java/com/sztzjy/marketing/service/impl/StuUserProfileDatabaseServiceImpl.java index 6608871..6ba6b44 100644 --- a/src/main/java/com/sztzjy/marketing/service/impl/StuUserProfileDatabaseServiceImpl.java +++ b/src/main/java/com/sztzjy/marketing/service/impl/StuUserProfileDatabaseServiceImpl.java @@ -42,9 +42,6 @@ public class StuUserProfileDatabaseServiceImpl implements StuUserProfileDatabase private StuUploadExcelUserMapper uploadExcelUserMapper; - - - /** * 用户数据基本信息 * @@ -63,9 +60,6 @@ public class StuUserProfileDatabaseServiceImpl implements StuUserProfileDatabase list.add("用户评论表"); //用户属性表 - - - StuUserAttributeExample userAttributeExample = new StuUserAttributeExample(); userAttributeExample.setOrderByClause("id asc"); List userAttributeList = userAttributeMapper.selectByExample(userAttributeExample); @@ -85,13 +79,12 @@ public class StuUserProfileDatabaseServiceImpl implements StuUserProfileDatabase .tableNames(list).build(); - return new ResultEntity<>(HttpStatus.OK,userProfileDto); + return new ResultEntity<>(HttpStatus.OK, userProfileDto); } /** * 条件查询用户表信息 - * * @param userId * @param tableName * @param selfTableName @@ -99,115 +92,112 @@ public class StuUserProfileDatabaseServiceImpl implements StuUserProfileDatabase */ @Override - public ResultEntity getBaseInfoBySelect(String userId, String tableName, String selfTableName,Integer index,Integer size) { + public ResultEntity getBaseInfoBySelect(String userId, String tableName, String selfTableName, Integer index, Integer size) { - if (index == null || size == null ) - { + if (index == null || size == null) { - throw new RuntimeException( "请输入正确的页码格式!"); + throw new RuntimeException("请输入正确的页码格式!"); } - if(tableName!=null && !tableName.isEmpty()){ - switch (tableName){ - case Constant.YONGHUSHUXINGBIAO: - //开启分页 - PageHelper.startPage(index,size); - //用户属性表 - StuUserAttributeExample userAttributeExample = new StuUserAttributeExample(); - userAttributeExample.setOrderByClause("id asc"); - List userAttributeList = userAttributeMapper.selectByExample(userAttributeExample); - if (userAttributeList.isEmpty()) { - throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); - } - - return new ResultEntity<>(HttpStatus.OK,new PageInfo<>(userAttributeList)); - - case Constant.YONGHUDENGLUHUOYUEBIAO: - //开启分页 - PageHelper.startPage(index,size); - //用户登录活跃表 - StuUserLoginActiveExample userLoginActiveExample = new StuUserLoginActiveExample(); - userLoginActiveExample.setOrderByClause("id asc"); - List userLoginActiveList = userLoginActiveMapper.selectByExample(userLoginActiveExample); - if (userLoginActiveList.isEmpty()) { - throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); - } - - return new ResultEntity<>(HttpStatus.OK,new PageInfo<>(userLoginActiveList)); - - - case Constant.YONGHUXIAOFEINENGLIBIAO: - //开启分页 - PageHelper.startPage(index,size); - //用户消费能力表 - StuUserConsumptionAbilityExample userConsumptionAbilityExample = new StuUserConsumptionAbilityExample(); - userConsumptionAbilityExample.setOrderByClause("id asc"); - List userConsumptionAbilityList = userConsumptionAbilityMapper.selectByExample(userConsumptionAbilityExample); - if (userConsumptionAbilityList.isEmpty()) { - throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); - } - - return new ResultEntity<>(HttpStatus.OK,new PageInfo<>(userConsumptionAbilityList)); - - case Constant.YONGHUXINGWEIBIAO: - //开启分页 - PageHelper.startPage(index,size); - //用户行为表 - StuUserAttributeBehaviorExample userAttributeBehaviorExample = new StuUserAttributeBehaviorExample(); - userAttributeBehaviorExample.setOrderByClause("id asc"); - List userAttributeBehaviorList = userAttributeBehaviorMapper.selectByExample(userAttributeBehaviorExample); - if (userAttributeBehaviorList.isEmpty()) { - throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); - } - - return new ResultEntity<>(HttpStatus.OK,new PageInfo<>(userAttributeBehaviorList)); + if (tableName != null && !tableName.isEmpty()) { + switch (tableName) { + case Constant.YONGHUSHUXINGBIAO: + //开启分页 + PageHelper.startPage(index, size); + //用户属性表 + StuUserAttributeExample userAttributeExample = new StuUserAttributeExample(); + userAttributeExample.setOrderByClause("id asc"); + List userAttributeList = userAttributeMapper.selectByExample(userAttributeExample); + if (userAttributeList.isEmpty()) { + throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); + } + + return new ResultEntity<>(HttpStatus.OK, new PageInfo<>(userAttributeList)); + + case Constant.YONGHUDENGLUHUOYUEBIAO: + //开启分页 + PageHelper.startPage(index, size); + //用户登录活跃表 + StuUserLoginActiveExample userLoginActiveExample = new StuUserLoginActiveExample(); + userLoginActiveExample.setOrderByClause("id asc"); + List userLoginActiveList = userLoginActiveMapper.selectByExample(userLoginActiveExample); + if (userLoginActiveList.isEmpty()) { + throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); + } + + return new ResultEntity<>(HttpStatus.OK, new PageInfo<>(userLoginActiveList)); + + + case Constant.YONGHUXIAOFEINENGLIBIAO: + //开启分页 + PageHelper.startPage(index, size); + //用户消费能力表 + StuUserConsumptionAbilityExample userConsumptionAbilityExample = new StuUserConsumptionAbilityExample(); + userConsumptionAbilityExample.setOrderByClause("id asc"); + List userConsumptionAbilityList = userConsumptionAbilityMapper.selectByExample(userConsumptionAbilityExample); + if (userConsumptionAbilityList.isEmpty()) { + throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); + } + + return new ResultEntity<>(HttpStatus.OK, new PageInfo<>(userConsumptionAbilityList)); + + case Constant.YONGHUXINGWEIBIAO: + //开启分页 + PageHelper.startPage(index, size); + //用户行为表 + StuUserAttributeBehaviorExample userAttributeBehaviorExample = new StuUserAttributeBehaviorExample(); + userAttributeBehaviorExample.setOrderByClause("id asc"); + List userAttributeBehaviorList = userAttributeBehaviorMapper.selectByExample(userAttributeBehaviorExample); + if (userAttributeBehaviorList.isEmpty()) { + throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); + } + + return new ResultEntity<>(HttpStatus.OK, new PageInfo<>(userAttributeBehaviorList)); //todo 用户评论表 - case Constant.YONGHUPINGLUNBIAO: - //开启分页 - PageHelper.startPage(index,size); - //用户行为表 - StuUserAttributeBehaviorExample behaviorExample = new StuUserAttributeBehaviorExample(); - behaviorExample.setOrderByClause("id asc"); - List behaviorList = userAttributeBehaviorMapper.selectByExample(behaviorExample); - if (behaviorList.isEmpty()) { - throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); - } - - return new ResultEntity<>(HttpStatus.OK,new PageInfo<>(behaviorList)); - - //todo 用户评论表 - } + case Constant.YONGHUPINGLUNBIAO: + //开启分页 + PageHelper.startPage(index, size); + //用户行为表 + StuUserAttributeBehaviorExample behaviorExample = new StuUserAttributeBehaviorExample(); + behaviorExample.setOrderByClause("id asc"); + List behaviorList = userAttributeBehaviorMapper.selectByExample(behaviorExample); + if (behaviorList.isEmpty()) { + throw new ServiceException(HttpStatus.OK, "未查询到用户数据!"); + } + + return new ResultEntity<>(HttpStatus.OK, new PageInfo<>(behaviorList)); - } + //todo 用户评论表 + } + } - if(selfTableName!=null && !selfTableName.isEmpty()){ - //todo 自建表查询 - List nameList = uploadExcelUserMapper.selectDistModuleName(userId); - String module = nameList.stream().filter(item -> item.equals(selfTableName)).findFirst().orElse(null); + if (selfTableName != null && !selfTableName.isEmpty()) { + //todo 自建表查询 - if (module==null) - { - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"自建表不存在"); - } - PageHelper.startPage(index,size); - StuUploadExcelUserExample uploadExcelUserExample = new StuUploadExcelUserExample(); - uploadExcelUserExample.createCriteria().andUserIdEqualTo(userId).andModuleEqualTo(module); - List stuUploadExcelUsers = uploadExcelUserMapper.selectByExample(uploadExcelUserExample); + List nameList = uploadExcelUserMapper.selectDistModuleName(userId); + String module = nameList.stream().filter(item -> item.equals(selfTableName)).findFirst().orElse(null); - if (stuUploadExcelUsers.isEmpty()) - { - return new ResultEntity<>(HttpStatus.OK,"数据不存在!"); - } + if (module == null) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "自建表不存在"); + } + PageHelper.startPage(index, size); + StuUploadExcelUserExample uploadExcelUserExample = new StuUploadExcelUserExample(); + uploadExcelUserExample.createCriteria().andUserIdEqualTo(userId).andModuleEqualTo(module); + List stuUploadExcelUsers = uploadExcelUserMapper.selectByExample(uploadExcelUserExample); + if (stuUploadExcelUsers.isEmpty()) { + return new ResultEntity<>(HttpStatus.OK, "数据不存在!"); + } - return new ResultEntity<>(HttpStatus.OK,new PageInfo<>(stuUploadExcelUsers)); - } + return new ResultEntity<>(HttpStatus.OK, new PageInfo<>(stuUploadExcelUsers)); + + } - return new ResultEntity<>(HttpStatus.BAD_REQUEST,"请求错误"); + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请求错误"); } @@ -215,8 +205,7 @@ public class StuUserProfileDatabaseServiceImpl implements StuUserProfileDatabase public ResultEntity selfExcelBaseInfo(String userId) { List nameList = uploadExcelUserMapper.selectDistModuleName(userId); - return new ResultEntity<>(HttpStatus.OK,nameList); - + return new ResultEntity<>(HttpStatus.OK, nameList); } diff --git a/src/main/java/com/sztzjy/marketing/service/impl/UserBehaviorProfilingAnaServiceImpl.java b/src/main/java/com/sztzjy/marketing/service/impl/UserBehaviorProfilingAnaServiceImpl.java index 83eb4a6..fea37d3 100644 --- a/src/main/java/com/sztzjy/marketing/service/impl/UserBehaviorProfilingAnaServiceImpl.java +++ b/src/main/java/com/sztzjy/marketing/service/impl/UserBehaviorProfilingAnaServiceImpl.java @@ -99,6 +99,25 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin } + if (StringUtils.hasText(learning.getStepechartlist1())) + { + String json = JSONObject.toJSONString(learning.getStepechartlist1()); + machineLearning.setStepechartlist1(json); + } + + if (StringUtils.hasText(learning.getStepechartlist2())) + { + String json = JSONObject.toJSONString(learning.getStepechartlist2()); + machineLearning.setStepechartlist2(json); + } + + if (StringUtils.hasText(learning.getStepechartlist3())) + { + String json = JSONObject.toJSONString(learning.getStepechartlist3()); + machineLearning.setStepechartlist3(json); + } + + machineLearningMapper.updateByPrimaryKeySelective(machineLearning); return new ResultEntity<>(HttpStatus.OK, "保存成功!"); @@ -114,7 +133,23 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin learning.setActiveUserAnalysis(json); } + if (StringUtils.hasText(learning.getStepechartlist1())) + { + String json = JSONObject.toJSONString(learning.getStepechartlist1()); + learning.setStepechartlist1(json); + } + + if (StringUtils.hasText(learning.getStepechartlist2())) + { + String json = JSONObject.toJSONString(learning.getStepechartlist2()); + learning.setStepechartlist2(json); + } + if (StringUtils.hasText(learning.getStepechartlist3())) + { + String json = JSONObject.toJSONString(learning.getStepechartlist3()); + learning.setStepechartlist3(json); + } machineLearningMapper.insertSelective(learning); return new ResultEntity<>(HttpStatus.OK, "保存成功!"); @@ -142,15 +177,28 @@ public class UserBehaviorProfilingAnaServiceImpl implements UserBehaviorProfilin } String activeUserAnalysis = machineLearningList.get(0).getActiveUserAnalysis(); - List stuMachineLearningInfoDTOList = JSONObject.parseArray(activeUserAnalysis, StuMachineLearningInfoDTO.class); + if(StringUtils.hasText(activeUserAnalysis)){ + List stuMachineLearningInfoDTOList = JSONObject.parseArray(activeUserAnalysis, StuMachineLearningInfoDTO.class); + machineLearningList.get(0).setStuMachineLearningInfoDTOList(stuMachineLearningInfoDTOList); + } + if(StringUtils.hasText(machineLearningList.get(0).getStepechartlist1())){ + String stuMachineLearningInfoDTOList = JSONObject.parseObject(machineLearningList.get(0).getStepechartlist1(), String.class); + machineLearningList.get(0).setStepechartlist1(stuMachineLearningInfoDTOList); + } + if(StringUtils.hasText(machineLearningList.get(0).getStepechartlist2())){ + String stuMachineLearningInfoDTOList = JSONObject.parseObject(machineLearningList.get(0).getStepechartlist2(), String.class); + machineLearningList.get(0).setStepechartlist2(stuMachineLearningInfoDTOList); + } - machineLearningList.get(0).setStuMachineLearningInfoDTOList(stuMachineLearningInfoDTOList); + if(StringUtils.hasText(machineLearningList.get(0).getStepechartlist3())){ + String stuMachineLearningInfoDTOList = JSONObject.parseObject(machineLearningList.get(0).getStepechartlist3(), String.class); + machineLearningList.get(0).setStepechartlist3(stuMachineLearningInfoDTOList); + } return new ResultEntity<>(HttpStatus.OK, "查询成功", machineLearningList.get(0)); - } /** diff --git a/src/main/resources/mappers/StuMachineLearningMapper.xml b/src/main/resources/mappers/StuMachineLearningMapper.xml index 4b255c9..1bc0ac3 100644 --- a/src/main/resources/mappers/StuMachineLearningMapper.xml +++ b/src/main/resources/mappers/StuMachineLearningMapper.xml @@ -77,6 +77,9 @@ + + + @@ -151,7 +154,7 @@ step_new_shiliu - active_user_analysis + active_user_analysis, stepEchartList1, stepEchartList2, stepEchartList3 @@ -926,6 +951,15 @@ active_user_analysis = #{record.activeUserAnalysis,jdbcType=LONGVARCHAR}, + + stepEchartList1 = #{record.stepechartlist1,jdbcType=LONGVARCHAR}, + + + stepEchartList2 = #{record.stepechartlist2,jdbcType=LONGVARCHAR}, + + + stepEchartList3 = #{record.stepechartlist3,jdbcType=LONGVARCHAR}, + @@ -1005,7 +1039,10 @@ step_new_shisi = #{record.stepNewShisi,jdbcType=VARCHAR}, step_new_shiwu = #{record.stepNewShiwu,jdbcType=VARCHAR}, step_new_shiliu = #{record.stepNewShiliu,jdbcType=VARCHAR}, - active_user_analysis = #{record.activeUserAnalysis,jdbcType=LONGVARCHAR} + active_user_analysis = #{record.activeUserAnalysis,jdbcType=LONGVARCHAR}, + stepEchartList1 = #{record.stepechartlist1,jdbcType=LONGVARCHAR}, + stepEchartList2 = #{record.stepechartlist2,jdbcType=LONGVARCHAR}, + stepEchartList3 = #{record.stepechartlist3,jdbcType=LONGVARCHAR} @@ -1307,6 +1344,15 @@ active_user_analysis = #{activeUserAnalysis,jdbcType=LONGVARCHAR}, + + stepEchartList1 = #{stepechartlist1,jdbcType=LONGVARCHAR}, + + + stepEchartList2 = #{stepechartlist2,jdbcType=LONGVARCHAR}, + + + stepEchartList3 = #{stepechartlist3,jdbcType=LONGVARCHAR}, + where id = #{id,jdbcType=INTEGER} @@ -1383,7 +1429,10 @@ step_new_shisi = #{stepNewShisi,jdbcType=VARCHAR}, step_new_shiwu = #{stepNewShiwu,jdbcType=VARCHAR}, step_new_shiliu = #{stepNewShiliu,jdbcType=VARCHAR}, - active_user_analysis = #{activeUserAnalysis,jdbcType=LONGVARCHAR} + active_user_analysis = #{activeUserAnalysis,jdbcType=LONGVARCHAR}, + stepEchartList1 = #{stepechartlist1,jdbcType=LONGVARCHAR}, + stepEchartList2 = #{stepechartlist2,jdbcType=LONGVARCHAR}, + stepEchartList3 = #{stepechartlist3,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=INTEGER} diff --git a/src/main/resources/mappers/StuUploadImgAiMapper.xml b/src/main/resources/mappers/StuUploadImgAiMapper.xml index e956656..2897248 100644 --- a/src/main/resources/mappers/StuUploadImgAiMapper.xml +++ b/src/main/resources/mappers/StuUploadImgAiMapper.xml @@ -394,17 +394,17 @@ - - - - - - - - - - - - - + \ No newline at end of file