Explorar el Código

Merge branch 'dev-zenas-20241018' of wangfan/adweb3-server into master

zhangqiang hace 5 meses
padre
commit
805252d1ab

+ 7 - 0
jeecg-module-system/jeecg-system-api/jeecg-system-local-api/src/main/java/org/jeecg/common/system/api/ISysBaseAPI.java

@@ -553,4 +553,11 @@ public interface ISysBaseAPI extends CommonAPI {
     boolean isNotOwnSite(Integer siteId);
 
     boolean isNotOwnSite(String siteCode);
+
+    /**
+     *
+     * @param siteId
+     * @return
+     */
+    public JSONObject getSiteInfoById(String siteId);
 }

+ 397 - 267
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoKeywordsController.java

@@ -4,7 +4,7 @@ import cn.hutool.core.io.IoUtil;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xkcoding.http.util.StringUtil;
@@ -23,11 +23,17 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.base.controller.JeecgController;
-import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.FastJsonUtil;
+import org.jeecg.config.security.utils.SecureUtil;
 import org.jeecg.modules.adweb.seo.dto.AvesApiSearchKeywordsDTO;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
-import org.jeecg.modules.adweb.seo.service.ISeoKeywordsService;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsRankService;
+import org.jeecg.modules.adweb.seo.service.ISeoKeywordsService;
+import org.jeecg.modules.system.entity.SysUser;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -38,284 +44,408 @@ import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 /**
- * @Description: 关键词
- * @Author: jeecg-boot
- * @Date:   2024-10-15
- * @Version: V1.0
+ * @Description: 关键词 @Author: jeecg-boot @Date: 2024-10-15 @Version: V1.0
  */
