Pārlūkot izejas kodu

巡检地址相关接口开发

jichaobo 2 gadi atpakaļ
vecāks
revīzija
09bcc147b0

+ 4 - 4
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/MybatisGeneratorUtils.java

@@ -65,13 +65,13 @@ public class MybatisGeneratorUtils {
         StrategyConfig strategy = new StrategyConfig();
         strategy.setNaming(NamingStrategy.underline_to_camel);
         strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-        strategy.setSuperMapperClass("com.usky.common.mvc.base.CrudMapper");
-        strategy.setSuperServiceClass("com.usky.common.mvc.base.CrudService");
-        strategy.setSuperServiceImplClass("com.usky.common.mvc.base.AbstractCrudService");
+        strategy.setSuperMapperClass("com.usky.common.mybatis.core.CrudMapper");
+        strategy.setSuperServiceClass("com.usky.common.mybatis.core.CrudService");
+        strategy.setSuperServiceImplClass("com.usky.common.mybatis.core.AbstractCrudService");
         // strategy.setTablePrefix("t_"); // 表名前缀
         strategy.setEntityLombokModel(true); //使用lombok
         //修改自己想要生成的表
-        strategy.setInclude("patrol_inspection_area");  // 逆向工程使用的表   如果要生成多个,这里可以传入String[]
+        strategy.setInclude("patrol_inspection_site");  // 逆向工程使用的表   如果要生成多个,这里可以传入String[]
         mpg.setStrategy(strategy);
 
         // 关闭默认 xml 生成,调整生成 至 根目录

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

@@ -20,7 +20,7 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/patrolInspectionArea")
-public class PatrolInspectionAreaController extends BaseController {
+public class PatrolInspectionAreaController {
 
     @Autowired
     private PatrolInspectionAreaService patrolInspectionAreaService;
@@ -71,7 +71,7 @@ public class PatrolInspectionAreaController extends BaseController {
      * @return
      */
     @GetMapping("patrolInspectionAreaList")
-    public ApiResult< List<PatrolInspectionArea>> patrolInspectionAreaList(@RequestParam(value = "areaName", required = false) String areaName,
+    public ApiResult<List<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) {

+ 63 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionSiteController.java

@@ -0,0 +1,63 @@
+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.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 java.util.List;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-13
+ */
+@RestController
+@RequestMapping("/patrolInspectionSite")
+public class PatrolInspectionSiteController {
+
+    @Autowired
+    private PatrolInspectionSiteService patrolInspectionSiteService;
+
+
+    /**
+     * 巡查自检-巡检地点-左侧树形区域
+     *
+     * @return
+     */
+    @GetMapping("areaLeftList")
+    public ApiResult<List<PatrolInspectionAreaVo>> areaLeftList() {
+        return ApiResult.success(patrolInspectionSiteService.areaLeftList());
+    }
+
+
+    /**
+     * 巡查自检-巡检地点-巡检列表
+     * @param areaId 区域id
+     * @param siteName 地点名称
+     * @param pageNum 当前页
+     * @param pageSize 每页条数
+     * @param id 巡检地点ID
+     * @return
+     */
+    @GetMapping("patrolInspectionSiteList")
+    public ApiResult<CommonPage<PatrolInspectionSite>> patrolInspectionSiteList(@RequestParam(value = "areaId", required = false) Integer areaId,
+                                                                                @RequestParam(value = "siteName", required = false) String siteName,
+                                                                                @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(patrolInspectionSiteService.patrolInspectionSiteList(areaId, siteName, pageNum, pageSize, id));
+    }
+
+}
+

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

@@ -0,0 +1,114 @@
+package com.usky.fire.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionSite implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检地点信息表主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 地点名称
+     */
+    private String siteName;
+
+    /**
+     * 地点号码
+     */
+    private String siteNubmber;
+
+    /**
+     * 地点描述
+     */
+    private String siteDescribe;
+
+    /**
+     * 地点类型
+     */
+    private Integer siteType;
+
+    /**
+     * 采集人员
+     */
+    private String collector;
+
+    /**
+     * 采集时间
+     */
+    private LocalDateTime collectTime;
+
+    /**
+     * 经度
+     */
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    private String latitude;
+
+    /**
+     * 区域id
+     */
+    private Integer areaId;
+
+    /**
+     * 图片地址
+     */
+    private String pictureUrl;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 使能标识(0 不生效,1 生效)
+     */
+    private String enable;
+
+    /**
+     * 误差范围
+     */
+    private Double distanceRange;
+
+    /**
+     * 租户ID
+     */
+    private Integer tenantId;
+
+    /**
+     * 单位ID
+     */
+    private Integer companyId;
+
+
+
+}

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionSiteMapper.java

@@ -0,0 +1,16 @@
+package com.usky.fire.mapper;
+
+import com.usky.common.mybatis.core.CrudMapper;
+import com.usky.fire.domain.PatrolInspectionSite;
+
+/**
+ * <p>
+ * Mapper 接口
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-13
+ */
+public interface PatrolInspectionSiteMapper extends CrudMapper<PatrolInspectionSite> {
+
+}

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

@@ -0,0 +1,23 @@
+package com.usky.fire.service;
+
+import com.usky.common.core.bean.CommonPage;
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.fire.domain.PatrolInspectionSite;
+import com.usky.fire.service.vo.PatrolInspectionAreaVo;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-13
+ */
+public interface PatrolInspectionSiteService extends CrudService<PatrolInspectionSite> {
+
+    List<PatrolInspectionAreaVo> areaLeftList();
+
+    CommonPage<PatrolInspectionSite> patrolInspectionSiteList(Integer areaId, String siteName, Integer pageNum, Integer pageSize,Integer id);
+}

+ 103 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionSiteServiceImpl.java

@@ -0,0 +1,103 @@
+package com.usky.fire.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+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.domain.PatrolInspectionSite;
+import com.usky.fire.mapper.PatrolInspectionSiteMapper;
+import com.usky.fire.service.PatrolInspectionAreaService;
+import com.usky.fire.service.PatrolInspectionSiteService;
+import com.usky.fire.service.util.OnlineMethod;
+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 java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-13
+ */
+@Service
+public class PatrolInspectionSiteServiceImpl extends AbstractCrudService<PatrolInspectionSiteMapper, PatrolInspectionSite> implements PatrolInspectionSiteService {
+
+    @Autowired
+    private PatrolInspectionAreaService patrolInspectionAreaService;
+
+    public List<PatrolInspectionAreaVo> areaLeftList() {
+        LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionArea::getTenantId, SecurityUtils.getTenantId())
+                .eq(PatrolInspectionArea::getEnable, 1);
+        List<PatrolInspectionArea> patrolInspectionAreaList = patrolInspectionAreaService.list(queryWrapper);
+        LambdaQueryWrapper<PatrolInspectionSite> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.eq(PatrolInspectionSite::getEnable, 1);
+        List<PatrolInspectionSite> list = this.list(queryWrapperOne);
+        Map<Integer, List<PatrolInspectionSite>> grouypByAreaId = list.stream().collect(
+                Collectors.groupingBy(o -> o.getAreaId())
+        );
+        List<DataCountVo> dataCountVoList = new ArrayList<>();
+        grouypByAreaId.forEach((k, v) -> {
+            DataCountVo dataCountVo = new DataCountVo();
+            dataCountVo.setListCount(v.size());
+            dataCountVo.setId(k);
+            dataCountVoList.add(dataCountVo);
+        });
+        List<PatrolInspectionAreaVo> patrolInspectionAreaVoList = new ArrayList<>();
+        if (patrolInspectionAreaList.size() > 0) {
+            for (int i = 0; i < patrolInspectionAreaList.size(); i++) {
+                PatrolInspectionAreaVo patrolInspectionAreaVo = new PatrolInspectionAreaVo();
+                patrolInspectionAreaVo.setId(patrolInspectionAreaList.get(i).getId());
+                patrolInspectionAreaVo.setAreaName(patrolInspectionAreaList.get(i).getAreaName());
+                patrolInspectionAreaVo.setAreaFid(patrolInspectionAreaList.get(i).getAreaFid());
+                patrolInspectionAreaVo.setCompanyId(patrolInspectionAreaList.get(i).getCompanyId());
+                patrolInspectionAreaVo.setTenantId(patrolInspectionAreaList.get(i).getTenantId());
+                patrolInspectionAreaVo.setCreator(patrolInspectionAreaList.get(i).getCreator());
+                patrolInspectionAreaVo.setCreateTime(patrolInspectionAreaList.get(i).getCreateTime());
+                patrolInspectionAreaVo.setEnable(patrolInspectionAreaList.get(i).getEnable());
+                patrolInspectionAreaVo.setSiteCount(0);
+                for (int j = 0; j < dataCountVoList.size(); j++) {
+                    if (patrolInspectionAreaList.get(i).getId() == dataCountVoList.get(j).getId()) {
+                        patrolInspectionAreaVo.setSiteCount(dataCountVoList.get(j).getListCount());
+                    }
+                }
+                patrolInspectionAreaVoList.add(patrolInspectionAreaVo);
+            }
+        }
+        List<PatrolInspectionAreaVo> patrolInspectionAreaVoListOne = new ArrayList<>();
+        if (patrolInspectionAreaVoList.size() > 0) {
+            patrolInspectionAreaVoListOne = OnlineMethod.getChildPerms(patrolInspectionAreaVoList, 0);
+        }
+        return patrolInspectionAreaVoListOne;
+    }
+
+
+    public CommonPage<PatrolInspectionSite> patrolInspectionSiteList(Integer areaId, String siteName, Integer pageNum, Integer pageSize,Integer id) {
+        LambdaQueryWrapper<PatrolInspectionSite> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionSite::getTenantId, SecurityUtils.getTenantId())
+                .eq(PatrolInspectionSite::getEnable, 1);
+        if (areaId != null) {
+            queryWrapper.eq(PatrolInspectionSite::getAreaId, areaId);
+        }
+        if (id != null&&id !=0) {
+            queryWrapper.eq(PatrolInspectionSite::getId, id);
+        }
+        if (siteName != null && !"".equals(siteName)) {
+            queryWrapper.like(PatrolInspectionSite::getSiteName, siteName);
+        }
+        List<PatrolInspectionSite> patrolInspectionSiteList = this.list(queryWrapper);
+        List<PatrolInspectionSite> list = patrolInspectionSiteList.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
+        return new CommonPage<>(list, patrolInspectionSiteList.size(), pageNum, pageSize);
+    }
+
+}

+ 18 - 28
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/util/OnlineMethod.java

@@ -1,6 +1,6 @@
 package com.usky.fire.service.util;
 
-import com.usky.fire.domain.PatrolInspectionArea;
+import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -11,19 +11,16 @@ public class OnlineMethod {
     /**
      * 根据父节点的ID获取所有子节点
      *
-     * @param list 分类表
+     * @param list     分类表
      * @param parentId 传入的父节点ID
      * @return String
      */
-    public List<PatrolInspectionArea> getChildPerms(List<PatrolInspectionArea> list, int parentId)
-    {
-        List<PatrolInspectionArea> returnList = new ArrayList<PatrolInspectionArea>();
-        for (Iterator<PatrolInspectionArea> iterator = list.iterator(); iterator.hasNext();)
-        {
-            PatrolInspectionArea t = (PatrolInspectionArea) iterator.next();
+    public static List<PatrolInspectionAreaVo> getChildPerms(List<PatrolInspectionAreaVo> list, int parentId) {
+        List<PatrolInspectionAreaVo> returnList = new ArrayList<PatrolInspectionAreaVo>();
+        for (Iterator<PatrolInspectionAreaVo> iterator = list.iterator(); iterator.hasNext(); ) {
+            PatrolInspectionAreaVo t = (PatrolInspectionAreaVo) iterator.next();
             // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
-            if (t.getAreaFid() == parentId)
-            {
+            if (t.getAreaFid() == parentId) {
                 recursionFn(list, t);
                 returnList.add(t);
             }
@@ -37,15 +34,12 @@ public class OnlineMethod {
      * @param list
      * @param t
      */
-    private void recursionFn(List<PatrolInspectionArea> list, PatrolInspectionArea t)
-    {
+    private static void recursionFn(List<PatrolInspectionAreaVo> list, PatrolInspectionAreaVo t) {
         // 得到子节点列表
-        List<PatrolInspectionArea> childList = getChildList(list, t);
+        List<PatrolInspectionAreaVo> childList = getChildList(list, t);
         t.setChildren(childList);
-        for (PatrolInspectionArea tChild : childList)
-        {
-            if (hasChild(list, tChild))
-            {
+        for (PatrolInspectionAreaVo tChild : childList) {
+            if (hasChild(list, tChild)) {
                 recursionFn(list, tChild);
             }
         }
@@ -55,15 +49,12 @@ public class OnlineMethod {
     /**
      * 得到子节点列表
      */
-    private List<PatrolInspectionArea> getChildList(List<PatrolInspectionArea> list, PatrolInspectionArea t)
-    {
-        List<PatrolInspectionArea> tlist = new ArrayList<PatrolInspectionArea>();
-        Iterator<PatrolInspectionArea> it = list.iterator();
-        while (it.hasNext())
-        {
-            PatrolInspectionArea n = (PatrolInspectionArea) it.next();
-            if (n.getAreaFid().longValue() == t.getId().longValue())
-            {
+    private static List<PatrolInspectionAreaVo> getChildList(List<PatrolInspectionAreaVo> list, PatrolInspectionAreaVo t) {
+        List<PatrolInspectionAreaVo> tlist = new ArrayList<PatrolInspectionAreaVo>();
+        Iterator<PatrolInspectionAreaVo> it = list.iterator();
+        while (it.hasNext()) {
+            PatrolInspectionAreaVo n = (PatrolInspectionAreaVo) it.next();
+            if (n.getAreaFid().longValue() == t.getId().longValue()) {
                 tlist.add(n);
             }
         }
@@ -74,8 +65,7 @@ public class OnlineMethod {
     /**
      * 判断是否有子节点
      */
-    private boolean hasChild(List<PatrolInspectionArea> list, PatrolInspectionArea t)
-    {
+    private static boolean hasChild(List<PatrolInspectionAreaVo> list, PatrolInspectionAreaVo t) {
         return getChildList(list, t).size() > 0 ? true : false;
     }
 

+ 32 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/DataCountVo.java

@@ -0,0 +1,32 @@
+package com.usky.fire.service.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class DataCountVo implements Serializable {
+
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     * 数量
+     */
+    private Integer listCount;
+
+}

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

@@ -1,13 +1,17 @@
 package com.usky.fire.service.vo;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.usky.fire.domain.PatrolInspectionArea;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -70,5 +74,13 @@ public class PatrolInspectionAreaVo implements Serializable {
      */
     private String[] areaNameArray;
 
+    /**
+     * 地址数量
+     */
+    private Integer siteCount;
+
 
+    /** 子菜单 */
+    @TableField(exist = false)
+    private List<PatrolInspectionAreaVo> children = new ArrayList<PatrolInspectionAreaVo>();
 }

+ 26 - 0
service-fire/service-fire-biz/src/main/resources/mapper.fire/PatrolInspectionSiteMapper.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.usky.fire.mapper.PatrolInspectionSiteMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.usky.fire.domain.PatrolInspectionSite">
+        <id column="id" property="id" />
+        <result column="site_name" property="siteName" />
+        <result column="site_nubmber" property="siteNubmber" />
+        <result column="site_describe" property="siteDescribe" />
+        <result column="site_type" property="siteType" />
+        <result column="collector" property="collector" />
+        <result column="collect_time" property="collectTime" />
+        <result column="longitude" property="longitude" />
+        <result column="latitude" property="latitude" />
+        <result column="area_id" property="areaId" />
+        <result column="picture_url" property="pictureUrl" />
+        <result column="create_time" property="createTime" />
+        <result column="creator" property="creator" />
+        <result column="enable" property="enable" />
+        <result column="distance_range" property="distanceRange" />
+        <result column="tenant_id" property="tenantId" />
+        <result column="company_id" property="companyId" />
+    </resultMap>
+
+</mapper>