|
|
@ -1,9 +1,11 @@
|
|
|
|
package com.sztzjy.forex.trading_trading.service;
|
|
|
|
package com.sztzjy.forex.trading_trading.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.sztzjy.forex.trading_trading.config.security.JwtUser;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.sztzjy.forex.trading_trading.entity.*;
|
|
|
|
import com.sztzjy.forex.trading_trading.entity.*;
|
|
|
|
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.mappers.TrainingMapper;
|
|
|
|
import com.sztzjy.forex.trading_trading.util.file.IFileUtil;
|
|
|
|
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;
|
|
|
@ -13,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -27,8 +30,8 @@ public class ReportService {
|
|
|
|
private TrainingService trainingService;
|
|
|
|
private TrainingService trainingService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IFileUtil fileUtil;
|
|
|
|
private IFileUtil fileUtil;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private static final String SERVER_DIRECTORY = "D:\\waihui\\";
|
|
|
|
private TrainingMapper trainingMapper;
|
|
|
|
|
|
|
|
|
|
|
|
//提交实训任务报告给老师端展示
|
|
|
|
//提交实训任务报告给老师端展示
|
|
|
|
public String submitReport(ReportWithBLOBs report) {
|
|
|
|
public String submitReport(ReportWithBLOBs report) {
|
|
|
@ -91,15 +94,15 @@ public class ReportService {
|
|
|
|
ReportExample reportExample = new ReportExample();
|
|
|
|
ReportExample reportExample = new ReportExample();
|
|
|
|
reportExample.createCriteria().andMemberIdEqualTo(member.getMemberId());
|
|
|
|
reportExample.createCriteria().andMemberIdEqualTo(member.getMemberId());
|
|
|
|
List<ReportWithBLOBs> reports = reportsMapper.selectByExampleWithBLOBs(reportExample);
|
|
|
|
List<ReportWithBLOBs> reports = reportsMapper.selectByExampleWithBLOBs(reportExample);
|
|
|
|
if(reports!=null&&reports.size()>0){
|
|
|
|
if (reports != null && reports.size() > 0) {
|
|
|
|
ReportWithBLOBs report = reports.get(0);
|
|
|
|
ReportWithBLOBs report = reports.get(0);
|
|
|
|
if(StringUtils.hasText(report.getFilePath())){
|
|
|
|
if (StringUtils.hasText(report.getFilePath())) {
|
|
|
|
fileUtil.remove(report.getFilePath());
|
|
|
|
fileUtil.remove(report.getFilePath());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
report.setFilePath(filePath);
|
|
|
|
report.setFilePath(filePath);
|
|
|
|
report.setFileName(fileName);
|
|
|
|
report.setFileName(fileName);
|
|
|
|
reportsMapper.updateByExample(report,reportExample);
|
|
|
|
reportsMapper.updateByExample(report, reportExample);
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
ReportWithBLOBs report = new ReportWithBLOBs();
|
|
|
|
ReportWithBLOBs report = new ReportWithBLOBs();
|
|
|
|
report.setFileName(fileName);
|
|
|
|
report.setFileName(fileName);
|
|
|
|
report.setFilePath(filePath);
|
|
|
|
report.setFilePath(filePath);
|
|
|
@ -109,6 +112,54 @@ public class ReportService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PageInfo<ReportDto> gerReportDtos(String studentNumber, Integer schoolId, String keyWord, Integer index, Integer size) {
|
|
|
|
|
|
|
|
PageHelper.startPage(index, size);
|
|
|
|
|
|
|
|
List<ReportDto> reportDtos = new ArrayList<>();
|
|
|
|
|
|
|
|
List<ReportDto> reportDtosByKeyWord = new ArrayList<>();
|
|
|
|
|
|
|
|
MemberExample memberExample = new MemberExample();
|
|
|
|
|
|
|
|
memberExample.createCriteria().andSchoolIdEqualTo(schoolId).andStudentNumberEqualTo(studentNumber);
|
|
|
|
|
|
|
|
List<Member> members = memberMapper.selectByExample(memberExample);
|
|
|
|
|
|
|
|
for (Member member : members) {
|
|
|
|
|
|
|
|
String trainingId = member.getTrainingId();
|
|
|
|
|
|
|
|
TrainingExample trainingExample = new TrainingExample();
|
|
|
|
|
|
|
|
TrainingExample.Criteria criteria = trainingExample.createCriteria();
|
|
|
|
|
|
|
|
criteria.andStatusEqualTo("FINISHED").andTrainingIdEqualTo(trainingId);
|
|
|
|
|
|
|
|
List<Training> trainingList1 = trainingMapper.selectByExample(trainingExample);
|
|
|
|
|
|
|
|
for (Training training : trainingList1) {
|
|
|
|
|
|
|
|
ReportExample reportExample = new ReportExample();
|
|
|
|
|
|
|
|
reportExample.createCriteria().andTrainingIdEqualTo(trainingId).andMemberIdEqualTo(member.getMemberId());
|
|
|
|
|
|
|
|
List<Report> reports = reportsMapper.selectByExample(reportExample);
|
|
|
|
|
|
|
|
ReportDto reportDto = new ReportDto();
|
|
|
|
|
|
|
|
if (reports.isEmpty()) {
|
|
|
|
|
|
|
|
reportDto.setFileName(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Report report : reports) {
|
|
|
|
|
|
|
|
reportDto.setFileName(report.getFileName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Double reportScore = member.getReportScore();
|
|
|
|
|
|
|
|
if (keyWord != null && !keyWord.isEmpty()) {
|
|
|
|
|
|
|
|
criteria.andTrainingNameLike("%" + keyWord + "%");
|
|
|
|
|
|
|
|
List<Training> trainingList = trainingMapper.selectByExample(trainingExample);
|
|
|
|
|
|
|
|
for (Training training1 : trainingList) {
|
|
|
|
|
|
|
|
reportDto.setTrainingName(training1.getTrainingName());
|
|
|
|
|
|
|
|
reportDto.setStartTime(training1.getStartTime());
|
|
|
|
|
|
|
|
reportDto.setEndTime(training1.getEndTime());
|
|
|
|
|
|
|
|
reportDto.setReportScore(reportScore);
|
|
|
|
|
|
|
|
reportDtosByKeyWord.add(reportDto);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new PageInfo<>(reportDtosByKeyWord);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
reportDto.setTrainingName(training.getTrainingName());
|
|
|
|
|
|
|
|
reportDto.setStartTime(training.getStartTime());
|
|
|
|
|
|
|
|
reportDto.setEndTime(training.getEndTime());
|
|
|
|
|
|
|
|
reportDto.setReportScore(reportScore);
|
|
|
|
|
|
|
|
reportDtos.add(reportDto);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new PageInfo<>(reportDtos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 指定服务器目录
|
|
|
|
// // 指定服务器目录
|
|
|
|
// public String uploadReport(InputStream fileInputStream, String fileName, String memberId,String trainingId) {
|
|
|
|
// public String uploadReport(InputStream fileInputStream, String fileName, String memberId,String trainingId) {
|
|
|
@ -184,4 +235,5 @@ public class ReportService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|