|
@@ -2,8 +2,12 @@ package cn.com.qmth.stmms.ms.admin.api;
|
|
|
|
|
|
import cn.com.qmth.stmms.ms.admin.service.InspectRangeService;
|
|
import cn.com.qmth.stmms.ms.admin.service.InspectRangeService;
|
|
import cn.com.qmth.stmms.ms.core.domain.InspectRange;
|
|
import cn.com.qmth.stmms.ms.core.domain.InspectRange;
|
|
|
|
+import cn.com.qmth.stmms.ms.core.domain.user.MarkUser;
|
|
|
|
+import cn.com.qmth.stmms.ms.core.domain.user.Role;
|
|
import cn.com.qmth.stmms.ms.core.repository.InspectRangeRepo;
|
|
import cn.com.qmth.stmms.ms.core.repository.InspectRangeRepo;
|
|
|
|
+import cn.com.qmth.stmms.ms.core.repository.MarkUserRepo;
|
|
import cn.com.qmth.stmms.ms.core.repository.PaperRepo;
|
|
import cn.com.qmth.stmms.ms.core.repository.PaperRepo;
|
|
|
|
+import cn.com.qmth.stmms.ms.core.vo.Subject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -19,10 +23,13 @@ public class InspectRangeApi {
|
|
@Autowired
|
|
@Autowired
|
|
private InspectRangeRepo inspectRangeRepo;
|
|
private InspectRangeRepo inspectRangeRepo;
|
|
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private InspectRangeService inspectRangeService;
|
|
private InspectRangeService inspectRangeService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MarkUserRepo markUserRepo;
|
|
|
|
+
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private PaperRepo paperRepo;
|
|
private PaperRepo paperRepo;
|
|
|
|
|
|
@@ -42,6 +49,12 @@ public class InspectRangeApi {
|
|
throw new RuntimeException("接口参数缺失");
|
|
throw new RuntimeException("接口参数缺失");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //判断该评卷工作是否已经有抽查工作了
|
|
|
|
+ int inspectRangeCount = inspectRangeRepo.countByWorkId(workId);
|
|
|
|
+ if (inspectRangeCount > 0) {
|
|
|
|
+ throw new RuntimeException("请勿重复创建抽查范围");
|
|
|
|
+ }
|
|
|
|
+
|
|
//判断是否已经全部打分完成了
|
|
//判断是否已经全部打分完成了
|
|
long unfinishedPaperCount = paperRepo.countByWorkIdAndScoreIsNull(workId);
|
|
long unfinishedPaperCount = paperRepo.countByWorkIdAndScoreIsNull(workId);
|
|
|
|
|
|
@@ -55,19 +68,36 @@ public class InspectRangeApi {
|
|
|
|
|
|
@PutMapping(value = "{domain}")
|
|
@PutMapping(value = "{domain}")
|
|
public void update(@PathVariable InspectRange domain, @RequestBody InspectRange inspectRange) {
|
|
public void update(@PathVariable InspectRange domain, @RequestBody InspectRange inspectRange) {
|
|
|
|
+
|
|
|
|
+ //如果抽查已经启动,则不能再修改了
|
|
|
|
+ if (domain.getEnabled()) {
|
|
|
|
+ throw new RuntimeException("抽查已经启动了,无法修改抽查范围。");
|
|
|
|
+ }
|
|
|
|
+
|
|
domain.setCondition(inspectRange.getCondition());
|
|
domain.setCondition(inspectRange.getCondition());
|
|
domain.setEnabled(inspectRange.getEnabled());
|
|
domain.setEnabled(inspectRange.getEnabled());
|
|
domain.setType(inspectRange.getType());
|
|
domain.setType(inspectRange.getType());
|
|
inspectRangeService.save(domain);
|
|
inspectRangeService.save(domain);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- //@PatchMapping(value = "{domain}/start")
|
|
|
|
- @RequestMapping(value = "{domain}/start",method = RequestMethod.PATCH)
|
|
|
|
|
|
+ @PatchMapping(value = "{domain}/start")
|
|
public void start(@PathVariable InspectRange domain) {
|
|
public void start(@PathVariable InspectRange domain) {
|
|
|
|
|
|
- domain.setEnabled(true);
|
|
|
|
- inspectRangeService.save(domain);
|
|
|
|
|
|
+ //已经启动了就不用再启动了
|
|
|
|
+ if (domain.getEnabled()) {
|
|
|
|
+ throw new RuntimeException("抽查已经启动了");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //判断是否可以启动
|
|
|
|
+ for (Subject subject : Subject.values()) {
|
|
|
|
+ //判断是否每一科目分配了复查专家账号
|
|
|
|
+ List<MarkUser> inspectors4Subject = markUserRepo.findByWorkIdAndSubjectAndRole(domain.getWorkId(), subject, Role.INSPECTOR);
|
|
|
|
+ if (inspectors4Subject == null || inspectors4Subject.size() < 1) {
|
|
|
|
+ throw new RuntimeException("至少添加一个" + subject.getName() + "复评专家");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ inspectRangeService.start(domain.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|