|
|
@@ -2,6 +2,8 @@ package com.chinaitop.agile.service.impl;
|
|
2
|
2
|
|
|
3
|
3
|
import com.alibaba.fastjson.JSONObject;
|
|
4
|
4
|
import com.chinaitop.agile.feignService.BasicEnumFeignService;
|
|
|
5
|
+import com.chinaitop.agile.feignService.BasicStorehouseFeignService;
|
|
|
6
|
+import com.chinaitop.agile.feignService.BasicWarehouseFeignService;
|
|
5
|
7
|
import com.chinaitop.agile.mapper.DataKcglFcbgzDefaultMapper;
|
|
6
|
8
|
import com.chinaitop.agile.mapper.DataKcglKcswDefaultMapper;
|
|
7
|
9
|
import com.chinaitop.agile.mapper.DataKcglXckcDefaultMapper;
|
|
|
@@ -15,9 +17,21 @@ import com.github.pagehelper.PageHelper;
|
|
15
|
17
|
import com.github.pagehelper.PageInfo;
|
|
16
|
18
|
|
|
17
|
19
|
import org.apache.commons.lang.ObjectUtils;
|
|
|
20
|
+import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
21
|
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
22
|
+import org.apache.poi.hssf.usermodel.HSSFFont;
|
|
|
23
|
+import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
24
|
+import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
25
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
26
|
+import org.apache.poi.ss.usermodel.Font;
|
|
18
|
27
|
import org.springframework.stereotype.Service;
|
|
19
|
28
|
|
|
20
|
29
|
import javax.annotation.Resource;
|
|
|
30
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
31
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
32
|
+
|
|
|
33
|
+import java.io.BufferedOutputStream;
|
|
|
34
|
+import java.io.OutputStream;
|
|
21
|
35
|
import java.math.BigDecimal;
|
|
22
|
36
|
import java.math.RoundingMode;
|
|
23
|
37
|
import java.text.DecimalFormat;
|
|
|
@@ -36,6 +50,10 @@ public class KcswServiceImpl implements KcswService{
|
|
36
|
50
|
private DataKcglFcbgzDefaultService fcbgzService;
|
|
37
|
51
|
@Resource
|
|
38
|
52
|
private BasicEnumFeignService basicEnumFeignService;
|
|
|
53
|
+ @Resource
|
|
|
54
|
+ private BasicStorehouseFeignService basicStorehouseFeignService;
|
|
|
55
|
+ @Resource
|
|
|
56
|
+ private BasicWarehouseFeignService basicWarehouseFeignService;
|
|
39
|
57
|
|
|
40
|
58
|
public Map<String, Object> queryByExample(Integer orgId) {
|
|
41
|
59
|
/* 返回数据对象 */
|
|
|
@@ -424,7 +442,7 @@ public class KcswServiceImpl implements KcswService{
|
|
424
|
442
|
pageInfo = new PageInfo<DataKcglKcswDefault>(list);
|
|
425
|
443
|
|
|
426
|
444
|
/* 2、查询对应仓房的生产年份,ZJ是自检要做判断 */
|
|
427
|
|
- if (!order.equals("ZJ") && null != pageInfo.getList() && pageInfo.getList().size() > 0) {
|
|
|
445
|
+ if (!"ZJ".equals(order) && null != pageInfo.getList() && pageInfo.getList().size() > 0) {
|
|
428
|
446
|
for (DataKcglKcswDefault kcswobj : pageInfo.getList()) {
|
|
429
|
447
|
DataKcglFcbgzDefaultExample fcbgz_example = new DataKcglFcbgzDefaultExample();
|
|
430
|
448
|
DataKcglFcbgzDefaultExample.Criteria fcbgz_criteria = fcbgz_example.createCriteria();
|
|
|
@@ -437,6 +455,7 @@ public class KcswServiceImpl implements KcswService{
|
|
437
|
455
|
if (null != fcbgz_list && fcbgz_list.size() > 0) {
|
|
438
|
456
|
int scnf = Integer.parseInt(ObjectUtils.toString(fcbgz_list.get(0).getScnf(), "0"));
|
|
439
|
457
|
kcswobj.setScnf(scnf);
|
|
|
458
|
+ kcswobj.setCjsj(fcbgz_list.get(0).getCjsj());
|
|
440
|
459
|
}
|
|
441
|
460
|
/* 3、查询这个仓房的已验收数量和未验收数量 */
|
|
442
|
461
|
map.put("orgId", kcsw.getUnitid());
|
|
|
@@ -467,4 +486,151 @@ public class KcswServiceImpl implements KcswService{
|
|
467
|
486
|
|
|
468
|
487
|
return pageInfo;
|
|
469
|
488
|
}
|
|
|
489
|
+
|
|
|
490
|
+ @Override
|
|
|
491
|
+ public List<DataKcglKcswDefault> importList(HttpServletRequest request, HttpServletResponse response, String kcswStr, String order) throws Exception {
|
|
|
492
|
+ List<DataKcglKcswDefault> list = null;
|
|
|
493
|
+
|
|
|
494
|
+ String orgInfo = ObjectUtils.toString(request.getSession().getAttribute("orgInfo"),"");
|
|
|
495
|
+ JSONObject org = null;
|
|
|
496
|
+ String orgName = "";
|
|
|
497
|
+ if (null != orgInfo && !"".equals(orgInfo)) {
|
|
|
498
|
+ org = JSONObject.parseObject(orgInfo);
|
|
|
499
|
+ orgName = org.get("orgName") == null?"":org.get("orgName").toString();
|
|
|
500
|
+ }
|
|
|
501
|
+
|
|
|
502
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
503
|
+ //创建一个Excel表单,参数为sheet的名字
|
|
|
504
|
+ HSSFSheet sheet = workbook.createSheet("库存数量统计");
|
|
|
505
|
+
|
|
|
506
|
+ //创建表头
|
|
|
507
|
+ setKcslTitle(workbook, sheet);
|
|
|
508
|
+
|
|
|
509
|
+ PageInfo<DataKcglKcswDefault> pageInfo = queryYYSSL(null, null, kcswStr, order);
|
|
|
510
|
+ list = pageInfo.getList();
|
|
|
511
|
+
|
|
|
512
|
+ int rowNum = 1;
|
|
|
513
|
+ DataKcglKcswDefault serviceVo = null;
|
|
|
514
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
515
|
+ serviceVo = list.get(i);
|
|
|
516
|
+ HSSFRow row = sheet.createRow(rowNum);
|
|
|
517
|
+ row.createCell(0).setCellValue(i++);
|
|
|
518
|
+ row.createCell(1).setCellValue(orgName);
|
|
|
519
|
+ row.createCell(2).setCellValue(getStorehouse(serviceVo.getCh(), Integer.parseInt(serviceVo.getUnitid())));
|
|
|
520
|
+ row.createCell(3).setCellValue(getWarehouse(serviceVo.getHwh()));
|
|
|
521
|
+ row.createCell(4).setCellValue(getEnum(Integer.parseInt(serviceVo.getPz())));
|
|
|
522
|
+ row.createCell(5).setCellValue(getEnum(Integer.parseInt(serviceVo.getHwxz())));
|
|
|
523
|
+ row.createCell(6).setCellValue(serviceVo.getKcsl()/1000);
|
|
|
524
|
+ row.createCell(7).setCellValue(serviceVo.getRksl()/1000);
|
|
|
525
|
+ row.createCell(8).setCellValue(serviceVo.getWyssl()/1000);
|
|
|
526
|
+ row.createCell(9).setCellValue(getEnum(serviceVo.getScnf()));
|
|
|
527
|
+ rowNum++;
|
|
|
528
|
+ }
|
|
|
529
|
+ String fileName = "库存数量统计.xlsx";
|
|
|
530
|
+ //清空response
|
|
|
531
|
+ response.reset();
|
|
|
532
|
+ //设置response的Header
|
|
|
533
|
+ response.addHeader("Content-Disposition", "attachment;filename="+ fileName);
|
|
|
534
|
+ OutputStream os = new BufferedOutputStream(response.getOutputStream());
|
|
|
535
|
+
|
|
|
536
|
+ response.setContentType("application/vnd.ms-excel;charset=gb2312");
|
|
|
537
|
+ //将excel写入到输出流中
|
|
|
538
|
+ workbook.write(os);
|
|
|
539
|
+ os.flush();
|
|
|
540
|
+ os.close();
|
|
|
541
|
+
|
|
|
542
|
+ return null;
|
|
|
543
|
+ }
|
|
|
544
|
+
|
|
|
545
|
+ public void setKcslTitle(HSSFWorkbook workbook, HSSFSheet sheet) {
|
|
|
546
|
+ HSSFRow row = sheet.createRow(0);
|
|
|
547
|
+ //设置数据所在列的宽度,setColumnWidth的第二个参数要乘以256,这个参数的单位是1/256个字符宽度
|
|
|
548
|
+ sheet.setColumnWidth(0, 5*256);
|
|
|
549
|
+ sheet.setColumnWidth(1, 10*256);
|
|
|
550
|
+ sheet.setColumnWidth(2, 10*256);
|
|
|
551
|
+ sheet.setColumnWidth(3, 10*256);
|
|
|
552
|
+ sheet.setColumnWidth(4, 10*256);
|
|
|
553
|
+ sheet.setColumnWidth(5, 10*256);
|
|
|
554
|
+ sheet.setColumnWidth(6, 10*256);
|
|
|
555
|
+ sheet.setColumnWidth(7, 10*256);
|
|
|
556
|
+ sheet.setColumnWidth(8, 10*256);
|
|
|
557
|
+ sheet.setColumnWidth(9, 10*256);
|
|
|
558
|
+
|
|
|
559
|
+ HSSFCellStyle style = workbook.createCellStyle();
|
|
|
560
|
+ HSSFFont font = workbook.createFont();
|
|
|
561
|
+ font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
562
|
+ style.setFont(font);
|
|
|
563
|
+
|
|
|
564
|
+ HSSFCell cell = null;
|
|
|
565
|
+
|
|
|
566
|
+ cell = row.createCell(0);
|
|
|
567
|
+ cell.setCellValue("序号");
|
|
|
568
|
+ cell.setCellStyle(style);
|
|
|
569
|
+
|
|
|
570
|
+ cell = row.createCell(1);
|
|
|
571
|
+ cell.setCellValue("储存库点");
|
|
|
572
|
+ cell.setCellStyle(style);
|
|
|
573
|
+
|
|
|
574
|
+ cell = row.createCell(2);
|
|
|
575
|
+ cell.setCellValue("仓房名称");
|
|
|
576
|
+ cell.setCellStyle(style);
|
|
|
577
|
+
|
|
|
578
|
+ cell = row.createCell(3);
|
|
|
579
|
+ cell.setCellValue("货位名称");
|
|
|
580
|
+ cell.setCellStyle(style);
|
|
|
581
|
+
|
|
|
582
|
+ cell = row.createCell(4);
|
|
|
583
|
+ cell.setCellValue("粮油品种");
|
|
|
584
|
+ cell.setCellStyle(style);
|
|
|
585
|
+
|
|
|
586
|
+ cell = row.createCell(5);
|
|
|
587
|
+ cell.setCellValue("粮油性质");
|
|
|
588
|
+ cell.setCellStyle(style);
|
|
|
589
|
+
|
|
|
590
|
+ cell = row.createCell(6);
|
|
|
591
|
+ cell.setCellValue("库存数量(吨)");
|
|
|
592
|
+ cell.setCellStyle(style);
|
|
|
593
|
+
|
|
|
594
|
+ cell = row.createCell(7);
|
|
|
595
|
+ cell.setCellValue("已验收数量(吨)");
|
|
|
596
|
+ cell.setCellStyle(style);
|
|
|
597
|
+
|
|
|
598
|
+ cell = row.createCell(8);
|
|
|
599
|
+ cell.setCellValue("未验收数量(吨)");
|
|
|
600
|
+ cell.setCellStyle(style);
|
|
|
601
|
+
|
|
|
602
|
+ cell = row.createCell(9);
|
|
|
603
|
+ cell.setCellValue("收获年度");
|
|
|
604
|
+ cell.setCellStyle(style);
|
|
|
605
|
+ }
|
|
|
606
|
+
|
|
|
607
|
+ public String getEnum(Integer enumid) {
|
|
|
608
|
+ String strResult = basicEnumFeignService.getEnumData(enumid);
|
|
|
609
|
+ String enumname = "";
|
|
|
610
|
+ if (null != strResult && !"".equals(strResult)) {
|
|
|
611
|
+ JSONObject enum_obj = JSONObject.parseObject(strResult);
|
|
|
612
|
+ enumname = enum_obj.get("enumname")+"";
|
|
|
613
|
+ }
|
|
|
614
|
+ return enumname;
|
|
|
615
|
+ }
|
|
|
616
|
+
|
|
|
617
|
+ public String getStorehouse(Integer id, Integer orgId) {
|
|
|
618
|
+ String strResult = basicStorehouseFeignService.getStorehouse(id, orgId);
|
|
|
619
|
+ String storehouseName = "";
|
|
|
620
|
+ if (null != strResult && !"".equals(strResult)) {
|
|
|
621
|
+ JSONObject enum_obj = JSONObject.parseObject(strResult);
|
|
|
622
|
+ storehouseName = enum_obj.get("storehouseName")+"";
|
|
|
623
|
+ }
|
|
|
624
|
+ return storehouseName;
|
|
|
625
|
+ }
|
|
|
626
|
+
|
|
|
627
|
+ public String getWarehouse(Integer id) {
|
|
|
628
|
+ String strResult = basicWarehouseFeignService.getWarehouse(id);
|
|
|
629
|
+ String warehouseName = "";
|
|
|
630
|
+ if (null != strResult && !"".equals(strResult)) {
|
|
|
631
|
+ JSONObject enum_obj = JSONObject.parseObject(strResult);
|
|
|
632
|
+ warehouseName = enum_obj.get("warehouseName")+"";
|
|
|
633
|
+ }
|
|
|
634
|
+ return warehouseName;
|
|
|
635
|
+ }
|
|
470
|
636
|
}
|