Browse Source

Merge remote-tracking branch 'origin/master'

xs 5 years atrás
parent
commit
cdff37dbd0

+ 45 - 14
src/main/java/com/jeeplus/common/utils/excel/ExportExcel.java

@@ -19,6 +19,7 @@ import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.util.HSSFColor;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Comment;
@@ -180,6 +181,7 @@ public class ExportExcel {
 	public ExportExcel(String title, List<String> headerList) {
 		initialize(title, headerList);
 	}
+
 	
 	/**
 	 * 初始化函数
@@ -187,7 +189,7 @@ public class ExportExcel {
 	 * @param headerList 表头列表
 	 */
 	private void initialize(String title, List<String> headerList) {
-		this.wb = new SXSSFWorkbook(500);
+		this.wb = new SXSSFWorkbook(700);
 		this.sheet = wb.createSheet("Export");
 		this.styles = createStyles(wb);
 		// Create title
@@ -205,9 +207,39 @@ public class ExportExcel {
 			throw new RuntimeException("headerList not null!");
 		}
 		Row headerRow = sheet.createRow(rownum++);
-		headerRow.setHeightInPoints(16);
+		headerRow.setHeightInPoints(30);
+		Row headerRow1 = sheet.createRow(rownum++);
+		headerRow1.setHeightInPoints(30);
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 0, 0));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 1, 1));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
+		sheet.addMergedRegion(new CellRangeAddress(0, 0, 4, 5));
+		sheet.addMergedRegion(new CellRangeAddress(0, 0, 7, 8));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 8, 8));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 9, 9));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 10, 10));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 11, 11));
+		sheet.setColumnWidth(0, 2000);
+		sheet.setColumnWidth(1, 3000);
+		sheet.setColumnWidth(2, 2000);
+		sheet.setColumnWidth(3, 12000);
+		sheet.setColumnWidth(4, 2000);
+		sheet.setColumnWidth(5, 2000);
+		sheet.setColumnWidth(6, 2000);
+		sheet.setColumnWidth(7, 2000);
+		sheet.setColumnWidth(8, 3000);
+		sheet.setColumnWidth(9, 3000);
+		sheet.setColumnWidth(10, 3000);
+		sheet.setColumnWidth(11, 3000);
+		Cell tempCell1 = headerRow.createCell(4);
+		tempCell1.setCellValue("建筑工程费");
+		tempCell1.setCellStyle(styles.get("header"));
+		Cell tempCell = headerRow.createCell(7);
+		tempCell.setCellStyle(styles.get("header"));
+		tempCell.setCellValue("安装工程费");
 		for (int i = 0; i < headerList.size(); i++) {
-			Cell cell = headerRow.createCell(i);
+			Cell cell = headerRow1.createCell(i);
 			cell.setCellStyle(styles.get("header"));
 			String[] ss = StringUtils.split(headerList.get(i), "**", 2);
 			if (ss.length==2){
@@ -221,12 +253,17 @@ public class ExportExcel {
 			}
 			sheet.autoSizeColumn(i);
 		}
-		for (int i = 0; i < headerList.size(); i++) {  
+		for (int i = 0; i < headerList.size(); i++) {
 			int colWidth = sheet.getColumnWidth(i)*2;
-	        sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);  
+	        sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
 		}
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 1, 1));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 2, 2));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 3, 3));
 		log.debug("Initialize success.");
 	}
