anderx 5 years ago
parent
commit
7eb1da0791

+ 39 - 35
src/main/java/com/goafanti/common/model/TOrderBillNew.java

@@ -3,19 +3,40 @@ package com.goafanti.common.model;
 import java.math.BigDecimal;
 import java.util.Date;
 
+import com.goafanti.common.utils.Excel.Excel;
+
 
 
 public class TOrderBillNew {
-    /**
-	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.bill_no
-	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
-	 */
+    
+	@Excel(name = "订单编号")
+	private String orderNo;
+	@Excel(name = "合同编号")
+	private String contractNo;
+	@Excel(name = "收款时间")
+	private String createTimes;
+	@Excel(name = "财务流水时间")
+	private String financialPayTimes;
+	@Excel(name = "平台流水号")
+	private String financialPayNo;
+	@Excel(name = "金额(万元)")
+	private BigDecimal transactionAmount;
+	@Excel(name = "收款方")
+	private String payeeName;
+	@Excel(name = "付款方")
+	private String payerName;
+	@Excel(name = "流水科目", readConverterExp = "0=代收,1=代付,2退款")
+	private Integer transactionSubject;
+	@Excel(name = "平台流水号")
 	private String billNo;
+	@Excel(name = "收款类型", readConverterExp = "0=手工,1=批量")
+	private Integer type;
+	@Excel(name = "备注")
+	private String remarks;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.order_no
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
 	 */
-	private String orderNo;
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.creater
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
@@ -41,26 +62,16 @@ public class TOrderBillNew {
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
 	 */
 	private String payerId;
-	/**
-	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.transaction_amount
-	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
-	 */
-	private BigDecimal transactionAmount;
-	/**
-	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.transaction_subject
-	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
-	 */
-	private Integer transactionSubject;
+	
+	
+	
+	
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.transaction_channel
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
 	 */
 	private Integer transactionChannel;
-	/**
-	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.remarks
-	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
-	 */
-	private String remarks;
+	
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.confirm_sign
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
@@ -71,21 +82,15 @@ public class TOrderBillNew {
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
 	 */
 	private Byte deleteSign;
-	/**
-	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.financial_pay_no
-	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
-	 */
-	private String financialPayNo;
+	
+	
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.financial_pay_time
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
 	 */
 	private Date financialPayTime;
-	/**
-	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.type
-	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
-	 */
-	private Integer type;
+	
+	
 	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column t_order_bill_new.delete_time
 	 * @mbg.generated  Wed Feb 19 08:54:03 CST 2020
@@ -421,9 +426,8 @@ public class TOrderBillNew {
 		this.refundTime = refundTime;
 	}
 
-	private String financialPayTimes;
-    private String payerName;
-    private String payeeName;
+	
+    
     private String createrName;
     private String startTime;
     private String endTime;
@@ -431,10 +435,10 @@ public class TOrderBillNew {
     private String saleId;
     private String saleName;
     private String departmentName;
-	private String createTimes;
+	
 	private String deleteTimes;
 	private String refundTimes;
-	private String contractNo;
+	
     
     public String getFinancialPayTimes() {
 		return this.financialPayTimes;

+ 4 - 0
src/main/java/com/goafanti/common/utils/DateUtils.java

@@ -476,6 +476,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 		}
 		return parse;
 	}
+
+	public static final String parseDateToStr(final String format, final Date date) {
+        return new SimpleDateFormat(format).format(date);
+    }
 	
 
 

+ 2 - 67
src/main/java/com/goafanti/common/utils/ExportExcelUtil.java

@@ -78,36 +78,7 @@ public class ExportExcelUtil {
 		return cellStyle;
 	}
 	
-	//下载课表
-	public static void download(String path, HttpServletResponse response,String filename) { 
-		try {  
-            // path是指欲下载的文件的路径。  
-            File file = new File(path);  
-            // 取得文件名。  
-            // 以流的形式下载文件。  
-            InputStream fis = new BufferedInputStream(new FileInputStream(path));  
-            byte[] buffer = new byte[fis.available()];  
-            fis.read(buffer);  
-            fis.close();  
-            // 清空response  
-            response.reset();  
-            // 设置response的Header  
-            response.addHeader("Content-Disposition", "attachment;filename="  
-                    + new String(filename.getBytes(),"iso-8859-1"));  //防止中文乱码或者中文忽略的情况
-            response.addHeader("Content-Length", "" + file.length());  
-            OutputStream toClient = new BufferedOutputStream(  
-                    response.getOutputStream());  
-            response.setContentType("application/octet-stream;charset=utf-8");  
-            toClient.write(buffer);  
-            toClient.flush();  
-            toClient.close();  
-            
-          
-        } catch (IOException ex) {  
-            ex.printStackTrace();  
-        }  
-		
-	}
+
 	public static void download(String path, HttpServletResponse response) {  
         try {  
             // path是指欲下载的文件的路径。  
@@ -551,43 +522,7 @@ public class ExportExcelUtil {
 		}
 		
 	}
-	/**
-	 * 年度导出数据模板
-	 * @return
-	 */
-	public static XSSFWorkbook downOrderModelExcel() {
-		String[] comment = {"姓名","电话","月份","项目类型","签单数量","累计签单金额(万元)"};
-		String[] d1 = {"张三","13275161283","1","科技项目","2","12"};
-		String[] d2 = {"张三","13275161283","1","认证项目","0.3","3"};
-		
-		//map 数据 comment表头 (列名称)
-		//1,创建一个workbook,对应的是一个excel文件
-		XSSFWorkbook wb = new XSSFWorkbook();
-		//2.创建一个sheet
-		XSSFSheet sheet = wb.createSheet();
-		//创建表头
-		XSSFCellStyle style1 = setCellStyle1(wb);
-		XSSFRow row = sheet.createRow(0);
-		XSSFRow row1 = sheet.createRow(1);
-		XSSFRow row2 = sheet.createRow(2);
-		for(int i = 0; i < comment.length; i++){
-			sheet.setColumnWidth(i, 3000);//设置列宽
-			XSSFCell c = row.createCell(i);
-			c.setCellValue(comment[i]);
-			c.setCellStyle(style1);
-		}
-		for(int i = 0; i < d1.length; i++){
-			XSSFCell c = row1.createCell(i);
-			c.setCellValue(d1[i]);
-			c.setCellStyle(style1);
-		}
-		for(int i = 0; i < d2.length; i++){
-			XSSFCell c = row2.createCell(i);
-			c.setCellValue(d2[i]);
-			c.setCellStyle(style1);
-		}
-		return wb;
-	}
+	
 	
 	/**
 	 * 导出营销部部门奖金的数据

+ 15 - 0
src/main/java/com/goafanti/common/utils/StringUtils.java

@@ -8,4 +8,19 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
 	public static boolean isFractionalNumeric(String val) {
 		return FRACTIONAL_NUMERIC.matcher(val).matches();
 	}
+
+	public static boolean isNull(Object value) {
+        return value == null;
+     }
+	
+	 /**
+     * * 判断一个对象是否非空
+     * 
+     * @param object Object
+     * @return true:非空 false:空
+     */
+    public static boolean isNotNull(Object object)
+    {
+        return !isNull(object);
+    }
 }

+ 9 - 33
src/main/java/com/goafanti/order/controller/FundManagerOrderApiController.java

@@ -5,6 +5,7 @@ import java.io.OutputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.List;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
@@ -24,6 +25,7 @@ import com.goafanti.common.model.TOrderBillNew;
 import com.goafanti.common.model.TOrderNew;
 import com.goafanti.common.model.TOrderRefund;
 import com.goafanti.common.utils.StringUtils;
+import com.goafanti.common.utils.Excel.NewExcelUtil;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.order.bo.OrderListBo;
 import com.goafanti.order.bo.OrderRefundBo;
@@ -310,39 +312,13 @@ public class FundManagerOrderApiController extends CertifyApiController {
 	 * @throws IOException 
 	 */
 	 @RequestMapping(value="/exportBillData", method = RequestMethod.GET)
-	 public Result exportBillData(TOrderBillNew billNew,HttpServletResponse response) throws IOException{
-		 OutputStream out = response.getOutputStream();
-		 Result res = new Result();
-		 XSSFWorkbook wb = orderBillServiceImpl.exportBillData(billNew);
-		 if(null == wb){
-			 wb = new XSSFWorkbook();
-			XSSFSheet sheet = wb.createSheet("没有流水记录");
-			XSSFRow row = sheet.createRow(0);
-			XSSFCell cell = row.createCell(0);
-			cell.setCellValue("没有流水记录");
-		 }
-		 String fileName = "部门流水" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) + ".xls";
-		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
-		 response.setContentType("application/octet-stream;charset=utf-8");  
-		 /*String fileName = "部门流水" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) + ".xls";
-		 ExportExcelUtil.download(path,response,fileName);
-		 res.setData(path);
-		 //删除
-		 File f = new File(path);
-		 if(f.exists()){
-			 System.out.println("shanchu----------------------0");
-			 f.delete();
-		 }*/
-		try {
-			// 返回数据流
-			wb.write(out); 
-			out.flush();
-			out.close();
-		} finally {
-			out.flush(); 
-			out.close(); 
-		}
-		return res;
+	 public void exportBillData(TOrderBillNew billNew,HttpServletResponse response) throws IOException{
+		 
+		 @SuppressWarnings("unchecked")
+		List<TOrderBillNew>list=(List<TOrderBillNew>) orderBillServiceImpl.myBillList(billNew,1, 99999).getList();
+		 NewExcelUtil<TOrderBillNew> excelUtil=new NewExcelUtil<>(TOrderBillNew.class);
+		 excelUtil.exportExcel(list, "订单流水表", response);
+
 	 }
 	 
 	 /**

+ 1 - 25
src/main/java/com/goafanti/order/controller/OrderBonusStatisticsApiController.java

@@ -285,31 +285,7 @@ public class OrderBonusStatisticsApiController extends CertifyApiController {
 		return res;
 	}
 	
-	/**
-	 * 下载年度订单数据模板
-	 * @param response
-	 * @return
-	 * @throws IOException
-	 */
-	@RequestMapping(value = "/downOrderModelExcel",method = RequestMethod.GET)
-	public Result downOrderModelExcel(HttpServletResponse response) throws IOException{
-		Result res = new Result();
-		 OutputStream out = response.getOutputStream();
-		 XSSFWorkbook wb = ExportExcelUtil.downOrderModelExcel();
-		 String fileName = "导入年度销售数据模板.xls";
-		 response.addHeader("Content-Disposition", "attachment;filename="  + new String(fileName.getBytes(),"iso-8859-1"));  
-		 response.setContentType("application/octet-stream;charset=utf-8");  
-		 try {
-			 // 返回数据流
-			 wb.write(out); 
-			 out.flush();
-			 out.close();
-		 } finally {
-			 out.flush(); 
-			 out.close(); 
-		 }
-		return res;
-	}
+	
 	 
 	/**
 	 * 手动更新校对单量

+ 1 - 7
src/main/java/com/goafanti/order/service/OrderBillService.java

@@ -1,6 +1,5 @@
 package com.goafanti.order.service;
 
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import com.goafanti.common.model.TOrderBillNew;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -17,12 +16,7 @@ public interface OrderBillService {
 	 */
 	Pagination<TOrderBillNew> myBillList(TOrderBillNew billNew,  Integer pageNo, Integer pageSize);
 	
-	/**
-	 * 导出流水数据
-	 * @param billNew
-	 * @return
-	 */
-	XSSFWorkbook exportBillData(TOrderBillNew billNew);
+
 
 	int deleteMyBill(String billNo);
 }

+ 1 - 33
src/main/java/com/goafanti/order/service/impl/OrderBillServiceImpl.java

@@ -6,7 +6,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -17,8 +16,6 @@ import com.goafanti.common.dao.TOrderBillNewMapper;
 import com.goafanti.common.dao.TOrderNewMapper;
 import com.goafanti.common.model.TOrderBillNew;
 import com.goafanti.common.model.TOrderNew;
-import com.goafanti.common.utils.ExportExcelUtil;
-import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
@@ -55,36 +52,7 @@ public class OrderBillServiceImpl extends BaseMybatisDao<TOrderBillNewMapper> im
 	}
 
 
-	@Override
-	public XSSFWorkbook exportBillData(TOrderBillNew billNew) {
-		// 判断导出是否有部门
-		String deptid = billNew.getDepartmentId();
-		Map<String, List<TOrderBillNew>> map = new HashMap<String, List<TOrderBillNew>>();
-		if(StringUtils.isBlank(deptid)){
-			//获得所有有数据的部门
-			List<TOrderBillNew> dlist = billNewMapper.getDeptBySome(billNew);
-			if(null == dlist || dlist.size() == 0){
-				return null;
-			}
-			for (int i = 0; i < dlist.size(); i++) {
-				TOrderBillNew ob = dlist.get(i);
-				billNew.setDepartmentId(ob.getDepartmentId());
-				map.put(ob.getDepartmentName(), billNewMapper.getBillData(billNew));
-			}
-		}else{
-			map.put(billNew.getDepartmentName(), billNewMapper.getBillData(billNew));
-		}
-		String[] comment = {"平台流水编号","平台流水时间","交易金额(万元)","付款方","收款方","流水科目","交易渠道","交易时间","财务流水号","订单编号","订单负责人"};
-		String filePath = uploadPath + "/billtemp";
-//		File f = new File(filePath);
-//		if(!f.exists()){
-//			f.mkdirs();
-//		}
-		//filePath += "/" + System.nanoTime() +".xls";
-		XSSFWorkbook wb = ExportExcelUtil.exportDeptBillInfo(map,  comment, filePath);
-		
-		return wb;
-	}
+
 
 
 	@Override

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

@@ -576,8 +576,6 @@ public class OrderReceivablesServiceImpl extends BaseMybatisDao<TemporaryReceiva
 					 response.setContentType("application/octet-stream;charset=utf-8");
 		    		 // 返回数据流
 					 wb.write(out); 
-					 out.flush();
-					 out.close();
 				} catch (Exception e) {
 					throw new BusinessException(new Error("表格生成错误。"));
 				}finally {