Pārlūkot izejas kodu

周边数据修改

weiximei 5 gadus atpakaļ
vecāks
revīzija
bb2786f307

+ 143
- 0
src/main/java/com/huiju/estateagents/controller/TaBuildingMapRelationController.java Parādīt failu

@@ -0,0 +1,143 @@
1
+package com.huiju.estateagents.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.huiju.estateagents.base.BaseController;
7
+import com.huiju.estateagents.base.ResponseBean;
8
+import com.huiju.estateagents.entity.TaBuildingMapRelation;
9
+import com.huiju.estateagents.service.ITaBuildingMapRelationService;
10
+import org.slf4j.Logger;
11
+import org.slf4j.LoggerFactory;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.*;
14
+
15
+/**
16
+ * <p>
17
+    *  前端控制器
18
+    * </p>
19
+ *
20
+ * @author jobob
21
+ * @since 2019-11-13
22
+ */
23
+@RestController
24
+@RequestMapping("/")
25
+public class TaBuildingMapRelationController extends BaseController {
26
+
27
+    private final Logger logger = LoggerFactory.getLogger(TaBuildingMapRelationController.class);
28
+
29
+    @Autowired
30
+    public ITaBuildingMapRelationService iTaBuildingMapRelationService;
31
+
32
+
33
+    /**
34
+     * 分页查询列表
35
+     * @param pageNum
36
+     * @param pageSize
37
+     * @return
38
+     */
39
+    @RequestMapping(value="/buildingMapRelation",method= RequestMethod.GET)
40
+    public ResponseBean buildingMapRelationList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
41
+                                                @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
42
+        ResponseBean responseBean = new ResponseBean();
43
+        try {
44
+            //使用分页插件
45
+		    IPage<TaBuildingMapRelation> pg = new Page<>(pageNum, pageSize);
46
+            QueryWrapper<TaBuildingMapRelation> queryWrapper = new QueryWrapper<>();
47
+            queryWrapper.orderByDesc("create_date");
48
+
49
+            IPage<TaBuildingMapRelation> result = iTaBuildingMapRelationService.page(pg, queryWrapper);
50
+            responseBean.addSuccess(result);
51
+        }catch (Exception e){
52
+            e.printStackTrace();
53
+            logger.error("buildingMapRelationList -=- {}",e.toString());
54
+            responseBean.addError(e.getMessage());
55
+        }
56
+        return responseBean;
57
+    }
58
+
59
+    /**
60
+     * 保存对象
61
+     * @param taBuildingMapRelation 实体对象
62
+     * @return
63
+     */
64
+    @RequestMapping(value="/buildingMapRelation",method= RequestMethod.POST)
65
+    public ResponseBean buildingMapRelationAdd(@RequestBody TaBuildingMapRelation taBuildingMapRelation){
66
+        ResponseBean responseBean = new ResponseBean();
67
+        try {
68
+            if (iTaBuildingMapRelationService.save(taBuildingMapRelation)){
69
+                responseBean.addSuccess(taBuildingMapRelation);
70
+            }else {
71
+                responseBean.addError("fail");
72
+            }
73
+        }catch (Exception e){
74
+            e.printStackTrace();
75
+            logger.error("buildingMapRelationAdd -=- {}",e.toString());
76
+            responseBean.addError(e.getMessage());
77
+        }
78
+        return responseBean;
79
+    }
80
+
81
+    /**
82
+     * 根据id删除对象
83
+     * @param id  实体ID
84
+     */
85
+    @ResponseBody
86
+    @RequestMapping(value="/buildingMapRelation/{id}", method= RequestMethod.DELETE)
87
+    public ResponseBean buildingMapRelationDelete(@PathVariable Integer id){
88
+        ResponseBean responseBean = new ResponseBean();
89
+        try {
90
+            if(iTaBuildingMapRelationService.removeById(id)){
91
+                responseBean.addSuccess("success");
92
+            }else {
93
+                responseBean.addError("fail");
94
+            }
95
+        }catch (Exception e){
96
+            e.printStackTrace();
97
+            logger.error("buildingMapRelationDelete -=- {}",e.toString());
98
+            responseBean.addError(e.getMessage());
99
+        }
100
+        return responseBean;
101
+    }
102
+
103
+    /**
104
+     * 修改对象
105
+     * @param id  实体ID
106
+     * @param taBuildingMapRelation 实体对象
107
+     * @return
108
+     */
109
+    @RequestMapping(value="/buildingMapRelation/{id}",method= RequestMethod.PUT)
110
+    public ResponseBean buildingMapRelationUpdate(@PathVariable Integer id,
111
+                                        @RequestBody TaBuildingMapRelation taBuildingMapRelation){
112
+        ResponseBean responseBean = new ResponseBean();
113
+        try {
114
+            if (iTaBuildingMapRelationService.updateById(taBuildingMapRelation)){
115
+                responseBean.addSuccess(taBuildingMapRelation);
116
+            }else {
117
+                responseBean.addError("fail");
118
+            }
119
+        }catch (Exception e){
120
+            e.printStackTrace();
121
+            logger.error("buildingMapRelationUpdate -=- {}",e.toString());
122
+            responseBean.addError(e.getMessage());
123
+        }
124
+        return responseBean;
125
+    }
126
+
127
+    /**
128
+     * 根据id查询对象
129
+     * @param id  实体ID
130
+     */
131
+    @RequestMapping(value="/buildingMapRelation/{id}",method= RequestMethod.GET)
132
+    public ResponseBean buildingMapRelationGet(@PathVariable Integer id){
133
+        ResponseBean responseBean = new ResponseBean();
134
+        try {
135
+            responseBean.addSuccess(iTaBuildingMapRelationService.getById(id));
136
+        }catch (Exception e){
137
+            e.printStackTrace();
138
+            logger.error("buildingMapRelationDelete -=- {}",e.toString());
139
+            responseBean.addError(e.getMessage());
140
+        }
141
+        return responseBean;
142
+    }
143
+}

