浏览代码

故障区段信息删除,故障区段确认状态更新

liuaini 1 月之前
父节点
当前提交
719c7bd42c

+ 38 - 4
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/controller/FhzgFaultPowerCutController.java

@@ -16,10 +16,10 @@ import com.hdkj.lt.core.mvc.BaseController;
 import com.hdkj.hussar.ApiResponse;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
 
 /**
  * 故障停电转供
@@ -160,4 +160,38 @@ public class FhzgFaultPowerCutController extends BaseController {
         HasDataTagDTO hasDataTagDTO = faultPowerCutService.getHasDataTag( dto);
         return ApiResponse.success(hasDataTagDTO);
     }
+
+    /**
+     * 更新故障区段确认状态
+     * @param faultId 故障id
+     * @return
+     * @param <T>
+     */
+    @GetMapping("/updateSectionStatus")
+    @ApiOperation(value = "更新故障区段确认状态")
+    public <T> ApiResponse<T> updateSectionStatus(@Valid @NotNull(message = "ID不能为空") Long faultId) {
+        try {
+            faultPowerCutService.updateSectionStatus(faultId);
+        }catch (Exception e) {
+            return ApiResponse.fail("更新失败!");
+        }
+        return ApiResponse.success();
+    }
+    /**
+     * 删除故障区段
+     * @param faultId 故障id
+     * @return
+     * @param <T>
+     */
+    @GetMapping("/deleteSection")
+    @ApiOperation(value = "删除故障区段")
+    public <T> ApiResponse<T> deleteSection(@Valid @NotNull(message = "ID不能为空") Long faultId) {
+        try {
+            faultPowerCutService.deleteSection(faultId);
+        }catch (Exception e) {
+            return ApiResponse.fail("删除失败!");
+        }
+        return ApiResponse.success();
+    }
+
 }

+ 11 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/IFaultPowerCutService.java

@@ -29,5 +29,16 @@ public interface IFaultPowerCutService extends IService<FaultPowerCut> {
     FhzgFaultPowerCutVO getSchemeByFaultId(Long faultId);
 
     List<AllSwitchInfoListDTO> getAllSwitchBySchemeId(Long faultId);
+    /**
+     * 更新故障区段确认状态
+     * @param faultId fhzg_fault_power_cut.id
+     */
+    void updateSectionStatus(Long faultId);
+
+    /**
+     * 删除故障区段
+     * @param faultId fhzg_fault_power_cut.id
+     */
+    void deleteSection(Long faultId);
 
 }

+ 29 - 0
services/load-transfer-bf/src/main/java/com/hdkj/lt/bf/service/impl/FaultPowerCutServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hdkj.lt.base.exception.BusinessException;
@@ -22,10 +23,13 @@ import com.hdkj.lt.core.bizms.modle.dto.FhzgFaultDistMappingFileDTO;
 import com.hdkj.lt.core.bizms.modle.po.fault.*;
 import com.hdkj.lt.modle.dto.jsty.AllSwitchInfoListDTO;
 import com.ruoyi.common.core.utils.StringUtils;
+import io.jsonwebtoken.lang.Assert;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -63,6 +67,8 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
     IFaultTransferSchemeService faultTransferSchemeService;
     @Autowired
     FhzgFaultSwitchInfoListMapper switchInfoListMapper;
+    @Autowired
+    private IFaultPowerCutSwitchService faultPowerCutSwitchService;
 
     @Override
     @UserCountyCodeAuto(sourceFiled = "countyCode",targetFiled = "countyCodeList")
@@ -247,4 +253,27 @@ public class FaultPowerCutServiceImpl extends ServiceImpl<FaultPowerCutMapper, F
         String allSwitchInfoListJson = switchInfoList.getAllSwitchInfoListJson();
         return JSON.parseArray(allSwitchInfoListJson, AllSwitchInfoListDTO.class);
     }
+
+    @Override
+    @Transactional(rollbackFor = BusinessException.class)
+    public void updateSectionStatus(Long faultId) {
+        FaultPowerCut entity = this.getById(faultId);
+        Assert.notNull(entity, "故障区段信息不存在");
+        List<FaultPowerCut> list = this.list(new LambdaQueryWrapper<FaultPowerCut>().eq(FaultPowerCut::getFaultNo, entity.getFaultNo()));
+        list.forEach(e->{
+            Integer sectionStatus = Objects.equals(faultId,e.getId())?1:0;
+            e.setSectionStatus(sectionStatus);
+        });
+        this.updateBatchById(list);
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class})
+    public void deleteSection(Long faultId) {
+        FaultPowerCut entity = this.getById(faultId);
+        Assert.notNull(entity, "故障区段信息不存在");
+        this.removeById(faultId);
+        //删除开关
+        faultPowerCutSwitchService.remove(new LambdaQueryWrapper<FaultPowerCutSwitch>().eq(FaultPowerCutSwitch::getFaultId, faultId));
+    }
 }