|
@@ -1,5 +1,8 @@
|
1
|
1
|
package com.huiju.welcome.controller;
|
2
|
2
|
|
|
3
|
+import com.alibaba.excel.ExcelWriter;
|
|
4
|
+import com.alibaba.excel.metadata.Sheet;
|
|
5
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
3
|
6
|
import com.alibaba.fastjson.JSONArray;
|
4
|
7
|
import com.alibaba.fastjson.JSONObject;
|
5
|
8
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -8,10 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
8
|
11
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
9
|
12
|
import com.huiju.welcome.common.base.BaseController;
|
10
|
13
|
import com.huiju.welcome.common.base.ResponseBean;
|
11
|
|
-import com.huiju.welcome.model.SysUser;
|
12
|
|
-import com.huiju.welcome.model.TaCustomer;
|
13
|
|
-import com.huiju.welcome.model.TaFollowupRecord;
|
14
|
|
-import com.huiju.welcome.model.TaMainUsherRecord;
|
|
14
|
+import com.huiju.welcome.model.*;
|
15
|
15
|
import com.huiju.welcome.service.*;
|
16
|
16
|
import com.huiju.welcome.utils.DateUtils;
|
17
|
17
|
import com.huiju.welcome.utils.JWTUtils;
|
|
@@ -23,7 +23,12 @@ import org.slf4j.LoggerFactory;
|
23
|
23
|
import org.springframework.beans.factory.annotation.Autowired;
|
24
|
24
|
import org.springframework.web.bind.annotation.*;
|
25
|
25
|
|
|
26
|
+import javax.servlet.ServletOutputStream;
|
26
|
27
|
import javax.servlet.http.HttpServletRequest;
|
|
28
|
+import javax.servlet.http.HttpServletResponse;
|
|
29
|
+import java.io.IOException;
|
|
30
|
+import java.time.LocalDateTime;
|
|
31
|
+import java.time.format.DateTimeFormatter;
|
27
|
32
|
import java.util.List;
|
28
|
33
|
|
29
|
34
|
/**
|
|
@@ -49,6 +54,9 @@ public class TaMainUsherRecordController extends BaseController {
|
49
|
54
|
@Autowired
|
50
|
55
|
private ITaPersonService iTaPersonService;
|
51
|
56
|
|
|
57
|
+ @Autowired
|
|
58
|
+ private ITaCustomerService iTaCustomerService;
|
|
59
|
+
|
52
|
60
|
/**
|
53
|
61
|
* 保存对象
|
54
|
62
|
* @param taMainUsherRecord 实体对象
|
|
@@ -214,6 +222,16 @@ public class TaMainUsherRecordController extends BaseController {
|
214
|
222
|
return responseBean;
|
215
|
223
|
}
|
216
|
224
|
|
|
225
|
+ /**
|
|
226
|
+ * 列表查询的参数必须要跟导出接口的参数一致
|
|
227
|
+ * @param pageNum
|
|
228
|
+ * @param pageSize
|
|
229
|
+ * @param customerName
|
|
230
|
+ * @param phone
|
|
231
|
+ * @param platNumber
|
|
232
|
+ * @param agentUserId
|
|
233
|
+ * @return
|
|
234
|
+ */
|
217
|
235
|
@RequestMapping(value="/customerList",method= RequestMethod.GET)
|
218
|
236
|
public ResponseBean customer(@RequestParam(defaultValue = "1") int pageNum,
|
219
|
237
|
@RequestParam(defaultValue = "10") int pageSize,
|
|
@@ -224,6 +242,42 @@ public class TaMainUsherRecordController extends BaseController {
|
224
|
242
|
ResponseBean result = iTaMainUsherRecordService.customerPage(pageNum, pageSize,customerName,phone,platNumber, agentUserId);
|
225
|
243
|
return result;
|
226
|
244
|
}
|
|
245
|
+
|
|
246
|
+ /**
|
|
247
|
+ * 导出接口的参数必须要跟列表查询的参数一致
|
|
248
|
+ * @param customerName
|
|
249
|
+ * @param phone
|
|
250
|
+ * @param platNumber
|
|
251
|
+ * @param agentUserId
|
|
252
|
+ * @param response
|
|
253
|
+ */
|
|
254
|
+ @RequestMapping(value="/excel/customerList",method= RequestMethod.GET)
|
|
255
|
+ public void exportCustomer(@RequestParam(value = "customerName" ,required = false)String customerName,
|
|
256
|
+ @RequestParam(value = "phone" ,required = false)String phone,
|
|
257
|
+ @RequestParam(value = "platNumber" ,required = false)String platNumber,
|
|
258
|
+ @RequestParam(value = "agentUserId", required = false) Integer agentUserId,
|
|
259
|
+ HttpServletResponse response) {
|
|
260
|
+ List<CustomerExcel> result = iTaCustomerService.getCustomersEqualCustomerPage(customerName, phone, platNumber, agentUserId);
|
|
261
|
+
|
|
262
|
+ try {
|
|
263
|
+ ServletOutputStream out = response.getOutputStream();
|
|
264
|
+
|
|
265
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
|
|
266
|
+ String fileName = LocalDateTime.now().format(formatter) + "-" + StringUtils.ifNull(null == agentUserId ? null : String.valueOf(agentUserId), "全部");
|
|
267
|
+
|
|
268
|
+ response.setContentType("multipart/form-data");
|
|
269
|
+ response.setCharacterEncoding("utf-8");
|
|
270
|
+ response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
|
|
271
|
+ ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX, true);
|
|
272
|
+ Sheet sheet1 = new Sheet(1, 0, CustomerExcel.class);
|
|
273
|
+ writer.write(result, sheet1);
|
|
274
|
+ writer.finish();
|
|
275
|
+
|
|
276
|
+ out.flush();
|
|
277
|
+ } catch (IOException e) {
|
|
278
|
+ e.printStackTrace();
|
|
279
|
+ }
|
|
280
|
+ }
|
227
|
281
|
|
228
|
282
|
/**
|
229
|
283
|
* 修改对象
|