Browse Source

完成 意向值,合并代码

魏熙美 5 years ago
parent
commit
c1b9b294d2

+ 23
- 6
src/main/java/com/huiju/estateagents/controller/TaBuildingIntentionController.java View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.huiju.estateagents.base.ResponseBean;
7 7
 import com.huiju.estateagents.entity.TaBuildingIntention;
8
+import com.huiju.estateagents.entity.TdBizEvent;
8 9
 import com.huiju.estateagents.service.ITaBuildingIntentionService;
9 10
 import org.slf4j.Logger;
10 11
 import org.slf4j.LoggerFactory;
@@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
18 19
 import org.springframework.web.bind.annotation.RestController;
19 20
 import com.huiju.estateagents.base.BaseController;
20 21
 
22
+import java.util.List;
23
+
21 24
 /**
22 25
  * <p>
23 26
     * 项目意向表  前端控制器
@@ -27,7 +30,7 @@ import com.huiju.estateagents.base.BaseController;
27 30
  * @since 2019-08-07
28 31
  */
29 32
 @RestController
30
-@RequestMapping("/")
33
+@RequestMapping("/api")
31 34
 public class TaBuildingIntentionController extends BaseController {
32 35
 
33 36
     private final Logger logger = LoggerFactory.getLogger(TaBuildingIntentionController.class);
@@ -42,7 +45,7 @@ public class TaBuildingIntentionController extends BaseController {
42 45
      * @param pageSize
43 46
      * @return
44 47
      */
45
-    @RequestMapping(value="/taBuildingIntention",method= RequestMethod.GET)
48
+    @RequestMapping(value="/admin/taBuildingIntention",method= RequestMethod.GET)
46 49
     public ResponseBean taBuildingIntentionList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47 50
 									 @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
48 51
         ResponseBean responseBean = new ResponseBean();
@@ -66,7 +69,7 @@ public class TaBuildingIntentionController extends BaseController {
66 69
      * @param taBuildingIntention 实体对象
67 70
      * @return
68 71
      */
69
-    @RequestMapping(value="/taBuildingIntention",method= RequestMethod.POST)
72
+    @RequestMapping(value="/admin/taBuildingIntention",method= RequestMethod.POST)
70 73
     public ResponseBean taBuildingIntentionAdd(@RequestBody TaBuildingIntention taBuildingIntention){
71 74
         ResponseBean responseBean = new ResponseBean();
72 75
         try {
@@ -82,12 +85,26 @@ public class TaBuildingIntentionController extends BaseController {
82 85
         return responseBean;
83 86
     }
84 87
 
88
+
89
+    /**
90
+     *  批量 保存 或者 修改 对象  意向值和列表
91
+     * @param tdBizEventList 实体对象集合
92
+     * @return
93
+     */
94
+    @RequestMapping(value="/admin/taBuildingIntentionAddOrUpdate/{buildingId}",method= RequestMethod.POST)
95
+    public ResponseBean taBuildingIntentionAddOrUpdate(@RequestBody List<TdBizEvent> tdBizEventList, @PathVariable String buildingId){
96
+        ResponseBean responseBean = new ResponseBean();
97
+        responseBean = iTaBuildingIntentionService.taBuildingIntentionAddOrUpdate(tdBizEventList, buildingId);
98
+        return responseBean;
99
+    }
100
+
101
+
85 102
     /**
86 103
      * 根据id删除对象
87 104
      * @param id  实体ID
88 105
      */
89 106
     @ResponseBody
90
-    @RequestMapping(value="/taBuildingIntention/{id}", method= RequestMethod.DELETE)
107
+    @RequestMapping(value="/admin/taBuildingIntention/{id}", method= RequestMethod.DELETE)
91 108
     public ResponseBean taBuildingIntentionDelete(@PathVariable Integer id){
92 109
         ResponseBean responseBean = new ResponseBean();
93 110
         try {
@@ -109,7 +126,7 @@ public class TaBuildingIntentionController extends BaseController {
109 126
      * @param taBuildingIntention 实体对象
110 127
      * @return
111 128
      */
112
-    @RequestMapping(value="/taBuildingIntention/{id}",method= RequestMethod.PUT)
129
+    @RequestMapping(value="/admin/taBuildingIntention/{id}",method= RequestMethod.PUT)
113 130
     public ResponseBean taBuildingIntentionUpdate(@PathVariable Integer id,
114 131
                                         @RequestBody TaBuildingIntention taBuildingIntention){
115 132
         ResponseBean responseBean = new ResponseBean();
@@ -130,7 +147,7 @@ public class TaBuildingIntentionController extends BaseController {
130 147
      * 根据id查询对象
131 148
      * @param id  实体ID
132 149
      */
133
-    @RequestMapping(value="/taBuildingIntention/{id}",method= RequestMethod.GET)
150
+    @RequestMapping(value="/admin/taBuildingIntention/{id}",method= RequestMethod.GET)
134 151
     public ResponseBean taBuildingIntentionGet(@PathVariable Integer id){
135 152
         ResponseBean responseBean = new ResponseBean();
136 153
         try {

+ 3
- 2
src/main/java/com/huiju/estateagents/controller/TaPersonIntentionRecordController.java View File

@@ -44,13 +44,14 @@ public class TaPersonIntentionRecordController extends BaseController {
44 44
      */
45 45
     @RequestMapping(value="/taPersonIntentionRecord",method= RequestMethod.GET)
46 46
     public ResponseBean taPersonIntentionRecordList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
-                                                    @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
47
+                                                    @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
48
+                                                    @RequestParam(value = "buildingId", required = false) String buildingId){
48 49
         ResponseBean responseBean = new ResponseBean();
49 50
         try {
50 51
             //使用分页插件
51 52
 		    IPage<TaPersonIntentionRecord> pg = new Page<>(pageNum, pageSize);
52 53
 
53
-            responseBean = iTaPersonIntentionRecordService.selectAll(pg);
54
+            responseBean = iTaPersonIntentionRecordService.selectAll(pg, buildingId);
54 55
         }catch (Exception e){
55 56
             logger.error("taPersonIntentionRecordList -=- {}",e.toString());
56 57
             responseBean.addError(e.getMessage());

+ 23
- 0
src/main/java/com/huiju/estateagents/controller/TdBizEventController.java View File

@@ -61,6 +61,29 @@ public class TdBizEventController extends BaseController {
61 61
         return responseBean;
62 62
     }
63 63
 
64
+
65
+    /**
66
+     * 分页查询列表,并携带意向值
67
+     * @param pageNum
68
+     * @param pageSize
69
+     * @return
70
+     */
71
+    @RequestMapping(value="/admin/tdBizEventIntention",method= RequestMethod.GET)
72
+    public ResponseBean tdBizEventAndIntention(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
73
+                                            @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
74
+                                            @RequestParam(value = "buildingId", required = false) String buildingId){
75
+        ResponseBean responseBean = new ResponseBean();
76
+        try {
77
+            //使用分页插件
78
+            IPage<TdBizEvent> pg = new Page<>(pageNum, pageSize);
79
+            responseBean = iTdBizEventService.getBizEventAndIntention(pg, buildingId);
80
+        }catch (Exception e){
81
+            logger.error("tdBizEventList -=- {}",e.toString());
82
+            responseBean.addError(e.getMessage());
83
+        }
84
+        return responseBean;
85
+    }
86
+
64 87
     /**
65 88
      * 分页查询列表
66 89
      * @param pageNum

+ 19
- 0
src/main/java/com/huiju/estateagents/entity/TdBizEvent.java View File

@@ -1,6 +1,7 @@
1 1
 package com.huiju.estateagents.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
5 6
 import java.time.LocalDateTime;
6 7
 import java.io.Serializable;
@@ -54,4 +55,22 @@ public class TdBizEvent implements Serializable {
54 55
      */
55 56
     private LocalDateTime createDate;
56 57
 
58
+    /**
59
+     * 意向值
60
+     */
61
+    @TableField(exist = false)
62
+    private Integer intention;
63
+
64
+    /**
65
+     * 是否选中了意向值
66
+     */
67
+    @TableField(exist = false)
68
+    private Boolean checkbox;
69
+
70
+    /**
71
+     * 项目意向ID
72
+     */
73
+    @TableField(exist = false)
74
+    private Integer intentionId;
75
+
57 76
 }

+ 11
- 0
src/main/java/com/huiju/estateagents/mapper/TdBizEventMapper.java View File

@@ -2,8 +2,12 @@ package com.huiju.estateagents.mapper;
2 2
 
3 3
 
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.huiju.estateagents.entity.TdBizEvent;
6 7
 import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+
10
+import java.util.Map;
7 11
 
8 12
 /**
9 13
  * <p>
@@ -16,4 +20,11 @@ import org.apache.ibatis.annotations.Mapper;
16 20
 @Mapper
17 21
 public interface TdBizEventMapper extends BaseMapper<TdBizEvent> {
18 22
 
23
+    /**
24
+     * 获取意向值选项和意向值
25
+     * @param pg
26
+     * @param buildingId
27
+     * @return
28
+     */
29
+    IPage<TdBizEvent> selectBizEventAndIntention(IPage<TdBizEvent> pg, @Param("buildingId") String buildingId);
19 30
 }

+ 10
- 0
src/main/java/com/huiju/estateagents/service/ITaBuildingIntentionService.java View File

@@ -2,7 +2,11 @@ package com.huiju.estateagents.service;
2 2
 
3 3
 
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.huiju.estateagents.base.ResponseBean;
5 6
 import com.huiju.estateagents.entity.TaBuildingIntention;
7
+import com.huiju.estateagents.entity.TdBizEvent;
8
+
9
+import java.util.List;
6 10
 
7 11
 /**
8 12
  * <p>
@@ -14,4 +18,10 @@ import com.huiju.estateagents.entity.TaBuildingIntention;
14 18
  */
15 19
 public interface ITaBuildingIntentionService extends IService<TaBuildingIntention> {
16 20
 
21
+    /**
22
+     * 添加或者修改
23
+     * @param tdBizEventsList
24
+     * @return
25
+     */
26
+    ResponseBean taBuildingIntentionAddOrUpdate(List<TdBizEvent> tdBizEventsList, String buildingId);
17 27
 }

+ 1
- 1
src/main/java/com/huiju/estateagents/service/ITaPersonIntentionRecordService.java View File

@@ -17,5 +17,5 @@ import com.huiju.estateagents.entity.TaPersonIntentionRecord;
17 17
 public interface ITaPersonIntentionRecordService extends IService<TaPersonIntentionRecord> {
18 18
 
19 19
 
20
-    ResponseBean selectAll(IPage<TaPersonIntentionRecord> pg);
20
+    ResponseBean selectAll(IPage<TaPersonIntentionRecord> pg,String buildingId);
21 21
 }

+ 10
- 0
src/main/java/com/huiju/estateagents/service/ITdBizEventService.java View File

@@ -1,7 +1,9 @@
1 1
 package com.huiju.estateagents.service;
2 2
 
3 3
 
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.huiju.estateagents.base.ResponseBean;
5 7
 import com.huiju.estateagents.entity.TdBizEvent;
6 8
 
7 9
 /**
@@ -14,4 +16,12 @@ import com.huiju.estateagents.entity.TdBizEvent;
14 16
  */
15 17
 public interface ITdBizEventService extends IService<TdBizEvent> {
16 18
 
19
+    /**
20
+     * 获取意向值选项和意向值
21
+     * @param pg
22
+     * @param buildingId
23
+     * @return
24
+     */
25
+    ResponseBean getBizEventAndIntention(IPage<TdBizEvent> pg, String buildingId);
26
+
17 27
 }

+ 28
- 0
src/main/java/com/huiju/estateagents/service/impl/TaBuildingIntentionServiceImpl.java View File

@@ -1,11 +1,16 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+import com.huiju.estateagents.base.ResponseBean;
4 5
 import com.huiju.estateagents.entity.TaBuildingIntention;
6
+import com.huiju.estateagents.entity.TdBizEvent;
5 7
 import com.huiju.estateagents.mapper.TaBuildingIntentionMapper;
6 8
 import com.huiju.estateagents.service.ITaBuildingIntentionService;
7 9
 import org.springframework.stereotype.Service;
8 10
 
11
+import java.util.List;
12
+import java.util.stream.Collectors;
13
+
9 14
 /**
10 15
  * <p>
11 16
  * 项目意向表  服务实现类
@@ -17,4 +22,27 @@ import org.springframework.stereotype.Service;
17 22
 @Service
18 23
 public class TaBuildingIntentionServiceImpl extends ServiceImpl<TaBuildingIntentionMapper, TaBuildingIntention> implements ITaBuildingIntentionService {
19 24
 
25
+
26
+    @Override
27
+    public ResponseBean taBuildingIntentionAddOrUpdate(List<TdBizEvent>tdBizEventsList, String buildingId) {
28
+        ResponseBean responseBean = new ResponseBean();
29
+
30
+        // 获取所有需要 保存 或者 修改
31
+        List<TaBuildingIntention> taBuildingIntentions = tdBizEventsList.stream().filter(e -> e.getCheckbox()).map(e -> {
32
+                TaBuildingIntention taBuildingIntention = new TaBuildingIntention();
33
+                taBuildingIntention.setIntentionId(e.getIntentionId());
34
+                taBuildingIntention.setEventId(e.getEventId());
35
+                taBuildingIntention.setEventCode(e.getEventCode());
36
+                taBuildingIntention.setEventName(e.getEventName());
37
+                taBuildingIntention.setIntention(e.getIntention());
38
+                taBuildingIntention.setCreateDate(e.getCreateDate());
39
+                taBuildingIntention.setBuildingId(buildingId);
40
+                taBuildingIntention.setStatus(1);
41
+                return taBuildingIntention;
42
+        }).collect(Collectors.toList());
43
+
44
+        this.saveOrUpdateBatch(taBuildingIntentions);
45
+        responseBean.addSuccess("操作成功!");
46
+        return responseBean;
47
+    }
20 48
 }

+ 6
- 2
src/main/java/com/huiju/estateagents/service/impl/TaPersonIntentionRecordServiceImpl.java View File

@@ -1,12 +1,14 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3 3
 
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6 7
 import com.huiju.estateagents.base.ResponseBean;
7 8
 import com.huiju.estateagents.entity.TaPersonIntentionRecord;
8 9
 import com.huiju.estateagents.mapper.TaPersonIntentionRecordMapper;
9 10
 import com.huiju.estateagents.service.ITaPersonIntentionRecordService;
11
+import org.apache.commons.lang3.StringUtils;
10 12
 import org.springframework.beans.factory.annotation.Autowired;
11 13
 import org.springframework.stereotype.Service;
12 14
 
@@ -25,9 +27,11 @@ public class TaPersonIntentionRecordServiceImpl extends ServiceImpl<TaPersonInte
25 27
     private TaPersonIntentionRecordMapper taPersonIntentionRecordMapper;
26 28
 
27 29
     @Override
28
-    public ResponseBean selectAll(IPage<TaPersonIntentionRecord> pg) {
30
+    public ResponseBean selectAll(IPage<TaPersonIntentionRecord> pg, String buildingId) {
29 31
         ResponseBean responseBean = new ResponseBean();
30
-        IPage<TaPersonIntentionRecord> taPersonIntentionRecordIPage = taPersonIntentionRecordMapper.selectAll(pg);
32
+        QueryWrapper<TaPersonIntentionRecord> queryWrapper = new QueryWrapper<>();
33
+        queryWrapper.eq(StringUtils.isNotBlank(buildingId),"building_id", buildingId);
34
+        IPage<TaPersonIntentionRecord> taPersonIntentionRecordIPage = taPersonIntentionRecordMapper.selectPage(pg, queryWrapper);
31 35
         responseBean.addSuccess(taPersonIntentionRecordIPage);
32 36
         return responseBean;
33 37
     }

+ 15
- 0
src/main/java/com/huiju/estateagents/service/impl/TdBizEventServiceImpl.java View File

@@ -1,11 +1,16 @@
1 1
 package com.huiju.estateagents.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.huiju.estateagents.base.ResponseBean;
4 6
 import com.huiju.estateagents.entity.TdBizEvent;
5 7
 import com.huiju.estateagents.mapper.TdBizEventMapper;
6 8
 import com.huiju.estateagents.service.ITdBizEventService;
9
+import org.springframework.beans.factory.annotation.Autowired;
7 10
 import org.springframework.stereotype.Service;
8 11
 
12
+import java.util.Map;
13
+
9 14
 /**
10 15
  * <p>
11 16
  * 事件字典  服务实现类
@@ -17,4 +22,14 @@ import org.springframework.stereotype.Service;
17 22
 @Service
18 23
 public class TdBizEventServiceImpl extends ServiceImpl<TdBizEventMapper, TdBizEvent> implements ITdBizEventService {
19 24
 
25
+    @Autowired
26
+    private TdBizEventMapper tdBizEventMapper;
27
+
28
+    @Override
29
+    public ResponseBean getBizEventAndIntention(IPage<TdBizEvent> pg, String buildingId) {
30
+        ResponseBean responseBean = new ResponseBean();
31
+        IPage<TdBizEvent> page = tdBizEventMapper.selectBizEventAndIntention(pg, buildingId);
32
+        responseBean.addSuccess(page);
33
+        return responseBean;
34
+    }
20 35
 }

+ 31
- 1
src/main/resources/mapper/TdBizEventMapper.xml View File

@@ -1,5 +1,35 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 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.TdBizEventMapper">
3
+<mapper namespace="com.huiju.estateagents.mapper.TdBizEventMapper">
4
+
5
+    <select id="selectBizEventAndIntention" resultType="com.huiju.estateagents.entity.TdBizEvent">
6
+        select
7
+            biz_event.*,
8
+            building_intention.intention AS intention,
9
+            IF( building_intention.event_code IS NOT NULL, 'true', 'false' ) AS checkbox,
10
+            building_intention.building_id AS buildingId,
11
+            building_intention.intention_id AS intentionId
12
+        FROM
13
+        (
14
+            SELECT
15
+              tbe.*
16
+            FROM
17
+                td_biz_event tbe
18
+        ) as biz_event
19
+        LEFT JOIN
20
+        (select
21
+            tbi.*
22
+         from
23
+            ta_building_intention tbi
24
+            <trim prefix="where" prefixOverrides="and | or">
25
+                <if test="buildingId != null and buildingId != ''">
26
+                    tbi.building_id = #{buildingId}
27
+                </if>
28
+            </trim>
29
+        ) as building_intention
30
+
31
+        ON biz_event.event_id = building_intention.event_id
32
+
33
+    </select>
4 34
 
5 35
 </mapper>