业务编写

pull/1/head
陈沅 2 years ago
parent 489f733a25
commit 04d56ec755

@ -1,13 +1,18 @@
package com.sztzjy.forex.trading_trading.controller; package com.sztzjy.forex.trading_trading.controller;
import com.sztzjy.forex.trading_trading.annotation.Permission;
import com.sztzjy.forex.trading_trading.annotation.aspect.PermissionType;
import com.sztzjy.forex.trading_trading.entity.ReportWithBLOBs; import com.sztzjy.forex.trading_trading.entity.ReportWithBLOBs;
import com.sztzjy.forex.trading_trading.service.ReportService; import com.sztzjy.forex.trading_trading.service.ReportService;
import com.sztzjy.forex.trading_trading.util.ResultEntity; import com.sztzjy.forex.trading_trading.util.ResultEntity;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@Api(tags = "实验报告") @Api(tags = "实验报告")
@ -29,4 +34,20 @@ public class ReportController {
public ResultEntity<String> submitReport(@RequestBody ReportWithBLOBs report) { public ResultEntity<String> submitReport(@RequestBody ReportWithBLOBs report) {
return new ResultEntity<>(reportService.submitReport(report)); return new ResultEntity<>(reportService.submitReport(report));
} }
@ApiOperation("教师端--对实训报告评分")
@PostMapping("review")
@Permission(codes = PermissionType.TRAINING_PLAN_MANAGEMENT_EDIT)
public ResultEntity review(@RequestParam String id,
@RequestParam Double score) {
reportService.review(id, score);
return new ResultEntity(HttpStatus.OK);
}
@ApiOperation("教师端--实训报告下载")
@GetMapping("download")
public void download(@RequestParam String id, HttpServletResponse response) {
reportService.download(id,response);
}
} }

@ -197,7 +197,7 @@ public class Member {
* *
* @mbg.generated Wed Jul 19 15:55:18 CST 2023 * @mbg.generated Wed Jul 19 15:55:18 CST 2023
*/ */
private Integer reportScore; private Double reportScore;
/** /**
* *
@ -720,7 +720,7 @@ public class Member {
* *
* @mbg.generated Wed Jul 19 15:55:18 CST 2023 * @mbg.generated Wed Jul 19 15:55:18 CST 2023
*/ */
public Integer getReportScore() { public Double getReportScore() {
return reportScore; return reportScore;
} }
@ -732,7 +732,7 @@ public class Member {
* *
* @mbg.generated Wed Jul 19 15:55:18 CST 2023 * @mbg.generated Wed Jul 19 15:55:18 CST 2023
*/ */
public void setReportScore(Integer reportScore) { public void setReportScore(Double reportScore) {
this.reportScore = reportScore; this.reportScore = reportScore;
} }

@ -83,4 +83,12 @@ public class GradeWeightService {
return findWeightByWeightId(gradeWeights.getWeightId()); return findWeightByWeightId(gradeWeights.getWeightId());
} }
public Double findReportScore(String id,Double score) {
GradeWeight gradeWeight = gradeWeightMapper.selectByPrimaryKey(id);
if (gradeWeight == null) {
return null;
}
return gradeWeight.getReportScoreScale() * score / 100;
}
} }

@ -1,14 +1,14 @@
package com.sztzjy.forex.trading_trading.service; package com.sztzjy.forex.trading_trading.service;
import com.sztzjy.forex.trading_trading.entity.Member; import com.sztzjy.forex.trading_trading.entity.*;
import com.sztzjy.forex.trading_trading.entity.MemberExample;
import com.sztzjy.forex.trading_trading.entity.ReportExample;
import com.sztzjy.forex.trading_trading.entity.ReportWithBLOBs;
import com.sztzjy.forex.trading_trading.mappers.MemberMapper; import com.sztzjy.forex.trading_trading.mappers.MemberMapper;
import com.sztzjy.forex.trading_trading.mappers.ReportMapper; import com.sztzjy.forex.trading_trading.mappers.ReportMapper;
import com.sztzjy.forex.trading_trading.util.file.IFileUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -20,6 +20,12 @@ public class ReportService {
private ReportMapper reportsMapper; private ReportMapper reportsMapper;
@Autowired @Autowired
private MemberMapper memberMapper; private MemberMapper memberMapper;
@Autowired
private GradeWeightService gradeWeightService;
@Autowired
private TrainingService trainingService;
@Autowired
private IFileUtil fileUtil;
private static final String SERVER_DIRECTORY = "D:\\waihui\\"; private static final String SERVER_DIRECTORY = "D:\\waihui\\";
@ -33,7 +39,7 @@ public class ReportService {
Member member = members.get(0); Member member = members.get(0);
ReportExample reportExample = new ReportExample(); ReportExample reportExample = new ReportExample();
reportExample.createCriteria().andMemberIdEqualTo(memberId).andTrainingIdEqualTo(trainingId); reportExample.createCriteria().andMemberIdEqualTo(memberId).andTrainingIdEqualTo(trainingId);
Integer reportScore = member.getReportScore(); Double reportScore = member.getReportScore();
List<ReportWithBLOBs> reportWithBLOBs = reportsMapper.selectByExampleWithBLOBs(reportExample); List<ReportWithBLOBs> reportWithBLOBs = reportsMapper.selectByExampleWithBLOBs(reportExample);
if (!reportWithBLOBs.isEmpty()) { if (!reportWithBLOBs.isEmpty()) {
if (reportScore == null) { if (reportScore == null) {
@ -55,7 +61,7 @@ public class ReportService {
Member member = members.get(0); Member member = members.get(0);
ReportExample reportExample = new ReportExample(); ReportExample reportExample = new ReportExample();
reportExample.createCriteria().andMemberIdEqualTo(memberId).andTrainingIdEqualTo(trainingId); reportExample.createCriteria().andMemberIdEqualTo(memberId).andTrainingIdEqualTo(trainingId);
Integer reportScore = member.getReportScore(); Double reportScore = member.getReportScore();
List<ReportWithBLOBs> reportWithBLOBs = reportsMapper.selectByExampleWithBLOBs(reportExample); List<ReportWithBLOBs> reportWithBLOBs = reportsMapper.selectByExampleWithBLOBs(reportExample);
try { try {
if (reportScore == null) { if (reportScore == null) {
@ -89,4 +95,23 @@ public class ReportService {
} }
return "老师已评分,禁止上传"; return "老师已评分,禁止上传";
} }
public void review(String reportId,Double score){
Report report = reportsMapper.selectByPrimaryKey(reportId);
Assert.isTrue(report!=null&&report.getMemberId()!=null,"报告不存在");
Member member = memberMapper.selectByPrimaryKey(report.getMemberId());
Assert.isTrue(member!=null&&member.getTrainingId()!=null,"数据异常");
Training training = trainingService.findById(member.getTrainingId());
Assert.isTrue(training!=null&&training.getWeightId()!=null,"数据异常");
member.setReportScore(gradeWeightService.findReportScore(training.getWeightId(),score));
memberMapper.updateByPrimaryKey(member);
}
public void download(String id, HttpServletResponse response){
Report report = reportsMapper.selectByPrimaryKey(id);
Assert.isTrue(report!=null&&report.getFilePath()!=null,"报告不存在");
fileUtil.download(response,report.getFilePath(),report.getFileName());
}
} }

Loading…
Cancel
Save