2 Commits 8188aada72 ... 5fe2ac1ab8

Autor SHA1 Mensagem Data
  zhouwang 5fe2ac1ab8 配套资源 通过经纬度及半径查询范围内的点位 1 mês atrás
  zhouwang 1b99dabfb1 新增配套资源后台管理模块 可手动添加类型 添加点位 1 mês atrás

+ 16 - 1
pom.xml

@@ -15,6 +15,7 @@
15 15
 
16 16
 
17 17
     <properties>
18
+        <geotools.version>19.2</geotools.version>
18 19
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19 20
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
20 21
         <java.version>1.8</java.version>
@@ -364,6 +365,20 @@
364 365
             <version>1.18.2</version> <!-- 请检查是否有更新的版本 -->
365 366
         </dependency>
366 367
 
368
+
369
+        <!--空间数据-->
370
+        <dependency>
371
+            <groupId>org.geotools</groupId>
372
+            <artifactId>gt-geojson</artifactId>
373
+            <version>${geotools.version}</version>
374
+        </dependency>
375
+        <dependency>
376
+            <groupId>org.geotools</groupId>
377
+            <artifactId>gt-epsg-hsql</artifactId>
378
+            <version>${geotools.version}</version>
379
+        </dependency>
380
+
381
+
367 382
     </dependencies>
368 383
     <build>
369 384
         <plugins>
@@ -429,4 +444,4 @@
429 444
             </plugin>
430 445
         </plugins>
431 446
     </build>
432
-</project>
447
+</project>

+ 69 - 0
src/main/java/com/lqkj/common/utils/GeoUtils.java

@@ -0,0 +1,69 @@
1
+package com.lqkj.common.utils;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.vividsolutions.jts.geom.Coordinate;
6
+import com.vividsolutions.jts.geom.Geometry;
7
+import com.vividsolutions.jts.geom.GeometryFactory;
8
+import com.vividsolutions.jts.geom.Point;
9
+import org.apache.commons.lang.StringUtils;
10
+import org.geotools.geojson.geom.GeometryJSON;
11
+import org.geotools.geometry.jts.JTSFactoryFinder;
12
+
13
+import java.io.StringWriter;
14
+
15
+public class GeoUtils {
16
+    private static GeometryFactory GEOMETRY_FACTORY = JTSFactoryFinder.getGeometryFactory( null );
17
+
18
+    public static Point createPoint(String lngLatString){
19
+        if(StringUtils.isNotEmpty(lngLatString)){
20
+            String[] lngLat = lngLatString.split(",");
21
+            if(lngLat.length == 2){
22
+                Double x = Double.parseDouble(lngLat[0]);
23
+                Double y = Double.parseDouble(lngLat[1]);
24
+                Coordinate coordinate = new Coordinate(x, y);
25
+                return GEOMETRY_FACTORY.createPoint(coordinate);
26
+            }
27
+            return null;
28
+        }
29
+        return null;
30
+    }
31
+
32
+    public static Geometry readFromGeoJsonString(String geoJson){
33
+        try {
34
+            GeometryJSON geometryJSON = new GeometryJSON(10);
35
+            return geometryJSON.read(geoJson);
36
+        } catch (Exception e) {
37
+            e.printStackTrace();
38
+        }
39
+        return null;
40
+    }
41
+
42
+    public static JSONObject readFromGeometry(Geometry geometry){
43
+        JSONObject json = null;
44
+        if (geometry != null)
45
+            try {
46
+                GeometryJSON geometryJSON = new GeometryJSON(30);//精度到小数点后参数位
47
+                StringWriter writer = new StringWriter();
48
+                geometryJSON.write(geometry, writer);
49
+                json = (JSONObject) JSON.parse(writer.toString());
50
+            } catch (Exception e) {
51
+                e.printStackTrace();
52
+            }
53
+        return json;
54
+    }
55
+    public static String  readFromGeometryToString(Geometry geometry) {
56
+        if (geometry != null) {
57
+            try {
58
+                GeometryJSON geometryJSON = new GeometryJSON(30);//精度到小数点后参数位
59
+                StringWriter writer = new StringWriter();
60
+                geometryJSON.write(geometry, writer);
61
+                return writer.toString();
62
+            } catch (Exception e) {
63
+                e.printStackTrace();
64
+                return null;
65
+            }
66
+        }
67
+        return null;
68
+    }
69
+}

+ 126 - 0
src/main/java/com/lqkj/supporting/controller/ResourcesInfoController.java

