Forráskód Böngészése

用户行为优化1.0.3

huangzhiguo 1 éve
szülő
commit
75f454ae68

+ 11 - 0
pom.xml

@@ -137,6 +137,17 @@
             <artifactId>jsoup</artifactId>
             <version>1.9.2</version>
         </dependency>
+        <dependency>
+            <groupId>com.github.junrar</groupId>
+            <artifactId>junrar</artifactId>
+            <version>7.4.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.lingala</groupId>
+            <artifactId>zip4j</artifactId>
+            <version>1.3.3</version>
+        </dependency>
     </dependencies>
 
     <profiles>

+ 33 - 51
src/main/java/com/caimei365/manager/controller/caimei/user/CmMarketShopApi.java

@@ -7,13 +7,12 @@ import com.caimei365.manager.entity.caimei.CmShop;
 import com.caimei365.manager.entity.caimei.shopImport.CmMarketReport;
 import com.caimei365.manager.entity.caimei.shopImport.CmMarketShop;
 import com.caimei365.manager.service.caimei.user.CmMarketShopService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.Map;
 
 /**
  * Description
@@ -27,49 +26,6 @@ public class CmMarketShopApi {
 
     @Resource private CmMarketShopService marketShopService;
 
-    /**
-     * 供应商列表
-     * @param shopName
-     * @param pageNum
-     * @param pageSize
-     * @return
-     */
-    @GetMapping("/getShop")
-    public ResponseJson<PaginationVo<CmShop>> getShop(String shopName,
-                                                      @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                      @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
-
-        return marketShopService.getShop(shopName, pageNum, pageSize);
-    }
-
-    /**
-     * 营销供应商列表
-     * @param shopName
-     * @param pageNum
-     * @param pageSize
-     * @return
-     */
-    @GetMapping("/getMarkShopList")
-    public ResponseJson<PaginationVo<CmMarketShop>> getMarkShopList(String shopName,
-                                                                    @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                    @RequestParam(value = "pageSize",defaultValue = "20") int pageSize) {
-
-        return marketShopService.getMarkShopList(shopName, pageNum, pageSize);
-    }
-
-    /**
-     * 添加营销供应商
-     * @param ids
-     * @return
-     */
-    @GetMapping("/saveMarketShop")
-    public ResponseJson saveMarketShop(String ids) {
-        if (StringUtils.isEmpty(ids) || StringUtils.isBlank(ids)) {
-            return  ResponseJson.error(-1, "供应商营销id不能为空", null);
-        }
-        return marketShopService.saveMarketShop(ids);
-    }
-
     /**
      * 上传供应商营销logo
      * @param id
@@ -144,22 +100,48 @@ public class CmMarketShopApi {
         return marketShopService.updateMarketReport(id);
     }
 
+    /**
+     * 上传zip、rar文件到服务器并解压
+     * @return
+     */
+    @PostMapping("/saveMarketReport")
+    public ResponseJson saveMarketReport(@RequestParam("reportFile") MultipartFile reportFile) throws IOException {
+
+        if (reportFile.isEmpty() || reportFile == null) {
+            return ResponseJson.error(-1, "报表文件不能为空", null);
+        }
+        return marketShopService.saveMarketReport(reportFile);
+    }
+
     /**
      * 保存报表数据
+     * @param marketId
      * @param reportDate
      * @param reportName
-     * @param reportFile
+     * @param filePath
      * @return
+     * @throws IOException
      */
