胡轶钦 il y a 5 ans
Parent
révision
8a504a3cd4

+ 51
- 0
src/main/java/com.huiju.welcome/controller/TaMainUsherRecordController.java Voir le fichier

@@ -6,6 +6,7 @@ import com.alibaba.excel.support.ExcelTypeEnum;
6 6
 import com.alibaba.fastjson.JSONObject;
7 7
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
8 8
 import com.baomidou.mybatisplus.core.metadata.IPage;
9
+import com.baomidou.mybatisplus.extension.api.R;
9 10
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
10 11
 import com.huiju.welcome.common.base.BaseController;
11 12
 import com.huiju.welcome.common.base.ResponseBean;
@@ -19,6 +20,7 @@ import org.apache.http.HttpStatus;
19 20
 import org.slf4j.Logger;
20 21
 import org.slf4j.LoggerFactory;
21 22
 import org.springframework.beans.factory.annotation.Autowired;
23
+import org.springframework.format.annotation.DateTimeFormat;
22 24
 import org.springframework.web.bind.annotation.*;
23 25
 
24 26
 import javax.servlet.ServletOutputStream;
@@ -301,6 +303,55 @@ public class TaMainUsherRecordController extends BaseController {
301 303
             e.printStackTrace();
302 304
         }
303 305
     }
