songhuangfeng123
2022-09-16 f4994092d9b3c6dcb60aaa0672eb283245ff5d8c
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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
package com.gkhy.safePlatform.equipment.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
import com.gkhy.safePlatform.equipment.entity.*;
import com.gkhy.safePlatform.equipment.enums.EquipmentLifeCycleEnum;
import com.gkhy.safePlatform.equipment.enums.EquipmentRepairStatusEnum;
import com.gkhy.safePlatform.equipment.enums.EquipmentResultCodes;
import com.gkhy.safePlatform.equipment.enums.EquipmentStopStatusEnum;
import com.gkhy.safePlatform.equipment.excepiton.EquipmentException;
import com.gkhy.safePlatform.equipment.model.dto.req.*;
import com.gkhy.safePlatform.equipment.model.dto.resp.EquipmentInfoDto;
import com.gkhy.safePlatform.equipment.model.dto.resp.EquipmentInfoExcel;
import com.gkhy.safePlatform.equipment.repository.EquipmentInfoRepository;
import com.gkhy.safePlatform.equipment.repository.EquipmentTypeMngRepository;
import com.gkhy.safePlatform.equipment.service.*;
import com.gkhy.safePlatform.equipment.service.baseService.*;
import com.gkhy.safePlatform.equipment.utils.DateUtils;
import com.gkhy.safePlatform.equipment.utils.QueryHelpPlus;
import com.gkhy.safePlatform.equipment.utils.poihelper.ExcelLogs;
import com.gkhy.safePlatform.equipment.utils.poihelper.ExcelUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 设备设施详细信息(EquipmentInfo)表服务实现类
 *
 * @author xurui
 * @since 2022-07-19 14:02:50
 */
@Service("equipmentInfoService")
public class EquipmentInfoServiceImpl implements EquipmentInfoService {
 
    @Autowired
    private EquipmentInfoBaseService equipmentInfoBaseService;
 
    @Autowired
    private EquipmentTakecareDetailBaseService equipmentTakecareDetailBaseService;
 
    @Autowired
    private EquipmentTestDetailBaseService equipmentTestDetailBaseService;
 
    @Autowired
    private EquipmentRepairDetailBaseService equipmentRepairDetailBaseService;
 
    @Autowired
    private EquipmentTakecareStardardDetailBaseService equipmentTakecareStardardDetailBaseService;
 
    @Autowired
    private EquipmentCheckStandardDetailBaseService equipmentCheckStandardDetailBaseService;
 
    @DubboReference(check = false)
    private AccountDepartmentService accountDepartmentService;
 
    @Autowired
    private EquipmentTypeMngRepository equipmentTypeMngRepository;
 
    @Autowired
    public HttpServletResponse response;
 