-@Tag(name="关键词")
+@Tag(name = "关键词")
 @RestController
 @RequestMapping("/seo/seoKeywords")
 @Slf4j
 public class SeoKeywordsController extends JeecgController<SeoKeywords, ISeoKeywordsService> {
-	@Autowired
-	private ISeoKeywordsService seoKeywordsService;
-
-	@Autowired ISeoKeywordsRankService seoKeywordsRankService;
-
-	@Autowired
-	ISeoKeywordsRankService seoKpiStatisticsService;
-
-	@Autowired
-	private ISysBaseAPI sysBaseAPI;
-	
-	/**
-	 * 分页列表查询
-	 *
-	 * @param seoKeywords
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	//@AutoLog(value = "关键词-分页列表查询")
-	@Operation(summary="关键词-分页列表查询")
-	@GetMapping(value = "/list")
-	public Result<IPage<SeoKeywords>> queryPageList(SeoKeywords seoKeywords,
-								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-								   HttpServletRequest req) {
-		QueryWrapper<SeoKeywords> queryWrapper = QueryGenerator.initQueryWrapper(seoKeywords, req.getParameterMap());
-		Page<SeoKeywords> page = new Page<SeoKeywords>(pageNo, pageSize);
-		IPage<SeoKeywords> pageList = seoKeywordsService.page(page, queryWrapper);
-		return Result.OK(pageList);
-	}
-	
-	/**
-	 *   添加
-	 *
-	 * @param seoKeywords
-	 * @return
-	 */
-	@AutoLog(value = "关键词-添加")
-	@Operation(summary="关键词-添加")
-	@PreAuthorize("@jps.requiresPermissions('serp:seo_keywords:add')")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody SeoKeywords seoKeywords) {
-		seoKeywordsService.save(seoKeywords);
-		return Result.OK("添加成功!");
-	}
-	
-	/**
-	 *  编辑
-	 *
-	 * @param seoKeywords
-	 * @return
-	 */
-	@AutoLog(value = "关键词-编辑")
-	@Operation(summary="关键词-编辑")
+    @Autowired private ISeoKeywordsService seoKeywordsService;
+
+    @Autowired ISeoKeywordsRankService seoKeywordsRankService;
+
+    @Autowired ISeoKeywordsRankService seoKpiStatisticsService;
+
+    @Autowired private ISysBaseAPI sysBaseAPI;
+
+    /**
+     * 分页列表查询
+     *
+     * @param seoKeywords
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    // @AutoLog(value = "关键词-分页列表查询")
+    @Operation(summary = "关键词-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<SeoKeywords>> queryPageList(
+            SeoKeywords seoKeywords,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            HttpServletRequest req) {
+        if ((seoKeywords.getSiteCode() == null || seoKeywords.getSiteCode().isEmpty())) {
+            return Result.error("请选择站点");
+        }
+        //		QueryWrapper<SeoKeywords> queryWrapper = QueryGenerator.initQueryWrapper(seoKeywords,
+        // req.getParameterMap());
+        //		Page<SeoKeywords> page = new Page<SeoKeywords>(pageNo, pageSize);
+        //		IPage<SeoKeywords> pageList = seoKeywordsService.page(page, queryWrapper);
+        //		return Result.OK(pageList);
+        String siteCode = null;
+        String userFlag = req.getParameter("siteCode");
+        if (StringUtil.isNotEmpty(userFlag)) {
+            siteCode = userFlag;
+        }
+
+        // 根据用户做筛选
+        if (!sysBaseAPI.isAdmin()) {
+            if (seoKeywords.getSiteId() != null) {
+                JSONObject jsonObject = sysBaseAPI.getSiteInfoById(seoKeywords.getSiteId());
+                log.info("jsonObject:{}", FastJsonUtil.toJSONString(jsonObject));
+                siteCode = jsonObject.getString("code");
+            } else {
+                return Result.error("fail");
+            }
+        }
+
+        // 根据关键词做筛选
+        String keywords = req.getParameter("keywords");
+
+        // 根据创建时间做筛选
+        String createTime = req.getParameter("createTime");
+
+        // 根据最后搜索时间查询
+        String lastSearchTime = req.getParameter("lastSearchTime");
+
+        // 根据订阅ID查询
+        String subscriptionId = seoKeywords.getSubscriptionId();
+        String order = seoKeywords.getOrder();
+        String column = seoKeywords.getColumn();
+        Page<SeoKeywords> page = new Page<>(pageNo, pageSize);
+        IPage<SeoKeywords> pageList =
+                seoKeywordsService.pageList(
+                        page,
+                        siteCode,
+                        keywords,
+                        subscriptionId,
+                        lastSearchTime,
+                        createTime,
+                        seoKeywords.getKeywordType(),
+                        column,
+                        order,
+                        seoKeywords.getKeywordRank());
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 添加
+     *
+     * @param seoKeywords
+     * @return
+     */
+    @AutoLog(value = "关键词-添加")
+    @Operation(summary = "关键词-添加")
+    @PreAuthorize("@jps.requiresPermissions('serp:seo_keywords:add')")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody SeoKeywords seoKeywords) {
+        seoKeywordsService.save(seoKeywords);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param seoKeywords
+     * @return
+     */
+    @AutoLog(value = "关键词-编辑")
+    @Operation(summary = "关键词-编辑")
     @PreAuthorize("@jps.requiresPermissions('serp:seo_keywords:edit')")
-	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody SeoKeywords seoKeywords) {
-		seoKeywordsService.updateById(seoKeywords);
-		return Result.OK("编辑成功!");
-	}
-	
-	/**
-	 *   通过id删除
-	 *
-	 * @param id
-	 * @return
-	 */
-	@AutoLog(value = "关键词-通过id删除")
-	@Operation(summary="关键词-通过id删除")
+    @RequestMapping(
+            value = "/edit",
+            method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody SeoKeywords seoKeywords) {
+        seoKeywordsService.updateById(seoKeywords);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "关键词-通过id删除")
+    @Operation(summary = "关键词-通过id删除")
     @PreAuthorize("@jps.requiresPermissions('serp:seo_keywords:delete')")
-	@DeleteMapping(value = "/delete")
-	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-		seoKeywordsService.removeById(id);
-		return Result.OK("删除成功!");
-	}
-	
-	/**
-	 *  批量删除
-	 *
-	 * @param ids
-	 * @return
-	 */
-	@AutoLog(value = "关键词-批量删除")
-	@Operation(summary="关键词-批量删除")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        seoKeywordsService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "关键词-批量删除")
+    @Operation(summary = "关键词-批量删除")
     @PreAuthorize("@jps.requiresPermissions('serp:seo_keywords:deleteBatch')")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		this.seoKeywordsService.removeByIds(Arrays.asList(ids.split(",")));