306
+
307
+    /**
308
+     * 导出接口的参数必须要跟列表查询的参数一致
309
+     */
310
+    @RequestMapping(value="/excel/usherListExcel",method= RequestMethod.GET)
311
+    public void exportCustomerExcel(@RequestParam(value = "personName" ,required = false)String personName,
312
+                                    @RequestParam(value = "startTime",required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startTime,
313
+                                    @RequestParam(value = "endTime",required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime endTime,
314
+                                    @RequestParam(value = "customerType" ,required = false)String customerType,
315
+                                    @RequestParam(value = "customerSource" ,required = false)String customerSource,
316
+                                    @RequestParam(value = "receiver" ,required = false)String receiver,
317
+                                    @RequestParam(value = "phone" ,required = false)String phone,
318
+                               HttpServletResponse response) {
319
+        List<UsherRecordExcel> result = iTaMainUsherRecordService.getCustomersEqualCustomerPageExcel(personName,phone,receiver,customerType,customerSource,startTime,endTime);
320
+
321
+        try {
322
+            ServletOutputStream out = response.getOutputStream();
323
+
324
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmm");
325
+            String fileName = LocalDateTime.now().format(formatter);
326
+
327
+            response.setContentType("multipart/form-data");
328
+            response.setCharacterEncoding("utf-8");
329
+            response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
330
+            ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX, true);
331
+            Sheet sheet1 = new Sheet(1, 0, CustomerExcel.class);
332
+            writer.write(result, sheet1);
333
+            writer.finish();
334
+
335
+            out.flush();
336
+        } catch (IOException e) {
337
+            e.printStackTrace();
338
+        }
339
+    }
340
+
341
+    @RequestMapping(value="/usherRecords",method= RequestMethod.GET)
342
+    public ResponseBean usherRecords(@RequestParam(defaultValue = "1") int pageNum,
343
+                                 @RequestParam(defaultValue = "10") int pageSize,
344
+                                     @RequestParam(value = "personName" ,required = false)String personName,
345
+                                     @RequestParam(value = "startTime",required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startTime,
346
+                                     @RequestParam(value = "endTime",required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime endTime,
347
+                                     @RequestParam(value = "customerType" ,required = false)String customerType,
348
+                                     @RequestParam(value = "customerSource" ,required = false)String customerSource,
349
+                                     @RequestParam(value = "receiver" ,required = false)String receiver,
350
+                                     @RequestParam(value = "phone" ,required = false)String phone){
351
+        ResponseBean result = new ResponseBean();
352
+        result.addSuccess(iTaMainUsherRecordService.usherRecords(personName,phone,receiver,customerType,customerSource,startTime,endTime,pageNum,pageSize));
353
+        return result;
354
+    }
304 355
     
305 356
     /**
306 357
      * 修改对象

+ 1
- 0
src/main/java/com.huiju.welcome/mapper/TaCustomerMapper.java Voir le fichier

@@ -6,6 +6,7 @@ import com.huiju.welcome.model.TaCustomer;
6 6
 import org.apache.ibatis.annotations.Mapper;
7 7
 import org.apache.ibatis.annotations.Param;
8 8
 
9
+import java.time.LocalDateTime;
9 10
 import java.util.List;
10 11
 
11 12
 /**

+ 2
- 0
src/main/java/com.huiju.welcome/mapper/TaMainUsherRecordMapper.java Voir le fichier

@@ -32,4 +32,6 @@ public interface TaMainUsherRecordMapper extends BaseMapper<TaMainUsherRecord> {
32 32
     List<TaMainUsherRecord> getLastList(@Param("personId") Integer personId, @Param("dt") LocalDateTime dt);
33 33
     IPage<TaMainUsherRecord> taMainUsherRecordList(IPage<TaMainUsherRecord> pg,@Param("phone")String phone,@Param("platNumber")String platNumber,@Param("personName")String personName,@Param("appointment")Integer appointment);
34 34
     Integer getRecIdByCustomerIdCurrentDate(@Param("customerId")Integer customerId);
35
+    IPage<TaMainUsherRecord> usherRecords(IPage<TaMainUsherRecord>pg,@Param("personName") String personName, @Param("phone") String phone, @Param("receiver") String receiver, @Param("customerType") String customerType, @Param("customerSource") String customerSource, @Param("startTime")LocalDateTime startTime,@Param("endTime")LocalDateTime endTime);
36
+    List<TaMainUsherRecord> getCustomersEqualCustomerPageExcel(@Param("personName") String personName, @Param("phone") String phone, @Param("receiver") String receiver, @Param("customerType") String customerType, @Param("customerSource") String customerSource, @Param("startTime")LocalDateTime startTime,@Param("endTime")LocalDateTime endTime);
35 37
 }

+ 3
- 0
src/main/java/com.huiju.welcome/model/TaMainUsherRecord.java Voir le fichier

@@ -80,6 +80,9 @@ public class TaMainUsherRecord implements Serializable {
80 80
     @TableField(exist = false)
81 81
     private boolean newCustomer;
82 82
 
83
+    @TableField(exist = false)
84
+    private String SourceName;
85
+
83 86
     private String receiver;
84 87
 
85 88
     private String customerType;

+ 37
- 0
src/main/java/com.huiju.welcome/model/UsherRecordExcel.java Voir le fichier

@@ -0,0 +1,37 @@
1
+package com.huiju.welcome.model;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.metadata.BaseRowModel;
5
+import lombok.Data;
6
+
7
+import java.time.LocalDateTime;
8
+
9
+@Data
10
+public class UsherRecordExcel extends BaseRowModel {
11
+
12
+
13
+    @ExcelProperty(value = "客户类型" ,index = 0)
14
+    String customerType;
15
+
16
+    @ExcelProperty(value = "姓名" ,index = 1)
17
+    String personName;
18
+
19
+    @ExcelProperty(value = "手机号码" ,index = 2)
20
+    String phone;
21
+
22
+    @ExcelProperty(value = "来访人数" ,index = 3)
23
+    Integer personNum;
24
+
25
+    @ExcelProperty(value = "到访时间" ,index = 4)
26
+    LocalDateTime visiteDate;
27
+
28
+    @ExcelProperty(value = "客户来源" ,index = 5)
29
+    String customerSource;
30
+
31
+    @ExcelProperty(value = "车牌号码" ,index = 6)
32
+    String plateNumber;
33
+
34
+    @ExcelProperty(value = "接待人" ,index = 7)
35
+    String receiver;
36
+
37
+}

+ 1
- 0
src/main/java/com.huiju.welcome/service/ITaCustomerService.java Voir le fichier

@@ -48,6 +48,7 @@ public interface ITaCustomerService extends IService<TaCustomer> {
48 48
 
49 49
     List<CustomerExcel> getCustomersEqualCustomerPage(String customerName, String phone, String platNumber, Integer agentUserId);
50 50
 
51
+
51 52
     IPage<TaCustomer> getCustomerListOfFront(int pageNumber, int pageSize, Integer consultantId, String nameOrPhoneOrReceiver, String identity, Integer consultantType);
52 53
 	
53 54
 	IPage<TaCustomer> getAttributionList(int pageNumber, int pageSize);

+ 6
- 4
src/main/java/com.huiju.welcome/service/ITaMainUsherRecordService.java Voir le fichier

@@ -4,11 +4,9 @@ import com.alibaba.fastjson.JSONArray;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.service.IService;
6 6
 import com.huiju.welcome.common.base.ResponseBean;
7
-import com.huiju.welcome.model.TaCustomer;
8
-import com.huiju.welcome.model.TaFirstUsherRecord;
9
-import com.huiju.welcome.model.TaMainUsherRecord;
10
-import com.huiju.welcome.model.TaPerson;
7
+import com.huiju.welcome.model.*;
11 8
 
9
+import java.time.LocalDateTime;
12 10
 import java.util.List;
13 11
 
14 12
 /**
@@ -53,4 +51,8 @@ public interface ITaMainUsherRecordService extends IService<TaMainUsherRecord> {
53 51
     TaMainUsherRecord newRecordByFirstUsher(TaFirstUsherRecord taFirstUsherRecord, TaCustomer taCustomer);
54 52
 
55 53
     TaMainUsherRecord mergeAndDelete(TaMainUsherRecord source, TaMainUsherRecord target);
54
+
55
+    List<UsherRecordExcel> getCustomersEqualCustomerPageExcel(String personName, String phone, String receiver, String customerType, String customerSource, LocalDateTime startTime,LocalDateTime endTime);
56
+
57
+    IPage<TaMainUsherRecord> usherRecords(String personName, String phone, String receiver, String customerType, String customerSource, LocalDateTime startTime,LocalDateTime endTime,Integer pageNum,Integer pageSize);
56 58
 }

+ 1
- 0
src/main/java/com.huiju.welcome/service/impl/TaCustomerServiceImpl.java Voir le fichier

@@ -591,6 +591,7 @@ public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCusto
591 591
         return result;
592 592
     }
593 593
 
594
+
594 595
     private String getItemNameOfDict(List<SysDict> dict, Integer id) {
595 596
         if (null == dict || null == id) return null;
596 597
 

+ 33
- 0
src/main/java/com.huiju.welcome/service/impl/TaMainUsherRecordServiceImpl.java Voir le fichier

@@ -679,4 +679,37 @@ public class TaMainUsherRecordServiceImpl extends ServiceImpl<TaMainUsherRecordM
679 679
 
680 680
         return taMainUsherRecord;
681 681
     }
682
+
683
+    @Override
684
+    public List<UsherRecordExcel> getCustomersEqualCustomerPageExcel(String personName, String phone, String receiver, String customerType, String customerSource, LocalDateTime startTime,LocalDateTime endTime) {
685
+        List<UsherRecordExcel> result = new ArrayList<>();
686
+        List<TaMainUsherRecord> customers = taMainUsherRecordMapper.getCustomersEqualCustomerPageExcel(personName,phone,receiver,customerType,customerSource,startTime,endTime);
687
+
688
+        if (null != customers) {
689
+            for (int i = 0; i < customers.size(); i ++) {
690
+                TaMainUsherRecord customer = customers.get(i);
691
+
692
+                UsherRecordExcel item = new UsherRecordExcel();
693
+                item.setCustomerSource(customer.getSourceName());
694
+                item.setCustomerType(customer.getCustomerType());
695
+                item.setPersonName(customer.getPersonName());
696
+                item.setPersonNum(customer.getPersonNum());;
697
+                item.setPhone(customer.getPhone());
698
+                item.setPlateNumber(customer.getPlateNumber());
699
+                item.setReceiver(customer.getReceiver());
700
+                item.setVisiteDate(customer.getVisiteDate());
701
+                result.add(item);
702
+            }
703
+        }
704
+
705
+        return result;
706
+    }
707
+
708
+    @Override
709
+    public  IPage<TaMainUsherRecord> usherRecords(String personName, String phone, String receiver, String customerType, String customerSource, LocalDateTime startTime,LocalDateTime endTime,Integer pageNum,Integer pageSize){
710
+        IPage<TaMainUsherRecord> page=new Page<>();
711
+        page.setSize(pageSize == null ? 10 : pageSize);
712
+        page.setCurrent(pageNum == null ? 1 : pageNum);
713
+        return taMainUsherRecordMapper.usherRecords(page,personName,phone,receiver,customerType,customerSource,startTime,endTime);
714
+    }
682 715
 }

+ 22
- 0
src/main/resources/mapper/TaCustomerMapper.xml Voir le fichier

@@ -67,6 +67,28 @@
67 67
         order by consultant_id, create_date desc
68 68
     </select>
69 69
 
70
+    <select id="getCustomersEqualCustomerPage" resultType="com.huiju.welcome.model.TaCustomer">
71
+        select * from ta_customer t
72
+        <where>
73
+            t.status &gt; -1
74
+            <if test="customerName !=null and customerName != ''">
75
+                and t.customer_name LIKE CONCAT('%',#{customerName},'%')
76
+            </if>
77
+
78
+            <if test="phone !=null and phone != ''">
79
+                and t.phone LIKE CONCAT('%',#{phone},'%')
80
+            </if>
81
+
82
+            <if test="platNumber !=null and platNumber != ''">
83
+                and t.plate_number LIKE CONCAT('%',#{platNumber},'%')
84
+            </if>
85
+            <if test="agentUserId != null">
86
+                and t.consultant_id = #{agentUserId}
87
+            </if>
88
+        </where>
89
+        order by consultant_id, create_date desc
90
+    </select>
91
+
70 92
     <select id="getSomeCustMayBe" resultType="com.huiju.welcome.model.TaCustomer">
71 93
         SELECT
72 94
             *

+ 68
- 0
src/main/resources/mapper/TaMainUsherRecordMapper.xml Voir le fichier

@@ -52,4 +52,72 @@ WHERE
52 52
 	and customer_id = #{customerId}
53 53
 	LIMIT 1;
54 54
     </select>
55
+
56
+    <select id="getCustomersEqualCustomerPageExcel" resultType="com.huiju.welcome.model.TaMainUsherRecord">
57
+        SELECT
58
+        t.*,
59
+        b.label as sourceName
60
+        FROM
61
+        ta_main_usher_record t
62
+        LEFT JOIN sys_dict b ON t.customer_source = b.id
63
+        <where>
64
+            t.status = 1
65
+            <if test="personName !=null and personName != ''">
66
+                and t.personName LIKE CONCAT('%',#{personName},'%')
67
+            </if>
68
+            <if test="phone !=null and phone != ''">
69
+                and t.phone LIKE CONCAT('%',#{phone},'%')
70
+            </if>
71
+            <if test="receiver !=null and receiver != ''">
72
+                and t.receiver LIKE CONCAT('%',#{receiver},'%')
73
+            </if>
74
+            <if test="customerType !=null and customerType != ''">
75
+                and t.customer_type =#{customerType}
76
+            </if>
77
+            <if test="customerSource !=null and customerSource != ''">
78
+                and t.customer_source =#{customerSource}
79
+            </if>
80
+            <if test="startTime != null">
81
+                and t.visite_date &gt;= #{startTime}
82
+            </if>
83
+            <if test="endTime != null">
84
+                and t.visite_date &lt;= #{endTime}
85
+            </if>
86
+        </where>
87
+        order by t.visite_date desc
88
+    </select>
89
+
90
+    <select id="usherRecords" resultType="com.huiju.welcome.model.TaMainUsherRecord">
91
+        SELECT
92
+        t.*,
93
+        b.label as sourceName
94
+        FROM
95
+        ta_main_usher_record t
96
+        LEFT JOIN sys_dict b ON t.customer_source = b.id
97
+        <where>
98
+            t.status = 1
99
+            <if test="personName !=null and personName != ''">
100
+                and t.personName LIKE CONCAT('%',#{personName},'%')
101
+            </if>
102
+            <if test="phone !=null and phone != ''">
103
+                and t.phone LIKE CONCAT('%',#{phone},'%')
104
+            </if>
105
+            <if test="receiver !=null and receiver != ''">
106
+                and t.receiver LIKE CONCAT('%',#{receiver},'%')
107
+            </if>
108
+            <if test="customerType !=null and customerType != ''">
109
+                and t.customer_type =#{customerType}
110
+            </if>
111
+            <if test="customerSource !=null and customerSource != ''">
112
+                and t.customer_source =#{customerSource}
113
+            </if>
114
+            <if test="startTime != null">
115
+                and t.visite_date &gt;= #{startTime}
116
+            </if>
117
+            <if test="endTime != null">
118
+                and t.visite_date &lt;= #{endTime}
119
+            </if>
120
+        </where>
121
+        order by t.visite_date desc
122
+    </select>
55 123
 </mapper>