+
 	
 	/**
 	 * 创建表格样式
@@ -285,22 +322,16 @@ public class ExportExcel {
 		style.setFillPattern(CellStyle.SOLID_FOREGROUND);
 		Font headerFont = wb.createFont();
 		headerFont.setFontName("Arial");
-		headerFont.setFontHeightInPoints((short) 10);
+		headerFont.setFontHeightInPoints((short) 15);
 		headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
-		headerFont.setColor(IndexedColors.WHITE.getIndex());
+		headerFont.setColor(IndexedColors.BLACK.getIndex());
 		style.setFont(headerFont);
 		styles.put("header", style);
-		
 		return styles;
 	}
 
 
-//	private Map<String, CellStyle> createStyles(Workbook wb) {
-//
-//
-//
-//
-//	}
+
 
 	/**
 	 * 添加一行

+ 100 - 3
src/main/java/com/jeeplus/modules/sg/overheadline/entity/JkxlDetailFee.java

@@ -38,6 +38,34 @@ public class JkxlDetailFee {
     private String subjectAllocate;  //科目分配
     private String feeType;   //1:主体部分  2:其他部分
 
+    private double sbFee;      //设备费
+    private double jzFee;      //建筑费
+    private double sbgzFee;    //设备购置费
+    private double azFee;      //安装费
+    private double zcFee;     //装材费
+    private double qtFee;    //其他费用
+    private double jsFee;    //结算价
+    private double cFee;      //差额
+    private String hierarchy;  //层级
+    private Integer index;    //序号
+
+    @ExcelField(title="设备费", align=1, sort=6)
+    public double getSbFee() {
+        return sbFee;
+    }
+
+    public void setSbFee(double sbFee) {
+        this.sbFee = sbFee;
+    }
+
+    @ExcelField(title="建筑费", align=1, sort=5)
+    public double getJzFee() {
+        return jzFee;
+    }
+
+    public void setJzFee(double jzFee) {
+        this.jzFee = jzFee;
+    }
 
     public Double getGxFee() {
         return gxFee;
@@ -107,7 +135,7 @@ public class JkxlDetailFee {
         this.projectId = projectId;
     }
 
-    @ExcelField(title="元素描述", align=1, sort=2)
+    @ExcelField(title="元素描述", align=1, sort=4)
     public String getDescribe() {
         return describe;
     }
@@ -123,7 +151,7 @@ public class JkxlDetailFee {
     public void setParentNode(String parentNode) {
         this.parentNode = parentNode;
     }
-    @ExcelField(title="WBS识别码", align=2, sort=1)
+    @ExcelField(title="WBS识别码", align=2, sort=2)
     public String getWbsCode() {
         return wbsCode;
     }
@@ -132,7 +160,7 @@ public class JkxlDetailFee {
         this.wbsCode = wbsCode;
     }
 
-    @ExcelField(title="结算金额", align=2, sort=3)
+    @ExcelField(title="合计", align=2, sort=11)
     public Double getTotalFee() {
         return totalFee;
     }
@@ -313,5 +341,74 @@ public class JkxlDetailFee {
         this.tex = tex;
     }
 
+    @ExcelField(title="设备购置费", align=2, sort=7)
+    public double getSbgzFee() {
+        return sbgzFee;
+    }
 
+    public void setSbgzFee(double sbgzFee) {
+        this.sbgzFee = sbgzFee;
+    }
+    @ExcelField(title="安装费", align=2, sort=8)
+    public double getAzFee() {
+        return azFee;
+    }
+
+    public void setAzFee(double azFee) {
+        this.azFee = azFee;
+    }
+
+    @ExcelField(title="装材费", align=2, sort=9)
+    public double getZcFee() {
+        return zcFee;
+    }
+
+    public void setZcFee(double zcFee) {
+        this.zcFee = zcFee;
+    }
+
+    @ExcelField(title="其他费用", align=2, sort=10)
+    public double getQtFee() {
+        return qtFee;
+    }
+
+    public void setQtFee(double qtFee) {
+        this.qtFee = qtFee;
+    }
+
+    @ExcelField(title="结算价", align=2, sort=12)
+    public double getJsFee() {
+        return jsFee;
+    }
+
+    public void setJsFee(double jsFee) {
+        this.jsFee = jsFee;
+    }
+
+    @ExcelField(title="差额", align=2, sort=13)
+    public double getcFee() {
+        return cFee;
+    }
+
+    public void setcFee(double cFee) {
+        this.cFee = cFee;
+    }
+
+    @ExcelField(title="层级", align=2, sort=3)
+    public String getHierarchy() {
+        return hierarchy;
+    }
+
+    public void setHierarchy(String hierarchy) {
+        this.hierarchy = hierarchy;
+    }
+
+    @ExcelField(title="序号", align=2, sort=1)
+    public Integer getIndex() {
+        return index;
+    }
+
+    public void setIndex(Integer index) {
+        this.index = index;
+    }
 }

+ 15 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/mapper/xml/OverheadLineMapper.xml

@@ -84,6 +84,21 @@
          a.mount_matter as mountMatter,
          a.mount_server as mountServer,
          b.original_total_cost as originalTotalCost,
+		b.original_rg_cost as originalRgCost,
+		b.original_cbr_cost as originalCbrCost,
+		b.original_fbr_cost as originalFbrCost,
+		b.original_jx_cost as originalJxCost,
+		b.rg_cost as rgCost,
+		b.cbr_cost as cbrCost,
+		b.fbr_cost as fbrCost,
+		b.jx_cost as jxCost,
+		b.measures_fee1 as measuresFee1,
+		b.measures_fee2 as measuresFee2,
+		b.measures_fee3 as measuresFee3,
+		b.other_cost as otherCost,
+		b.tex as tex,
+		b.fees as fees,
+		b.zjgc_fee as zjgcFee,
          b.total_fee as totalFee
          FROM sg_wbs_elements a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
          and b.id = #{id}

+ 36 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/service/OverheadLineService.java

@@ -43,12 +43,38 @@ public class OverheadLineService {
 
    public List<JkxlDetailFee> findList(String id){
        List<JkxlDetailFee> list = overheadLineMapper.findList(id);
+       JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
+       jkxlAdjustFee.setId(id);
+       jkxlAdjustFee.setType(BashInfo.CE);
+       List<JkxlAdjustFee> jkxlAdjustFees = feeAdjustService.getTzFee(jkxlAdjustFee);
+       JkxlAdjustFee jkxlAdjustFee1 = jkxlAdjustFees.get(0);
+       double cFee = jkxlAdjustFee1.getFee();
        double btTotal = 0.00;
        double qtTotal = 0.00;
+       double azTotal = 0.00;
+       double otherTotal = 0.00;
+       for(JkxlDetailFee jkxlDetailFee : list){
+           double measuresFee1 = jkxlDetailFee.getMeasuresFee1()!=null? jkxlDetailFee.getMeasuresFee1():0.00;
+           double measuresFee2 = jkxlDetailFee.getMeasuresFee2()!=null? jkxlDetailFee.getMeasuresFee2():0.00;
+           double measuresFee3 = jkxlDetailFee.getMeasuresFee3()!=null? jkxlDetailFee.getMeasuresFee3():0.00;
+           double otherCost = jkxlDetailFee.getTex()!=null? jkxlDetailFee.getTex():0.00;
+           double Fees = jkxlDetailFee.getOtherCost()!=null? jkxlDetailFee.getOtherCost():0.00;
+           double Tex = jkxlDetailFee.getFees()!=null? jkxlDetailFee.getFees():0.00;
+           double qtFee = measuresFee1 + measuresFee2 + measuresFee3 + otherCost + Fees + Tex;
+           double rgFee = jkxlDetailFee.getRgCost()!=null? jkxlDetailFee.getRgCost():0.00;
+           double cbrFee = jkxlDetailFee.getCbrCost()!=null? jkxlDetailFee.getCbrCost():0.00;
+           double fbrFee = jkxlDetailFee.getFbrCost()!=null? jkxlDetailFee.getFbrCost():0.00;
+           double jxFee = jkxlDetailFee.getJxCost()!=null? jkxlDetailFee.getJxCost():0.00;
+           double azFee = rgFee + cbrFee + fbrFee + jxFee;
+           jkxlDetailFee.setQtFee(qtFee);
+           jkxlDetailFee.setAzFee(azFee);
+       }
        for(JkxlDetailFee jkxlDetailFee : list){
            //本体费用求和
            if(jkxlDetailFee.getOriginalTotalCost() != null){
                btTotal += jkxlDetailFee.getTotalFee();
+               azTotal += jkxlDetailFee.getAzFee();
+               otherTotal += jkxlDetailFee.getQtFee();
            }
            //其他费用求和
            if(jkxlDetailFee.getOriginalTotalCost() == null && jkxlDetailFee.getTotalFee() != null){
@@ -58,14 +84,24 @@ public class OverheadLineService {
        for(JkxlDetailFee jkxlDetailFee : list){
            if(jkxlDetailFee.getWbsCode().equals("30000000")){
                jkxlDetailFee.setTotalFee(btTotal+qtTotal);
+               jkxlDetailFee.setAzFee(azTotal);
+               jkxlDetailFee.setQtFee(otherTotal);
+               jkxlDetailFee.setcFee(cFee);
+               jkxlDetailFee.setJsFee(btTotal+qtTotal+cFee);
            }
            if(jkxlDetailFee.getWbsCode().equals("39000000")){
                jkxlDetailFee.setTotalFee(btTotal);
+               jkxlDetailFee.setAzFee(azTotal);
+               jkxlDetailFee.setQtFee(otherTotal);
            }
            if(jkxlDetailFee.getWbsCode().equals("34000000")){
                jkxlDetailFee.setTotalFee(qtTotal);
+
            }
        }
+       for (int i=0;i<list.size();i++){
+           list.get(i).setIndex(i+1);
+       }
        return list;
 
    }

+ 1 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/util/BashInfo.java

@@ -409,4 +409,5 @@ public class BashInfo {
         return list;
     }
 
+
 }

+ 582 - 0
src/main/java/com/jeeplus/modules/sg/project/util/ExportUtil.java

@@ -0,0 +1,582 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.project.util;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.utils.Encodes;
+import com.jeeplus.common.utils.Reflections;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.modules.sys.utils.DictUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * 导出Excel文件(导出“XLSX”格式,支持大数据量导出   @see org.apache.poi.ss.SpreadsheetVersion)
+ * @author jeeplus
+ * @version 2016-04-21
+ */
+public class ExportUtil {
+
+	private static Logger log = LoggerFactory.getLogger(ExportUtil.class);
+
+	/**
+	 * 工作薄对象
+	 */
+	private SXSSFWorkbook wb;
+
+	/**
+	 * 工作表对象
+	 */
+	private Sheet sheet;
+
+	/**
+	 * 样式列表
+	 */
+	private Map<String, CellStyle> styles;
+
+	/**
+	 * 当前行号
+	 */
+	private int rownum;
+
+
+	/**
+	 * 注解列表(Object[]{ ExcelField, Field/Method })
+	 */
+	List<Object[]> annotationList = Lists.newArrayList();
+
+	/**
+	 * 构造函数
+	 * @param title 表格标题,传“空值”,表示无标题
+	 * @param cls 实体对象,通过annotation.ExportField获取标题
+	 */
+
+	public ExportUtil(String title, Class<?> cls,String[] st){
+		this(title, cls, 1,st);
+	}
+
+	/**
+	 * 构造函数
+	 * @param title 表格标题,传“空值”,表示无标题
+	 * @param cls 实体对象,通过annotation.ExportField获取标题
+	 * @param type 导出类型(1:导出数据;2:导出模板)
+	 * @param groups 导入分组
+	 */
+	public ExportUtil(String title, Class<?> cls, int type,String[] st, int... groups){
+		// Get annotation field
+		Field[] fs = cls.getDeclaredFields();
+		for (Field f : fs){
+			ExcelField ef = f.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==type)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, f});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, f});
+				}
+			}
+		}
+		// Get annotation method
+		Method[] ms = cls.getDeclaredMethods();
+		for (Method m : ms){
+			ExcelField ef = m.getAnnotation(ExcelField.class);
+			if (ef != null && (ef.type()==0 || ef.type()==type)){
+				if (groups!=null && groups.length>0){
+					boolean inGroup = false;
+					for (int g : groups){
+						if (inGroup){
+							break;
+						}
+						for (int efg : ef.groups()){
+							if (g == efg){
+								inGroup = true;
+								annotationList.add(new Object[]{ef, m});
+								break;
+							}
+						}
+					}
+				}else{
+					annotationList.add(new Object[]{ef, m});
+				}
+			}
+		}
+		// Field sorting
+		Collections.sort(annotationList, new Comparator<Object[]>() {
+			public int compare(Object[] o1, Object[] o2) {
+				return new Integer(((ExcelField)o1[0]).sort()).compareTo(
+						new Integer(((ExcelField)o2[0]).sort()));
+			};
+		});
+		// Initialize
+		List<String> headerList = Lists.newArrayList();
+		for (Object[] os : annotationList){
+			String t = ((ExcelField)os[0]).title();
+			// 如果是导出,则去掉注释
+			if (type==1){
+				String[] ss = StringUtils.split(t, "**", 2);
+				if (ss.length==2){
+					t = ss[0];
+				}
+			}
+			headerList.add(t);
+		}
+		initialize(title, headerList,st);
+	}
+
+	/**
+	 * 构造函数
+	 * @param title 表格标题,传“空值”,表示无标题
+	 * @param headers 表头数组
+	 */
+	public ExportUtil(String title, String[] headers) {
+		initialize(title, Lists.newArrayList(headers));
+	}
+
+	/**
+	 * 构造函数
+	 * @param title 表格标题,传“空值”,表示无标题
+	 * @param headerList 表头列表
+	 */
+	public ExportUtil(String title, List<String> headerList) {
+		initialize(title, headerList);
+	}
+
+	public ExportUtil(String title, List<String> headerList, String[] st) {
+		initialize(title, headerList ,st);
+	}
+	
+	/**
+	 * 初始化函数
+	 * @param title 表格标题,传“空值”,表示无标题
+	 * @param headerList 表头列表
+	 */
+	private void initialize(String title, List<String> headerList) {
+		this.wb = new SXSSFWorkbook(700);
+		this.sheet = wb.createSheet("Export");
+		this.styles = createStyles(wb);
+		// Create title
+		if (StringUtils.isNotBlank(title)){
+			Row titleRow = sheet.createRow(rownum++);
+			titleRow.setHeightInPoints(30);
+			Cell titleCell = titleRow.createCell(0);
+			titleCell.setCellStyle(styles.get("title"));
+			titleCell.setCellValue(title);
+			sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
+					titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));
+		}
+		// Create header
+		if (headerList == null){
+			throw new RuntimeException("headerList not null!");
+		}
+		Row headerRow = sheet.createRow(rownum++);
+		headerRow.setHeightInPoints(30);
+		Row headerRow1 = sheet.createRow(rownum++);
+		headerRow1.setHeightInPoints(30);
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 0, 0));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 1, 1));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
+		sheet.addMergedRegion(new CellRangeAddress(0, 0, 4, 5));
+		sheet.addMergedRegion(new CellRangeAddress(0, 0, 7, 8));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 8, 8));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 9, 9));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 10, 10));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 11, 11));
+		sheet.setColumnWidth(0, 2000);
+		sheet.setColumnWidth(1, 3000);
+		sheet.setColumnWidth(2, 2000);
+		sheet.setColumnWidth(3, 12000);
+		sheet.setColumnWidth(4, 2000);
+		sheet.setColumnWidth(5, 2000);
+		sheet.setColumnWidth(6, 2000);
+		sheet.setColumnWidth(7, 2000);
+		sheet.setColumnWidth(8, 3000);
+		sheet.setColumnWidth(9, 3000);
+		sheet.setColumnWidth(10, 3000);
+		sheet.setColumnWidth(11, 3000);
+		Cell tempCell1 = headerRow.createCell(4);
+		tempCell1.setCellValue("建筑工程费");
+		tempCell1.setCellStyle(styles.get("header"));
+		Cell tempCell = headerRow.createCell(7);
+		tempCell.setCellStyle(styles.get("header"));
+		tempCell.setCellValue("安装工程费");
+		for (int i = 0; i < headerList.size(); i++) {
+			Cell cell = headerRow1.createCell(i);
+			cell.setCellStyle(styles.get("header"));
+			String[] ss = StringUtils.split(headerList.get(i), "**", 2);
+			if (ss.length==2){
+				cell.setCellValue(ss[0]);
+				Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
+						new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
+				comment.setString(new XSSFRichTextString(ss[1]));
+				cell.setCellComment(comment);
+			}else{
+				cell.setCellValue(headerList.get(i));
+			}
+			sheet.autoSizeColumn(i);
+		}
+		for (int i = 0; i < headerList.size(); i++) {
+			int colWidth = sheet.getColumnWidth(i)*2;
+	        sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
+		}
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 1, 1));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 2, 2));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 3, 3));
+		log.debug("Initialize success.");
+	}
+	private void initialize(String title, List<String> headerList ,String[] st) {
+		this.wb = new SXSSFWorkbook(700);
+		for(int j=0;j<st.length;j++) {
+			rownum=0;
+			this.sheet = wb.createSheet(st[j]);
+			this.styles = createStyles(wb);
+			// Create title
+			if (StringUtils.isNotBlank(title)) {
+				Row titleRow = sheet.createRow(rownum++);
+				titleRow.setHeightInPoints(30);
+				Cell titleCell = titleRow.createCell(0);
+				titleCell.setCellStyle(styles.get("title"));
+				titleCell.setCellValue(title);
+				sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
+						titleRow.getRowNum(), titleRow.getRowNum(), headerList.size() - 1));
+			}
+			// Create header
+			if (headerList == null) {
+				throw new RuntimeException("headerList not null!");
+			}
+			Row headerRow = sheet.createRow(rownum++);
+			headerRow.setHeightInPoints(30);
+			Row headerRow1 = sheet.createRow(rownum++);
+			headerRow1.setHeightInPoints(30);
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 0, 0));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 1, 1));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
+			sheet.addMergedRegion(new CellRangeAddress(0, 0, 4, 5));
+			sheet.addMergedRegion(new CellRangeAddress(0, 0, 7, 8));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 8, 8));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 9, 9));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 10, 10));
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 11, 11));
+			sheet.setColumnWidth(0, 2000);
+			sheet.setColumnWidth(1, 3000);
+			sheet.setColumnWidth(2, 2000);
+			sheet.setColumnWidth(3, 12000);
+			sheet.setColumnWidth(4, 2000);
+			sheet.setColumnWidth(5, 2000);
+			sheet.setColumnWidth(6, 2000);
+			sheet.setColumnWidth(7, 2000);
+			sheet.setColumnWidth(8, 3000);
+			sheet.setColumnWidth(9, 3000);
+			sheet.setColumnWidth(10, 3000);
+			sheet.setColumnWidth(11, 3000);
+			Cell tempCell1 = headerRow.createCell(4);
+			tempCell1.setCellValue("建筑工程费");
+			tempCell1.setCellStyle(styles.get("header"));
+			Cell tempCell = headerRow.createCell(7);
+			tempCell.setCellStyle(styles.get("header"));
+			tempCell.setCellValue("安装工程费");
+			for (int i = 0; i < headerList.size(); i++) {
+				Cell cell = headerRow1.createCell(i);
+				cell.setCellStyle(styles.get("header"));
+				String[] ss = StringUtils.split(headerList.get(i), "**", 2);
+				if (ss.length == 2) {
+					cell.setCellValue(ss[0]);
+					Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
+							new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
+					comment.setString(new XSSFRichTextString(ss[1]));
+					cell.setCellComment(comment);
+				} else {
+					cell.setCellValue(headerList.get(i));
+				}
+				sheet.autoSizeColumn(i);
+			}
+			for (int i = 0; i < headerList.size(); i++) {
+				int colWidth = sheet.getColumnWidth(i) * 2;
+				sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
+			}
+//		sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 1, 1));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 2, 2));
+//		sheet.addMergedRegion(new CellRangeAddress(1, 0, 3, 3));
+			log.debug("Initialize success.");
+		}
+	}
+	
+	/**
+	 * 创建表格样式
+	 * @param wb 工作薄对象
+	 * @return 样式列表
+	 */
+	private Map<String, CellStyle> createStyles(Workbook wb) {
+		Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
+		
+		CellStyle style = wb.createCellStyle();
+		style.setAlignment(CellStyle.ALIGN_CENTER);
+		style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+		Font titleFont = wb.createFont();
+		titleFont.setFontName("Arial");
+		titleFont.setFontHeightInPoints((short) 16);
+		titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+		style.setFont(titleFont);
+		styles.put("title", style);
+
+		style = wb.createCellStyle();
+		style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
+		style.setBorderRight(CellStyle.BORDER_THIN);
+		style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
+		style.setBorderLeft(CellStyle.BORDER_THIN);
+		style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
+		style.setBorderTop(CellStyle.BORDER_THIN);
+		style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
+		style.setBorderBottom(CellStyle.BORDER_THIN);
+		style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
+		Font dataFont = wb.createFont();
+		dataFont.setFontName("Arial");
+		dataFont.setFontHeightInPoints((short) 10);
+		style.setFont(dataFont);
+		styles.put("data", style);
+		
+		style = wb.createCellStyle();
+		style.cloneStyleFrom(styles.get("data"));
+		style.setAlignment(CellStyle.ALIGN_LEFT);
+		styles.put("data1", style);
+
+		style = wb.createCellStyle();
+		style.cloneStyleFrom(styles.get("data"));
+		style.setAlignment(CellStyle.ALIGN_CENTER);
+		styles.put("data2", style);
+
+		style = wb.createCellStyle();
+		style.cloneStyleFrom(styles.get("data"));
+		style.setAlignment(CellStyle.ALIGN_RIGHT);
+		styles.put("data3", style);
+		
+		style = wb.createCellStyle();
+		style.cloneStyleFrom(styles.get("data"));
+//		style.setWrapText(true);
+		style.setAlignment(CellStyle.ALIGN_CENTER);
+		style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
+		style.setFillPattern(CellStyle.SOLID_FOREGROUND);
+		Font headerFont = wb.createFont();
+		headerFont.setFontName("Arial");
+		headerFont.setFontHeightInPoints((short) 15);
+		headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
+		headerFont.setColor(IndexedColors.BLACK.getIndex());
+		style.setFont(headerFont);
+		styles.put("header", style);
+		return styles;
+	}
+
+
+
+
+	/**
+	 * 添加一行
+	 * @return 行对象
+	 */
+	public Row addRow(int i){
+		return wb.getSheetAt(i).createRow(rownum++);
+	}
+	
+
+	/**
+	 * 添加一个单元格
+	 * @param row 添加的行
+	 * @param column 添加列号
+	 * @param val 添加值
+	 * @return 单元格对象
+	 */
+	public Cell addCell(Row row, int column, Object val){
+		return this.addCell(row, column, val, 0, Class.class);
+	}
+	
+	/**
+	 * 添加一个单元格
+	 * @param row 添加的行
+	 * @param column 添加列号
+	 * @param val 添加值
+	 * @param align 对齐方式(1:靠左;2:居中;3:靠右)
+	 * @return 单元格对象
+	 */
+	public Cell addCell(Row row, int column, Object val, int align, Class<?> fieldType){
+		Cell cell = row.createCell(column);
+		CellStyle style = styles.get("data"+(align>=1&&align<=3?align:""));
+		try {
+			if (val == null){
+				cell.setCellValue("");
+			} else if (val instanceof String) {
+				cell.setCellValue((String) val);
+			} else if (val instanceof Integer) {
+				cell.setCellValue((Integer) val);
+			} else if (val instanceof Long) {
+				cell.setCellValue((Long) val);
+			} else if (val instanceof Double) {
+				cell.setCellValue((Double) val);
+			} else if (val instanceof Float) {
+				cell.setCellValue((Float) val);
+			} else if (val instanceof Date) {
+				DataFormat format = wb.createDataFormat();
+	            style.setDataFormat(format.getFormat("yyyy-MM-dd"));
+				cell.setCellValue((Date) val);
+			} else {
+				if (fieldType != Class.class){
+					cell.setCellValue((String)fieldType.getMethod("setValue", Object.class).invoke(null, val));
+				}else{
+					cell.setCellValue((String)Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(), 
+						"fieldtype."+val.getClass().getSimpleName()+"Type")).getMethod("setValue", Object.class).invoke(null, val));
+				}
+			}
+		} catch (Exception ex) {
+			log.info("Set cell value ["+row.getRowNum()+","+column+"] error: " + ex.toString());
+			cell.setCellValue(val.toString());
+		}
+		cell.setCellStyle(style);
+		return cell;
+	}
+
+	/**
+	 * 添加数据(通过annotation.ExportField添加数据)
+	 * @return list 数据列表
+	 */
+	public <E> ExportUtil setDataList(List<E> list ,int i){
+		for (E e : list){
+			int colunm = 0;
+			Row row = this.addRow(i);
+			StringBuilder sb = new StringBuilder();
+			for (Object[] os : annotationList){
+				ExcelField ef = (ExcelField)os[0];
+				Object val = null;
+				// Get entity value
+				try{
+					if (StringUtils.isNotBlank(ef.value())){
+						val = Reflections.invokeGetter(e, ef.value());
+					}else{
+						if (os[1] instanceof Field){
+							val = Reflections.invokeGetter(e, ((Field)os[1]).getName());
+						}else if (os[1] instanceof Method){
+							val = Reflections.invokeMethod(e, ((Method)os[1]).getName(), new Class[] {}, new Object[] {});
+						}
+					}
+					// If is dict, get dict label
+					if (StringUtils.isNotBlank(ef.dictType())){
+						val = DictUtils.getDictLabel(val==null?"":val.toString(), ef.dictType(), "");
+					}
+				}catch(Exception ex) {
+					// Failure to ignore
+					log.info(ex.toString());
+					val = "";
+				}
+				this.addCell(row, colunm++, val, ef.align(), ef.fieldType());
+				sb.append(val + ", ");
+			}
+			log.debug("Write success: ["+row.getRowNum()+"] "+sb.toString());
+		}
+		return this;
+	}
+	
+	/**
+	 * 输出数据流
+	 * @param os 输出数据流
+	 */
+	public ExportUtil write(OutputStream os) throws IOException{
+		wb.write(os);
+		return this;
+	}
+	
+	/**
+	 * 输出到客户端
+	 * @param fileName 输出文件名
+	 */
+	public ExportUtil write(HttpServletResponse response, String fileName) throws IOException{
+		response.reset();
+        response.setContentType("application/octet-stream; charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment; filename="+Encodes.urlEncode(fileName));
+		write(response.getOutputStream());
+		return this;
+	}
+	
+	/**
+	 * 输出到文件
+	 * @param name 输出文件名
+	 */
+	public ExportUtil writeFile(String name) throws FileNotFoundException, IOException{
+		FileOutputStream os = new FileOutputStream(name);
+		this.write(os);
+		return this;
+	}
+	
+	/**
+	 * 清理临时文件
+	 */
+	public ExportUtil dispose(){
+		wb.dispose();
+		return this;
+	}
+	
+//	/**
+//	 * 导出测试
+//	 */
+//	public static void main(String[] args) throws Throwable {
+//		
+//		List<String> headerList = Lists.newArrayList();
+//		for (int i = 1; i <= 10; i++) {
+//			headerList.add("表头"+i);
+//		}
+//		
+//		List<String> dataRowList = Lists.newArrayList();
+//		for (int i = 1; i <= headerList.size(); i++) {
+//			dataRowList.add("数据"+i);
+//		}
+//		
+//		List<List<String>> dataList = Lists.newArrayList();
+//		for (int i = 1; i <=1000000; i++) {
+//			dataList.add(dataRowList);
+//		}
+//
+//		ExportExcel ee = new ExportExcel("表格标题", headerList);
+//		
+//		for (int i = 0; i < dataList.size(); i++) {
+//			Row row = ee.addRow();
+//			for (int j = 0; j < dataList.get(i).size(); j++) {
+//				ee.addCell(row, j, dataList.get(i).get(j));
+//			}
+//		}
+//		
+//		ee.writeFile("target/export.xlsx");
+//
+//		ee.dispose();
+//		
+//		log.debug("Export success.");
+//		
+//	}
+
+}