@@ -0,0 +1,126 @@
1
+package com.lqkj.supporting.controller;
2
+
3
+import java.util.List;
4
+
5
+import org.apache.ibatis.annotations.Param;
6
+import org.springframework.security.access.prepost.PreAuthorize;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.web.bind.annotation.GetMapping;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.PutMapping;
11
+import org.springframework.web.bind.annotation.DeleteMapping;
12
+import org.springframework.web.bind.annotation.PathVariable;
13
+import org.springframework.web.bind.annotation.RequestBody;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.RestController;
16
+import com.lqkj.common.annotation.Log;
17
+import com.lqkj.common.core.controller.BaseController;
18
+import com.lqkj.common.core.model.ResultUtil;
19
+import com.lqkj.common.enums.BusinessType;
20
+import io.swagger.annotations.Api;
21
+import io.swagger.annotations.ApiOperation;
22
+import com.lqkj.supporting.entity.ResourcesInfo;
23
+import com.lqkj.supporting.service.ResourcesInfoService;
24
+import com.lqkj.common.utils.poi.ExcelUtil;
25
+import com.github.pagehelper.PageInfo;
26
+
27
+/**
28
+ * 资源点位对象Controller
29
+ *
30
+ * @author lqkj
31
+ * @date 2025-05-07
32
+ */
33
+@Api(tags = {"资源点位对象"})
34
+@RestController
35
+@RequestMapping("/supporting/info")
36
+public class ResourcesInfoController extends BaseController
37
+{
38
+    @Autowired
39
+    private ResourcesInfoService resourcesInfoService;
40
+
41
+    /**
42
+     * 查询资源点位对象列表
43
+     */
44
+    @ApiOperation("查询资源点位对象列表")
45
+    @PreAuthorize("@ss.hasPermi('supporting:info:list')")
46
+    @GetMapping("/list")
47
+    public ResultUtil list(ResourcesInfo resourcesInfo)
48
+    {
49
+        startPage( resourcesInfo);
50
+        PageInfo<ResourcesInfo> pageInfo = new PageInfo<>(resourcesInfoService.selectResourcesInfoList(resourcesInfo));
51
+        return ResultUtil.success(pageInfo);
52
+    }
53
+
54
+    /**
55
+     * 导出资源点位对象列表
56
+     */
57
+    @ApiOperation("导出资源点位对象列表")
58
+    @PreAuthorize("@ss.hasPermi('supporting:info:export')")
59
+    @Log(title = "资源点位对象", businessType = BusinessType.EXPORT)
60
+    @GetMapping("/export")
61
+    public ResultUtil export(ResourcesInfo resourcesInfo)
62
+    {
63
+        List<ResourcesInfo> list = resourcesInfoService.selectResourcesInfoList(resourcesInfo);
64
+        ExcelUtil<ResourcesInfo> util = new ExcelUtil<ResourcesInfo>(ResourcesInfo.class);
65
+        return util.exportExcel(list, "资源点位对象数据");
66
+    }
67
+
68
+    /**
69
+     * 获取资源点位对象详细信息
70
+     */
71
+    @ApiOperation("获取资源点位对象详细信息")
72
+    @PreAuthorize("@ss.hasPermi('supporting:info:query')")
73
+    @GetMapping(value = "/{infoId}")
74
+    public ResultUtil getInfo(@PathVariable("infoId") Integer infoId)
75
+    {
76
+        return ResultUtil.success(resourcesInfoService.selectResourcesInfoByInfoId(infoId));
77
+    }
78
+
79
+    /**
80
+     * 新增资源点位对象
81
+     */
82
+    @ApiOperation("新增资源点位对象")
83
+    @PreAuthorize("@ss.hasPermi('supporting:info:add')")
84
+    @Log(title = "资源点位对象", businessType = BusinessType.INSERT)
85
+    @PostMapping
86
+    public ResultUtil add(@RequestBody ResourcesInfo resourcesInfo)
87
+    {
88
+        return resultByRows(resourcesInfoService.insertResourcesInfo(resourcesInfo));
89
+    }
90
+
91
+    /**
92
+     * 修改资源点位对象
93
+     */
94
+    @ApiOperation("修改资源点位对象")
95
+    @PreAuthorize("@ss.hasPermi('supporting:info:edit')")
96
+    @Log(title = "资源点位对象", businessType = BusinessType.UPDATE)
97
+    @PutMapping
98
+    public ResultUtil edit(@RequestBody ResourcesInfo resourcesInfo)
99
+    {
100
+        return resultByRows(resourcesInfoService.updateResourcesInfo(resourcesInfo));
101
+    }
102
+
103
+    /**
104
+     * 删除资源点位对象
105
+     */
106
+    @ApiOperation("删除资源点位对象")
107
+    @PreAuthorize("@ss.hasPermi('supporting:info:remove')")
108
+    @Log(title = "资源点位对象", businessType = BusinessType.DELETE)
109
+	@DeleteMapping("/{infoIds}")
110
+    public ResultUtil remove(@PathVariable Integer[] infoIds)
111
+    {
112
+        return resultByRows(resourcesInfoService.deleteResourcesInfoByInfoIds(infoIds));
113
+    }
114
+
115
+    /**
116
+     * 根据geom查询资源点位对象
117
+     * @param location 点位对象
118
+     * @param distance 距离
119
+     * @return 点位集合
120
+     */
121
+    @GetMapping("/listByGeom")
122
+    public List<ResourcesInfo> selectResourcesInfoListByGeom(@Param("location") String location, @Param("distance") int distance ){
123
+        return resourcesInfoService.selectResourcesInfoListByGeom(location,distance);
124
+    }
125
+
126
+}

+ 134 - 0
src/main/java/com/lqkj/supporting/controller/ResourcesTypeController.java

@@ -0,0 +1,134 @@
1
+package com.lqkj.supporting.controller;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+
6
+import org.springframework.security.access.prepost.PreAuthorize;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.web.bind.annotation.GetMapping;
9
+import org.springframework.web.bind.annotation.PostMapping;
10
+import org.springframework.web.bind.annotation.PutMapping;
11
+import org.springframework.web.bind.annotation.DeleteMapping;
12
+import org.springframework.web.bind.annotation.PathVariable;
13
+import org.springframework.web.bind.annotation.RequestBody;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.RestController;
16
+import com.lqkj.common.annotation.Log;
17
+import com.lqkj.common.core.controller.BaseController;
18
+import com.lqkj.common.core.model.ResultUtil;
19
+import com.lqkj.common.enums.BusinessType;
20
+import io.swagger.annotations.Api;
21
+import io.swagger.annotations.ApiOperation;
22
+import com.lqkj.supporting.entity.ResourcesType;
23
+import com.lqkj.supporting.service.ResourcesTypeService;
24
+import com.lqkj.common.utils.poi.ExcelUtil;
25
+import com.github.pagehelper.PageInfo;
26
+
27
+/**
28
+ * 资源类型Controller
29
+ *
30
+ * @author lqkj
31
+ * @date 2025-05-07
32
+ */
33
+@Api(tags = {"资源类型"})
34
+@RestController
35
+@RequestMapping("/supporting/type")
36
+public class ResourcesTypeController extends BaseController
37
+{
38
+    @Autowired
39
+    private ResourcesTypeService resourcesTypeService;
40
+
41
+    /**
42
+     * 查询资源类型列表
43
+     */
44
+    @ApiOperation("查询资源类型列表")
45
+    @PreAuthorize("@ss.hasPermi('supporting:type:list')")
46
+    @GetMapping("/list")
47
+    public ResultUtil list(ResourcesType resourcesType)
48
+    {
49
+        startPage( resourcesType);
50
+        PageInfo<ResourcesType> pageInfo = new PageInfo<>(resourcesTypeService.selectResourcesTypeList(resourcesType));
51
+        return ResultUtil.success(pageInfo);
52
+    }
53
+    @ApiOperation("查询所有资源类型列表")
54
+    @GetMapping("/listAll")
55
+    public ResultUtil list() {
56
+        return ResultUtil.success(resourcesTypeService.selectResourcesTypeList(new ResourcesType()));
57
+    }
58
+
59
+    /**
60
+     * 导出资源类型列表
61
+     */
62
+    @ApiOperation("导出资源类型列表")
63
+    @PreAuthorize("@ss.hasPermi('supporting:type:export')")
64
+    @Log(title = "资源类型", businessType = BusinessType.EXPORT)
65
+    @GetMapping("/export")
66
+    public ResultUtil export(ResourcesType resourcesType)
67
+    {
68
+        List<ResourcesType> list = resourcesTypeService.selectResourcesTypeList(resourcesType);
69
+        ExcelUtil<ResourcesType> util = new ExcelUtil<ResourcesType>(ResourcesType.class);
70
+        return util.exportExcel(list, "资源类型数据");
71
+    }
72
+
73
+    /**
74
+     * 获取资源类型详细信息
75
+     */
76
+    @ApiOperation("获取资源类型详细信息")
77
+    @PreAuthorize("@ss.hasPermi('supporting:type:query')")
78
+    @GetMapping(value = "/{typeId}")
79
+    public ResultUtil getInfo(@PathVariable("typeId") Integer typeId)
80
+    {
81
+        return ResultUtil.success(resourcesTypeService.selectResourcesTypeByTypeId(typeId));
82
+    }
83
+
84
+    /**
85
+     * 新增资源类型
86
+     */
87
+    @ApiOperation("新增资源类型")
88
+    @PreAuthorize("@ss.hasPermi('supporting:type:add')")
89
+    @Log(title = "资源类型", businessType = BusinessType.INSERT)
90
+    @PostMapping
91
+    public ResultUtil add(@RequestBody ResourcesType resourcesType)
92
+    {
93
+        return resultByRows(resourcesTypeService.insertResourcesType(resourcesType));
94
+    }
95
+
96
+    /**
97
+     * 修改资源类型
98
+     */
99
+    @ApiOperation("修改资源类型")
100
+    @PreAuthorize("@ss.hasPermi('supporting:type:edit')")
101
+    @Log(title = "资源类型", businessType = BusinessType.UPDATE)
102
+    @PutMapping
103
+    public ResultUtil edit(@RequestBody ResourcesType resourcesType)
104
+    {
105
+        return resultByRows(resourcesTypeService.updateResourcesType(resourcesType));
106
+    }
107
+
108
+    /**
109
+     * 删除资源类型
110
+     */
111
+    @ApiOperation("删除资源类型")
112
+    @PreAuthorize("@ss.hasPermi('supporting:type:remove')")
113
+    @Log(title = "资源类型", businessType = BusinessType.DELETE)
114
+	@DeleteMapping("/{typeIds}")
115
+    public ResultUtil remove(@PathVariable Integer[] typeIds)
116
+    {
117
+        return resultByRows(resourcesTypeService.deleteResourcesTypeByTypeIds(typeIds));
118
+    }
119
+
120
+
121
+
122
+
123
+    /**
124
+     *  资源类型列表 分组返回每个类型对应的点位数量
125
+     *
126
+     * @return 资源类型集合
127
+     */
128
+    @GetMapping("/listGroupByTypeLabel")
129
+    public Map<String, List<ResourcesType>> selectResourcesTypeListGroupByTypeLabel(){
130
+        return resourcesTypeService.selectResourcesTypeMapByTypeLabel();
131
+    }
132
+
133
+
134
+}