-		return Result.OK("批量删除成功!");
-	}
-	
-	/**
-	 * 通过id查询
-	 *
-	 * @param id
-	 * @return
-	 */
-	//@AutoLog(value = "关键词-通过id查询")
-	@Operation(summary="关键词-通过id查询")
-	@GetMapping(value = "/queryById")
-	public Result<SeoKeywords> queryById(@RequestParam(name="id",required=true) String id) {
-		SeoKeywords seoKeywords = seoKeywordsService.getById(id);
-		if(seoKeywords==null) {
-			return Result.error("未找到对应数据");
-		}
-		return Result.OK(seoKeywords);
-	}
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.seoKeywordsService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("批量删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    // @AutoLog(value = "关键词-通过id查询")
+    @Operation(summary = "关键词-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<SeoKeywords> queryById(@RequestParam(name = "id", required = true) String id) {
+        SeoKeywords seoKeywords = seoKeywordsService.getById(id);
+        if (seoKeywords == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(seoKeywords);
+    }
 
     /**
-    * 导出excel
-    *
-    * @param request
-    * @param seoKeywords
-    */
+     * 导出excel
+     *
+     * @param request
+     */
     @PreAuthorize("@jps.requiresPermissions('serp:seo_keywords:exportXls')")
     @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, SeoKeywords seoKeywords) {
-        return super.exportXls(request, seoKeywords, SeoKeywords.class, "关键词");
+    public ModelAndView exportXls(HttpServletRequest request) throws Exception {
+        // Step.1 组装查询条件
+        //		QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser,
+        // request.getParameterMap());
+        // Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        // update-begin--Author:kangxiaolin  Date:20180825
+        // for:[03]用户导出,如果选择数据则只导出相关数据--------------------
+        //		String selections = request.getParameter("selections");
+        //		if(!oConvertUtils.isEmpty(selections)){
+        //			queryWrapper.in("id",selections.split(","));
+        //		}
+        // update-end--Author:kangxiaolin  Date:20180825
+        // for:[03]用户导出,如果选择数据则只导出相关数据----------------------
+        //		List<SysUser> pageList = sysUserService.list(queryWrapper);
+        AvesApiSearchKeywordsDTO avesApiSearchKeywordsDTO = new AvesApiSearchKeywordsDTO();
+        Result<?> res = this.queryRankInfoList(avesApiSearchKeywordsDTO, 1, 5000, request);
+        if (res == null || res.getResult() == null) {
+            return null;
+        }
+        IPage<SeoKeywords> pageList = (IPage<SeoKeywords>) res.getResult();
+        if (pageList.getRecords().isEmpty()) {
+            return null;
+        }
+        ArrayList<String> columns = null;
+        // 表头信息
+        if (sysBaseAPI.isAdmin()) {
+            columns = new ArrayList<>(Arrays.asList("序号", "关键词", "url", "关键词类型"));
+        } else {
+            columns = new ArrayList<>(Arrays.asList("序号", "关键词", "关键词类型"));
+        }
+
+        // 将关键词信息改为可以导出的格式
+        List<Map<String, Object>> list = new ArrayList<>();
+        List<SeoKeywords> enquiryList = pageList.getRecords();
+
+        List<String> dates = pageList.getRecords().get(0).getDateList();
+        columns.addAll(dates);
+
+        boolean isAdmin = sysBaseAPI.isAdmin();
+
+        for (int i = 0; i < enquiryList.size(); i++) {
+            SeoKeywords seoKeywords = enquiryList.get(i);
+            Map<String, Object> map = new LinkedHashMap<>();
+            map.put("序号", i + 1);
+            map.put("关键词", seoKeywords.getKeywords());
+            if (isAdmin) {
+                map.put("url", seoKeywords.getPositionUrl());
+            }
+            if (seoKeywords.getKeywordType() == 1) {
+                map.put("关键词类型", "指定词");
+            } else if (seoKeywords.getKeywordType() == 2) {
+                map.put("关键词类型", "长尾词");
+            }
+            // 遍历日期
+            for (String date : dates) {
+                map.put(
+                        date,
+                        Integer.valueOf(
+                                seoKeywords.getRankInfo().get(date) == null
+                                        ? "0"
+                                        : seoKeywords.getRankInfo().get(date)));
+            }
+            list.add(map);
+        }
+        // 导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "关键词排行");
+        mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
+        LoginUser user = SecureUtil.currentUser();
+        ExportParams exportParams =
+                new ExportParams("关键词排行数据", "导出人:" + user.getRealname(), "导出信息");
+        mv.addObject(NormalExcelConstants.PARAMS, exportParams);
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
     }
 
-    /**
-      * 通过excel导入数据
-    *
-    * @param request
-    * @param response
-    * @return
-    */
-    @PreAuthorize("@jps.requiresPermissions('serp:seo_keywords:importExcel')")
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, SeoKeywords.class);
+    /** 关键词排名页面 - 列表数据 */
+    @AutoLog(value = "营销推广-SEO-关键词排名统计查询接口")
+    @RequestMapping(value = "/keywordList")
+    public Result<?> queryRankInfoList(
+            AvesApiSearchKeywordsDTO avesApiSearchKeywordsDTO,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            HttpServletRequest req)
+            throws Exception {
+        if (sysBaseAPI.isNotOwnSite(avesApiSearchKeywordsDTO.getSiteCode())) {
+            return Result.OK(new Page<>());
+        }
+        // 参数判断
+        IPage<SeoKeywords> pageList = new Page<>();
+        String siteCode = req.getParameter("siteCode");
+        if (StringUtil.isEmpty(siteCode)) {
+            siteCode = avesApiSearchKeywordsDTO.getSiteCode();
+        }
+        if (StringUtil.isEmpty(siteCode)) {
+            log.info("缺少siteCode参数");
+            return Result.OK(pageList);
+        }
+        String subscriptionId = avesApiSearchKeywordsDTO.getSubscriptionId();
+        Integer keywordType = avesApiSearchKeywordsDTO.getKeywordType();
+        // 查询关键词
+        String column = req.getParameter("column");
+        String order = req.getParameter("order");
+        String buttonColumn = req.getParameter("buttonColmn");
+        String buttonSort = req.getParameter("buttonSort");
+        Page<SeoKeywords> page = new Page<SeoKeywords>(pageNo, pageSize);
+        List<String> dateList =
+                seoKeywordsService.getKeywordsLastSevenDays(siteCode, keywordType, subscriptionId);
+        pageList =
+                seoKeywordsService.getKeywordList(
+                        page,
+                        avesApiSearchKeywordsDTO.getRankStart(),
+                        avesApiSearchKeywordsDTO.getRankEnd(),
+                        avesApiSearchKeywordsDTO.getKeywords(),
+                        siteCode,
+                        keywordType,
+                        avesApiSearchKeywordsDTO.getReachStandard() != null
+                                && avesApiSearchKeywordsDTO.getReachStandard() == 1,
+                        subscriptionId,
+                        column,
+                        order,
+                        buttonColumn,
+                        buttonSort,
+                        dateList);
+
+        // 给关键词对象增加排名信息
+        if (pageList == null) {
+            return Result.error("未获取到关键词数据");
+        }
+        seoKeywordsRankService.addRankInfoByIntervalTimeByType(
+                pageList.getRecords(),
+                avesApiSearchKeywordsDTO.getKeywordType(),
+                siteCode,
+                subscriptionId,
+                dateList);
+        log.info(pageList.toString());
+        return Result.OK(pageList);
     }
 
-	 /**
-	  * 关键词排名页面 - 列表数据
-	  */
-	 @AutoLog(value = "营销推广-SEO-关键词排名统计查询接口")
-	 @RequestMapping(value = "/keywordList")
-	 public Result<?> queryRankInfoList(AvesApiSearchKeywordsDTO avesApiSearchKeywordsDTO,
-										@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-										@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-										HttpServletRequest req) throws Exception {
-		 if (sysBaseAPI.isNotOwnSite(avesApiSearchKeywordsDTO.getSiteCode())) {
-			 return Result.OK(new Page<>());
-		 }
-		 // 参数判断
-		 IPage<SeoKeywords> pageList = new Page<>();
-		 String siteCode = req.getParameter("siteCode");
-		 if (StringUtil.isEmpty(siteCode)) {
-			 siteCode = avesApiSearchKeywordsDTO.getSiteCode();
-		 }
-		 if (StringUtil.isEmpty(siteCode)) {
-			 log.info("缺少siteCode参数");
-			 return Result.OK(pageList);
-		 }
-		 String subscriptionId = avesApiSearchKeywordsDTO.getSubscriptionId();
-		 Integer keywordType = avesApiSearchKeywordsDTO.getKeywordType();
-		 // 查询关键词
-		 String column = req.getParameter("column");
-		 String order = req.getParameter("order");
-		 String buttonColumn = req.getParameter("buttonColmn");
-		 String buttonSort = req.getParameter("buttonSort");
-		 Page<SeoKeywords> page = new Page<SeoKeywords>(pageNo, pageSize);
-		 List<String> dateList = seoKeywordsService.getKeywordsLastSevenDays(siteCode,keywordType,subscriptionId);
-		 pageList = seoKeywordsService.getKeywordList(page,
-				 avesApiSearchKeywordsDTO.getRankStart(),
-				 avesApiSearchKeywordsDTO.getRankEnd(),
-				 avesApiSearchKeywordsDTO.getKeywords(),
-				 siteCode,
-				 keywordType,
-				 avesApiSearchKeywordsDTO.getReachStandard() != null && avesApiSearchKeywordsDTO.getReachStandard() == 1,
-				 subscriptionId,
-				 column,
-				 order,
-				 buttonColumn,
-				 buttonSort,
-				 dateList);
-
-		 // 给关键词对象增加排名信息
-		 if(pageList == null){
-			 return Result.error("未获取到关键词数据");
-		 }
-		 seoKeywordsRankService.addRankInfoByIntervalTimeByType(pageList.getRecords(), avesApiSearchKeywordsDTO.getKeywordType(),siteCode,subscriptionId,dateList);
-		 log.info(pageList.toString());
-		 return Result.OK(pageList);
-	 }
-
-	/**
-	 * Excel导出
-	 * 关键词排名的导出
-	 * @param avesApiSearchKeywordsDTO 查询参数
-	 * @return 询盘列表
-	 */
-	@RequestMapping(value = "/exportExcel")
-	public void exportExcel(AvesApiSearchKeywordsDTO avesApiSearchKeywordsDTO,
-							HttpServletRequest req,
-							HttpServletResponse response) throws Exception {
-		Result res = this.queryRankInfoList(avesApiSearchKeywordsDTO, 1, 5000, req);
-		if (res == null || res.getResult() == null) {
-			return;
-		}
-		IPage<SeoKeywords> pageList = (IPage<SeoKeywords>) res.getResult();
-		if (pageList.getRecords().size() == 0) {
-			return;
-		}
-		ArrayList<String> columns = null;
-		// 表头信息
-		if (sysBaseAPI.isAdmin()) {
-			columns = new ArrayList<>(Arrays.asList("序号", "关键词", "url", "关键词类型"));
-		} else {
-			columns = new ArrayList<>(Arrays.asList("序号", "关键词", "关键词类型"));
-		}
-
-		// 将关键词信息改为可以导出的格式
-		List<Map<String, Object>> list = new ArrayList<>();
-		List<SeoKeywords> enquiryList = pageList.getRecords();
-
-		List<String> dates = pageList.getRecords().get(0).getDateList();
-		columns.addAll(dates);
-
-		boolean isAdmin = sysBaseAPI.isAdmin();
-
-		for (int i = 0; i < enquiryList.size(); i++) {
-			SeoKeywords seoKeywords = enquiryList.get(i);
-			Map<String, Object> map = new LinkedHashMap<>();
-			map.put("序号", i + 1);
-			map.put("关键词", seoKeywords.getKeywords());
-			if (isAdmin) {
-				map.put("url", seoKeywords.getPositionUrl());
-			}
-			if(seoKeywords.getKeywordType() == 1) {
-				map.put("关键词类型", "指定词");
-			} else if(seoKeywords.getKeywordType() == 2) {
-				map.put("关键词类型", "长尾词");
-			}
-			// 遍历日期
-			for (String date : dates) {
-				map.put(date,Integer.valueOf(seoKeywords.getRankInfo().get(date) == null ? "0" : seoKeywords.getRankInfo().get(date)));
-			}
-			list.add(map);
-		}
-		StringBuilder fileName = new StringBuilder();
-		fileName.append("关键词排名导出");
-
-		response.setContentType("application/vnd.ms-excel;charset=utf-8");
-		// test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
-		ServletOutputStream out = null;
-		ExcelWriter writer = ExcelUtil.getWriter(true);
-		try {
-			Sheet sheet = writer.getSheet();
-			sheet.setDefaultColumnWidth(12);
-			sheet.setDefaultRowHeightInPoints(20);
-			// 设置请求头属性
-			response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xlsx").getBytes(), StandardCharsets.ISO_8859_1));
-			out = response.getOutputStream();
-			writer.write(list, true);
-			seoKeywordsRankService.setSizeColumn(sheet, list.get(0).size());
-			// 写出到文件
-			writer.flush(out, true);
-			// 关闭writer,释放内存
-			writer.close();
-			// 此处记得关闭输出Servlet流
-			IoUtil.close(out);
-		} catch (IOException e) {
-			log.error(e.getMessage());
-			e.printStackTrace();
-		}
-	}
+    /**
+     * Excel导出 关键词排名的导出
+     *
+     * @param avesApiSearchKeywordsDTO 查询参数
+     * @return 询盘列表
+     */
+    @RequestMapping(value = "/exportExcel")
+    public void exportExcel(
+            AvesApiSearchKeywordsDTO avesApiSearchKeywordsDTO,
+            HttpServletRequest req,
+            HttpServletResponse response)
+            throws Exception {
+        Result<?> res = this.queryRankInfoList(avesApiSearchKeywordsDTO, 1, 5000, req);
+        if (res == null || res.getResult() == null) {
+            return;
+        }
+        IPage<SeoKeywords> pageList = (IPage<SeoKeywords>) res.getResult();
+        if (pageList.getRecords().isEmpty()) {
+            return;
+        }
+        ArrayList<String> columns = null;
+        // 表头信息
+        if (sysBaseAPI.isAdmin()) {
+            columns = new ArrayList<>(Arrays.asList("序号", "关键词", "url", "关键词类型"));
+        } else {
+            columns = new ArrayList<>(Arrays.asList("序号", "关键词", "关键词类型"));
+        }
+
+        // 将关键词信息改为可以导出的格式
+        List<Map<String, Object>> list = new ArrayList<>();
+        List<SeoKeywords> enquiryList = pageList.getRecords();
+
+        List<String> dates = pageList.getRecords().get(0).getDateList();
+        columns.addAll(dates);
+
+        boolean isAdmin = sysBaseAPI.isAdmin();
+
+        for (int i = 0; i < enquiryList.size(); i++) {
+            SeoKeywords seoKeywords = enquiryList.get(i);
+            Map<String, Object> map = new LinkedHashMap<>();
+            map.put("序号", i + 1);
+            map.put("关键词", seoKeywords.getKeywords());
+            if (isAdmin) {
+                map.put("url", seoKeywords.getPositionUrl());
+            }
+            if (seoKeywords.getKeywordType() == 1) {
+                map.put("关键词类型", "指定词");
+            } else if (seoKeywords.getKeywordType() == 2) {
+                map.put("关键词类型", "长尾词");
+            }
+            // 遍历日期
+            for (String date : dates) {
+                map.put(
+                        date,
+                        Integer.valueOf(
+                                seoKeywords.getRankInfo().get(date) == null
+                                        ? "0"
+                                        : seoKeywords.getRankInfo().get(date)));
+            }
+            list.add(map);
+        }
+        StringBuilder fileName = new StringBuilder();
+        fileName.append("关键词排名导出");
+
+        response.setContentType("application/vnd.ms-excel;charset=utf-8");
+        // test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
+        ServletOutputStream out = null;
+        ExcelWriter writer = ExcelUtil.getWriter(true);
+        try {
+            Sheet sheet = writer.getSheet();
+            sheet.setDefaultColumnWidth(12);
+            sheet.setDefaultRowHeightInPoints(20);
+            // 设置请求头属性
+            response.setHeader(
+                    "Content-Disposition",
+                    "attachment;filename="
+                            + new String(
+                                    (fileName + ".xlsx").getBytes(), StandardCharsets.ISO_8859_1));
+            out = response.getOutputStream();
+            log.info("导出数据:" + list);
+            writer.write(list, true);
+            seoKeywordsRankService.setSizeColumn(sheet, list.get(0).size());
+            // 写出到文件
+            writer.flush(out, true);
+            // 关闭writer,释放内存
+            writer.close();
+            // 此处记得关闭输出Servlet流
+            IoUtil.close(out);
+        } catch (IOException e) {
+            log.error(e.getMessage());
+            e.printStackTrace();
+        }
+    }
 }

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/controller/SeoKeywordsRankController.java