+ 25 - 3
src/main/java/com/jeeplus/modules/sg/project/web/ProjectController.java

@@ -1,11 +1,16 @@
 package com.jeeplus.modules.sg.project.web;
 
 import com.jeeplus.common.json.AjaxJson;
+import com.jeeplus.common.utils.DateUtils;
 import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.core.web.BaseController;
+import com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee;
+import com.jeeplus.modules.sg.overheadline.service.OverheadLineService;
+import com.jeeplus.modules.sg.project.entity.WbsItem;
 import com.jeeplus.modules.sg.project.entity.WbsProject;
 import com.jeeplus.modules.sg.project.entity.WbsSelection;
 import com.jeeplus.modules.sg.project.service.ProjectService;
+import com.jeeplus.modules.sg.project.util.ExportUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.ModelAttribute;
@@ -17,6 +22,7 @@ import org.springframework.ui.Model;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -28,6 +34,9 @@ public class ProjectController extends BaseController {
     private HttpServletRequest request;
     @Autowired
     private ProjectService projectService;
+    @Autowired
+    private OverheadLineService overheadLineService;
+
 
     @ModelAttribute
     public WbsProject get(@RequestParam(required=false) String id) {
@@ -84,10 +93,23 @@ public class ProjectController extends BaseController {
     }
 
     //项目编辑
-    @RequestMapping("/toList")
-    public String toList(HttpServletRequest request,Model model){
+    @RequestMapping("/export")
+    public String toList(HttpServletRequest request,Model model,HttpServletResponse response) throws IOException {
         String id = request.getParameter("id");
-        return "redirect:/a/jkxl/list?id="+id;
+        WbsProject wbsProject = projectService.get(id);
+        String fileName = wbsProject.getProjectName()+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+        List<WbsItem> wbsItems = wbsProject.getWbsItems();
+        String[] sts = new String[wbsItems.size()];
+        for (int i=0;i<wbsItems.size();i++){
+            sts[i] = wbsItems.get(i).getItemName();
+        }
+        ExportUtil exportUtil = new ExportUtil(null, JkxlDetailFee.class,sts);
+        for(int j=0;j<wbsItems.size();j++){
+            List<JkxlDetailFee> jkxlDetailFees = overheadLineService.findList(wbsItems.get(j).getId());
+            exportUtil.setDataList(jkxlDetailFees,j);
+        }
+        exportUtil.write(response,fileName).dispose();
+        return "redirect:/a/project/list";
     }
 
     //项目删除

+ 1 - 1
src/main/webapp/webpage/modules/sg/project/management.jsp

@@ -188,7 +188,7 @@
                                 xml += "<a class='layui-btn layui-btn-primary layui-btn-xs' onclick=\"look( '${ctx}/project/form?id=" + d.id + "&tabId=1')\">查看</a>"
                                     +"<a class='layui-btn layui-btn-xs'  onclick=\"update( '${ctx}/project/form?id=" + d.id + "&tabId=2')\">修改</a>"
                                     +"<a class='layui-btn layui-btn-normal layui-btn-xs' lay-event='add'>添加项目</a>"
-                                    +"<a class='layui-btn layui-btn-warm layui-btn-xs' lay-event=''>导出</a>";
+                                    +"<a class='layui-btn layui-btn-warm layui-btn-xs' lay-event=''href=\"${ctx}/project/export?id=" + d.id+"\">导出</a>";
                             }
                             if(d.status==2){
                                 xml +="<span class='myspan'>操作</span>";