+ 115 - 0
src/main/java/com/lqkj/supporting/entity/ResourcesInfo.java

@@ -0,0 +1,115 @@
1
+package com.lqkj.supporting.entity;
2
+
3
+import com.fasterxml.jackson.annotation.JsonIgnore;
4
+import com.vividsolutions.jts.geom.Geometry;
5
+import org.apache.commons.lang3.builder.ToStringBuilder;
6
+import org.apache.commons.lang3.builder.ToStringStyle;
7
+import com.lqkj.common.annotation.Excel;
8
+import com.lqkj.common.core.model.BaseEntity;
9
+
10
+/**
11
+ * 资源点位对象对象 resources_info
12
+ *
13
+ * @author lqkj
14
+ * @date 2025-05-07
15
+ */
16
+public class ResourcesInfo extends BaseEntity
17
+{
18
+    private static final long serialVersionUID = 1L;
19
+
20
+    /** 信息ID */
21
+    private Integer infoId;
22
+
23
+    /** 类型编号:type_id */
24
+    @Excel(name = "类型编号:type_id")
25
+    private Integer typeId;
26
+
27
+    /** 名字:area_name */
28
+    @Excel(name = "名字:area_name")
29
+    private String infoName;
30
+
31
+    /** 备注:memo */
32
+    @Excel(name = "备注:memo")
33
+    private String memo;
34
+
35
+    /** 坐标: location */
36
+    @Excel(name = "坐标: location")
37
+    private Object location;
38
+
39
+    private String typeName;
40
+
41
+    private int distance;
42
+
43
+    public void setInfoId(Integer infoId)
44
+    {
45
+        this.infoId = infoId;
46
+    }
47
+
48
+    public Integer getInfoId()
49
+    {
50
+        return infoId;
51
+    }
52
+    public void setTypeId(Integer typeId)
53
+    {
54
+        this.typeId = typeId;
55
+    }
56
+
57
+    public Integer getTypeId()
58
+    {
59
+        return typeId;
60
+    }
61
+    public void setInfoName(String infoName)
62
+    {
63
+        this.infoName = infoName;
64
+    }
65
+
66
+    public String getInfoName()
67
+    {
68
+        return infoName;
69
+    }
70
+    public void setMemo(String memo)
71
+    {
72
+        this.memo = memo;
73
+    }
74
+
75
+    public String getMemo()
76
+    {
77
+        return memo;
78
+    }
79
+    public void setLocation(Object location)
80
+    {
81
+        this.location = location;
82
+    }
83
+
84
+    public Object getLocation()
85
+    {
86
+        return location;
87
+    }
88
+
89
+    public String getTypeName() {
90
+        return typeName;
91
+    }
92
+
93
+    public void setTypeName(String typeName) {
94
+        this.typeName = typeName;
95
+    }
96
+
97
+    public int getDistance() {
98
+        return distance;
99
+    }
100
+
101
+    public void setDistance(int distance) {
102
+        this.distance = distance;
103
+    }
104
+
105
+    @Override
106
+    public String toString() {
107
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
108
+            .append("infoId", getInfoId())
109
+            .append("typeId", getTypeId())
110
+            .append("infoName", getInfoName())
111
+            .append("memo", getMemo())
112
+            .append("location", getLocation())
113
+            .toString();
114
+    }
115
+}

+ 118 - 0
src/main/java/com/lqkj/supporting/entity/ResourcesType.java

