Ver Fonte

修复一些问题

linyk há 2 anos atrás
pai
commit
0f55d67bdc

+ 5 - 5
core/src/main/java/com/mooctest/crowd/domain/domainobject/BookTestSummary.java

@@ -6,9 +6,9 @@ import java.math.BigDecimal;
 
 @Data
 public class BookTestSummary {
-    BigDecimal sum;    //酬劳总得
-    BigDecimal defaultSum;
-    BigDecimal commitSum;
-    BigDecimal auditSum;
-    BigDecimal completeSum;
+    BigDecimal sum = new BigDecimal("0.0");    //酬劳总得
+    BigDecimal defaultSum = new BigDecimal("0.0");
+    BigDecimal commitSum = new BigDecimal("0.0");
+    BigDecimal auditSum = new BigDecimal("0.0");
+    BigDecimal completeSum = new BigDecimal("0.0");
 }

+ 11 - 6
core/src/main/java/com/mooctest/crowd/domain/domainobject/CrowdTestTask.java

@@ -190,16 +190,21 @@ public class CrowdTestTask {
 
     public void confirmFinish() {
         // 具有配置项,管理员可以结束任务
-        if(this.getEndPoint() != null){
-            this.setStatus(CrowdTestTaskStatus.HAS_FINISHED);
-            this.setEndTime(new Timestamp(System.currentTimeMillis()));
-        } else if ((this.getParticipantHasCommittedCount() == this.getAcceptedCount() && this.getStatus() == CrowdTestTaskStatus.HAS_RECEIVED) || (this.getParticipantHasCommittedCount() == this.getParticipantCount() && this.getStatus() == CrowdTestTaskStatus.HAS_COMMITED)) {
+//        if(this.getEndPoint() != null){
+//            this.setStatus(CrowdTestTaskStatus.HAS_FINISHED);
+//            this.setEndTime(new Timestamp(System.currentTimeMillis()));
+//        } else if ((this.getParticipantHasCommittedCount() == this.getAcceptedCount() && this.getStatus() == CrowdTestTaskStatus.HAS_RECEIVED) || (this.getParticipantHasCommittedCount() == this.getParticipantCount() && this.getStatus() == CrowdTestTaskStatus.HAS_COMMITED)) {
+//            this.setStatus(CrowdTestTaskStatus.HAS_FINISHED);
+//            this.setEndTime(new Timestamp(System.currentTimeMillis()));
+//        } else {
+//            throw new CrowdTestTaskException("评测机构未提请结束任务,无法确认结束!");
+//        }
+        if (this.getStatus() != CrowdTestTask.HAS_FINISHED) {
             this.setStatus(CrowdTestTaskStatus.HAS_FINISHED);
             this.setEndTime(new Timestamp(System.currentTimeMillis()));
         } else {
-            throw new CrowdTestTaskException("评测机构未提请结束任务,无法确认结束!");
+            throw new CrowdTestTaskException("该任务已结束!");
         }
-
     }
 
     public void addToken(String token) {

+ 13 - 6
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -1696,7 +1696,7 @@ public class WebMediatorImpl implements ViewMediator {
         if (project.getUserId().equals(user.getId()) || user.getRoleList().stream().anyMatch(role -> role.getName().equals("SystemAdministrator"))) {
             if (project.getStatus() < CrowdTestProjectStatus.HAS_RECEIVED) {
                 operationControl.setUpdate(true);
-            } else if (project.getStatus() == CrowdTestProjectStatus.HAS_COMMITED) {
+            } else if (project.getStatus() == CrowdTestProjectStatus.HAS_COMMITED || project.getStatus() == CrowdTestProjectStatus.HAS_TIME_OUT) {
                 operationControl.setConfirmFinish(true);
             }
         }
@@ -1764,6 +1764,13 @@ public class WebMediatorImpl implements ViewMediator {
             taskOperationControl.setTestCaseManage(true);
         }
 
+        if (user.getRoleList().stream().anyMatch(role -> role.getName().equals("SystemAdministrator"))
+                || (user.getId().equals(project.getRegionalManagerId()))) {
+            if (task.getStatus() != CrowdTestTask.HAS_FINISHED || endPointPOOptional.isPresent()) {
+                taskOperationControl.setConfirmFinish(true);
+            }
+        }
+
         if(task.getStatus() == CrowdTestTaskStatus.HAS_FINISHED){// 任务已结束,如果存在配置项的任务展示token则显示 任务面板按钮
             if(endPointPOOptional.isPresent()){
                 if(endPointPOOptional.get().getToken() != null &&  !endPointPOOptional.get().getToken().equals("")){
@@ -1792,18 +1799,18 @@ public class WebMediatorImpl implements ViewMediator {
                     }
                 }else{
                     taskOperationControl.setTaskRecommend(true);
-                    if ((task.getParticipantHasCommittedCount() == task.getAcceptedCount() && task.getStatus() == CrowdTestTaskStatus.HAS_RECEIVED) || (task.getParticipantHasCommittedCount() == task.getParticipantCount() && task.getStatus() == CrowdTestTaskStatus.HAS_COMMITED)) {
-                        taskOperationControl.setConfirmFinish(true);
-                    }
+//                    if ((task.getParticipantHasCommittedCount() == task.getAcceptedCount() && task.getStatus() == CrowdTestTaskStatus.HAS_RECEIVED) || (task.getParticipantHasCommittedCount() == task.getParticipantCount() && task.getStatus() == CrowdTestTaskStatus.HAS_COMMITED)) {
+//                        taskOperationControl.setConfirmFinish(true);
+//                    }
                     if (task.getStatus() == CrowdTestTaskStatus.HAS_FINISHED || task.getStatus() == CrowdTestTaskStatus.HAS_TIME_OUT) {
-                        taskOperationControl.setConfirmFinish(false);
+//                        taskOperationControl.setConfirmFinish(false);
                         taskOperationControl.setTaskRecommend(false);
                     }
                     // 具有配置项,需要在第三方进行填写报告
                     if(endPointPOOptional.isPresent()){
                         taskOperationControl.setWriteReport(true);
                         taskOperationControl.setUploadReport(true);
-                        taskOperationControl.setConfirmFinish(true);
+//                        taskOperationControl.setConfirmFinish(true);
                         if(endPointPOOptional.get().getToken() != null &&  !endPointPOOptional.get().getToken().equals("")){
                             taskOperationControl.setTaskDemonstrate(true);
                         }

+ 4 - 2
site/src/main/java/com/mooctest/crowd/site/service/impl/BookTestServiceImpl.java

@@ -16,6 +16,7 @@ import com.mooctest.crowd.site.service.BookTestService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import springfox.documentation.builders.BuilderDefaults;
 
 import java.math.BigDecimal;
@@ -77,11 +78,12 @@ public class  BookTestServiceImpl implements BookTestService {
     }
 
     @Override
+    @Transactional
     public void saveBookTest(TaskAmountVO taskAmountVO) {
-        BookTestPO book = new BookTestPO();
         List<TaskAmountVO.TesterAmountVO> testerAmounts = taskAmountVO.getTesterAmounts();
         if (testerAmounts.size() > 0) {
             for (TaskAmountVO.TesterAmountVO testerAmount : testerAmounts) {
+                BookTestPO book = new BookTestPO();
                 book.setUid(testerAmount.getTesterId());
                 //根据项目编号查询发包机构ID
                 String cptcode = taskAmountVO.getProjectCode();
@@ -135,7 +137,7 @@ public class  BookTestServiceImpl implements BookTestService {
                 book.setTopVeryLowDefectScore(testerAmount.getTopVeryLowDefectScore());
                 bookTestRepo.saveBookTest(book);
             }
-            }
+        }
 
     }
 

+ 14 - 11
site/src/main/java/com/mooctest/crowd/site/service/impl/TaskAmountServiceImpl.java

@@ -12,10 +12,7 @@ import com.mooctest.crowd.domain.repository.CrowdTestTaskRepo;
 import com.mooctest.crowd.domain.repository.TestCaseRepo;
 import com.mooctest.crowd.site.data.vo.MixDefectInfoVO;
 import com.mooctest.crowd.site.data.vo.TaskAmountVO;
-import com.mooctest.crowd.site.service.CrowdTaskService;
-import com.mooctest.crowd.site.service.MixDefectService;
-import com.mooctest.crowd.site.service.TaskAmountService;
-import com.mooctest.crowd.site.service.UserService;
+import com.mooctest.crowd.site.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -26,6 +23,7 @@ import java.math.RoundingMode;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 public class TaskAmountServiceImpl implements TaskAmountService {
@@ -52,6 +50,8 @@ public class TaskAmountServiceImpl implements TaskAmountService {
     private TaskAmountDao taskAmountDao;
     @Autowired
     private CrowdTaskService crowdTaskService;
+    @Autowired
+    private BookTestService bookTestService;
 
     @Override
     public TaskAmountVO calculation(Long userId, String taskCode, BigDecimal effectiveWorkloadAmount, BigDecimal defectExciationAmount, BigDecimal extraRewardAmount) {
@@ -59,7 +59,7 @@ public class TaskAmountServiceImpl implements TaskAmountService {
         CrowdTestTask crowdTestTask = crowdTestTaskRepo.findByCode(taskCode);
         BigDecimal totalAmount = BigDecimal.valueOf(crowdTestTask.getQuotedPrice());
 //        if (effectiveWorkloadAmount.add(defectExciationAmount).add(extraRewardAmount).compareTo(totalAmount) != 0) {
-//            throw new BaseException("不能超出总金额!");
+//            throw new BaseException("有效测试用例奖励金额+缺陷奖励金额+额外奖励金额需等于任务总金额!");
 //        }
         List<Map> validTestCaseCountMaps = testCaseDao.countAllByTaskCodeAndExamStatusGroupByDesignerId(taskCode, TestCaseExamStatus.VALID.getValue());
         Map<Long, TaskAmountVO.TesterAmountVO> userIdTaskAmountInfoMap = new HashMap();
@@ -220,27 +220,30 @@ public class TaskAmountServiceImpl implements TaskAmountService {
         TaskAmountVO taskAmountVO = calculation(userId, taskAmountSaveCommand.getTaskCode(),
                 taskAmountSaveCommand.getEffectiveWorkloadAmount(), taskAmountSaveCommand.getDefectExciationAmount(),
                 taskAmountSaveCommand.getExtraRewardAmount());
-        if (taskAmountVO.getStatus() != CrowdTestTask.HAS_COMMITED) {
-            throw new BaseException("该任务还未提交!");
-        }
+//        if (taskAmountVO.getStatus() != CrowdTestTask.HAS_COMMITED) {
+//            throw new BaseException("该任务还未提交!");
+//        }
         if (taskAmountSaveCommand.getEffectiveWorkloadAmount().add(taskAmountSaveCommand.getDefectExciationAmount())
                 .add(taskAmountSaveCommand.getExtraRewardAmount()).compareTo(taskAmountVO.getTotalAmount()) != 0) {
             throw new BaseException("有效测试用例奖励金额+缺陷奖励金额+额外奖励金额需等于任务总金额!");
         }
         BigDecimal totalExtraRewardAmount = BigDecimal.valueOf(0.0);
+        Map<Long, TaskAmountVO.TesterAmountVO> userIdTesterAmountMap = taskAmountVO.getTesterAmounts().stream().collect(Collectors.toMap(TaskAmountVO.TesterAmountVO::getTesterId, o -> o));
         for(TaskAmountSaveCommand.TesterExtraRewardAmount testerExtraRewardAmount : taskAmountSaveCommand.getTesterExtraRewardAmounts()) {
-            totalExtraRewardAmount.add(testerExtraRewardAmount.getAmount());
+            totalExtraRewardAmount = totalExtraRewardAmount.add(testerExtraRewardAmount.getAmount());
+            userIdTesterAmountMap.get(testerExtraRewardAmount.getUserId()).setExtraRewardAmount(testerExtraRewardAmount.getAmount());
         }
-        if (!totalExtraRewardAmount.equals(taskAmountSaveCommand.getExtraRewardAmount())) {
+        if (totalExtraRewardAmount.compareTo(taskAmountSaveCommand.getExtraRewardAmount()) != 0) {
             throw new BaseException("所有测试人员的额外奖励金额加起来需等于总的额外奖励金额!");
         }
         TaskAmountPO taskAmountPO = new TaskAmountPO();
+        taskAmountPO.setProjectCode(taskAmountVO.getProjectCode());
         taskAmountPO.setTaskCode(taskAmountSaveCommand.getTaskCode());
         taskAmountPO.setEffectiveWorkloadAmount(taskAmountSaveCommand.getEffectiveWorkloadAmount());
         taskAmountPO.setDefectExciationAmount(taskAmountSaveCommand.getDefectExciationAmount());
         taskAmountPO.setExtraRewardAmount(taskAmountSaveCommand.getExtraRewardAmount());
         taskAmountDao.save(taskAmountPO);
-
+        bookTestService.saveBookTest(taskAmountVO);
         crowdTaskService.confirmFinish(taskAmountVO.getProjectCode(), taskAmountPO.getTaskCode(), userId);
     }