|
@@ -1,21 +1,28 @@
|
1
|
1
|
package com.huiju.estateagents.controller;
|
2
|
2
|
|
|
3
|
+import com.alibaba.fastjson.JSONObject;
|
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.plugins.pagination.Page;
|
6
|
7
|
import com.huiju.estateagents.base.BaseController;
|
7
|
8
|
import com.huiju.estateagents.base.ResponseBean;
|
|
9
|
+import com.huiju.estateagents.entity.TaPersonBuilding;
|
8
|
10
|
import com.huiju.estateagents.entity.TaPreselection;
|
|
11
|
+import com.huiju.estateagents.entity.TaSalesBatch;
|
9
|
12
|
import com.huiju.estateagents.service.ITaPreselectionService;
|
|
13
|
+import com.huiju.estateagents.service.impl.TaSalesBatchServiceImpl;
|
10
|
14
|
import org.slf4j.Logger;
|
11
|
15
|
import org.slf4j.LoggerFactory;
|
12
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
17
|
import org.springframework.web.bind.annotation.*;
|
14
|
18
|
|
|
19
|
+import javax.servlet.http.HttpServletRequest;
|
|
20
|
+import java.util.List;
|
|
21
|
+
|
15
|
22
|
/**
|
16
|
23
|
* <p>
|
17
|
|
- * 预选表 前端控制器
|
18
|
|
- * </p>
|
|
24
|
+ * 预选表 前端控制器
|
|
25
|
+ * </p>
|
19
|
26
|
*
|
20
|
27
|
* @author jobob
|
21
|
28
|
* @since 2020-02-26
|
|
@@ -29,28 +36,62 @@ public class TaPreselectionController extends BaseController {
|
29
|
36
|
@Autowired
|
30
|
37
|
public ITaPreselectionService iTaPreselectionService;
|
31
|
38
|
|
|
39
|
+ @Autowired
|
|
40
|
+ private TaSalesBatchServiceImpl taSalesBatchService;
|
|
41
|
+
|
|
42
|
+ /**
|
|
43
|
+ * 获取销售批次列表-预选
|
|
44
|
+ *
|
|
45
|
+ * @param pageNum
|
|
46
|
+ * @param pageSize
|
|
47
|
+ * @param buildingId
|
|
48
|
+ * @param salesBatchName
|
|
49
|
+ * @param status
|
|
50
|
+ * @param request
|
|
51
|
+ * @return
|
|
52
|
+ */
|
|
53
|
+ @RequestMapping(value = "/admin/listSalesBatchForPreselect", method = RequestMethod.GET)
|
|
54
|
+ public ResponseBean listSalesBatchForPreselect(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
55
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
|
56
|
+ String buildingId, String salesBatchName, Integer status,
|
|
57
|
+ HttpServletRequest request) {
|
|
58
|
+ ResponseBean responseBean = new ResponseBean();
|
|
59
|
+
|
|
60
|
+ try {
|
|
61
|
+ Integer orgId = getOrgId(request);
|
|
62
|
+ List<TaPersonBuilding> personBuildingList = getTaPersonBuildingListByUserId(request);
|
|
63
|
+
|
|
64
|
+ responseBean = taSalesBatchService.listSalesBatchForPreselect(pageSize, pageNum, salesBatchName, buildingId, orgId, status, personBuildingList);
|
|
65
|
+ logger.info("listSalesBatchForPreselect 返回结果:{}", JSONObject.toJSONString(responseBean));
|
|
66
|
+ } catch (Exception e) {
|
|
67
|
+ logger.error("listSalesBatchForPreselect -=- {}", e);
|
|
68
|
+ responseBean.addError(e.getMessage());
|
|
69
|
+ }
|
|
70
|
+ return responseBean;
|
|
71
|
+ }
|
32
|
72
|
|
33
|
73
|
/**
|
34
|
74
|
* 分页查询列表
|
|
75
|
+ *
|
35
|
76
|
* @param pageNum
|
36
|
77
|
* @param pageSize
|
37
|
78
|
* @return
|
38
|
79
|
*/
|
39
|
|
- @RequestMapping(value="/taPreselection",method= RequestMethod.GET)
|
40
|
|
- public ResponseBean taPreselectionList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
41
|
|
- @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
80
|
+ @RequestMapping(value = "/taPreselection", method = RequestMethod.GET)
|
|
81
|
+ public ResponseBean taPreselectionList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
82
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
42
|
83
|
ResponseBean responseBean = new ResponseBean();
|
43
|
84
|
try {
|
44
|
85
|
//使用分页插件
|
45
|
|
- IPage<TaPreselection> pg = new Page<>(pageNum, pageSize);
|
|
86
|
+ IPage<TaPreselection> pg = new Page<>(pageNum, pageSize);
|
46
|
87
|
QueryWrapper<TaPreselection> queryWrapper = new QueryWrapper<>();
|
47
|
88
|
queryWrapper.orderByDesc("create_date");
|
48
|
89
|
|
49
|
90
|
IPage<TaPreselection> result = iTaPreselectionService.page(pg, queryWrapper);
|
50
|
91
|
responseBean.addSuccess(result);
|
51
|
|
- }catch (Exception e){
|
|
92
|
+ } catch (Exception e) {
|
52
|
93
|
e.printStackTrace();
|
53
|
|
- logger.error("taPreselectionList -=- {}",e.toString());
|
|
94
|
+ logger.error("taPreselectionList -=- {}", e.toString());
|
54
|
95
|
responseBean.addError(e.getMessage());
|
55
|
96
|
}
|
56
|
97
|
return responseBean;
|
|
@@ -58,43 +99,97 @@ public class TaPreselectionController extends BaseController {
|
58
|
99
|
|
59
|
100
|
/**
|
60
|
101
|
* 保存对象
|
|
102
|
+ *
|
61
|
103
|
* @param taPreselection 实体对象
|
62
|
104
|
* @return
|
63
|
105
|
*/
|
64
|
|
- @RequestMapping(value="/taPreselection",method= RequestMethod.POST)
|
65
|
|
- public ResponseBean taPreselectionAdd(@RequestBody TaPreselection taPreselection){
|
|
106
|
+ @RequestMapping(value = "/admin/taPreselection", method = RequestMethod.POST)
|
|
107
|
+ public ResponseBean taPreselectionAdd(@RequestBody TaPreselection taPreselection, HttpServletRequest request) {
|
66
|
108
|
ResponseBean responseBean = new ResponseBean();
|
67
|
109
|
try {
|
68
|
|
- if (iTaPreselectionService.save(taPreselection)){
|
|
110
|
+ if (taPreselection.getSalesBatchId() == null) {
|
|
111
|
+ responseBean.addError("销售批次为空");
|
|
112
|
+ return responseBean;
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ Integer orgId = getOrgId(request);
|
|
116
|
+ // 校验是否预选过
|
|
117
|
+ QueryWrapper<TaPreselection> queryWrapper = new QueryWrapper<>();
|
|
118
|
+ queryWrapper.eq("org_id", orgId);
|
|
119
|
+ queryWrapper.eq("sales_batch_id", taPreselection.getSalesBatchId());
|
|
120
|
+ TaPreselection record = iTaPreselectionService.getOne(queryWrapper);
|
|
121
|
+ if (record != null) {
|
|
122
|
+ responseBean.addError("销售批次已新增过预选");
|
|
123
|
+ return responseBean;
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ // 更新批次表信息
|
|
127
|
+ TaSalesBatch taSalesBatch = new TaSalesBatch();
|
|
128
|
+ taSalesBatch.setSalesBatchId(taPreselection.getSalesBatchId());
|
|
129
|
+ taSalesBatch.setPreselectionStartTime(taPreselection.getPreselectionStartTime());
|
|
130
|
+ taSalesBatch.setPreselectionEndTime(taPreselection.getPreselectionEndTime());
|
|
131
|
+ Boolean updateResult = taSalesBatchService.updateById(taSalesBatch);
|
|
132
|
+ if (!updateResult) {
|
|
133
|
+ responseBean.addError("fail");
|
|
134
|
+ return responseBean;
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ // 新增数据
|
|
138
|
+ if (iTaPreselectionService.save(taPreselection)) {
|
69
|
139
|
responseBean.addSuccess(taPreselection);
|
70
|
|
- }else {
|
|
140
|
+ } else {
|
71
|
141
|
responseBean.addError("fail");
|
72
|
142
|
}
|
73
|
|
- }catch (Exception e){
|
|
143
|
+ } catch (Exception e) {
|
|
144
|
+ e.printStackTrace();
|
|
145
|
+ logger.error("taPreselectionAdd -=- {}", e.toString());
|
|
146
|
+ responseBean.addError(e.getMessage());
|
|
147
|
+ }
|
|
148
|
+ return responseBean;
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ /**
|
|
152
|
+ * 批量删除
|
|
153
|
+ *
|
|
154
|
+ * @param taPreselectionList
|
|
155
|
+ * @param request
|
|
156
|
+ * @return
|
|
157
|
+ */
|
|
158
|
+ @ResponseBody
|
|
159
|
+ @RequestMapping(value = "/admin/preselection/batchDelete", method = RequestMethod.PUT)
|
|
160
|
+ public ResponseBean batchDelete(@RequestBody List<TaPreselection> taPreselectionList, HttpServletRequest request) {
|
|
161
|
+ ResponseBean responseBean = new ResponseBean();
|
|
162
|
+ try {
|
|
163
|
+ Integer orgId = getOrgId(request);
|
|
164
|
+ responseBean = iTaPreselectionService.batchDelete(taPreselectionList, orgId);
|
|
165
|
+ logger.info("TaPreselectionController.batchDelete 返回:{}", JSONObject.toJSONString(responseBean));
|
|
166
|
+
|
|
167
|
+ } catch (Exception e) {
|
74
|
168
|
e.printStackTrace();
|
75
|
|
- logger.error("taPreselectionAdd -=- {}",e.toString());
|
|
169
|
+ logger.error("taPreselectionDelete -=- {}", e.toString());
|
76
|
170
|
responseBean.addError(e.getMessage());
|
77
|
171
|
}
|
78
|
172
|
return responseBean;
|
79
|
173
|
}
|
80
|
174
|
|
81
|
175
|
/**
|
82
|
|
- * 根据id删除对象
|
83
|
|
- * @param id 实体ID
|
|
176
|
+ * 删除
|
|
177
|
+ *
|
|
178
|
+ * @param id 实体ID
|
84
|
179
|
*/
|
85
|
180
|
@ResponseBody
|
86
|
|
- @RequestMapping(value="/taPreselection/{id}", method= RequestMethod.DELETE)
|
87
|
|
- public ResponseBean taPreselectionDelete(@PathVariable Integer id){
|
|
181
|
+ @RequestMapping(value = "/admin/taPreselection/{id}", method = RequestMethod.DELETE)
|
|
182
|
+ public ResponseBean taPreselectionDelete(@PathVariable Integer id) {
|
88
|
183
|
ResponseBean responseBean = new ResponseBean();
|
89
|
184
|
try {
|
90
|
|
- if(iTaPreselectionService.removeById(id)){
|
|
185
|
+ if (iTaPreselectionService.removeById(id)) {
|
91
|
186
|
responseBean.addSuccess("success");
|
92
|
|
- }else {
|
|
187
|
+ } else {
|
93
|
188
|
responseBean.addError("fail");
|
94
|
189
|
}
|
95
|
|
- }catch (Exception e){
|
|
190
|
+ } catch (Exception e) {
|
96
|
191
|
e.printStackTrace();
|
97
|
|
- logger.error("taPreselectionDelete -=- {}",e.toString());
|
|
192
|
+ logger.error("taPreselectionDelete -=- {}", e.toString());
|
98
|
193
|
responseBean.addError(e.getMessage());
|
99
|
194
|
}
|
100
|
195
|
return responseBean;
|
|
@@ -102,23 +197,24 @@ public class TaPreselectionController extends BaseController {
|
102
|
197
|
|
103
|
198
|
/**
|
104
|
199
|
* 修改对象
|
105
|
|
- * @param id 实体ID
|
|
200
|
+ *
|
|
201
|
+ * @param id 实体ID
|
106
|
202
|
* @param taPreselection 实体对象
|
107
|
203
|
* @return
|
108
|
204
|
*/
|
109
|
|
- @RequestMapping(value="/taPreselection/{id}",method= RequestMethod.PUT)
|
|
205
|
+ @RequestMapping(value = "/taPreselection/{id}", method = RequestMethod.PUT)
|
110
|
206
|
public ResponseBean taPreselectionUpdate(@PathVariable Integer id,
|
111
|
|
- @RequestBody TaPreselection taPreselection){
|
|
207
|
+ @RequestBody TaPreselection taPreselection) {
|
112
|
208
|
ResponseBean responseBean = new ResponseBean();
|
113
|
209
|
try {
|
114
|
|
- if (iTaPreselectionService.updateById(taPreselection)){
|
|
210
|
+ if (iTaPreselectionService.updateById(taPreselection)) {
|
115
|
211
|
responseBean.addSuccess(taPreselection);
|
116
|
|
- }else {
|
|
212
|
+ } else {
|
117
|
213
|
responseBean.addError("fail");
|
118
|
214
|
}
|
119
|
|
- }catch (Exception e){
|
|
215
|
+ } catch (Exception e) {
|
120
|
216
|
e.printStackTrace();
|
121
|
|
- logger.error("taPreselectionUpdate -=- {}",e.toString());
|
|
217
|
+ logger.error("taPreselectionUpdate -=- {}", e.toString());
|
122
|
218
|
responseBean.addError(e.getMessage());
|
123
|
219
|
}
|
124
|
220
|
return responseBean;
|
|
@@ -126,16 +222,17 @@ public class TaPreselectionController extends BaseController {
|
126
|
222
|
|
127
|
223
|
/**
|
128
|
224
|
* 根据id查询对象
|
129
|
|
- * @param id 实体ID
|
|
225
|
+ *
|
|
226
|
+ * @param id 实体ID
|
130
|
227
|
*/
|
131
|
|
- @RequestMapping(value="/taPreselection/{id}",method= RequestMethod.GET)
|
132
|
|
- public ResponseBean taPreselectionGet(@PathVariable Integer id){
|
|
228
|
+ @RequestMapping(value = "/taPreselection/{id}", method = RequestMethod.GET)
|
|
229
|
+ public ResponseBean taPreselectionGet(@PathVariable Integer id) {
|
133
|
230
|
ResponseBean responseBean = new ResponseBean();
|
134
|
231
|
try {
|
135
|
232
|
responseBean.addSuccess(iTaPreselectionService.getById(id));
|
136
|
|
- }catch (Exception e){
|
|
233
|
+ } catch (Exception e) {
|
137
|
234
|
e.printStackTrace();
|
138
|
|
- logger.error("taPreselectionDelete -=- {}",e.toString());
|
|
235
|
+ logger.error("taPreselectionDelete -=- {}", e.toString());
|
139
|
236
|
responseBean.addError(e.getMessage());
|
140
|
237
|
}
|
141
|
238
|
return responseBean;
|