@@ -0,0 +1,118 @@
1
+package com.lqkj.supporting.entity;
2
+
3
+import org.apache.commons.lang3.builder.ToStringBuilder;
4
+import org.apache.commons.lang3.builder.ToStringStyle;
5
+import com.lqkj.common.annotation.Excel;
6
+import com.lqkj.common.core.model.BaseEntity;
7
+
8
+/**
9
+ * 资源类型对象 resources_type
10
+ *
11
+ * @author lqkj
12
+ * @date 2025-05-07
13
+ */
14
+public class ResourcesType extends BaseEntity
15
+{
16
+    private static final long serialVersionUID = 1L;
17
+
18
+    /** 类型ID */
19
+    private Integer typeId;
20
+
21
+    /** 类型名称 */
22
+    @Excel(name = "类型名称")
23
+    private String typeName;
24
+
25
+    /** 类型分类 */
26
+    @Excel(name = "类型分类")
27
+    private String typeLabel;
28
+
29
+    /** 类型图标 */
30
+    @Excel(name = "类型图标")
31
+    private String icon;
32
+
33
+    /** 排序:order_id */
34
+    @Excel(name = "排序:order_id")
35
+    private Integer orderId;
36
+
37
+    /** 备注 */
38
+    @Excel(name = "备注")
39
+    private String memo;
40
+
41
+
42
+    private int count;
43
+
44
+    public void setTypeId(Integer typeId)
45
+    {
46
+        this.typeId = typeId;
47
+    }
48
+
49
+    public Integer getTypeId()
50
+    {
51
+        return typeId;
52
+    }
53
+    public void setTypeName(String typeName)
54
+    {
55
+        this.typeName = typeName;
56
+    }
57
+
58
+    public String getTypeName()
59
+    {
60
+        return typeName;
61
+    }
62
+    public void setTypeLabel(String typeLabel)
63
+    {
64
+        this.typeLabel = typeLabel;
65
+    }
66
+
67
+    public String getTypeLabel()
68
+    {
69
+        return typeLabel;
70
+    }
71
+    public void setIcon(String icon)
72
+    {
73
+        this.icon = icon;
74
+    }
75
+
76
+    public String getIcon()
77
+    {
78
+        return icon;
79
+    }
80
+    public void setOrderId(Integer orderId)
81
+    {
82
+        this.orderId = orderId;
83
+    }
84
+
85
+    public Integer getOrderId()
86
+    {
87
+        return orderId;
88
+    }
89
+    public void setMemo(String memo)
90
+    {
91
+        this.memo = memo;
92
+    }
93
+
94
+    public String getMemo()
95
+    {
96
+        return memo;
97
+    }
98
+
99
+    public int getCount() {
100
+        return count;
101
+    }
102
+
103
+    public void setCount(int count) {
104
+        this.count = count;
105
+    }
106
+
107
+    @Override
108
+    public String toString() {
109
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
110
+            .append("typeId", getTypeId())
111
+            .append("typeName", getTypeName())
112
+            .append("typeLabel", getTypeLabel())
113
+            .append("icon", getIcon())
114
+            .append("orderId", getOrderId())
115
+            .append("memo", getMemo())
116
+            .toString();
117
+    }
118
+}

+ 76 - 0
src/main/java/com/lqkj/supporting/mapper/ResourcesInfoMapper.java

@@ -0,0 +1,76 @@
1
+package com.lqkj.supporting.mapper;
2
+
3
+import java.util.List;
4
+import org.apache.ibatis.annotations.Mapper;
5
+import com.lqkj.supporting.entity.ResourcesInfo;
6
+import org.apache.ibatis.annotations.Select;
7
+import org.springframework.data.repository.query.Param;
8
+
9
+/**
10
+ * 资源点位对象Mapper接口
11
+ *
12
+ * @author lqkj
13
+ * @date 2025-05-07
14
+ */
15
+@Mapper
16
+public interface ResourcesInfoMapper
17
+{
18
+    /**
19
+     * 查询资源点位对象
20
+     *
21
+     * @param infoId 资源点位对象主键
22
+     * @return 资源点位对象
23
+     */
24
+    public ResourcesInfo selectResourcesInfoByInfoId(Integer infoId);
25
+
26
+    /**
27
+     * 查询资源点位对象列表
28
+     *
29
+     * @param resourcesInfo 资源点位对象
30
+     * @return 资源点位对象集合
31
+     */
32
+    public List<ResourcesInfo> selectResourcesInfoList(ResourcesInfo resourcesInfo);
33
+
34
+    /**
35
+     * 新增资源点位对象
36
+     *
37
+     * @param resourcesInfo 资源点位对象
38
+     * @return 结果
39
+     */
40
+    public int insertResourcesInfo(ResourcesInfo resourcesInfo);
41
+
42
+    /**
43
+     * 修改资源点位对象
44
+     *
45
+     * @param resourcesInfo 资源点位对象
46
+     * @return 结果
47
+     */
48
+    public int updateResourcesInfo(ResourcesInfo resourcesInfo);
49
+
50
+    /**
51
+     * 删除资源点位对象
52
+     *
53
+     * @param infoId 资源点位对象主键
54
+     * @return 结果
55
+     */
56
+    public int deleteResourcesInfoByInfoId(Integer infoId);
57
+
58
+    /**
59
+     * 批量删除资源点位对象
60
+     *
61
+     * @param infoIds 需要删除的数据主键集合
62
+     * @return 结果
63
+     */
64
+    public int deleteResourcesInfoByInfoIds(Integer[] infoIds);
65
+
66
+    /**
67
+     * 根据geom查询资源点位对象
68
+     * @param location 点位对象
69
+     * @param distance 距离
70
+     * @return 点位集合
71
+     */
72
+//    @Select("select info_id,type_id,info_name,location,memo,CAST(st_distancesphere(ST_SetSRID(st_geomfromgeojson(location),4326), st_geomfromgeojson(#{location})) AS NUMERIC(10,2)) distance from resources_info  \n" +
73
+//            "        where st_distancesphere(ST_SetSRID(st_geomfromgeojson(location),4326), st_geomfromgeojson(#{location})) <= :distance \n" +
74
+//            "        order by st_distancesphere(ST_SetSRID(st_geomfromgeojson(location),4326), st_geomfromgeojson(#{location})) limit 5")
75
+    public List<ResourcesInfo> selectResourcesInfoListByGeom(Object location,int distance);
76
+}

+ 81 - 0
src/main/java/com/lqkj/supporting/mapper/ResourcesTypeMapper.java

@@ -0,0 +1,81 @@
1
+package com.lqkj.supporting.mapper;
2
+
3
+import java.util.List;
4
+import org.apache.ibatis.annotations.Mapper;
5
+import com.lqkj.supporting.entity.ResourcesType;
6
+import org.apache.ibatis.annotations.Select;
7
+
8
+/**
9
+ * 资源类型Mapper接口
10
+ *
11
+ * @author lqkj
12
+ * @date 2025-05-07
13
+ */
14
+@Mapper
15
+public interface ResourcesTypeMapper
16
+{
17
+    /**
18
+     * 查询资源类型
19
+     *
20
+     * @param typeId 资源类型主键
21
+     * @return 资源类型
22
+     */
23
+    public ResourcesType selectResourcesTypeByTypeId(Integer typeId);
24
+
25
+    /**
26
+     * 查询资源类型列表
27
+     *
28
+     * @param resourcesType 资源类型
29
+     * @return 资源类型集合
30
+     */
31
+    public List<ResourcesType> selectResourcesTypeList(ResourcesType resourcesType);
32
+
33
+    /**
34
+     * 新增资源类型
35
+     *
36
+     * @param resourcesType 资源类型
37
+     * @return 结果
38
+     */
39
+    public int insertResourcesType(ResourcesType resourcesType);
40
+
41
+    /**
42
+     * 修改资源类型
43
+     *
44
+     * @param resourcesType 资源类型
45
+     * @return 结果
46
+     */
47
+    public int updateResourcesType(ResourcesType resourcesType);
48
+
49
+    /**
50
+     * 删除资源类型
51
+     *
52
+     * @param typeId 资源类型主键
53
+     * @return 结果
54
+     */
55
+    public int deleteResourcesTypeByTypeId(Integer typeId);
56
+
57
+    /**
58
+     * 批量删除资源类型
59
+     *
60
+     * @param typeIds 需要删除的数据主键集合
61
+     * @return 结果
62
+     */
63
+    public int deleteResourcesTypeByTypeIds(Integer[] typeIds);
64
+
65
+
66
+
67
+
68
+    /**
69
+     * 资源类型列表 分组返回每个类型对应的点位数量
70
+     *
71
+     * @return 资源类型集合
72
+     */
73
+    @Select("SELECT ei.type_label, ei.type_id,ei.type_name,ei.icon,COUNT(ri.type_id) \n" +
74
+            "            FROM resources_type ei \n" +
75
+            "            LEFT JOIN resources_info ri ON ei.type_id = ri.type_id \n" +
76
+            "            GROUP BY ei.type_label ,ei.type_id,ei.type_name")
77
+    public List<ResourcesType> selectResourcesTypeListGroupByTypeLabel();
78
+
79
+
80
+
81
+}

