Explorar el Código

通话记录导出

1550076451 %!s(int64=2) %!d(string=hace) años
padre
commit
520d99e2c9

+ 74 - 1
zxkf-api/src/main/java/api/controller/call/CallLogController.java

1
 package api.controller.call;
1
 package api.controller.call;
2
 
2
 
3
+import api.entity.database.system.User;
4
+import api.entity.view.call.CallLogExportView;
3
 import api.entity.view.call.CallLogView;
5
 import api.entity.view.call.CallLogView;
4
 import api.service.system.IConfigService;
6
 import api.service.system.IConfigService;
5
 import api.util.annotation.Anonymous;
7
 import api.util.annotation.Anonymous;
8
+import api.util.helper.ExcelHelper;
6
 import com.alibaba.fastjson2.JSON;
9
 import com.alibaba.fastjson2.JSON;
7
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
10
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
8
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
11
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
18
 import api.util.helper.StringHelper;
21
 import api.util.helper.StringHelper;
19
 import io.swagger.annotations.Api;
22
 import io.swagger.annotations.Api;
20
 import io.swagger.annotations.ApiOperation;
23
 import io.swagger.annotations.ApiOperation;
24
+import lombok.var;
21
 import org.springframework.beans.factory.annotation.Autowired;
25
 import org.springframework.beans.factory.annotation.Autowired;
22
 import org.springframework.web.bind.annotation.*;
26
 import org.springframework.web.bind.annotation.*;
23
 
27
 
26
 import java.time.temporal.Temporal;
30
 import java.time.temporal.Temporal;
27
 import java.util.Arrays;
31
 import java.util.Arrays;
28
 import java.util.List;
32
 import java.util.List;
33
+import java.util.stream.Collectors;
29
 
34
 
30
 @Api(value = "通话记录表",tags = "通话记录表")
35
 @Api(value = "通话记录表",tags = "通话记录表")
31
 @RestController
36
 @RestController
40
     @Log(title = "查询通话记录表列表",businessType = BusinessType.QUERY)
45
     @Log(title = "查询通话记录表列表",businessType = BusinessType.QUERY)
41
     @GetMapping
46
     @GetMapping
42
     public AjaxResult getList(CallLog input, PageInput pageInput) {
47
     public AjaxResult getList(CallLog input, PageInput pageInput) {
43
-        LambdaQueryWrapper<CallLog> qw = new LambdaQueryWrapper();
48
+        LambdaQueryWrapper<CallLog> qw = new LambdaQueryWrapper<>();
44
         qw.eq(input.getActionId() != null && input.getActionId() > 0, CallLog::getActionId, input.getActionId());
49
         qw.eq(input.getActionId() != null && input.getActionId() > 0, CallLog::getActionId, input.getActionId());
45
         qw.eq(!StringHelper.isEmpty(input.getCallerAgent()), CallLog::getCallerAgent, input.getCallerAgent());
50
         qw.eq(!StringHelper.isEmpty(input.getCallerAgent()), CallLog::getCallerAgent, input.getCallerAgent());
46
         qw.eq(!StringHelper.isEmpty(input.getCaller()), CallLog::getCaller, input.getCaller());
51
         qw.eq(!StringHelper.isEmpty(input.getCaller()), CallLog::getCaller, input.getCaller());
56
         qw.eq(input.getMyd() != null && input.getMyd() > 0, CallLog::getMyd, input.getMyd());
61
         qw.eq(input.getMyd() != null && input.getMyd() > 0, CallLog::getMyd, input.getMyd());
57
         qw.eq(!StringHelper.isEmpty(input.getWorkordercode()), CallLog::getWorkordercode, input.getWorkordercode());
62
         qw.eq(!StringHelper.isEmpty(input.getWorkordercode()), CallLog::getWorkordercode, input.getWorkordercode());
58
         qw.orderByDesc(CallLog::getId);
63
         qw.orderByDesc(CallLog::getId);
64
+
59
         if (pageInput.getPageNum()==null){pageInput.setPageNum(1);}
65
         if (pageInput.getPageNum()==null){pageInput.setPageNum(1);}
60
         if (pageInput.getPageSize()==null){pageInput.setPageSize(10);}
66
         if (pageInput.getPageSize()==null){pageInput.setPageSize(10);}
61
         Page<CallLog> page = GetPage(pageInput);
67
         Page<CallLog> page = GetPage(pageInput);
81
             }
87
             }