-    public ResponseJson saveMarketReport(String reportDate, String reportName, MultipartFile reportFile) {
+    @GetMapping("/saveReport")
+    public ResponseJson saveReport(Integer marketId, String reportDate, String reportName, String filePath) throws IOException {
+        if (marketId == null) {
+            return ResponseJson.error(-1, "供应商营销Id不能为空", null);
+        }
         if (StringUtils.isBlank(reportDate) || StringUtils.isEmpty(reportDate)) {
             return ResponseJson.error(-1, "报表时间不能为空", null);
         }
         if (StringUtils.isBlank(reportName) || StringUtils.isEmpty(reportName)) {
             return ResponseJson.error(-1, "报表名称不能为空", null);
         }
-        if (reportFile.isEmpty()) {
-            return ResponseJson.error(-1, "报表文件不能为空", null);
+        if (StringUtils.isBlank(filePath) || StringUtils.isEmpty(filePath)) {
+            return ResponseJson.error(-1, "报表路径不能为空", null);
+        }
+        return marketShopService.saveReport(marketId, reportDate, reportName, filePath);
+    }
+
+    public ResponseJson<Map<String, Object>> preview(Integer id) {
+        if (id == null) {
+            return ResponseJson.error(-1, "报表id不能为空", null);
         }
         return null;
     }

+ 78 - 27
src/main/java/com/caimei365/manager/dao/user/CmMarketShopDao.java

@@ -16,32 +16,6 @@ import java.util.List;
 @Mapper
 public interface CmMarketShopDao {
 
-    /**
-     * 供应商列表
-     * @param shopName
-     * @return
-     */
-    List<CmShop> getShopList(@Param("shopName") String shopName);
-
-    /**
-     * 营销已包含的供应商
-     * @return
-     */
-    List<Integer> getMarketShopIdList();
-
-    /**
-     * 营销供应商列表
-     * @param shopName
-     * @return
-     */
-    List<CmMarketShop> getMarketShopList(@Param("shopName") String shopName);
-
-    /**
-     * 添加营销供应商
-     * @param shopId
-     */
-    void insertMarketShop(@Param("shopId") Integer shopId);
-
     /**
      * 上传营销供应商logo
      * @param id
@@ -140,11 +114,88 @@ public interface CmMarketShopDao {
      * 广告图点击量
      * @param mallHits
      */
-    void insertMarketMallHits(AdvertHits mallHits);
+    void insertMarketAdvertHits(AdvertHits mallHits);
 
     /**
      * 咨询数量
      * @param remark
      */
     void insertMarketRemark(Remark remark);
+
+    /**
+     * 获取阶段描述
+     * @param marketReportId
+     * @return
+     */
+    List<Stage> getMarketStage(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取漏洞模型数据
+     * @param marketReportId
+     * @return
+     */
+    List<FunnelModel> getMarketFunnelModel(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取推文数据
+     * @param marketReportId
+     * @return
+     */
+    List<ArticleReadVolume> getMarketArticleReadVolume(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取展现量数据
+     * @param marketReportId
+     * @return
+     */
+    List<Impressions> getMarketImpressions(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取点击量数据
+     * @param marketReportId
+     * @return
+     */
+    List<ReadVolume> getMarketReadVolume(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取SEO汇总数据
+     * @param marketReportId
+     * @return
+     */
+    List<Summary> getMarketSummary(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取访问量数据
+     * @param marketReportId
+     * @return
+     */
+    List<Visits> getMarketVisits(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取访客来源分布数据
+     * @param marketReportId
+     * @return
+     */
+    List<Proportion> getMarketProportion(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取页面平均访问时长数据
+     * @param marketReportId
+     * @return
+     */
+    List<PageDuration> getMarketPageDuration(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取广告图点击量数据
+     * @param marketReportId
+     * @return
+     */
+    List<AdvertHits> getMarketAdvertHits(@Param("marketReportId") Integer marketReportId);
+
+    /**
+     * 获取咨询数量数据
+     * @param marketReportId
+     * @return
+     */
+    List<Remark> getMarketRemark(@Param("marketReportId") Integer marketReportId);
 }

+ 8 - 0
src/main/java/com/caimei365/manager/entity/caimei/cmUser/CmShopStatistics.java

@@ -38,6 +38,14 @@ public class CmShopStatistics {
      * 统计状态 0 统计 1 不统计
      */
     private Integer status;
+    /**
+     * log
+     */
+    private String logo;
+    /**
+     * 最近报表时间
+     */
+    private String recentlyTime;
     /**
      * 添加时间
      */

+ 20 - 0
src/main/java/com/caimei365/manager/entity/caimei/shopImport/CmMarketShop.java

@@ -30,4 +30,24 @@ public class CmMarketShop {
      * 删除标记 0 未删除 1 已删除
      */
     private Integer delFlag;
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+    /**
+     * 供应商联系人
+     */
+    private String linkMan;
+    /**
+     * 供应商联系电话
+     */
+    private String contractMobile;
+    /**
+     * 供应商状态
+     */
+    private Integer status;
+    /**
+     * 最近报表时间
+     */
+    private String recentlyTime;
 }

+ 10 - 11
src/main/java/com/caimei365/manager/service/caimei/listener/AdvertHitsListener.java

@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -20,17 +21,16 @@ public class AdvertHitsListener extends AnalysisEventListener<AdvertHits> {
     private Integer marketReportId;
 
     private CmMarketShopDao marketShopDao;
+    // 首页图片集合
+    private Map<String, String> advertImageHomeList;
+    // 信息中心图片集合
+    private Map<String, String> advertImageInfoList;
 
-    private List<String> advertImageHomeList;
-
-    private List<String> advertImageInfoList;
-
-    private final Integer SIZE = 100;
-    private Integer INDEX = 0;
+    private final Integer SIZE = 10;
 
     private final List<AdvertHits> dataList = new ArrayList();
 
-    public AdvertHitsListener(Integer marketReportId, CmMarketShopDao marketShopDao, List<String> advertImageHomeList, List<String> advertImageInfoList) {
+    public AdvertHitsListener(Integer marketReportId, CmMarketShopDao marketShopDao, Map<String, String> advertImageHomeList, Map<String, String> advertImageInfoList) {
         this.marketReportId = marketReportId;
         this.marketShopDao = marketShopDao;
         this.advertImageHomeList = advertImageHomeList;
@@ -65,10 +65,9 @@ public class AdvertHitsListener extends AnalysisEventListener<AdvertHits> {
 
         for (AdvertHits advertHits : dataList){
             advertHits.setMarketReportId(marketReportId);
-            advertHits.setHome(advertImageHomeList.get(INDEX));
-            advertHits.setInfoCenter(advertImageInfoList.get(INDEX));
-            marketShopDao.insertMarketMallHits(advertHits);
-            INDEX++;
+            advertHits.setHome(advertImageHomeList.get(advertHits.getHome()));
+            advertHits.setInfoCenter(advertImageInfoList.get(advertHits.getInfoCenter()));
+            marketShopDao.insertMarketAdvertHits(advertHits);
         }
     }
 }

+ 4 - 5
src/main/java/com/caimei365/manager/service/caimei/listener/SummaryListener.java

@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -21,14 +22,13 @@ public class SummaryListener extends AnalysisEventListener<Summary> {
 
     private CmMarketShopDao marketShopDao;
 
-    private List<String> seoImagePathList;
+    private Map<String, String> seoImagePathList;
 
     private final Integer SIZE = 100;
-    private Integer INDEX = 0;
 
     private final List<Summary> dataList = new ArrayList();
 
-    public SummaryListener(Integer marketReportId, CmMarketShopDao marketShopDao, List<String> seoImagePathList) {
+    public SummaryListener(Integer marketReportId, CmMarketShopDao marketShopDao, Map<String, String> seoImagePathList) {
         this.marketReportId = marketReportId;
         this.marketShopDao = marketShopDao;
         this.seoImagePathList = seoImagePathList;
@@ -61,9 +61,8 @@ public class SummaryListener extends AnalysisEventListener<Summary> {
     public void saveData(List<Summary> dataList) {
         dataList.forEach(summary -> {
             summary.setMarketReportId(marketReportId);
-            summary.setSeoRanking(seoImagePathList.get(INDEX));
+            summary.setSeoRanking(seoImagePathList.get(summary.getSeoRanking()));
             marketShopDao.insertMarketSummary(summary);
-            INDEX++;
         });
     }
 }

+ 28 - 18
src/main/java/com/caimei365/manager/service/caimei/user/CmMarketShopService.java

@@ -5,6 +5,10 @@ import com.caimei365.manager.entity.ResponseJson;
 import com.caimei365.manager.entity.caimei.CmShop;
 import com.caimei365.manager.entity.caimei.shopImport.CmMarketReport;
 import com.caimei365.manager.entity.caimei.shopImport.CmMarketShop;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.Map;
 
 /**
  * Description
@@ -13,24 +17,6 @@ import com.caimei365.manager.entity.caimei.shopImport.CmMarketShop;
  * @date : 2023/12/14
  */
 public interface CmMarketShopService {
-    /**
-     * 供应商列表
-     * @return
-     */
-    ResponseJson<PaginationVo<CmShop>> getShop(String shopName, int pageNum, int pageSize);
-    /**
-     * 营销供应商列表
-     * @param shopName
-     * @return
-     */
-    ResponseJson<PaginationVo<CmMarketShop>> getMarkShopList(String shopName, int pageNum, int pageSize);
-
-    /**
-     * 添加营销供应商
-     * @param ids
-     * @return
-     */
-    ResponseJson saveMarketShop(String ids);
 
     /**
      * 上传供应商营销logo
@@ -70,4 +56,28 @@ public interface CmMarketShopService {
      * @return
      */
     ResponseJson updateMarketReport(Integer id);
+
+    /**
+     * 上传zip、rar文件到服务器并解压
+     * @param reportFile
+     * @return
+     */
+    ResponseJson saveMarketReport(MultipartFile reportFile) throws IOException;
+
+    /**
+     * 保存报表数据
+     * @param marketId
+     * @param reportDate
+     * @param reportName
+     * @param filePath
+     * @return
+     */
+    ResponseJson saveReport(Integer marketId, String reportDate, String reportName, String filePath) throws IOException;
+
+    /**
+     * 报表数据预览
+     * @param id
+     * @return
+     */
+    ResponseJson<Map<String, Object>> preview(Integer id);
 }

+ 209 - 53
src/main/java/com/caimei365/manager/service/caimei/user/impl/CmMarketShopServiceImpl.java

@@ -1,17 +1,32 @@
 package com.caimei365.manager.service.caimei.user.impl;
 
+import cn.hutool.core.util.ZipUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
 import com.caimei365.manager.dao.user.CmMarketShopDao;
 import com.caimei365.manager.entity.PaginationVo;
 import com.caimei365.manager.entity.ResponseJson;
 import com.caimei365.manager.entity.caimei.CmShop;
-import com.caimei365.manager.entity.caimei.shopImport.CmMarketReport;
-import com.caimei365.manager.entity.caimei.shopImport.CmMarketShop;
+import com.caimei365.manager.entity.caimei.shopImport.*;
+import com.caimei365.manager.service.caimei.listener.*;
 import com.caimei365.manager.service.caimei.user.CmMarketShopService;
+import com.caimei365.manager.utils.FileUtil;
+import com.caimei365.manager.utils.formDataUtils;
 import com.github.pagehelper.PageHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.fileupload.disk.DiskFileItem;
+import org.apache.commons.io.IOUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
 import javax.annotation.Resource;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -19,63 +34,19 @@ import java.util.List;
  * @author : hzg
  * @date : 2023/12/14
  */
+@Slf4j
 @Service
 public class CmMarketShopServiceImpl implements CmMarketShopService {
 
-    @Resource private CmMarketShopDao marketShopDao;
+    private final static String ZIP_FILE = "zip";
+    private final static String RAR_FILE = "rar";
 
-    /**
-     * 供应商列表
-     * @return
-     */
-    @Override
-    public ResponseJson<PaginationVo<CmShop>> getShop(String shopName, int pageNum, int pageSize) {
-        PageHelper.startPage(pageNum, pageSize);
-        List<CmShop> shopList = marketShopDao.getShopList(shopName);
-        List<Integer> marketShopIdList = marketShopDao.getMarketShopIdList();
-        shopList.forEach(shop -> {
-            if (marketShopIdList.contains(shop.getShopId())) {
-                shop.setFlag(false);
-            } else {
-                shop.setFlag(true);
-            }
-        });
-        PaginationVo<CmShop> page = new PaginationVo<>(shopList);
-        return ResponseJson.success(page);
-    }
+//    private final static String extract = "/mnt/newdatadrive/data/runtime/jar-instance/manager-api/extract";
+    private final static String extract = "E:\\Users\\Desktop\\extract";
 
-    /**
-     * 营销供应商列表
-     *
-     * @param shopName
-     * @return
-     */
-    @Override
-    public ResponseJson<PaginationVo<CmMarketShop>> getMarkShopList(String shopName, int pageNum, int pageSize) {
-        PageHelper.startPage(pageNum, pageSize);
-        List<CmMarketShop> marketShopList = marketShopDao.getMarketShopList(shopName);
-        PaginationVo<CmMarketShop> page = new PaginationVo<>(marketShopList);
-        return ResponseJson.success(page);
-    }
+    @Resource private CmMarketShopDao marketShopDao;
 
-    /**
-     * 添加营销供应商
-     *
-     * @param ids
-     * @return
-     */
-    @Override
-    public ResponseJson saveMarketShop(String ids) {
-        if (ids.contains(",")) {
-            String[] split = ids.split(",");
-            for(String id : split) {
-                marketShopDao.insertMarketShop(Integer.parseInt(id));
-            }
-        } else {
-            marketShopDao.insertMarketShop(Integer.parseInt(ids));
-        }
-        return ResponseJson.success();
-    }
+    @Resource private formDataUtils formDataUtils;
 
     /**
      * 上传供应商营销logo
@@ -141,4 +112,189 @@ public class CmMarketShopServiceImpl implements CmMarketShopService {
         marketShopDao.updateMarketReport(id);
         return ResponseJson.success();
     }
+
+    /**
+     * 上传zip、rar文件到服务器并解压
+     *
+     * @param reportFile
+     * @return
+     */
+    @Override
+    public ResponseJson saveMarketReport( MultipartFile reportFile) throws IOException {
+
+        boolean isZipPack = true;
+
+        //不存在则创建
+        File packFile = new File(extract);
+        if (!packFile.exists()) {
+            boolean mkdirs = packFile.mkdirs();
+        }
+
+        if (reportFile== null) {
+            return ResponseJson.error(-1, "请上传文件", null);
+        }
+        String contentType = reportFile.getContentType();
+        String filename = reportFile.getOriginalFilename();
+        log.info("contentType===="+contentType);
+        //将压缩包保存在指定路径
+        String packFilePath = extract + File.separator + filename;
+        if (contentType.contains(ZIP_FILE)) {
+            //zip解压缩处理
+        } else if (contentType.contains(RAR_FILE)) {
+            //rar解压缩处理
+            isZipPack = false;
+        } else {
+            return ResponseJson.error(-1, "上传的压缩包格式不正确,仅支持rar和zip压缩文件!", null);
+        }
+
+        File file = new File(packFilePath);
+
+        try {
+            reportFile.transferTo(file);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return ResponseJson.error(-1, "压缩文件到:" + extract + " 失败!", null);
+        }
+        if (isZipPack) {
+            //zip压缩包
+            FileUtil.unZip(packFilePath, extract);
+        } else {
+            //rar压缩包
+            FileUtil.unPackRar(file, extract);
+        }
+        //获取压缩包名称
+        filename = filename.substring(0, filename.lastIndexOf("."));
+        log.info("filename===="+filename);
+        log.info("packFilePath===="+packFilePath);
+        if (file.exists()) {
+            file.delete();
+        }
+        String filePath = extract + "/" + filename;
+        return ResponseJson.success(filePath);
+    }
+
+    /**
+     * 保存报表数据
+     *
+     * @param marketId
+     * @param reportDate
+     * @param reportName
+     * @param filePath
+     * @return
+     */
+    @Override
+    public ResponseJson saveReport(Integer marketId, String reportDate, String reportName, String filePath) throws IOException {
+        CmMarketReport marketReport = new CmMarketReport();
+        marketReport.setMarketId(marketId);
+        marketReport.setReportDate(reportDate);
+        marketReport.setReportName(reportName);
+        marketShopDao.insertMarketReport(marketReport);
+        // 读取文件,处理数据
+        readFile(marketReport.getId(), filePath);
+        return ResponseJson.success();
+    }
+
+    /**
+     * 报表数据预览
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> preview(Integer id) {
+        Map<String, Object> map = new HashMap<>();
+
+        return ResponseJson.success(map);
+    }
+
+    /**
+     * 读取文件夹数据————指定格式 (营销供应商)
+     * @param marketReportId
+     * @param filePath
+     * @throws IOException
+     */
+    private void readFile(Integer marketReportId, String filePath) throws IOException {
+        // SEO 图片集合
+        Map<String, String> seoImagePathList = new HashMap<>();
+        // 广告图点击量 首页图片集合
+        Map<String, String> advertImageHomeList = new HashMap<>();
+        // 广告图点击量 信息中心图片集合
+        Map<String, String> advertImageInfoList = new HashMap<>();
+        File file = new File(filePath);
+        if (file.exists() && file.isDirectory()) {
+            for (File fileSpecific: file.listFiles()) {
+                if (fileSpecific.getName().equals("SEO汇总图片") && fileSpecific.exists() && fileSpecific.isDirectory()) {
+                    for (File fileSpecificContain : fileSpecific.listFiles()) {
+                        if (fileSpecificContain.getName().contains("SEO")) {
+                            // 上传图到服务器并获取图链接,存入数据库,图片顺序需与 SEO 列表顺序一致
+                            MultipartFile filex = FileUtil.fileToMultipartFileConverter(fileSpecificContain);
+                            String seoImagePath = formDataUtils.saveShopFile(filex);
+                            seoImagePathList.put(filex.getName(), seoImagePath);
+                        }
+                    }
+                }
+                if (fileSpecific.getName().equals("广告图片") && fileSpecific.exists() && fileSpecific.isDirectory()) {
+                    for (File fileSpecificContain : fileSpecific.listFiles()) {
+                        if (fileSpecificContain.getName().contains("首页")) {
+                            // 上传图到服务器并获取图链接,存入数据库,图片顺序需与 广告图点击量 列表顺序一致
+                            MultipartFile filex = FileUtil.fileToMultipartFileConverter(fileSpecificContain);
+                            String advertImagePath = formDataUtils.saveShopFile(filex);
+                            advertImageHomeList.put(filex.getName(), advertImagePath);
+                        }
+                        if (fileSpecificContain.getName().contains("信息中心")) {
+                            // 上传图到服务器并获取图链接,存入数据库,图片顺序需与 广告图点击量 列表顺序一致
+                            MultipartFile filex = FileUtil.fileToMultipartFileConverter(fileSpecificContain);
+                            String advertImagePath = formDataUtils.saveShopFile(filex);
+                            advertImageInfoList.put(filex.getName(), advertImagePath);
+                        }
+                    }
+                }
+                if (fileSpecific.getName().endsWith(".xlsx") || fileSpecific.getName().endsWith(".xls")) {
+                    readExcel(marketReportId, fileSpecific, seoImagePathList, advertImageHomeList, advertImageInfoList);
+                }
+            }
+        }
+        file.delete();
+    }
+
+    /**
+     * 多sheet excel文件读取 -- 指定sheet名称  多sheet读取必须多次创建文件流
+     * @param marketReportId
+     * @param file
+     * @param seoImagePathList
+     * @param advertImageHomeList
+     * @param advertImageInfoList
+     * @throws IOException
+     */
+    private void readExcel(Integer marketReportId, File file, Map<String, String> seoImagePathList, Map<String, String> advertImageHomeList, Map<String, String> advertImageInfoList) throws IOException {
+        String excelType = "XLSX";
+        if (file.getName().endsWith(".xls")) {
+            excelType = "XLS";
+        }
+        MultipartFile multipartFile = FileUtil.fileToMultipartFileConverter(file);
+        InputStream inputStream = new BufferedInputStream(multipartFile.getInputStream());
+        InputStream is = inputStream;
+        EasyExcel.read(is, Stage.class, new StageListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("阶段描述").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, FunnelModel.class, new FunnelModelListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("漏斗模型数据").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, ArticleReadVolume.class, new ArticleReadVolumeListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("推文阅读量").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, Impressions.class, new ImpressionsListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("展现量").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, ReadVolume.class, new ReadVolumeListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("点击量").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, Summary.class, new SummaryListener(marketReportId, marketShopDao, seoImagePathList)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("SEO汇总").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, Visits.class, new VisitsLisener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("访问量").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, Proportion.class, new ProportionListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("访客来源分布").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, PageDuration.class, new PageDurationListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("页面平均时长").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, AdvertHits.class, new AdvertHitsListener(marketReportId, marketShopDao, advertImageHomeList, advertImageInfoList)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("广告图点击量").doRead();
+        is = new BufferedInputStream(multipartFile.getInputStream());
+        EasyExcel.read(is, Remark.class, new RemarkListener(marketReportId, marketShopDao)).excelType(ExcelTypeEnum.valueOf(excelType)).sheet("咨询数量").doRead();
+    }
+
 }

+ 135 - 0
src/main/java/com/caimei365/manager/utils/FileUtil.java

@@ -0,0 +1,135 @@
+package com.caimei365.manager.utils;
+
+import com.github.junrar.Archive;
+import com.github.junrar.rarfile.FileHeader;
+import lombok.extern.slf4j.Slf4j;
+import net.lingala.zip4j.core.ZipFile;
+import org.apache.commons.fileupload.disk.DiskFileItem;
+import org.apache.commons.io.IOUtils;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
+import java.io.*;
+import java.nio.charset.Charset;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2023/12/19
+ */
+@Slf4j
+public class FileUtil {
+
+    /**
+     * 将file 文件转为 MultipartFile 文件
+     * @param file
+     * @return
+     * @throws IOException
+     */
+    public static MultipartFile fileToMultipartFileConverter(File file) throws IOException {
+        DiskFileItem diskFileItem = new DiskFileItem("File", "application/octet-stream", true, file.getName(), (int) file.length(), file.getParentFile());
+        try(InputStream is = new FileInputStream(file)) {
+            diskFileItem.getOutputStream().write(IOUtils.toByteArray(is));
+        }
+        return new CommonsMultipartFile(diskFileItem);
+    }
+
+
+
+    /**
+     * zip文件解压
+     *
+     * @param destPath 解压文件路径
+     * @param zipFilePath  压缩文件路径
+     */
+    public static void unZip(String zipFilePath, String destPath) throws IOException {
+        File destDir = new File(destPath);
+        if (!destDir.exists()) {
+            destDir.mkdir();
+        }
+        ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath), Charset.forName("GBK"));
+        ZipEntry entry = zipIn.getNextEntry();
+        while (entry != null) {
+            String filePath = destPath + File.separator + entry.getName();
+            if (!entry.isDirectory()) {
+                File file = new File(filePath);
+                file.getParentFile().mkdirs();
+                try (FileOutputStream fos = new FileOutputStream(file)) {
+                    byte[] bytes = new byte[4096];
+                    int length;
+                    while ((length = zipIn.read(bytes)) != -1) {
+                        fos.write(bytes, 0, length);
+                    }
+                }
+            } else {
+                File dir = new File(filePath);
+                dir.mkdir();
+            }
+            zipIn.closeEntry();
+            entry = zipIn.getNextEntry();
+        }
+        zipIn.close();
+    }
+
+    /**
+     * zip文件解压
+     *
+     * @param destPath 解压文件路径
+     * @param zipFile  压缩文件
+     */
+    public static void unPackZip(File zipFile, String destPath) {
+        try {
+            ZipFile zip = new ZipFile(zipFile);
+            /*zip4j默认用GBK编码去解压,这里设置编码为GBK的*/
+            zip.setFileNameCharset("GBK");
+            log.info("begin unpack zip file....");
+            zip.extractAll(destPath);
+        } catch (Exception e) {
+            log.error("解压失败:", e.getMessage(), e);
+        }
+    }
+
+    /**
+     * rar文件解压(不支持有密码的压缩包)
+     *
+     * @param rarFile  rar压缩包
+     * @param destPath 解压保存路径
+     */
+    public static void unPackRar(File rarFile, String destPath) {
+        try (Archive archive = new Archive(rarFile)) {
+            if (null != archive) {
+                FileHeader fileHeader = archive.nextFileHeader();
+                File file = null;
+                while (null != fileHeader) {
+                    // 防止文件名中文乱码问题的处理
+                    String fileName = fileHeader.getFileName().isEmpty() ? fileHeader.getFileNameString() : fileHeader.getFileName();
+                    if (fileHeader.isDirectory()) {
+                        //是文件夹
+                        file = new File(destPath + File.separator + fileName);
+                        file.mkdirs();
+                    } else {
+                        //不是文件夹
+                        file = new File(destPath + File.separator + fileName.trim());
+                        if (!file.exists()) {
+                            if (!file.getParentFile().exists()) {
+                                // 相对路径可能多级,可能需要创建父目录.
+                                file.getParentFile().mkdirs();
+                            }
+                            file.createNewFile();
+                        }
+                        FileOutputStream os = new FileOutputStream(file);
+                        archive.extractFile(fileHeader, os);
+                        os.close();
+                    }
+                    fileHeader = archive.nextFileHeader();
+                }
+            }
+        } catch (Exception e) {
+            log.error("解压失败:", e.getMessage(), e);
+        }
+    }
+
+}

+ 123 - 47
src/main/resources/mapper/user/CmMarketShopDao.xml

@@ -2,50 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.manager.dao.user.CmMarketShopDao">
 
-    <select id="getShopList" resultType="com.caimei365.manager.entity.caimei.CmShop">
-        SELECT
-            name,
-            linkMan,
-            contractMobile,
-            Status
-        FROM shop
-        <where>
-            <if test="shopName != null and shopName != ''">
-                name like concat('%',#{shopName},'%')
-            </if>
-        </where>
-    </select>
-
-    <select id="getMarketShopIdList" resultType="java.lang.Integer">
-        select shopId from cm_market_shop where delFlag = 0
-    </select>
-
-    <select id="getMarketShopList" resultType="com.caimei365.manager.entity.caimei.shopImport.CmMarketShop">
-        SELECT
-            cms.id,
-            s.name,
-            s.linkMan,
-            s.contractMobile,
-            s.status,
-            (SELECT ADDTIME FROM cm_market_report WHERE marketId = cms.id ORDER BY ADDTIME DESC LIMIT 1) AS recentlyTime,
-            cms.addTime
-        FROM cm_market_shop cms
-                 LEFT JOIN shop s ON s.shopId = cms.shopId
-        <where>
-            delFlag = 0
-            <if test="shopName != null and shopName != ''">
-                and s.name LIKE concat('%',#{shopName},'%')
-            </if>
-        </where>
-    </select>
-
-    <insert id="insertMarketShop">
-        insert into cm_market_shop(shopId, addTime, delFlag)
-        values (#{shopId}, now(), 0)
-    </insert>
-
     <update id="updateShopLogo">
-        update cm_market_shop
+        update cm_shop_statistics
         set logo = #{logo}
         where id = #{id}
     </update>
@@ -62,7 +20,7 @@
         FROM cm_market_report
         <where>
             marketId = #{marketId} AND delFlag = 0
-            <if test="reportName != null anf reportName != ''">
+            <if test="reportName != null and reportName != ''">
                 AND reportName LIKE concat('%', #{reportName}, '%')
             </if>
         </where>
@@ -93,7 +51,7 @@
         where id = #{id}
     </update>
 
-    <insert id="insertMarketReport">
+    <insert id="insertMarketReport" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
         insert into cm_market_report (marketId, reportDate, reportName, visible, addTime, delFlag)
         values (#{marketId}, #{reportDate}, #{reportName}, 1, now(), 0)
     </insert>
@@ -143,8 +101,8 @@
         values (#{marketReportId}, #{pageLabel}, #{accessDuration}, now())
     </insert>
 
-    <insert id="insertMarketMallHits">
-        insert into cm_market_mallHits (marketReportId, position, home, infoCenter, hits, addTime)
+    <insert id="insertMarketAdvertHits">
+        insert into cm_market_advertHits (marketReportId, position, home, infoCenter, hits, addTime)
         values (#{marketReportId}, #{position}, #{home}, #{infoCenter}, #{hits}, now())
     </insert>
 
@@ -152,4 +110,122 @@
         insert into cm_market_remark (marketReportId, remarkNumber, addTime)
         values (#{marketReportId}, #{remarkNumber}, now())
     </insert>
+
+    <select id="getMarketStage" resultType="com.caimei365.manager.entity.caimei.shopImport.Stage">
+        SELECT
+            id,
+            stage,
+            theme
+        FROM cm_market_stage
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketFunnelModel" resultType="com.caimei365.manager.entity.caimei.shopImport.FunnelModel">
+        SELECT
+        id,
+        impressions,
+        hits,
+        visits,
+        consultation,
+        report
+        FROM cm_market_funnelModel
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketArticleReadVolume" resultType="com.caimei365.manager.entity.caimei.shopImport.ArticleReadVolume">
+        SELECT
+            id,
+            title,
+            link,
+            titleReferred,
+            type,
+            keyword,
+            channel,
+            touchNumber,
+            wechatNumber
+        FROM cm_market_articleReadVolume
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketImpressions" resultType="com.caimei365.manager.entity.caimei.shopImport.Impressions">
+        SELECT
+            id,
+            generalNumber,
+            microBlog,
+            redBookNumber,
+            otherNumber
+        FROM cm_market_impressions
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketReadVolume" resultType="com.caimei365.manager.entity.caimei.shopImport.ReadVolume">
+        SELECT
+            id,
+            generalNumber,
+            microBlog,
+            redBookNumber,
+            otherNumber
+        FROM cm_market_readVolume
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketSummary" resultType="com.caimei365.manager.entity.caimei.shopImport.Summary">
+        SELECT
+            id,
+            keyword,
+            seoRanking,
+            searchVolume
+        FROM cm_market_summary
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketVisits" resultType="com.caimei365.manager.entity.caimei.shopImport.Visits">
+        SELECT
+            id,
+            clubNumber,
+            touristNumber
+        FROM cm_market_visits
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketProportion" resultType="com.caimei365.manager.entity.caimei.shopImport.Proportion">
+        SELECT
+            id,
+            search,
+            general,
+            microBlog,
+            directAccess
+        FROM cm_market_proportion
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketPageDuration" resultType="com.caimei365.manager.entity.caimei.shopImport.PageDuration">
+        SELECT
+            id,
+            pageLabel,
+            accessDuration
+        FROM cm_market_pageDuration
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketAdvertHits" resultType="com.caimei365.manager.entity.caimei.shopImport.AdvertHits">
+        SELECT
+            id,
+            POSITION,
+            home,
+            infoCenter,
+            hits
+        FROM cm_market_advertHits
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
+    <select id="getMarketRemark" resultType="com.caimei365.manager.entity.caimei.shopImport.Remark">
+        SELECT
+            id,
+            remarkNumber,
+            ADDTIME
+        FROM cm_market_remark
+        WHERE marketReportId = #{marketReportId}
+    </select>
+
 </mapper>

+ 2 - 0
src/main/resources/mapper/user/CustomerServiceDao.xml

@@ -6,11 +6,13 @@
         SELECT
             DISTINCT css.id as id,
                      css.shopID AS shopId,
+                     css.logo,
                      s.name as shopName,
                      s.linkMan,
                      s.contractMobile AS mobile,
                      s.status AS shopStatus,
                      css.status,
+                    (SELECT ADDTIME FROM cm_market_report WHERE marketId = css.id ORDER BY ADDTIME DESC LIMIT 1) AS recentlyTime,
                      css.addTime
         FROM cm_shop_statistics css
                  LEFT JOIN shop s ON css.shopId = s.shopId

+ 5 - 2
src/test/java/com/caimei365/manager/ManagerApplicationTests.java

@@ -1,3 +1,4 @@
+/*
 package com.caimei365.manager;
 
 import cn.hutool.core.util.ZipUtil;
@@ -45,12 +46,13 @@ class ManagerApplicationTests {
             outFile.mkdirs();
         }
         File zipFile = new File(filePath);
-        /*MultipartFile multipartFile = fileToMultipartFileConverter(zipFile);
+        MultipartFile multipartFile = fileToMultipartFileConverter(zipFile);
         try {
             multipartFile.transferTo(inputFile);
         } catch (Exception e) {
             e.printStackTrace();
-        }*/
+        }
+
         ZipUtil.unzip(inputFile, outFile);
         System.out.println("inputFile======"+inputFile.getPath());
 
@@ -189,3 +191,4 @@ class ManagerApplicationTests {
     }
 
 }
+*/