tudc před 3 roky
rodič
revize
73219b025f

+ 6 - 0
adm/pom.xml

@@ -438,6 +438,12 @@
 		    <artifactId>jedis</artifactId>
 		    <version>2.7.2</version>
 		</dependency>
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>easyexcel</artifactId>
+			<version>3.0.5</version>
+		</dependency>
+
 
 		<dependency>
 			<groupId>gson</groupId>

+ 65 - 1
adm/src/main/java/com/minpay/guomao/stockManage/BatchPrintBillManageAction.java

@@ -1,6 +1,9 @@
 package com.minpay.guomao.stockManage;
 
+import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
+import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -8,6 +11,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.alibaba.excel.EasyExcel;
 import com.minpay.common.bean.User;
 import com.minpay.common.format.IFormatService;
 import com.minpay.common.service.IGuoMaoCommonService;
@@ -72,6 +76,8 @@ import com.startup.minpay.frame.target.MINParam;
 
 import net.sf.json.JSONArray;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * 批量打印
  * @author 华硕
@@ -97,6 +103,9 @@ public class BatchPrintBillManageAction implements IMINAction {
 	
 	/**保存发出量确认函*/
 	public final static String	SAVE_GIVE_PRINT		= "saveGivePrint";
+
+	/**导出查款单excel*/
+	public final static String	EXPORT_CHECK_LIST_EXCEL		= "exportCheckListExcel";
 	
 	
 	
@@ -975,7 +984,62 @@ public class BatchPrintBillManageAction implements IMINAction {
 		
 		return res;
 	}
-	
+
+
+	/**
+	 * 导出查款单
+	 */
+	@MINAction(value = EXPORT_CHECK_LIST_EXCEL)
+	public MINActionResult exportCheckListExcel(
+			@MINParam(key = "sellerNameAll") String sellerNameAll,
+			@MINParam(key = "totalId") String totalId,
+			@MINParam(key = "buyNameAll") String buyNameAll,
+			@MINParam(key = "buyTypeDesc") String buyTypeDesc,
+			@MINParam(key = "entryTime") String entryTime,
+			@MINParam(key = "warehouseName") String warehouseName,
+			@MINParam(key = "remark") String remark,
+			@MINParam(key = "spValue") String spValue,
+			@MINParam(key = "unitPrice") String unitPrice,
+			@MINParam(key = "weight") String weight,
+			@MINParam(key = "totalPrice") String totalPrice,
+			@MINParam(key = "custom") String custom,
+			HttpServletResponse response
+	) throws IOException {
+		MINActionResult res = new MINActionResult();
+		// 获取文件路径
+		String path = this.getClass().getResource("").getPath();
+		path = path.substring(0, path.indexOf("WEB-INF"));
+//		path = "D:\\workspace\\shanghai\\guomao\\adm\\src\\main\\webapp\\";
+		String templateFileName = path + "excel/查款单.xlsx";
+
+		long time = System.currentTimeMillis();
+		String fileName = path + "excel/" + time + ".xlsx";
+		// 这里 会填充到第一个sheet, 然后文件流会自动关闭
+		Map<String, Object> map = new HashMap<>();
+		map.put("sellerNameAll", sellerNameAll);
+		map.put("totalId", totalId);
+		map.put("buyNameAll", buyNameAll);
+		map.put("buyTypeDesc", buyTypeDesc);
+		map.put("entryTime", entryTime);
+		map.put("warehouseName", warehouseName);
+		map.put("remark", remark.replaceAll("<br>", "\n"));
+		map.put("spValue", spValue);
+		map.put("unitPrice", unitPrice);
+		map.put("weight", weight);
+		map.put("totalPrice", totalPrice);
+		map.put("custom", custom);
+
+
+		response.setContentType("application/vnd.ms-excel");
+		response.setCharacterEncoding("utf-8");
+		response.setHeader("Content-disposition", "attachment;filename=" + time + ".xlsx");
+
+		EasyExcel.write(response.getOutputStream()).withTemplate(templateFileName).sheet().doFill(map);
+		File file = new File(fileName);
+		file.delete();
+
+		return res;
+	}
 	
 	
 }

+ 35 - 29
adm/src/main/java/com/minpay/guomao/templateexport/action/TemplateExportAction.java

@@ -25,29 +25,8 @@ import com.minpay.common.util.ChineseNumber;
 import com.minpay.common.util.CommonUtil;
 import com.minpay.common.util.DateUtil;
 import com.minpay.common.util.ListUtil;
-import com.minpay.db.table.mapper.ApBrandInfMapper;
-import com.minpay.db.table.mapper.ApCompanyAccountMapper;
-import com.minpay.db.table.mapper.ApContractDetailMapper;
-import com.minpay.db.table.mapper.ApContractInfMapper;
-import com.minpay.db.table.mapper.ApMoreInfMapper;
-import com.minpay.db.table.mapper.ApProductInfMapper;
-import com.minpay.db.table.mapper.ApProductSpecRelMapper;
-import com.minpay.db.table.mapper.ApWarehouseInfMapper;
-import com.minpay.db.table.model.ApBrandInf;
-import com.minpay.db.table.model.ApBrandInfExample;
-import com.minpay.db.table.model.ApCompanyAccount;
-import com.minpay.db.table.model.ApCompanyAccountExample;
-import com.minpay.db.table.model.ApContractDetail;
-import com.minpay.db.table.model.ApContractDetailExample;
-import com.minpay.db.table.model.ApContractInf;
-import com.minpay.db.table.model.ApContractInfExample;
-import com.minpay.db.table.model.ApMoreInf;
-import com.minpay.db.table.model.ApProductInf;
-import com.minpay.db.table.model.ApProductInfExample;
-import com.minpay.db.table.model.ApProductSpecRel;
-import com.minpay.db.table.model.ApProductSpecRelExample;
-import com.minpay.db.table.model.ApWarehouseInf;
-import com.minpay.db.table.model.OwnApWarehouseInfExample;
+import com.minpay.db.table.mapper.*;
+import com.minpay.db.table.model.*;
 import com.minpay.db.table.own.mapper.LongContractMapper;
 import com.minpay.db.table.own.mapper.OrderManageMapper;
 import com.minpay.db.table.own.mapper.WarehouseInventoryMapper;
