liujiankang 6 rokov pred
rodič
commit
fbdf79a42e

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

@@ -13,7 +13,7 @@ public class DownloadProgressInfo implements Serializable {
     private String downloadProgress;
     private Integer downloadStatus;
     private String downloadUrl;
-    private Date downloadDate;
+    private String downloadDate;
     private Date downloadCreateTime;
 
     public Integer getDownloadId() {
@@ -56,11 +56,11 @@ public class DownloadProgressInfo implements Serializable {
         this.downloadUrl = downloadUrl;
     }
 
-    public Date getDownloadDate() {
+    public String getDownloadDate() {
         return downloadDate;
     }
 
-    public void setDownloadDate(Date downloadDate) {
+    public void setDownloadDate(String downloadDate) {
         this.downloadDate = downloadDate;
     }
 

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

@@ -173,7 +173,7 @@ public interface CustomerService {
      * 导出客诉信息到excel
      * @return
      */
-    List<CustomerStatisticalInfo> listStatisticalCustomer();
+    List<CustomerStatisticalInfo> listStatisticalCustomer(CustomerInfo customerInfo);
 
     /**
      * 总销量

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

@@ -796,8 +796,8 @@ public class CustomerServiceImpl implements CustomerService {
     }
 
     @Override
-    public List<CustomerStatisticalInfo> listStatisticalCustomer() {
-        return customerInfoMapper.listStatisticalCustomer();
+    public List<CustomerStatisticalInfo> listStatisticalCustomer(CustomerInfo customerInfo) {
+        return customerInfoMapper.listStatisticalCustomer(customerInfo);
     }
 
     @Override

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

@@ -52,7 +52,7 @@ public interface CustomerInfoMapper {
      * 导出客诉信息到excel
      * @return
      */
-    List<CustomerStatisticalInfo> listStatisticalCustomer();
+    List<CustomerStatisticalInfo> listStatisticalCustomer(CustomerInfo customerInfo);
 
     /**
      * 总销量

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

@@ -725,7 +725,7 @@
   </select>
 
   <!-- 导出客诉信息到excel -->
-  <select id="listStatisticalCustomer" resultType="CustomerStatisticalInfo">
+  <select id="listStatisticalCustomer" parameterType="CustomerInfo" resultType="CustomerStatisticalInfo">
 SELECT
 	c.customer_id customerId,
 	null AS orderId,
@@ -803,6 +803,23 @@ LEFT JOIN tb_rst_cm_relation cr ON cr.customer_id = c.customer_id
 LEFT JOIN tb_rst_cm_proc_method cpm ON cpm.proc_method_id = cr.proc_method_id
 LEFT JOIN tb_rst_cm_proc_type cpt ON cpt.proc_type_id = cpm.proc_type_id
 LEFT JOIN tb_rst_cm_sendback_info csi ON csi.relation_id = cr.relation_id
+<where>
+  <if test="companyId != null and companyId!=''">
+    c.company_id = #{companyId}
+  </if>
+  <if test="storeId != null and storeId!=''">
+    AND c.store_id = #{storeId}
+  </if>
+  <if test="procTypeId != null and procTypeId!=''">
+    AND cpt.proc_type_id = #{procTypeId}
+  </if>
+  <if test="startTime!=null and startTime!='' ">
+    AND c.customer_create_time &gt; #{startTime}
+  </if>
+  <if test="endTime!=null and endTime!=''">
+    and c.customer_create_time &lt; #{endTime}
+  </if>
+</where>
 </select>
   <!-- 退换货统计sql start -->
   <!-- 总销量 -->
@@ -1436,34 +1453,35 @@ LEFT JOIN tb_rst_cm_sendback_info csi ON csi.relation_id = cr.relation_id
   <select id="listDownloadProgressInfo" parameterType="DownloadProgressInfo" resultType="DownloadProgressInfo">
       SELECT * FROM tb_rst_download_progress_info
       <where>
-        <if test="downloadId != null || downloadId != ''">
+        <if test="downloadId != null and downloadId != ''">
           download_id = #{downloadId}
         </if>
-        <if test="downloadAdminId != null || downloadAdminId != ''">
+        <if test="downloadAdminId != null and downloadAdminId != ''">
           download_admin_id = #{downloadAdminId}
         </if>
-        <if test="downloadStatus != null || downloadStatus != ''">
+        <if test="downloadStatus != null and downloadStatus != ''">
           download_status = #{downloadStatus}
         </if>
       </where>
+      ORDER BY download_create_time DESC
   </select>
   <update id="updateDownloadProgressInfo" parameterType="DownloadProgressInfo">
       update tb_rst_download_progress_info
       <set>
-        <if test="downloadStatus != null || downloadStatus != ''">
+        <if test="downloadStatus != null and downloadStatus != ''">
           download_status = #{downloadStatus},
         </if>
-        <if test="downloadProgress != null || downloadProgress != ''">
+        <if test="downloadProgress != null and downloadProgress != ''">
           download_progress = #{downloadProgress},
         </if>
-        <if test="downloadUrl != null || downloadUrl != ''">
+        <if test="downloadUrl != null and downloadUrl != ''">
           download_url = #{downloadUrl},
         </if>
-        <if test="downloadDate != null || downloadDate != ''">
+        <if test="downloadDate != null and downloadDate != ''">
           download_date = #{downloadDate}
         </if>
       </set>
-
+      WHERE download_id = #{downloadId}
   </update>
 
   <insert id="addDownloadProgressInfo" parameterType="DownloadProgressInfo"  keyProperty="downloadId" useGeneratedKeys="true">

+ 156 - 108
watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminCustomerController.java

@@ -1682,142 +1682,189 @@ public class AdminCustomerController {
         }
     }
 
-
     /**
-     * 下载客诉信息 (2018-05-29)
+     * 进入下载客诉页面
      *
      * @param request
      * @param res
      * @param
      * @throws Exception
      */
-    @RequestMapping("/download_customer_excel")
-    public void downloadEfastOrderExcel(HttpServletRequest request, HttpServletResponse res) throws Exception {
+    @ResponseBody
+    @RequestMapping("/to_download_customer_excel")
+    public ModelAndView toDownloadCustomerExcel(HttpServletRequest request, HttpServletResponse res, CustomerInfo customerInfo) throws Exception {
+        ModelAndView mv = new ModelAndView("cm/customer/download_customer");
         Admin admin = AdminUtils.getLoginAdmin();
-        //添加一条下载记录
+        //获取销售公司
+        List<CompanyInfo> companyInfoList = companyInfoService.listCompanyInfo(new CompanyInfo());
+        //查询店铺
+        StoreInfo storeInfo = new StoreInfo();
+        storeInfo.setCompanyId(companyInfoList.get(0).getCompanyId());
+        List<StoreInfo> storeList = storeInfoService.listStore(storeInfo);
+        //查询处理类型
+        List<ProcType> procTypeList = customerService.listProcType();
+        //查询登录人下载客诉记录
         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 = {
-                "日期", "姓名", "联系电话", "类别", "来源入口",
-                "问题类别", "小类名称", "客诉问题", "处理过程", "购买日期",
-                "处理方式","处理结果", "销售公司", "销售渠道", "产品型号", "产品颜色",
-                "产品数量", "寄回快递", "寄回单号", "签收日期",
-                "状态", "寄出快递", "寄出快递", "开箱损", "二次客诉", "跟进客服", "工厂报价", "客户报价", "邮费信息"
-        };
-        List<CustomerStatisticalInfo> customerStatisticalInfoList = new ArrayList<>();
-        for (CustomerStatisticalInfo customerInfo : customerList) {
-            long startTime=System.currentTimeMillis();   //获取开始时间
-            s++;
-            //新建一个容器
-            CustomerStatisticalInfo customer = new CustomerStatisticalInfo();
-            //将数据copy到新容器
-            BeanUtils.copyProperties(customerInfo, customer);
-            CustomerCommon customerCommon = new CustomerCommon();
-            customerCommon.setCustomerId(customerInfo.getCustomerId());
-            customerCommon.setRelationId(customerInfo.getRelationId());
-            List<CustomerCommon> listCustomerCommon = customerService.listCustomerCommons(customerCommon);
-            if(listCustomerCommon.size() > 0) {
-                for (CustomerCommon common : listCustomerCommon) {
-                    if (common.getSalesOrderList().size() > 0) {
-                        for (SalesOrder salesOrder : common.getSalesOrderList()) {
-                            if (salesOrder.getSalesOrderItemList().size() > 0) {
-                                for (SalesOrderItem salesOrderItem : salesOrder.getSalesOrderItemList()) {
-                                    //将数据copy到新容器
-                                    CustomerStatisticalInfo customers = new CustomerStatisticalInfo();
-                                    BeanUtils.copyProperties(customer, customers);
-                                    customers.setRelationBackLogisticsCompany(customerInfo.getRelationBackLogisticsCompany());
-                                    customers.setRelationBackLogisticsNo(customerInfo.getRelationBackLogisticsNo());
-                                    customers.setRelationSendLogisticsCompany(customerInfo.getRelationSendLogisticsCompany());
-                                    customers.setRelationSendLogisticsNo(customerInfo.getRelationSendLogisticsNo());
-                                    customers.setRelationBackStatus(String.valueOf(customerInfo.getRelationBackStatus()));
-                                            if(customerInfo.getRelationBackReceiptDate() == null){
-                                                customers.setRelationBackReceiptDate(null);
-                                            }else{
-                                                customers.setRelationBackReceiptDate(customerInfo.getRelationBackReceiptDate());
-                                            }
-                                    customers.setSalesPayTime(salesOrder.getSalesPayTime());
-                                    customers.setItemProductName(salesOrderItem.getItemProductName());
-                                    customers.setItemProductColor(salesOrderItem.getItemProductColor());
-                                    customers.setItemNum(String.valueOf(salesOrderItem.getItemNum()));
-                                    customers.setRelationFactoryCosts(customerInfo.getRelationFactoryCosts());
-                                    customers.setRelationCustomerCosts(customerInfo.getRelationCustomerCosts());
-                                    String postageString = "";
-                                    //查询邮费信息
-                                    List<PostageInfo> listPostageInfo = customerService.listPostageInfo(customers.getRelationId());
-                                    if(listPostageInfo.size() > 0){
-                                        for(PostageInfo postageInfo : listPostageInfo){
-                                            String state = "";
-                                            if(postageInfo.getPostageStatus() == 1){
-                                                state = "未申请";
-                                            }
-                                            if(postageInfo.getPostageStatus() == 2){
-                                                state = "已申请(待转账)";
-                                            }
-                                            if(postageInfo.getPostageStatus() == 3){
-                                                state = "已转账";
+        List<DownloadProgressInfo> listDownloadProgressInfo = customerService.listDownloadProgressInfo(downloadProgressInfo);
+        mv.addObject("listDownloadProgressInfo",listDownloadProgressInfo);
+        mv.addObject("companyInfoList",companyInfoList);
+        mv.addObject("storeList",storeList);
+        mv.addObject("procTypeList",procTypeList);
+        return mv;
+    }
+
+    /**
+     * 下载客诉信息 (2018-05-29)
+     *
+     * @param request
+     * @param res
+     * @param
+     * @throws Exception
+     */
+    @ResponseBody
+    @RequestMapping("/download_customer_excel")
+    public ResponseJson downloadEfastOrderExcel(HttpServletRequest request, HttpServletResponse res, CustomerInfo customerInfo) throws Exception {
+        String path = request.getSession().getServletContext().getRealPath("/");
+        new Thread(new Mythread(path,customerInfo)).start();
+        return new ResponseJson(200, "查询成功", 200);
+    }
+
+    class Mythread extends Thread{
+        private String path;
+        private CustomerInfo customerInfo;
+        public Mythread(String path,CustomerInfo customerInfo) {
+            this.path=path;
+            this.customerInfo=customerInfo;
+        }
+        @Override
+        public void run(){
+            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;
+            int s = 0;
+            List<CustomerStatisticalInfo> customerList = customerService.listStatisticalCustomer(customerInfo);
+            String[] cells = {
+                    "日期", "姓名", "联系电话", "类别", "来源入口",
+                    "问题类别", "小类名称", "客诉问题", "处理过程", "购买日期",
+                    "处理方式","处理结果", "销售公司", "销售渠道", "产品型号", "产品颜色",
+                    "产品数量", "寄回快递", "寄回单号", "签收日期",
+                    "状态", "寄出快递", "寄出快递", "开箱损", "二次客诉", "跟进客服", "工厂报价", "客户报价", "邮费信息"
+            };
+            List<CustomerStatisticalInfo> customerStatisticalInfoList = new ArrayList<>();
+            for (CustomerStatisticalInfo customerInfo : customerList) {
+                long startTime=System.currentTimeMillis();   //获取开始时间
+                s++;
+                //新建一个容器
+                CustomerStatisticalInfo customer = new CustomerStatisticalInfo();
+                //将数据copy到新容器
+                BeanUtils.copyProperties(customerInfo, customer);
+                CustomerCommon customerCommon = new CustomerCommon();
+                customerCommon.setCustomerId(customerInfo.getCustomerId());
+                customerCommon.setRelationId(customerInfo.getRelationId());
+                List<CustomerCommon> listCustomerCommon = customerService.listCustomerCommons(customerCommon);
+                if(listCustomerCommon.size() > 0) {
+                    for (CustomerCommon common : listCustomerCommon) {
+                        if (common.getSalesOrderList().size() > 0) {
+                            for (SalesOrder salesOrder : common.getSalesOrderList()) {
+                                if (salesOrder.getSalesOrderItemList().size() > 0) {
+                                    for (SalesOrderItem salesOrderItem : salesOrder.getSalesOrderItemList()) {
+                                        //将数据copy到新容器
+                                        CustomerStatisticalInfo customers = new CustomerStatisticalInfo();
+                                        BeanUtils.copyProperties(customer, customers);
+                                        customers.setRelationBackLogisticsCompany(customerInfo.getRelationBackLogisticsCompany());
+                                        customers.setRelationBackLogisticsNo(customerInfo.getRelationBackLogisticsNo());
+                                        customers.setRelationSendLogisticsCompany(customerInfo.getRelationSendLogisticsCompany());
+                                        customers.setRelationSendLogisticsNo(customerInfo.getRelationSendLogisticsNo());
+                                        customers.setRelationBackStatus(String.valueOf(customerInfo.getRelationBackStatus()));
+                                                if(customerInfo.getRelationBackReceiptDate() == null){
+                                                    customers.setRelationBackReceiptDate(null);
+                                                }else{
+                                                    customers.setRelationBackReceiptDate(customerInfo.getRelationBackReceiptDate());
+                                                }
+                                        customers.setSalesPayTime(salesOrder.getSalesPayTime());
+                                        customers.setItemProductName(salesOrderItem.getItemProductName());
+                                        customers.setItemProductColor(salesOrderItem.getItemProductColor());
+                                        customers.setItemNum(String.valueOf(salesOrderItem.getItemNum()));
+                                        customers.setRelationFactoryCosts(customerInfo.getRelationFactoryCosts());
+                                        customers.setRelationCustomerCosts(customerInfo.getRelationCustomerCosts());
+                                        String postageString = "";
+                                        //查询邮费信息
+                                        List<PostageInfo> listPostageInfo = customerService.listPostageInfo(customers.getRelationId());
+                                        if(listPostageInfo.size() > 0){
+                                            for(PostageInfo postageInfo : listPostageInfo){
+                                                String state = "";
+                                                if(postageInfo.getPostageStatus() == 1){
+                                                    state = "未申请";
+                                                }
+                                                if(postageInfo.getPostageStatus() == 2){
+                                                    state = "已申请(待转账)";
+                                                }
+                                                if(postageInfo.getPostageStatus() == 3){
+                                                    state = "已转账";
+                                                }
+                                                postageString = postageString+"状态:"+state+" ,金额:"+postageInfo.getPostageAmount()/100+" ,支付宝账号:"+postageInfo.getPostageAlipay()+";";
                                             }
-                                            postageString = postageString+"状态:"+state+" ,金额:"+postageInfo.getPostageAmount()/100+" ,支付宝账号:"+postageInfo.getPostageAlipay()+";";
                                         }
+                                        customers.setPostageString(postageString);
+                                        customerStatisticalInfoList.add(customers);
                                     }
-                                    customers.setPostageString(postageString);
-                                    customerStatisticalInfoList.add(customers);
+                                } else {
+                                    customerStatisticalInfoList.add(customer);
                                 }
-                            } else {
-                                customerStatisticalInfoList.add(customer);
                             }
+                        } else {
+                            customerStatisticalInfoList.add(customer);
                         }
-                    } else {
-                        customerStatisticalInfoList.add(customer);
-                    }
 
+                    }
+                }else{
+                    customerStatisticalInfoList.add(customer);
                 }
-            }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{
+                long endTime=System.currentTimeMillis(); //获取结束时间
                 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);
+                if(s == 1){
+                    cycleOne = endTime - startTime;
+
+                    SimpleDateFormat sdf3=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    cycleOnes = cycleOne * customerList.size();
+                    //修改预计下载完成时间
+                    downloadProgressInfo.setDownloadDate(sdf3.format(new Date().getTime()+cycleOnes));
+                    downloadProgressInfo.setDownloadProgress(result);
+                    customerService.updateDownloadProgressInfo(downloadProgressInfo);
+                }else{
+                    numberFormat.setMaximumFractionDigits(2);
+                    downloadProgressInfo.setDownloadProgress(result);
+                    customerService.updateDownloadProgressInfo(downloadProgressInfo);
+                }
+            }
+                //导出订单Excel并下载
+            try {
+                customerExcel(cells,customerStatisticalInfoList,downloadProgressInfo,path);
+            } catch (Exception e) {
+                e.printStackTrace();
             }
 
         }
-            //导出订单Excel并下载
-            customerExcel(request,res,cells,customerStatisticalInfoList,downloadProgressInfo);
-
         }
 
 
     /**
      * 导出订单Excel并下载
-     * @param request
-     * @param res
      * @param cells
      * @throws Exception
      */
-    public void customerExcel(HttpServletRequest request,HttpServletResponse res,
-                                String[] cells,List<CustomerStatisticalInfo> customerList,
-                              DownloadProgressInfo downloadProgressInfo) throws Exception {
+    public void customerExcel(String[] cells,List<CustomerStatisticalInfo> customerList,
+                              DownloadProgressInfo downloadProgressInfo,String path) throws Exception {
 
         //创建一个workbook,对应一个Excel文件
         HSSFWorkbook wb = new HSSFWorkbook();
@@ -1918,7 +1965,7 @@ public class AdminCustomerController {
 
         }
         //下载导出订单Excel
-       downloadCustomerExcel(wb,downloadProgressInfo);
+       downloadCustomerExcel(wb,downloadProgressInfo,path);
     }
 
     /**
@@ -1926,18 +1973,19 @@ public class AdminCustomerController {
      * @param wb
      * @throws Exception
      */
-    public void downloadCustomerExcel(HSSFWorkbook wb,DownloadProgressInfo downloadProgressInfo) throws Exception{
+    public void downloadCustomerExcel(HSSFWorkbook wb,DownloadProgressInfo downloadProgressInfo,String path) 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");
+        FileOutputStream fout = new FileOutputStream(path+"/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");
+        downloadProgressInfo.setDownloadUrl("\\common\\customerExcel\\"+fileName+downloadProgressInfo.getDownloadId()+".xls");
+        customerService.updateDownloadProgressInfo(downloadProgressInfo);
     }
 
     /**

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 198 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/cm/customer/download_customer.ftl