    @Override
    public ResultVO queryAll(PageQuery<EquipmentInfoQueryCriteria> pageQuery) {
        if(pageQuery.getSearchParams().getInfoType() == null){
            return new ResultVO<>(ResultCodes.CLIENT_PARAM_ILLEGAL,"缺少infoType");
        }
 
        PageUtils.checkCheck(pageQuery);
 
        Long pageIndex = pageQuery.getPageIndex();
        Long pageSize = pageQuery.getPageSize();
        IPage<EquipmentInfo> page = new Page<>(pageIndex, pageSize);
 
        page = equipmentInfoBaseService.selectPage(page,
                QueryHelpPlus.getPredicate(EquipmentInfo.class, pageQuery.getSearchParams()));
        List<EquipmentInfoDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), EquipmentInfoDto.class);
 
        //获取额外信息
        respList.forEach(f->{
            //设备保养
            EquipmentTakecareDetailQueryCriteria criteria = new EquipmentTakecareDetailQueryCriteria();
            criteria.setEquipmentId(f.getId());
            criteria.setInfoTpe(pageQuery.getSearchParams().getInfoType());
            List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailBaseService.queryAll(criteria);
            f.setTakecareDetailList(takecareDetailList);
 
            //设备检测
            EquipmentTestDetailQueryCriteria criteria1 = new EquipmentTestDetailQueryCriteria();
            criteria1.setEquipmentId(f.getId());
            criteria1.setInfoTpe(pageQuery.getSearchParams().getInfoType());
            List<EquipmentTestDetail> testDetailList = equipmentTestDetailBaseService.queryAll(criteria1);
            f.setTestDetailList(testDetailList);
 
            //设备检查 TODO
 
 
            //设备维修
            EquipmentRepairDetailQueryCriteria criteria2 = new EquipmentRepairDetailQueryCriteria();
            criteria2.setEquipmentId(f.getId());
            criteria2.setInfoTpe(pageQuery.getSearchParams().getInfoType());
            List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailBaseService.queryAll(criteria2);
            f.setRepaireDetailList(repairDetailList);
 
 
            // --------------------------- 获取部门信息-----------------------
            //收集所用到的部门ID
            Set<Long> collectDepIdSet = new HashSet();
            collectDepIdSet.add(f.getDepartmentId());
            collectDepIdSet.add(f.getLeadingDepartmentId());
            collectDepIdSet.add(f.getLeadingPersonDepartmentId());
            takecareDetailList.forEach(info->{collectDepIdSet.add(info.getLeadingPersonDepartmentId());});
            testDetailList.forEach(info->{collectDepIdSet.add(info.getTestPersonDepartmentId());});
            repairDetailList.forEach(info->{collectDepIdSet.add(info.getRepairPersonDepartmentId());});
 
            //获取部门名集合
            Map<Long,String> depNameMap = getDepName(collectDepIdSet);
 
            //set
            f.setDepartmentName(depNameMap.get(f.getDepartmentId()));
            f.setLeadingDepartmentName(depNameMap.get(f.getLeadingDepartmentId()));
            f.setLeadingPersonDepartmentName(depNameMap.get(f.getLeadingPersonDepartmentId()));
            takecareDetailList.forEach(info->{info.setLeadingPersonDepartmentName(depNameMap.get(info.getLeadingPersonDepartmentId()));});
            testDetailList.forEach(info->{info.setTestPersonDepartmentName(depNameMap.get(info.getTestPersonDepartmentId()));});
            repairDetailList.forEach(info->{info.setRepairPersonDepartmentName(depNameMap.get(info.getRepairPersonDepartmentId()));});
 
        });
        return new SearchResultVO<>(
                true,
                pageIndex,
                pageSize,page.getPages(),
                page.getTotal(),
                respList,
                ResultCodes.OK
        );
    }
 
 
    @Override
    public List<EquipmentInfo> queryAll(EquipmentInfoQueryCriteria criteria) {
        return equipmentInfoBaseService.queryAll(criteria);
    }
 
    @Override
    public EquipmentInfoDto selectOne(Serializable id) {
        EquipmentInfo equipmentInfo = equipmentInfoBaseService.getById(id);
        if(equipmentInfo == null){
            return null;
        }
 
        EquipmentInfoDto infoDto = BeanCopyUtils.copyBean(equipmentInfo, EquipmentInfoDto.class);
 
        //设备保养
        EquipmentTakecareDetailQueryCriteria criteria = new EquipmentTakecareDetailQueryCriteria();
        criteria.setEquipmentId(infoDto.getId());
        criteria.setInfoTpe(infoDto.getInfoType());
        List<EquipmentTakecareDetail> takecareDetailList = equipmentTakecareDetailBaseService.queryAll(criteria);
        infoDto.setTakecareDetailList(takecareDetailList);
 
        //设备检测
        EquipmentTestDetailQueryCriteria criteria1 = new EquipmentTestDetailQueryCriteria();
        criteria1.setEquipmentId(infoDto.getId());
        criteria1.setInfoTpe(infoDto.getInfoType());
        List<EquipmentTestDetail> testDetailList = equipmentTestDetailBaseService.queryAll(criteria1);
        infoDto.setTestDetailList(testDetailList);
 
        //设备检查 TODO
 
 
        //设备维修
        EquipmentRepairDetailQueryCriteria criteria2 = new EquipmentRepairDetailQueryCriteria();
        criteria2.setEquipmentId(infoDto.getId());
        criteria2.setInfoTpe(infoDto.getInfoType());
        List<EquipmentRepairDetail> repairDetailList = equipmentRepairDetailBaseService.queryAll(criteria2);
        infoDto.setRepaireDetailList(repairDetailList);
 
        //检查标准
        EquipmentCheckStandardDetailQueryCriteria criteria3 = new EquipmentCheckStandardDetailQueryCriteria();
        criteria3.setEquipmentId(infoDto.getId());
        criteria3.setInfoTpe(infoDto.getInfoType());
        List<EquipmentCheckStandardDetail> checkStandardDetailList = equipmentCheckStandardDetailBaseService.queryAll(criteria3);
        infoDto.setCheckStandardeDetailList(checkStandardDetailList);
 
        //保养标准
        EquipmentTakecareStardardDetailQueryCriteria criteria4 = new EquipmentTakecareStardardDetailQueryCriteria();
        criteria4.setEquipmentId(infoDto.getId());
        criteria4.setInfoTpe(infoDto.getInfoType());
        List<EquipmentTakecareStardardDetail> takecareStardardDetailList = equipmentTakecareStardardDetailBaseService.queryAll(criteria4);
        infoDto.setTakecareStardardeDetailList(takecareStardardDetailList);
 
 
        // --------------------------- 获取部门信息-----------------------
        //收集所用到的部门ID
        Set<Long> collectDepIdSet = new HashSet();
        collectDepIdSet.add(infoDto.getDepartmentId());
        collectDepIdSet.add(infoDto.getLeadingDepartmentId());
        collectDepIdSet.add(infoDto.getLeadingPersonDepartmentId());
        takecareDetailList.forEach(info->{collectDepIdSet.add(info.getLeadingPersonDepartmentId());});
        testDetailList.forEach(info->{collectDepIdSet.add(info.getTestPersonDepartmentId());});
        repairDetailList.forEach(info->{collectDepIdSet.add(info.getRepairPersonDepartmentId());});
 
        //获取部门名集合
        Map<Long,String> depNameMap = getDepName(collectDepIdSet);
 
        //set
        infoDto.setDepartmentName(depNameMap.get(infoDto.getDepartmentId()));
        infoDto.setLeadingDepartmentName(depNameMap.get(infoDto.getLeadingDepartmentId()));
        infoDto.setLeadingPersonDepartmentName(depNameMap.get(infoDto.getLeadingPersonDepartmentId()));
        takecareDetailList.forEach(info->{info.setLeadingPersonDepartmentName(depNameMap.get(info.getLeadingPersonDepartmentId()));});
        testDetailList.forEach(info->{info.setTestPersonDepartmentName(depNameMap.get(info.getTestPersonDepartmentId()));});
        repairDetailList.forEach(info->{info.setRepairPersonDepartmentName(depNameMap.get(info.getRepairPersonDepartmentId()));});
 
        EquipmentTypeMng typeMng = equipmentTypeMngRepository.selectOne(new QueryWrapper<EquipmentTypeMng>().eq("id",infoDto.getEquipmentTypeId()));
        if(typeMng != null){
            infoDto.setEquipmentTypeName(typeMng.getTypeName());
        }
        return infoDto;
    }
 
    @Override
    public void addOrUpdate(EquipmentInfoSaveOrUpdate infoDto) {
 
        // 验证枚举
        checkEnum(infoDto);
 
        if(infoDto.getInfoType() == null || infoDto.getEquipmentTypeId() == null){
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL);
        }
        if(infoDto.getInfoType() == 3){
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL);
        }
 
        EquipmentInfo equipmentInfo = BeanCopyUtils.copyBean(infoDto, EquipmentInfo.class);
        //保存主数据
        if (infoDto.getId() == null) { //新增
            equipmentInfoBaseService.save(equipmentInfo);
        } else {
            equipmentInfoBaseService.update(equipmentInfo,new UpdateWrapper<EquipmentInfo>().eq("id",infoDto.getId()));
        }
 
 
        //保存设备保养
        List<EquipmentTakecareDetail> takecareDetailList = infoDto.getTakecareDetailList();
        takecareDetailList.forEach(f->{
            f.setEquipmentId(equipmentInfo.getId());
            f.setInfoTpe(equipmentInfo.getInfoType());
        });
        equipmentTakecareDetailBaseService.saveOrUpdateBatch(takecareDetailList);
        if(StringUtils.hasText(infoDto.getDelTakecareDetails())){
            List<Long> idList = Arrays.stream(infoDto.getDelTakecareDetails().split(",")).map(s-> Long.parseLong(s.trim()))
                    .collect(Collectors.toList());
 
            List<EquipmentTakecareDetail> delList = new ArrayList<>();
            idList.forEach(f->{
                EquipmentTakecareDetail info = new EquipmentTakecareDetail();
                info.setDelFlag(1);
                info.setId(f);
                delList.add(info);
            });
            equipmentTakecareDetailBaseService.updateBatchById(delList);
        }
 
 
 
        //保存设备检测
        List<EquipmentTestDetail> testDetailList = infoDto.getTestDetailList();
        testDetailList.forEach(f->{
            f.setEquipmentId(equipmentInfo.getId());
            f.setInfoTpe(equipmentInfo.getInfoType());
        });
        equipmentTestDetailBaseService.saveOrUpdateBatch(testDetailList);
        if(StringUtils.hasText(infoDto.getDelTestDetails())){
            List<Long> idList = Arrays.stream(infoDto.getDelTestDetails().split(",")).map(s-> Long.parseLong(s.trim()))
                    .collect(Collectors.toList());
            List<EquipmentTestDetail> delList = new ArrayList<>();
            idList.forEach(f->{
                EquipmentTestDetail info = new EquipmentTestDetail();
                info.setDelFlag(1);
                info.setId(f);
                delList.add(info);
            });
            equipmentTestDetailBaseService.updateBatchById(delList);
        }
 
        //设备检查 TODO
 
 
        //保存设备维修
        List<EquipmentRepairDetail> repaireDetailList = infoDto.getRepaireDetailList();
        repaireDetailList.forEach(f->{
            f.setEquipmentId(equipmentInfo.getId());
            f.setInfoTpe(equipmentInfo.getInfoType());
        });
        equipmentRepairDetailBaseService.saveOrUpdateBatch(repaireDetailList);
        if(StringUtils.hasText(infoDto.getDelRepaireDetails())){
            List<Long> idList = Arrays.stream(infoDto.getDelRepaireDetails().split(",")).map(s-> Long.parseLong(s.trim()))
                    .collect(Collectors.toList());
            List<EquipmentRepairDetail> delList = new ArrayList<>();
            idList.forEach(f->{
                EquipmentRepairDetail info = new EquipmentRepairDetail();
                info.setDelFlag(1);
                info.setId(f);
                delList.add(info);
            });
            equipmentRepairDetailBaseService.updateBatchById(delList);
        }
 
        //保存检查标准
        List<EquipmentCheckStandardDetail> checkStandardeDetailList = infoDto.getCheckStandardeDetailList();
        checkStandardeDetailList.forEach(f->{
            f.setEquipmentId(equipmentInfo.getId());
            f.setInfoTpe(equipmentInfo.getInfoType());
        });
        equipmentCheckStandardDetailBaseService.saveOrUpdateBatch(checkStandardeDetailList);
        if(StringUtils.hasText(infoDto.getDelCheckStandardeDetails())){
            List<Long> idList = Arrays.stream(infoDto.getDelCheckStandardeDetails().split(",")).map(s-> Long.parseLong(s.trim()))
                    .collect(Collectors.toList());
            List<EquipmentCheckStandardDetail> delList = new ArrayList<>();
            idList.forEach(f->{
                EquipmentCheckStandardDetail info = new EquipmentCheckStandardDetail();
                info.setDelFlag(1);
                info.setId(f);
                delList.add(info);
            });
            equipmentCheckStandardDetailBaseService.updateBatchById(delList);
        }
 
        //保存保养标准
        List<EquipmentTakecareStardardDetail> takecareStardardeDetailList = infoDto.getTakecareStardardeDetailList();
        takecareStardardeDetailList.forEach(f->{
            f.setEquipmentId(equipmentInfo.getId());
            f.setInfoTpe(equipmentInfo.getInfoType());
        });
        equipmentTakecareStardardDetailBaseService.saveOrUpdateBatch(takecareStardardeDetailList);
        if(StringUtils.hasText(infoDto.getDelTakecareStardardeDetails())){
            List<Long> idList = Arrays.stream(infoDto.getDelTakecareStardardeDetails().split(",")).map(s-> Long.parseLong(s.trim()))
                    .collect(Collectors.toList());
            List<EquipmentTakecareStardardDetail> delList = new ArrayList<>();
            idList.forEach(f->{
                EquipmentTakecareStardardDetail info = new EquipmentTakecareStardardDetail();
                info.setDelFlag(1);
                info.setId(f);
                delList.add(info);
            });
            equipmentTakecareStardardDetailBaseService.updateBatchById(delList);
        }
 
 
    }
 
    @Override
    public Object statistics() {
        QueryWrapper<EquipmentInfo> wrapper = new QueryWrapper<EquipmentInfo>()
                .select("stop_status as stopStatus,count(0) as count")
                .groupBy("stop_status");
 
        List<Map<String, Object>> list = equipmentInfoBaseService.listMaps(wrapper);
 
 
        Map<String, Object> map = new HashMap<>();
        map.put("-1",equipmentInfoBaseService.countOverTime());//超时未保养
        return list;
    }
 
    @Override
    public Map<Long,String> getDepName(Set<Long> collectDepIdSet) {
        Map<Long, String> depPool = new HashMap<>();
        collectDepIdSet.forEach(depId ->{
            // 设置部门名称
            if (!depPool.containsKey(depId)) {
                try {
                    ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(depId);
                    if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) {
                        if (rpcResult.getData() != null) {
                            DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData();
                            depPool.put(dep.getDepId(), dep.getDepName());
                        }
                    }
                } catch (Exception e) {
                    System.out.println("exception"+e);
                }
            }
        });
        return depPool;
    }
 
    @Override
    public void importData(MultipartFile file) throws IOException {
        String contentType = file.getContentType();
        if(!"application/vnd.ms-excel".equals(contentType)
                && !"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet".equals(contentType)) {
            throw new EquipmentException("上传的excel格式错误");
        }
 
        Collection<EquipmentInfoImportExcel> importExcel = ExcelUtil.importExcel(EquipmentInfoImportExcel.class, file.getInputStream(), "yyyy-MM-dd HH:mm:ss", new ExcelLogs() , 0);
 
        if (CollectionUtils.isEmpty(importExcel)) {
            return ;
        }
 
        List<EquipmentInfo> respList = BeanCopyUtils.copyBeanList((List<EquipmentInfoImportExcel>)importExcel, EquipmentInfo.class);
 
        equipmentInfoBaseService.saveBatch(respList);
    }
 
    @Override
    public void delete(Long[] ids) {
        if(ids == null){
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL);
        }
        List<Long> idList = Arrays.asList(ids);
 
        List<EquipmentInfo> delList = new ArrayList<>();
        idList.forEach(f->{
            EquipmentInfo info = new EquipmentInfo();
            info.setDelFlag(1);
            info.setId(f);
            delList.add(info);
        });
 
        equipmentInfoBaseService.updateBatchById(delList);
 
    }
 
    @Override
    public void exportTemplate() throws IOException {
        Map<String,String> map = new LinkedHashMap<>();
        map.put("1", "类型/类别外键");
        map.put("2", "具体类型(页面左侧的导航栏使用) 0:仪器仪表信息 1:生产设备设施 2:安全设备设施 ");
        map.put("3", "名称");
        map.put("4", "位号");
        map.put("5", "用途");
        map.put("6", "型号");
        map.put("7", "单位部门外键");
        map.put("8", "设置部位");
        map.put("9", "生产日期(yyyy-MM-dd HH:mm:ss)");
        map.put("10", "使用期限(天)");
        map.put("11", "生命周期 1:已使用 2:库存中 3:报废");
        map.put("12", "投用日期(yyyy-MM-dd HH:mm:ss)");
        map.put("13", "维修状态 1:维修中 2:已修好");
        map.put("14", "停用状态 1:停用 2.在用 3.维修 4.报废");
        map.put("15", "上次检查日期(yyyy-MM-dd HH:mm:ss)");
        map.put("16", "上次检测日期(yyyy-MM-dd HH:mm:ss)");
        map.put("17", "上次保养日期(yyyy-MM-dd HH:mm:ss)");
        map.put("18", "下次检查日期(yyyy-MM-dd HH:mm:ss)");
        map.put("19", "下次检测日期(yyyy-MM-dd HH:mm:ss)");
        map.put("20", "下次保养日期(yyyy-MM-dd HH:mm:ss)");
        map.put("21", "负责人ID外键");
        map.put("22", "负责人部门外键");
        map.put("23", "供应商");
        map.put("24", "使用说明");
        map.put("25", "是否检查 1:是 2:否");
        map.put("26", "检查周期");
        map.put("27", "检查提前提醒");
        map.put("28", "是否检测 1:是 2:否");
        map.put("29", "检测周期");
        map.put("30", "检测提前提醒");
        map.put("31", "是否保养 1:是 2:否");
        map.put("32", "检查内容");
        map.put("33", "负责部门/外键");
        map.put("34", "检查指标");
        map.put("35", "预警值");
        map.put("36", "联锁值");
        map.put("37", "停用理由");
        map.put("38", "停用后措施");
        map.put("39", "实际停用日期(yyyy-MM-dd HH:mm:ss)");
        map.put("40", "停用提交人/外键");
        map.put("41", "停用提交日期(yyyy-MM-dd HH:mm:ss)");
        map.put("42", "恢复理由");
        map.put("43", "恢复填报日期(yyyy-MM-dd HH:mm:ss)");
        map.put("44", "实际恢复日期(yyyy-MM-dd HH:mm:ss)");
        map.put("45", "报废理由");
        map.put("46", "报废填报日期(yyyy-MM-dd HH:mm:ss)");
        map.put("47", "实际报废日期(yyyy-MM-dd HH:mm:ss)");
        map.put("48", "保养周期");
        String fileName = URLEncoder.encode("设备设施管理数据导入模板.xls", "UTF-8");
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
 
        ExcelUtil.exportExcel(map,new ArrayList<>() , response.getOutputStream());
        response.getOutputStream().close();
    }
 
    @Override
    public void exportData(EquipmentInfoQueryCriteria queryCriteria) throws IOException {
        Map<String,String> map = new LinkedHashMap<>();
        map.put("0", "ID");
        map.put("1", "类型/类别外键");
        map.put("2", "具体类型(页面左侧的导航栏使用) 0:仪器仪表信息 1:生产设备设施 2:安全设备设施 ");
        map.put("3", "名称");
        map.put("4", "位号");
        map.put("5", "用途");
        map.put("6", "型号");
        map.put("7", "单位部门外键");
        map.put("8", "设置部位");
        map.put("9", "生产日期(yyyy-MM-dd HH:mm:ss)");
        map.put("10", "使用期限(天)");
        map.put("11", "生命周期 1:已使用 2:库存中 3:报废");
        map.put("12", "投用日期(yyyy-MM-dd HH:mm:ss)");
        map.put("13", "维修状态 1:维修中 2:已修好");
        map.put("14", "停用状态 1:停用 2.在用 3.维修 4.报废");
        map.put("15", "上次检查日期(yyyy-MM-dd HH:mm:ss)");
        map.put("16", "上次检测日期(yyyy-MM-dd HH:mm:ss)");
        map.put("17", "上次保养日期(yyyy-MM-dd HH:mm:ss)");
        map.put("18", "下次检查日期(yyyy-MM-dd HH:mm:ss)");
        map.put("19", "下次检测日期(yyyy-MM-dd HH:mm:ss)");
        map.put("20", "下次保养日期(yyyy-MM-dd HH:mm:ss)");
        map.put("21", "负责人ID外键");
        map.put("22", "负责人部门外键");
        map.put("23", "供应商");
        map.put("24", "使用说明");
        map.put("25", "是否检查 1:是 2:否");
        map.put("26", "检查周期");
        map.put("27", "检查提前提醒");
        map.put("28", "是否检测 1:是 2:否");
        map.put("29", "检测周期");
        map.put("30", "检测提前提醒");
        map.put("31", "是否保养 1:是 2:否");
        map.put("32", "检查内容");
        map.put("33", "负责部门/外键");
        map.put("34", "检查指标");
        map.put("35", "预警值");
        map.put("36", "联锁值");
        map.put("37", "停用理由");
        map.put("38", "停用后措施");
        map.put("39", "实际停用日期(yyyy-MM-dd HH:mm:ss)");
        map.put("40", "停用提交人/外键");
        map.put("41", "停用提交日期(yyyy-MM-dd HH:mm:ss)");
        map.put("42", "恢复理由");
        map.put("43", "恢复填报日期(yyyy-MM-dd HH:mm:ss)");
        map.put("44", "实际恢复日期(yyyy-MM-dd HH:mm:ss)");
        map.put("45", "报废理由");
        map.put("46", "报废填报日期(yyyy-MM-dd HH:mm:ss)");
        map.put("47", "实际报废日期(yyyy-MM-dd HH:mm:ss)");
        map.put("48", "保养周期");
 
        String key = DateUtils.date2String(new Date(), DateUtils.PATTERN_ALLTIME_NOSIGN) ;
        String fileName = URLEncoder.encode("设备设施管理"+key+".xls", "UTF-8");
        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
 
        queryCriteria.setDelFlag(0);
        List<EquipmentInfoExcel> respList = BeanCopyUtils.copyBeanList(this.queryAll(queryCriteria), EquipmentInfoExcel.class);
 
        ExcelUtil.exportExcel(map,respList , response.getOutputStream(),DateUtils.PATTERN_STANDARD);
        response.getOutputStream().close();
    }
 
 
    /**
     * 枚举验证
     * @param infoDto
     */
    public void checkEnum(EquipmentInfoSaveOrUpdate infoDto){
        if (EquipmentLifeCycleEnum.getByCode(infoDto.getLifeCycle()) == null) {
            throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_LIFE_CYCLE_NOT_EXIST);
        }
 
        if (EquipmentRepairStatusEnum.getByCode(infoDto.getRepairStatus()) == null) {
            throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_STOP_STATUS_NOT_EXIST);
        }
 
        if (EquipmentStopStatusEnum.getByCode(infoDto.getStopStatus()) == null) {
            throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_REPAIR_STATUS_NOT_EXIST);
        }
    }
}