|
|
|
@ -1,14 +1,14 @@
|
|
|
|
|
package com.sztzjy.forex.trading_trading.service;
|
|
|
|
|
|
|
|
|
|
import com.sztzjy.forex.trading_trading.entity.Member;
|
|
|
|
|
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.entity.*;
|
|
|
|
|
import com.sztzjy.forex.trading_trading.mappers.MemberMapper;
|
|
|
|
|
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.stereotype.Service;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
@ -20,6 +20,12 @@ public class ReportService {
|
|
|
|
|
private ReportMapper reportsMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MemberMapper memberMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private GradeWeightService gradeWeightService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TrainingService trainingService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IFileUtil fileUtil;
|
|
|
|
|
|
|
|
|
|
private static final String SERVER_DIRECTORY = "D:\\waihui\\";
|
|
|
|
|
|
|
|
|
@ -33,7 +39,7 @@ public class ReportService {
|
|
|
|
|
Member member = members.get(0);
|
|
|
|
|
ReportExample reportExample = new ReportExample();
|
|
|
|
|
reportExample.createCriteria().andMemberIdEqualTo(memberId).andTrainingIdEqualTo(trainingId);
|
|
|
|
|
Integer reportScore = member.getReportScore();
|
|
|
|
|
Double reportScore = member.getReportScore();
|
|
|
|
|
List<ReportWithBLOBs> reportWithBLOBs = reportsMapper.selectByExampleWithBLOBs(reportExample);
|
|
|
|
|
if (!reportWithBLOBs.isEmpty()) {
|
|
|
|
|
if (reportScore == null) {
|
|
|
|
@ -55,7 +61,7 @@ public class ReportService {
|
|
|
|
|
Member member = members.get(0);
|
|
|
|
|
ReportExample reportExample = new ReportExample();
|
|
|
|
|
reportExample.createCriteria().andMemberIdEqualTo(memberId).andTrainingIdEqualTo(trainingId);
|
|
|
|
|
Integer reportScore = member.getReportScore();
|
|
|
|
|
Double reportScore = member.getReportScore();
|
|
|
|
|
List<ReportWithBLOBs> reportWithBLOBs = reportsMapper.selectByExampleWithBLOBs(reportExample);
|
|
|
|
|
try {
|
|
|
|
|
if (reportScore == null) {
|
|
|
|
@ -89,4 +95,23 @@ public class ReportService {
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|