liujiankang 6 年 前
コミット
97a938bad8

+ 2 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/cm/CustomerStatisticalInfo.java

@@ -15,6 +15,8 @@ public class CustomerStatisticalInfo implements Serializable {
     private static final long serialVersionUID = 7150678136334412114L;
     private Integer customerId;//客诉id
     private Integer orderId;//订单id
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
     private Date createTime;//创建日期
     private String customerName;//姓名
     private String customerTel;//联系电话

+ 74 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/cm/DownloadProgressInfo.java

@@ -0,0 +1,74 @@
+package com.iamberry.rst.core.cm;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by Administrator on 2019/4/1.
+ */
+public class DownloadProgressInfo implements Serializable {
+    private static final long serialVersionUID = -532651953639505413L;
+    private Integer downloadId;
+    private Integer downloadAdminId;
+    private String downloadProgress;
+    private Integer downloadStatus;
+    private String downloadUrl;
+    private Date downloadDate;
+    private Date downloadCreateTime;
+
+    public Integer getDownloadId() {
+        return downloadId;
+    }
+
+    public void setDownloadId(Integer downloadId) {
+        this.downloadId = downloadId;
+    }
+
+    public Integer getDownloadAdminId() {
+        return downloadAdminId;
+    }
+
+    public void setDownloadAdminId(Integer downloadAdminId) {
+        this.downloadAdminId = downloadAdminId;
+    }
+
+    public String getDownloadProgress() {
+        return downloadProgress;
+    }
+
+    public void setDownloadProgress(String downloadProgress) {
+        this.downloadProgress = downloadProgress;
+    }
+
+    public Integer getDownloadStatus() {
+        return downloadStatus;
+    }
+
+    public void setDownloadStatus(Integer downloadStatus) {
+        this.downloadStatus = downloadStatus;
+    }
+
+    public String getDownloadUrl() {
+        return downloadUrl;
+    }
+
+    public void setDownloadUrl(String downloadUrl) {
+        this.downloadUrl = downloadUrl;
+    }
+
+    public Date getDownloadDate() {
+        return downloadDate;
+    }
+
+    public void setDownloadDate(Date downloadDate) {
+        this.downloadDate = downloadDate;
+    }
+
+    public Date getDownloadCreateTime() {
+        return downloadCreateTime;
+    }
+
+    public void setDownloadCreateTime(Date downloadCreateTime) {
+        this.downloadCreateTime = downloadCreateTime;
+    }
+}

+ 22 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/cm/CustomerService.java

@@ -372,4 +372,26 @@ public interface CustomerService {
      * 修改订单项所有退货数量为0
      */
     Integer updateItemreturnNumByorderid(Integer itemOrderId);
+
+
+    /**
+     * 查询下载进度列表
+     * @param downloadProgressInfo
+     * @return
+     */
+    List<DownloadProgressInfo> listDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo);
+
+    /**
+     * 修改下载进度列表
+     * @param downloadProgressInfo
+     * @return
+     */
+    Integer updateDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo);
+
+    /**
+     * 添加下载进度列表
+     * @param downloadProgressInfo
+     * @return
+     */
+    Integer addDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo);
 }

+ 15 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/CustomerServiceImpl.java

@@ -1850,4 +1850,19 @@ public class CustomerServiceImpl implements CustomerService {
     public Integer updateItemreturnNumByorderid(Integer itemOrderId) {
         return customerInfoMapper.updateItemreturnNumByorderid(itemOrderId);
     }
+
+    @Override
+    public List<DownloadProgressInfo> listDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo) {
+        return customerInfoMapper.listDownloadProgressInfo(downloadProgressInfo);
+    }
+
+    @Override
+    public Integer updateDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo) {
+        return customerInfoMapper.updateDownloadProgressInfo(downloadProgressInfo);
+    }
+
+    @Override
+    public Integer addDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo) {
+        return customerInfoMapper.addDownloadProgressInfo(downloadProgressInfo);
+    }
 }