@@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.modules.adweb.seo.entity.ComprehensiveStatistics;
+import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
 import org.jeecg.modules.adweb.seo.service.ISeoKeywordsRankService;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/entity/ComprehensiveStatistics.java → jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/dto/ComprehensiveStatistics.java

@@ -1,4 +1,4 @@
-package org.jeecg.modules.adweb.seo.entity;
+package org.jeecg.modules.adweb.seo.dto;
 
 import lombok.Data;
 

+ 33 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/SeoKeywordsMapper.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.adweb.seo.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
 import org.jeecg.modules.adweb.seo.vo.RankInfoVO;
@@ -66,4 +67,36 @@ public interface SeoKeywordsMapper extends BaseMapper<SeoKeywords> {
      */
     List<SeoKeywords> getKeywordsToSerp(List<String> sideCodes, int keywordType, int limit);
 
+    /**
+     * 关键词管理列表数据
+     * @param page
+     * @param siteCode
+     * @param keywords
+     * @param subscriptionId
+     * @param lastSearchTime
+     * @param createTime
+     * @param keywordType
+     * @param column
+     * @param order
+     * @param keywordRank
+     * @return
+     */
+    IPage<SeoKeywords> getPageList(Page<SeoKeywords> page, String siteCode, String keywords, String subscriptionId, String lastSearchTime, String createTime, Integer keywordType, String column, String order, Integer keywordRank);
+
+    /**
+     * 关键词管理列表数据
+     * @param page
+     * @param siteCode
+     * @param keywords
+     * @param subscriptionId
+     * @param lastSearchTime
+     * @param createTime
+     * @param keywordType
+     * @param column
+     * @param order
+     * @param keywordRank
+     * @return
+     */
+    IPage<SeoKeywords> getPageListByCreateTime(Page<SeoKeywords> page, String siteCode, String keywords, String subscriptionId, String lastSearchTime, String createTime, Integer keywordType, String column, String order, Integer keywordRank);
+
 }

