|
@@ -1,12 +1,15 @@
|
|
|
package com.mooctest.service;
|
|
|
|
|
|
+import com.mooctest.dao.BugDataDao;
|
|
|
import com.mooctest.dao.MasterReportDao;
|
|
|
+import com.mooctest.model.BugData;
|
|
|
import com.mooctest.model.MasterReport;
|
|
|
-import com.sun.codemodel.internal.JForEach;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -15,9 +18,46 @@ public class BugReviewService {
|
|
|
@Autowired
|
|
|
MasterReportDao masterReportDao;
|
|
|
|
|
|
- public boolean isBugReviewed(String bugId) {// 聚合报告是否被审核
|
|
|
- MasterReport mr = masterReportDao.findByBugId(bugId);
|
|
|
- return (mr != null) && (mr.getStatus() == 1);
|
|
|
+ @Autowired
|
|
|
+ BugDataService bugDataService;
|
|
|
+ @Autowired
|
|
|
+ BugDataDao bugDataDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ MasterReportService masterReportService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ HistoryService historyService;
|
|
|
+
|
|
|
+ public boolean isBugReviewed(String bugId) {// 报告是否被审核
|
|
|
+// MasterReport mr = masterReportDao.findByBugId(bugId);
|
|
|
+// return (mr != null) && (mr.getStatus() == 1);
|
|
|
+ BugData data = bugDataService.getBugData(bugId);
|
|
|
+ return (data!=null) && (data.getStatus()==1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isMasterReviewed ( long examId,long caseId, String bugId ){
|
|
|
+ // 聚合报告是否被审核
|
|
|
+ List<MasterReport> data = masterReportDao.findByMasterId(bugId) ;
|
|
|
+ Map<String,BugData> datas = bugDataService.bugId2BugData(examId, caseId);
|
|
|
+ boolean flag = true;
|
|
|
+ for(MasterReport ms:data){
|
|
|
+ if(datas.get(ms.getBugId()).getStatus()==0){
|
|
|
+ return false; // 拥有子报告没有被审核。
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true; // 所有的子报告都被审核过了
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isTreeReviewed ( long examId,long caseId ,String bugId){
|
|
|
+ List<String> childs = historyService.getSingleRootReports(bugId);
|
|
|
+ Map<String,BugData> datas = bugDataService.bugId2BugData(examId, caseId);
|
|
|
+ for(String child: childs){
|
|
|
+ if(datas.get(child).getStatus()==0){
|
|
|
+ return false; // 拥有子报告没有被审核
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;//所有的子报告都已经被审核过了
|
|
|
}
|
|
|
|
|
|
// public boolean isMasterBugReviewed (String masterBugId){
|
|
@@ -37,13 +77,60 @@ public class BugReviewService {
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param reportId
|
|
|
+ * @return 是否审核成功
|
|
|
+ */
|
|
|
+ public boolean singleReportReview (String reportId){ //
|
|
|
+ // 仅仅是将这一份报告的状态设置为已经review, 如果这个报告还有tree报告或者master报告还没review 就提示无法review。
|
|
|
+ //如果是树状的root 和master报告就要看是不是下面的报告已经都审核了
|
|
|
+ BugData data = bugDataService.getBugData(reportId);
|
|
|
+ List<String> roots = historyService.getTreeRoots(data.getCaseId()+"-"+data.getExamId());
|
|
|
+ List<String> child = new ArrayList<>();
|
|
|
+ if(roots.contains(reportId)){
|
|
|
+ //如果是root报告的根节点
|
|
|
+ child.addAll( historyService.getSingleRootReports(reportId));
|
|
|
+ }
|
|
|
+ List<MasterReport> mrs = masterReportDao.findByMasterId(reportId);
|
|
|
+ child.addAll(mrs.stream().map(MasterReport::getBugId).collect(Collectors.toList()));
|
|
|
+ child = child.stream().distinct().collect(Collectors.toList());
|
|
|
+ child.remove(reportId);
|
|
|
+ if(isAllRemove(child)){
|
|
|
+ updateSingleBugReview(reportId);
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isAllRemove (List<String> ids) {
|
|
|
+ List<BugData> data = bugDataService.getBugDataByIds(ids);
|
|
|
+ for (BugData d:data){
|
|
|
+ if(d.getStatus() == 0){
|
|
|
+ //包含未审核的报告
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public void aggReportReview(String masterId) {
|
|
|
List<MasterReport> mrs = masterReportDao.findByMasterId(masterId);
|
|
|
List<String> bugIds = mrs.stream().map(MasterReport::getBugId).collect(Collectors.toList());
|
|
|
-
|
|
|
updateBugReviewed(bugIds);
|
|
|
}
|
|
|
|
|
|
+ private void updateSingleBugReview ( String id ){
|
|
|
+ BugData single = bugDataDao.findByBugId(id);
|
|
|
+ single.setStatus(1);
|
|
|
+ bugDataDao.save(single);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 废弃方法
|
|
|
private void updateBugReviewed(List<String> bugIds) {
|
|
|
List<MasterReport> mrs = masterReportDao.findByBugIdIn(bugIds);
|
|
|
mrs.forEach(mr -> {
|