+ 1
- 0
src/main/java/com/huiju/estateagents/entity/TaBuilding.java Parādīt failu

@@ -201,6 +201,7 @@ public class TaBuilding implements Serializable {
201 201
     /**
202 202
      * 地图数据
203 203
      */
204
+    @TableField(exist = false)
204 205
     private String mapJson;
205 206
 
206 207
     /**

+ 51
- 0
src/main/java/com/huiju/estateagents/entity/TaBuildingMapRelation.java Parādīt failu

@@ -0,0 +1,51 @@
1
+package com.huiju.estateagents.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableName;
7
+import lombok.Data;
8
+import lombok.EqualsAndHashCode;
9
+import lombok.experimental.Accessors;
10
+
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+
14
+/**
15
+ * <p>
16
+ * 
17
+ * </p>
18
+ *
19
+ * @author jobob
20
+ * @since 2019-11-13
21
+ */
22
+@Data
23
+@EqualsAndHashCode(callSuper = false)
24
+@Accessors(chain = true)
25
+@TableName("ta_building_map_relation")
26
+public class TaBuildingMapRelation implements Serializable {
27
+
28
+    @TableId(value = "map_id", type = IdType.AUTO)
29
+    private Integer mapId;
30
+
31
+    private static final long serialVersionUID = 1L;
32
+
33
+    private String buildingId;
34
+
35
+    private Integer orgId;
36
+
37
+    private String types;
38
+
39
+    private String data;
40
+
41
+    private String label;
42
+
43
+    @TableField(value = "`key`")
44
+    private String key;
45
+
46
+    private Integer status;
47
+
48
+    private LocalDateTime createDate;
49
+
50
+
51
+}

+ 18
- 0
src/main/java/com/huiju/estateagents/mapper/TaBuildingMapRelationMapper.java Parādīt failu

@@ -0,0 +1,18 @@
1
+package com.huiju.estateagents.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.huiju.estateagents.entity.TaBuildingMapRelation;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ *  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author jobob
13
+ * @since 2019-11-13
14
+ */
15
+@Mapper
16
+public interface TaBuildingMapRelationMapper extends BaseMapper<TaBuildingMapRelation> {
17
+
18
+}

+ 16
- 0
src/main/java/com/huiju/estateagents/service/ITaBuildingMapRelationService.java Parādīt failu

@@ -0,0 +1,16 @@
1
+package com.huiju.estateagents.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.huiju.estateagents.entity.TaBuildingMapRelation;
5
+
6
+/**
7
+ * <p>
8
+ *  服务类
9
+ * </p>
10
+ *
11
+ * @author jobob
12
+ * @since 2019-11-13
13
+ */
14
+public interface ITaBuildingMapRelationService extends IService<TaBuildingMapRelation> {
15
+
16
+}

+ 20
- 0
src/main/java/com/huiju/estateagents/service/impl/TaBuildingMapRelationServiceImpl.java Parādīt failu

@@ -0,0 +1,20 @@
1
+package com.huiju.estateagents.service.impl;
2
+
3
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+import com.huiju.estateagents.entity.TaBuildingMapRelation;
5
+import com.huiju.estateagents.mapper.TaBuildingMapRelationMapper;
6
+import com.huiju.estateagents.service.ITaBuildingMapRelationService;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ *  服务实现类
12
+ * </p>
13
+ *
14
+ * @author jobob
15
+ * @since 2019-11-13
16
+ */
17
+@Service
18
+public class TaBuildingMapRelationServiceImpl extends ServiceImpl<TaBuildingMapRelationMapper, TaBuildingMapRelation> implements ITaBuildingMapRelationService {
19
+
20
+}

+ 62
- 3
src/main/java/com/huiju/estateagents/service/impl/TaBuildingServiceImpl.java Parādīt failu

@@ -13,6 +13,7 @@ import com.huiju.estateagents.common.DateUtils;
13 13
 import com.huiju.estateagents.common.StringUtils;
14 14
 import com.huiju.estateagents.entity.*;
15 15
 import com.huiju.estateagents.mapper.*;
16
+import com.huiju.estateagents.service.ITaBuildingMapRelationService;
16 17
 import com.huiju.estateagents.service.ITaBuildingService;
17 18
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
18 19
 import com.huiju.estateagents.service.TaPosterService;
@@ -86,6 +87,9 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
86 87
     @Autowired
87 88
     private  TaOrgMapper  taOrgMapper;
88 89
 
90
+    @Autowired
91
+    private ITaBuildingMapRelationService iTaBuildingMapRelationService;
92
+
89 93
     @Override
90 94
     public ResponseBean buildingList(Integer pageNum, Integer pageSize, String name, String code, LocalDateTime startDate, String buildingStatus, String marketStatus, Integer cityId, Integer isMain, Integer orgId) {
91 95
         Page<TaBuilding> page = new Page<>();
@@ -168,6 +172,13 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
168 172
         building.setPosters(taPosterService.getPostersForTarget(id,CommConstant.POSTER_CONTENT_TYPE_BUILDING));
169 173
         building.setShareContents(taShareContentService.getPostersForTarget(id,CommConstant.POSTER_CONTENT_TYPE_BUILDING));
170 174
 
175
+        // 查询 周边数据
176
+        QueryWrapper<TaBuildingMapRelation> mapRelationQueryWrapper = new QueryWrapper<>();
177
+        mapRelationQueryWrapper.eq("building_id", building.getBuildingId());
178
+        mapRelationQueryWrapper.eq("org_id", building.getOrgId());
179
+        List<TaBuildingMapRelation> mapRelationList = iTaBuildingMapRelationService.list(mapRelationQueryWrapper);
180
+        building.setMapJson(mapRelationList.size() > 0 ? JSONObject.toJSONString(mapRelationList) : null);
181
+
171 182
         return ResponseBean.success(building);
172 183
     }
173 184
 
@@ -247,9 +258,14 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
247 258
         shareActivityQueryWrapper.eq("status", 1);
248 259
         shareActivityQueryWrapper.in("activity_status", 0, 1);
249 260
         List<TaShareActivity> shareActivityList = taShareActivityMapper.selectList(shareActivityQueryWrapper);
250
-
251 261
         building.setShareActivityList(shareActivityList);
252 262
 
263
+        // 查询 周边数据
264
+        QueryWrapper<TaBuildingMapRelation> mapRelationQueryWrapper = new QueryWrapper<>();
265
+        mapRelationQueryWrapper.eq("building_id", building.getBuildingId());
266
+        mapRelationQueryWrapper.eq("org_id", building.getOrgId());
267
+        List<TaBuildingMapRelation> mapRelationList = iTaBuildingMapRelationService.list(mapRelationQueryWrapper);
268
+        building.setMapJson(mapRelationList.size() > 0 ? JSONObject.toJSONString(mapRelationList) : null);
253 269
 
254 270
         return ResponseBean.success(building);
255 271
     }