82
         }
88
         }
83
         return Success("成功", callLogView, iPage.getTotal());
89
         return Success("成功", callLogView, iPage.getTotal());
90
+
84
     }
91
     }
85
 
92
 
93
+
94
+    @ApiOperation("导出Excel")
95
+    @Log(title = "导出excel", businessType = BusinessType.EXPORT)
96
+    @PostMapping("/exportExcel")
97
+    public void ExportExcel(CallLog input) {
98
+        LambdaQueryWrapper<CallLog> qw = new LambdaQueryWrapper<>();
99
+        qw.eq(input.getActionId() != null && input.getActionId() > 0, CallLog::getActionId, input.getActionId());
100
+        qw.eq(!StringHelper.isEmpty(input.getCallerAgent()), CallLog::getCallerAgent, input.getCallerAgent());
101
+        qw.eq(!StringHelper.isEmpty(input.getCaller()), CallLog::getCaller, input.getCaller());
102
+        qw.eq(!StringHelper.isEmpty(input.getTrunkNum()), CallLog::getTrunkNum, input.getTrunkNum());
103
+        qw.eq(!StringHelper.isEmpty(input.getCalleeAgent()), CallLog::getCalleeAgent, input.getCalleeAgent());
104
+        qw.eq(!StringHelper.isEmpty(input.getCallee()), CallLog::getCallee, input.getCallee());
105
+        qw.eq(!StringHelper.isEmpty(input.getGroupNo()), CallLog::getGroupNo, input.getGroupNo());
106
+        qw.eq(input.getCallType() != null && input.getCallType() > 0, CallLog::getCallType, input.getCallType());
107
+        qw.ge(input.getCreateTime() != null , CallLog::getCreateTime, input.getCreateTime());
108
+        qw.le(input.getEndTime() != null , CallLog::getCreateTime, input.getEndTime());
109
+        qw.eq(input.getIsAnswer() != null && input.getIsAnswer() > 0, CallLog::getIsAnswer, input.getIsAnswer());
110
+        qw.eq(input.getOpType() != null && input.getOpType() > 0, CallLog::getOpType, input.getOpType());
111
+        qw.eq(input.getMyd() != null && input.getMyd() > 0, CallLog::getMyd, input.getMyd());
112
+        qw.eq(!StringHelper.isEmpty(input.getWorkordercode()), CallLog::getWorkordercode, input.getWorkordercode());
113
+        qw.orderByDesc(CallLog::getId);
114
+
115
+        var list=calllogService.getList(qw);
116
+
117
+        List<CallLogExportView>  callLogView=  JSON.parseArray(JSON.toJSONString(list),CallLogExportView.class);
118
+        int i=0;
119
+        if (callLogView!=null && callLogView.size()>0)
120
+        {
121
+            for (CallLogExportView callLog : callLogView) {
122
+                if (callLog.getEndTime()!=null&& callLog.getCreateTime()!=null)
123
+                {
124
+                    long SECONDSDiff = ChronoUnit.SECONDS.between(callLog.getCreateTime().toInstant(), callLog.getEndTime().toInstant());
125
+                    callLog.setLongTime(SECONDSDiff);
126
+                }
127
+                if (list.get(i ).getCallType()==0)
128
+                {
129
+                    callLog.setCallTypeName("呼入");
130
+                }
131
+                else
132
+                {
133
+                    callLog.setCallTypeName("呼出");
134
+                }
135
+                if(list.get(i ).getMyd()!=null&&list.get(i ).getMyd()>0)
136
+                {
137
+                    if (list.get(i ).getMyd()==1)
138
+                    {
139
+                        callLog.setMyd("满意");
140
+                    }
141
+                    else  if (list.get(i ).getMyd()==2)
142
+                    {
143
+                        callLog.setMyd("基本满意");
144
+                    }
145
+                    else
146
+                    {
147
+                        callLog.setMyd("不满意");
148
+                    }
149
+                }
150
+
151
+                i++;
152
+            }
153
+        }
154
+        ExcelHelper<CallLogExportView> excel = new ExcelHelper<>(CallLogExportView.class);
155
+        excel.exportExcel("xlsx", callLogView);
156
+    }
157
+
158
+
86
     @ApiOperation("详情")
