|
@@ -47,6 +47,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.text.MessageFormat;
|
|
|
+import java.text.NumberFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -1692,6 +1693,18 @@ public class AdminCustomerController {
|
|
|
*/
|
|
|
@RequestMapping("/download_customer_excel")
|
|
|
public void downloadEfastOrderExcel(HttpServletRequest request, HttpServletResponse res) throws Exception {
|
|
|
+ Admin admin = AdminUtils.getLoginAdmin();
|
|
|
+ //添加一条下载记录
|
|
|
+ DownloadProgressInfo downloadProgressInfo = new DownloadProgressInfo();
|
|
|
+ downloadProgressInfo.setDownloadAdminId(admin.getAdminId());
|
|
|
+ downloadProgressInfo.setDownloadProgress("00.00%");
|
|
|
+ downloadProgressInfo.setDownloadStatus(1);
|
|
|
+ customerService.addDownloadProgressInfo(downloadProgressInfo);
|
|
|
+ //循环一次的时间(毫秒)
|
|
|
+ long cycleOne = 0;
|
|
|
+ long cycleOnes = 0;
|
|
|
+ Date date = new Date();
|
|
|
+ int s = 0;
|
|
|
List<CustomerStatisticalInfo> customerList = customerService.listStatisticalCustomer();
|
|
|
String[] cells = {
|
|
|
"日期", "姓名", "联系电话", "类别", "来源入口",
|
|
@@ -1701,8 +1714,9 @@ public class AdminCustomerController {
|
|
|
"状态", "寄出快递", "寄出快递", "开箱损", "二次客诉", "跟进客服", "工厂报价", "客户报价", "邮费信息"
|
|
|
};
|
|
|
List<CustomerStatisticalInfo> customerStatisticalInfoList = new ArrayList<>();
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
for (CustomerStatisticalInfo customerInfo : customerList) {
|
|
|
+ long startTime=System.currentTimeMillis(); //获取开始时间
|
|
|
+ s++;
|
|
|
//新建一个容器
|
|
|
CustomerStatisticalInfo customer = new CustomerStatisticalInfo();
|
|
|
//将数据copy到新容器
|
|
@@ -1769,9 +1783,27 @@ public class AdminCustomerController {
|
|
|
}else{
|
|
|
customerStatisticalInfoList.add(customer);
|
|
|
}
|
|
|
+ long endTime=System.currentTimeMillis(); //获取结束时间
|
|
|
+ if(s == 1){
|
|
|
+ cycleOne = startTime - endTime;
|
|
|
+ cycleOnes = cycleOne * customerList.size();
|
|
|
+ date.setTime(cycleOnes);
|
|
|
+ //修改预计下载完成时间
|
|
|
+ downloadProgressInfo.setDownloadDate(date);
|
|
|
+ downloadProgressInfo.setDownloadProgress("01.00%");//进度变为1
|
|
|
+ customerService.updateDownloadProgressInfo(downloadProgressInfo);
|
|
|
+ }else{
|
|
|
+ NumberFormat numberFormat = NumberFormat.getInstance();
|
|
|
+ numberFormat.setMaximumFractionDigits(2);
|
|
|
+ float percentage = (float) s / (float) customerList.size() * 100;
|
|
|
+ String result = numberFormat.format(percentage);
|
|
|
+ downloadProgressInfo.setDownloadProgress(result);
|
|
|
+ customerService.updateDownloadProgressInfo(downloadProgressInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
//导出订单Excel并下载
|
|
|
- customerExcel(request,res,cells,customerStatisticalInfoList);
|
|
|
+ customerExcel(request,res,cells,customerStatisticalInfoList,downloadProgressInfo);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1784,7 +1816,8 @@ public class AdminCustomerController {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void customerExcel(HttpServletRequest request,HttpServletResponse res,
|
|
|
- String[] cells,List<CustomerStatisticalInfo> customerList) throws Exception {
|
|
|
+ String[] cells,List<CustomerStatisticalInfo> customerList,
|
|
|
+ DownloadProgressInfo downloadProgressInfo) throws Exception {
|
|
|
|
|
|
//创建一个workbook,对应一个Excel文件
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
@@ -1885,7 +1918,26 @@ public class AdminCustomerController {
|
|
|
|
|
|
}
|
|
|
//下载导出订单Excel
|
|
|
- downloadCustomerExcel(res,wb);
|
|
|
+ downloadCustomerExcel(wb,downloadProgressInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载导出客诉到本地
|
|
|
+ * @param wb
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public void downloadCustomerExcel(HSSFWorkbook wb,DownloadProgressInfo downloadProgressInfo) throws Exception{
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String fileName = format.format(new Date()) + "客诉报表";
|
|
|
+ try {
|
|
|
+ FileOutputStream fout = new FileOutputStream("/common/customerExcel/"+fileName+downloadProgressInfo.getDownloadId()+".xls");
|
|
|
+ wb.write(fout);
|
|
|
+ fout.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ downloadProgressInfo.setDownloadStatus(2);
|
|
|
+ downloadProgressInfo.setDownloadUrl("/common/customerExcel/"+fileName+downloadProgressInfo.getDownloadId()+".xls");
|
|
|
}
|
|
|
|
|
|
/**
|