+ 135 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/mapper/xml/SeoKeywordsMapper.xml

@@ -180,4 +180,139 @@
         AND last_search_time <![CDATA[ <]]> CURDATE()
         LIMIT #{limit}
     </select>
+
+    <select id="getPageList" resultType="org.jeecg.modules.adweb.seo.entity.SeoKeywords">
+        (
+        SELECT
+        *,CHAR_LENGTH( t1.keywords ) keywordsLength
+        FROM
+        seo_keywords t1
+        WHERE
+        t1.`status` = 1
+        AND t1.app_key = 'adweb'
+        AND t1.last_rank <![CDATA[ <>]]> 0
+        <if test="siteCode != null and siteCode != ''">
+            AND t1.site_code = #{siteCode}
+        </if>
+        <if test="keywordType != null and keywordType != ''">
+            AND t1.keyword_type = #{keywordType}
+        </if>
+        <if test="keywords != null and keywords != ''">
+            AND t1.keywords LIKE CONCAT('%', #{keywords}, '%')
+        </if>
+        <if test="createTime != null and createTime != ''">
+            AND t1.create_time LIKE CONCAT(#{createTime}, '%')
+        </if>
+        <if test="subscriptionId != null and subscriptionId != ''">
+            AND t1.subscription_id = #{subscriptionId}
+        </if>
+        <if test="lastSearchTime != null and lastSearchTime != ''">
+            AND t1.last_search_time LIKE CONCAT(#{lastSearchTime}, '%')
+        </if>
+        <if test="keywordRank != null and keywordRank != ''">
+            AND t1.last_rank >= 1
+            AND #{keywordRank} * 10 >= t1.last_rank
+        </if>
+        ORDER BY
+        <if test="column != null and column != '' and column != 'keywords'">
+            ${column} ${order}
+        </if>
+        <if test="column != null and column != '' and column == 'keywords'">
+            CHAR_LENGTH(t1.keywords) ${order}
+        </if>
+        <if test="keywordRank != null and keywordRank != ''">
+            ,last_rank ASC
+        </if>
+        <if test="column == null">
+            ,priority ASC,optimize_process DESC,create_time DESC
+        </if>
+        LIMIT 99999999999
+        )
+        UNION ALL
+        (
+        SELECT
+        *,CHAR_LENGTH( t1.keywords ) keywordsLength
+        FROM
+        seo_keywords t1
+        WHERE
+        t1.`status` = 1
+        AND t1.app_key = 'adweb'
+        AND t1.last_rank = 0
+        <if test="siteCode != null and siteCode != ''">
+            AND t1.site_code = #{siteCode}
+        </if>
+        <if test="keywordType != null and keywordType != ''">
+            AND t1.keyword_type = #{keywordType}
+        </if>
+        <if test="keywords != null and keywords != ''">
+            AND t1.keywords LIKE CONCAT('%', #{keywords}, '%')
+        </if>
+        <if test="createTime != null and createTime != ''">
+            AND t1.create_time LIKE CONCAT(#{createTime}, '%')
+        </if>
+        <if test="subscriptionId != null and subscriptionId != ''">
+            AND t1.subscription_id = #{subscriptionId}
+        </if>
+        <if test="lastSearchTime != null and lastSearchTime != ''">
+            AND t1.last_search_time LIKE CONCAT(#{lastSearchTime}, '%')
+        </if>
+        <if test="keywordRank != null and keywordRank != ''">
+            AND t1.last_rank >= 1
+            AND #{keywordRank} * 10 >= t1.last_rank
+        </if>
+        ORDER BY
+        <if test="column != null and column != '' and column != 'keywords'">
+            ${column} ${order}
+        </if>
+        <if test="column != null and column != '' and column == 'keywords'">
+            CHAR_LENGTH(t1.keywords) ${order}
+        </if>
+        <if test="keywordRank != null and keywordRank != ''">
+            ,last_rank ASC
+        </if>
+        <if test="column == null">
+            ,priority ASC,optimize_process DESC,create_time DESC
+        </if>
+        LIMIT 99999999999
+        )
+    </select>
+
+    <select id="getPageListByCreateTime" resultType="org.jeecg.modules.adweb.seo.entity.SeoKeywords">
+        SELECT
+        *
+        FROM
+        seo_keywords t1
+        WHERE
+        t1.`status` = 1
+        AND t1.app_key = 'adweb'
+        <if test="siteCode != null and siteCode != ''">
+            AND t1.site_code = #{siteCode}
+        </if>
+        <if test="keywordType != null and keywordType != ''">
+            AND t1.keyword_type = #{keywordType}
+        </if>
+        <if test="keywords != null and keywords != ''">
+            AND t1.keywords LIKE CONCAT('%', #{keywords}, '%')
+        </if>
+        <if test="createTime != null and createTime != ''">
+            AND t1.create_time LIKE CONCAT(#{createTime}, '%')
+        </if>
+        <if test="subscriptionId != null and subscriptionId != ''">
+            AND t1.subscription_id = #{subscriptionId}
+        </if>
+        <if test="lastSearchTime != null and lastSearchTime != ''">
+            AND t1.last_search_time LIKE CONCAT(#{lastSearchTime}, '%')
+        </if>
+        <if test="keywordRank != null and keywordRank != ''">
+            AND t1.last_rank >= 1
+            AND #{keywordRank} * 10 >= t1.last_rank
+        </if>
+        ORDER BY
+        <if test="column != null and column != ''">
+            ${column} ${order}
+        </if>
+        <if test="keywordRank != null and keywordRank != ''">
+            ,last_rank ASC
+        </if>
+    </select>
 </mapper>

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoKeywordsRankService.java

@@ -1,7 +1,7 @@
 package org.jeecg.modules.adweb.seo.service;
 
 import org.apache.poi.ss.usermodel.Sheet;
-import org.jeecg.modules.adweb.seo.entity.ComprehensiveStatistics;
+import org.jeecg.modules.adweb.seo.dto.ComprehensiveStatistics;
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
 import org.jeecg.modules.adweb.seo.vo.SeoRankInfoVO;
 import org.jeecg.modules.adweb.site.entity.AdwebSite;

+ 4 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/seo/service/ISeoKeywordsService.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.adweb.seo.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import org.jeecg.modules.adweb.seo.entity.SeoKeywords;
@@ -34,4 +35,7 @@ public interface ISeoKeywordsService extends IService<SeoKeywords> {
                                       String buttonColumn,
                                       String buttonSort,
                                       List<String> dateList) throws ParseException;
+
+    IPage<SeoKeywords> pageList(Page<SeoKeywords> page, String siteCode, String keywords, String subscriptionId, String lastSearchTime, String createTime, Integer keywordType,
+                                String column, String order, Integer keywordRank);
 }

+ 18 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java

@@ -1993,4 +1993,22 @@ public class SysBaseApiImpl implements ISysBaseAPI {
 		}
 		return true;
 	}
+
+	/**
+	 * @param siteId
+	 * @return
+	 */
+	public JSONObject getSiteInfoById(String siteId) {
+		JSONObject json = new JSONObject();
+		QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
+		queryWrapper.eq("id", siteId);
+		queryWrapper.ne("status", 0);
+		AdwebSite adwebSite = adwebSiteService.getOne(queryWrapper);
+		if (adwebSite != null) {
+			json.put("code", adwebSite.getCode());
+			json.put("keywordsNum", adwebSite.getKeywordsNum());
+			json.put("data", adwebSite);
+		}
+		return json;
+	}
 }