@@ -258,7 +274,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
258 274
     public ResponseBean buildingUpdate(String parameter, Integer orgId) {
259 275
         JSONObject object= JSONObject.parseObject(parameter);
260 276
 
261
-        TaBuilding building = JSONObject.parseObject(parameter,TaBuilding.class);
277
+        TaBuilding building = object.toJavaObject(TaBuilding.class);
262 278
 
263 279
         // 先删除视频
264 280
         UpdateWrapper<TaBuilding> updateWrapper = new UpdateWrapper<>();
@@ -328,6 +344,20 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
328 344
         if (CollectionUtils.isNotEmpty(buildingProjectTypeArray)) {
329 345
             taBuildingProjectTypeMapper.insertBuildingProjectTypeBatch(buildingProjectTypeArray, building.getBuildingId());
330 346
         }
347
+
348
+        // 地图周边
349
+        JSONArray mapJson = object.getJSONArray("mapJson");
350
+        if (null != mapJson) {
351
+            // 先删除
352
+            QueryWrapper<TaBuildingMapRelation> mapRelationQueryWrapper = new QueryWrapper<>();
353
+            mapRelationQueryWrapper.eq("building_id", building.getBuildingId());
354
+            mapRelationQueryWrapper.eq("org_id", orgId);
355
+            iTaBuildingMapRelationService.remove(mapRelationQueryWrapper);
356
+
357
+            List<TaBuildingMapRelation> taBuildingMapRelations = mapJson.toJavaList(TaBuildingMapRelation.class);
358
+            insertBuildingMapRelationBeach(taBuildingMapRelations, building.getBuildingId(), orgId);
359
+        }
360
+
331 361
         return ResponseBean.success(building);
332 362
     }
