浏览代码

表下载

zhijiezhao 2 年之前
父节点
当前提交
e1a264db20

+ 99 - 82
src/main/java/com/caimei/modules/product/web/KeywordFrequencyController.java

@@ -45,130 +45,142 @@ import java.util.List;
 @RequestMapping(value = "${adminPath}/product/keywordFrequency")
 public class KeywordFrequencyController extends BaseController {
 
-        @Autowired
-        private KeywordFrequencyService keywordFrequencyService;
+    @Autowired
+    private KeywordFrequencyService keywordFrequencyService;
 
     /**
      * 查询未加入关键词库的数据
+     *
      * @param searchFrequency
      * @param request
      * @param response
      * @param model
      * @return
      */
-        @RequestMapping(value="/getKeyInfo")
-        public String getKeyInfo(SearchFrequency searchFrequency, HttpServletRequest request, HttpServletResponse response,  Model model){//@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
-            searchFrequency.setTrueStatus(0);
-            Page<SearchFrequency> keyInfo = keywordFrequencyService.findPage(new Page<SearchFrequency>(request,response),searchFrequency);
-            List<SearchFrequency> seacherFrom = keywordFrequencyService.getSearchFrom(1);
-            model.addAttribute("keyInfo",keyInfo);
-            model.addAttribute("searchFrequency",searchFrequency);
-            model.addAttribute("seacherFrom",seacherFrom);
-            return "modules/product/keywordFrequency";
-        }
+    @RequestMapping(value = "/getKeyInfo")
+    public String getKeyInfo(SearchFrequency searchFrequency, HttpServletRequest request, HttpServletResponse response, Model model) {//@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
+        searchFrequency.setTrueStatus(0);
+        Page<SearchFrequency> keyInfo = keywordFrequencyService.findPage(new Page<SearchFrequency>(request, response), searchFrequency);
+        List<SearchFrequency> seacherFrom = keywordFrequencyService.getSearchFrom(1);
+        model.addAttribute("keyInfo", keyInfo);
+        model.addAttribute("searchFrequency", searchFrequency);
+        model.addAttribute("seacherFrom", seacherFrom);
+        return "modules/product/keywordFrequency";
+    }
+
     /**
      * 查询已加入关键词库的数据
+     *
      * @param searchFrequency
      * @param request
      * @param response
      * @param model
      * @return
      */
-    @RequestMapping(value="/getKeywordThesaurusInfo")
-    public String getKeywordThesaurusInfo(SearchFrequency searchFrequency, HttpServletRequest request, HttpServletResponse response,  Model model){//@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
+    @RequestMapping(value = "/getKeywordThesaurusInfo")
+    public String getKeywordThesaurusInfo(SearchFrequency searchFrequency, HttpServletRequest request, HttpServletResponse response, Model model) {//@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
         searchFrequency.setTrueStatus(1);
-        Page<SearchFrequency> keyInfo = keywordFrequencyService.findPage(new Page<SearchFrequency>(request,response),searchFrequency);
+        Page<SearchFrequency> keyInfo = keywordFrequencyService.findPage(new Page<SearchFrequency>(request, response), searchFrequency);
         List<SearchFrequency> list = keyInfo.getList();
-        for (SearchFrequency search:list) {
-            if(null != search.getSearchTime()){
+        for (SearchFrequency search : list) {
+            if (null != search.getSearchTime()) {
                 SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                Date da=new Date(search.getSearchTime().getTime());
+                Date da = new Date(search.getSearchTime().getTime());
                 String date = fmt.format(da);
                 search.setSerachDate(date);
             }
         }
         keyInfo.setList(list);
         List<SearchFrequency> seacherFrom = keywordFrequencyService.getSearchFrom(2);
-        model.addAttribute("keyInfo",keyInfo);
-        model.addAttribute("searchFrequency",searchFrequency);
-        model.addAttribute("seacherFrom",seacherFrom);
+        model.addAttribute("keyInfo", keyInfo);
+        model.addAttribute("searchFrequency", searchFrequency);
+        model.addAttribute("seacherFrom", seacherFrom);
         return "modules/product/keywordThesaurus";
     }
 
-        /**
-         * 查询未加入关键词库的关键词来源
-         * @return
-         */
-        @ResponseBody
-        @RequestMapping("/getSeacherFrom")
-        public List<String> getSearchFrom(Integer trueStatus){
+    /**
+     * 查询未加入关键词库的关键词来源
+     *
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping("/getSeacherFrom")
+    public List<String> getSearchFrom(Integer trueStatus) {
 //            List<String> seacherFrom = keywordFrequencyService.getSearchFrom(trueStatus);
-            return null;
-        }
+        return null;
+    }
 
     /**
      * 加入关键词库
+     *
      * @param ids
      * @return
      */
     @RequestMapping("/addKeyWordList")
     @ResponseBody
-    public String addKeyWordList(String ids,Model model){
+    public String addKeyWordList(String ids, Model model) {
         keywordFrequencyService.addKeyWordList(ids);
         return "success";
     }
+
     /**
      * 验证关键词库是该否存在关键词
+     *
      * @param keyword
      * @return
      */
     @RequestMapping("/verificationKeword")
     @ResponseBody
-    public String verificationKeword(String keyword,Model model){
+    public String verificationKeword(String keyword, Model model) {
         boolean b = keywordFrequencyService.verificationKeword(keyword);
-        if(b){
+        if (b) {
             return "-1";
-        }else{
+        } else {
             return "0";
         }
 
     }
+
     /**
      * 验证关键词库是该否存在关键词
+     *
      * @param keywords
      * @return
      */
     @RequestMapping("/verificationKewords")
     @ResponseBody
-    public String verificationKewords(String keywords,Model model){
+    public String verificationKewords(String keywords, Model model) {
         boolean b = keywordFrequencyService.verificationKewords(keywords);
-        if(b){
+        if (b) {
             return "-1";
-        }else{
+        } else {
             return "0";
         }
 
     }
+
     /**
      * 删除关键词
      * status 区分是关键词界面还是关键词库界面 (1关键词;2关键词库)
+     *
      * @param id
      * @return
      */
     @RequestMapping("/delKeyWordById")
-    public String delKeyWordById(Integer id,Integer status,RedirectAttributes redirectAttributes){
-        keywordFrequencyService.delKeyWordById(id,status);
+    public String delKeyWordById(Integer id, Integer status, RedirectAttributes redirectAttributes) {
+        keywordFrequencyService.delKeyWordById(id, status);
         addMessage(redirectAttributes, "删除关键词成功");
-        if(status==1){
-            return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeyInfo";
+        if (status == 1) {
+            return "redirect:" + Global.getAdminPath() + "/product/keywordFrequency/getKeyInfo";
 
         }
-        return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
+        return "redirect:" + Global.getAdminPath() + "/product/keywordFrequency/getKeywordThesaurusInfo";
 
     }
 
     /**
      * 跳转编辑添加页面
+     *
      * @param searchFrequency
      * @param model
      * @return
@@ -181,51 +193,53 @@ public class KeywordFrequencyController extends BaseController {
 
     /**
      * 更新关键词
+     *
      * @param searchFrequency
      * @param redirectAttributes
      * @param model
      * @return
      */
     @RequestMapping("save")
-    public String save(SearchFrequency searchFrequency,RedirectAttributes redirectAttributes,Model model){
-        if (!beanValidator(model, searchFrequency)){
+    public String save(SearchFrequency searchFrequency, RedirectAttributes redirectAttributes, Model model) {
+        if (!beanValidator(model, searchFrequency)) {
             return form(searchFrequency, model);
         }
         //如果是新增操作时
         searchFrequency.setTrueStatus(1);
         searchFrequency.setFromSearch(6);//为管理员添加
         searchFrequency.setPath("管理员添加");
-        Date date=new Date();
-        SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = new Date();
+        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         sd.format(date);
 //        searchFrequency.setSearchTime(new java.sql.Timestamp(date.getTime()));
         Calendar cal = Calendar.getInstance();
         cal.setTime(date);
         searchFrequency.setSearchTime(new java.sql.Timestamp(cal.getTime().getTime()));
 
-        if(null !=searchFrequency.getKeyId()){
+        if (null != searchFrequency.getKeyId()) {
             searchFrequency.setId(searchFrequency.getKeyId().toString());
         }
         keywordFrequencyService.save(searchFrequency);
-        if(searchFrequency.getStatus()==2){
+        if (searchFrequency.getStatus() == 2) {
             //保存后重置关键词redis缓存
             keywordFrequencyService.cacheKeyWord();
-            List<SearchFrequency> list=new ArrayList<>();
+            List<SearchFrequency> list = new ArrayList<>();
             list.add(searchFrequency);
             keywordFrequencyService.conKeyWord(list);
         }
         addMessage(redirectAttributes, "保存成功");
         //编辑
-        if(null !=searchFrequency.getStatus()&&1==searchFrequency.getStatus()){
-            return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeyInfo";
+        if (null != searchFrequency.getStatus() && 1 == searchFrequency.getStatus()) {
+            return "redirect:" + Global.getAdminPath() + "/product/keywordFrequency/getKeyInfo";
         }
         //新增
-        return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
+        return "redirect:" + Global.getAdminPath() + "/product/keywordFrequency/getKeywordThesaurusInfo";
 
     }
 
     /**
      * 导出关键词
+     *
      * @param ids
      * @param redirectAttributes
      * @param request
@@ -249,8 +263,10 @@ public class KeywordFrequencyController extends BaseController {
             e.printStackTrace();
         }
     }
+
     /**
      * 导出关键词库关键词
+     *
      * @param ids
      * @param redirectAttributes
      * @param request
@@ -277,22 +293,23 @@ public class KeywordFrequencyController extends BaseController {
 
     /**
      * 导入关键词
+     *
      * @param file
      * @param redirectAttributes
      * @return
      */
     @RequestMapping(value = "importKeyword")
-    public String importKeyword(@RequestParam("file") MultipartFile file, RedirectAttributes redirectAttributes){
+    public String importKeyword(@RequestParam("file") MultipartFile file, RedirectAttributes redirectAttributes) {
         String contentType = file.getContentType();
         String fileName = file.getOriginalFilename();
         if (file.isEmpty()) {
-            addMessage(redirectAttributes,"请选择需要导入的关键词文件");
-            return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
+            addMessage(redirectAttributes, "请选择需要导入的关键词文件");
+            return "redirect:" + Global.getAdminPath() + "/product/keywordFrequency/getKeywordThesaurusInfo";
         }
-        int sum=0;//总数量
-        int falseNum=0;//已存在数量
-        int successNum=0;
-        String falseKeys="";//已存在关键词
+        int sum = 0;//总数量
+        int falseNum = 0;//已存在数量
+        int successNum = 0;
+        String falseKeys = "";//已存在关键词
         try {
             //根据路径获取这个操作excel的实例
             HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
@@ -300,33 +317,33 @@ public class KeywordFrequencyController extends BaseController {
             HSSFSheet sheet = wb.getSheetAt(0);
             HSSFRow row = null;
             //循环sesheet页中数据从第二行开始,第一行是标题
-            List<SearchFrequency> searchFrequencyList=new ArrayList<>();
-             sum=sheet.getPhysicalNumberOfRows()-1;
-            for(int i=1;i<=sheet.getPhysicalNumberOfRows()-1;i++){
+            List<SearchFrequency> searchFrequencyList = new ArrayList<>();
+            sum = sheet.getPhysicalNumberOfRows() - 1;
+            for (int i = 1; i <= sheet.getPhysicalNumberOfRows() - 1; i++) {
                 row = sheet.getRow(i);
-                SearchFrequency searchFrequency=new SearchFrequency();
+                SearchFrequency searchFrequency = new SearchFrequency();
                 //关键词
-                if(null !=row.getCell(1)){
-                searchFrequency.setKeyword(row.getCell(1).toString());
+                if (null != row.getCell(1)) {
+                    searchFrequency.setKeyword(row.getCell(1).toString());
                     boolean b = keywordFrequencyService.verificationKeword(row.getCell(1).toString());
-                    if(b){//判断关键词是否已存在
-                        falseNum+=1;
-                        if(StringUtils.isNotEmpty(falseKeys)){
-                            falseKeys=falseKeys+","+row.getCell(1).toString();
-                        }else{
-                            falseKeys+=row.getCell(1).toString();
+                    if (b) {//判断关键词是否已存在
+                        falseNum += 1;
+                        if (StringUtils.isNotEmpty(falseKeys)) {
+                            falseKeys = falseKeys + "," + row.getCell(1).toString();
+                        } else {
+                            falseKeys += row.getCell(1).toString();
                         }
                         continue;
                     }
-                }else{
+                } else {
                     continue;
                 }
                 //联动次数
-                if(null !=row.getCell(2)){
-                   String linkageFrequency= row.getCell(2).toString();
-                   if(linkageFrequency.indexOf(".")>0){
-                       linkageFrequency=linkageFrequency.replace(".","");
-                   }
+                if (null != row.getCell(2)) {
+                    String linkageFrequency = row.getCell(2).toString();
+                    if (linkageFrequency.indexOf(".") > 0) {
+                        linkageFrequency = linkageFrequency.replace(".", "");
+                    }
                     searchFrequency.setLinkageFrequency(Integer.valueOf(linkageFrequency));
                 }
 //                if(null != row.getCell(2)){
@@ -339,23 +356,23 @@ public class KeywordFrequencyController extends BaseController {
 //                    }
 //                }
                 //添加时间
-                if(null != row.getCell(3)){
+                if (null != row.getCell(3)) {
                     searchFrequency.setSearchTime(new java.sql.Timestamp(row.getCell(3).getDateCellValue().getTime()));
                 }
                 searchFrequency.setPath("管理员添加");
                 searchFrequency.setTrueStatus(1);
                 searchFrequencyList.add(searchFrequency);
             }
-             successNum=sum-falseNum;
+            successNum = sum - falseNum;
             //保存文件数据
             keywordFrequencyService.importKeyword(searchFrequencyList);
             //保存后重置关键词redis缓存
             keywordFrequencyService.cacheKeyWord();
             keywordFrequencyService.conKeyWord(searchFrequencyList);
-        } catch (IOException  e) {//| ParseException
+        } catch (IOException e) {//| ParseException
             e.printStackTrace();
         }
-        addMessage(redirectAttributes,"导入关键词成功:总数: "+sum+" 条  其中成功 " +successNum+"  条"+";   关键词库已存在: "+falseNum+" 条( "+falseKeys+" )");
-        return "redirect:"+Global.getAdminPath()+"/product/keywordFrequency/getKeywordThesaurusInfo";
+        addMessage(redirectAttributes, "导入关键词成功:总数: " + sum + " 条  其中成功 " + successNum + "  条" + ";   关键词库已存在: " + falseNum + " 条( " + falseKeys + " )");
+        return "redirect:" + Global.getAdminPath() + "/product/keywordFrequency/getKeywordThesaurusInfo";
     }
 }

+ 2 - 0
src/main/java/com/caimei/modules/user/dao/NewCmClubDao.java

@@ -87,4 +87,6 @@ public interface NewCmClubDao extends CrudDao<NewCmClub> {
     List<CmBehaviorRecord> selRegisterIP(Integer clubId);
 
     List<ClubStatistics> selStatisticsList(ClubStatistics statistics);
+
+    List<easyExcel> findExcelList(ClubStatistics statistics);
 }

+ 183 - 0
src/main/java/com/caimei/modules/user/entity/easyExcel.java

@@ -0,0 +1,183 @@
+package com.caimei.modules.user.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.thinkgem.jeesite.common.utils.excel.annotation.ExcelField;
+
+/**
+ * @author zzj
+ */
+public class easyExcel {
+    //机构ID
+
+    @ExcelProperty(value = "机构Id",index = 0)
+    private String clubId;
+    @ExcelProperty(value = "机构名称",index = 1)
+    private String name; //机构名称
+    @ExcelProperty(value = "联系人",index = 2)
+    private String linkMan; //联系人
+    @ExcelProperty(value = "联系人身份",index = 3)
+    private String linkManIdentity; //联系人身份:1老板,2采购,3运营,4其他
+    @ExcelProperty(value = "手机号",index = 4)
+    private String contractMobile; //手机号
+    @ExcelProperty(value = "协销人员",index = 5)
+    private String spName; //协销人员
+    @ExcelProperty(value = "状态",index = 6)
+    private String clubStatus; //状态
+    @ExcelProperty(value = "机构类型",index = 7)
+    private String clubType; //机构类型
+    @ExcelProperty(value = "机构级别",index = 8)
+    private String clubRank; //机构级别
+    @ExcelProperty(value = "资料完整度",index = 9)
+    private String clubDataIntegrity; //资料完整度
+    @ExcelProperty(value = "注册时间",index = 10)
+    private String addTime; //注册时间
+    @ExcelProperty(value = "近一个月订单数",index = 11)
+    private String orderCountMonth; //近一个月订单数
+    @ExcelProperty(value = "近一年订单数",index = 12)
+    private String orderCountYear; //近一年订单数
+    @ExcelProperty(value = "近一年购买额",index = 13)
+    private String payTotalMonth; //近一年购买额
+    @ExcelProperty(value = "总购买额",index = 14)
+    private String payTotal; //总购买额
+    @ExcelProperty(value = "最常搜索词",index = 15)
+    private String pageLabel; //最常搜索词
+    @ExcelProperty(value = "最近下单时间",index = 16)
+    private String lastOrderTime; //最近下单时间
+
+
+    public String getClubId() {
+        return clubId;
+    }
+
+    public void setClubId(String clubId) {
+        this.clubId = clubId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getLinkMan() {
+        return linkMan;
+    }
+
+    public void setLinkMan(String linkMan) {
+        this.linkMan = linkMan;
+    }
+
+    public String getLinkManIdentity() {
+        return linkManIdentity;
+    }
+
+    public void setLinkManIdentity(String linkManIdentity) {
+        this.linkManIdentity = linkManIdentity;
+    }
+
+    public String getContractMobile() {
+        return contractMobile;
+    }
+
+    public void setContractMobile(String contractMobile) {
+        this.contractMobile = contractMobile;
+    }
+
+    public String getSpName() {
+        return spName;
+    }
+
+    public void setSpName(String spName) {
+        this.spName = spName;
+    }
+
+    public String getClubStatus() {
+        return clubStatus;
+    }
+
+    public void setClubStatus(String clubStatus) {
+        this.clubStatus = clubStatus;
+    }
+
+    public String getClubType() {
+        return clubType;
+    }
+
+    public void setClubType(String clubType) {
+        this.clubType = clubType;
+    }
+
+    public String getClubRank() {
+        return clubRank;
+    }
+
+    public void setClubRank(String clubRank) {
+        this.clubRank = clubRank;
+    }
+
+    public String getClubDataIntegrity() {
+        return clubDataIntegrity;
+    }
+
+    public void setClubDataIntegrity(String clubDataIntegrity) {
+        this.clubDataIntegrity = clubDataIntegrity;
+    }
+
+    public String getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(String addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getOrderCountMonth() {
+        return orderCountMonth;
+    }
+
+    public void setOrderCountMonth(String orderCountMonth) {
+        this.orderCountMonth = orderCountMonth;
+    }
+
+    public String getOrderCountYear() {
+        return orderCountYear;
+    }
+
+    public void setOrderCountYear(String orderCountYear) {
+        this.orderCountYear = orderCountYear;
+    }
+
+    public String getPayTotalMonth() {
+        return payTotalMonth;
+    }
+
+    public void setPayTotalMonth(String payTotalMonth) {
+        this.payTotalMonth = payTotalMonth;
+    }
+
+    public String getPayTotal() {
+        return payTotal;
+    }
+
+    public void setPayTotal(String payTotal) {
+        this.payTotal = payTotal;
+    }
+
+    public String getPageLabel() {
+        return pageLabel;
+    }
+
+    public void setPageLabel(String pageLabel) {
+        this.pageLabel = pageLabel;
+    }
+
+    public String getLastOrderTime() {
+        return lastOrderTime;
+    }
+
+    public void setLastOrderTime(String lastOrderTime) {
+        this.lastOrderTime = lastOrderTime;
+    }
+}

+ 65 - 3
src/main/java/com/caimei/modules/user/service/NewCmClubService.java

@@ -244,12 +244,74 @@ public class NewCmClubService extends CrudService<NewCmClubDao, NewCmClub> {
         return page;
     }
 
-    public List<ClubStatistics> exportExcel(ClubStatistics statistics) {
-        List<ClubStatistics> statisticsList = newCmClubDao.selStatisticsList(statistics);
-        setListData(statisticsList);
+    public List<easyExcel> exportExcel(ClubStatistics statistics) {
+        List<easyExcel> statisticsList = newCmClubDao.findExcelList(statistics);
+        setExData(statisticsList);
         return statisticsList;
     }
 
+    public List<easyExcel> setExData(List<easyExcel> selStatisticsList) {
+        int number = 0;
+        String type = "" ;
+        for (easyExcel clubStatistics : selStatisticsList) {
+            // 机构类型
+//            if (StringUtils.isNotBlank(clubStatistics.getFirstClubType())) {
+//                type += clubStatistics.getFirstClubType();
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getClassify())) {
+//                type += "-" + clubStatistics.getClassify();
+//            }
+            clubStatistics.setClubType(type);
+            // 计算资料完整度
+            if (StringUtils.isNotBlank(clubStatistics.getName())) {
+                number += 10;
+            }
+            if (StringUtils.isNotBlank(clubStatistics.getLinkMan())) {
+                number += 10;
+            }
+            if (StringUtils.isNotBlank(clubStatistics.getContractMobile())) {
+                number += 10;
+            }
+            if (StringUtils.isNotBlank(clubStatistics.getLinkManIdentity())) {
+                number += 10;
+            }
+//            if (StringUtils.isNotBlank(clubStatistics.getAddress())) {
+//                number += 10;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getBusinessLicenseImage())) {
+//                number += 10;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getUserIdentity())) {
+//                number += 10;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getSname())) {
+//                number += 3;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getContractEmail())) {
+//                number += 5;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getContractPhone())) {
+//                number += 4;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getFax())) {
+//                number += 3;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getHeadpic())) {
+//                number += 5;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getSocialCreditCode())) {
+//                number += 5;
+//            }
+//            if (StringUtils.isNotBlank(clubStatistics.getInfo())) {
+//                number += 5;
+//            }
+            clubStatistics.setClubDataIntegrity(number+"%");
+            number=0;
+            type = "";
+        }
+        return selStatisticsList;
+    }
+
     public List<ClubStatistics> setListData(List<ClubStatistics> selStatisticsList) {
         int number = 0;
         String type = "" ;

+ 44 - 34
src/main/java/com/caimei/modules/user/web/newUser/AgencyController.java

@@ -39,6 +39,7 @@ import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.map.HashedMap;
 import org.apache.poi.openxml4j.util.ZipSecureFile;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -1431,24 +1432,32 @@ public class AgencyController extends BaseController {
         String path = "";
         try {
 
-            ServletOutputStream os = response.getOutputStream();
-            FileSystemView view = FileSystemView.getFileSystemView();
-            File homeDirectory = view.getHomeDirectory();
-            name = System.currentTimeMillis()+fileName;
-            path = homeDirectory+"\\";
-            fileName = path+name;
-
-            List<ClubStatistics> statisticsList = newCmClubService.exportExcel(statistics);
-            //得到模板文件路径(线上直接读取服务器位置文件)
-            String config = Global.getConfig("cm.config");
-            if(config.equals("dev")){
-                templataFileName = FileUtils.class.getClassLoader().getResource(templataFileName).getPath();
-            }
-            ExcelWriter excel = EasyExcel.write(fileName).withTemplate(templataFileName).build();
-            WriteSheet writeSheet = EasyExcel.writerSheet().build();
-            excel.fill(statisticsList,writeSheet);
-            excel.finish();
-            downLoadFile(fileName , response);
+//            ServletOutputStream os = response.getOutputStream();
+//            FileSystemView view = FileSystemView.getFileSystemView();
+//            File homeDirectory = view.getHomeDirectory();
+//            name = System.currentTimeMillis()+fileName;
+//            path = homeDirectory+"\\";
+//            fileName = path+name;
+//
+            List<easyExcel> statisticsList = newCmClubService.exportExcel(statistics);
+//            //得到模板文件路径(线上直接读取服务器位置文件)
+//            String config = Global.getConfig("cm.config");
+//            if(config.equals("dev")){
+//                templataFileName = FileUtils.class.getClassLoader().getResource(templataFileName).getPath();
+//            }
+//            ExcelWriter excel = EasyExcel.write(fileName).withTemplate(templataFileName).build();
+//            WriteSheet writeSheet = EasyExcel.writerSheet().build();
+//            excel.fill(statisticsList,writeSheet);
+//            excel.finish();
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            response.setCharacterEncoding("utf-8");
+            // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
+            fileName = URLEncoder.encode("测试", "UTF-8").replaceAll("\\+", "%20");
+            response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+            // 这里需要设置不关闭流
+            EasyExcel.write(response.getOutputStream(), easyExcel.class).autoCloseStream(Boolean.FALSE).sheet("模板")
+                    .doWrite(statisticsList);
+//            downLoadFile(fileName , response);
             /*File file = new File(fileName);
             file.delete();*/
 //            return "redirect:"+Global.getAdminPath()+"/new/user/agency/statisticsList?"+statistics;
@@ -1466,22 +1475,23 @@ public class AgencyController extends BaseController {
      */
     private static void downLoadFile(String path, HttpServletResponse response) {
         try {
-            File file = new File(path);
-            String filename = file.getName();
-            // 以流的形式下载文件。
-            InputStream fis = new BufferedInputStream(new FileInputStream(path));
-            byte[] buffer = new byte[fis.available()];
-            fis.read(buffer);
-            fis.close();
-            // 清空response
-            response.reset();
-            response.setContentType("application/octet-stream;charset=UTF-8");
-            String fileName = new String(filename.getBytes("gb2312"), "iso8859-1");
-            response.setHeader("Content-disposition", "attachment;filename=" + fileName);
-            OutputStream ouputStream = response.getOutputStream();
-            ouputStream.write(buffer);
-            ouputStream.flush();
-            ouputStream.close();
+//            File file = new File("C:\\Users\\Administrator\\Desktop\\全量.xls");
+//            String filename = file.getName();
+//            // 以流的形式下载文件。
+//            InputStream fis = new BufferedInputStream(new FileInputStream("C:\\Users\\Administrator\\Desktop\\全量.xls"));
+//            byte[] buffer = new byte[fis.available()];
+//            fis.read(buffer);
+//            fis.close();
+//            // 清空response
+//            response.reset();
+//            response.setContentType("application/octet-stream;charset=UTF-8");
+//            String fileName = new String(filename.getBytes("gb2312"), "iso8859-1");
+//            response.setHeader("Content-disposition", "attachment;filename=" + fileName);
+//            OutputStream ouputStream = response.getOutputStream();
+//            ouputStream.write(buffer);
+//            ouputStream.flush();
+//            ouputStream.close();
+
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 174 - 0
src/main/resources/mappings/modules/user/NewCmClubMapper.xml

@@ -893,4 +893,178 @@
         </where>
         GROUP BY c.userID ORDER BY MAX(cor.orderTime) DESC
     </select>
+    <select id="findExcelList" resultType="com.caimei.modules.user.entity.easyExcel">
+        SELECT
+        u.userId,
+        c.clubID,
+        c.name,
+        c.linkMan,
+        c.contractMobile,
+        c.linkManIdentity,
+        c.address,
+        c.businessLicenseImage,
+        u.userIdentity,
+        c.sname,
+        c.contractEmail,
+        c.contractPhone,
+        c.fax,
+        c.headpic,
+        c.socialCreditCode,
+        c.info,
+        (CASE WHEN c.linkManIdentity=1 THEN '老板'
+        WHEN c.linkManIdentity=2 THEN '采购'
+        WHEN c.linkManIdentity=3 THEN '运营'
+        WHEN c.linkManIdentity=4 THEN '其他'
+        END) AS linkManStatus,
+        (CASE WHEN c.status = 1 THEN '待审核'
+        WHEN c.status=91 THEN '已下线'
+        WHEN c.status=90 THEN '已上线'
+        WHEN c.status=92 THEN '审核未通过'
+        WHEN c.status=93 THEN '已确认'
+        ELSE '已冻结' END) AS clubStatus,
+        (CASE WHEN u.userIdentity=2 THEN '资质机构'
+        ELSE '个人机构' END) AS clubRank,
+        (CASE WHEN c.firstClubType=1 THEN '医美'
+        WHEN c.firstClubType=2 THEN '生美'
+        WHEN c.firstClubType=3 THEN '项目公司'
+        WHEN c.firstClubType=4 THEN '个人'
+        ELSE '其他' END) AS firstClubType,
+        (CASE WHEN c.secondClubType=1 THEN '诊所'
+        WHEN c.secondClubType=2 THEN '门诊'
+        WHEN c.secondClubType=3 THEN '医院'
+        END) AS classify,
+        c.addTime AS addTime,
+        IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
+        case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS spName,
+        IFNULL(orderMonth.payTotalMonth,0) AS payTotalMonth,
+        IFNULL(orderMonth.orderCountMonth,0) AS orderCountMonth,
+        IFNULL(orderYesr.payTotalYesr,0) AS payTotalYear,
+        IFNULL(orderYesr.orderCountYesr,0) AS orderCountYear,
+        IFNULL(orderTotal.payTotal,0) AS payTotal,
+        pb.pageLabel,
+        MAX(cor.orderTime) AS lastOrderTime
+        FROM club c
+        LEFT JOIN cm_order cor ON c.userID = cor.userID
+        LEFT JOIN USER u ON u.userId=c.userId
+        LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
+        LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
+        LEFT JOIN
+        (SELECT userId,SUM(co.payTotalFee) AS payTotalMonth,
+        COUNT(co.orderid) AS orderCountMonth
+        FROM cm_order co
+        <where>
+            co.status NOT IN (0,6,7)
+            <if test="monthStartTime != null and monthStartTime != '' and monthEndTime != null and monthEndTime != ''">
+                AND co.orderTime BETWEEN #{monthStartTime} AND #{monthEndTime}
+            </if>
+        </where>
+        GROUP BY co.userid) AS orderMonth ON c.userId=orderMonth.userId
+
+        LEFT JOIN
+        (SELECT userId,SUM(co.payTotalFee) AS payTotalYesr,
+        COUNT(co.orderid) AS orderCountYesr
+        FROM cm_order co
+        <where>
+            co.status NOT IN (0,6,7)
+            <if test="yearStartTime != null and yearStartTime != '' and yearEndTime != null and yearEndTime != ''">
+                AND co.orderTime BETWEEN #{yearStartTime} AND #{yearEndTime}
+            </if>
+        </where>
+        GROUP BY co.userid) AS orderYesr ON c.userId=orderYesr.userId
+
+        LEFT JOIN
+        (SELECT userId,SUM(co.payTotalFee) AS payTotal,
+        COUNT(co.orderid) AS 21OrderCount
+        FROM cm_order co
+        <where>
+            co.status NOT IN (0,6,7)
+            <if test="customStartTime != null and customStartTime != ''">
+                AND (co.orderTime > #{customStartTime} or co.orderTime = #{customStartTime})
+            </if>
+            <if test="customEndTime != null and customEndTime != ''">
+                AND co.orderTime <![CDATA[ <= ]]> #{customEndTime}
+            </if>
+        </where>
+        GROUP BY co.userid) AS orderTotal ON c.userId=orderTotal.userId
+
+        LEFT JOIN
+        (
+        SELECT c.userID, COUNT(cbr.pageLabel), cbr.pageLabel
+        FROM cm_behavior_record cbr
+        LEFT JOIN club c ON cbr.userID = c.userID
+        <where> cbr.userID = c.userID</where>
+        GROUP BY cbr.pageLabel) AS pb ON c.userID = pb.userID
+        <where>
+            <if test="registerStartTime != null and registerStartTime != ''">
+                AND (c.addTime > #{registerStartTime} or c.addTime = #{registerStartTime} )
+            </if>
+            <if test="registerEndTime != null and registerEndTime != ''">
+                AND c.addTime <![CDATA[ <= ]]> #{registerEndTime}
+            </if>
+            <if test="searchStartTime != null and searchStartTime != ''">
+                AND (cor.orderTime > #{searchStartTime} or cor.orderTime = #{searchStartTime} )
+            </if>
+            <if test=" searchEndTime != null and searchEndTime != ''">
+                AND cor.orderTime <![CDATA[ <= ]]> #{searchEndTime}
+            </if>
+            <if test="customerValue != null and customerValue != ''">
+                AND c.firstClubType = #{customerValue}
+            </if>
+            <if test="searchUserIdentity != null and searchUserIdentity != ''">
+                AND u.userIdentity = #{searchUserIdentity}
+            </if>
+            <if test="searchStatus != null and searchStatus != ''">
+                AND c.status = #{searchStatus}
+            </if>
+            <if test="linkManIdentity != null and linkManIdentity != ''">
+                AND c.linkManIdentity = #{linkManIdentity}
+            </if>
+            <if test="clubDataIntegrity != null and clubDataIntegrity != ''">
+                AND c.status = #{clubDataIntegrity}
+            </if>
+            <if test="payTotalMonth != null and payTotalMonth != ''">
+                <if test="payTotalMonth==1">
+                    AND orderMonth.payTotalMonth <![CDATA[ < ]]> 10000
+                </if>
+                <if test="payTotalMonth==2">
+                    AND orderMonth.payTotalMonth BETWEEN 10000 AND 100000
+                </if>
+                <if test="payTotalMonth==3">
+                    AND orderMonth.payTotalMonth BETWEEN 100000 AND 1000000
+                </if>
+                <if test="payTotalMonth==4">
+                    AND orderMonth.payTotalMonth <![CDATA[ > ]]> 1000000
+                </if>
+            </if>
+            <if test="payTotalYear != null and payTotalYear != ''">
+                <if test="payTotalYear==1">
+                    AND orderYesr.payTotalYesr <![CDATA[ < ]]> 10000
+                </if>
+                <if test="payTotalYear==2">
+                    AND orderYesr.payTotalYesr BETWEEN 10000 AND 100000
+                </if>
+                <if test="payTotalYear==3">
+                    AND orderYesr.payTotalYesr BETWEEN 100000 AND 1000000
+                </if>
+                <if test="payTotalYear==4">
+                    AND orderYesr.payTotalYesr <![CDATA[ > ]]> 1000000
+                </if>
+            </if>
+            <if test="payTotal != null and payTotal != ''">
+                <if test="payTotal==1">
+                    AND orderTotal.payTotal <![CDATA[ < ]]> 10000
+                </if>
+                <if test="payTotal==2">
+                    AND orderTotal.payTotal BETWEEN 10000 AND 100000
+                </if>
+                <if test="payTotal==3">
+                    AND orderTotal.payTotal BETWEEN 100000 AND 1000000
+                </if>
+                <if test="payTotal==4">
+                    AND orderTotal.payTotal <![CDATA[ > ]]> 1000000
+                </if>
+            </if>
+        </where>
+        GROUP BY c.userID ORDER BY MAX(cor.orderTime) DESC
+    </select>
 </mapper>

+ 31 - 30
src/main/webapp/WEB-INF/views/modules/userNew/cmAgencyStatisticsList.jsp

@@ -309,38 +309,39 @@ function subClick() {
 $(function () {
     $("#export").click(function () {
         var formData = $('#searchForm').serialize()
+        window.location.href= "${ctx}/new/user/agency/club/export"
         <%--window.location.href = "${ctx}/new/user/agency/club/export?"+formData;--%>
-        $.ajax({
-            url: "${ctx}/new/user/agency/club/export",
-            type: "post",
-            data: formData,
-            contentType : 'application/json;charset=UTF-8', //contentType很重要
-            // responseType: 'blob',
+        <%--$.ajax({--%>
+        <%--    url: "${ctx}/new/user/agency/club/export",--%>
+        <%--    type: "post",--%>
+        <%--    data: formData,--%>
+        <%--    contentType : 'application/json;charset=UTF-8', //contentType很重要--%>
+        <%--    // responseType: 'blob',--%>
 
-        }).then(res => {
-            console.log("00000");
-            /*const content = res // 文件流
-            const blob = new Blob([content], {
-                // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
-                type: "application/msexcel;charset=utf-8",
-            })
-            //var myDate = new Date() | ' + myDate.getTime() + '
-            const fileName = '机构.xlsx'
-            if ('download' in document.createElement('a')) {
-                // 非IE下载
-                const link = document.createElement('a')
-                link.download = fileName
-                link.style.display = 'none'
-                link.href = URL.createObjectURL(blob)
-                document.body.appendChild(link)
-                link.click()
-                URL.revokeObjectURL(link.href) // 释放URL 对象
-                document.body.removeChild(link)
-            } else {
-                // IE10+下载
-                navigator.msSaveBlob(blob, fileName)
-            }*/
-        })
+        <%--}).then(res => {--%>
+        <%--    console.log("00000");--%>
+        <%--    /*const content = res // 文件流--%>
+        <%--    const blob = new Blob([content], {--%>
+        <%--        // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',--%>
+        <%--        type: "application/msexcel;charset=utf-8",--%>
+        <%--    })--%>
+        <%--    //var myDate = new Date() | ' + myDate.getTime() + '--%>
+        <%--    const fileName = '机构.xlsx'--%>
+        <%--    if ('download' in document.createElement('a')) {--%>
+        <%--        // 非IE下载--%>
+        <%--        const link = document.createElement('a')--%>
+        <%--        link.download = fileName--%>
+        <%--        link.style.display = 'none'--%>
+        <%--        link.href = URL.createObjectURL(blob)--%>
+        <%--        document.body.appendChild(link)--%>
+        <%--        link.click()--%>
+        <%--        URL.revokeObjectURL(link.href) // 释放URL 对象--%>
+        <%--        document.body.removeChild(link)--%>
+        <%--    } else {--%>
+        <%--        // IE10+下载--%>
+        <%--        navigator.msSaveBlob(blob, fileName)--%>
+        <%--    }*/--%>
+        <%--})--%>
 
     })
 })