瀏覽代碼

客诉统计下载功能

liujiankang 5 年之前
父節點
當前提交
15648c0eb8
共有 20 個文件被更改,包括 787 次插入119 次删除
  1. 12 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/cm/CustomerCommon.java
  2. 12 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/cm/CustomerStatisticalInfo.java
  3. 106 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/cm/CustomerStatistics.java
  4. 9 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/fm/ComplaintDetectInfo.java
  5. 5 0
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/cm/CustomerService.java
  6. 5 0
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/fm/ComplaintSignclosedInfoService.java
  7. 7 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/cm/CustomerServiceImpl.java
  8. 6 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/CustomerInfoMapper.java
  9. 31 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/customerInfoMapper.xml
  10. 31 28
      watero-rst-service/src/main/java/com/iamberry/rst/service/fm/ComplaintDetectInfoServiceImpl.java
  11. 5 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/fm/ComplaintSignclosedInfoServiceImpl.java
  12. 5 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/ComplaintSignclosedInfoMapper.java
  13. 2 1
      watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/complaintDetectInfoMapper.xml
  14. 22 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/complaintSignclosedInfoMapper.xml
  15. 3 3
      watero-rst-service/src/main/java/com/iamberry/rst/util/CustomerCommonUtil.java
  16. 341 11
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminCustomerController.java
  17. 153 76
      watero-rst-web/src/main/java/com/iamberry/rst/utils/ExcelUtil.java
  18. 3 0
      watero-rst-web/src/main/resources/watero-rst-orm.xml
  19. 27 0
      watero-rst-web/src/main/webapp/WEB-INF/views/cm/customer/download_customer.ftl
  20. 2 0
      watero-rst-web/src/main/webapp/WEB-INF/views/cm/inspection/detect_repair_list.ftl

+ 12 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/cm/CustomerCommon.java

@@ -1,5 +1,6 @@
 package com.iamberry.rst.core.cm;
 