+ 152 - 0
src/main/java/com/lqkj/supporting/service/ResourcesInfoService.java

@@ -0,0 +1,152 @@
1
+package com.lqkj.supporting.service;
2
+
3
+import java.util.ArrayList;
4
+import java.util.LinkedHashMap;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+import com.alibaba.fastjson.JSON;
9
+import com.alibaba.fastjson.JSONArray;
10
+import com.alibaba.fastjson.JSONObject;
11
+import com.fasterxml.jackson.databind.ObjectMapper;
12
+import com.lqkj.common.utils.GeoUtils;
13
+import com.lqkj.supporting.entity.ResourcesType;
14
+import com.vividsolutions.jts.geom.Coordinate;
15
+import com.vividsolutions.jts.geom.Geometry;
16
+import com.vividsolutions.jts.geom.GeometryFactory;
17
+import com.vividsolutions.jts.geom.Point;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.stereotype.Service;
20
+import com.lqkj.supporting.mapper.ResourcesInfoMapper;
21
+import com.lqkj.supporting.entity.ResourcesInfo;
22
+import com.lqkj.common.utils.uuid.IdUtils;
23
+import org.springframework.util.CollectionUtils;
24
+
25
+/**
26
+ * 资源点位对象Service业务层处理
27
+ *
28
+ * @author lqkj
29
+ * @date 2025-05-07
30
+ */
31
+@Service
32
+public class ResourcesInfoService {
33
+    @Autowired
34
+    private ResourcesInfoMapper resourcesInfoMapper;
35
+
36
+    @Autowired
37
+    private ResourcesTypeService resourcesTypeService;
38
+
39
+    /**
40
+     * 查询资源点位对象
41
+     *
42
+     * @param infoId 资源点位对象主键
43
+     * @return 资源点位对象
44
+     */
45
+
46
+    public ResourcesInfo selectResourcesInfoByInfoId(Integer infoId) {
47
+        ResourcesInfo resourcesInfo = resourcesInfoMapper.selectResourcesInfoByInfoId(infoId);
48
+        paseGeom(resourcesInfo);
49
+        return resourcesInfo;
50
+    }
51
+
52
+    private void paseGeom(ResourcesInfo resourcesInfo) {
53
+        Object location = resourcesInfo.getLocation();
54
+        System.out.println(location.getClass());
55
+        Map<String, Object> map = (LinkedHashMap<String, Object>) location;
56
+        // 假设该 Map 来自 GeoJSON 格式,可以手动提取坐标并构造 Point
57
+        List coordinates = (ArrayList) map.get("coordinates");
58
+
59
+        resourcesInfo.setLocation(coordinates.get(0).toString()  + "," + coordinates.get(1).toString());
60
+        Integer typeId = resourcesInfo.getTypeId();
61
+        ResourcesType resourcesType = resourcesTypeService.selectResourcesTypeByTypeId(typeId);
62
+        resourcesInfo.setTypeName(resourcesType.getTypeName());
63
+    }
64
+
65
+    /**
66
+     * 查询资源点位对象列表
67
+     *
68
+     * @param resourcesInfo 资源点位对象
69
+     * @return 资源点位对象
70
+     */
71
+    public List<ResourcesInfo> selectResourcesInfoList(ResourcesInfo resourcesInfo) {
72
+        List<ResourcesInfo> resourcesInfos = resourcesInfoMapper.selectResourcesInfoList(resourcesInfo);
73
+        if (!CollectionUtils.isEmpty(resourcesInfos)) {
74
+            resourcesInfos.forEach(resourcesInfo1 -> {
75
+                paseGeom(resourcesInfo1);
76
+            });
77
+        }
78
+        return resourcesInfos;
79
+    }
80
+
81
+    /**
82
+     * 新增资源点位对象
83
+     *
84
+     * @param resourcesInfo 资源点位对象
85
+     * @return 结果
86
+     */
87
+
88
+    public int insertResourcesInfo(ResourcesInfo resourcesInfo) {
89
+
90
+        String location = (String) resourcesInfo.getLocation();
91
+        Point point = GeoUtils.createPoint(location);
92
+        JSONObject jsonObject = GeoUtils.readFromGeometry(point);
93
+        resourcesInfo.setLocation(jsonObject);
94
+        return resourcesInfoMapper.insertResourcesInfo(resourcesInfo);
95
+    }
96
+
97
+    /**
98
+     * 修改资源点位对象
99
+     *
100
+     * @param resourcesInfo 资源点位对象
101
+     * @return 结果
102
+     */
103
+
104
+    public int updateResourcesInfo(ResourcesInfo resourcesInfo) {
105
+//        String location = resourcesInfo.getLocation();
106
+//        Point point = GeoUtils.createPoint(location);
107
+//        JSONObject jsonObject = GeoUtils.readFromGeometry(point);
108
+//        resourcesInfo.setLocation(jsonObject.toJSONString());
109
+        return resourcesInfoMapper.updateResourcesInfo(resourcesInfo);
110
+    }
111
+
112
+    /**
113
+     * 批量删除资源点位对象
114
+     *
115
+     * @param infoIds 需要删除的资源点位对象主键
116
+     * @return 结果
117
+     */
118
+
119
+    public int deleteResourcesInfoByInfoIds(Integer[] infoIds) {
120
+        return resourcesInfoMapper.deleteResourcesInfoByInfoIds(infoIds);
121
+    }
122
+
123
+    /**
124
+     * 删除资源点位对象信息
125
+     *
126
+     * @param infoId 资源点位对象主键
127
+     * @return 结果
128
+     */
129
+
130
+    public int deleteResourcesInfoByInfoId(Integer infoId) {
131
+        return resourcesInfoMapper.deleteResourcesInfoByInfoId(infoId);
132
+    }
133
+
134
+    /**
135
+     * 根据geom查询资源点位对象
136
+     * @param location 点位对象
137
+     * @param distance 距离
138
+     * @return 点位集合
139
+     */
140
+    public List<ResourcesInfo> selectResourcesInfoListByGeom(String location,int distance){
141
+        Point point = GeoUtils.createPoint(location);
142
+        JSONObject jsonObject = GeoUtils.readFromGeometry(point);
143
+        List<ResourcesInfo> resourcesInfos = resourcesInfoMapper.selectResourcesInfoListByGeom(jsonObject, distance);
144
+        if (!CollectionUtils.isEmpty(resourcesInfos)) {
145
+            resourcesInfos.forEach(this::paseGeom);
146
+        }
147
+
148
+        return resourcesInfos;
149
+    }
150
+
151
+
152
+}

