Commit 48fa360e0fdf6fb2e1424a9ded89ddc231fcddb2
1 parent
ccf95700
refactor(garden): 移除重复的查询逻辑
- 删除了巡检计划服务中的冗余条件分支 - 删除了维护计划服务中的冗余条件分支 - 简化了计划冲突检查的实现逻辑
Showing
2 changed files
with
22 additions
and
20 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanServiceImpl.java
| @@ -249,17 +249,18 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { | @@ -249,17 +249,18 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { | ||
| 249 | .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | 249 | .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime |
| 250 | 250 | ||
| 251 | count = inspectionPlanMapper.selectCount(sql); | 251 | count = inspectionPlanMapper.selectCount(sql); |
| 252 | - } else { | ||
| 253 | - QueryWrapper<InspectionPlanDO> sql = new QueryWrapper<>(); | ||
| 254 | - sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId()) | ||
| 255 | - .in(InspectionPlanDO::getRoadId, roadIds) | ||
| 256 | - .eq(InspectionPlanDO::getDeleted, 0) | ||
| 257 | - .eq(InspectionPlanDO::getPlanAttr, 2) //临时计划 | ||
| 258 | - .le(InspectionPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime | ||
| 259 | - .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | ||
| 260 | - | ||
| 261 | - count = inspectionPlanMapper.selectCount(sql); | ||
| 262 | } | 252 | } |
| 253 | +// else { | ||
| 254 | +// QueryWrapper<InspectionPlanDO> sql = new QueryWrapper<>(); | ||
| 255 | +// sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId()) | ||
| 256 | +// .in(InspectionPlanDO::getRoadId, roadIds) | ||
| 257 | +// .eq(InspectionPlanDO::getDeleted, 0) | ||
| 258 | +// .eq(InspectionPlanDO::getPlanAttr, 2) //临时计划 | ||
| 259 | +// .le(InspectionPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime | ||
| 260 | +// .ge(InspectionPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | ||
| 261 | +// | ||
| 262 | +// count = inspectionPlanMapper.selectCount(sql); | ||
| 263 | +// } | ||
| 263 | 264 | ||
| 264 | if (count > 0) { | 265 | if (count > 0) { |
| 265 | throw exception(INSPECTION_PLAN_EXISTS); | 266 | throw exception(INSPECTION_PLAN_EXISTS); |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanServiceImpl.java
| @@ -268,17 +268,18 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -268,17 +268,18 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 268 | .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | 268 | .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime |
| 269 | 269 | ||
| 270 | count = maintainPlanMapper.selectCount(sql); | 270 | count = maintainPlanMapper.selectCount(sql); |
| 271 | - } else { | ||
| 272 | - QueryWrapper<MaintainPlanDO> sql = new QueryWrapper<>(); | ||
| 273 | - sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId()) | ||
| 274 | - .in(MaintainPlanDO::getRoadId, roadIds) | ||
| 275 | - .eq(MaintainPlanDO::getDeleted, 0) | ||
| 276 | - .eq(MaintainPlanDO::getPlanAttr, 2) //临时计划 | ||
| 277 | - .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime | ||
| 278 | - .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | ||
| 279 | - | ||
| 280 | - count = maintainPlanMapper.selectCount(sql); | ||
| 281 | } | 271 | } |
| 272 | +// else { | ||
| 273 | +// QueryWrapper<MaintainPlanDO> sql = new QueryWrapper<>(); | ||
| 274 | +// sql.lambda().eq(MaintainPlanDO::getPlanTypeId, req.getPlanTypeId()) | ||
| 275 | +// .in(MaintainPlanDO::getRoadId, roadIds) | ||
| 276 | +// .eq(MaintainPlanDO::getDeleted, 0) | ||
| 277 | +// .eq(MaintainPlanDO::getPlanAttr, 2) //临时计划 | ||
| 278 | +// .le(MaintainPlanDO::getBeginTime, req.getEndTime()) // start_time <= endTime | ||
| 279 | +// .ge(MaintainPlanDO::getEndTime, req.getBeginTime()); // end_time >= startTime | ||
| 280 | +// | ||
| 281 | +// count = maintainPlanMapper.selectCount(sql); | ||
| 282 | +// } | ||
| 282 | 283 | ||
| 283 | if (count > 0) { | 284 | if (count > 0) { |
| 284 | throw exception(INSPECTION_PLAN_EXISTS); | 285 | throw exception(INSPECTION_PLAN_EXISTS); |