159
     @ApiOperation("详情")
87
     @Log(title = "查询通话记录表详情",businessType = BusinessType.QUERY)
160
     @Log(title = "查询通话记录表详情",businessType = BusinessType.QUERY)
88
     @GetMapping("/{id}")
161
     @GetMapping("/{id}")

+ 3 - 0
zxkf-api/src/main/java/api/controller/call/RecordController.java

123
             return Error("修改失败");
123
             return Error("修改失败");
124
         }
124
         }
125
     }
125
     }
126
+
127
+
128
+
126
 }
129
 }

+ 28 - 0
zxkf-api/src/main/java/api/controller/system/WorkroderTypeController.java

71
     @PostMapping
71
     @PostMapping
72
     public AjaxResult add(@RequestBody WorkroderType input) {
72
     public AjaxResult add(@RequestBody WorkroderType input) {
73
         Date currentDate = new Date(System.currentTimeMillis());
73
         Date currentDate = new Date(System.currentTimeMillis());
74
+        if (StringHelper.isEmpty(input.getTypeName()))
75
+            return Error("请输入类型名称");
76
+        if (StringHelper.isEmpty(input.getTypeCode()))
77
+            return Error("请输入类型编码");
78
+
74
         if (input.getParentId()!=null&&input.getParentId()>0)
79
         if (input.getParentId()!=null&&input.getParentId()>0)
75
         {
80
         {
76
             var model=workrodertypeService.getEntity(input.getParentId());
81
             var model=workrodertypeService.getEntity(input.getParentId());
104
     @Log(title = "编辑工单类型",businessType = BusinessType.UPDATE)
109
     @Log(title = "编辑工单类型",businessType = BusinessType.UPDATE)
105
     @PutMapping
110
     @PutMapping
106
     public AjaxResult edit(@RequestBody WorkroderType input)  {
111
     public AjaxResult edit(@RequestBody WorkroderType input)  {
112
+        if (StringHelper.isEmpty(input.getTypeName()))
113
+            return Error("请输入类型名称");
114
+        if (StringHelper.isEmpty(input.getTypeCode()))
115
+            return Error("请输入类型编码");
116
+        if (input.getId()==null)
117
+            return Error("请选择类型");
118
+        if (input.getParentId()!=null&&input.getParentId()>0)
119
+        {
120
+            var model=workrodertypeService.getEntity(input.getParentId());
121
+            if (model!=null)
122
+            {
123
+                input.setAncestors(model.getAncestors()+","+model.getId());
124
+            }
125
+            else
126
+            {
127
+                return Error("该父级分类不存在");
128
+            }
129
+        }
130
+        else
131
+        {
132
+            input.setAncestors("0");
133
+            input.setParentId(0L);
134
+        }
107
         boolean result = workrodertypeService.update(input);
135
         boolean result = workrodertypeService.update(input);
108
         if (result) {
136
         if (result) {
109
             return Success("成功");
137
             return Success("成功");

+ 58 - 0
zxkf-entity/src/main/java/api/entity/view/call/CallLogExportView.java

1
+package api.entity.view.call;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+import java.util.Date;
9
+@Data
10
+public class CallLogExportView {
11
+    @ApiModelProperty("坐席工号")
12
+    private String callerAgent;
13
+    /** 主叫号码,分机号或者手机号 */
14
+    @ApiModelProperty("电话号码")
15
+    private String caller;
16
+    /** 中继号,手机号呼入系统时拨打号码(底号) */
17
+    @ApiModelProperty("底号")
18
+    private String trunkNum;
19
+    /** 被叫坐席工号,分机为被叫且签入才会有值,否则为空 */
20
+    @ApiModelProperty("被叫坐席工号")
21
+    private String calleeAgent;
22
+    /** 被叫号码,分机号或手机号 */
23
+    @ApiModelProperty("被叫号码")
24
+    private String callee;
25
+
26
+    /** 呼叫类型,0呼入(外线即手机号打进系统),1呼出 */
27
+    @ApiModelProperty("呼叫类型")
28
+    private String callTypeName;
29
+    /** 呼入系统时间 */
30
+    @ApiModelProperty("呼入系统时间")
31
+    private Date createTime;
32
+    /** 被叫振铃时间 */
33
+    @ApiModelProperty("被叫振铃时间")
34
+    private Date ringTime;
35
+    /** 被叫应答时间 */
36
+    @ApiModelProperty("被叫应答时间")
37
+    private Date answerTime;
38
+    /** 被叫是否接听 */
39
+    @ApiModelProperty("被叫是否接听")
40
+    private Long isAnswer;
41
+    /** 坐席挂机时间 */
42
+    @ApiModelProperty("坐席挂机时间")
43
+    private Date endTime;
44
+    /** 外线挂机时间 */
45
+    @ApiModelProperty("外线挂机时间")
46
+    private Date hangupTime;
47
+
48
+    @ApiModelProperty("通话时长")
49
+    private long longTime;
50
+
51
+    /** 满意度,1,2,3 */
52
+    @ApiModelProperty("满意度")
53
+    private String myd;
54
+    /** 工单号 */
55
+    @ApiModelProperty("工单号")
56
+    private String workordercode;
57
+
58
+}

+ 133 - 0
zxkf-util/src/main/java/api/util/helper/ExcelHelper.java

14
 import java.math.BigDecimal;
14
 import java.math.BigDecimal;
15
 import java.text.DecimalFormat;
15
 import java.text.DecimalFormat;
16
 import java.text.SimpleDateFormat;
16
 import java.text.SimpleDateFormat;
17
+import java.time.temporal.ChronoUnit;
17
 import java.util.*;
18
 import java.util.*;
18
 
19
 
19
 @Slf4j
20
 @Slf4j
361
     }
362
     }
362
 
363
 
363
     /**
364
     /**
365
+     * 创建sheet
366
+     * @param wb
367
+     * @param
368
+     */
369
+    private Sheet createSheet(Workbook wb,List<String > filedMap,CellStyle style){
370
+        Sheet sheet = wb.createSheet();
371
+        Row headerRow = sheet.createRow(0);
372
+        headerRow.setHeightInPoints(16);
373
+        int i=0;
374
+        for (String cols : filedMap) {
375
+            Cell cell = headerRow.createCell(i);
376
+            cell.setCellValue(cols);
377
+            cell.setCellStyle(style);
378
+            i++;
379
+        }
380
+
381
+        return sheet;
382
+    }
383
+
384
+    /**
364
      * 创建行
385
      * 创建行
365
      * @param sheet
386
      * @param sheet
366
      * @param rowindex
387
      * @param rowindex
397
             i++;
418
             i++;
398
         }
419
         }
399
     }
420
     }
421
+
422
+    private void createRow(Sheet sheet,int rowindex,List<String > filedMap,List<T> list,CellStyle style)
423
+    {
424
+
425
+
426
+        for(int i = 0; i < list.size() ;i++){
427
+
428
+            Row row = sheet.createRow(rowindex);
429
+            row.setHeightInPoints(16);
430
+            //反射得到所有属性
431
+            Class cls = list.get(i).getClass();
432
+            Field[] fields = cls.getDeclaredFields();
433
+            for(int k = 0 ; k < filedMap.size() ; k++) {
434
+                for (Field field : fields) {
435
+                    //得到属性
436
+                    //打开私有访问
437
+                    field.setAccessible(true);
438
+                    //获取属性
439
+                    Object obj = null;
440
+                    try {
441
+                        obj = field.get(list.get(i));
442
+                    } catch (IllegalAccessException e) {
443
+                        e.printStackTrace();
444
+                    }
445
+                    Cell cell = row.createCell(k);
446
+                    cell.setCellStyle(style);
447
+                    if (obj != null) {
448
+                        if (Date.class == field.getType()) {
449
+                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
450
+                            String value = format.format((Date) obj);
451
+                            cell.setCellValue(value);
452
+                        } else {
453
+                            cell.setCellValue(obj.toString());
454
+                        }
455
+                    }else {
456
+                        cell.setCellValue("");
457
+                    }
458
+
459
+
460
+                    }
461
+                }
462
+            rowindex++;
463
+            }
464
+    }
465
+
466
+
467
+    public void ExportToExcel(String suffix,List<String> cols, List<T> list, String title) {
468
+        HttpServletResponse response=ServletHelper.getResponse();
469
+        try {
470
+            Workbook wb = new HSSFWorkbook();
471
+            if (suffix == "xlsx") {
472
+                wb = new XSSFWorkbook();
473
+            }
474
+            if(suffix!="xls"&&suffix!="xlsx") {
475
+                suffix = "xls";
476
+            }
477
+
478
+            CellStyle titleStyle = wb.createCellStyle(); // 标题样式
479
+            titleStyle.setAlignment(HorizontalAlignment.CENTER);
480
+            Font titleFont = wb.createFont(); // 创建字体样式
481
+            titleFont.setBold(true); // 字体加粗
482
+            titleFont.setFontName("Times New Roman"); // 设置字体类型
483
+            titleFont.setFontHeightInPoints((short) 18); // 设置字体大小
484
+            titleStyle.setFont(titleFont); // 为标题样式设置字体样式
485
+
486
+            CellStyle headerCellStyle = wb.createCellStyle();
487
+            headerCellStyle.setBorderTop(BorderStyle.THIN);
488
+            headerCellStyle.setBorderBottom(BorderStyle.THIN);
489
+            headerCellStyle.setBorderLeft(BorderStyle.THIN);
490
+            headerCellStyle.setBorderRight(BorderStyle.THIN);
491
+            Font headerFont = wb.createFont(); // 创建字体样式
492
+            headerFont.setBold(true); // 字体加粗
493
+            headerCellStyle.setFont(headerFont);
494
+            headerCellStyle.setAlignment(HorizontalAlignment.CENTER);
495
+
496
+            Sheet sheet = createSheet(wb, cols, headerCellStyle);
497
+
498
+            CellStyle cellStyle = wb.createCellStyle();
499
+            cellStyle.setBorderTop(BorderStyle.THIN);
500
+            cellStyle.setBorderBottom(BorderStyle.THIN);
501
+            cellStyle.setBorderLeft(BorderStyle.THIN);
502
+            cellStyle.setBorderRight(BorderStyle.THIN);
503
+            createRow(sheet, 1,cols,list, cellStyle);
504
+            if (StringHelper.isEmpty(title)) {
505
+                title = System.currentTimeMillis() + "";
506
+            }
507
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
508
+            response.setHeader("Content-disposition", "attachment;filename=" + title + "."+suffix);
509
+            response.setCharacterEncoding("utf-8");
510
+            wb.write(response.getOutputStream());
511
+        } catch (Exception e) {
512
+            log.error("导出excel异常", e);
513
+
514
+            Map map = new HashMap();
515
+            map.put("state", "error");
516
+            map.put("message", "导出失败");
517
+
518
+            try {
519
+                PrintWriter out = response.getWriter();
520
+                out.write(JSON.toJSONString(map));
521
+                out.flush();
522
+                out.close();
523
+            } catch (IOException ex) {
524
+                throw new RuntimeException(ex);
525
+            }
526
+        }
527
+    }
528
+
529
+
530
+
531
+
532
+
400
 }
533
 }