+ 116 - 0
src/main/java/com/lqkj/supporting/service/ResourcesTypeService.java

@@ -0,0 +1,116 @@
1
+package com.lqkj.supporting.service;
2
+
3
+import java.util.Collections;
4
+import java.util.List;
5
+import java.util.Map;
6
+import java.util.function.Function;
7
+import java.util.stream.Collectors;
8
+
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.stereotype.Service;
11
+import com.lqkj.supporting.mapper.ResourcesTypeMapper;
12
+import com.lqkj.supporting.entity.ResourcesType;
13
+import com.lqkj.common.utils.uuid.IdUtils;
14
+import org.springframework.util.CollectionUtils;
15
+
16
+/**
17
+ * 资源类型Service业务层处理
18
+ *
19
+ * @author lqkj
20
+ * @date 2025-05-07
21
+ */
22
+@Service
23
+public class ResourcesTypeService
24
+{
25
+    @Autowired
26
+    private ResourcesTypeMapper resourcesTypeMapper;
27
+
28
+    /**
29
+     * 查询资源类型
30
+     *
31
+     * @param typeId 资源类型主键
32
+     * @return 资源类型
33
+     */
34
+
35
+    public ResourcesType selectResourcesTypeByTypeId(Integer typeId)
36
+    {
37
+        return resourcesTypeMapper.selectResourcesTypeByTypeId(typeId);
38
+    }
39
+
40
+    /**
41
+     * 查询资源类型列表
42
+     *
43
+     * @param resourcesType 资源类型
44
+     * @return 资源类型
45
+     */
46
+    public List<ResourcesType> selectResourcesTypeList(ResourcesType resourcesType)
47
+    {
48
+        return resourcesTypeMapper.selectResourcesTypeList(resourcesType);
49
+    }
50
+
51
+    /**
52
+     * 新增资源类型
53
+     *
54
+     * @param resourcesType 资源类型
55
+     * @return 结果
56
+     */
57
+
58
+    public int insertResourcesType(ResourcesType resourcesType)
59
+    {
60
+        return resourcesTypeMapper.insertResourcesType(resourcesType);
61
+    }
62
+
63
+    /**
64
+     * 修改资源类型
65
+     *
66
+     * @param resourcesType 资源类型
67
+     * @return 结果
68
+     */
69
+
70
+    public int updateResourcesType(ResourcesType resourcesType)
71
+    {
72
+        return resourcesTypeMapper.updateResourcesType(resourcesType);
73
+    }
74
+
75
+    /**
76
+     * 批量删除资源类型
77
+     *
78
+     * @param typeIds 需要删除的资源类型主键
79
+     * @return 结果
80
+     */
81
+
82
+    public int deleteResourcesTypeByTypeIds(Integer[] typeIds)
83
+    {
84
+        return resourcesTypeMapper.deleteResourcesTypeByTypeIds(typeIds);
85
+    }
86
+
87
+    /**
88
+     * 删除资源类型信息
89
+     *
90
+     * @param typeId 资源类型主键
91
+     * @return 结果
92
+     */
93
+
94
+    public int deleteResourcesTypeByTypeId(Integer typeId)
95
+    {
96
+        return resourcesTypeMapper.deleteResourcesTypeByTypeId(typeId);
97
+    }
98
+
99
+    /**
100
+     * 资源类型列表 分组返回每个类型对应的点位数量
101
+     *
102
+     * @return 资源类型集合
103
+     */
104
+    public Map<String, List<ResourcesType>> selectResourcesTypeMapByTypeLabel() {
105
+        List<ResourcesType> resourcesTypes = resourcesTypeMapper.selectResourcesTypeListGroupByTypeLabel();
106
+        if (!CollectionUtils.isEmpty(resourcesTypes)) {
107
+            return resourcesTypes.stream()
108
+                    .collect(Collectors.groupingBy(ResourcesType::getTypeLabel));
109
+        }
110
+        return Collections.emptyMap();
111
+    }
112
+
113
+
114
+
115
+
116
+}

+ 171 - 0
src/main/resources/db/migration/V1_17__20250507.sql

