|
@@ -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);
|
|
|
}
|
|
|
|