|
@@ -36,6 +36,7 @@ import java.io.BufferedInputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -57,7 +58,9 @@ public class AnnualInspectionController {
|
|
|
private AnnualInspectionService annualInspectionService;
|
|
|
private LiftService liftService;
|
|
|
|
|
|
- private Map<String, String> headerAlias;
|
|
|
+ private Map<String, String> headerAlias;
|
|
|
+ //最大年检间隔
|
|
|
+ private static final int inspection_interval = 365;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void initHeaderAlias() {
|
|
@@ -135,6 +138,13 @@ public class AnnualInspectionController {
|
|
|
public RestResponse confirm(@Ver @RequestBody AnnualInspection entity){
|
|
|
long count = annualInspectionService.countConfirm(entity.getLiftId(), entity.getMtCompanyId(), entity.getPlanDate());
|
|
|
Verify.nogt0(count, "年检计划已存在");
|
|
|
+
|
|
|
+ AnnualInspection current = annualInspectionService.findCurrentConfirm(entity.getLiftId(), entity.getMtCompanyId());
|
|
|
+ if(null != current){
|
|
|
+ LocalDate deadline = current.getPlanDate().plusDays(inspection_interval);
|
|
|
+ Verify.notTrue(deadline.isBefore(entity.getPlanDate()), "上次年检" + current.getPlanDate() + ",计划年检设置" + deadline + "之前有效");
|
|
|
+ }
|
|
|
+
|
|
|
entity.setStatus(0);
|
|
|
entity.setStepStatus(1);
|
|
|
entity.setStepName(1);
|
|
@@ -177,7 +187,6 @@ public class AnnualInspectionController {
|
|
|
old.setIsCheckGoverner(entity.getIsCheckGoverner());
|
|
|
old.setLoadInspectionSetting(entity.getLoadInspectionSetting());
|
|
|
|
|
|
- old.setStatus(0);
|
|
|
old.setStepStatus(1);
|
|
|
old.setStepName(1);
|
|
|
boolean ai = annualInspectionService.saveOrUpdate(old);
|
|
@@ -196,7 +205,7 @@ public class AnnualInspectionController {
|
|
|
Integer oldStepName = old.getStepName();
|
|
|
Integer oldStepStatus = old.getStepStatus();
|
|
|
Integer stepStatus = entity.getStepStatus();
|
|
|
- Verify.isTrue(oldStepName == 1, "请进行第一阶段操作");
|
|
|
+ Verify.isTrue(oldStepName == 1, "请先完成确认操作再进行第一阶段");
|
|
|
Verify.isTrue(oldStepStatus == 1 || oldStepStatus == 2, "请进行第一阶段操作");
|
|
|
Verify.isTrue(stepStatus == 2, "请进行第一阶段操作");
|
|
|
|
|
@@ -204,7 +213,6 @@ public class AnnualInspectionController {
|
|
|
old.setSelfcheckDate(entity.getSelfcheckDate());
|
|
|
old.setStepStatus(entity.getStepStatus());
|
|
|
|
|
|
- old.setStatus(0);
|
|
|
old.setStepName(2);//流转到阶段2
|
|
|
|
|
|
boolean ai = annualInspectionService.saveOrUpdate(old);
|
|
@@ -222,7 +230,7 @@ public class AnnualInspectionController {
|
|
|
Verify.notNull(old, Verify.Inspection.confirm);
|
|
|
Integer oldStepName = old.getStepName();
|
|
|
Integer oldStepStatus = old.getStepStatus();
|
|
|
- Verify.isTrue(oldStepName == 1 || oldStepName == 2, "请进行第二阶段操作");
|
|
|
+ Verify.isTrue(oldStepName == 1 || oldStepName == 2, "请先完成第一阶段再进行第二阶段");
|
|
|
Verify.isTrue(oldStepStatus == 2 || oldStepStatus == 3, "请进行第二阶段操作");
|
|
|
|
|
|
old.setCheckDate(entity.getCheckDate());
|
|
@@ -230,7 +238,6 @@ public class AnnualInspectionController {
|
|
|
old.setOperator(entity.getOperator());
|
|
|
old.setTelephone(entity.getTelephone());
|
|
|
|
|
|
- old.setStatus(0);
|
|
|
old.setStepStatus(3);
|
|
|
old.setStepName(3);//流转到阶段3
|
|
|
|
|
@@ -254,23 +261,25 @@ public class AnnualInspectionController {
|
|
|
Integer oldStepName = old.getStepName();
|
|
|
Integer oldStepStatus = old.getStepStatus();
|
|
|
Integer stepStatus = entity.getStepStatus();
|
|
|
- Verify.isTrue(oldStepName == 2 || oldStepName == 3, "请进行第三阶段操作");
|
|
|
+ Verify.isTrue(oldStepName == 2 || oldStepName == 3, "请先完成第二阶段再进行第三阶段");
|
|
|
Verify.isTrue(oldStepStatus >= 3 && oldStepStatus <= 7, "请进行第三阶段操作");
|
|
|
Verify.isTrue(stepStatus >= 4 && stepStatus <= 7, "请进行第三阶段操作");
|
|
|
|
|
|
- old.setCheckResultImg(entity.getCheckResultImg());
|
|
|
+ LocalDate deadline = old.getPlanDate().plusDays(inspection_interval);
|
|
|
+ Verify.notTrue(deadline.isBefore(entity.getNextInspectionTime()), "上次年检" + old.getPlanDate() + ",下次年检设置" + deadline + "之前有效");
|
|
|
+
|
|
|
old.setStepStatus(entity.getStepStatus());
|
|
|
+ old.setCheckResultImg(entity.getCheckResultImg());
|
|
|
old.setNextInspectionTime(entity.getNextInspectionTime());
|
|
|
|
|
|
- old.setStatus(0);
|
|
|
//企业文员确认检验结果-整改 --> 回到第二阶段
|
|
|
- if(stepStatus == 4) {
|
|
|
- old.setStepName(3);
|
|
|
- }else if(stepStatus == 5 || stepStatus == 7){
|
|
|
+ if(stepStatus == 5 || stepStatus == 7){
|
|
|
old.setStepName(4);//流转到阶段4
|
|
|
} else if(stepStatus == 6){
|
|
|
old.setStepStatus(3);
|
|
|
old.setStepName(2);//转回阶段2
|
|
|
+ old.setCheckResultImg(null);
|
|
|
+ old.setNextInspectionTime(null);
|
|
|
}
|
|
|
return annualInspectionService.stepThree(old, entity.getProjectId(), entity.getIsCheckGoverner(), entity.getLoadInspectionSetting());
|
|
|
}
|
|
@@ -288,7 +297,7 @@ public class AnnualInspectionController {
|
|
|
Integer oldStepName = old.getStepName();
|
|
|
Integer oldStepStatus = old.getStepStatus();
|
|
|
Integer stepStatus = entity.getStepStatus();
|
|
|
- Verify.isTrue(oldStepName == 3 || oldStepName == 4, "请进行第三阶段操作");
|
|
|
+ Verify.isTrue(oldStepName == 3 || oldStepName == 4, "请先完成第三阶段再进行第四阶段");
|
|
|
Verify.isTrue(oldStepStatus >= 5 && oldStepStatus <= 10, "请进行第四阶段操作");
|
|
|
Verify.isTrue(stepStatus >= 8 && stepStatus <= 10, "请进行第四阶段操作");
|
|
|
|
|
@@ -296,19 +305,14 @@ public class AnnualInspectionController {
|
|
|
old.setAnnualInspectionImg(entity.getAnnualInspectionImg());
|
|
|
old.setCertificateImgUrl(entity.getCertificateImgUrl());
|
|
|
|
|
|
-
|
|
|
- if(stepStatus == 8){
|
|
|
- old.setStatus(0);//未完成
|
|
|
- } else if(stepStatus == 9){
|
|
|
+ if(stepStatus == 9){
|
|
|
old.setStatus(1);//已完成
|
|
|
+ old.setFinishTime(LocalDateTime.now());
|
|
|
} else if(stepStatus == 10){
|
|
|
old.setStatus(2);//超期
|
|
|
- }
|
|
|
- if(stepStatus == 9 || stepStatus == 10){
|
|
|
old.setFinishTime(LocalDateTime.now());
|
|
|
}
|
|
|
old.setStepName(4);
|
|
|
-
|
|
|
return annualInspectionService.stepFour(old);
|
|
|
}
|
|
|
/**
|