@@ -0,0 +1,171 @@
1
+-- 一级菜单 SQL
2
+
3
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
4
+                      status, perms, icon, create_by, create_time, update_by, update_time, remark)
5
+values ('配套资源', '0', '0', 'supporting', null, false, true,'M', true,
6
+        true, '', 'trend-chart', 'admin', now(), '', null,'配套资源主分类');
7
+
8
+
9
+
10
+with temp_menu2 as (
11
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
12
+                      status, perms, icon, create_by, create_time, update_by, update_time, remark)
13
+values ('类型管理', (select menu_id from sys_menu where menu_name = '配套资源' limit 1), '1', 'type', 'supporting/type/index', false, true,'C', true,
14
+        true, 'supporting:type:list', 'operation', 'admin', now(), '', null,'配套资源类型管理') returning menu_id)
15
+
16
+
17
+-- 按钮 SQL
18
+insert
19
+into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms,
20
+               icon, create_by, create_time, update_by, update_time, remark)
21
+values ('类型管理查询', (select * from temp_menu2), '1', '#', '', false, true, 'F', true, true,
22
+    'supporting:type:query', '#', 'admin', now(), '', null, ''),
23
+    ('类型管理新增', (select * from temp_menu2), '2', '#', '', false, true, 'F', true, true,
24
+    'supporting:type:add', '#', 'admin', now(), '', null, ''),
25
+    ('类型管理修改', (select * from temp_menu2), '3', '#', '', false, true, 'F', true, true,
26
+    'supporting:type:edit', '#', 'admin', now(), '', null, ''),
27
+    ('类型管理删除', (select * from temp_menu2), '4', '#', '', false, true, 'F', true, true,
28
+    'supporting:type:remove', '#', 'admin', now(), '', null, ''),
29
+    ('类型管理导出', (select * from temp_menu2), '5', '#', '', false, true, 'F', true, true,
30
+    'supporting:type:export', '#', 'admin', now(), '', null, '');
31
+
32
+-- 菜单 SQL
33
+with temp_menu3 as (
34
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
35
+                      status, perms, icon, create_by, create_time, update_by, update_time, remark)
36
+values ('点位管理', (select menu_id from sys_menu where menu_name = '配套资源' limit 1), '2', 'info', 'supporting/info/index', false, true, 'C',
37
+    true, true, 'supporting:info:list', 'operation', 'admin', now(), '', null,
38
+    '配套资源点位管理') returning menu_id)
39
+-- 按钮 SQL
40
+insert
41
+into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms,
42
+               icon, create_by, create_time, update_by, update_time, remark)
43
+values ('点位管理查询', (select * from temp_menu3), '1', '#', '', false, true, 'F', true, true,
44
+    'supporting:info:query', '#', 'admin', now(), '', null, ''),
45
+    ('点位管理新增', (select * from temp_menu3), '2', '#', '', false, true, 'F', true, true,
46
+    'supporting:info:add', '#', 'admin', now(), '', null, ''),
47
+    ('点位管理修改', (select * from temp_menu3), '3', '#', '', false, true, 'F', true, true,
48
+    'supporting:info:edit', '#', 'admin', now(), '', null, ''),
49
+    ('点位管理删除', (select * from temp_menu3), '4', '#', '', false, true, 'F', true, true,
50
+    'supporting:info:remove', '#', 'admin', now(), '', null, ''),
51
+    ('点位管理导出', (select * from temp_menu3), '5', '#', '', false, true, 'F', true, true,
52
+    'supporting:info:export', '#', 'admin', now(), '', null, '');
53
+
54
+INSERT INTO "public"."sys_dict_type" ("dict_name", "dict_type", "status", "create_by", "create_time", "update_by", "update_time", "remark")
55
+VALUES ('配套资源分类', 'supporting_resources_classify', 't', '超级管理员', now(), NULL, NULL, NULL);
56
+
57
+
58
+INSERT INTO "public"."sys_dict_data" ("dict_sort", "dict_label", "dict_value", "dict_type", "css_class", "list_class", "is_default", "status", "create_by", "create_time", "update_by", "update_time", "remark", "icon", "park_id")
59
+       VALUES (1, '企业服务', '企业服务', 'supporting_resources_classify', NULL, 'default', 'f', 't', '超级管理员', now(), NULL, NULL, NULL, NULL, NULL),
60
+              (2, '便民服务', '便民服务', 'supporting_resources_classify', NULL, 'default', 'f', 't', '超级管理员', now(), NULL, NULL, NULL, NULL, NULL),
61
+              (3, '交通服务', '交通服务', 'supporting_resources_classify', NULL, 'default', 'f', 't', '超级管理员', now(), NULL, NULL, NULL, NULL, NULL);
62
+
63
+
64
+
65
+
66
+create table resources_type (
67
+                           type_id              SERIAL               not null,
68
+                           type_name            VARCHAR(255)         null,
69
+                           type_label           VARCHAR(255)         null,
70
+                           icon                 VARCHAR(255)         null,
71
+                           order_id             INT4                 null,
72
+                           memo                 VARCHAR(255)         null,
73
+                           constraint PK_RESOURCES_TYPE primary key (type_id)
74
+);
75
+
76
+comment on table resources_type is
77
+    '资源类型';
78
+
79
+comment on column resources_type.type_id is
80
+    '类型ID';
81
+
82
+comment on column resources_type.type_name is
83
+    '类型名称';
84
+
85
+comment on column resources_type.type_label is
86
+    '类型分类';
87
+
88
+comment on column resources_type.icon is
89
+    '类型图标';
90
+
91
+comment on column resources_type.order_id is
92
+    '排序:order_id';
93
+
94
+comment on column resources_type.memo is
95
+    '备注';
96
+
97
+
98
+
99
+
100
+create table resources_info (
101
+                           info_id              SERIAL               not null,
102
+                           type_id              INT4                 not null,
103
+                           info_name            VARCHAR(255)         null,
104
+                           memo                 VARCHAR(255)         null,
105
+                           location             jsonb                null,
106
+                           constraint PK_RESOURCES_INFO primary key (info_id)
107
+);
108
+
109
+comment on table resources_info is
110
+    '资源点位对象';
111
+
112
+comment on column resources_info.info_id is
113
+    '信息ID';
114
+
115
+comment on column resources_info.type_id is
116
+    '类型编号:type_id';
117
+
118
+comment on column resources_info.info_name is
119
+    '名字:area_name';
120
+
121
+comment on column resources_info.memo is
122
+    '备注:memo';
123
+
124
+comment on column resources_info.location is
125
+    '坐标: location';
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+

+ 110 - 0
src/main/resources/mapper/supporting/ResourcesInfoMapper.xml

