王佳豪
2021-06-26 718f604deb342b0bee6c588bb44e22ced3371fb8
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
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
package com.slcf.service.impl;
 
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletResponse;
 
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.slcf.bean.LocChartPie;
import com.slcf.bean.WorkChartAxis;
import com.slcf.dao.ReportQueryDao;
import com.slcf.pojo.AdjDetailBean;
import com.slcf.pojo.PlcCommandBean;
import com.slcf.pojo.ViewInOutBean;
import com.slcf.pojo.ViewLocMapBean;
import com.slcf.pojo.ViewStayTimeBean;
import com.slcf.pojo.ViewStockUseBean;
import com.slcf.pojo.ViewWorkInBean;
import com.slcf.service.ReportQueryService;
import com.slcf.util.DateTimeUtil;
 
/**
 * 日志统计接口实现
 * @author admin
 * @date 2018年11月23日
 */
@Service
public class ReportQueryServiceImpl implements ReportQueryService {
 
    @Autowired
    ReportQueryDao reportQueryDao;
    
    //------------------库位使用统计--------------------------------------
    public Map<String,Object> queryViewStockUseList(ViewStockUseBean viewStockUse) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<ViewStockUseBean> list=reportQueryDao.queryViewStockUseList(viewStockUse);
            int count =reportQueryDao.getViewStockUseCount(viewStockUse);
            map.put("rows", list);
            map.put("total", count);
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
    //导出excel
    public void ExportViewStockUseList(ViewStockUseBean viewStockUse, HttpServletResponse response) {
        // 输出Excel文件
        try {
            // HSSFWorkbook对象(excel的文档对象)
            HSSFWorkbook workBook = new HSSFWorkbook();
 
            // sheet对象(excel的表单)
            HSSFSheet sheet = workBook.createSheet("库位使用信息");
 
            sheet.setColumnWidth(0, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(2, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(3, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(5, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(6, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(7, (int) ((15 + 0.72) * 256));
 
            HSSFRow rows = sheet.createRow(0);// 第二行
            // 创建单元格并设置单元格内容
            rows.createCell(0).setCellValue("钢架号");
            rows.createCell(1).setCellValue("库位总数");
            rows.createCell(2).setCellValue("在库数量");
            rows.createCell(3).setCellValue("空库位数量");
            rows.createCell(4).setCellValue("禁用库位数量");
            rows.createCell(5).setCellValue("空容器数量");
            rows.createCell(6).setCellValue("在库率(%)");
            rows.createCell(7).setCellValue("使用率(%)");
 
            List<ViewStockUseBean> list = reportQueryDao.getViewStockUseAll(viewStockUse);
            for (int i = 0; i < list.size(); i++) {
                HSSFRow row = sheet.createRow(i + 1);// 从第三行开始
                // 创建单元格并设置单元格内容
                row.createCell(0).setCellValue(list.get(i).getRow1());
                row.createCell(1).setCellValue(list.get(i).getTotal_qty());
                row.createCell(2).setCellValue(list.get(i).getFull_qty());
                row.createCell(3).setCellValue(list.get(i).getNull_qty());
                row.createCell(4).setCellValue(list.get(i).getForbid_qty());
                row.createCell(5).setCellValue(list.get(i).getEmpty_qty());
                row.createCell(6).setCellValue(list.get(i).getFull_rate());
                row.createCell(7).setCellValue(list.get(i).getOcc_rate());
            }
            // //输出Excel文件
            // try {
            OutputStream output = response.getOutputStream();
            response.reset();
            response.setHeader("Content-disposition",
                    "attachment; filename=StockUse" + DateTimeUtil.getStringDateTime(14) + ".xls");
            response.setContentType("application/msexcel");
            workBook.write(output);
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
        
    //------------------库存滞留统计--------------------------------------
    public Map<String,Object> queryViewStayTimeList(ViewStayTimeBean viewStayTime) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<ViewStayTimeBean> list=reportQueryDao.queryViewStayTimeList(viewStayTime);
            int count =reportQueryDao.getViewStayTimeCount(viewStayTime);
            map.put("rows", list);
            map.put("total", count);
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
    //导出excel
    public void ExportViewStayTimeList(ViewStayTimeBean viewStayTime, HttpServletResponse response) {
        // 输出Excel文件
        try {
            // HSSFWorkbook对象(excel的文档对象)
            HSSFWorkbook workBook = new HSSFWorkbook();
 
            // sheet对象(excel的表单)
            HSSFSheet sheet = workBook.createSheet("库存滞留时间统计");
 
            sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(1, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(2, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(3, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(4, (int) ((25 + 0.72) * 256));
            sheet.setColumnWidth(5, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(6, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(7, (int) ((5 + 0.72) * 256));
            sheet.setColumnWidth(8, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(9, (int) ((10 + 0.72) * 256));
 
            HSSFRow rows = sheet.createRow(0);// 第二行
            // 创建单元格并设置单元格内容
            rows.createCell(0).setCellValue("入库时间");
            rows.createCell(1).setCellValue("滞留天数");
            rows.createCell(2).setCellValue("库位号");
            rows.createCell(3).setCellValue("物料");
            rows.createCell(4).setCellValue("物料描述");
            rows.createCell(5).setCellValue("工厂");
            rows.createCell(6).setCellValue("数量");
            rows.createCell(7).setCellValue("单位");
            rows.createCell(8).setCellValue("托盘码");
            rows.createCell(9).setCellValue("用户ID");
 
            List<ViewStayTimeBean> list = reportQueryDao.getViewStayTimeAll(viewStayTime);
            for (int i = 0; i < list.size(); i++) {
                HSSFRow row = sheet.createRow(i + 1);// 从第三行开始
                // 创建单元格并设置单元格内容
                row.createCell(0).setCellValue(list.get(i).getAppe_time());
                row.createCell(1).setCellValue(list.get(i).getStay_time());
                row.createCell(2).setCellValue(list.get(i).getLoc_no());
                row.createCell(3).setCellValue(list.get(i).getMatnr());
                row.createCell(4).setCellValue(list.get(i).getMaktx());
                row.createCell(5).setCellValue(list.get(i).getWerks());
                row.createCell(6).setCellValue(list.get(i).getAnfme());
                row.createCell(7).setCellValue(list.get(i).getAltme());
                row.createCell(8).setCellValue(list.get(i).getZpallet());
                row.createCell(9).setCellValue(list.get(i).getBname());
            }
            // //输出Excel文件
            // try {
            OutputStream output = response.getOutputStream();
            response.reset();
            response.setHeader("Content-disposition",
                    "attachment; filename=StayTime" + DateTimeUtil.getStringDateTime(14) + ".xls");
            response.setContentType("application/msexcel");
            workBook.write(output);
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
        
    //------------------库存调整记录--------------------------------------
    public Map<String,Object> queryAdjDetailList(AdjDetailBean adjDetail) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<AdjDetailBean> list=reportQueryDao.queryAdjDetailList(adjDetail);
            int count =reportQueryDao.getAdjDetailCount(adjDetail);
            map.put("rows", list);
            map.put("total", count);
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
    //导出excel
    public void ExportAdjDetailList(AdjDetailBean adjDetail, HttpServletResponse response) {
        // 输出Excel文件
        try {
            // HSSFWorkbook对象(excel的文档对象)
            HSSFWorkbook workBook = new HSSFWorkbook();
 
            // sheet对象(excel的表单)
            HSSFSheet sheet = workBook.createSheet("库存调整统计");
 
            sheet.setColumnWidth(0, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(1, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(3, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(5, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(6, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(7, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(8, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(9, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(10, (int) ((6 + 0.72) * 256));
            sheet.setColumnWidth(11, (int) ((20 + 0.72) * 256));
 
            HSSFRow rows = sheet.createRow(0);// 第二行
            // 创建单元格并设置单元格内容
            rows.createCell(0).setCellValue("库位号");
            rows.createCell(1).setCellValue("物料编码");
            rows.createCell(2).setCellValue("物料名称");
            rows.createCell(3).setCellValue("原数量");
            rows.createCell(4).setCellValue("调整数量");
            rows.createCell(5).setCellValue("调整后数量");
            rows.createCell(6).setCellValue("原箱数");
            rows.createCell(7).setCellValue("调整箱数");
            rows.createCell(8).setCellValue("调整后箱数");
            rows.createCell(9).setCellValue("备注");
            rows.createCell(10).setCellValue("调整人员");
            rows.createCell(11).setCellValue("调整时间");
 
            List<AdjDetailBean> list = reportQueryDao.getAdjDetailAll(adjDetail);
            for (int i = 0; i < list.size(); i++) {
                HSSFRow row = sheet.createRow(i + 1);// 从第三行开始
                // 创建单元格并设置单元格内容
                row.createCell(0).setCellValue(list.get(i).getLoc_no());
                row.createCell(1).setCellValue(list.get(i).getMat_no());
                row.createCell(2).setCellValue(list.get(i).getMat_name());
                row.createCell(3).setCellValue(list.get(i).getS_qty());
                row.createCell(4).setCellValue(list.get(i).getAdj_qty());
                row.createCell(5).setCellValue(list.get(i).getQty());
                row.createCell(6).setCellValue(list.get(i).getS_ctns());
                row.createCell(7).setCellValue(list.get(i).getAdj_ctns());
                row.createCell(8).setCellValue(list.get(i).getCtns());
                row.createCell(9).setCellValue(list.get(i).getMemo());
                row.createCell(10).setCellValue(list.get(i).getModi_user());
                row.createCell(11).setCellValue(list.get(i).getModi_time());
            }
            // //输出Excel文件
            // try {
            OutputStream output = response.getOutputStream();
            response.reset();
            response.setHeader("Content-disposition",
                    "attachment; filename=AdjDetail" + DateTimeUtil.getStringDateTime(14) + ".xls");
            response.setContentType("application/msexcel");
            workBook.write(output);
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
    //------------------站点日入出库次数统计--------------------------------------
    public Map<String,Object> queryViewInOutList(ViewInOutBean viewInOut) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<ViewInOutBean> list=reportQueryDao.queryViewInOutList(viewInOut);
            int count =reportQueryDao.getViewInOutCount(viewInOut);
            map.put("rows", list);
            map.put("total", count);
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
    //导出excel
    public void ExportViewInOutList(ViewInOutBean viewInOut, HttpServletResponse response) {
        // 输出Excel文件
        try {
            // HSSFWorkbook对象(excel的文档对象)
            HSSFWorkbook workBook = new HSSFWorkbook();
 
            // sheet对象(excel的表单)
            HSSFSheet sheet = workBook.createSheet("日入出库次数统计");
 
            sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(2, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(3, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256));
 
            HSSFRow rows = sheet.createRow(0);// 第二行
            // 创建单元格并设置单元格内容
            rows.createCell(0).setCellValue("日期");
            rows.createCell(1).setCellValue("站点编号");
            rows.createCell(2).setCellValue("入库次数");
            rows.createCell(3).setCellValue("出库次数");
            rows.createCell(4).setCellValue("总次数");
 
            List<ViewInOutBean> list = reportQueryDao.getViewInOutAll(viewInOut);
            for (int i = 0; i < list.size(); i++) {
                HSSFRow row = sheet.createRow(i + 1);// 从第三行开始
                // 创建单元格并设置单元格内容
                row.createCell(0).setCellValue(list.get(i).getYmd());
                row.createCell(1).setCellValue(list.get(i).getSource_sta_no());
                row.createCell(2).setCellValue(list.get(i).getSto_qty());
                row.createCell(3).setCellValue(list.get(i).getRet_qty());
                row.createCell(4).setCellValue(list.get(i).getTotal_qty());
            }
            // //输出Excel文件
            // try {
            OutputStream output = response.getOutputStream();
            response.reset();
            response.setHeader("Content-disposition",
                    "attachment; filename=InOutCount" + DateTimeUtil.getStringDateTime(14) + ".xls");
            response.setContentType("application/msexcel");
            workBook.write(output);
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    //------------------日入库明细记录--------------------------------------
    public Map<String,Object> queryViewWorkInList(ViewWorkInBean viewWorkIn) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<ViewWorkInBean> list=reportQueryDao.queryViewWorkInList(viewWorkIn);
            int count =reportQueryDao.getViewWorkInCount(viewWorkIn);
            map.put("rows", list);
            map.put("total", count);
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
    //导出excel
    public void ExportViewWorkInList(ViewWorkInBean viewWorkIn, HttpServletResponse response) {
        // 输出Excel文件
        try {
            // HSSFWorkbook对象(excel的文档对象)
            HSSFWorkbook workBook = new HSSFWorkbook();
 
            // sheet对象(excel的表单)
            HSSFSheet sheet = workBook.createSheet("日入库明细查询");
 
            sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(3, (int) ((25 + 0.72) * 256));
            sheet.setColumnWidth(4, (int) ((38 + 0.72) * 256));
            sheet.setColumnWidth(5, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(6, (int) ((45 + 0.72) * 256));
            sheet.setColumnWidth(7, (int) ((8 + 0.72) * 256));
            sheet.setColumnWidth(8, (int) ((20 + 0.72) * 256));
 
            HSSFRow rows = sheet.createRow(0);// 第二行
            // 创建单元格并设置单元格内容
            rows.createCell(0).setCellValue("入库时间");
            rows.createCell(1).setCellValue("库位号");
            rows.createCell(2).setCellValue("物料");
            rows.createCell(3).setCellValue("物料描述");
            rows.createCell(4).setCellValue("工厂");
            rows.createCell(5).setCellValue("数量");
            rows.createCell(6).setCellValue("单位");
            rows.createCell(7).setCellValue("托盘码");
            rows.createCell(8).setCellValue("用户ID");
 
            List<ViewWorkInBean> list = reportQueryDao.getViewWorkInAll(viewWorkIn);
            for (int i = 0; i < list.size(); i++) {
                HSSFRow row = sheet.createRow(i + 1);// 从第三行开始
                // 创建单元格并设置单元格内容
                row.createCell(0).setCellValue(list.get(i).getIo_time());
                row.createCell(1).setCellValue(list.get(i).getLoc_no());
                row.createCell(2).setCellValue(list.get(i).getMatnr());
                row.createCell(3).setCellValue(list.get(i).getMaktx());
                row.createCell(4).setCellValue(list.get(i).getWerks());
                row.createCell(5).setCellValue(list.get(i).getAnfme());
                row.createCell(6).setCellValue(list.get(i).getAltme());
                row.createCell(7).setCellValue(list.get(i).getZpallet());
                row.createCell(8).setCellValue(list.get(i).getBname());
            }
            // //输出Excel文件
            // try {
            OutputStream output = response.getOutputStream();
            response.reset();
            response.setHeader("Content-disposition",
                    "attachment; filename=DailyStore" + DateTimeUtil.getStringDateTime(14) + ".xls");
            response.setContentType("application/msexcel");
            workBook.write(output);
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    //------------------日出库明细记录--------------------------------------
    public Map<String,Object> queryViewWorkOutList(ViewWorkInBean viewWorkOut) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<ViewWorkInBean> list=reportQueryDao.queryViewWorkOutList(viewWorkOut);
            int count =reportQueryDao.getViewWorkOutCount(viewWorkOut);
            map.put("rows", list);
            map.put("total", count);
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
    //导出excel
    public void ExportViewWorkOutList(ViewWorkInBean viewWorkOut, HttpServletResponse response) {
        // 输出Excel文件
        try {
            // HSSFWorkbook对象(excel的文档对象)
            HSSFWorkbook workBook = new HSSFWorkbook();
 
            // sheet对象(excel的表单)
            HSSFSheet sheet = workBook.createSheet("日出库明细查询");
 
            sheet.setColumnWidth(0, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(1, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(3, (int) ((25 + 0.72) * 256));
            sheet.setColumnWidth(4, (int) ((38 + 0.72) * 256));
            sheet.setColumnWidth(5, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(6, (int) ((45 + 0.72) * 256));
            sheet.setColumnWidth(7, (int) ((8 + 0.72) * 256));
            sheet.setColumnWidth(8, (int) ((20 + 0.72) * 256));
 
            HSSFRow rows = sheet.createRow(0);// 第二行
            // 创建单元格并设置单元格内容
            rows.createCell(0).setCellValue("出库时间");
            rows.createCell(1).setCellValue("库位号");
            rows.createCell(2).setCellValue("物料");
            rows.createCell(3).setCellValue("物料描述");
            rows.createCell(4).setCellValue("工厂");
            rows.createCell(5).setCellValue("数量");
            rows.createCell(6).setCellValue("单位");
            rows.createCell(7).setCellValue("托盘码");
            rows.createCell(8).setCellValue("用户ID");
            
            List<ViewWorkInBean> list = reportQueryDao.getViewWorkOutAll(viewWorkOut);
            for (int i = 0; i < list.size(); i++) {
                HSSFRow row = sheet.createRow(i + 1);// 从第三行开始
                // 创建单元格并设置单元格内容
                row.createCell(0).setCellValue(list.get(i).getIo_time());
                row.createCell(1).setCellValue(list.get(i).getLoc_no());
                row.createCell(2).setCellValue(list.get(i).getMatnr());
                row.createCell(3).setCellValue(list.get(i).getMaktx());
                row.createCell(4).setCellValue(list.get(i).getWerks());
                row.createCell(5).setCellValue(list.get(i).getAnfme());
                row.createCell(6).setCellValue(list.get(i).getAltme());
                row.createCell(7).setCellValue(list.get(i).getZpallet());
                row.createCell(8).setCellValue(list.get(i).getBname());
            }
            // //输出Excel文件
            // try {
            OutputStream output = response.getOutputStream();
            response.reset();
            response.setHeader("Content-disposition",
                    "attachment; filename=DailyRetrieve" + DateTimeUtil.getStringDateTime(14) + ".xls");
            response.setContentType("application/msexcel");
            workBook.write(output);
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    //------------------库存MAP图--------------------------------------
    public Map<String,Object> queryViewLocMapList(ViewLocMapBean viewLocMap) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<ViewLocMapBean> list = new ArrayList<ViewLocMapBean>();
            String row1 = String.format("%02d", Integer.parseInt(viewLocMap.getRow1()));
            
            List<String> levList = reportQueryDao.getViewLocLevCount(Integer.parseInt(row1));
            for(String lev1 : levList) {
                List<ViewLocMapBean> bayList= reportQueryDao.getViewLocBays(Integer.parseInt(row1),Integer.parseInt(lev1));
                ViewLocMapBean locMap = new ViewLocMapBean();
                locMap.setRowlev(row1+String.format("%02d", Integer.parseInt(lev1)));
                int i=0;
//                if(Integer.parseInt(lev1)>3){
//                    i = i+1;
//                    locMap.setL001(bayList.get(i-1).getLoc_sts());
//                    locMap.setL087(bayList.get(i+85).getLoc_sts());
//                }
                
                locMap.setL002(bayList.get(i).getLoc_sts());
                locMap.setL003(bayList.get(i+1).getLoc_sts());
                locMap.setL004(bayList.get(i+2).getLoc_sts());
                locMap.setL005(bayList.get(i+3).getLoc_sts());
                locMap.setL006(bayList.get(i+4).getLoc_sts());
                locMap.setL007(bayList.get(i+5).getLoc_sts());
                locMap.setL008(bayList.get(i+6).getLoc_sts());
                locMap.setL009(bayList.get(i+7).getLoc_sts());
                locMap.setL010(bayList.get(i+8).getLoc_sts());
                locMap.setL011(bayList.get(i+9).getLoc_sts());
                locMap.setL012(bayList.get(i+10).getLoc_sts());
                locMap.setL013(bayList.get(i+11).getLoc_sts());
                locMap.setL014(bayList.get(i+12).getLoc_sts());
                locMap.setL015(bayList.get(i+13).getLoc_sts());
                locMap.setL016(bayList.get(i+14).getLoc_sts());
                locMap.setL017(bayList.get(i+15).getLoc_sts());
                locMap.setL018(bayList.get(i+16).getLoc_sts());
                locMap.setL019(bayList.get(i+17).getLoc_sts());
                locMap.setL020(bayList.get(i+18).getLoc_sts());
                locMap.setL021(bayList.get(i+19).getLoc_sts());
                locMap.setL022(bayList.get(i+20).getLoc_sts());
                locMap.setL023(bayList.get(i+21).getLoc_sts());
                locMap.setL024(bayList.get(i+22).getLoc_sts());
                locMap.setL025(bayList.get(i+23).getLoc_sts());
                locMap.setL026(bayList.get(i+24).getLoc_sts());
                locMap.setL027(bayList.get(i+25).getLoc_sts());
                locMap.setL028(bayList.get(i+26).getLoc_sts());
                locMap.setL029(bayList.get(i+27).getLoc_sts());
                locMap.setL030(bayList.get(i+28).getLoc_sts());
                locMap.setL031(bayList.get(i+29).getLoc_sts());
                locMap.setL032(bayList.get(i+30).getLoc_sts());
                locMap.setL033(bayList.get(i+31).getLoc_sts());
                locMap.setL034(bayList.get(i+32).getLoc_sts());
                locMap.setL035(bayList.get(i+33).getLoc_sts());
                locMap.setL036(bayList.get(i+34).getLoc_sts());
                locMap.setL037(bayList.get(i+35).getLoc_sts());
                locMap.setL038(bayList.get(i+36).getLoc_sts());
                locMap.setL039(bayList.get(i+37).getLoc_sts());
                locMap.setL040(bayList.get(i+38).getLoc_sts());
                locMap.setL041(bayList.get(i+39).getLoc_sts());
                locMap.setL042(bayList.get(i+40).getLoc_sts());
                locMap.setL043(bayList.get(i+41).getLoc_sts());
                locMap.setL044(bayList.get(i+42).getLoc_sts());
                locMap.setL045(bayList.get(i+43).getLoc_sts());
                locMap.setL046(bayList.get(i+44).getLoc_sts());
                locMap.setL047(bayList.get(i+45).getLoc_sts());
//                locMap.setL048(bayList.get(i+46).getLoc_sts());
//                locMap.setL049(bayList.get(i+47).getLoc_sts());
//                locMap.setL050(bayList.get(i+48).getLoc_sts());
//                locMap.setL051(bayList.get(i+49).getLoc_sts());
//                locMap.setL052(bayList.get(i+50).getLoc_sts());
//                locMap.setL053(bayList.get(i+51).getLoc_sts());
//                locMap.setL054(bayList.get(i+52).getLoc_sts());
//                locMap.setL055(bayList.get(i+53).getLoc_sts());
//                locMap.setL056(bayList.get(i+54).getLoc_sts());
//                locMap.setL057(bayList.get(i+55).getLoc_sts());
//                locMap.setL058(bayList.get(i+56).getLoc_sts());
//                locMap.setL059(bayList.get(i+57).getLoc_sts());
//                locMap.setL060(bayList.get(i+58).getLoc_sts());
//                locMap.setL061(bayList.get(i+59).getLoc_sts());
//                locMap.setL062(bayList.get(i+60).getLoc_sts());
//                locMap.setL063(bayList.get(i+61).getLoc_sts());
//                locMap.setL064(bayList.get(i+62).getLoc_sts());
//                locMap.setL065(bayList.get(i+63).getLoc_sts());
//                locMap.setL066(bayList.get(i+64).getLoc_sts());
//                locMap.setL067(bayList.get(i+65).getLoc_sts());
//                locMap.setL068(bayList.get(i+66).getLoc_sts());
//                locMap.setL069(bayList.get(i+67).getLoc_sts());
//                locMap.setL070(bayList.get(i+68).getLoc_sts());
//                locMap.setL071(bayList.get(i+69).getLoc_sts());
//                locMap.setL072(bayList.get(i+70).getLoc_sts());
//                locMap.setL073(bayList.get(i+71).getLoc_sts());
//                locMap.setL074(bayList.get(i+72).getLoc_sts());
//                locMap.setL075(bayList.get(i+73).getLoc_sts());
//                locMap.setL076(bayList.get(i+74).getLoc_sts());
//                locMap.setL077(bayList.get(i+75).getLoc_sts());
//                locMap.setL078(bayList.get(i+76).getLoc_sts());
//                locMap.setL079(bayList.get(i+77).getLoc_sts());
//                locMap.setL080(bayList.get(i+78).getLoc_sts());
//                locMap.setL081(bayList.get(i+79).getLoc_sts());
//                locMap.setL082(bayList.get(i+80).getLoc_sts());
//                locMap.setL083(bayList.get(i+81).getLoc_sts());
//                locMap.setL084(bayList.get(i+82).getLoc_sts());
//                locMap.setL085(bayList.get(i+83).getLoc_sts());
//                locMap.setL086(bayList.get(i+84).getLoc_sts());
                
                list.add(locMap);
            }
            map.put("rows", list);
            map.put("total", levList.size());
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
//    public Map<String,Object> queryViewLocMapList(ViewLocMapBean viewLocMap) {
//        try {
//            Map<String,Object> map=new HashMap<String, Object>();
//            List<ViewLocMapBean> list=reportQueryDao.queryViewLocMapList(viewLocMap);
//            int count =reportQueryDao.getViewLocMapCount(viewLocMap);
//            map.put("rows", list);
//            map.put("total", count);
//            return map;
//        }catch(Exception e) {
//            System.out.println(e.getMessage());
//            System.out.println(e.getMessage());
//            return null;
//        }
//    }
    
    /**
     * 库位占用图表
     */
    public LocChartPie getLocUseRate() {
        try {
            LocChartPie locUseRate = reportQueryDao.getLocUseRate();
            return locUseRate;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            return null;
        }
    }
    
    /**
     * 入出曲线统计图
     */
    public List<WorkChartAxis> getChartAxis(){
        List<WorkChartAxis> list = new ArrayList<WorkChartAxis>();
        try {
            list = reportQueryDao.getChartAxis();
        }catch(Exception e) {
            System.out.println(e.getMessage());
        }
        return list;
    }
    
    //------------------堆垛机异常记录--------------------------------------
    public Map<String,Object> queryCrnErrorList(PlcCommandBean plcCommand) {
        try {
            Map<String,Object> map=new HashMap<String, Object>();
            List<PlcCommandBean> list=reportQueryDao.queryCrnErrorList(plcCommand);
            int count =reportQueryDao.getCrnErrorCount(plcCommand);
            map.put("rows", list);
            map.put("total", count);
            return map;
        }catch(Exception e) {
            System.out.println(e.getMessage());
            System.out.println(e.getMessage());
            return null;
        }
    }
    //导出excel
    public void ExportCrnErrorList(PlcCommandBean plcCommand, HttpServletResponse response) {
        // 输出Excel文件
        try {
            // HSSFWorkbook对象(excel的文档对象)
            HSSFWorkbook workBook = new HSSFWorkbook();
 
            // sheet对象(excel的表单)
            HSSFSheet sheet = workBook.createSheet("堆垛机异常记录");
 
            sheet.setColumnWidth(0, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(1, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(2, (int) ((20 + 0.72) * 256));
            sheet.setColumnWidth(3, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(4, (int) ((15 + 0.72) * 256));
            sheet.setColumnWidth(5, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(6, (int) ((10 + 0.72) * 256));
            sheet.setColumnWidth(7, (int) ((10 + 0.72) * 256));
 
            HSSFRow rows = sheet.createRow(0);// 第二行
            // 创建单元格并设置单元格内容
            rows.createCell(0).setCellValue("日期时间");
            rows.createCell(1).setCellValue("堆垛机号");
            rows.createCell(2).setCellValue("工作号");
            rows.createCell(3).setCellValue("异常码");
            rows.createCell(4).setCellValue("异常描述");
            rows.createCell(5).setCellValue("库位号");
            rows.createCell(6).setCellValue("发生时间");
            rows.createCell(7).setCellValue("工作档时间");
 
            List<PlcCommandBean> list = reportQueryDao.getCrnErrorAll(plcCommand);
            for (int i = 0; i < list.size(); i++) {
                HSSFRow row = sheet.createRow(i + 1);// 从第三行开始
                // 创建单元格并设置单元格内容
                row.createCell(0).setCellValue(list.get(i).getIo_time());
                row.createCell(1).setCellValue(list.get(i).getDev_no());
                row.createCell(2).setCellValue(list.get(i).getWrk_no());
                row.createCell(3).setCellValue(list.get(i).getS_location());
                row.createCell(4).setCellValue(list.get(i).getErr_name());
                row.createCell(5).setCellValue(list.get(i).getO_location());
                row.createCell(6).setCellValue(list.get(i).getModi_time());
                row.createCell(7).setCellValue(list.get(i).getWrk_time());
            }
            // //输出Excel文件
            // try {
            OutputStream output = response.getOutputStream();
            response.reset();
            response.setHeader("Content-disposition",
                    "attachment; filename=CrnError" + DateTimeUtil.getStringDateTime(14) + ".xls");
            response.setContentType("application/msexcel");
            workBook.write(output);
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}