Commit 446bdedb629306acfe47712427fb75b943898f36

Authored by 王富生
1 parent 6b57476e

巡查计划-创建提交

urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/InspectionPlanController.java
1 1 package com.zteits.urbanops.module.garden.controller.admin.inspectionplan;
2 2  
  3 +import jakarta.validation.constraints.NotBlank;
3 4 import org.springframework.web.bind.annotation.*;
4 5 import jakarta.annotation.Resource;
5 6 import org.springframework.validation.annotation.Validated;
... ... @@ -70,6 +71,17 @@ public class InspectionPlanController {
70 71 return success(true);
71 72 }
72 73  
  74 + @DeleteMapping("/delete-batch_no")
  75 + @Parameter(name = "batchNo", description = "批次号", required = true)
  76 + @Operation(summary = "根据batch_no删除巡检计划汇总")
  77 + @PreAuthorize("@ss.hasPermission('garden:inspection-plan:delete')")
  78 + public CommonResult<Boolean> deleteInspectionPlanByBatchNo(@RequestParam("batch_no") @NotBlank String batchNo) {
  79 + inspectionPlanService.deleteInspectionPlanByBatchNo(batchNo);
  80 + return success(true);
  81 + }
  82 +
  83 +
  84 +
73 85 @GetMapping("/get")
74 86 @Operation(summary = "获得巡检计划汇总")
75 87 @Parameter(name = "id", description = "编号", required = true, example = "1024")
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
... ... @@ -57,4 +57,5 @@ public interface ErrorCodeConstants {
57 57 ErrorCode INSPECTION_PLAN_NOT_EXISTS = new ErrorCode(1-200-100-001, "巡检计划汇总不存在");
58 58 ErrorCode INSPECTION_CYCLE_ID_ERROR = new ErrorCode(1-200-100-002, "周期id错误");
59 59 ErrorCode INSPECTION_CYCLE_ERROR = new ErrorCode(1-200-100-003, "获取两个时间之间间隔天数错误");
  60 + ErrorCode INSPECTION_PLAN_EXISTS = new ErrorCode(1-200-100-004, "道路对应类型已存在记录");
60 61 }
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanService.java
... ... @@ -64,6 +64,6 @@ public interface InspectionPlanService {
64 64 * 根据批次号删除
65 65 * @param batchNo 批次号
66 66 */
67   - void deleteInspectionPlanBy(String batchNo);
  67 + void deleteInspectionPlanByBatchNo(String batchNo);
68 68  
69 69 }
70 70 \ No newline at end of file
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanServiceImpl.java
... ... @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.garden.service.inspectionplan;
2 2  
3 3 import cn.hutool.core.date.DateUtil;
4 4 import cn.hutool.core.util.RandomUtil;
  5 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 6 import com.zteits.urbanops.framework.common.pojo.CommonResult;
6 7 import com.zteits.urbanops.framework.common.util.collection.CollectionUtils;
7 8 import com.zteits.urbanops.framework.dict.core.DictFrameworkUtils;
... ... @@ -24,6 +25,7 @@ import java.time.LocalDateTime;
24 25 import java.time.format.DateTimeFormatter;
25 26 import java.util.*;
26 27 import java.util.concurrent.atomic.AtomicInteger;
  28 +import java.util.stream.Collectors;
27 29  
28 30 import com.zteits.urbanops.module.garden.controller.admin.inspectionplan.vo.*;
29 31 import com.zteits.urbanops.module.garden.dal.dataobject.inspectionplan.InspectionPlanDO;
... ... @@ -57,6 +59,8 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
57 59 @Transactional(rollbackFor = Exception.class)
58 60 @Override
59 61 public CommonResult<Long> createInspectionPlan(InspectionPlanSaveReqVO createReqVO) {
  62 + //存在性校验
  63 + validateInspectionPlanExists(createReqVO);
60 64 LocalDateTime now = LocalDateTime.now();
61 65 String userName = SecurityFrameworkUtils.getLoginUserNickname() + "(" + SecurityFrameworkUtils.getLoginUserId() + ")";
62 66 Integer rateValue;
... ... @@ -165,12 +169,26 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
165 169 }
166 170  
167 171  
  172 + private void validateInspectionPlanExists(InspectionPlanSaveReqVO req) {
  173 + Set<Long> roadIds = req.getRoadListReqVO().stream().map(InspectionPlanRoadReqVO::getRoadId).collect(Collectors.toSet());
  174 + QueryWrapper<InspectionPlanDO> sql = new QueryWrapper();
  175 + sql.lambda().eq(InspectionPlanDO::getPlanTypeId, req.getPlanTypeId())
  176 + .in(InspectionPlanDO::getRoadId, roadIds)
  177 + .between(InspectionPlanDO::getBeginTime, req.getBeginTime(), req.getEndTime());
  178 +
  179 + Long count = inspectionPlanMapper.selectCount(sql);
  180 + if (count > 0) {
  181 + throw exception(INSPECTION_PLAN_EXISTS);
  182 + }
  183 + }
  184 +
168 185 private void validateInspectionPlanExists(Long id) {
169 186 if (inspectionPlanMapper.selectById(id) == null) {
170 187 throw exception(INSPECTION_PLAN_NOT_EXISTS);
171 188 }
172 189 }
173 190  
  191 +
174 192 @Override
175 193 public InspectionPlanDO getInspectionPlan(Long id) {
176 194 return inspectionPlanMapper.selectById(id);
... ... @@ -182,8 +200,10 @@ public class InspectionPlanServiceImpl implements InspectionPlanService {
182 200 }
183 201  
184 202 @Override
185   - public void deleteInspectionPlanBy(String batchNo) {
186   - //TODO
  203 + public void deleteInspectionPlanByBatchNo(String batchNo) {
  204 + inspectionPlanMapper.delete(InspectionPlanDO::getBatchNo, batchNo);
  205 + inspectionPlanDetailMapper.delete(InspectionPlanDetailDO::getBatchNo, batchNo);
  206 + inspectionPlanRoleMapper.delete(InspectionPlanRoleDO::getBatchNo, batchNo);
187 207 }
188 208  
189 209 }
190 210 \ No newline at end of file
... ...