@@ -0,0 +1,110 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+		PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+		"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.lqkj.supporting.mapper.ResourcesInfoMapper">
6
+
7
+	<resultMap type="ResourcesInfo" id="ResourcesInfoResult">
8
+		<result property="infoId"    column="info_id"    />
9
+		<result property="typeId"    column="type_id"    />
10
+		<result property="infoName"    column="info_name"    />
11
+		<result property="memo"    column="memo"    />
12
+		<result property="location"    column="location"   jdbcType="OTHER"
13
+				typeHandler="com.lqkj.framework.sql.JsonbTypeHandler"/>
14
+		<result property="distance" column="distance" />
15
+	</resultMap>
16
+
17
+	<sql id="selectResourcesInfoVo">
18
+		select info_id, type_id, info_name, memo, location from resources_info
19
+	</sql>
20
+
21
+	<select id="selectResourcesInfoList" parameterType="ResourcesInfo" resultMap="ResourcesInfoResult">
22
+		<include refid="selectResourcesInfoVo"/>
23
+		<where>
24
+			<if test="typeId != null "> and type_id = #{typeId}</if>
25
+			<if test="infoName != null  and infoName != ''"> and info_name like concat('%', #{infoName}, '%')</if>
26
+		</where>
27
+		order by info_id
28
+
29
+	</select>
30
+
31
+	<select id="selectResourcesInfoByInfoId" parameterType="Integer" resultMap="ResourcesInfoResult">
32
+		<include refid="selectResourcesInfoVo"/>
33
+		where info_id = #{infoId}
34
+	</select>
35
+
36
+	<insert id="insertResourcesInfo" parameterType="ResourcesInfo" useGeneratedKeys="true" keyProperty="infoId">
37
+		insert into resources_info
38
+		<trim prefix="(" suffix=")" suffixOverrides=",">
39
+			<if test="typeId != null">type_id,</if>
40
+			<if test="infoName != null and infoName != ''">info_name,</if>
41
+			<if test="memo != null and memo != ''">memo,</if>
42
+			<if test="location != null and location != ''">location,</if>
43
+		</trim>
44
+		<trim prefix="values (" suffix=")" suffixOverrides=",">
45
+			<if test="typeId != null">#{typeId},</if>
46
+			<if test="infoName != null and infoName != ''">#{infoName},</if>
47
+			<if test="memo != null and memo != ''">#{memo},</if>
48
+			<if test="location != null and location != ''">#{location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler},</if>
49
+		</trim>
50
+	</insert>
51
+
52
+	<update id="updateResourcesInfo" parameterType="ResourcesInfo">
53
+		update resources_info
54
+		<trim prefix="SET" suffixOverrides=",">
55
+			<if test="typeId != null ">type_id = #{typeId},</if>
56
+			info_name = #{infoName},
57
+			memo = #{memo},
58
+			location = #{location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler},
59
+		</trim>
60
+		where info_id = #{infoId}
61
+	</update>
62
+
63
+	<delete id="deleteResourcesInfoByInfoId" parameterType="Integer">
64
+		delete from resources_info where info_id = #{infoId}
65
+	</delete>
66
+
67
+	<delete id="deleteResourcesInfoByInfoIds" parameterType="String">
68
+		delete from resources_info where info_id in
69
+		<foreach item="infoId" collection="array" open="(" separator="," close=")">
70
+			#{infoId}
71
+		</foreach>
72
+	</delete>
73
+
74
+
75
+<!--	<select id="selectResourcesInfoListByGeom" resultType="ResourcesInfo">-->
76
+
77
+<!--		select info_id,-->
78
+<!--		       type_id,-->
79
+<!--		       info_name,-->
80
+<!--		       location,-->
81
+<!--		       memo,-->
82
+<!--		       CAST(st_distancesphere(ST_SetSRID(st_geomfromgeojson(location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler),4326),-->
83
+<!--		st_geomfromgeojson(#{location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler})) AS NUMERIC(10,2)) distance-->
84
+<!--		from resources_info-->
85
+<!--		where st_distancesphere(ST_SetSRID(st_geomfromgeojson(location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler),4326), st_geomfromgeojson(#{location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler})) <= #{distance}-->
86
+<!--		order by st_distancesphere(ST_SetSRID(st_geomfromgeojson(location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler),4326), st_geomfromgeojson(#{location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler})) limit 5-->
87
+<!--	</select>-->
88
+	<select id="selectResourcesInfoListByGeom" resultMap="ResourcesInfoResult">
89
+		 <![CDATA[
90
+		select
91
+			info_id,
92
+			type_id,
93
+			info_name,
94
+			location,
95
+			memo,
96
+			CAST(st_distancesphere(
97
+					ST_SetSRID(st_geomfromgeojson(location), 4326),
98
+					st_geomfromgeojson(#{location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler})
99
+				 ) AS NUMERIC(10,2)) distance
100
+		from resources_info
101
+		where st_distancesphere(
102
+					  ST_SetSRID(st_geomfromgeojson(location), 4326),
103
+					  st_geomfromgeojson(#{location,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler})
104
+			  ) <= #{distance}
105
+		order by distance
106
+			limit 5
107
+		]]>
108
+	</select>
109
+
110
+</mapper>

+ 75 - 0
src/main/resources/mapper/supporting/ResourcesTypeMapper.xml

@@ -0,0 +1,75 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+		PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+		"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.lqkj.supporting.mapper.ResourcesTypeMapper">
6
+
7
+	<resultMap type="ResourcesType" id="ResourcesTypeResult">
8
+		<result property="typeId"    column="type_id"    />
9
+		<result property="typeName"    column="type_name"    />
10
+		<result property="typeLabel"    column="type_label"    />
11
+		<result property="icon"    column="icon"    />
12
+		<result property="orderId"    column="order_id"    />
13
+		<result property="memo"    column="memo"    />
14
+	</resultMap>
15
+
16
+	<sql id="selectResourcesTypeVo">
17
+		select type_id, type_name, type_label, icon, order_id, memo from resources_type
18
+	</sql>
19
+
20
+	<select id="selectResourcesTypeList" parameterType="ResourcesType" resultMap="ResourcesTypeResult">
21
+		<include refid="selectResourcesTypeVo"/>
22
+		<where>
23
+			<if test="typeName != null  and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
24
+			<if test="typeLabel != null  and typeLabel != ''"> and type_label = #{typeLabel}</if>
25
+		</where>
26
+		order by type_id
27
+
28
+	</select>
29
+
30
+	<select id="selectResourcesTypeByTypeId" parameterType="Integer" resultMap="ResourcesTypeResult">
31
+		<include refid="selectResourcesTypeVo"/>
32
+		where type_id = #{typeId}
33
+	</select>
34
+
35
+	<insert id="insertResourcesType" parameterType="ResourcesType" useGeneratedKeys="true" keyProperty="typeId">
36
+		insert into resources_type
37
+		<trim prefix="(" suffix=")" suffixOverrides=",">
38
+			<if test="typeName != null and typeName != ''">type_name,</if>
39
+			<if test="typeLabel != null and typeLabel != ''">type_label,</if>
40
+			<if test="icon != null and icon != ''">icon,</if>
41
+			<if test="orderId != null">order_id,</if>
42
+			<if test="memo != null and memo != ''">memo,</if>
43
+		</trim>
44
+		<trim prefix="values (" suffix=")" suffixOverrides=",">
45
+			<if test="typeName != null and typeName != ''">#{typeName},</if>
46
+			<if test="typeLabel != null and typeLabel != ''">#{typeLabel},</if>
47
+			<if test="icon != null and icon != ''">#{icon},</if>
48
+			<if test="orderId != null">#{orderId},</if>
49
+			<if test="memo != null and memo != ''">#{memo},</if>
50
+		</trim>
51
+	</insert>
52
+
53
+	<update id="updateResourcesType" parameterType="ResourcesType">
54
+		update resources_type
55
+		<trim prefix="SET" suffixOverrides=",">
56
+			<if test="typeName != null  and typeName != ''">type_name = #{typeName},</if>
57
+			<if test="typeLabel != null  and typeLabel != ''">type_label = #{typeLabel},</if>
58
+			icon = #{icon},
59
+			order_id = #{orderId},
60
+			memo = #{memo},
61
+		</trim>
62
+		where type_id = #{typeId}
63
+	</update>
64
+
65
+	<delete id="deleteResourcesTypeByTypeId" parameterType="Integer">
66
+		delete from resources_type where type_id = #{typeId}
67
+	</delete>
68
+
69
+	<delete id="deleteResourcesTypeByTypeIds" parameterType="String">
70
+		delete from resources_type where type_id in
71
+		<foreach item="typeId" collection="array" open="(" separator="," close=")">
72
+			#{typeId}
73
+		</foreach>
74
+	</delete>
75
+</mapper>