|
@@ -1,6 +1,5 @@
|
|
|
package cn.com.ty.lift.business.maintenance.service;
|
|
|
|
|
|
-import cn.com.ty.lift.business.common.CommonRequest;
|
|
|
import cn.com.ty.lift.business.evaluation.dao.entity.Evaluation;
|
|
|
import cn.com.ty.lift.business.evaluation.service.EvaluationService;
|
|
|
import cn.com.ty.lift.business.framework.util.MessageUtils;
|
|
@@ -22,9 +21,7 @@ import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
|
|
|
import cn.com.ty.lift.business.project.service.ProjectService;
|
|
|
import cn.com.ty.lift.common.constants.CommonEnum;
|
|
|
import cn.com.ty.lift.common.utils.MapHelper;
|
|
|
-import cn.com.ty.lift.common.verify.VerifyUtils;
|
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.IterUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
@@ -41,10 +38,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
-import java.util.Optional;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -159,15 +154,17 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
if (ObjectUtil.isEmpty(entry)) return false;
|
|
|
int interval = entry.getPlanInterval();
|
|
|
List<MaintenancePlan> planList = maintenancePlanService.findPlanList(liftId, projectId, mtCompanyId, request.getCurrentTime());
|
|
|
+ //提前保养跳过当前保养的计划
|
|
|
+ Iterator<MaintenancePlan> iterator = planList.iterator();
|
|
|
+ if (iterator.hasNext()) {
|
|
|
+ MaintenancePlan next = iterator.next();
|
|
|
+ if (Objects.nonNull(next))
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
//获取当前时间后的维保计划列表,并清除计划
|
|
|
maintenancePlanService.removeByIds(planList.stream().map(MaintenancePlan::getId).collect(Collectors.toList()));
|
|
|
//按照修改时间重新生成计划
|
|
|
List<MaintenancePlan> plans = maintenancePlanService.generatePlan(plan, periods, interval, request.getCurrentTime(), endDate);
|
|
|
- for (MaintenancePlan p : plans) {
|
|
|
- if (request.getCurrentTime().equals(p.getPlanDate())) {
|
|
|
- p.setStatus(Integer.parseInt(CommonEnum.MaintenancePlanStatus.MAINTENANCE_DOING.getCode()));
|
|
|
- }
|
|
|
- }
|
|
|
return maintenancePlanService.saveBatch(plans, plans.size());
|
|
|
}
|
|
|
|
|
@@ -203,6 +200,13 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
return RestResponse.fail(MessageUtils.get("msg.error.person.scope"));
|
|
|
MaintenancePlan plan = maintenancePlanService.getOne(record.getMtPlanId());
|
|
|
if (ObjectUtil.isEmpty(plan)) return RestResponse.fail(MessageUtils.get("msg.maintenance.plan.not.exist"));
|
|
|
+
|
|
|
+ plan.setStatus(Integer.parseInt(CommonEnum.MaintenancePlanStatus.MAINTENANCE_DOING.getCode()));
|
|
|
+ boolean planResult = maintenancePlanService.updateById(plan);
|
|
|
+ if (!planResult) {
|
|
|
+ rollback();
|
|
|
+ return RestResponse.fail(MessageUtils.get("msg.add.fail"));
|
|
|
+ }
|
|
|
//若保养时间在计划时间之前,则需要修改维保计划
|
|
|
boolean compareResult = request.getCurrentTime().isBefore(plan.getPlanDate());
|
|
|
if (compareResult) {
|
|
@@ -210,13 +214,6 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
if (!modifyPlan) {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|
|
|
}
|
|
|
- } else {
|
|
|
- plan.setStatus(Integer.parseInt(CommonEnum.MaintenancePlanStatus.MAINTENANCE_DOING.getCode()));
|
|
|
- boolean planResult = maintenancePlanService.updateById(plan);
|
|
|
- if (!planResult) {
|
|
|
- rollback();
|
|
|
- return RestResponse.fail(MessageUtils.get("msg.add.fail"));
|
|
|
- }
|
|
|
}
|
|
|
Optional<Lift> lift = liftService.getOne(null, liftId);
|
|
|
if (lift.isPresent()) {
|
|
@@ -227,6 +224,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
record.setWorkerId1(record.getWorkerId1());
|
|
|
record.setWorkDate(LocalDate.now());
|
|
|
record.setPlanDate(plan.getPlanDate());
|
|
|
+ record.setStopDate(LocalDateTime.now());
|
|
|
boolean ret = save(record);
|
|
|
if (!ret) {
|
|
|
rollback();
|
|
@@ -252,6 +250,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
return RestResponse.success(null, MessageUtils.get("msg.record.not.exist"));
|
|
|
|
|
|
record.setStatus(CommonEnum.MaintenanceRecordStatus.COMPLETE.getCode());
|
|
|
+ record.setRecoveryDate(LocalDateTime.now());
|
|
|
boolean result = updateById(record);
|
|
|
if (!result) {
|
|
|
return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
|