+import com.iamberry.rst.core.fm.SignclosedProductInfo;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
@@ -111,6 +112,9 @@ public class CustomerCommon implements Serializable {
      /*订单集合*/
      private List<SalesOrder> salesOrderList = new ArrayList<>();
 
+    //售后签收产品表
+    private List<SignclosedProductInfo> signclosedProductInfos = new ArrayList<SignclosedProductInfo>();
+
     public String getSalesOrderId() {
         return salesOrderId;
     }
@@ -458,4 +462,12 @@ public class CustomerCommon implements Serializable {
     public void setRelationCustomerCosts(Integer relationCustomerCosts) {
         this.relationCustomerCosts = relationCustomerCosts;
     }
+
+    public List<SignclosedProductInfo> getSignclosedProductInfos() {
+        return signclosedProductInfos;
+    }
+
+    public void setSignclosedProductInfos(List<SignclosedProductInfo> signclosedProductInfos) {
+        this.signclosedProductInfos = signclosedProductInfos;
+    }
 }

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

@@ -1,6 +1,7 @@
 package com.iamberry.rst.core.cm;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.iamberry.rst.core.fm.SignclosedProductInfo;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
@@ -48,6 +49,9 @@ public class CustomerStatisticalInfo implements Serializable {
     private String procMethodName;//处理详细方式
     private String postageString;//邮费信息
 
+    //售后签收产品表
+    private List<SignclosedProductInfo> signclosedProductInfos = new ArrayList<SignclosedProductInfo>();
+
     public Integer getCustomerId() {
         return customerId;
     }
@@ -303,4 +307,12 @@ public class CustomerStatisticalInfo implements Serializable {
     public void setPostageString(String postageString) {
         this.postageString = postageString;
     }
+
+    public List<SignclosedProductInfo> getSignclosedProductInfos() {
+        return signclosedProductInfos;
+    }
+
+    public void setSignclosedProductInfos(List<SignclosedProductInfo> signclosedProductInfos) {
+        this.signclosedProductInfos = signclosedProductInfos;
+    }
 }

+ 106 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/cm/CustomerStatistics.java

@@ -0,0 +1,106 @@
+package com.iamberry.rst.core.cm;
+
+import java.io.Serializable;
+
+public class CustomerStatistics implements Serializable {
+    private static final long serialVersionUID = -4821717154706468738L;
+    private String productModel;//产品型号
+    private String month;//月份
+    private String processingResults;//处理结果
+    private Integer numberOne;//数量1
+    private String processingMethod;//处理方法
+    private Integer numberTwo ;//数量2
+    private String buyMonth;//购买月份
+    private Integer numberThree;//数量3
+    private String aftersaleProblem ;//客诉问题
+    private Integer numberFour;//数量4
+    private Integer numberFive;//数量5
+
+    public String getProductModel() {
+        return productModel;
+    }
+
+    public void setProductModel(String productModel) {
+        this.productModel = productModel;
+    }
+
+    public String getMonth() {
+        return month;
+    }
+
+    public void setMonth(String month) {
+        this.month = month;
+    }
+
+    public String getProcessingResults() {
+        return processingResults;
+    }
+
+    public void setProcessingResults(String processingResults) {
+        this.processingResults = processingResults;
+    }
+
+    public Integer getNumberOne() {
+        return numberOne;
+    }
+
+    public void setNumberOne(Integer numberOne) {
+        this.numberOne = numberOne;
+    }
+
+    public String getProcessingMethod() {
+        return processingMethod;
+    }
+
+    public void setProcessingMethod(String processingMethod) {
+        this.processingMethod = processingMethod;
+    }
+
+    public Integer getNumberTwo() {
+        return numberTwo;
+    }
+
+    public void setNumberTwo(Integer numberTwo) {
+        this.numberTwo = numberTwo;
+    }
+
+    public String getBuyMonth() {
+        return buyMonth;
+    }
+
+    public void setBuyMonth(String buyMonth) {
+        this.buyMonth = buyMonth;
+    }
+
+    public Integer getNumberThree() {
+        return numberThree;
+    }
+
+    public void setNumberThree(Integer numberThree) {
+        this.numberThree = numberThree;
+    }
+
+    public String getAftersaleProblem() {
+        return aftersaleProblem;
+    }
+
+    public void setAftersaleProblem(String aftersaleProblem) {
+        this.aftersaleProblem = aftersaleProblem;
+    }
+
+    public Integer getNumberFour() {
+        return numberFour;
+    }
+
+    public void setNumberFour(Integer numberFour) {
+        this.numberFour = numberFour;
+    }
+
+    public Integer getNumberFive() {
+        return numberFive;
+    }
+
+    public void setNumberFive(Integer numberFive) {
+        this.numberFive = numberFive;
+    }
+}

+ 9 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/fm/ComplaintDetectInfo.java

@@ -138,6 +138,7 @@ public class ComplaintDetectInfo implements Serializable {
     private String signclosedStoreName;//店铺名称
 
     private Integer detectIsDownload;
+    private String signclosedCustomerDesc;//签收客服备注
 
     public String getQuestionName() {
         return questionName;
@@ -889,4 +890,12 @@ public class ComplaintDetectInfo implements Serializable {
     public void setDetectIsDownload(Integer detectIsDownload) {
         this.detectIsDownload = detectIsDownload;
     }
+
+    public String getSignclosedCustomerDesc() {
+        return signclosedCustomerDesc;
+    }
+
+    public void setSignclosedCustomerDesc(String signclosedCustomerDesc) {
+        this.signclosedCustomerDesc = signclosedCustomerDesc;
+    }
 }

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

@@ -367,4 +367,9 @@ public interface CustomerService {
      * @return
      */
     Integer addDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo);
+    /**
+     * 查询客诉统计
+     * @return
+     */
+    List<CustomerStatistics> selectCustomerStatistics(String month);
 }

+ 5 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/fm/ComplaintSignclosedInfoService.java

@@ -104,4 +104,9 @@ public interface ComplaintSignclosedInfoService {
      * @return
      */
     Integer updateSignclosedByYny(ComplaintSignclosedInfo record);
+    /**
+     * 查询签收产品记录
+     * @return
+     */
+    List<SignclosedProductInfo> listSignclosedProductById(Integer customerId);
 }

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

@@ -1413,6 +1413,8 @@ public class CustomerServiceImpl implements CustomerService {
             closedProdcue.setRelationId(c.getRelationId());
             List<ClosedProdcue> closedProdcueList = closedProdcueMapper.listclosedProdcue(closedProdcue);
             c.setClosedProdcues(closedProdcueList);
+            //查询实际签收产品
+            c.setSignclosedProductInfos(complaintSignclosedInfoMapper.listSignclosedProductById(c.getCustomerId()));
         }
         return customerCommonList;
     }
@@ -1725,4 +1727,9 @@ public class CustomerServiceImpl implements CustomerService {
     public Integer addDownloadProgressInfo(DownloadProgressInfo downloadProgressInfo) {
         return customerInfoMapper.addDownloadProgressInfo(downloadProgressInfo);
     }
+
+    @Override
+    public List<CustomerStatistics> selectCustomerStatistics(String month) {
+        return customerInfoMapper.selectCustomerStatistics(month);
+    }
 }

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

@@ -252,4 +252,10 @@ public interface CustomerInfoMapper {
      * @return
      */
     Integer updateCmRelationProcMethod(CmRelation cmRelation);
+
+    /**
+     * 查询客诉统计
+     * @return
+     */
+    List<CustomerStatistics> selectCustomerStatistics(String month);
 }

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

@@ -1646,4 +1646,35 @@ LEFT JOIN tb_rst_cm_sendback_info csi ON csi.relation_id = cr.relation_id
     WHERE
       customer_id = #{customerId}
   </update>
+
+
+    <select id="selectCustomerStatistics" parameterType="String" resultType="CustomerStatistics">
+        SELECT
+        distinct(rpt.type_name) AS productModel,
+        date_format(
+        ci.customer_create_time,
+        '%Y-%m'
+        ) AS month,
+        pt.proc_type_name AS processingResults,
+        count(pt.proc_type_name) AS numberOne,
+        pm.proc_method_name AS processingMethod,
+        count(pm.proc_method_name) AS numberTwo,
+        date_format(oi.sales_pay_time,'%Y-%m') AS buyMonth,
+        count(date_format(oi.sales_pay_time,'%Y-%m')) AS numberThree,
+        cq.question_name AS aftersaleProblem,
+        count(cq.question_name) AS numberFour,
+        sum(csp.product_num) AS numberFive
+        FROM
+        tb_rst_cm_customer_info ci
+        LEFT JOIN tb_rst_product_type rpt ON rpt.type_id = ci.type_id
+        LEFT JOIN tb_rst_cm_relation cr ON cr.customer_id = ci.customer_id
+        LEFT JOIN tb_rst_cm_proc_method pm ON pm.proc_method_id = cr.proc_method_id
+        LEFT JOIN tb_rst_cm_proc_type pt ON pt.proc_type_id = pm.proc_type_id
+        LEFT JOIN tb_rst_sales_order_info oi ON oi.sales_customer_id = ci.customer_id
+        LEFT JOIN tb_rst_cm_complaint_question cq ON cq.question_id = ci.question_id
+        LEFT JOIN tb_rst_complaint_signclosed cs ON cs.signclosed_customer_id = ci.customer_id
+        LEFT JOIN tb_rst_complaint_signclosed_product csp ON csp.signclosed_id = cs.signclosed_id
+        WHERE ci.customer_create_time &gt;= CONCAT(#{month},'-01') and ci.customer_create_time &lt;= CONCAT(#{month},'-31')
+        group by rpt.type_name,pt.proc_type_name,pm.proc_method_name,	date_format(oi.sales_pay_time,'%Y-%m'),cq.question_name
+    </select>
 </mapper>

+ 31 - 28
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/ComplaintDetectInfoServiceImpl.java

@@ -616,35 +616,38 @@ public class ComplaintDetectInfoServiceImpl implements ComplaintDetectInfoServic
         try {
             if(complaintDetectInfoMapper.updateDetectById(detectInfo) > 0){
                 //添加业务员操作记录
-                TreatmentRecordLog log = new TreatmentRecordLog();
-                log.setDetectId(detectInfo.getDetectId());
-                log.setRecordAdminId(detect.getSalesmanAdminId());
-                log.setRecordDesc(detect.getDetectCustomerDesc());
-                log.setRecordProcessingResults(detectInfo.getDetectProcessingResults());
-                complaintDetectInfoMapper.addTreatmentRecordLog(log);
-                //发送确认短信
-                String results = "";
-                switch (detectInfo.getDetectProcessingResults()){
-                    case 1:
-                        results = "付费维修";
-                        break;
-                    case 2:
-                        results = "免费维修";
-                        break;
-                    case 3:
-                        results = "退货";
-                        break;
-                    case 4:
-                        results = "换货";
-                        break;
-                    case 5:
-                        results = "原机退回";
-                        break;
+                if(detect.getSalesmanAdminId() != null && !detect.getSalesmanAdminId().equals("")){
+                    TreatmentRecordLog log = new TreatmentRecordLog();
+                    log.setDetectId(detectInfo.getDetectId());
+                    log.setRecordAdminId(detect.getSalesmanAdminId());
+                    log.setRecordDesc(detect.getDetectCustomerDesc());
+                    log.setRecordProcessingResults(detectInfo.getDetectProcessingResults());
+                    complaintDetectInfoMapper.addTreatmentRecordLog(log);
+                    //发送确认短信
+                    String results = "";
+                    switch (detectInfo.getDetectProcessingResults()){
+                        case 1:
+                            results = "付费维修";
+                            break;
+                        case 2:
+                            results = "免费维修";
+                            break;
+                        case 3:
+                            results = "退货";
+                            break;
+                        case 4:
+                            results = "换货";
+                            break;
+                        case 5:
+                            results = "原机退回";
+                            break;
+                    }
+                    String text = MessageFormat.format(SmsConfig.CUSTOMER_CONFIRM, detect.getDetectNumber(),results);
+                    String result = smsService.sendOtherCMS(SmsConfig.CUSTOMER_PHONE, text);
+                    logger.info("给 " + SmsConfig.CUSTOMER_PHONE + " 手机用户发送短信:" + text+"发送结果:"+result);
+                    return true;
                 }
-                String text = MessageFormat.format(SmsConfig.CUSTOMER_CONFIRM, detect.getDetectNumber(),results);
-                String result = smsService.sendOtherCMS(SmsConfig.CUSTOMER_PHONE, text);
-                logger.info("给 " + SmsConfig.CUSTOMER_PHONE + " 手机用户发送短信:" + text+"发送结果:"+result);
-                return true;
+
             }
         }catch (Exception e){
             e.printStackTrace();

+ 5 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/ComplaintSignclosedInfoServiceImpl.java

@@ -478,6 +478,11 @@ public class ComplaintSignclosedInfoServiceImpl implements ComplaintSignclosedIn
         return 1;
     }
 
+    @Override
+    public List<SignclosedProductInfo> listSignclosedProductById(Integer customerId) {
+        return complaintSignclosedInfoMapper.listSignclosedProductById(customerId);
+    }
+
     private Integer addSifnclosed(Map<String,Integer> Map,Integer signclosedId) {
         Integer msg = 0;
         for (Map.Entry<String, Integer> entry : Map.entrySet()) {

+ 5 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/ComplaintSignclosedInfoMapper.java

@@ -67,4 +67,9 @@ public interface ComplaintSignclosedInfoMapper {
      * @return
      */
     Integer getSignclosedDay(ComplaintSignclosedInfo complaintSignclosedInfo);
+    /**
+     * 查询签收产品记录
+     * @return
+     */
+    List<SignclosedProductInfo> listSignclosedProductById(Integer customerId);
 }

+ 2 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/complaintDetectInfoMapper.xml

@@ -184,7 +184,8 @@
     cpts.proc_type_name typeName,
     cd.company_id companyId,
     si.store_name signclosedStoreName,
-    cd.detect_is_download detectIsDownload
+    cd.detect_is_download detectIsDownload,
+    cs.signclosed_customer_desc signclosedCustomerDesc
     from tb_rst_complaint_detect cd
     LEFT JOIN tb_rst_product_info pi ON cd.product_id = pi.product_id
     LEFT JOIN tb_rst_cm_question_describe qd on cd.customer_id = qd.customer_id

+ 22 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/complaintSignclosedInfoMapper.xml

@@ -346,6 +346,7 @@
       LEFT JOIN tb_rst_cm_customer_info ci ON cs.signclosed_customer_id = ci.customer_id
       <where>
           signclosed_is_receiving = 2
+        AND signclosed_company_id != 3
           <if test="date != null and date != ''" >
               AND cs.signclosed_date = #{date}
           </if>
@@ -357,4 +358,25 @@
         </if>
       </where>
   </select>
+
+    <select id="listSignclosedProductById" resultType="SignclosedProductInfo" parameterType="Integer" >
+        select
+        sp.product_id productId,
+        sp.signclosed_id signclosedId,
+        sp.product_name productName,
+        sp.signclosed_create_time signclosedCreateTime,
+        sp.signclosed_update_time signclosedUpdateTime,
+        sp.signclosed_product_type signclosedProductType,
+        sp.signclosed_product_id signclosedProductId,
+        sp.signclosed_product_color signclosedProductColor,
+        pc.color_name colorName,
+        sp.product_num productNum
+        from
+        tb_rst_complaint_signclosed_product sp
+        LEFT JOIN tb_rst_complaint_signclosed cs on cs.signclosed_id = sp.signclosed_id
+        LEFT JOIN tb_rst_product_color pc on sp.signclosed_product_color = pc.color_id
+        LEFT JOIN tb_rst_product_info pi on sp.signclosed_product_id = pi.product_id
+        where cs.signclosed_customer_id = #{customerId}
+        GROUP BY sp.product_name,pc.color_name
+    </select>
 </mapper>

+ 3 - 3
watero-rst-service/src/main/java/com/iamberry/rst/util/CustomerCommonUtil.java

@@ -2,7 +2,10 @@ package com.iamberry.rst.util;
 
 import com.iamberry.rst.core.cm.*;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 
 public class CustomerCommonUtil {
@@ -360,7 +363,4 @@ public class CustomerCommonUtil {
         }
     }
 
-
-
-
 }

+ 341 - 11
watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminCustomerController.java

@@ -5,10 +5,7 @@ import com.iamberry.rst.core.address.City;
 import com.iamberry.rst.core.address.District;
 import com.iamberry.rst.core.address.Province;
 import com.iamberry.rst.core.cm.*;
-import com.iamberry.rst.core.fm.ComplaintAfterSalesNum;
-import com.iamberry.rst.core.fm.ComplaintDetectInfo;
-import com.iamberry.rst.core.fm.ComplaintSignclosedInfo;
-import com.iamberry.rst.core.fm.ComplaintSmallClassInfo;
+import com.iamberry.rst.core.fm.*;
 import com.iamberry.rst.core.order.Product;
 import com.iamberry.rst.core.order.ProductColor;
 import com.iamberry.rst.core.order.ProductType;
@@ -25,6 +22,7 @@ import com.iamberry.rst.faces.order.LogisticsInfoService;
 import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.faces.sms.SmsService;
 import com.iamberry.rst.faces.sys.SysService;
+import com.iamberry.rst.util.CustomerCommonUtil;
 import com.iamberry.rst.util.SmsConfig;
 import com.iamberry.rst.utils.*;
 import com.iamberry.wechat.tools.NameUtils;
@@ -1868,6 +1866,7 @@ public class AdminCustomerController {
                                         customers.setItemNum(String.valueOf(salesOrderItem.getItemNum()));
                                         customers.setRelationFactoryCosts(customerInfo.getRelationFactoryCosts());
                                         customers.setRelationCustomerCosts(customerInfo.getRelationCustomerCosts());
+                                        customers.setSignclosedProductInfos(common.getSignclosedProductInfos());
                                         String postageString = "";
                                         //查询邮费信息
                                         List<PostageInfo> listPostageInfo = customerService.listPostageInfo(customers.getRelationId());
@@ -2012,11 +2011,14 @@ public class AdminCustomerController {
             row.createCell(11).setCellValue(customerStatisticalInfo.getCustomerIsSolve() == null ? null : customerStatisticalInfo.getCustomerIsSolve());
             row.createCell(12).setCellValue(customerStatisticalInfo.getCompanyName() == null ? null : customerStatisticalInfo.getCompanyName());
             row.createCell(13).setCellValue(customerStatisticalInfo.getStoreName() == null ? null : customerStatisticalInfo.getStoreName());
-            if(customerStatisticalInfo.getItemProductName() == null || customerStatisticalInfo.getItemProductColor() == null|| customerStatisticalInfo.getItemNum() == null){
-                row.createCell(14).setCellValue("");
-            }else{
-                row.createCell(14).setCellValue(customerStatisticalInfo.getItemProductName()+"("+customerStatisticalInfo.getItemProductColor()+")"+"*"+customerStatisticalInfo.getItemNum());
+            StringBuffer sb = new StringBuffer("");
+            if(customerStatisticalInfo.getSignclosedProductInfos().size() > 0){
+                for(SignclosedProductInfo sign : customerStatisticalInfo.getSignclosedProductInfos()){
+                    sb.append(sign.getProductName()+"("+sign.getColorName()+")"+"*"+sign.getProductNum()+";");
+                }
             }
+            row.createCell(14).setCellValue(sb.toString());
+
             row.createCell(15).setCellValue(customerStatisticalInfo.getItemProductColor() == null ? null : customerStatisticalInfo.getItemProductColor());
             row.createCell(16).setCellValue(customerStatisticalInfo.getItemNum() == null ? null : customerStatisticalInfo.getItemNum());
             row.createCell(17).setCellValue(backLogisticsCompany);
@@ -2042,7 +2044,7 @@ public class AdminCustomerController {
 
         }
         //下载导出订单Excel
-       downloadCustomerExcel(wb,downloadProgressInfo,path);
+       downloadCustomerExcel(wb,downloadProgressInfo,path,"客诉报表");
     }
 
     /**
@@ -2050,9 +2052,9 @@ public class AdminCustomerController {
      * @param wb
      * @throws Exception
      */
-    public void downloadCustomerExcel(HSSFWorkbook wb,DownloadProgressInfo downloadProgressInfo,String path) throws Exception{
+    public void downloadCustomerExcel(HSSFWorkbook wb,DownloadProgressInfo downloadProgressInfo,String path,String name) throws Exception{
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
-        String fileName = format.format(new Date()) + "客诉报表";
+        String fileName = format.format(new Date()) + name;
         try {
         FileOutputStream fout = new FileOutputStream(path+"/common/customerExcel/"+fileName+downloadProgressInfo.getDownloadId()+".xls");
         wb.write(fout);
@@ -2686,5 +2688,333 @@ public class AdminCustomerController {
         rj.addResponseKeyValue("isOneself",isOneself);
         return rj;
     }
+
+
+    /**
+     * 下载客诉统计信息 (2018-05-29)
+     *
+     * @param request
+     * @param res
+     * @param
+     * @throws Exception
+     */
+    @ResponseBody
+    @RequestMapping("/download_customer_statistics")
+    public ResponseJson downloadStatisticsExcel(HttpServletRequest request, HttpServletResponse res, CustomerInfo customerInfo) throws Exception {
+        String path = request.getSession().getServletContext().getRealPath("/");
+        new Thread(new Mythread2(path,customerInfo)).start();
+        return new ResponseJson(200, "查询成功", 200);
+    }
+
+    class Mythread2 extends Thread{
+        private String path;
+        private CustomerInfo customerInfo;
+        public Mythread2(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<CustomerStatistics> customerList = new ArrayList<>();
+            //计算统计月份
+            List<String> listmonth = ExcelUtil.month(customerInfo.getStartTime(),customerInfo.getEndTime());
+            if(listmonth.size() > 0){
+                for(String month : listmonth){
+                    List<CustomerStatistics> list = customerService.selectCustomerStatistics(month);
+                    customerList.addAll(list);
+                }
+
+            }
+
+            String[] cells = {
+                    "月份", "产品型号", "处理结果", "数量1", "处理方法",
+                    "数量2", "购买月份", "数量3", "客诉问题", "数量4",
+                    "数量5"
+            };
+
+            long startTime=System.currentTimeMillis();   //获取开始时间
+            s++;
+
+            long endTime=System.currentTimeMillis(); //获取结束时间
+            NumberFormat numberFormat = NumberFormat.getInstance();
+            float percentage = (float) s / (float) customerList.size() * 100;
+            String result = numberFormat.format(percentage);
+            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);
+            }
+            //导出订单Excel并下载
+            try {
+                customerExcel2(cells,customerList,downloadProgressInfo,path);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        }
+    }
+
+
+    /**
+     * 导出订单Excel并下载
+     * @param cells
+     * @throws Exception
+     */
+    public void customerExcel2(String[] cells,List<CustomerStatistics> customerList,
+                              DownloadProgressInfo downloadProgressInfo,String path) throws Exception {
+
+        //创建一个workbook,对应一个Excel文件
+        HSSFWorkbook wb = new HSSFWorkbook();
+        //在workbook中添加一个sheet,对应Excel中的一个sheet
+        HSSFSheet sheet = wb.createSheet("导出客诉统计");
+        //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
+        HSSFRow row = sheet.createRow((int) 0);
+        //创建单元格,设置值表头,设置表头居中
+        HSSFCellStyle style = wb.createCellStyle();
+        //居中格式
+        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        //设置表头
+
+        if (cells == null || cells.length == 0) {
+            return;
+        }
+        //循环设置表头
+        HSSFCell cell = null;
+        for (int i = 0; i < cells.length; i++) {
+            String name = cells[i];
+            cell = row.createCell(i);
+            cell.setCellValue(name);
+            cell.setCellStyle(style);
+        }
+
+        if (customerList.size() > 0) {
+            int s1 = 0;
+            for (int i = 0; i < customerList.size() - 1; i++) {
+                if (i >= s1) {
+                    for (int j = 0; j < customerList.size() - 1; j++) {
+                        if (j >= s1) {
+                            if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
+                                    && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())) {
+                                customerList.get(i).setNumberOne(customerList.get(i).getNumberOne() + customerList.get(j + 1).getNumberOne());
+                                customerList.get(j + 1).setNumberOne(0);
+                                s1 = j + 1;
+                            } else {
+                                s1 = j + 1;
+                                break;
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+            if (customerList.size() > 0) {
+                int s2 = 0;
+                for (int i = 0; i < customerList.size() - 1; i++) {
+                    if (i >= s2) {
+                        for (int j = 0; j < customerList.size() - 1; j++) {
+                            if (j >= s2) {
+                                if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
+                                        && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())
+                                        && customerList.get(i).getProcessingMethod().equals(customerList.get(j + 1).getProcessingMethod())) {
+                                    customerList.get(i).setNumberTwo(customerList.get(i).getNumberTwo() + customerList.get(j + 1).getNumberTwo());
+                                    customerList.get(j + 1).setNumberTwo(0);
+                                    s2 = j + 1;
+                                } else {
+                                    s2 = j + 1;
+                                    break;
+
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (customerList.size() > 0) {
+                int s2 = 0;
+                for (int i = 0; i < customerList.size() - 1; i++) {
+                    if (i >= s2) {
+                        for (int j = 0; j < customerList.size() - 1; j++) {
+                            if (j >= s2) {
+                                if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
+                                        && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())
+                                        && customerList.get(i).getProcessingMethod().equals(customerList.get(j + 1).getProcessingMethod())
+                                        && customerList.get(i).getBuyMonth() != null && customerList.get(j + 1).getBuyMonth() != null
+                                        && customerList.get(i).getBuyMonth().equals(customerList.get(j + 1).getBuyMonth())) {
+                                    customerList.get(i).setNumberThree(customerList.get(i).getNumberThree() + customerList.get(j + 1).getNumberThree());
+                                    customerList.get(j + 1).setNumberThree(0);
+
+                                    customerList.get(j + 1).setBuyMonth("");
+
+                                    s2 = j + 1;
+                                } else {
+                                    s2 = j + 1;
+                                    break;
+
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            if (customerList.size() > 0) {
+                int s2 = 0;
+                for (int i = 0; i < customerList.size() - 1; i++) {
+                    if (i >= s2) {
+                        for (int j = 0; j < customerList.size() - 1; j++) {
+                            if (j >= s2) {
+                                if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
+                                        && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())
+                                        && customerList.get(i).getProcessingMethod().equals(customerList.get(j + 1).getProcessingMethod())) {
+                                    customerList.get(j + 1).setProcessingMethod("");
+                                    s2 = j + 1;
+                                } else {
+                                    s2 = j + 1;
+                                    break;
+
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+            if (customerList.size() > 0) {
+                int s2 = 0;
+                for (int i = 0; i < customerList.size() - 1; i++) {
+                    if (i >= s2) {
+                        for (int j = 0; j < customerList.size() - 1; j++) {
+                            if (j >= s2) {
+                                if (customerList.get(i).getProcessingResults().equals(customerList.get(j + 1).getProcessingResults())
+                                        && customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())) {
+                                    customerList.get(j + 1).setProcessingResults("");
+                                    s2 = j + 1;
+                                } else {
+                                    s2 = j + 1;
+                                    break;
+
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+                if (customerList.size() > 0) {
+                    int s2 = 0;
+                    for (int i = 0; i < customerList.size() - 1; i++) {
+                        if (i >= s2) {
+                            for (int j = 0; j < customerList.size() - 1; j++) {
+                                if (j >= s2) {
+                                    if (customerList.get(i).getProductModel().equals(customerList.get(j + 1).getProductModel())) {
+                                        customerList.get(j + 1).setProductModel("");
+                                        s2 = j + 1;
+                                    } else {
+                                        s2 = j + 1;
+                                        break;
+
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                if (customerList.size() > 0) {
+                    int s2 = 0;
+                    for (int i = 0; i < customerList.size() - 1; i++) {
+                        if (i >= s2) {
+                            for (int j = 0; j < customerList.size() - 1; j++) {
+                                if (j >= s2) {
+                                    if (customerList.get(i).getMonth().equals(customerList.get(j + 1).getMonth())) {
+                                        customerList.get(j + 1).setMonth("");
+                                        s2 = j + 1;
+                                    } else {
+                                        s2 = j + 1;
+                                        break;
+
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            for (int i = 0; i < customerList.size(); i++) {
+                row = sheet.createRow((int) i + 1);
+                CustomerStatistics customerStatisticalInfo = customerList.get(i);
+                // 创建单元格,设置值
+                row.createCell(0).setCellValue(customerStatisticalInfo.getMonth() == null ? "" : customerStatisticalInfo.getMonth());
+                if(customerStatisticalInfo.getProductModel() == null){
+                    row.createCell(1).setCellValue("");
+                }else{
+                    row.createCell(1).setCellValue( customerStatisticalInfo.getProductModel());
+                }
+                if(customerStatisticalInfo.getProcessingResults() == null){
+                    row.createCell(2).setCellValue("");
+                }else{
+                    row.createCell(2).setCellValue( customerStatisticalInfo.getProcessingResults());
+                }
+                if(customerStatisticalInfo.getNumberOne() == null || customerStatisticalInfo.getNumberOne() == 0){
+                    row.createCell(3).setCellValue("");
+                }else{
+                    row.createCell(3).setCellValue( customerStatisticalInfo.getNumberOne());
+                }
+                if(customerStatisticalInfo.getProcessingMethod() == null){
+                    row.createCell(4).setCellValue("");
+                }else{
+                    row.createCell(4).setCellValue( customerStatisticalInfo.getProcessingMethod());
+                }
+                if(customerStatisticalInfo.getNumberTwo() == null || customerStatisticalInfo.getNumberTwo() == 0){
+                    row.createCell(5).setCellValue("");
+                }else{
+                    row.createCell(5).setCellValue( customerStatisticalInfo.getNumberTwo());
+                }
+                if(customerStatisticalInfo.getBuyMonth() == null){
+                    row.createCell(6).setCellValue("");
+                }else{
+                    row.createCell(6).setCellValue( customerStatisticalInfo.getBuyMonth());
+                }
+                if(customerStatisticalInfo.getNumberThree() == null || customerStatisticalInfo.getNumberThree() == 0){
+                    row.createCell(7).setCellValue("");
+                }else{
+                    row.createCell(7).setCellValue( customerStatisticalInfo.getNumberThree());
+                }
+                if(customerStatisticalInfo.getAftersaleProblem() == null){
+                    row.createCell(8).setCellValue("");
+                }else{
+                    row.createCell(8).setCellValue( customerStatisticalInfo.getAftersaleProblem());
+                }
+                if(customerStatisticalInfo.getNumberFour() == null || customerStatisticalInfo.getNumberFour() == 0){
+                    row.createCell(9).setCellValue("");
+                }else{
+                    row.createCell(9).setCellValue( customerStatisticalInfo.getNumberFour());
+                }
+                if(customerStatisticalInfo.getNumberFive() == null || customerStatisticalInfo.getNumberFive() == 0){
+                    row.createCell(10).setCellValue("");
+                }else{
+                    row.createCell(10).setCellValue( customerStatisticalInfo.getNumberFive());
+                }
+            }
+            NumberFormat numberFormat = NumberFormat.getInstance();
+            numberFormat.setMaximumFractionDigits(2);
+            downloadProgressInfo.setDownloadProgress("100");
+            customerService.updateDownloadProgressInfo(downloadProgressInfo);
+            //下载导出订单Excel
+            downloadCustomerExcel(wb, downloadProgressInfo,path,"统计报表");
+        }
 }
 

+ 153 - 76
watero-rst-web/src/main/java/com/iamberry/rst/utils/ExcelUtil.java

@@ -140,10 +140,11 @@ public class ExcelUtil {
 
     /**
      * 读取Excel内容 -- 行数是否超过100,超过false  不超过true;
+     *
      * @param filePath
      * @return
      */
-    public static boolean readExcelNumber(String filePath,Integer maxNuber) throws IOException {
+    public static boolean readExcelNumber(String filePath, Integer maxNuber) throws IOException {
         // 判断文件是否存在
         File file = new File(filePath);
         if (!file.exists()) {
@@ -180,15 +181,15 @@ public class ExcelUtil {
             }
 
             if (cellValue != null && !"".equals(cellValue)) {
-                number ++;
+                number++;
             }
             i++;
 
-            if(number > maxNuber+1){
+            if (number > maxNuber + 1) {
                 return false;
             }
 
-            if(i > maxNuber+1){
+            if (i > maxNuber + 1) {
                 break;
             }
         }
@@ -226,7 +227,7 @@ public class ExcelUtil {
         Cell cell = null;
         cell = rows.getCell(1);//列
         String bomName = "";
-        if(cell != null){
+        if (cell != null) {
             bomName = cell.getStringCellValue();
         }
 
@@ -234,7 +235,7 @@ public class ExcelUtil {
         rows = sheet.getRow(2);// 获取行
         cell = rows.getCell(1);//列
         String produceName = "";
-        if(cell != null){
+        if (cell != null) {
             produceName = cell.getStringCellValue();
         }
 
@@ -242,7 +243,7 @@ public class ExcelUtil {
         rows = sheet.getRow(3);// 获取行
         cell = rows.getCell(1);//列
         String bomVersion = "";
-        if(cell != null){
+        if (cell != null) {
             bomVersion = cell.getStringCellValue();
         }
 
@@ -250,7 +251,7 @@ public class ExcelUtil {
         rows = sheet.getRow(4);// 获取行
         cell = rows.getCell(1);//列
         String machineVersionNo = "";
-        if(cell != null){
+        if (cell != null) {
             machineVersionNo = cell.getStringCellValue();
         }
 
@@ -258,7 +259,7 @@ public class ExcelUtil {
         rows = sheet.getRow(5);// 获取行
         cell = rows.getCell(1);//列
         String bomRemarks = "";
-        if(cell != null){
+        if (cell != null) {
             bomRemarks = cell.getStringCellValue();
         }
 
@@ -267,24 +268,24 @@ public class ExcelUtil {
         int i = 0;
         while (rowss.hasNext()) {
             Row ro = rowss.next();
-            if(i>7){
+            if (i > 7) {
                 Iterator<Cell> cells = ro.cellIterator();
-                if(ro == null){
+                if (ro == null) {
                     break;
                 }
 
-                int j=0;
+                int j = 0;
                 PtsBomComponents bomComponents = new PtsBomComponents();
                 String componentsNo = "";
                 String bomComponentsQuantity = "";
                 while (cells.hasNext()) {
                     Cell ce = cells.next();
-                    if (ce == null){
+                    if (ce == null) {
                         break;
                     }
-                    if(j == 0){
+                    if (j == 0) {
                         componentsNo = ce.getStringCellValue();
-                    }else if(j == 1){
+                    } else if (j == 1) {
                         bomComponentsQuantity = ce.getStringCellValue();
                     }
                     j++;
@@ -296,20 +297,17 @@ public class ExcelUtil {
             i++;
         }
 
-        Map<String,Object> map = new HashMap<String, Object>();
-        map.put("bomName",bomName);
-        map.put("produceName",produceName);
-        map.put("bomVersion",bomVersion);
-        map.put("machineVersionNo",machineVersionNo);
-        map.put("bomRemarks",bomRemarks);
-        map.put("componentsList",componentsList);
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("bomName", bomName);
+        map.put("produceName", produceName);
+        map.put("bomVersion", bomVersion);
+        map.put("machineVersionNo", machineVersionNo);
+        map.put("bomRemarks", bomRemarks);
+        map.put("componentsList", componentsList);
         return map;
     }
 
 
-
-
-
     /**
      * 读取Excel内容
      * 不去除重复
@@ -373,8 +371,8 @@ public class ExcelUtil {
 
 
     public List<EfastOrder> readCell(String filePath, String productName, String[] maps,
-                                            String[] infos, String tel, String name,String platformOrder, String num, String discount,String remark,
-                                            Map<String, ProductColor> price, String postType, String orderStoreInfoSt, Integer isOtherStore,String[] storeArray,Integer selfOperated)
+                                     String[] infos, String tel, String name, String platformOrder, String num, String discount, String remark,
+                                     Map<String, ProductColor> price, String postType, String orderStoreInfoSt, Integer isOtherStore, String[] storeArray, Integer selfOperated)
             throws IOException {
         Map<String, String> map = new HashMap<>();
         for (String t : maps) {
@@ -471,7 +469,7 @@ public class ExcelUtil {
         while (rows.hasNext()) {
             Row temp = rows.next();
             try {
-                if(errorNum > 5){
+                if (errorNum > 5) {
                     break;
                 }
                 EfastOrder order = new EfastOrder();
@@ -485,41 +483,41 @@ public class ExcelUtil {
                 String userTel = String.valueOf(getExcelCell(telCell));
                 // 读取对应的产品id
                 String OrderProductBarCodeValue = map.get(getValue(temp.getCell(productColumnIndex)).trim());
-                if(StringUtils.isEmpty(nameValue)){
-                    errorNum ++;
+                if (StringUtils.isEmpty(nameValue)) {
+                    errorNum++;
                     order.setReturnStatus("error");
-                    order.setReturnMsg("姓名为空-交易号:"+platformOrderIdValue);
+                    order.setReturnMsg("姓名为空-交易号:" + platformOrderIdValue);
                     order.setPlatformOrderId("1");
                 }
-                if(StringUtils.isEmpty(userTel) ){
-                    errorNum ++;
+                if (StringUtils.isEmpty(userTel)) {
+                    errorNum++;
                     order.setReturnStatus("error");
-                    order.setReturnMsg("手机号码为空-交易号:"+platformOrderIdValue);
+                    order.setReturnMsg("手机号码为空-交易号:" + platformOrderIdValue);
                     order.setPlatformOrderId("1");
                 }
-                if(StringUtils.isEmpty(OrderProductBarCodeValue)){
-                    errorNum ++;
+                if (StringUtils.isEmpty(OrderProductBarCodeValue)) {
+                    errorNum++;
                     order.setReturnStatus("error");
-                    order.setReturnMsg("交易号出错-交易号:"+platformOrderIdValue);
+                    order.setReturnMsg("交易号出错-交易号:" + platformOrderIdValue);
                     order.setPlatformOrderId("1");
                 }
 
                 order.setOrderAddressName(nameValue);
-                if(!StringUtils.isEmpty(platformOrderIdValue)){
+                if (!StringUtils.isEmpty(platformOrderIdValue)) {
 
 //                    if (!ValidateUtil.checkString(platformOrderIdValue.trim())) {
 //                        order.setReturnStatus("error");
 //                        order.setReturnMsg("交易号出错-交易号:"+platformOrderIdValue);
 //                        order.setPlatformOrderId("1");
 //                    }else{
-                        Integer flag = salesOrderService.getOrderBySalesDealCodeNum(platformOrderIdValue.trim());
-                        if(flag > 0){
-                            order.setReturnStatus("error");
-                            order.setReturnMsg("交易号重复");
-                        }
-                        order.setPlatformOrderId(platformOrderIdValue.trim());
+                    Integer flag = salesOrderService.getOrderBySalesDealCodeNum(platformOrderIdValue.trim());
+                    if (flag > 0) {
+                        order.setReturnStatus("error");
+                        order.setReturnMsg("交易号重复");
+                    }
+                    order.setPlatformOrderId(platformOrderIdValue.trim());
 //                    }
-                }else{
+                } else {
                     order.setReturnStatus("error");
                     order.setReturnMsg("订单交易号不正确");
                     order.setPlatformOrderId("1");
@@ -537,15 +535,15 @@ public class ExcelUtil {
                 order.setOrderProductBarCode(OrderProductBarCodeValue);
                 String orderNum = getValue(temp.getCell(numColumnIndex)).trim();
                 String orderRemark = getValue(temp.getCell(remarkColumnIndex));
-                if(orderNum != null && !"".equals(orderNum)){
-                    orderNum = orderNum.replaceAll("\\r|\\r|\\n","");
+                if (orderNum != null && !"".equals(orderNum)) {
+                    orderNum = orderNum.replaceAll("\\r|\\r|\\n", "");
                 }
-                if(orderNum == null || "".equals(orderNum) || Integer.valueOf(orderNum) == 0){
+                if (orderNum == null || "".equals(orderNum) || Integer.valueOf(orderNum) == 0) {
                     order.setReturnStatus("error");
                     order.setReturnMsg("数量不正确");
                     // 读取购买数量
                     order.setOrderNum(0);
-                }else{
+                } else {
                     // 读取购买数量
                     order.setOrderNum(Integer.valueOf(orderNum));
                     orderNumByInt = Integer.valueOf(orderNum);
@@ -553,35 +551,35 @@ public class ExcelUtil {
                 order.setOrderRemark(orderRemark);
 
                 String colorDiscount = "0";
-                if(selfOperated == 1){
+                if (selfOperated == 1) {
                     colorDiscount = getValue(temp.getCell(discountColumnIndex)).trim();
-                    if(colorDiscount != null && !"".equals(colorDiscount)){
-                        colorDiscount = colorDiscount.replaceAll("\\r|\\r|\\n","");
+                    if (colorDiscount != null && !"".equals(colorDiscount)) {
+                        colorDiscount = colorDiscount.replaceAll("\\r|\\r|\\n", "");
                     }
-                    if(colorDiscount == null || "".equals(colorDiscount)){
+                    if (colorDiscount == null || "".equals(colorDiscount)) {
                         order.setReturnStatus("error");
                         order.setReturnMsg("价格不正确");
                         // 读取购买数量
                         order.setOrderProductDiscount(0);
                         order.setOrderProductPrice(0);
-                    }else{
+                    } else {
                         // 读取购买数量
                         Double colorDiscountDou = Double.valueOf(colorDiscount);
-                        colorDiscountDou = colorDiscountDou*100/orderNumByInt;
+                        colorDiscountDou = colorDiscountDou * 100 / orderNumByInt;
                         order.setOrderProductDiscount(colorDiscountDou.intValue());
                         order.setOrderProductPrice(colorDiscountDou.intValue());
                         Double orderTotal = Double.valueOf(colorDiscount);
-                        orderTotal = orderTotal*100;
+                        orderTotal = orderTotal * 100;
                         order.setOrderTotal(orderTotal.intValue());
                     }
-                }else{
+                } else {
                     order.setOrderProductDiscount(0);
                     order.setOrderProductPrice(0);
                     order.setOrderTotal(0);
                 }
 
-                try{
-                    if (infoColumnIndex.length == 1){
+                try {
+                    if (infoColumnIndex.length == 1) {
                         // 如果infoColumnIndex = 1, 则表示需要截取(可能是-、“ ”)
                         Cell cell = temp.getCell(infoColumnIndex[0]);
                         String addrInfo = getValue(cell);
@@ -618,7 +616,7 @@ public class ExcelUtil {
                         }
                         continue;
                     }
-                }catch (Exception e){
+                } catch (Exception e) {
                     order.setReturnStatus("error");
                     order.setReturnMsg("地址错误");
                     order.setPlatformOrderId("1");
@@ -632,22 +630,22 @@ public class ExcelUtil {
                 order.setOrderProductName(price.get(order.getOrderProductBarCode()).getColorName());
                 order.setOrderId(OrderNoUtil.createOrderCode(Math.abs(new Random().nextInt(1000))));
 
-                if(isOtherStore == 2){
+                if (isOtherStore == 2) {
                     // 读取店铺
                     String storeValue = getValue(temp.getCell(orderStoreInfoStColumnIndex)).trim();
-                    for (int k=0;k<storeArray.length;k++){
-                       String[] stores = storeArray[k].split("_");
-                       if(stores[0].trim().equals(storeValue.trim())){
-                           //店铺
-                           order.setStoreId(Integer.valueOf(stores[1]));
-                       }
+                    for (int k = 0; k < storeArray.length; k++) {
+                        String[] stores = storeArray[k].split("_");
+                        if (stores[0].trim().equals(storeValue.trim())) {
+                            //店铺
+                            order.setStoreId(Integer.valueOf(stores[1]));
+                        }
                     }
-                }else{
+                } else {
                     //店铺
                     order.setStoreId(Integer.valueOf(storeArray[0]));
                 }
                 order.setOid(oid);
-                try{
+                try {
                     if (postType.equals("ems")) {
                         if (order.getOrderProvince().contains("广东")) {
                             order.setOrderPostType("ems");
@@ -657,7 +655,7 @@ public class ExcelUtil {
                     } else {
                         order.setOrderPostType(postType);
                     }
-                }catch (Exception e){
+                } catch (Exception e) {
                     order.setOrderPostType("ems");
                     e.printStackTrace();
                     logger.info("匹配快递公司失败");
@@ -666,7 +664,7 @@ public class ExcelUtil {
                 orderEfasts.add(order);
             } catch (Exception e) {
                 row.getCell(0).setCellStyle(cellStyle);
-                errorNum ++;
+                errorNum++;
                 logger.error(e.getMessage(), e);
             }
             // 迭代
@@ -714,8 +712,8 @@ public class ExcelUtil {
         Iterator<Cell> cells = row.cellIterator();
         while (cells.hasNext()) {
             Cell cell = cells.next();
-                cellNum = cell.getColumnIndex();
-                break;
+            cellNum = cell.getColumnIndex();
+            break;
         }
         if (cellNum == -1) return null;
 
@@ -741,11 +739,12 @@ public class ExcelUtil {
     }
 
     /**
-     *获取值
+     * 获取值
+     *
      * @param cell
      * @return
      */
-    private static Object getExcelCell(Cell cell){
+    private static Object getExcelCell(Cell cell) {
         Object obj;
         if (null != cell) {
             switch (cell.getCellType()) {
@@ -854,7 +853,7 @@ public class ExcelUtil {
                 return new String[]{addrs[0].trim(), addrs[1].trim(), addrs[2].trim(), address};
             }
         } else if (addrs != null && addrs.length > 4) {
-            String start = addrs[0].trim() + splitCharTemp + addrs[1].trim() + splitCharTemp +  addrs[2].trim() + splitCharTemp;
+            String start = addrs[0].trim() + splitCharTemp + addrs[1].trim() + splitCharTemp + addrs[2].trim() + splitCharTemp;
             String addressInfo = addrInfo.substring(start.length(), addrInfo.length());
             return new String[]{addrs[0].trim(), addrs[1].trim(), addrs[2].trim(), addressInfo};
         }
@@ -943,6 +942,7 @@ public class ExcelUtil {
 
     /**
      * excel 强制获取text文本
+     *
      * @param cell
      * @return
      */
@@ -951,4 +951,81 @@ public class ExcelUtil {
         return cell.getStringCellValue();
     }
 
+        //获取俩个日期内所有月份
+        public static List<String> month(Date startDate, Date endDate) {
+            List<String> list = new ArrayList<String>();
+            try {
+            /*Date startDate = new SimpleDateFormat("yyyy-MM").parse(y1);
+            Date endDate = new SimpleDateFormat("yyyy-MM").parse(y2);*/
+
+                Calendar calendar = Calendar.getInstance();
+                if (startDate == null) {
+                    startDate = new SimpleDateFormat("yyyy-MM").parse("2018-02");
+                }
+                calendar.setTime(startDate);
+                // 获取开始年份和开始月份
+                int startYear = calendar.get(Calendar.YEAR);
+                int startMonth = calendar.get(Calendar.MONTH);
+                // 获取结束年份和结束月份
+                if (endDate == null) {
+                    calendar.setTime(new Date());
+                } else {
+                    calendar.setTime(endDate);
+                }
+                int endYear = calendar.get(Calendar.YEAR);
+                int endMonth = calendar.get(Calendar.MONTH);
+                //
+
+                for (int i = startYear; i <= endYear; i++) {
+                    String date = "";
+                    if (startYear == endYear) {
+                        for (int j = startMonth; j <= endMonth; j++) {
+                            if (j < 9) {
+                                date = i + "-0" + (j + 1);
+                            } else {
+                                date = i + "-" + (j + 1);
+                            }
+                            list.add(date);
+                        }
+
+                    } else {
+                        if (i == startYear) {
+                            for (int j = startMonth; j < 12; j++) {
+                                if (j < 9) {
+                                    date = i + "-0" + (j + 1);
+                                } else {
+                                    date = i + "-" + (j + 1);
+                                }
+                                list.add(date);
+                            }
+                        } else if (i == endYear) {
+                            for (int j = 0; j <= endMonth; j++) {
+                                if (j < 9) {
+                                    date = i + "-0" + (j + 1);
+                                } else {
+                                    date = i + "-" + (j + 1);
+                                }
+                                list.add(date);
+                            }
+                        } else {
+                            for (int j = 0; j < 12; j++) {
+                                if (j < 9) {
+                                    date = i + "-0" + (j + 1);
+                                } else {
+                                    date = i + "-" + (j + 1);
+                                }
+                                list.add(date);
+                            }
+                        }
+
+                    }
+
+                }
+
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            return list;
+        }
 }

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

@@ -218,6 +218,9 @@
 		<typeAlias type="com.iamberry.rst.core.dm.SupplierProduct" alias="SupplierProduct"/>
 		<typeAlias type="com.iamberry.rst.core.dm.SupplierProductItem" alias="SupplierProductItem"/>
 		<typeAlias type="com.iamberry.rst.core.dm.DmChannelType" alias="DmChannelType"/>
+
+		<!--客诉统计新增-->
+		<typeAlias type="com.iamberry.rst.core.cm.CustomerStatistics" alias="CustomerStatistics"/>
 	</typeAliases>
 	<!-- PageHelper -->
 	<plugins>

+ 27 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/cm/customer/download_customer.ftl

@@ -82,6 +82,9 @@
                 <div class="col-2 col-sm-2">
                     <button type="button" class="btn" style="background: #50a2ea;border: 1px solid #50a2ea;color: #fff;height: 35px;margin-top: -8px;margin-bottom: 3px;" onclick="download();">开始下载</button>
                 </div>
+                <div class="col-2 col-sm-2">
+                    <button type="button" class="btn" style="background: #50a2ea;border: 1px solid #50a2ea;color: #fff;height: 35px;margin-top: -8px;margin-bottom: 3px;" onclick="download2();">下载统计</button>
+                </div>
             </div>
 
             <div class="row cl">
@@ -162,6 +165,30 @@
             }
         })
     }
+
+    function download2(){
+        $.ajax({
+            cache: true,
+            type: "POST",
+            data: {"procTypeId" : $("#procTypeId").val(),
+                "companyId" : $("#companyId").val(),
+                "storeId" : $("#storeId").val(),
+                "startTime" : $("#startTime").val(),
+                "endTime" : $("#endTime").val()
+            },
+            url: "${path}/admin/customer/download_customer_statistics",
+            async: false,
+            success: function(data){
+                if (data.returnCode == 200) {
+                    layer.msg("正在下载,可进入下载列表查看进度!",{icon: 1,time:2000});
+                    location.replace(location.href);
+                }
+            },
+            error: function(XmlHttpRequest, textStatus, errorThrown){
+                layer.msg("下载失败,请刷新重试!",{icon: 5,time:1000});
+            }
+        })
+    }
     ref = setInterval(function(){
         refresh();
     },2000);

+ 2 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/cm/inspection/detect_repair_list.ftl

@@ -129,6 +129,7 @@
                 <th width="100">机器信息</th>
                 <th width="100">维修状态</th>
                 <th width="100">检测日期</th>
+                <th width="100">客服备注</th>
                 <th width="120">操作</th>
             </tr>
             </thead>
@@ -192,6 +193,7 @@
                         </#if>
                     </td>
                     <td class="text-c" width="100">${(detect.detectDate?string("yyyy-MM-dd"))!'-'}</td>
+                    <td class="text-c" width="100">${detect.signclosedCustomerDesc!''}</td>
                     <!-- 遍历操作 -->
                     <td class="td-manage text-c" width="120">
                             <#if detect.detectState == 30 || detect.detectState == 34|| detect.detectState == 38>