完成教师端所有功能

master
whb 10 months ago
parent c0b2fcf1ef
commit 4f2d24630f

@ -216,6 +216,28 @@
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>admin-convert-pdf</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.22</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
<version>9.1.22</version>
</dependency>

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- <parent>-->
<!-- <groupId>com.ibeetl</groupId>-->
<!-- <artifactId>admin-framwork</artifactId>-->
<!-- <version>1.3.1</version>-->
<!-- </parent>-->
<modelVersion>4.0.0</modelVersion>
<groupId>com.ibeetl</groupId>
<artifactId>admin-convert-pdf</artifactId>
<version>1.3.1</version>
<description>任意格式转换成PDF的工具包</description>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.3</version>
<scope>compile</scope>
</dependency>
<!--pdf依赖开始,导入本地依赖包crack jar-->
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>18.10</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/aspose-words-18.10-jdk16.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-pdf</artifactId>
<version>18.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/aspose-pdf-18.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>20.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/aspose-cells-20.7-crack.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.0.11</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>AsposeJavaAPI</id>
<url>https://repository.aspose.com/repo/</url>
</pluginRepository>
</pluginRepositories>
</project>

@ -0,0 +1,538 @@
package util.convertPDF;
import com.aspose.words.FontSettings;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import org.apache.poi.hslf.usermodel.*;
import org.apache.poi.xslf.usermodel.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static util.convertPDF.PDFConvertUtil.TypeEnum.*;
/**
* : <br>
* PDF
*
* @Author: lx
* @Date: 2022/12/13 16:26
*/
public final class PDFConvertUtil {
final private static Map<TypeEnum, List<String>> types = new HashMap<>();
public static enum TypeEnum {
WORD, EXCEL, PPT, PPTX, IMG, OTHER
}
static {
types.put(WORD, Arrays.asList("DOC", "DOCX"));
types.put(EXCEL, Arrays.asList("XLS", "XLSX"));
types.put(PPT, Arrays.asList("PPT"));
types.put(PPTX, Arrays.asList("PPTX"));
// types.put(IMG, Arrays.asList("JPEG", "JPG", "PNG"));
types.put(OTHER, Arrays.asList("OOXML", "RTF HTML", "OpenDocument", "EPUB", "XPS", "SWF"));
}
/**
* @param inputStream
* @param outputStream pdf
**/
public static boolean imgToPdf(InputStream inputStream, OutputStream outputStream) {
Document document = null; PdfWriter pdfWriter = null;
try {
//此处处理乱码和小方块
//如果在本地运行,此处报错,请注释这个这是字体,主要是为了解决linux环境下面运行jar时找不到中文字体的问题
//指定文件库内容路径
FontSettings.getDefaultInstance().setFontsFolders(
new String[] {"/usr/share/fonts", "/usr/share/fonts/chinese"}
, true);
// 创建文档,设置PDF页面的大小 A2-A9, 个人觉得A3最合适
document = new Document(PageSize.A6, 0, 0, 0, 0);
// 新建pdf文档,具体逻辑看.getInstance方法
pdfWriter = PdfWriter.getInstance(document, outputStream);
document.open();
document.newPage();
// 将文件流转换为字节流,便于格式转换
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
int length = 0 ;
while (-1 != (length = bufferedInputStream.read(bytes))) {
byteArrayOutputStream.write(bytes, 0, length);
}
// 处理img图片
Image image = Image.getInstance(byteArrayOutputStream.toByteArray());
float height = image.getHeight();
float width = image.getWidth();
float percent = 0.0f;
// 设置像素或者长宽高,将会影响图片的清晰度,因为只是对图片放大或缩小
if (height > width) {
// A4 - A9
percent = PageSize.A6.getHeight() / height * 100;
} else {
percent = PageSize.A6.getWidth() / width * 100;
}
image.setAlignment(Image.MIDDLE);
image.scalePercent(percent);
// 将图片放入文档中完成pdf转换
document.add(image);
System.out.println("image转换完毕");
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
close(document, pdfWriter);
closeOutput(outputStream);
closeInput(inputStream);
}
return true;
}
/**
* @param inputStream
* @param outputStream pdf
**/
public static boolean wordToPdfByAspose(InputStream inputStream, OutputStream outputStream) {
// 验证License 若不验证则转化出的pdf文档会有水印产生
if (!getLicense()) {
return false;
}
try {
//此处处理乱码和小方块
//如果在本地运行,此处报错,请注释这个这是字体,主要是为了解决linux环境下面运行jar时找不到中文字体的问题
//指定文件库内容路径
FontSettings.getDefaultInstance().setFontsFolders(
new String[] {"/usr/share/fonts", "/usr/share/fonts/win"}
, true);
// 将源文件保存在com.aspose.words.Document中具体的转换格式依靠里面的save方法
com.aspose.words.Document doc = new com.aspose.words.Document(inputStream);
// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,EPUB, XPS, SWF 相互转换
doc.save(outputStream, SaveFormat.PDF);
System.out.println("word转换完毕");
} catch (Exception e) {
e.printStackTrace();
return false;
}finally {
closeOutput(outputStream);
closeInput(inputStream);
}
return true;
}
/**
*
* @param outputStream
*/
private static void closeOutput(OutputStream outputStream) {
if (outputStream != null) {
try {
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
*
* @param inputStream
*/
private static void closeInput(InputStream inputStream) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static void close(Document document, PdfWriter pdfWriter) {
if (document != null) {
document.close();
}
if (pdfWriter != null) {
pdfWriter.close();
}
}
// 官方文档的要求 无需理会
public static boolean getLicense() {
boolean result = false;
try {
String s = "<License>\n" +
" <Data>\n" +
" <Products>\n" +
" <Product>Aspose.Total for Java</Product>\n" +
" <Product>Aspose.Words for Java</Product>\n" +
" </Products>\n" +
" <EditionType>Enterprise</EditionType>\n" +
" <SubscriptionExpiry>20991231</SubscriptionExpiry>\n" +
" <LicenseExpiry>20991231</LicenseExpiry>\n" +
" <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>\n" +
" </Data>\n" +
" <Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>\n" +
"</License>";
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes());
License aposeLic = new License();
aposeLic.setLicense(is);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* @param inputStream
* @param outputStream pdf
**/
public static boolean excelToPdf(InputStream inputStream, OutputStream outputStream) {
// 验证License 若不验证则转化出的pdf文档会有水印产生
if (!getExcelLicense()) {
return false;
}
try {
//此处处理乱码和小方块
//如果在本地运行,此处报错,请注释这个这是字体,主要是为了解决linux环境下面运行jar时找不到中文字体的问题
//指定文件库内容路径
FontSettings.getDefaultInstance().setFontsFolders(
new String[] {"/usr/share/fonts", "/usr/share/fonts/win"}
, true);
// 原始excel路径
com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(inputStream);
com.aspose.cells.PdfSaveOptions pdfSaveOptions = new com.aspose.cells.PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(false);
int[] autoDrawSheets={3};
//当excel中对应的sheet页宽度太大时在PDF中会拆断并分页。此处等比缩放。
autoDraw(wb,autoDrawSheets);
int[] showSheets={0};
//隐藏workbook中不需要的sheet页。
printSheetPage(wb,showSheets);
wb.save(outputStream, pdfSaveOptions);
System.out.println("excel转换完毕");
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}finally {
closeOutput(outputStream);
closeInput(inputStream);
}
return true;
}
/**
* sheet
* @param wb
* @param page sheet
*/
public static void autoDraw(com.aspose.cells.Workbook wb,int[] page){
if(null!=page&&page.length>0){
for (int i = 0; i < page.length; i++) {
wb.getWorksheets().get(i).getHorizontalPageBreaks().clear();
wb.getWorksheets().get(i).getVerticalPageBreaks().clear();
}
}
}
/**
* workbooksheet
*
* @param wb
* @param page sheet
*/
public static void printSheetPage(com.aspose.cells.Workbook wb, int[] page) {
for (int i = 1; i < wb.getWorksheets().getCount(); i++) {
wb.getWorksheets().get(i).setVisible(false);
}
if (null == page || page.length == 0) {
wb.getWorksheets().get(0).setVisible(true);
} else {
for (int i = 0; i < page.length; i++) {
wb.getWorksheets().get(i).setVisible(true);
}
}
}
public static boolean getExcelLicense() {
boolean result = false;
try {
String s = "<License>\n" +
" <Data>\n" +
" <Products>\n" +
" <Product>Aspose.Cells for Java</Product>\n" +
" </Products>\n" +
" <EditionType>Enterprise</EditionType>\n" +
" <SubscriptionExpiry>29991231</SubscriptionExpiry>\n" +
" <LicenseExpiry>29991231</LicenseExpiry>\n" +
" <SerialNumber>evilrule</SerialNumber>\n" +
" </Data>\n" +
" <Signature>evilrule</Signature>\n" +
"</License>";
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes());
com.aspose.cells.License aposeLic = new com.aspose.cells.License();
aposeLic.setLicense(is);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/**
* pptToPdf
* @param inputStream
* @param outputStream
* @return
*/
public static boolean pptToPdf(InputStream inputStream, OutputStream outputStream) {
Document document = null;
HSLFSlideShow hslfSlideShow = null;
PdfWriter pdfWriter = null;
try {
//此处处理乱码和小方块
//如果在本地运行,此处报错,请注释这个这是字体,主要是为了解决linux环境下面运行jar时找不到中文字体的问题
//指定文件库内容路径
FontSettings.getDefaultInstance().setFontsFolders(
new String[] {"/usr/share/fonts", "/usr/share/fonts/win"}
, true);
hslfSlideShow = new HSLFSlideShow(inputStream);
// 获取ppt文件页面
Dimension dimension = hslfSlideShow.getPageSize();
document = new Document();
// pdfWriter实例
pdfWriter = PdfWriter.getInstance(document, outputStream);
document.open();
PdfPTable pdfPTable = new PdfPTable(1);
List<HSLFSlide> hslfSlideList = hslfSlideShow.getSlides();
for (int i=0; i < hslfSlideList.size(); i++) {
HSLFSlide hslfSlide = hslfSlideList.get(i);
// 设置字体, 解决中文乱码
for (HSLFShape shape : hslfSlide.getShapes()) {
if (shape instanceof HSLFTextShape) {
HSLFTextShape textShape = (HSLFTextShape) shape;
for (HSLFTextParagraph textParagraph : textShape.getTextParagraphs()) {
for (HSLFTextRun textRun : textParagraph.getTextRuns()) {
textRun.setFontFamily("宋体");
}
}
}
}
BufferedImage bufferedImage = new BufferedImage((int)dimension.getWidth(), (int)dimension.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2d = bufferedImage.createGraphics();
graphics2d.setPaint(Color.white);
graphics2d.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
hslfSlide.draw(graphics2d);
graphics2d.dispose();
Image image = Image.getInstance(bufferedImage, null);
image.scalePercent(56f);
// 写入单元格
pdfPTable.addCell(new PdfPCell(image, true));
document.add(image);
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
close(document, pdfWriter);
closeOutput(outputStream);
closeInput(inputStream);
}
System.out.println("ppt转换完毕");
return true;
}
/**
* pptxToPdf
* @param inputStream
* @param outputStream
* @return
*/
public static boolean pptxToPdf(InputStream inputStream, OutputStream outputStream) {
Document document = null;
XMLSlideShow slideShow = null;
PdfWriter pdfWriter = null;
try {
//此处处理乱码和小方块
//如果在本地运行,此处报错,请注释这个这是字体,主要是为了解决linux环境下面运行jar时找不到中文字体的问题
//指定文件库内容路径
FontSettings.getDefaultInstance().setFontsFolders(
new String[] {"/usr/share/fonts", "/usr/share/fonts/win"}
, true);
slideShow = new XMLSlideShow(inputStream);
Dimension dimension = slideShow.getPageSize();
document = new Document();
pdfWriter = PdfWriter.getInstance(document, outputStream);
document.open();
PdfPTable pdfPTable = new PdfPTable(1);
List<XSLFSlide> slideList = slideShow.getSlides();
for (int i = 0, row = slideList.size(); i < row; i++) {
XSLFSlide slide = slideList.get(i);
// 设置字体, 解决中文乱码
for (XSLFShape shape : slide.getShapes()) {
if (shape instanceof XSLFTextShape) {
XSLFTextShape textShape = (XSLFTextShape) shape;
for (XSLFTextParagraph textParagraph : textShape.getTextParagraphs()) {
for (XSLFTextRun textRun : textParagraph.getTextRuns()) {
textRun.setFontFamily("宋体");
}
}
}
}
BufferedImage bufferedImage = new BufferedImage((int)dimension.getWidth(), (int)dimension.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2d = bufferedImage.createGraphics();
graphics2d.setPaint(Color.white);
graphics2d.setFont(new java.awt.Font("宋体", java.awt.Font.PLAIN, 12));
slide.draw(graphics2d);
graphics2d.dispose();
Image image = Image.getInstance(bufferedImage, null);
//image.scalePercent(50f);
image.scalePercent(56f);
// 写入单元格
pdfPTable.addCell(new PdfPCell(image, true));
document.add(image);
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
close(document, pdfWriter);
closeOutput(outputStream);
closeInput(inputStream);
}
System.out.println("pptx转换完毕");
return true;
}
/**
* : <br>
*
*
* @return {@link boolean}
* @Author: lx
* @Date: 2022/12/13 16:37
*/
public static boolean convertToPDFByFileNameSuffix(String fileName, InputStream inputStream, OutputStream outputStream) {
String fileSuffix = getFileSuffix(fileName).toUpperCase();
if (types.get(WORD).contains(fileSuffix)) {
return wordToPdfByAspose(inputStream, outputStream);
}
if (types.get(EXCEL).contains(fileSuffix)) {
return excelToPdf(inputStream, outputStream);
}
if (types.get(PPT).contains(fileSuffix)) {
return pptToPdf(inputStream, outputStream);
}
if (types.get(PPTX).contains(fileSuffix)) {
return pptxToPdf(inputStream, outputStream);
}
// if (types.get(IMG).contains(fileSuffix)) {
// return imgToPdf(inputStream, outputStream);
// }
if (types.get(OTHER).contains(fileSuffix)) {
return wordToPdfByAspose(inputStream, outputStream);
}
return false;
}
/**
* PDF
* @param fileName
* @return
*/
public static boolean isCreatePdf(String fileName) {
return types.values().stream().anyMatch(item -> item.contains(getFileSuffix(fileName).toUpperCase()));
}
/**
* : <br>
*
*
* @param fileName
* @return {@link String}
* @Author: lx
* @Date: 2022/12/13 21:51
*/
private static String getFileSuffix(String fileName) {
if (!fileName.contains(".")) {
throw new RuntimeException("非法的文件名,文件名必须要有文件类型!");
}
String[] split = fileName.split("\\.");
return split[split.length - 1];
}
}

@ -242,4 +242,15 @@ public class Constant {
"收支情况刘先生年收入180万元年底有80万元分红妻子年收入100万元年底奖金50万元。家庭月日常生活支出 38000元儿子教育费用6000元/月每年衣物及礼金支出50000元支付刘先生父母生活费50000元/年旅游费用150000元/年汽车使用费包括保险120000元/年健身支出30000/年家政保姆支出12万/年交际娱乐支出12万/年。\n" +
"刘先生持有两张信用卡目前一张信用卡额度为20万一张信用卡额度为50万已用额度为10万最近6个月平均使用额度为为65000元首张信用卡发卡月份为2005年3月份。此外刘先生还有一笔对外担保担保金额为100万元担保本金余额50万。\n" +
"刘先生养老保险金账户余额为208000元医疗保险账户余额为140000元住房公积金账户余额98000元未出现过断缴情况";
public static final String PERSONYXYSFX_MODULE = "个人影响因素分析";
public static final String PERSONZXYHFX_MODULE = "个人征信优化分析";
public static final String PERSONZXPJMX_MOXULE = "个人征信评级模型";
public static final String QIYEYXYSFX_MODULE = "企业影响因素分析";
public static final String QIYEZXYHFX_MODULE = "企业征信优化分析";
public static final String QIYEZXPJMX_MOXULE = "企业征信评级模型";
}

@ -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,374 @@
package com.sztzjy.digital_credit.controller.tch;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.digital_credit.annotation.AnonymousAccess;
import com.sztzjy.digital_credit.entity.*;
import com.sztzjy.digital_credit.entity.dto.StuScoreDetailsDTO;
import com.sztzjy.digital_credit.entity.tchdto.ScoreOverviewParametesDTO;
import com.sztzjy.digital_credit.entity.tchdto.TchConceptualWeight;
import com.sztzjy.digital_credit.entity.tchdto.TchManualRatingByTeacherDTO;
import com.sztzjy.digital_credit.mapper.*;
import com.sztzjy.digital_credit.service.StuUserService;
import com.sztzjy.digital_credit.util.ResultEntity;
import com.sztzjy.digital_credit.util.excel.FilePortUtil;
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 javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.math.BigDecimal;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.sztzjy.digital_credit.config.Constant;
@RestController
@RequestMapping("/api/tch/achievement")
@Api(tags = "(征信画像个人征信企业征信综合案例)页面")
public class TchConceptTechnologyAchievement {
@Autowired
StuUserService userService;
@Autowired
StuUserMapper userMapper;
@Autowired
StuScoreDetailsMapper stuScoreDetailsMapper;
@Autowired
private TchModuleWeithMapper tchModuleWeithMapper;
@Autowired
StuPracticalTrainingReportMapper practicalTrainingReportMapper;
@Autowired
private TchPublicResourceWeightMapper tchPublicResourceWeightMapper;
@Value("${file.path}")
private String filePath;
@AnonymousAccess
@PostMapping("/getConceptTechnologyAchievementList")
@ApiOperation("成绩情况")
public ResultEntity getConceptAchievementList(@RequestBody ScoreOverviewParametesDTO parametes) {
PageInfo<StuUser> pageInfo = userService.getCreditPortraitAchievementList(parametes);
return new ResultEntity(HttpStatus.OK, parametes.getModule()+"展示", pageInfo);
}
@GetMapping("/getGradeDetails")
@AnonymousAccess
@ApiOperation("成绩详情")
public ResultEntity getGradeDetails(@RequestParam String userId, @RequestParam String module, @RequestParam String schoolId) {
StuScoreDetailsExample example = new StuScoreDetailsExample();
example.createCriteria().andUserIdEqualTo(userId).andModuleEqualTo(module);
List<StuScoreDetails> stuScoreDetails = stuScoreDetailsMapper.selectByExample(example);
TchPublicResourceWeightExample weightExample = new TchPublicResourceWeightExample();
weightExample.createCriteria().andSchoolIdEqualTo(schoolId).andModuleEqualTo(module);
List<TchPublicResourceWeight> tchPublicResourceWeightList = tchPublicResourceWeightMapper.selectByExample(weightExample);
if (tchPublicResourceWeightList.isEmpty()){
TchPublicResourceWeight tchPublicResourceWeight = new TchPublicResourceWeight(schoolId, module);
tchPublicResourceWeightMapper.insertSelective(tchPublicResourceWeight);
tchPublicResourceWeightList.add(tchPublicResourceWeight);
}
List<StuScoreDetailsDTO> list = new ArrayList<>();
for (int i = 0; i < stuScoreDetails.size(); i++) {
StuScoreDetailsDTO detailsDTO = new StuScoreDetailsDTO(stuScoreDetails.get(i), tchPublicResourceWeightList.get(0));
list.add(detailsDTO);
}
return new ResultEntity(HttpStatus.OK, "成绩详情", list);
}
@AnonymousAccess
@ApiOperation("获取权重")
@GetMapping("/getWeight")
public ResultEntity getConceptTechnologyWeight(@RequestParam String schoolId) {
TchModuleWeithExample weightExample = new TchModuleWeithExample();
weightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<TchModuleWeith> tchModuleWeithList = tchModuleWeithMapper.selectByExample(weightExample);
if (tchModuleWeithList.isEmpty())
{
TchModuleWeith tchModuleWeith = new TchModuleWeith(schoolId);
tchModuleWeithMapper.insertSelective(tchModuleWeith);
tchModuleWeithList.add(tchModuleWeith);
}
return new ResultEntity(HttpStatus.OK, "权重设置回显", tchModuleWeithList.get(0));
}
@PostMapping("/setyWeight")
@AnonymousAccess
@ApiOperation("权重设置")
public ResultEntity setConceptTechnologyWeight(@RequestBody TchConceptualWeight weight) {
String schoolId = weight.getSchoolId();
String module = weight.getModule();
TchModuleWeithExample weightExample = new TchModuleWeithExample();
weightExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<TchModuleWeith> tchModuleWeithList = tchModuleWeithMapper.selectByExample(weightExample);
if (tchModuleWeithList.isEmpty())
{
TchModuleWeith tchModuleWeith = new TchModuleWeith(schoolId);
tchModuleWeithMapper.insertSelective(tchModuleWeith);
tchModuleWeithList.add(tchModuleWeith);
}
TchModuleWeith tchModuleWeith = tchModuleWeithList.get(0);
if ("征信画像成绩".equals(module))
{
//贷款案例权重
tchModuleWeith.setLoanCasesWeight(weight.getLoanCasesWeight());
//个人情况与违约权重
tchModuleWeith.setPerSituationWeiht(weight.getPerSituationWeiht());
//还款行为与违约权重
tchModuleWeith.setRepaymentBehaviorWeiht(weight.getRepaymentBehaviorWeiht());
tchModuleWeith.setSchoolId(schoolId);
tchModuleWeithMapper.updateByPrimaryKeySelective(tchModuleWeith);
userService.totalRank(schoolId);
//征信画像成绩排序
userService.creditPortraitRank(schoolId);
}
if ("个人征信成绩".equals(module))
{
//个人征信-影响因素与分析权重
tchModuleWeith.setPerInfluenceFactorWeith(weight.getPerInfluenceFactorWeith());
//个人征信-征信优化与分析权重
tchModuleWeith.setPerCreditOptimizationWeith(weight.getPerCreditOptimizationWeith());
//个人征信-征信评级模型权重
tchModuleWeith.setPerCreditRatingWeith(weight.getPerCreditRatingWeith());
tchModuleWeith.setSchoolId(schoolId);
tchModuleWeithMapper.updateByPrimaryKeySelective(tchModuleWeith);
userService.totalRank(schoolId);
//个人征信成绩
userService.personCreditRank(schoolId);
}
if ("企业征信成绩".equals(module))
{
//企业征信-影响因素与分析权重
tchModuleWeith.setEntInfluenceFactorWeith(weight.getEntInfluenceFactorWeith());
//企业征信-征信优化与分析权重
tchModuleWeith.setEntCreditOptimizationWeith(weight.getEntCreditOptimizationWeith());
//企业征信-征信评级模型权重
tchModuleWeith.setEntCreditRatingWeith(weight.getEntCreditRatingWeith());
tchModuleWeith.setSchoolId(schoolId);
tchModuleWeithMapper.updateByPrimaryKeySelective(tchModuleWeith);
userService.totalRank(schoolId);
//企业征信成绩
userService.corporateCreditRank(schoolId);
}
if ("综合案例成绩".equals(module))
{
//案例-用户画像权重
tchModuleWeith.setCaseUserProfileWeith(weight.getCaseUserProfileWeith());
//案例-个人征信权重
tchModuleWeith.setCasePersonalCreditWeith(weight.getCasePersonalCreditWeith());
//案例-企业征信权重
tchModuleWeith.setCaseCorporateCreditWeith(weight.getCaseCorporateCreditWeith());
tchModuleWeith.setSchoolId(schoolId);
tchModuleWeithMapper.updateByPrimaryKeySelective(tchModuleWeith);
userService.totalRank(schoolId);
//征信画像成绩排序
userService.comprehensiveCaseRank(schoolId);
}
return new ResultEntity(HttpStatus.OK, module+"权重设置成功");
}
@AnonymousAccess
@GetMapping("/conceptTechnologyExport")
@ApiOperation("成绩导出")
public void conceptTechnologyExport(HttpServletResponse response, @RequestParam String schoolId,@RequestParam String module) {
//导出的表名
String title = IdUtil.simpleUUID();
//表中第一行表头字段
String[] headers=null;
List<String> listColumn = null;
Boolean flag = true;
if("征信画像成绩".equals(module)){
headers = new String[]{"用户名", "学号", "班级", "贷款案例", "个人情况与违约","还款行为与违约","综合得分","排名"};
listColumn = Arrays.asList("name", "studentId", "className","loanCasesScore","perSituationScore","repaymentBehaviorScore","creditPortraitScore","creditPortraitRank");
}
else if("个人征信成绩".equals(module)){
headers = new String[]{"用户名", "学号", "班级", "影响因素分析", "征信优化分析","征信评级模型","综合得分","排名"};
listColumn = Arrays.asList("name", "studentId", "className","perInfluenceFactorScore","perCreditOptimizationSocre","perCreditRatingSocre","personalCreditScore","personalCreditRank");
}
else if("企业征信成绩".equals(module)){
headers = new String[]{"用户名", "学号", "班级", "影响因素分析", "征信优化分析","征信评级模型","综合得分","排名"};
listColumn = Arrays.asList("name", "studentId", "className","entInfluenceFactorSocre","entCreditOptimizationSocre","entCreditRatingSocre","corporateCreditScore","corporateCreditRank");
}
else if("综合案例成绩".equals(module)){
headers = new String[]{"用户名", "学号", "班级", "征信画像案例成绩", "个人征信案例客观成绩", "个人征信案例主观成绩", "企业征信案例客观成绩","企业征信案例主观成绩","综合得分","排名"};
listColumn = Arrays.asList("name", "studentId", "className","caseUserProfileSocre","casePersonalCreditObjScore","casePersonalCreditSubScore","caseCorporateCreditObjScore","caseCorporateCreditSubScore","comprehensiveCaseScore","comprehensiveCaseRank");
}
//实际数据结果集
List<StuUser> stuUsers = userService.selectViewList(schoolId,module);
//具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
try {
FilePortUtil.exportExcel(response, title, headers, stuUsers, listColumn);
} catch (Exception e) {
e.printStackTrace();
}
}
@AnonymousAccess
@ApiOperation("老师主观成绩手动评分")
@PostMapping("/manualRatingByTeacher")
public ResultEntity manualRatingByTeacher(@RequestParam TchManualRatingByTeacherDTO manualRatingByTeacherDTO) {
userService.manualRatingByTeacher(manualRatingByTeacherDTO);
return new ResultEntity(HttpStatus.OK, "评分成功");
}
@AnonymousAccess
@ApiOperation("获取所有实验报告")
@GetMapping("/getTrainingReportList")
public ResultEntity getTrainingReportList(@RequestParam String schoolId,@RequestParam String module,@RequestParam Integer index,@RequestParam Integer size){
PageHelper.startPage(index, size);
StuPracticalTrainingReportExample example=new StuPracticalTrainingReportExample();
StuPracticalTrainingReportExample.Criteria criteria = example.createCriteria();
criteria.andSchoolIdEqualTo(schoolId);
if(Constant.CREDIT_PORTRAIT_SCORE.equals(module)){
List<String> list=new ArrayList<>();
list.add(Constant.DKAL_MODULE);
list.add(Constant.GRQKYWY_MODULE);
list.add(Constant.HKXWYWY_MODULE);
criteria.andModuleIn(list);
}else if(Constant.PERSONAL_CREDIT_SCORE.equals(module)){
List<String> list=new ArrayList<>();
list.add(Constant.PERSONYXYSFX_MODULE);
list.add(Constant.PERSONZXYHFX_MODULE);
list.add(Constant.PERSONZXPJMX_MOXULE);
criteria.andModuleIn(list);
}else if(Constant.CORPORATE_CREDIT_SCORE.equals(module)){
List<String> list=new ArrayList<>();
list.add(Constant.QIYEYXYSFX_MODULE);
list.add(Constant.QIYEZXYHFX_MODULE);
list.add(Constant.QIYEZXPJMX_MOXULE);
criteria.andModuleIn(list);
}
List<StuPracticalTrainingReport> stuPracticalTrainingReports = practicalTrainingReportMapper.selectByExample(example);
PageInfo<StuPracticalTrainingReport> pageInfo=new PageInfo<>(stuPracticalTrainingReports);
List<TchPracticalTrainingReportDto> dtoList=new ArrayList<>();
for (int i = 0; i < stuPracticalTrainingReports.size(); i++) {
StuPracticalTrainingReport report = stuPracticalTrainingReports.get(i);
String userid = report.getUserid();
StuUser stuUser = userMapper.selectByPrimaryKey(userid); // //根据查询出来的userid 去user表中查询用户名、学号、班级
if(stuUser==null){
continue;
}
dtoList.add(new TchPracticalTrainingReportDto(stuUser,report));
}
PageInfo<TchPracticalTrainingReportDto> pageInfo1=new PageInfo<>(dtoList);
pageInfo1.setTotal(pageInfo.getTotal());
return new ResultEntity(HttpStatus.OK, module+"实训报告展示成功",pageInfo1);
}
@GetMapping("/getCurrencyScoreReport")
@ApiOperation("评阅界面")
@AnonymousAccess
public ResultEntity<PageInfo<StuUserDto>> getCurrencyScoreReport(@RequestParam String schoolId,
@RequestParam Integer index,
@RequestParam Integer size,
@RequestParam String module,
@ApiParam("姓名或者学号") @RequestParam(required = false) String name,
@RequestParam(required = false) String studentId,
@RequestParam(required = false) String className,
@ApiParam("模块") @RequestParam(required = false) String keyWord) {
return new ResultEntity<>(userService.getScoreReport(schoolId, index, size, module, name, studentId, className,keyWord));
}
@GetMapping("/getReport")
@ApiOperation("获取单个学生报告接口")
@AnonymousAccess
public ResponseEntity<FileSystemResource> getReport(@RequestParam String userId, @RequestParam String module, HttpServletResponse response) {
StuPracticalTrainingReportExample practicalTrainingReportExample = new StuPracticalTrainingReportExample();
practicalTrainingReportExample.createCriteria().andUseridEqualTo(userId).andModuleEqualTo(module);
List<StuPracticalTrainingReport> stuPracticalTrainingReports = practicalTrainingReportMapper.selectByExample(practicalTrainingReportExample);
if (stuPracticalTrainingReports.isEmpty()) {
return null;
}
StuPracticalTrainingReport stuPracticalTrainingReport = stuPracticalTrainingReports.get(0);
String url = stuPracticalTrainingReport.getUrl();
String videoPath = filePath + url;
File videoFile = new File(videoPath);
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();
}
}
@PostMapping("/ratingAndComment")
@ApiOperation("老师输入评语和打分")
@AnonymousAccess
public void ratingAndComment(@RequestBody StuPracticalTrainingReport practicalTrainingReport) {
practicalTrainingReportMapper.updateByPrimaryKeySelective(practicalTrainingReport);
if (practicalTrainingReport.getRating() != null) {
StuScoreDetailsExample stuScoreDetailsExample = new StuScoreDetailsExample();
stuScoreDetailsExample.createCriteria().andModuleEqualTo(practicalTrainingReport.getModule()).andUserIdEqualTo(practicalTrainingReport.getUserid()).andSerialNumberEqualTo(5);
List<StuScoreDetails> stuScoreDetails = stuScoreDetailsMapper.selectByExample(stuScoreDetailsExample);
if (!stuScoreDetails.isEmpty()) {
StuScoreDetails stuScoreDetails1 = stuScoreDetails.get(0);
stuScoreDetails1.setScoreProject(practicalTrainingReport.getRating());
stuScoreDetailsMapper.updateByPrimaryKey(stuScoreDetails1);
}
}
}
@AnonymousAccess
@GetMapping("/getClassNameBySchoolId")
@ApiOperation("班级下拉框")
public ResultEntity<List<String>> getClassNameBySchoolId(@RequestParam String schoolId) {
return new ResultEntity<List<String>>(userService.getClassNameBySchoolId(schoolId));
}
}

@ -13,6 +13,7 @@ import com.sztzjy.digital_credit.mapper.TchModuleWeithMapper;
import com.sztzjy.digital_credit.service.StuUserService;
import com.sztzjy.digital_credit.util.ResultEntity;
import com.sztzjy.digital_credit.util.excel.FilePortUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@ -26,6 +27,7 @@ import java.util.List;
//教师端成绩总览
@RestController
@RequestMapping("/api/tch/generalView")
@Api(tags = "教师端成绩总览")
public class TchGeneralViewController {
@Autowired
StuUserService userService;

@ -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();
}
}

@ -2,7 +2,10 @@ package com.sztzjy.digital_credit.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
/**
*
* @author tz
@ -15,6 +18,8 @@ public class StuPracticalTrainingReport {
@ApiModelProperty("报告名称")
private String reportName;
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
@ApiModelProperty("上传时间")
private Date uploadTime;

@ -122,17 +122,24 @@ public class StuUser {
public StuUser(StuUser stuUser, TchModuleWeith resultsOverviewWeight) {
this.userId=stuUser.getUserId();
//征信画像
BigDecimal creditPortraitScore =stuUser.getLoanCasesScore().add(stuUser.getPerSituationScore()).add(stuUser.getRepaymentBehaviorScore()).divide(BigDecimal.valueOf(3),2,BigDecimal.ROUND_HALF_UP).multiply(resultsOverviewWeight.getCreditPortraitWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
creditPortraitScore =((stuUser.getLoanCasesScore().multiply(resultsOverviewWeight.getLoanCasesWeight())).add(stuUser.getPerSituationScore().multiply(resultsOverviewWeight.getPerSituationWeiht())).add(stuUser.getRepaymentBehaviorScore().multiply(resultsOverviewWeight.getRepaymentBehaviorWeiht()))).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal socre1 = creditPortraitScore.multiply(resultsOverviewWeight.getCreditPortraitWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
//个人征信
BigDecimal personalCreditScore=stuUser.getPerInfluenceFactorScore().add(stuUser.getPerCreditOptimizationSocre()).add(stuUser.getPerCreditRatingSocre()).divide(BigDecimal.valueOf(3),2,BigDecimal.ROUND_HALF_UP).multiply(resultsOverviewWeight.getPersonalCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
personalCreditScore=((stuUser.getPerInfluenceFactorScore().multiply(resultsOverviewWeight.getPerInfluenceFactorWeith())).add(stuUser.getPerCreditOptimizationSocre().multiply(resultsOverviewWeight.getPerCreditOptimizationWeith())).add(stuUser.getPerCreditRatingSocre().multiply(resultsOverviewWeight.getPerCreditRatingWeith()))).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal socre2 =personalCreditScore.multiply(resultsOverviewWeight.getPersonalCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
//企业征信
BigDecimal corporateCreditScore=stuUser.getEntInfluenceFactorSocre().add(stuUser.getEntCreditOptimizationSocre()).add(stuUser.getEntCreditRatingSocre()).divide(BigDecimal.valueOf(3),2,BigDecimal.ROUND_HALF_UP).multiply(resultsOverviewWeight.getEnterpriseCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
corporateCreditScore=((stuUser.getEntInfluenceFactorSocre().multiply(resultsOverviewWeight.getEntInfluenceFactorWeith())).add(stuUser.getEntCreditOptimizationSocre().multiply(resultsOverviewWeight.getEntCreditOptimizationWeith())).add(stuUser.getEntCreditRatingSocre().multiply(resultsOverviewWeight.getEntCreditRatingWeith()))).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal socre3 = corporateCreditScore.multiply(resultsOverviewWeight.getEnterpriseCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
//综合案例
BigDecimal comprehensiveCaseScore=stuUser.getCaseUserProfileSocre().add(stuUser.getCasePersonalCreditScore()).add(stuUser.getCaseCorporateCreditScore()).divide(BigDecimal.valueOf(3),2,BigDecimal.ROUND_HALF_UP).multiply(resultsOverviewWeight.getCaseStudyWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
comprehensiveCaseScore = ((stuUser.getCaseUserProfileSocre().multiply(resultsOverviewWeight.getCaseUserProfileWeith())).add(stuUser.getCasePersonalCreditScore().multiply(resultsOverviewWeight.getCasePersonalCreditWeith())).add(stuUser.getCaseCorporateCreditScore().multiply(resultsOverviewWeight.getCaseCorporateCreditWeith()))).setScale(2,BigDecimal.ROUND_HALF_UP);
BigDecimal socre4 = comprehensiveCaseScore.multiply(resultsOverviewWeight.getCaseStudyWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
this.totalScore= creditPortraitScore.add(personalCreditScore).add(corporateCreditScore)
.add(comprehensiveCaseScore).setScale(2,BigDecimal.ROUND_HALF_UP);
this.totalScore= socre1.add(socre2).add(socre3)
.add(socre4).setScale(2,BigDecimal.ROUND_HALF_UP);
}

@ -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();
}
}

@ -22,6 +22,8 @@ public class ScoreOverviewParametesDTO {
private Integer index;
private String module;

@ -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;
}

@ -120,33 +120,42 @@ public class TchGeneralViewDTO {
}
public TchGeneralViewDTO(StuUser stuUser, TchModuleWeith resultsOverviewWeight) {
//这个DTO求的是×权重的成绩 并不写入数据库
this.name=stuUser.getName();
this.studentId=stuUser.getStudentId();
this.className=stuUser.getClassName();
//征信画像
this.creditPortraitScore=stuUser.getLoanCasesScore().add(stuUser.getPerSituationScore()).add(stuUser.getRepaymentBehaviorScore()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getCreditPortraitWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
creditPortraitScore =((stuUser.getLoanCasesScore().multiply(resultsOverviewWeight.getLoanCasesWeight())).add(stuUser.getPerSituationScore().multiply(resultsOverviewWeight.getPerSituationWeiht())).add(stuUser.getRepaymentBehaviorScore().multiply(resultsOverviewWeight.getRepaymentBehaviorWeiht()))).setScale(2,BigDecimal.ROUND_HALF_UP);
this.creditPortraitWeith=resultsOverviewWeight.getCreditPortraitWeith();
if(stuUser.getCreditPortraitRank()!=null){
this.creditPortraitRank=stuUser.getCreditPortraitRank();
}
//个人征信
this.personalCreditScore=stuUser.getPerInfluenceFactorScore().add(stuUser.getPerCreditOptimizationSocre()).add(stuUser.getPerCreditRatingSocre()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getPersonalCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
this.personalCreditScore=((stuUser.getPerInfluenceFactorScore().multiply(resultsOverviewWeight.getPerInfluenceFactorWeith())).add(stuUser.getPerCreditOptimizationSocre().multiply(resultsOverviewWeight.getPerCreditOptimizationWeith())).add(stuUser.getPerCreditRatingSocre().multiply(resultsOverviewWeight.getPerCreditRatingWeith()))).setScale(2,BigDecimal.ROUND_HALF_UP);
this.personalCreditWeith=resultsOverviewWeight.getPersonalCreditWeith();
if(stuUser.getPersonalCreditRank()!=null){
this.personalCreditRank=stuUser.getPersonalCreditRank();
}
//企业征信
this.corporateCreditScore=stuUser.getEntInfluenceFactorSocre().add(stuUser.getEntCreditOptimizationSocre()).add(stuUser.getEntCreditRatingSocre()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getEnterpriseCreditWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
this.corporateCreditScore=((stuUser.getEntInfluenceFactorSocre().multiply(resultsOverviewWeight.getEntInfluenceFactorWeith())).add(stuUser.getEntCreditOptimizationSocre().multiply(resultsOverviewWeight.getEntCreditOptimizationWeith())).add(stuUser.getEntCreditRatingSocre().multiply(resultsOverviewWeight.getEntCreditRatingWeith()))).setScale(2,BigDecimal.ROUND_HALF_UP);
this.enterpriseCreditWeith=resultsOverviewWeight.getEnterpriseCreditWeith();
if(stuUser.getCorporateCreditRank()!=null){
this.corporateCreditRank=stuUser.getCorporateCreditRank();
}
//综合案例
this.comprehensiveCaseScore=stuUser.getCaseUserProfileSocre().add(stuUser.getCasePersonalCreditScore()).add(stuUser.getCaseCorporateCreditScore()).divide(BigDecimal.valueOf(3)).multiply(resultsOverviewWeight.getCaseStudyWeith()).setScale(2,BigDecimal.ROUND_HALF_UP);
this.comprehensiveCaseScore=((stuUser.getCaseUserProfileSocre().multiply(resultsOverviewWeight.getCaseUserProfileWeith())).add(stuUser.getCasePersonalCreditScore().multiply(resultsOverviewWeight.getCasePersonalCreditWeith())).add(stuUser.getCaseCorporateCreditScore().multiply(resultsOverviewWeight.getCaseCorporateCreditWeith()))).setScale(2,BigDecimal.ROUND_HALF_UP);
this.caseStudyWeith=resultsOverviewWeight.getCaseStudyWeith();
if(stuUser.getComprehensiveCaseRank()!=null){
this.comprehensiveCaseRank=stuUser.getComprehensiveCaseRank();

@ -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);
}

@ -80,4 +80,6 @@ public interface StuUserMapper {
"s.user_id = r.user_id " +
"SET s.comprehensive_case_rank = r.ranking WHERE school_id=#{schoolId}")
void updateComprehensiveCaseRank(String schoolId);
List<String> getClassNameBySchoolId(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);
}

@ -1,9 +1,12 @@
package com.sztzjy.digital_credit.service;
import com.github.pagehelper.PageInfo;
import com.sztzjy.digital_credit.controller.tch.StuUserDto;
import com.sztzjy.digital_credit.entity.StuUser;
import com.sztzjy.digital_credit.entity.tchdto.ScoreOverviewParametesDTO;
import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewDTO;
import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewWeightDTO;
import com.sztzjy.digital_credit.entity.tchdto.TchManualRatingByTeacherDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -54,4 +57,29 @@ public interface StuUserService {
*/
void comprehensiveCaseRank(@Param("schoolId") String schoolId);
/**
*
* @param parametes
* @return
*/
PageInfo<StuUser> getCreditPortraitAchievementList(ScoreOverviewParametesDTO parametes);
//实际数据结果集
List<StuUser> selectViewList(String schoolId, String module);
/**
*
* @param manualRatingByTeacherDTO
* @return
*/
void manualRatingByTeacher(TchManualRatingByTeacherDTO manualRatingByTeacherDTO);
PageInfo<StuUserDto> getScoreReport(String schoolId, Integer index, Integer size, String module, String name, String studentId, String className, String keyWord);
//班级下拉框
List<String> getClassNameBySchoolId(@Param("schoolId") String schoolId);
}

@ -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;
}
}

@ -5,6 +5,7 @@ package com.sztzjy.digital_credit.service.impl;/**
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.digital_credit.controller.tch.StuUserDto;
import com.sztzjy.digital_credit.entity.StuUser;
import com.sztzjy.digital_credit.entity.StuUserExample;
import com.sztzjy.digital_credit.entity.TchModuleWeith;
@ -12,11 +13,16 @@ import com.sztzjy.digital_credit.entity.TchModuleWeithExample;
import com.sztzjy.digital_credit.entity.tchdto.ScoreOverviewParametesDTO;
import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewDTO;
import com.sztzjy.digital_credit.entity.tchdto.TchGeneralViewWeightDTO;
import com.sztzjy.digital_credit.entity.tchdto.TchManualRatingByTeacherDTO;
import com.sztzjy.digital_credit.mapper.StuUserDtoMapper;
import com.sztzjy.digital_credit.mapper.StuUserMapper;
import com.sztzjy.digital_credit.mapper.TchModuleWeithMapper;
import com.sztzjy.digital_credit.service.StuUserService;
import com.sztzjy.digital_credit.util.PageUtil;
import com.sztzjy.digital_credit.util.ResultEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@ -34,6 +40,9 @@ public class StuUserServiceImpl implements StuUserService {
@Autowired
private StuUserMapper userMapper;
@Autowired
private StuUserDtoMapper stuUserDtoMapper;
/**
* ()
@ -49,10 +58,9 @@ public class StuUserServiceImpl implements StuUserService {
TchModuleWeithExample tchModuleWeithExample = new TchModuleWeithExample();
tchModuleWeithExample.createCriteria().andSchoolIdEqualTo(parametes.getSchoolId());
List<TchModuleWeith> tchModuleWeithList = tchModuleWeithMapper.selectByExample(tchModuleWeithExample);
if (tchModuleWeithList.isEmpty())
{
if (tchModuleWeithList.isEmpty()) {
//创建默认权重数据
TchModuleWeith tchModuleWeith=new TchModuleWeith(parametes.getSchoolId());
TchModuleWeith tchModuleWeith = new TchModuleWeith(parametes.getSchoolId());
tchModuleWeithMapper.insert(tchModuleWeith);
}
@ -130,8 +138,7 @@ public class StuUserServiceImpl implements StuUserService {
tchModuleWeithExample.createCriteria().andSchoolIdEqualTo(schoolId);
List<TchModuleWeith> tchModuleWeithList = tchModuleWeithMapper.selectByExample(tchModuleWeithExample);
if (tchModuleWeithList.isEmpty())
{
if (tchModuleWeithList.isEmpty()) {
TchModuleWeith tchModuleWeith = new TchModuleWeith(schoolId);
tchModuleWeithMapper.insertSelective(tchModuleWeith);
tchModuleWeithList.add(tchModuleWeith);
@ -144,7 +151,7 @@ public class StuUserServiceImpl implements StuUserService {
List<StuUser> list = new ArrayList();
for (int i = 0; i < stuUsers.size(); i++) {
//System.out.println(stuUsers.get(i).getUserId());
StuUser stuUser=new StuUser(stuUsers.get(i),tchModuleWeithList.get(0));
StuUser stuUser = new StuUser(stuUsers.get(i), tchModuleWeithList.get(0));
list.add(stuUser);
}
Collections.sort(list, new Comparator<StuUser>() {
@ -164,6 +171,7 @@ public class StuUserServiceImpl implements StuUserService {
/**
*
*
* @param schoolId
* @return
*/
@ -178,6 +186,7 @@ public class StuUserServiceImpl implements StuUserService {
/**
*
*
* @param schoolId
* @return
*/
@ -191,6 +200,7 @@ public class StuUserServiceImpl implements StuUserService {
/**
*
*
* @param schoolId
* @return
*/
@ -201,6 +211,7 @@ public class StuUserServiceImpl implements StuUserService {
/**
*
*
* @param schoolId
* @return
*/
@ -210,5 +221,112 @@ public class StuUserServiceImpl implements StuUserService {
userMapper.updateComprehensiveCaseRank(schoolId);
}
@Override
public PageInfo<StuUser> getCreditPortraitAchievementList(ScoreOverviewParametesDTO parametes) {
PageHelper.startPage(parametes.getIndex(), parametes.getSize());
StuUserExample example = new StuUserExample();
StuUserExample.Criteria criteria = example.createCriteria();
criteria.andSchoolIdEqualTo(parametes.getSchoolId());
if (StringUtils.isNotBlank(parametes.getName())) {
// criteria.andNameEqualTo(viewShowDTO.getName());
criteria.andNameLike("%" + parametes.getName() + "%");
}
if (StringUtils.isNotBlank(parametes.getStudentId())) {
// criteria.andStudentIdEqualTo(viewShowDTO.getStudentId());
criteria.andStudentIdLike("%" + parametes.getStudentId() + "%");
}
if (StringUtils.isNotBlank(parametes.getClassName())) {
criteria.andClassNameLike("%" + parametes.getClassName() + "%");
}
if (parametes.getModule().equals("征信画像成绩")) {
example.setOrderByClause("credit_portrait_rank");
} else if (parametes.getModule().equals("个人征信成绩")) {
example.setOrderByClause("personal_credit_rank");
} else if (parametes.getModule().equals("企业征信成绩")) {
example.setOrderByClause("corporate_credit_rank");
} else if (parametes.getModule().equals("综合案例成绩")) {
example.setOrderByClause("comprehensive_case_rank");
}
List<StuUser> stuUsers = userMapper.selectByExample(example);
PageInfo<StuUser> pageInfo = new PageInfo<>(stuUsers);
return pageInfo;
}
//实际数据结果集
@Override
public List<StuUser> selectViewList(String schoolId, String module) {
StuUserExample example = new StuUserExample();
StuUserExample.Criteria criteria = example.createCriteria();
criteria.andSchoolIdEqualTo(schoolId);
if (module.equals("征信画像成绩")) {
example.setOrderByClause("credit_portrait_rank ASC");
} else if (module.equals("个人征信成绩")) {
example.setOrderByClause("personal_credit_rank ASC");
} else if (module.equals("企业征信成绩")) {
example.setOrderByClause("corporate_credit_rank ASC");
} else if (module.equals("综合案例成绩")) {
example.setOrderByClause("comprehensive_case_rank ASC");
}
List<StuUser> stuUsers = userMapper.selectByExample(example);
return stuUsers;
}
/**
*
* @param manualRatingByTeacherDTO
* @return
*/
@Override
public void manualRatingByTeacher(TchManualRatingByTeacherDTO manualRatingByTeacherDTO) {
StuUser stuUser = userMapper.selectByPrimaryKey(manualRatingByTeacherDTO.getUserId());
//将老师评分手动写入对应分数
if ("个人征信案例主观成绩".equals(manualRatingByTeacherDTO.getModule())){
stuUser.setCasePersonalCreditSubScore(manualRatingByTeacherDTO.getScore());
stuUser.setCasePersonalCreditScore(manualRatingByTeacherDTO.getScore().add(stuUser.getCasePersonalCreditObjScore()));
}
if ("企业征信案例主观成绩".equals(manualRatingByTeacherDTO.getModule())){
stuUser.setCaseCorporateCreditSubScore(manualRatingByTeacherDTO.getScore());
stuUser.setCaseCorporateCreditScore(manualRatingByTeacherDTO.getScore().add(stuUser.getCaseCorporateCreditObjScore()));
}
//总分累加
userMapper.updateByPrimaryKeySelective(stuUser);
}
@Override
public PageInfo<StuUserDto> getScoreReport(String schoolId, Integer index, Integer size, String module, String name, String studentId, String className, String keyWord) {
List<StuUserDto>userDtoList= stuUserDtoMapper.selectByCondition(name,studentId,className,module,keyWord,schoolId);
PageInfo<StuUserDto> pageInfo = PageUtil.pageHelper(userDtoList, index, size);
return pageInfo;
}
//班级下拉框
@Override
public List<String> getClassNameBySchoolId(String schoolId) {
return userMapper.getClassNameBySchoolId(schoolId);
}
}

@ -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("&nbsp;","&#160;")
.replace("&ldquo;","\"")
.replace("&rdquo;","\"");
// 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>

@ -401,6 +401,7 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update stu_user
<set>
@ -820,4 +821,11 @@
</foreach>
</update>
<select id="getClassNameBySchoolId" resultType="java.lang.String">
select class_name from stu_user
where school_id = #{schoolId}
group by class_name
</select>
</mapper>

Binary file not shown.
Loading…
Cancel
Save