|
@@ -42,6 +42,7 @@ import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import cn.hutool.poi.excel.ExcelWriter;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -276,6 +277,12 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
//若保养时间在计划时间之前,提前保养,则需要修改维保计划
|
|
|
if (request.getCurrentTime().isBefore(plan.getPlanDate())) {
|
|
|
|
|
|
+ //当前时间和计划时间查询数据库维保计划的数量
|
|
|
+ if (getCountByTime(mtCompanyId, liftId, request.getCurrentTime(), plan.getPlanDate()) != 0) {
|
|
|
+ rollback();
|
|
|
+ return RestResponse.fail("不能跨期提前维保..");
|
|
|
+ }
|
|
|
+
|
|
|
//制定的是后面的维保计划 期数需要+1
|
|
|
request.setPeriods(request.getPeriods() + 1);
|
|
|
|
|
@@ -325,6 +332,32 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
|
|
|
return RestResponse.success(record.getId(), MessageUtils.get("msg.add.success"));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算当前时间和计划时间之间的 维保计划数量
|
|
|
+ *
|
|
|
+ * @param mtCompanyId
|
|
|
+ * @param liftId
|
|
|
+ * @param currentTime
|
|
|
+ * @param planDate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private int getCountByTime(Long mtCompanyId, Long liftId, LocalDate currentTime, LocalDate planDate) {
|
|
|
+
|
|
|
+ int count = maintenancePlanService.count(new QueryWrapper<MaintenancePlan>()
|
|
|
+ .lambda()
|
|
|
+ .eq(MaintenancePlan::getMtCompanyId, mtCompanyId)
|
|
|
+ .eq(MaintenancePlan::getLiftId, liftId)
|
|
|
+ //计划时间大于当前时间
|
|
|
+ .gt(MaintenancePlan::getPlanDate, currentTime)
|
|
|
+ //计划时间小于当前数据的计划时间
|
|
|
+ .lt(MaintenancePlan::getPlanDate, planDate)
|
|
|
+ //完成时间为空
|
|
|
+ .isNull(MaintenancePlan::getWorkDate));
|
|
|
+
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param params 获取任务单入参
|
|
|
* @return GetMission 任务单信息
|