浏览代码

巡检区域相关接口查询

jichaobo 2 年之前
父节点
当前提交
533019fc67

+ 76 - 6
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionAreaController.java

@@ -1,15 +1,18 @@
 package com.usky.fire.controller.web;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.bean.CommonPage;
+import com.usky.fire.domain.PatrolInspectionArea;
+import com.usky.fire.service.PatrolInspectionAreaService;
+import com.usky.fire.service.vo.PatrolInspectionAreaVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RestController;
+import java.util.List;
 
 /**
- * <p>
- *  前端控制器
- * </p>
+ * 巡查自检-巡检区域
  *
  * @author JCB
  * @since 2022-07-12
@@ -18,5 +21,72 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/patrolInspectionArea")
 public class PatrolInspectionAreaController {
 
+    @Autowired
+    private PatrolInspectionAreaService patrolInspectionAreaService;
+
+    /**
+     * 巡查自检-巡检区域-新增
+     *
+     * @param patrolInspectionAreaVo
+     * @return
+     */
+    @PostMapping("addPatrolInspectionArea")
+    public ApiResult<Void> addPatrolInspectionArea(@RequestBody PatrolInspectionAreaVo patrolInspectionAreaVo) {
+        patrolInspectionAreaService.addPatrolInspectionArea(patrolInspectionAreaVo);
+        return ApiResult.success();
+    }
+
+    /**
+     * 巡查自检-巡检区域-编辑
+     *
+     * @param patrolInspectionArea
+     * @return
+     */
+    @PostMapping("updatePatrolInspectionArea")
+    public ApiResult<Void> updatePatrolInspectionArea(@RequestBody PatrolInspectionArea patrolInspectionArea) {
+        patrolInspectionAreaService.updatePatrolInspectionArea(patrolInspectionArea);
+        return ApiResult.success();
+    }
+
+    /**
+     * 巡查自检-巡检区域-删除
+     *
+     * @param id 区域ID
+     * @return
+     */
+    @GetMapping("delPatrolInspectionArea")
+    public ApiResult<Void> delPatrolInspectionArea(@RequestParam(value = "id") Integer id) {
+        patrolInspectionAreaService.delPatrolInspectionArea(id);
+        return ApiResult.success();
+    }
+
+    /**
+     * 巡查自检-巡检区域-列表查詢
+     *
+     * @param areaName 区域名称
+     * @param pageNum  当前页
+     * @param pageSize 每页条数
+     * @param id
+     * @return
+     */
+    @GetMapping("patrolInspectionAreaList")
+    public ApiResult<CommonPage<PatrolInspectionArea>> patrolInspectionAreaList(@RequestParam(value = "areaName", required = false) String areaName,
+                                                                                @RequestParam(value = "pageNum", required = false, defaultValue = "0") Integer pageNum,
+                                                                                @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
+                                                                                @RequestParam(value = "id", required = false, defaultValue = "0") Integer id) {
+        return ApiResult.success(patrolInspectionAreaService.patrolInspectionAreaList(id, areaName, pageNum, pageSize));
+    }
+
+    /**
+     * 巡查自检-巡检区域-一级区域下拉框
+     *
+     * @return
+     */
+    @GetMapping("patrolInspectionAreaSelect")
+    public ApiResult<List<PatrolInspectionArea>> patrolInspectionAreaSelect() {
+        return ApiResult.success(patrolInspectionAreaService.patrolInspectionAreaSelect());
+    }
+
+
 }
 

+ 13 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionAreaService.java

@@ -1,7 +1,11 @@
 package com.usky.fire.service;
 
+import com.usky.common.core.bean.CommonPage;
 import com.usky.common.mybatis.core.CrudService;
 import com.usky.fire.domain.PatrolInspectionArea;
+import com.usky.fire.service.vo.PatrolInspectionAreaVo;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,13 @@ import com.usky.fire.domain.PatrolInspectionArea;
  */
 public interface PatrolInspectionAreaService extends CrudService<PatrolInspectionArea> {
 
+    void addPatrolInspectionArea(PatrolInspectionAreaVo patrolInspectionAreaVo);
+
+    void updatePatrolInspectionArea(PatrolInspectionArea patrolInspectionArea);
+
+    void delPatrolInspectionArea(Integer id);
+
+    CommonPage<PatrolInspectionArea> patrolInspectionAreaList(Integer id, String areaName, Integer pageNum, Integer pageSize);
+
+    List<PatrolInspectionArea> patrolInspectionAreaSelect();
 }

+ 118 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionAreaServiceImpl.java

@@ -1,10 +1,21 @@
 package com.usky.fire.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.usky.common.core.bean.CommonPage;
 import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.PatrolInspectionArea;
 import com.usky.fire.mapper.PatrolInspectionAreaMapper;
 import com.usky.fire.service.PatrolInspectionAreaService;