@@ -362,6 +341,33 @@ public class TemplateExportAction implements IMINAction {
 
         //将总金额转换成中文大写
         String chineseNb = ChineseNumber.getChineseNumber(amtAll);
+		String companyId = u.getCompanyId();
+		// 获取公司联系人列表的第一条数据
+		ApCompanyContactExample apCompanyContactExample = new ApCompanyContactExample();
+		apCompanyContactExample.createCriteria().andCompanyIdEqualTo(companyId);
+		List<ApCompanyContact> apCompanyContactList = Service.lookup(IMINDataBaseService.class)
+				.selectByExample(ApCompanyContactMapper.class, apCompanyContactExample);
+
+		String ownerContactName = "";
+		String ownerContactPhone = "";
+		if(apCompanyContactList.size()>0){
+			ApCompanyContact apCompanyContact = apCompanyContactList.get(0);
+			ownerContactName = apCompanyContact.getName();
+			ownerContactPhone = apCompanyContact.getPhone();
+		}
+		String finalOwnerContactName = ownerContactName;
+		String finalOwnerContactPhone = ownerContactPhone;
+		// 获取公司下的地址列表的第一条数据
+		ApCompanySiteExample apCompanySiteExample = new ApCompanySiteExample();
+		apCompanySiteExample.createCriteria().andCompanyIdEqualTo(companyId);
+		List<ApCompanySite> apCompanySiteList = Service.lookup(IMINDataBaseService.class)
+				.selectByExample(ApCompanySiteMapper.class, apCompanySiteExample);
+		String ownerAddress = "";
+		if(apCompanySiteList.size()>0){
+			ApCompanySite apCompanySite = apCompanySiteList.get(0);
+			ownerAddress = apCompanySite.getAddress();
+		}
+		String finalOwnerAddress = ownerAddress;
 		XWPFTemplate template = XWPFTemplate.compile(strm).render(new HashMap<String, Object>(){{
 				String proName = "";
 				String weight = "";
@@ -428,15 +434,15 @@ public class TemplateExportAction implements IMINAction {
 		        	put("sellerContractPhone", contractPhone);
 		        	put("sellerAddress", address);
 		        	// 买方信息
-		        	put("buyerContractName", "");
-		        	put("buyerContractPhone", "");
-		        	put("buyerAddress", "");
+		        	put("buyerContractName", finalOwnerContactName);
+		        	put("buyerContractPhone", finalOwnerContactPhone);
+		        	put("buyerAddress", finalOwnerAddress);
 		        // 销售合同
 		        } else {
 		        	// 卖方信息
-		        	put("sellerContractName", "");
-		        	put("sellerContractPhone", "");
-		        	put("sellerAddress", "");
+		        	put("sellerContractName", finalOwnerContactName);
+		        	put("sellerContractPhone", finalOwnerContactPhone);
+		        	put("sellerAddress", finalOwnerAddress);
 		        	// 买方信息
 		        	put("buyerContractName", contractName);
 		        	put("buyerContractPhone", contractPhone);

+ 34 - 3
adm/src/main/webapp/admin/stockManage/printCheckMore.html

@@ -78,6 +78,7 @@
 	</div> 
 	<div style="height: 80px;width: 100%;"></div>
 	<div class="stock-btn">
+	    <button class="layui-btn left-bnt1 in-b" id="downExcel">下载excel</button>
 		<button class="layui-btn left-bnt1 in-b" id="printBtn">打印</button>
 	</div>
     <!--操作功能-->
@@ -153,11 +154,41 @@
 		}
 	});
 	 
-		//打印
+	//打印
   	$(document).on('click','#printBtn',function(){
-	    $("#big").jqprint();
+        $("#big").jqprint();
 	}); 
-    
+		//打印
+  	$(document).on('click','#downExcel',function(){
+  	    var sellerNameAll = $("#sellerNameAll").html();
+  	    var totalId = $("#totalId").html();
+  	    var buyNameAll = $("#buyNameAll").html();
+  	    var buyTypeDesc = $("#buyTypeDesc").html();
+  	    var entryTime = $("#entryTime").html();
+  	    var warehouseName = $("#warehouseName").html();
+  	    var remark = $("#remark").html();
+  	    var spValue = $("#spValue").html();
+  	    var unitPrice = $("#unitPrice").html();
+  	    var weight = $("#weight").html();
+  	    var totalPrice = $("#totalPrice").html();
+  	    var custom = $("#custom").html();
+
+        var param = {};
+        param.sellerNameAll = sellerNameAll;
+        param.totalId = totalId;
+        param.buyNameAll = buyNameAll;
+        param.buyTypeDesc = buyTypeDesc;
+        param.entryTime = entryTime;
+        param.warehouseName = warehouseName;
+        param.remark = remark;
+        param.spValue = spValue;
+        param.unitPrice = unitPrice;
+        param.weight = weight;
+        param.totalPrice = totalPrice;
+        param.custom = custom;
+        exportExcel("../../BatchPrintBillManageAction/exportCheckListExcel?",param);
+	});
+
 </script>
      
   

binární
adm/src/main/webapp/excel/enquiry.xlsx


binární
adm/src/main/webapp/excel/quotation.xlsx


binární
adm/src/main/webapp/excel/查款单.xlsx