333 363
 
@@ -350,7 +380,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
350 380
             return ResponseBean.error("楼盘已超过最大限制", ResponseBean.ERROR_UNAVAILABLE);
351 381
         }
352 382
 
353
-        TaBuilding building = JSONObject.parseObject(parameter,TaBuilding.class);
383
+        TaBuilding building = object.toJavaObject(TaBuilding.class);
354 384
         if(null!= object.getDate("openingDate")){
355 385
             building.setOpeningDate(DateUtils.date2LocalDateTime(object.getDate("openingDate")));
356 386
         }
@@ -401,9 +431,37 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
401 431
             taBuildingProjectTypeMapper.insertBuildingProjectTypeBatch(buildingProjectTypeArray, building.getBuildingId());
402 432
         }
403 433
 
434
+        // 地图周边
435
+        JSONArray mapJson = object.getJSONArray("mapJson");
436
+        if (null != mapJson) {
437
+            List<TaBuildingMapRelation> taBuildingMapRelations = mapJson.toJavaList(TaBuildingMapRelation.class);
438
+            insertBuildingMapRelationBeach(taBuildingMapRelations, building.getBuildingId(), orgId);
439
+        }
440
+
441
+
404 442
         return ResponseBean.success(building);
405 443
     }
406 444
 
445
+    /**
446
+     * 批量插入 周边地图数据
447
+     * @param list
448
+     * @param buildingId
449
+     * @param orgId
450
+     * @return
451
+     */
452
+    private List<TaBuildingMapRelation> insertBuildingMapRelationBeach(List<TaBuildingMapRelation> list, String buildingId, Integer orgId) {
453
+        List<TaBuildingMapRelation> newList = list.stream().map(e -> {
454
+            e.setBuildingId(buildingId);
455
+            e.setOrgId(orgId);
456
+            e.setStatus(1);
457
+            e.setCreateDate(LocalDateTime.now());
458
+            return e;
459
+        }).collect(Collectors.toList());
460
+
461
+        iTaBuildingMapRelationService.saveBatch(newList);
462
+        return newList;
463
+    }
464
+
407 465
     @Override
408 466
     public ResponseBean buildingUpdateStatus(String parameter, Integer orgId) {
409 467
         TaBuilding  building = new TaBuilding();
@@ -449,6 +507,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
449 507
         }
450 508
 
451 509
         JSONObject jsonobject = JSONObject.parseObject(parameter);
510
+
452 511
         //图片数组
453 512
         String imgStr = jsonobject.getString("img");
454 513
         //转集合

+ 5
- 0
src/main/resources/mapper/TaBuildingMapRelationMapper.xml Parādīt failu

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.huiju.estateagents.ta.mapper.TaBuildingMapRelationMapper">
4
+
5
+</mapper>