+import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * <p>
@@ -17,4 +28,111 @@ import org.springframework.stereotype.Service;
 @Service
 public class PatrolInspectionAreaServiceImpl extends AbstractCrudService<PatrolInspectionAreaMapper, PatrolInspectionArea> implements PatrolInspectionAreaService {
 
+    /**
+     * 巡查自检-巡检区域-新增
+     *
+     * @param patrolInspectionAreaVo
+     */
+    @Override
+    @Transactional
+    public void addPatrolInspectionArea(PatrolInspectionAreaVo patrolInspectionAreaVo) {
+        PatrolInspectionArea patrolInspectionArea = new PatrolInspectionArea();
+        patrolInspectionArea.setAreaName(patrolInspectionAreaVo.getAreaName());
+        patrolInspectionArea.setAreaFid(0);
+        patrolInspectionArea.setCompanyId(patrolInspectionAreaVo.getCompanyId());
+        patrolInspectionArea.setCreator(SecurityUtils.getUsername());
+        patrolInspectionArea.setCreateTime(LocalDateTime.now());
+        patrolInspectionArea.setEnable(1);
+        patrolInspectionArea.setTenantId(SecurityUtils.getTenantId());
+        this.save(patrolInspectionArea);
+        Integer areaFid = patrolInspectionArea.getId();
+        for (int i = 0; i < patrolInspectionAreaVo.getAreaNameArray().length; i++) {
+            PatrolInspectionArea patrolInspectionAreaZ = new PatrolInspectionArea();
+            patrolInspectionAreaZ.setAreaName(patrolInspectionAreaVo.getAreaNameArray()[i]);
+            patrolInspectionAreaZ.setAreaFid(areaFid);
+            patrolInspectionAreaZ.setCompanyId(patrolInspectionAreaVo.getCompanyId());
+            patrolInspectionAreaZ.setCreator(SecurityUtils.getUsername());
+            patrolInspectionAreaZ.setCreateTime(LocalDateTime.now());
+            patrolInspectionAreaZ.setEnable(1);
+            patrolInspectionAreaZ.setTenantId(SecurityUtils.getTenantId());
+            this.save(patrolInspectionAreaZ);
+        }
+    }
+
+    /**
+     * 巡查自检-巡检区域-编辑
+     *
+     * @param patrolInspectionArea
+     */
+    @Override
+    public void updatePatrolInspectionArea(PatrolInspectionArea patrolInspectionArea) {
+        this.updateById(patrolInspectionArea);
+    }
+
+    /**
+     * 巡查自检-巡检区域-删除
+     *
+     * @param id 区域ID
+     */
+    @Override
+    @Transactional
+    public void delPatrolInspectionArea(Integer id) {
+        LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid,id);
+        List<PatrolInspectionArea> patrolInspectionArealist = this.list(queryWrapper);
+        if (null!=patrolInspectionArealist&&!patrolInspectionArealist.isEmpty()){
+            for (int i=0;i<patrolInspectionArealist.size();i++){
+                PatrolInspectionArea patrolInspectionAreaz = new PatrolInspectionArea();
+                patrolInspectionAreaz.setId(patrolInspectionArealist.get(i).getId());
+                patrolInspectionAreaz.setEnable(0);
+                this.updateById(patrolInspectionAreaz);
+            }
+        }
+        PatrolInspectionArea patrolInspectionArea = new PatrolInspectionArea();
+        patrolInspectionArea.setId(id);
+        patrolInspectionArea.setEnable(0);
+        this.updateById(patrolInspectionArea);
+    }
+
+    /**
+     * 巡查自检-巡检区域-列表查詢
+     * @param id 区域ID
+     * @param areaName 区域名称
+     * @param pageNum 当前页
+     * @param pageSize 每页条数
+     * @return
+     */
+    public CommonPage<PatrolInspectionArea> patrolInspectionAreaList(Integer id, String areaName, Integer pageNum, Integer pageSize) {
+        IPage<PatrolInspectionArea> page = new Page<PatrolInspectionArea>(pageNum, pageSize);
+        LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
+                .eq(PatrolInspectionArea::getEnable, 1);
+        if (id != null && id != 0) {
+            queryWrapper.eq(PatrolInspectionArea::getId, id);
+        }
+        if (!"".equals(areaName) && areaName != null) {
+            queryWrapper.eq(PatrolInspectionArea::getAreaName, areaName);
+        }
+        queryWrapper.orderByDesc(PatrolInspectionArea::getId);
+        Integer total = this.list(queryWrapper).size();
+        page = this.page(page, queryWrapper);
+        this.ToCommonPage(page);
+        return new CommonPage<>(page.getRecords(), total, page.getSize(), page.getCurrent());
+    }
+
+
+    /**
+     * 巡查自检-巡检区域-一级区域下拉框
+     * @return
+     */
+    public List<PatrolInspectionArea> patrolInspectionAreaSelect(){
+        LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
+                .eq(PatrolInspectionArea::getEnable, 1).eq(PatrolInspectionArea::getAreaFid,0)
+                .orderByDesc(PatrolInspectionArea::getId);
+        return this.list(queryWrapper);
+    }
+
+
+
 }

+ 74 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionAreaVo.java

@@ -0,0 +1,74 @@
+package com.usky.fire.service.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionAreaVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检区域ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 区域名称
+     */
+    private String areaName;
+
+    /**
+     * 区域父ID
+     */
+    private Integer areaFid;
+
+    /**
+     * 单位ID
+     */
+    private Integer companyId;
+
+    /**
+     * 租户ID
+     */
+    private Integer tenantId;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 使能标识(0 不生效,1 生效)
+     */
+    private Integer enable;
+
+    /**
+     * 子区域
+     */
+    private String[] areaNameArray;
+
+
+}