瀏覽代碼

巡查自检-巡检地点相关接口开发

jichaobo 2 年之前
父節點
當前提交
32977f91d2

+ 35 - 4
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionSiteController.java

@@ -3,14 +3,12 @@ package com.usky.fire.controller.web;
 
 import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.bean.CommonPage;
+import com.usky.fire.domain.PatrolInspectionArea;
 import com.usky.fire.domain.PatrolInspectionSite;
 import com.usky.fire.service.PatrolInspectionSiteService;
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -59,5 +57,38 @@ public class PatrolInspectionSiteController {
         return ApiResult.success(patrolInspectionSiteService.patrolInspectionSiteList(areaId, siteName, pageNum, pageSize, id));
     }
 
+    /**
+     * 巡查自检-巡检地点-添加地点-保存
+     * @param PatrolInspectionSiteList
+     * @return
+     */
+    @PostMapping("updatePatrolInspectionSiteList")
+    public ApiResult<Void> updatePatrolInspectionSiteList(@RequestBody List<PatrolInspectionSite> PatrolInspectionSiteList) {
+        patrolInspectionSiteService.updatePatrolInspectionSiteList(PatrolInspectionSiteList);
+        return ApiResult.success();
+    }
+
+    /**
+     *  巡查自检-巡检地点-编辑
+     * @param PatrolInspectionSite
+     * @return
+     */
+    @PostMapping("updatePatrolInspectionSite")
+    public ApiResult<Void> updatePatrolInspectionSite(@RequestBody PatrolInspectionSite PatrolInspectionSite) {
+        patrolInspectionSiteService.updatePatrolInspectionSite(PatrolInspectionSite);
+        return ApiResult.success();
+    }
+
+    /**
+     * 巡查自检-巡检地点-删除
+     * @param id 巡检地点ID
+     * @return
+     */
+    @GetMapping("delPatrolInspectionSite")
+    public ApiResult<Void> delPatrolInspectionSite(@RequestParam(value = "id") Integer id) {
+        patrolInspectionSiteService.delPatrolInspectionSite(id);
+        return ApiResult.success();
+    }
+
 }
 

+ 1 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionSite.java

@@ -92,7 +92,7 @@ public class PatrolInspectionSite implements Serializable {
     /**
      * 使能标识(0 不生效,1 生效)
      */
-    private String enable;
+    private Integer enable;
 
     /**
      * 误差范围

+ 6 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionSiteService.java

@@ -20,4 +20,10 @@ public interface PatrolInspectionSiteService extends CrudService<PatrolInspectio
     List<PatrolInspectionAreaVo> areaLeftList();
 
     CommonPage<PatrolInspectionSite> patrolInspectionSiteList(Integer areaId, String siteName, Integer pageNum, Integer pageSize,Integer id);
+
+    void updatePatrolInspectionSiteList(List<PatrolInspectionSite> patrolInspectionSiteList);
+
+    void updatePatrolInspectionSite(PatrolInspectionSite patrolInspectionSite);
+
+    void delPatrolInspectionSite(Integer id);
 }

+ 29 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionSiteServiceImpl.java

@@ -15,6 +15,7 @@ import com.usky.fire.service.vo.DataCountVo;
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -41,7 +42,7 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
                 .eq(PatrolInspectionArea::getEnable, 1);
         List<PatrolInspectionArea> patrolInspectionAreaList = patrolInspectionAreaService.list(queryWrapper);
         LambdaQueryWrapper<PatrolInspectionSite> queryWrapperOne = Wrappers.lambdaQuery();
-        queryWrapperOne.eq(PatrolInspectionSite::getEnable, 1);
+        queryWrapperOne.eq(PatrolInspectionSite::getEnable, 1).eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId());
         List<PatrolInspectionSite> list = this.list(queryWrapperOne);
         Map<Integer, List<PatrolInspectionSite>> grouypByAreaId = list.stream().collect(
                 Collectors.groupingBy(o -> o.getAreaId())
@@ -100,4 +101,31 @@ public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolI
         return new CommonPage<>(list, patrolInspectionSiteList.size(), pageNum, pageSize);
     }
 
+
+    @Override
+    @Transactional
+    public void updatePatrolInspectionSiteList(List<PatrolInspectionSite> patrolInspectionSiteList){
+        for (int i=0;i<patrolInspectionSiteList.size();i++){
+            PatrolInspectionSite patrolInspectionSite = new PatrolInspectionSite();
+            patrolInspectionSite.setId(patrolInspectionSiteList.get(i).getId());
+            patrolInspectionSite.setAreaId(patrolInspectionSiteList.get(i).getAreaId());
+            patrolInspectionSite.setPictureUrl(patrolInspectionSiteList.get(i).getPictureUrl());
+            patrolInspectionSite.setDistanceRange(patrolInspectionSiteList.get(i).getDistanceRange());
+            this.updateById(patrolInspectionSite);
+        }
+    }
+
+    @Override
+    public void updatePatrolInspectionSite(PatrolInspectionSite patrolInspectionSite){
+        this.updateById(patrolInspectionSite);
+    }
+
+    @Override
+    public void delPatrolInspectionSite(Integer id){
+        PatrolInspectionSite patrolInspectionSite = new PatrolInspectionSite();
+        patrolInspectionSite.setId(id);
+        patrolInspectionSite.setEnable(0);
+        this.updateById(patrolInspectionSite);
+    }
+
 }