Explorar o código

运营数据统计导出添加搜索条件

anderx %!s(int64=4) %!d(string=hai) anos
pai
achega
d9566e3881

+ 46 - 8
src/main/java/com/goafanti/common/utils/excel/NewExcelUtil.java

@@ -74,6 +74,8 @@ public class NewExcelUtil<T> {
 	public static final int sheetSize = 65536;
 	
 	public  String downloadPath = "";
+
+	public  String screen = "";
 	
 	
 
@@ -164,6 +166,8 @@ public class NewExcelUtil<T> {
 		exportExcel(response);
 		return new Result().data(1);
 	}
+
+
 	
 	
 	/**
@@ -176,6 +180,19 @@ public class NewExcelUtil<T> {
 		this.downloadPath=uploadPath;
 		return exportExcel();
 	}
+	/**
+	 * 	直接导出CXCEL表
+	 * @param list 导出数据集合
+	 * @param sheetName 工作表的名称
+	 * @param uploadPath 导出本地地址
+	 * @param screen 搜索条件
+	 */
+	public Result exportExcel(List<T> list, String sheetName, String uploadPath,String screen) {
+		this.init(list, sheetName);
+		this.downloadPath=uploadPath;
+		this.screen=screen;
+		return exportExcel();
+	}
 
 	private void exportExcel(HttpServletResponse response) {
 		try {
@@ -184,22 +201,32 @@ public class NewExcelUtil<T> {
 				int sheetNo = (int) Math.ceil(list.size() / sheetSize);
 				String dateFilename =DateFilename(sheetName);
 				for (int index = 0; index <= sheetNo; index++) {
+					Integer line=0;
 					createSheet(sheetNo, index);
 					// 产生一行
-					Row title = sheet.createRow(0);
+					Row title = sheet.createRow(line);
 					Cell cell = title.createCell(0);
 					cell.setCellValue(sheetName);
 					CellRangeAddress region = new CellRangeAddress(0, 0, 0, fields.size()-1);
 					sheet.addMergedRegion(region);
 					cell.setCellStyle(styles.get("total"));
-					Row row = sheet.createRow(1);
+					if (StringUtils.isNotNull(screen)){
+						log.debug(screen);
+						Row r = sheet.createRow(++line);
+						Cell c = r.createCell(0);
+						c.setCellValue(screen);
+						CellRangeAddress rg = new CellRangeAddress(line, line, 0, fields.size()-1);
+						sheet.addMergedRegion(rg);
+						c.setCellStyle(styles.get("header"));
+					}
+					Row row = sheet.createRow(++line);
 					int column = 0;
 					// 写入各个字段的列头名称
 					for (Object[] os : fields) {
 						Excel excel = (Excel) os[1];
 						this.createCell(excel, row, column++);
 					}
-					fillExcelData(index, row);
+					fillExcelData(index, row,line);
 					addStatisticsRow();
 				}
 				response.addHeader("Content-Disposition", "attachment;filename="  + new String(dateFilename.getBytes(),"iso-8859-1"));
@@ -253,14 +280,24 @@ public class NewExcelUtil<T> {
 				int sheetNo = (int) Math.ceil(list.size() / sheetSize);
 				for (int index = 0; index <= sheetNo; index++) {
 					createSheet(sheetNo, index);
+					int line=0;
 					// 产生一行
-					Row title = sheet.createRow(0);
+					Row title = sheet.createRow(line);
 					Cell cell = title.createCell(0);
 					cell.setCellValue(sheetName);
 					CellRangeAddress region = new CellRangeAddress(0, 0, 0, fields.size()-1);
 					sheet.addMergedRegion(region);
 					cell.setCellStyle(styles.get("total"));
-					Row row = sheet.createRow(1);
+					if (StringUtils.isNotNull(screen)){
+						log.debug(screen);
+						Row r = sheet.createRow(++line);
+						Cell c = r.createCell(0);
+						c.setCellValue(screen);
+						CellRangeAddress rg = new CellRangeAddress(line, line, 0, fields.size()-1);
+						sheet.addMergedRegion(rg);
+						c.setCellStyle(styles.get("header"));
+					}
+					Row row = sheet.createRow(++line);
 					// 产生一行
 					int column = 0;
 					// 写入各个字段的列头名称
@@ -270,7 +307,7 @@ public class NewExcelUtil<T> {
 					}
 					filename = encodingFilename(sheetName);
 					out = new FileOutputStream(getAbsoluteFile(filename));
-					fillExcelData(index, row);
+					fillExcelData(index, row,++line);
 					addStatisticsRow();
 				}
 				wb.write(out);
@@ -303,11 +340,12 @@ public class NewExcelUtil<T> {
 	 * @param index 序号
 	 * @param row   单元格行
 	 */
-	public void fillExcelData(int index, Row row) {
+	public void fillExcelData(int index, Row row,Integer line) {
 		int startNo = index * sheetSize;
 		int endNo = Math.min(startNo + sheetSize, list.size());
+		if(line==null)line=2;
 		for (int i = startNo; i < endNo; i++) {
-			row = sheet.createRow(i + 2 - startNo);
+			row = sheet.createRow(i + line - startNo);
 			// 得到导出对象.
 			T vo = (T) list.get(i);
 			int column = 0;

+ 17 - 4
src/main/java/com/goafanti/order/controller/AdminNewOrderApiController.java

@@ -546,10 +546,23 @@ public class AdminNewOrderApiController extends CertifyApiController {
 	public Result statisticsListExprot(InputStatistics in){
 		List<outStatisticsList>  list =orderNewService.statisticsList(in);
 		NewExcelUtil<outStatisticsList> excelUtil=new NewExcelUtil<>(outStatisticsList.class);
-		StringBuffer sb=new StringBuffer("搜索条件  ");
-		if (in.getDepName()!=null)sb.append("  部门:").append(in.getDepName());
-		if(in.getProvinceName()!=null)sb.append("  省份:").append(in.getProvinceName());
-		return res().data(excelUtil.exportExcel(list,"签单统计表",uploadPath));
+		StringBuffer sb=new StringBuffer("搜索条件=》");
+		if (in.getDepName()!=null)sb=sb.append("部门:").append(in.getDepName()).append(",");
+		if(in.getProvinceName()!=null)sb=sb.append("省份:").append(in.getProvinceName()).append(",");
+		if(in.getSort()!=null){
+			sb=sb.append("排序:");
+			if (in.getSort()==0)sb=sb.append("按签单额");
+			else if (in.getSort()==1)sb=sb.append("按签单总量");
+			else if (in.getSort()==2)sb=sb.append("按签单人数");
+			sb=sb.append(",");
+		}
+		if (in.getStartCreate()!=null&&in.getEndCreate()!=null){
+			sb=sb.append("下单时间:").append(in.getStartCreate()).append("~").append(in.getEndCreate()).append(",");
+		}
+		if (in.getStartSign()!=null&&in.getEndSign()!=null){
+			sb=sb.append("合同时间:").append(in.getStartSign()).append("~").append(in.getEndSign()).append(",");
+		}
+		return excelUtil.exportExcel(list,"签单统计表",uploadPath,sb.substring(0,sb.toString().length()-1));
 	}
 
 	/**

+ 0 - 2
src/main/java/com/goafanti/order/service/OrderInvoiceService.java

@@ -19,8 +19,6 @@ public interface OrderInvoiceService {
 	
 	/**
 	 * 修改发票申请
-	 * @param uid
-	 * @param orderType
 	 * @return
 	 */
 	int updateServiceOrder(TOrderInvoice t);

+ 15 - 2
src/main/java/com/goafanti/user/controller/UserFollowController.java

@@ -63,11 +63,24 @@ public class UserFollowController extends BaseApiController {
      * @return
      */
     @RequestMapping(value = "/followStatisticsListExport", method = RequestMethod.GET)
-    public Result  followStatisticsListExport(String depId,String date,Integer province,Integer sort){
+    public Result  followStatisticsListExport(String depId,String date,Integer province,Integer sort,String depName,String provinceName){
         Result res =new Result();
         List<outFollowStatisticsList> list=userFollowService.followStatisticsList(depId,date,province,sort);
         NewExcelUtil<outFollowStatisticsList>excelUtil =new NewExcelUtil<>(outFollowStatisticsList.class);
-        return res.data(excelUtil.exportExcel(list,"面谈跟进统计",uploadPath));
+        StringBuffer sb=new StringBuffer("搜索条件=》");
+        if (depName!=null)sb=sb.append("部门:").append(depName).append(",");
+        if(provinceName!=null)sb=sb.append("省份:").append(provinceName).append(",");
+        if(sort!=null){
+            sb=sb.append("排序:");
+            if (sort==0)sb=sb.append("按总数量");
+            else if (sort==1)sb=sb.append("按总金额");
+            else if (sort==2)sb=sb.append("按总面谈");
+            sb=sb.append(",");
+        }
+        if (date!=null){
+            sb=sb.append("时间:").append(date).append(",");
+        }
+        return excelUtil.exportExcel(list,"面谈跟进统计",uploadPath,sb.substring(0,sb.toString().length()-1));
     }