蔡德晨 5 år sedan
förälder
incheckning
91556d2349

+ 19 - 6
src/main/java/com/jeeplus/modules/sg/financial/settlement/service/DataMaintenanceService.java

@@ -81,13 +81,26 @@ public class DataMaintenanceService extends CrudService<DataMaintenanceMapper, M
 			e.printStackTrace();
 		} finally {
 		}
+        	}
 
 
-
-
-
-
-
-        	}
+	public void exportHeard( HttpServletResponse response){
+		Workbook workbook = null;
+		try {
+			workbook = ExcelWriter.exportHeard();
+			long time = System.currentTimeMillis();
+			String outFile = time + ".xlsx";
+			OutputStream outputStream = response.getOutputStream();
+			response.reset();
+			response.setHeader("Content-Disposition", "attachment;filename="+outFile);
+			response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+			workbook.write(outputStream);
+			outputStream.flush();
+			outputStream.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+		}
+	}
 	
 }

+ 227 - 2
src/main/java/com/jeeplus/modules/sg/financial/settlement/util/ExcelWriter.java

@@ -9,6 +9,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  *
@@ -44,6 +45,26 @@ public class ExcelWriter {
         return workbook;
     }
 
+
+    public static Workbook exportHeard(){
+        // 生成xlsx的Excel
+        Workbook workbook = new SXSSFWorkbook();
+        // 生成Sheet表,写入第一行的列头
+        Sheet sheet = buildHerd(workbook);
+        List<MaintainData> dataList = new LinkedList<>();
+        int rowNum = 3;
+        for (Iterator<MaintainData> it = dataList.iterator(); it.hasNext(); ) {
+            MaintainData data = it.next();
+            if (data == null) {
+                continue;
+            }
+            //输出行数据
+            Row row = sheet.createRow(rowNum++);
+            convertDataToRow(data, row);
+        }
+        return workbook;
+    }
+
     /**
      * 生成sheet表,并写入第一行数据(列头)
      * @param workbook 工作簿对象
@@ -72,6 +93,7 @@ public class ExcelWriter {
         sheet.addMergedRegion(new CellRangeAddress(2, 1, 11, 11));
         sheet.addMergedRegion(new CellRangeAddress(2, 1, 12, 12));
         sheet.addMergedRegion(new CellRangeAddress(1, 1, 13, 18));
+        sheet.addMergedRegion(new CellRangeAddress(2, 1, 19, 19));
         // 构建头单元格样式
         styles = createStyles(sheet.getWorkbook());
         CellStyle cellStyle = buildHeadCellStyle(sheet.getWorkbook());
@@ -205,6 +227,12 @@ public class ExcelWriter {
         Cell celll = row3.createCell(11);
         celll.setCellValue("");
         celll.setCellStyle(styles.get("header"));
+        Cell celll1 = row3.createCell(19);
+        celll1.setCellValue("");
+        celll1.setCellStyle(styles.get("header"));
+        Cell celll11 = row1.createCell(19);
+        celll11.setCellValue("");
+        celll11.setCellStyle(styles.get("header"));
 
         Cell cell9 = row2.createCell(12);
         cell9.setCellValue("主材费");
@@ -212,6 +240,9 @@ public class ExcelWriter {
         Cell cell10 = row2.createCell(13);
         cell10.setCellValue("其他费用");
         cell10.setCellStyle(styles.get("header"));
+        Cell cell101 = row2.createCell(19);
+        cell101.setCellValue("合计");
+        cell101.setCellStyle(styles.get("header"));
         Cell cell11 = row3.createCell(13);
         cell11.setCellValue("设计费");
         cell11.setCellStyle(styles.get("header"));
@@ -228,7 +259,7 @@ public class ExcelWriter {
         cell15.setCellValue("法人管理费(余物清理费)");
         cell15.setCellStyle(styles.get("header"));
         Cell cell16 = row3.createCell(18);
-        cell16.setCellValue("计");
+        cell16.setCellValue("计");
         cell16.setCellStyle(styles.get("header"));
         return sheet;
     }
@@ -463,10 +494,204 @@ public class ExcelWriter {
         cell = row.createCell(cellNum++);
         cell.setCellStyle(styles.get("data"));
         if (null != maintainData.getTotalFee()) {
-            cell.setCellValue(maintainData.getTotalFee());
+            cell.setCellValue(maintainData.getDesignFee()+maintainData.getSupervisionFee()+maintainData.getPreliminaryWorkFee()
+                              +maintainData.getDamages()+maintainData.getManagementFee());
+        } else {
+            cell.setCellValue("");
+        }
+        cell = row.createCell(cellNum++);
+        cell.setCellStyle(styles.get("data"));
+        if (null != maintainData.getTotalFee()) {
+            cell.setCellValue(maintainData.getDesignFee()+maintainData.getSupervisionFee()+maintainData.getPreliminaryWorkFee()
+                    +maintainData.getDamages()+maintainData.getManagementFee()+maintainData.getBuildingFee()+maintainData.getInstallFee()
+                    +maintainData.getEquipmentFee()+maintainData.getMaterialFee());
         } else {
             cell.setCellValue("");
         }
 
     }
+
+    private static Sheet buildHerd(Workbook workbook) {
+        Sheet sheet = workbook.createSheet();
+        // 设置列头宽度
+//        for (int i=0; i<CELL_HEADS.size(); i++) {
+//            sheet.setColumnWidth(i, 4000);
+//        }
+        // 设置默认行高
+        sheet.setDefaultRowHeight((short) 400);
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 0, 0));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 1, 1));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 2, 2));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 3, 3));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 4, 4));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 5, 5));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 6, 6));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 7, 7));
+        sheet.addMergedRegion(new CellRangeAddress(2, 0, 8, 8));
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 9, 17));
+        sheet.addMergedRegion(new CellRangeAddress(2, 1, 9, 9));
+        sheet.addMergedRegion(new CellRangeAddress(2, 1, 10, 10));
+        sheet.addMergedRegion(new CellRangeAddress(2, 1, 11, 11));
+        sheet.addMergedRegion(new CellRangeAddress(2, 1, 12, 12));
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 13, 17));
+        // 构建头单元格样式
+        styles = createStyles(sheet.getWorkbook());
+        CellStyle cellStyle = buildHeadCellStyle(sheet.getWorkbook());
+
+
+
+        // 写入第一行各列的数据
+        Row row1 = sheet.createRow(0);
+        Row row2 = sheet.createRow(1);
+        Row row3 = sheet.createRow(2);
+        Cell cell1 = row1.createCell(0);
+        cell1.setCellValue("项目定义编码");
+        cell1.setCellStyle(styles.get("header"));
+        Cell cella1 = row1.createCell(1);
+        cella1.setCellValue("设计单位");
+        cella1.setCellStyle(styles.get("header"));
+        Cell cellb1 = row1.createCell(2);
+        cellb1.setCellValue("施工单位");
+        cellb1.setCellStyle(styles.get("header"));
+        Cell cellc1 = row1.createCell(3);
+        cellc1.setCellValue("建筑地址");
+        cellc1.setCellStyle(styles.get("header"));
+        Cell celld1 = row1.createCell(4);
+        celld1.setCellValue("建筑属性");
+        celld1.setCellStyle(styles.get("header"));
+        Cell celle1 = row1.createCell(5);
+        celle1.setCellValue("发文总投资");
+        celle1.setCellStyle(styles.get("header"));
+        Cell cell2 = row1.createCell(6);
+        cell2.setCellValue("开工时间");
+        cell2.setCellStyle(styles.get("header"));
+        Cell cell3 = row1.createCell(7);
+        cell3.setCellValue("竣工时间");
+        cell3.setCellStyle(styles.get("header"));
+        Cell cell4 = row1.createCell(8);
+        cell4.setCellValue("批准文号");
+        cell4.setCellStyle(styles.get("header"));
+
+
+        Cell cella = row2.createCell(0);
+        cella.setCellValue("");
+        cella.setCellStyle(styles.get("header"));
+        Cell cella2 = row2.createCell(1);
+        cella2.setCellValue("");
+        cella2.setCellStyle(styles.get("header"));
+        Cell cella3 = row2.createCell(2);
+        cella3.setCellValue("");
+        cella3.setCellStyle(styles.get("header"));
+        Cell cella4 = row2.createCell(3);
+        cella4.setCellValue("");
+        cella4.setCellStyle(styles.get("header"));
+        Cell cella5 = row2.createCell(4);
+        cella5.setCellValue("");
+        cella5.setCellStyle(styles.get("header"));
+        Cell cella6 = row2.createCell(5);
+        cella6.setCellValue("");
+        cella6.setCellStyle(styles.get("header"));
+        Cell cellb = row2.createCell(6);
+        cellb.setCellValue("");
+        cellb.setCellStyle(styles.get("header"));
+        Cell cellc = row2.createCell(7);
+        cellc.setCellValue("");
+        cellc.setCellStyle(styles.get("header"));
+        Cell celld = row2.createCell(8);
+        celld.setCellValue("");
+        celld.setCellStyle(styles.get("header"));
+
+        Cell cellm = row2.createCell(14);
+        cellm.setCellValue("");
+        cellm.setCellStyle(styles.get("header"));
+        Cell celln = row2.createCell(15);
+        celln.setCellValue("");
+        celln.setCellStyle(styles.get("header"));
+        Cell cello = row2.createCell(16);
+        cello.setCellValue("");
+        cello.setCellStyle(styles.get("header"));
+        Cell cellp = row2.createCell(17);
+        cellp.setCellValue("");
+        cellp.setCellStyle(styles.get("header"));
+
+        Cell celle = row3.createCell(0);
+        celle.setCellValue("");
+        celle.setCellStyle(styles.get("header"));
+        Cell celle6 = row3.createCell(1);
+        celle6.setCellValue("");
+        celle6.setCellStyle(styles.get("header"));
+        Cell celle2 = row3.createCell(2);
+        celle2.setCellValue("");
+        celle2.setCellStyle(styles.get("header"));
+        Cell celle3 = row3.createCell(3);
+        celle3.setCellValue("");
+        celle3.setCellStyle(styles.get("header"));
+        Cell celle4 = row3.createCell(4);
+        celle4.setCellValue("");
+        celle4.setCellStyle(styles.get("header"));
+        Cell celle5 = row3.createCell(5);
+        celle5.setCellValue("");
+        celle5.setCellStyle(styles.get("header"));
+        Cell cellf = row3.createCell(6);
+        cellf.setCellValue("");
+        cellf.setCellStyle(styles.get("header"));
+        Cell cellg = row3.createCell(7);
+        cellg.setCellValue("");
+        cellg.setCellStyle(styles.get("header"));
+        Cell cellh = row3.createCell(8);
+        cellh.setCellValue("");
+        cellh.setCellStyle(styles.get("header"));
+
+        Cell cell5 = row1.createCell(9);
+        cell5.setCellValue("概算数");
+        cell5.setCellStyle(styles.get("header"));
+        Cell cell6 = row2.createCell(9);
+        cell6.setCellValue("建筑费");
+        cell6.setCellStyle(styles.get("header"));
+        Cell cell7 = row2.createCell(10);
+        cell7.setCellValue("安装费");
+        cell7.setCellStyle(styles.get("header"));
+        Cell cell8 = row2.createCell(11);
+        cell8.setCellValue("设备购置费");
+        cell8.setCellStyle(styles.get("header"));
+
+        Cell cellj = row3.createCell(9);
+        cellj.setCellValue("");
+        cellj.setCellStyle(styles.get("header"));
+        Cell cellk = row3.createCell(10);
+        cellk.setCellValue("");
+        cellk.setCellStyle(styles.get("header"));
+        Cell celll = row3.createCell(11);
+        celll.setCellValue("");
+        celll.setCellStyle(styles.get("header"));
+        Cell celll1 = row3.createCell(12);
+        celll1.setCellValue("");
+        celll1.setCellStyle(styles.get("header"));
+
+
+        Cell cell9 = row2.createCell(12);
+        cell9.setCellValue("主材费");
+        cell9.setCellStyle(styles.get("header"));
+        Cell cell10 = row2.createCell(13);
+        cell10.setCellValue("其他费用");
+        cell10.setCellStyle(styles.get("header"));
+        Cell cell11 = row3.createCell(13);
+        cell11.setCellValue("设计费");
+        cell11.setCellStyle(styles.get("header"));
+        Cell cell12 = row3.createCell(14);
+        cell12.setCellValue("监理费");
+        cell12.setCellStyle(styles.get("header"));
+        Cell cell13 = row3.createCell(15);
+        cell13.setCellValue("项目前期工作费");
+        cell13.setCellStyle(styles.get("header"));
+        Cell cell14 = row3.createCell(16);
+        cell14.setCellValue("线路施工赔偿费");
+        cell14.setCellStyle(styles.get("header"));
+        Cell cell15 = row3.createCell(17);
+        cell15.setCellValue("法人管理费(余物清理费)");
+        cell15.setCellStyle(styles.get("header"));
+        return sheet;
+    }
+
 }
+

+ 3 - 5
src/main/java/com/jeeplus/modules/sg/financial/settlement/web/DataMaintenanceController.java

@@ -241,10 +241,9 @@ public class DataMaintenanceController extends BaseController {
      public AjaxJson importFileTemplate(HttpServletResponse response) {
 		AjaxJson j = new AjaxJson();
 		try {
-            String fileName = "维护数据导入模板.xlsx";
-    		List<MaintainData> list = Lists.newArrayList();
-    		new ExportExcel(null, MaintainData.class, 1).setDataList(list).write(response, fileName).dispose();
-    		return null;
+			dataMaintenanceService.exportHeard(response);
+			j.setSuccess(true);
+			j.setMsg("导出成功!");
 		} catch (Exception e) {
 			j.setSuccess(false);
 			j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
@@ -282,7 +281,6 @@ public class DataMaintenanceController extends BaseController {
 				maintainData.setPreliminaryWorkFee(getDouble(importExcel,row,15));
 				maintainData.setDamages(getDouble(importExcel,row,16));
 				maintainData.setManagementFee(getDouble(importExcel,row,17));
-				maintainData.setTotalFee(getDouble(importExcel,row,18));
 				list.add(maintainData);
 			}
 		}

+ 8 - 4
src/main/webapp/webpage/modules/sg/financial/settlement/dataMaintenanceList.js

@@ -175,10 +175,10 @@ $(document).ready(function() {
 					   field: 'managementFee',
 					   title: '法人管理费'
                }
-             ,{
-					   field: 'totalFee',
-					   title: '合计'
-               }
+             // ,{
+				// 	   field: 'totalFee',
+				// 	   title: '合计'
+             //   }
 		     ]
 		
 		});
@@ -256,6 +256,10 @@ $(document).ready(function() {
 			jp.downloadFile('${ctx}/sg/settlement/export');
 	  });
 
+    $("#export1").click(function(){//导出Excel文件
+        jp.downloadFile('${ctx}/sg/settlement/import/template');
+     });
+
 		    
 	  $("#search").click("click", function() {// 绑定查询按扭
 		  $('#dataTable').bootstrapTable('refresh');

+ 16 - 10
src/main/webapp/webpage/modules/sg/financial/settlement/dataMaintenanceList.jsp

@@ -43,16 +43,26 @@
 					<i class="glyphicon glyphicon-plus"></i> 新建
 				</button>
 			</shiro:hasPermission>
+		<shiro:hasPermission name="sg:settlement:del">
+			<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
+				<i class="glyphicon glyphicon-remove"></i> 删除
+			</button>
+		</shiro:hasPermission>
 			<shiro:hasPermission name="sg:settlement:edit">
 			    <button id="edit" class="btn btn-success" disabled onclick="edit()">
 	            	<i class="glyphicon glyphicon-edit"></i> 修改
 	        	</button>
 			</shiro:hasPermission>
-			<shiro:hasPermission name="sg:settlement:del">
-				<button id="remove" class="btn btn-danger" disabled onclick="deleteAll()">
-	            	<i class="glyphicon glyphicon-remove"></i> 删除
-	        	</button>
-			</shiro:hasPermission>
+		<shiro:hasPermission name="sg:settlement:view">
+			<button id="view" class="btn btn-default" disabled onclick="view()">
+				<i class="fa fa-search-plus"></i> 查看
+			</button>
+		</shiro:hasPermission>
+		<shiro:hasPermission name="sg:settlement:export">
+			<button id="export1" class="btn btn-warning">
+				<i class="fa fa-file-excel-o"></i> 导出模板
+			</button>
+		</shiro:hasPermission>
 			<shiro:hasPermission name="sg:settlement:import">
 				<button id="btnImport" class="btn btn-info"><i class="fa fa-folder-open-o"></i> 导入</button>
 			</shiro:hasPermission>
@@ -61,11 +71,7 @@
 					<i class="fa fa-file-excel-o"></i> 导出
 				</button>
 			 </shiro:hasPermission>
-	                 <shiro:hasPermission name="sg:settlement:view">
-				<button id="view" class="btn btn-default" disabled onclick="view()">
-					<i class="fa fa-search-plus"></i> 查看
-				</button>
-			</shiro:hasPermission>
+
 		    <shiro:hasPermission name="sg:settlement:import">
 					<button id="btnSearch" class="btn btn-info"><i class="fa fa-folder-open-o"></i> 导入查询
 			    </button>