完成教师端所有功能
parent
c0b2fcf1ef
commit
4f2d24630f
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,198 @@
|
||||
package com.sztzjy.digital_credit.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nimbusds.jose.shaded.gson.Gson;
|
||||
|
||||
import com.sztzjy.digital_credit.annotation.AnonymousAccess;
|
||||
import com.sztzjy.digital_credit.config.security.TokenProvider;
|
||||
import com.sztzjy.digital_credit.entity.*;
|
||||
import com.sztzjy.digital_credit.entity.dto.StuBlockProductWithDTO;
|
||||
import com.sztzjy.digital_credit.entity.dto.StuLearningAssessmentDTO;
|
||||
import com.sztzjy.digital_credit.entity.dto.StuLearningAssessmentScoreDTO;
|
||||
import com.sztzjy.digital_credit.entity.dto.StuScoreDetailsDTO;
|
||||
import com.sztzjy.digital_credit.mapper.StuResourcesMapper;
|
||||
import com.sztzjy.digital_credit.service.StuConceptBlockService;
|
||||
import com.sztzjy.digital_credit.util.ResultDataEntity;
|
||||
import com.sztzjy.digital_credit.util.ResultEntity;
|
||||
import com.sztzjy.digital_credit.util.file.IFileUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(tags="区块链")
|
||||
@RequestMapping("/api/stu/concept/block")
|
||||
public class StuConceptBlockController {
|
||||
|
||||
|
||||
@Resource
|
||||
private StuConceptBlockService stuConceptBlockService;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;
|
||||
|
||||
|
||||
@Resource
|
||||
private StuResourcesMapper stuResourcesMapper;
|
||||
|
||||
|
||||
|
||||
@ApiOperation("区块链学习资源查看")
|
||||
@PostMapping("/getBlockResources")
|
||||
@AnonymousAccess
|
||||
public ResultDataEntity<StuResources> getBlockResources(@RequestBody JSONObject jsonObject) {
|
||||
String module = jsonObject.getString("module");
|
||||
if (module.isEmpty()) {
|
||||
return new ResultDataEntity(HttpStatus.NO_CONTENT, "参数为空");
|
||||
}
|
||||
List<StuResources> conceptBlockResources = stuConceptBlockService.getConceptBlockResources(module);
|
||||
return new ResultDataEntity(HttpStatus.OK, conceptBlockResources);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("区块链知识笔记查看")
|
||||
@PostMapping("/getBlockKnowledgeNotes")
|
||||
@AnonymousAccess
|
||||
public ResultEntity getBlockKnowledgeNotes(String userId, String module) {
|
||||
if (module.isEmpty() && userId.isEmpty()) {
|
||||
return new ResultEntity("参数为空");
|
||||
}
|
||||
StuKnowledgeNotes knowledgeNotes = stuConceptBlockService.getKnowledgeNotes(userId,module);
|
||||
return new ResultEntity(knowledgeNotes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/addKnowledgeNotes")
|
||||
@ApiOperation("区块链知识笔记上传")
|
||||
@AnonymousAccess
|
||||
public ResultEntity addKnowledgeNotes(@RequestBody JSONObject jsonObject) {
|
||||
StuKnowledgeNotes stuKnowledgeNotes = jsonObject.getObject("stuKnowledgeNotes", StuKnowledgeNotes.class);
|
||||
if (stuKnowledgeNotes != null) {
|
||||
stuConceptBlockService.addKnowledgeNotes(stuKnowledgeNotes);
|
||||
return new ResultEntity("上传成功");
|
||||
} else {
|
||||
return new ResultEntity("上传失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/downBlockKnowledge")
|
||||
@ApiOperation("区块链知识笔记导出为pdf")
|
||||
@AnonymousAccess
|
||||
public void OutPdf(HttpServletResponse response,String context) {
|
||||
|
||||
stuConceptBlockService.OutPdf(response,context);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getReport")
|
||||
@ApiOperation("获取实训报告详情")
|
||||
@AnonymousAccess
|
||||
public ResultDataEntity<StuPracticalTrainingReport> getReport(String userId, String module) {
|
||||
|
||||
StuPracticalTrainingReport report = stuConceptBlockService.getReport(userId, module);
|
||||
return new ResultDataEntity<>(HttpStatus.OK, report);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/upload")
|
||||
@ApiOperation("上传实训报告")
|
||||
@AnonymousAccess
|
||||
public ResultDataEntity<StuPracticalTrainingReport> 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @author whb
|
||||
* @Date 2023/10/11
|
||||
* 下载报告
|
||||
*/
|
||||
@GetMapping("/download")
|
||||
@ApiOperation("下载实训报告")
|
||||
@AnonymousAccess
|
||||
public void download(@RequestParam String userId, String TOKEN, HttpServletResponse response, String module) {
|
||||
TokenProvider.getJWTUser(TOKEN);
|
||||
stuConceptBlockService.download(userId, response, module);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getResource")
|
||||
@ApiOperation("获取视频流")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<FileSystemResource> streamVideo(@RequestParam String module, @RequestParam String name, HttpServletResponse response) {
|
||||
|
||||
|
||||
StuResourcesExample example = new StuResourcesExample();
|
||||
example.createCriteria().andModuleEqualTo(module).andResourcesNameEqualTo(name);
|
||||
List<StuResources> stuResources = stuResourcesMapper.selectByExample(example);
|
||||
if (stuResources.size() > 0) {
|
||||
StuResources stuResources1 = stuResources.get(0);
|
||||
String url = stuResources1.getResourcesUrl();
|
||||
String videoPath = filePath + url;
|
||||
File videoFile = new File(videoPath);
|
||||
if ("mp4".equals(stuResources1.getResourcesType())) {
|
||||
|
||||
|
||||
if (videoFile.exists()) {
|
||||
Path path = Paths.get(videoPath);
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(videoFile);
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType("video/mp4"))
|
||||
.body(fileSystemResource);
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
} else if ("pdf".equals(stuResources1.getResourcesType())) {
|
||||
|
||||
// fileUtil.getPdf(response,name,url);
|
||||
if (videoFile.exists()) {
|
||||
Path path = Paths.get(videoPath);
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(videoFile);
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.parseMediaType("application/pdf"))
|
||||
.body(fileSystemResource);
|
||||
|
||||
} else {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return ResponseEntity.notFound().build();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.sztzjy.digital_credit.controller.tch;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
public class StuUserDto {
|
||||
private String userId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String studentId;
|
||||
|
||||
private String module;
|
||||
|
||||
private String className;
|
||||
|
||||
// private String schoolId;
|
||||
|
||||
private String reportUrl;
|
||||
|
||||
private Integer reportId;
|
||||
|
||||
private Double rating;
|
||||
|
||||
// private Integer reportStatus;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.sztzjy.digital_credit.controller.tch;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.sztzjy.digital_credit.entity.StuPracticalTrainingReport;
|
||||
import com.sztzjy.digital_credit.entity.StuUser;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class TchPracticalTrainingReportDto {
|
||||
private String userId;//用户id
|
||||
private String name;//用户名
|
||||
private String studentId;//学号
|
||||
private String className;//班级
|
||||
private String module;//归属模块
|
||||
private String reportName;//报告名称
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date uploadTime; //上传时间
|
||||
private Integer size;//报告大小
|
||||
private Double rating;//教师评分
|
||||
|
||||
public TchPracticalTrainingReportDto(StuUser stuUser, StuPracticalTrainingReport report) {
|
||||
this.userId=stuUser.getUserId();
|
||||
this.name=stuUser.getName();
|
||||
this.studentId=stuUser.getStudentId();
|
||||
this.className=stuUser.getClassName();
|
||||
this.module=report.getModule();
|
||||
this.reportName=report.getReportName();
|
||||
this.uploadTime=report.getUploadTime();
|
||||
this.size=report.getSize();
|
||||
this.rating=report.getRating();
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.sztzjy.digital_credit.entity.dto;
|
||||
|
||||
/**
|
||||
* @author 17803
|
||||
* @date 2023-10-17 11:23
|
||||
*/
|
||||
|
||||
public class StuBlockProductWithDTO {
|
||||
private String module;
|
||||
private String schoolId;
|
||||
private String userId;
|
||||
|
||||
|
||||
public String getSchoolId() {
|
||||
return schoolId;
|
||||
}
|
||||
|
||||
public void setSchoolId(String schoolId) {
|
||||
this.schoolId = schoolId == null ? null : schoolId.trim();
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module == null ? null : module.trim();
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId == null ? null : userId.trim();
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.sztzjy.digital_credit.entity.tchdto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author 17803
|
||||
* @date 2024-05-10 10:08
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class TchConceptualWeight {
|
||||
|
||||
@ApiModelProperty("模块权重ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("学校ID")
|
||||
private String schoolId;
|
||||
|
||||
@ApiModelProperty("贷款案例权重")
|
||||
private BigDecimal loanCasesWeight;
|
||||
|
||||
@ApiModelProperty("个人情况与违约权重")
|
||||
private BigDecimal perSituationWeiht;
|
||||
|
||||
@ApiModelProperty("还款行为与违约权重")
|
||||
private BigDecimal repaymentBehaviorWeiht;
|
||||
|
||||
@ApiModelProperty("个人征信-影响因素与分析权重")
|
||||
private BigDecimal perInfluenceFactorWeith;
|
||||
|
||||
@ApiModelProperty("个人征信-征信优化与分析权重")
|
||||
private BigDecimal perCreditOptimizationWeith;
|
||||
|
||||
@ApiModelProperty("个人征信-征信评级模型权重")
|
||||
private BigDecimal perCreditRatingWeith;
|
||||
|
||||
@ApiModelProperty("企业征信-影响因素与分析权重")
|
||||
private BigDecimal entInfluenceFactorWeith;
|
||||
|
||||
@ApiModelProperty("企业征信-征信优化与分析权重")
|
||||
private BigDecimal entCreditOptimizationWeith;
|
||||
|
||||
@ApiModelProperty("企业征信-征信评级模型权重")
|
||||
private BigDecimal entCreditRatingWeith;
|
||||
|
||||
@ApiModelProperty("案例-用户画像权重")
|
||||
private BigDecimal caseUserProfileWeith;
|
||||
|
||||
@ApiModelProperty("案例-个人征信权重")
|
||||
private BigDecimal casePersonalCreditWeith;
|
||||
|
||||
@ApiModelProperty("案例-企业征信权重")
|
||||
private BigDecimal caseCorporateCreditWeith;
|
||||
|
||||
@ApiModelProperty("征信画像成绩权重")
|
||||
private BigDecimal creditPortraitWeith;
|
||||
|
||||
@ApiModelProperty("个人征信成绩权重")
|
||||
private BigDecimal personalCreditWeith;
|
||||
|
||||
@ApiModelProperty("企业征信成绩权重")
|
||||
private BigDecimal enterpriseCreditWeith;
|
||||
|
||||
@ApiModelProperty("综合案例成绩权重")
|
||||
private BigDecimal caseStudyWeith;
|
||||
|
||||
@ApiModelProperty("模块")
|
||||
private String module;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.sztzjy.digital_credit.entity.tchdto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author 17803
|
||||
* @date 2024-05-10 14:54
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class TchManualRatingByTeacherDTO {
|
||||
|
||||
@ApiModelProperty("老师评分")
|
||||
private BigDecimal score;
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty("归属模块")
|
||||
private String module;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.sztzjy.digital_credit.mapper;
|
||||
|
||||
|
||||
import com.sztzjy.digital_credit.controller.tch.StuUserDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface StuUserDtoMapper {
|
||||
List<StuUserDto> selectByCondition(@Param("name") String name,
|
||||
@Param("studentId") String studentId,
|
||||
@Param("className") String className,
|
||||
@Param("module") String module,
|
||||
@Param("keyWord") String keyWord,
|
||||
@Param("schoolId") String schoolId);
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.sztzjy.digital_credit.service;
|
||||
|
||||
|
||||
|
||||
import com.sztzjy.digital_credit.entity.StuKnowledgeNotes;
|
||||
import com.sztzjy.digital_credit.entity.StuPracticalTrainingReport;
|
||||
import com.sztzjy.digital_credit.entity.StuResources;
|
||||
import com.sztzjy.digital_credit.entity.dto.StuBlockProductWithDTO;
|
||||
import com.sztzjy.digital_credit.entity.dto.StuLearningAssessmentDTO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
public interface StuConceptBlockService {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//区块链学习资源查看
|
||||
List<StuResources> getConceptBlockResources(String module);
|
||||
|
||||
|
||||
|
||||
StuKnowledgeNotes getKnowledgeNotes(String userId, String module);
|
||||
|
||||
|
||||
int addKnowledgeNotes(StuKnowledgeNotes stuKnowledgeNotes);
|
||||
|
||||
|
||||
|
||||
StuPracticalTrainingReport upload(MultipartFile file, StuBlockProductWithDTO stuBlockProductWithBLOBs);
|
||||
|
||||
void download(String id, HttpServletResponse response,String module);
|
||||
|
||||
StuPracticalTrainingReport getReport(String userId, String module);
|
||||
|
||||
/**
|
||||
* 区块链知识笔记导出为pdf
|
||||
|
||||
* @param response
|
||||
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
|
||||
void OutPdf( HttpServletResponse response, String context);
|
||||
|
||||
}
|
@ -0,0 +1,424 @@
|
||||
package com.sztzjy.digital_credit.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
|
||||
import com.sztzjy.digital_credit.entity.*;
|
||||
import com.sztzjy.digital_credit.entity.dto.StuBlockProductWithDTO;
|
||||
import com.sztzjy.digital_credit.mapper.*;
|
||||
import com.sztzjy.digital_credit.service.StuConceptBlockService;
|
||||
import com.sztzjy.digital_credit.util.ConvertUtil;
|
||||
import com.sztzjy.digital_credit.util.PdfUtil;
|
||||
import com.sztzjy.digital_credit.util.compute.ScoringUtil;
|
||||
import com.sztzjy.digital_credit.util.file.IFileUtil;
|
||||
import com.sztzjy.digital_credit.util.file.LocalFileUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import util.convertPDF.PDFConvertUtil;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
|
||||
@Service
|
||||
public class StuConceptBlockServiceImpl implements StuConceptBlockService {
|
||||
@Resource
|
||||
private TchPublicResourceWeightMapper tchPublicResourceWeightMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IFileUtil fileUtil;
|
||||
@Resource
|
||||
StuPracticalTrainingReportMapper stuPracticalTrainingReportMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private StuScoreDetailsMapper stuScoreDetailsMapper;
|
||||
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private StuResourcesMapper stuResourcesMapper;
|
||||
|
||||
@Resource
|
||||
StuKnowledgeNotesMapper stuKnowledgeNotesMapper;
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
IFileUtil localFileUtil;
|
||||
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;
|
||||
|
||||
|
||||
//区块链学习资源查看
|
||||
@Override
|
||||
public List<StuResources> getConceptBlockResources(String module) {
|
||||
StuResourcesExample resourcesExample = new StuResourcesExample();
|
||||
resourcesExample.createCriteria().andModuleEqualTo(module);
|
||||
List<StuResources> stuResources = stuResourcesMapper.selectByExample(resourcesExample);
|
||||
return stuResources;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 知识笔记查看
|
||||
*
|
||||
* @param module 所属模块
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StuKnowledgeNotes getKnowledgeNotes(String userId, String module) {
|
||||
StuKnowledgeNotesExample notesExample = new StuKnowledgeNotesExample();
|
||||
notesExample.createCriteria().andModuleEqualTo(module).andUserIdEqualTo(userId);
|
||||
|
||||
List<StuKnowledgeNotes> stuKnowledgeNotes = stuKnowledgeNotesMapper.selectByExample(notesExample);
|
||||
if (stuKnowledgeNotes.size()>0)
|
||||
{
|
||||
return stuKnowledgeNotes.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int addKnowledgeNotes(StuKnowledgeNotes stuKnowledgeNotes) {
|
||||
if (stuKnowledgeNotes.getNotesContent().isEmpty()) {
|
||||
throw new RuntimeException("笔记内容不能为空");
|
||||
}
|
||||
StuKnowledgeNotesExample notesExample = new StuKnowledgeNotesExample();
|
||||
notesExample.createCriteria().andModuleEqualTo(stuKnowledgeNotes.getModule()).andUserIdEqualTo(stuKnowledgeNotes.getUserId());
|
||||
List<StuKnowledgeNotes> knowledgeNotesList = stuKnowledgeNotesMapper.selectByExample(notesExample);
|
||||
if (knowledgeNotesList.size()>0)
|
||||
{
|
||||
|
||||
StuKnowledgeNotes KnowledgeNotes = knowledgeNotesList.get(0);
|
||||
KnowledgeNotes.setNotesContent(stuKnowledgeNotes.getNotesContent());
|
||||
stuKnowledgeNotesMapper.updateByPrimaryKeySelective(KnowledgeNotes);
|
||||
return 0;
|
||||
}else {
|
||||
stuKnowledgeNotes.setNotesId(UUID.randomUUID().toString().replaceAll("-",""));
|
||||
int insert = stuKnowledgeNotesMapper.insert(stuKnowledgeNotes);
|
||||
return insert;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 上传实验报告
|
||||
*
|
||||
* @param file 文件
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StuPracticalTrainingReport upload(MultipartFile file, StuBlockProductWithDTO stuBlockProductWithBLOBs) {
|
||||
|
||||
if (file.isEmpty()) {
|
||||
throw new RuntimeException("文件不能为空");
|
||||
}
|
||||
if (stuBlockProductWithBLOBs == null) {
|
||||
throw new RuntimeException("模块或用户ID不能为空");
|
||||
}
|
||||
|
||||
StuPracticalTrainingReportExample stuPracticalTrainingReportExample = new StuPracticalTrainingReportExample();
|
||||
stuPracticalTrainingReportExample.createCriteria().andUseridEqualTo(stuBlockProductWithBLOBs.getUserId()).andModuleEqualTo(stuBlockProductWithBLOBs.getModule());
|
||||
List<StuPracticalTrainingReport> 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();
|
||||
|
||||
|
||||
//上传实验报告后写入学习成绩
|
||||
TchPublicResourceWeightExample weightExample = new TchPublicResourceWeightExample();
|
||||
weightExample.createCriteria().andModuleEqualTo(stuBlockProductWithBLOBs.getModule());
|
||||
List<TchPublicResourceWeight> weights = tchPublicResourceWeightMapper.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.setModule(stuBlockProductWithBLOBs.getModule());
|
||||
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("没有查询到实验报告权重信息");
|
||||
}
|
||||
|
||||
|
||||
TchPublicResourceWeight tchConceptualTechnologyWeight = weights.get(0);
|
||||
if (tchConceptualTechnologyWeight != null) {
|
||||
//获取权重信息
|
||||
BigDecimal reportWeight = tchConceptualTechnologyWeight.getReportWeight();
|
||||
if (reportWeight != null) {
|
||||
StuScoreDetails scoreDetails = new StuScoreDetails();
|
||||
scoreDetails.setUserId(stuBlockProductWithBLOBs.getUserId());
|
||||
scoreDetails.setModule(stuBlockProductWithBLOBs.getModule());
|
||||
scoreDetails.setScoreWeight(reportWeight.doubleValue());
|
||||
scoreDetails.setId(id);
|
||||
scoreDetails.setLearningProjects("实训报告");
|
||||
scoreDetails.setSerialNumber(5);
|
||||
scoreDetails.setCompletionStatus("已提交");
|
||||
stuScoreDetailsMapper.insert(scoreDetails);
|
||||
}
|
||||
}
|
||||
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()).andModuleEqualTo(stuBlockProductWithBLOBs.getModule());
|
||||
List<StuScoreDetails> 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;
|
||||
} else {
|
||||
|
||||
//格式不为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.setModule(stuBlockProductWithBLOBs.getModule());
|
||||
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("没有查询到实验报告权重信息");
|
||||
}
|
||||
TchPublicResourceWeight tchConceptualTechnologyWeight = weights.get(0);
|
||||
if (tchConceptualTechnologyWeight != null) {
|
||||
//获取权重信息
|
||||
BigDecimal reportWeight = tchConceptualTechnologyWeight.getReportWeight();
|
||||
if (reportWeight != null) {
|
||||
StuScoreDetails scoreDetails = new StuScoreDetails();
|
||||
scoreDetails.setUserId(stuBlockProductWithBLOBs.getUserId());
|
||||
scoreDetails.setModule(stuBlockProductWithBLOBs.getModule());
|
||||
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()).andModuleEqualTo(stuBlockProductWithBLOBs.getModule());
|
||||
List<StuScoreDetails> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @author whb
|
||||
* @Date 2023/10/11
|
||||
*
|
||||
*下载报告
|
||||
*/
|
||||
@Override
|
||||
public void download(String id, HttpServletResponse response, String module) {
|
||||
StuPracticalTrainingReportExample reportExample = new StuPracticalTrainingReportExample();
|
||||
reportExample.createCriteria().andModuleEqualTo(module).andUseridEqualTo(id);
|
||||
|
||||
|
||||
|
||||
|
||||
List<StuPracticalTrainingReport> stuPracticalTrainingReport = stuPracticalTrainingReportMapper.selectByExample(reportExample);
|
||||
|
||||
if (stuPracticalTrainingReport.size()>0)
|
||||
{
|
||||
Assert.isTrue(stuPracticalTrainingReport != null && stuPracticalTrainingReport.get(0).getUrl() != null, "报告不存在");
|
||||
|
||||
fileUtil.download(response, stuPracticalTrainingReport.get(0).getReportName(), stuPracticalTrainingReport.get(0).getUrl());
|
||||
}else {
|
||||
throw new RuntimeException("报告不存在");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实验报告
|
||||
*
|
||||
* @param userId
|
||||
* @param module
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public StuPracticalTrainingReport getReport(String userId, String module) {
|
||||
|
||||
//获取实验报告
|
||||
StuPracticalTrainingReportExample export = new StuPracticalTrainingReportExample();
|
||||
export.createCriteria().andUseridEqualTo(userId).andModuleEqualTo(module);
|
||||
|
||||
if (stuPracticalTrainingReportMapper.selectByExample(export).size() != 0) {
|
||||
StuPracticalTrainingReport report = stuPracticalTrainingReportMapper.selectByExample(export).get(0);
|
||||
|
||||
|
||||
return report;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@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");
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException {
|
||||
// 创建一个临时文件
|
||||
File tempFile = File.createTempFile("temp", null);
|
||||
|
||||
// 将 MultipartFile 的内容写入临时文件
|
||||
multipartFile.transferTo(tempFile);
|
||||
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.sztzjy.digital_credit.util;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.xhtmlrenderer.pdf.ITextFontResolver;
|
||||
import org.xhtmlrenderer.pdf.ITextRenderer;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
|
||||
/**
|
||||
* 生成pdf的工具类
|
||||
* @author hyy
|
||||
*/
|
||||
public class PdfUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PdfUtil.class);
|
||||
|
||||
/**
|
||||
* 基于 flying-saucer-pdf-itext5
|
||||
* html 字符串生成pdf
|
||||
* @param content 带css样式的富文本内容
|
||||
* @return 返回生成的pdf本地路径
|
||||
*/
|
||||
public static String htmlStringToPdf(String content, FileOutputStream fileOutputStream) {
|
||||
content = content.replace(" "," ")
|
||||
.replace("“","\"")
|
||||
.replace("”","\"");
|
||||
// String path = System.getProperty("user.dir") + "//" + name;
|
||||
|
||||
try{
|
||||
ITextRenderer renderer = new ITextRenderer();
|
||||
|
||||
renderer.setDocumentFromString("<html><body style=\"font-family: SimSun\">" + content + "</body></html>");
|
||||
//设置字符集(宋体),此处必须与模板中的<body style="font-family: SimSun">一致,区分大小写,不能写成汉字"宋体"
|
||||
ITextFontResolver fontResolver = renderer.getFontResolver();
|
||||
fontResolver.addFont("simsun.ttf", com.lowagie.text.pdf.BaseFont.IDENTITY_H, com.lowagie.text.pdf.BaseFont.NOT_EMBEDDED);
|
||||
//展现和输出pdf
|
||||
renderer.layout();
|
||||
renderer.createPDF(fileOutputStream);
|
||||
renderer.finishPDF();
|
||||
return "success";
|
||||
} catch (Exception e) {
|
||||
logger.error("生成pdf发生异常",e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sztzjy.digital_credit.mapper.StuUserDtoMapper">
|
||||
<resultMap id="BaseResultMap" type="com.sztzjy.digital_credit.controller.tch.StuUserDto">
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="studentId" column="student_id"/>
|
||||
<result property="module" column="module"/>
|
||||
<result property="className" column="class_name"/>
|
||||
<result property="reportUrl" column="url"/>
|
||||
<result property="reportId" column="id"/>
|
||||
<result property="rating" column="rating"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByCondition" resultMap="BaseResultMap">
|
||||
select u.user_id,u.name,u.student_id,u.class_name,r.module,r.url,r.id,r.rating
|
||||
from stu_user u
|
||||
JOIN stu_practical_training_report r ON u.user_id = r.userId
|
||||
<where>
|
||||
AND u.school_id = #{schoolId}
|
||||
<if test="module =='征信画像成绩'">
|
||||
AND r.module IN ('贷款案例', '个人情况与违约', '还款行为与违约')
|
||||
</if>
|
||||
<if test="module =='个人征信成绩'">
|
||||
AND r.module IN ('个人影响因素分析', '个人征信优化分析','个人征信评级模型')
|
||||
</if>
|
||||
<if test="module =='企业征信成绩'">
|
||||
AND r.module IN ('企业影响因素分析', '企业征信优化分析','企业征信评级模型')
|
||||
</if>
|
||||
|
||||
<if test="name != null">
|
||||
AND u.name LIKE CONCAT('%', #{name} ,'%')
|
||||
</if>
|
||||
<if test="studentId != null">
|
||||
AND u.student_id = #{studentId}
|
||||
</if>
|
||||
<if test="className != null">
|
||||
AND u.class_name = #{className}
|
||||
</if>
|
||||
<if test="keyWord != null">
|
||||
AND r.module = #{keyWord}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY r.rating DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
Binary file not shown.
Loading…
Reference in New Issue