Pu Zhibing
2025-01-01 a4080268cca54be0629269b71c4ebf411c913dec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
package com.stylefeng.guns.modular.system.service.impl;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.dao.TaskDetailMapper;
import com.stylefeng.guns.modular.system.model.PatrolTask;
import com.stylefeng.guns.modular.system.model.TaskDetail;
import com.stylefeng.guns.modular.system.model.TaskDetailVehicles;
import com.stylefeng.guns.modular.system.model.TaskDetailVehiclesChannel;
import com.stylefeng.guns.modular.system.model.enums.VideoChannelEnum;
import com.stylefeng.guns.modular.system.model.vo.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.ExcelUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.IOUtils;
import org.quartz.JobKey;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;
 
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @author zhibing.pu
 * @Date 2024/12/17 20:23
 */
@Service
public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDetail> implements ITaskDetailService {
    
    
    @Autowired
    private QuartzUtil quartzUtil;
    
    @Autowired
    private IPatrolTaskService patrolTaskService;
    
    @Autowired
    private ITaskDetailVehiclesService taskDetailVehiclesService;
    
    @Autowired
    private ITaskDetailVehiclesChannelService taskDetailVehiclesChannelService;
    
    @Autowired
    private IUserService userService;
    
    
    
    
    
    
    /**
     * 获取巡查任务列表数据
     * @param vo
     * @return
     */
    @Override
    public List<TaskDetailList> getTaskDetailList(Page<TaskDetailList> pageInfo, TaskDetailListVo vo) {
        return this.baseMapper.getTaskDetailList(pageInfo, vo);
    }
    
    
    /**
     * 删除任务
     * @param ids
     */
    @Override
    public void delTaskDetail(List<String> ids) {
        this.baseMapper.deleteBatchIds(ids);
        List<TaskDetail> taskDetails = this.selectBatchIds(ids);
        for (TaskDetail taskDetail : taskDetails) {
            JobKey jobKey = new JobKey(taskDetail.getId().toString());
            quartzUtil.deleteQuartzTask(jobKey);
        }
    }
    
    /**
     * 获取任务记录列表
     * @param pageInfo
     * @param vo
     * @return
     */
    @Override
    public List<TaskRecordList> getTaskRecordList(Page<TaskRecordList> pageInfo, TaskRecordListVo vo) {
        return this.baseMapper.getTaskRecordList(pageInfo, vo);
    }
    
    
    /**
     * 获取任务记录详情
     * @param id
     * @return
     */
    @Override
    public TaskRecordInfo getTaskRecordInfo(Integer id) {
        TaskDetail taskDetail = this.selectById(id);
        TaskRecordInfo info = new TaskRecordInfo();
        info.setId(id);
        List<TaskDetailVehicles> taskDetailVehiclesList = taskDetailVehiclesService.selectList(new EntityWrapper<TaskDetailVehicles>().eq("task_detail_id", id));
        info.setVehicleNum(taskDetailVehiclesList.size());
        long unexecutedQuantity = taskDetailVehiclesList.stream().filter(s -> s.getStatus() == 1).count();
        info.setUnexecutedQuantity(unexecutedQuantity);
        PatrolTask patrolTask = patrolTaskService.selectById(taskDetail.getPatrolTaskId());
        info.setType(patrolTask.getType());
        info.setName(patrolTask.getName());
        info.setStatus(taskDetail.getStatus());
        info.setExecutionTime(taskDetail.getExecutionTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        //执行状态(1=待执行,2=执行中,3=成功,4=离线,5=失败)
        long offlineNum = taskDetailVehiclesList.stream().filter(s -> s.getStatus() == 4).count();
        info.setOfflineNum(offlineNum);
        long normalNum = taskDetailVehiclesList.stream().filter(s -> s.getStatus() == 3).count();
        info.setNormalNum(normalNum);
        long abnormalNum = taskDetailVehiclesList.stream().filter(s -> s.getStatus() == 5).count();
        info.setAbnormalNum(abnormalNum);
        long underway = taskDetailVehiclesList.stream().filter(s -> s.getStatus() == 2).count();
        info.setUnderway(underway);
        return info;
    }
    
    
    /**
     * 获取任务记录中的车船数据
     * @param vo
     * @return
     */
    @Override
    public PictureDetailsVehicle getPictureDetailsVehicle(PictureDetailsVo vo) {
        PictureDetailsVehicle info = new PictureDetailsVehicle();
        Wrapper<TaskDetailVehicles> wrapper = new EntityWrapper<TaskDetailVehicles>().eq("task_detail_id", vo.getId());
        if(ToolUtil.isNotEmpty(vo.getVehicle())){
            JSONArray jsonArray = JSON.parseArray(vo.getVehicle());
            List<String> vehicleIdList = new ArrayList<>();
            for (int i = 0; i < jsonArray.size(); i++) {
                Integer vehicleId = jsonArray.getJSONObject(i).getInteger("vehicleId");
                Integer vehicleType = jsonArray.getJSONObject(i).getInteger("vehicleType");
                vehicleIdList.add(vehicleId + "_" + vehicleType);
            }
            wrapper.in("vehicleIdUnique", vehicleIdList);
        }
        if(null != vo.getStatus()){
            wrapper.eq("status", vo.getStatus());
        }
        if(null != vo.getSysStatus()){
            List<TaskDetailVehiclesChannel> sys_status = taskDetailVehiclesChannelService.selectList(new EntityWrapper<TaskDetailVehiclesChannel>().eq("sys_status", vo.getSysStatus()));
            List<Integer> collect = sys_status.stream().map(TaskDetailVehiclesChannel::getTaskDetailVehiclesId).collect(Collectors.toList());
            if(collect.size() == 0){
                collect.add(-1);
            }
            wrapper.in("id", collect);
        }
        if(null != vo.getArtificialStatus()){
            List<TaskDetailVehiclesChannel> sys_status = taskDetailVehiclesChannelService.selectList(new EntityWrapper<TaskDetailVehiclesChannel>().eq("artificial_status", vo.getArtificialStatus()));
            List<Integer> collect = sys_status.stream().map(TaskDetailVehiclesChannel::getTaskDetailVehiclesId).collect(Collectors.toList());
            if(collect.size() == 0){
                collect.add(-1);
            }
            wrapper.in("id", collect);
        }
        
        List<TaskDetailVehicles> taskDetailVehiclesList = taskDetailVehiclesService.selectList(wrapper);
        List<TaskDetailVehicles> vehiclesList = taskDetailVehiclesList.stream().filter(s -> s.getVehicleType() == 1).collect(Collectors.toList());
        List<VehicleVo> vehicle = new ArrayList<>();
        for (TaskDetailVehicles taskDetailVehicles : vehiclesList) {
            VehicleVo vehicleVo = new VehicleVo();
            BeanUtils.copyProperties(taskDetailVehicles, vehicleVo);
            vehicle.add(vehicleVo);
        }
        info.setVehicle(vehicle);
        List<TaskDetailVehicles> shipList = taskDetailVehiclesList.stream().filter(s -> s.getVehicleType() == 2).collect(Collectors.toList());
        List<VehicleVo> ship = new ArrayList<>();
        for (TaskDetailVehicles taskDetailVehicles : shipList) {
            VehicleVo vehicleVo = new VehicleVo();
            BeanUtils.copyProperties(taskDetailVehicles, vehicleVo);
            ship.add(vehicleVo);
        }
        info.setShip(ship);
        return info;
    }
    
    
    
    
    /**
     * 获取任务记录详情中的通道数据
     * @param vo
     * @return
     */
    @Override
    public List<PictureDetails> getPictureDetails(Page<PictureDetails> pageInfo, PictureDetailsVo vo) {
        Wrapper<TaskDetailVehicles> wrapper = new EntityWrapper<TaskDetailVehicles>().eq("task_detail_id", vo.getId());
        if(ToolUtil.isNotEmpty(vo.getVehicle())){
            JSONArray jsonArray = JSON.parseArray(vo.getVehicle());
            List<String> vehicleIdList = new ArrayList<>();
            for (int i = 0; i < jsonArray.size(); i++) {
                Integer vehicleId = jsonArray.getJSONObject(i).getInteger("vehicleId");
                Integer vehicleType = jsonArray.getJSONObject(i).getInteger("vehicleType");
                vehicleIdList.add(vehicleId + "_" + vehicleType);
            }
            wrapper.in("vehicleIdUnique", vehicleIdList);
        }
        if(null != vo.getStatus()){
            wrapper.eq("status", vo.getStatus());
        }
        List<TaskDetailVehicles> taskDetailVehiclesList = taskDetailVehiclesService.selectList(wrapper);
        List<Integer> collect = taskDetailVehiclesList.stream().map(TaskDetailVehicles::getId).collect(Collectors.toList());
        if(collect.size() > 0){
            collect.add(-1);
        }
        List<PictureDetails> pictureDetails = taskDetailVehiclesChannelService.getPictureDetails(pageInfo, collect, vo.getSysStatus(), vo.getArtificialStatus());
        for (PictureDetails pictureDetail : pictureDetails) {
            String videoChannel = pictureDetail.getVideoChannel();
            String name = VideoChannelEnum.getName(Integer.valueOf(videoChannel));
            pictureDetail.setVideoChannel(name);
        }
        return pictureDetails;
    }
    
    
    /**
     * 人工审核
     * @param vo
     * @return
     */
    @Override
    public ResultUtil manualAudit(ManualAuditVo vo, String userId) {
        List<TaskDetailVehiclesChannel> taskDetailVehiclesChannels = taskDetailVehiclesChannelService.selectBatchIds(vo.getId());
        for (TaskDetailVehiclesChannel taskDetailVehiclesChannel : taskDetailVehiclesChannels) {
            if(null != taskDetailVehiclesChannel.getArtificialStatus() && 1 != taskDetailVehiclesChannel.getArtificialStatus()){
                return ResultUtil.error("不能重复审核");
            }
            taskDetailVehiclesChannel.setArtificialStatus(vo.getStatus());
            taskDetailVehiclesChannel.setRemark(vo.getRemark());
            taskDetailVehiclesChannel.setArtificialCreateTime(LocalDateTime.now());
            taskDetailVehiclesChannel.setArtificialUserId(Integer.valueOf(userId));
            taskDetailVehiclesChannelService.updateById(taskDetailVehiclesChannel);
        }
        return ResultUtil.success();
    }
    
    
    /**
     * 下载任务记录数据
     * @param ids
     * @param code
     * @param status
     * @param response
     */
    @Override
    public void downloadTaskRecord(List<String> ids, String code, Integer status, HttpServletResponse response) {
        List<Map<String, Object>> mapList = this.baseMapper.getDownloadTaskRecord(ids, code, status);
        try {
            HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
            HSSFSheet hssfSheet = hssfWorkbook.createSheet();
            hssfSheet.setDefaultColumnWidth(20);
            hssfSheet.setDefaultRowHeight((short) 800);
            //设置单元格合并
            for (int i = 0; i < 10; i++) {
                CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 1, i, i);
                hssfSheet.addMergedRegion(cellRangeAddress);
            }
            CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 0, 10, 16);
            hssfSheet.addMergedRegion(cellRangeAddress);
            // 创建单元格样式
            HSSFCellStyle style = hssfWorkbook.createCellStyle();
            style.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
            style.setAlignment(HorizontalAlignment.CENTER); // 水平居中
            HSSFFont font = hssfWorkbook.createFont();
            font.setBold(true);
            style.setFont(font);
            
            HSSFCellStyle style1 = hssfWorkbook.createCellStyle();
            style1.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
            style1.setAlignment(HorizontalAlignment.CENTER); // 水平居中
            
            HSSFRow hssfRow = hssfSheet.createRow(0);//设置第一行数据(标题)
            List<String> titles = Arrays.asList("序号", "任务名称", "任务类型", "执行时间", "执行状态", "车牌号", "运输公司", "年审有效期", "巡检状态", "车辆轨迹图片", "货箱通道");
            for (int l = 0; l < titles.size(); l++) {
                HSSFCell hssfCell = hssfRow.createCell(l);
                hssfCell.setCellType(CellType.STRING);//设置表格类型
                hssfCell.setCellStyle(style);
                hssfCell.setCellValue(titles.get(l));
            }
            hssfRow = hssfSheet.createRow(1);//设置第一行数据(标题)
            titles = Arrays.asList("图片", "系统审核", "系统审核时间", "人工审核", "审核意见", "审核人", "审核时间");
            for (int l = 0; l < titles.size(); l++) {
                HSSFCell hssfCell = hssfRow.createCell(l + 10);
                hssfCell.setCellType(CellType.STRING);//设置表格类型
                hssfCell.setCellStyle(style);
                hssfCell.setCellValue(titles.get(l));
            }
            
            HSSFPatriarch patriarch = hssfSheet.createDrawingPatriarch();
            for (int i = 0; i < mapList.size(); i++) {
                hssfRow = hssfSheet.createRow(i + 2);
                
                Map<String, Object> map = mapList.get(i);
                //序号
                HSSFCell hssfCell = hssfRow.createCell(0);
                hssfCell.setCellType(CellType.STRING);//设置表格类型
                hssfCell.setCellStyle(style1);
                hssfCell.setCellValue(i + 1);
                //任务名称
                HSSFCell hssfCell1 = hssfRow.createCell(1);
                hssfCell1.setCellType(CellType.STRING);//设置表格类型
                hssfCell1.setCellStyle(style1);
                hssfCell1.setCellValue("");
                if(null != map.get("name")){
                    hssfCell1.setCellValue(map.get("name").toString());
                }
                //任务类型
                HSSFCell hssfCell2 = hssfRow.createCell(2);
                hssfCell2.setCellType(CellType.STRING);//设置表格类型
                hssfCell2.setCellStyle(style1);
                hssfCell2.setCellValue("");
                if(null != map.get("taskType")){
                    hssfCell2.setCellValue(map.get("taskType").toString());
                }
                //执行时间
                HSSFCell hssfCell3 = hssfRow.createCell(3);
                hssfCell3.setCellType(CellType.STRING);//设置表格类型
                hssfCell3.setCellStyle(style1);
                hssfCell3.setCellValue("");
                if(null != map.get("executionTime")){
                    hssfCell3.setCellValue(map.get("executionTime").toString());
                }
                //执行状态
                HSSFCell hssfCell4 = hssfRow.createCell(4);
                hssfCell4.setCellType(CellType.STRING);//设置表格类型
                hssfCell4.setCellStyle(style1);
                hssfCell4.setCellValue("");
                if(null != map.get("status")){
                    Integer status1 = Integer.valueOf(map.get("status").toString());
                    //执行状态(1=待执行,2=进行中,3=成功,4=失败)
                    hssfCell4.setCellValue(1 == status1 ? "待执行" : 2 == status1 ? "进行中" : 3 == status1 ? "成功" : "失败");
                }
                //车牌号
                HSSFCell hssfCell5 = hssfRow.createCell(5);
                hssfCell5.setCellType(CellType.STRING);//设置表格类型
                hssfCell5.setCellStyle(style1);
                hssfCell5.setCellValue("");
                if(null != map.get("vehicleNum")){
                    hssfCell5.setCellValue(map.get("vehicleNum").toString());
                }
                //运输公司
                HSSFCell hssfCell6 = hssfRow.createCell(6);
                hssfCell6.setCellType(CellType.STRING);//设置表格类型
                hssfCell6.setCellStyle(style1);
                hssfCell6.setCellValue("");
                if(null != map.get("companyName")){
                    hssfCell6.setCellValue(map.get("companyName").toString());
                }
                //年审有效期
                HSSFCell hssfCell7 = hssfRow.createCell(7);
                hssfCell7.setCellType(CellType.STRING);//设置表格类型
                hssfCell7.setCellStyle(style1);
                hssfCell7.setCellValue("");
                if(null != map.get("inspectPeriodEnd")){
                    hssfCell7.setCellValue(map.get("inspectPeriodEnd").toString());
                }
                //巡检状态
                HSSFCell hssfCell8 = hssfRow.createCell(8);
                hssfCell8.setCellType(CellType.STRING);//设置表格类型
                hssfCell8.setCellStyle(style1);
                hssfCell8.setCellValue("");
                if(null != map.get("vehiclesStatus")){
                    //审核状态(1=未执行,2=正常,3=异常)
                    Integer vehiclesStatus = Integer.valueOf(map.get("vehiclesStatus").toString());
                    hssfCell8.setCellValue(1 == vehiclesStatus ? "未执行" : 2 == vehiclesStatus ? "正常" : "异常");
                }
                //车辆轨迹图片
                HSSFCell hssfCell9 = hssfRow.createCell(9);
                hssfCell9.setCellType(CellType.STRING);//设置表格类型
                hssfCell9.setCellStyle(style1);
                hssfCell9.setCellValue("");
                //图片
                if(null != map.get("imageUrl")){
                    try {
                        URL url = new URL(map.get("imageUrl").toString());
                        URLConnection urlConnection = url.openConnection();
                        urlConnection.connect();
                        InputStream inputStream = urlConnection.getInputStream();
                        byte[] bytes = IOUtils.toByteArray(inputStream);
                        int pictureIdx = hssfWorkbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
                        inputStream.close();
                        
                        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) 10, i + 2, (short) 11, i + 3);
                        //在Excel中添加图片
                        HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx);
                        //设置图片尺寸
                        //picture.resize(0.5, 0.18);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }else{
                    HSSFCell hssfCell10 = hssfRow.createCell(10);
                    hssfCell10.setCellType(CellType.STRING);//设置表格类型
                    hssfCell10.setCellStyle(style1);
                    hssfCell10.setCellValue("");
                }
                //系统审核
                HSSFCell hssfCell11 = hssfRow.createCell(11);
                hssfCell11.setCellType(CellType.STRING);//设置表格类型
                hssfCell11.setCellStyle(style1);
                hssfCell11.setCellValue("");
                if(null != map.get("sysStatus")){
                    //系统审核状态(1=未执行,2=正常,3=异常)
                    Integer sysStatus = Integer.valueOf(map.get("sysStatus").toString());
                    hssfCell11.setCellValue(1 == sysStatus ? "未执行" : 2 == sysStatus ? "正常" : "异常");
                }
                //系统审核时间
                HSSFCell hssfCell12 = hssfRow.createCell(12);
                hssfCell12.setCellType(CellType.STRING);//设置表格类型
                hssfCell12.setCellStyle(style1);
                hssfCell12.setCellValue("");
                if(null != map.get("sysCreateTime")){
                    hssfCell12.setCellValue(map.get("sysCreateTime").toString());
                }
                //人工审核
                HSSFCell hssfCell13 = hssfRow.createCell(13);
                hssfCell13.setCellType(CellType.STRING);//设置表格类型
                hssfCell13.setCellStyle(style1);
                hssfCell13.setCellValue("");
                if(null != map.get("artificialStatus")){
                    //人工审核状态(1=未执行,2=正常,3=异常)
                    Integer artificialStatus = Integer.valueOf(map.get("artificialStatus").toString());
                    hssfCell13.setCellValue(1 == artificialStatus ? "未执行" : 2 == artificialStatus ? "正常" : "异常");
                }
                //审核意见
                HSSFCell hssfCell14 = hssfRow.createCell(14);
                hssfCell14.setCellType(CellType.STRING);//设置表格类型
                hssfCell14.setCellStyle(style1);
                hssfCell14.setCellValue("");
                if(null != map.get("remark")){
                    hssfCell14.setCellValue(map.get("remark").toString());
                }
                //审核人
                HSSFCell hssfCell15 = hssfRow.createCell(15);
                hssfCell15.setCellType(CellType.STRING);//设置表格类型
                hssfCell15.setCellStyle(style1);
                hssfCell15.setCellValue("");
                if(null != map.get("artificialUser")){
                    hssfCell15.setCellValue(map.get("artificialUser").toString());
                }
                //审核时间
                HSSFCell hssfCell16 = hssfRow.createCell(16);
                hssfCell16.setCellType(CellType.STRING);//设置表格类型
                hssfCell16.setCellStyle(style1);
                hssfCell16.setCellValue("");
                if(null != map.get("artificialCreateTime")){
                    hssfCell16.setCellValue(map.get("artificialCreateTime").toString());
                }
            }
            
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("任务记录(" + sdf.format(new Date()) + ").xls", "utf-8"));
            response.setContentType("application/vnd.ms-excel");
            ServletOutputStream out = response.getOutputStream();
            hssfWorkbook.write(out);
            out.flush();
            out.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}