+ 20 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/CustomerInfoMapper.java

@@ -226,4 +226,24 @@ public interface CustomerInfoMapper {
      */
     Integer updateItemreturnNumByorderid(Integer itemOrderId);
 
+    /**
+     * 查询下载进度列表
+     * @param downloadProgressInfo
+     * @return
+     */
+    List<DownloadProgressInfo> listDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo);
+
+    /**
+     * 修改下载进度列表
+     * @param downloadProgressInfo
+     * @return
+     */
+    Integer updateDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo);
+
+    /**
+     * 添加下载进度列表
+     * @param downloadProgressInfo
+     * @return
+     */
+    Integer addDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo);
 }

+ 57 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/customerInfoMapper.xml

@@ -729,7 +729,7 @@
 SELECT
 	c.customer_id customerId,
 	null AS orderId,
-	DATE_FORMAT(c.customer_create_time,'%Y-%m-%d')  AS createTime,
+	c.customer_create_time AS createTime,
 	c.customer_name AS customerName,
 	c.customer_tel AS customerTel,
 (CASE
@@ -1432,4 +1432,60 @@ LEFT JOIN tb_rst_cm_sendback_info csi ON csi.relation_id = cr.relation_id
         item_return_num = 0
     where item_order_id = #{itemOrderId}
   </update>
+  <!--查询客诉下载进度sql state -->
+  <select id="listDownloadProgressInfo" parameterType="DownloadProgressInfo" resultType="DownloadProgressInfo">
+      SELECT * FROM tb_rst_download_progress_info
+      <where>
+        <if test="downloadId != null || downloadId != ''">
+          download_id = #{downloadId}
+        </if>
+        <if test="downloadAdminId != null || downloadAdminId != ''">
+          download_admin_id = #{downloadAdminId}
+        </if>
+        <if test="downloadStatus != null || downloadStatus != ''">
+          download_status = #{downloadStatus}
+        </if>
+      </where>
+  </select>
+  <update id="updateDownloadProgressInfo" parameterType="DownloadProgressInfo">
+      update tb_rst_download_progress_info
+      <set>
+        <if test="downloadStatus != null || downloadStatus != ''">
+          download_status = #{downloadStatus},
+        </if>
+        <if test="downloadProgress != null || downloadProgress != ''">
+          download_progress = #{downloadProgress},
+        </if>
+        <if test="downloadUrl != null || downloadUrl != ''">
+          download_url = #{downloadUrl},
+        </if>
+        <if test="downloadDate != null || downloadDate != ''">
+          download_date = #{downloadDate}
+        </if>
+      </set>
+
+  </update>
+
+  <insert id="addDownloadProgressInfo" parameterType="DownloadProgressInfo"  keyProperty="downloadId" useGeneratedKeys="true">
+    insert into tb_rst_download_progress_info
+    (
+    download_id,
+    download_admin_id,
+    download_progress,
+    download_status,
+    download_url,
+    download_create_time
+    )
+    VALUES
+    (
+    #{downloadId},
+    #{downloadAdminId},
+    #{downloadProgress},
+    #{downloadStatus},
+    #{downloadUrl},
+    NOW()
+    )
+  </insert>
+  <!--查询客诉下载进度sql end -->
+  
 </mapper>

+ 56 - 4
watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminCustomerController.java

@@ -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");
     }
 
     /**

+ 1 - 0
watero-rst-web/src/main/resources/watero-rst-orm.xml

@@ -199,6 +199,7 @@
 
 		<typeAlias type="com.iamberry.rst.core.order.SmsTemplateInfo" alias="SmsTemplateInfo"/>
 		<typeAlias type="com.iamberry.rst.core.order.SmsSignatureInfo" alias="SmsSignatureInfo"/>
+		<typeAlias type="com.iamberry.rst.core.cm.DownloadProgressInfo" alias="DownloadProgressInfo"/>
 	</typeAliases>
 	<!-- PageHelper -->
 	<plugins>