Explorar o código

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

chenpeiqing hai 4 meses
pai
achega
b512250fe6
Modificáronse 14 ficheiros con 1232 adicións e 104 borrados
  1. 25 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/AdaptiveWidthUtils.java
  2. 294 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/controller/AdwebPublicEnquriyRuleController.java
  3. 559 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/controller/AdwebSiteBlackEmailController.java
  4. 231 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/controller/AdwebSiteEnquiryRuleController.java
  5. 32 18
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/entity/AdwebSiteEnquiryRule.java
  6. 4 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/AdwebSiteBlackEmailMapper.java
  7. 3 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/AdwebSiteEnquiryRuleMapper.java
  8. 10 10
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebEnquirySiteRuleMapper.xml
  9. 20 20
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebPublicEnquiryRuleMapper.xml
  10. 3 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebSiteBlackEmailMapper.xml
  11. 6 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/IAdwebSiteBlackEmailService.java
  12. 3 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/IAdwebSiteEnquiryRuleService.java
  13. 35 35
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebSiteBlackEmailServiceImpl.java
  14. 7 6
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebSiteEnquiryRuleServiceImpl.java

+ 25 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/common/util/AdaptiveWidthUtils.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.adweb.common.util;
+
+import org.apache.poi.ss.usermodel.Sheet;
+
+
+public class AdaptiveWidthUtils {
+    /**
+     * 自适应宽度(中文支持)
+     *
+     * @param sheet sheet
+     * @param size  因为for循环从0开始,size值为 列数-1
+     */
+    public static void setSizeColumn(Sheet sheet, int size) {
+        for (int i = 0; i < size; i++) {
+            int orgWidth = sheet.getColumnWidth(i);
+            sheet.autoSizeColumn(i, true);
+            int newWidth = (int) (sheet.getColumnWidth(i) + 100);
+            int maxWith = 256 * 255;
+            //限制下最大宽度
+            if (newWidth > maxWith) {
+                sheet.setColumnWidth(i, maxWith);
+            } else sheet.setColumnWidth(i, Math.max(newWidth, orgWidth));
+        }
+    }
+}

+ 294 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/controller/AdwebPublicEnquriyRuleController.java

@@ -0,0 +1,294 @@
+package org.jeecg.modules.adweb.enquiry.controller;
+
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelReader;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.adweb.common.util.AdaptiveWidthUtils;
+import org.jeecg.modules.adweb.enquiry.entity.AdwebPublicEnquiryRule;
+import org.jeecg.modules.adweb.enquiry.service.IAdwebPublicEnquiryRuleService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: 用于询盘规则过滤
+ * @Author: jeecg-boot
+ * @Date: 2023-02-01
+ * @Version: V1.0
+ */
+@Tag(name = "用于询盘规则过滤")
+@RestController
+@RequestMapping("/adweb/adwebEnquiryRule")
+@Slf4j
+public class AdwebPublicEnquriyRuleController extends JeecgController<AdwebPublicEnquiryRule, IAdwebPublicEnquiryRuleService> {
+    @Resource
+    private IAdwebPublicEnquiryRuleService adwebEnquiryRuleService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param adwebEnquiryRule
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "用于询盘规则过滤-分页列表查询")
+    @Operation(summary = "用于询盘规则过滤-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<?> queryPageList(AdwebPublicEnquiryRule adwebEnquiryRule,
+                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                   HttpServletRequest req) {
+        Page<AdwebPublicEnquiryRule> page = new Page<AdwebPublicEnquiryRule>(pageNo, pageSize);
+        String column = req.getParameter("column");
+        String order = req.getParameter("order");
+        IPage<AdwebPublicEnquiryRule> pageList = getPageList(page, adwebEnquiryRule, column, order);
+        return Result.OK(pageList);
+    }
+
+    public IPage<AdwebPublicEnquiryRule> getPageList(Page<AdwebPublicEnquiryRule> page, AdwebPublicEnquiryRule adwebEnquiryRule, String column, String order) {
+        IPage<AdwebPublicEnquiryRule> pageList = adwebEnquiryRuleService.pageList(page, adwebEnquiryRule.getWord(), adwebEnquiryRule.getBlackOrWhiteList(), adwebEnquiryRule.getIsEnable(), adwebEnquiryRule.getUseStatus(), column, order);
+        return pageList;
+    }
+
+    /**
+     * 添加
+     *
+     * @param adwebEnquiryRule
+     * @return
+     */
+    @AutoLog(value = "用于询盘规则过滤-添加")
+    @Operation(summary = "用于询盘规则过滤-添加")
+    @PostMapping(value = "/add")
+    public Result<?> add(@RequestBody AdwebPublicEnquiryRule adwebEnquiryRule) {
+        if (StringUtils.isBlank(adwebEnquiryRule.getWord())) {
+            return Result.error("规则关键词不能为空");
+        }
+
+        adwebEnquiryRule.setWord(adwebEnquiryRule.getWord().replaceAll(" {2,}", " ").trim().toLowerCase());
+
+        int count = (int) adwebEnquiryRuleService.count(new QueryWrapper<AdwebPublicEnquiryRule>().eq("word", adwebEnquiryRule.getWord()).ne("status", 0).eq("use_status", adwebEnquiryRule.getUseStatus()));
+        if (count > 0) {
+            return Result.error("规则关键词已存在");
+        }
+
+        adwebEnquiryRule.setStatus(1);
+        adwebEnquiryRuleService.save(adwebEnquiryRule);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param adwebEnquiryRule
+     * @return
+     */
+    @AutoLog(value = "用于询盘规则过滤-编辑")
+    @Operation(summary = "用于询盘规则过滤-编辑")
+    @PutMapping(value = "/edit")
+    public Result<?> edit(@RequestBody AdwebPublicEnquiryRule adwebEnquiryRule) {
+        if (StringUtils.isBlank(adwebEnquiryRule.getWord())) {
+            return Result.error("规则关键词不能为空");
+        }
+
+        adwebEnquiryRule.setWord(adwebEnquiryRule.getWord().replaceAll(" {2,}", " ").trim().toLowerCase());
+
+        int count = (int) adwebEnquiryRuleService.count(new QueryWrapper<AdwebPublicEnquiryRule>().eq("word", adwebEnquiryRule.getWord()).ne("status", 0).ne("id", adwebEnquiryRule.getId()).eq("use_status", adwebEnquiryRule.getUseStatus()));
+
+        if (count > 0) {
+            return Result.error("规则关键词已存在");
+        }
+
+        adwebEnquiryRuleService.updateById(adwebEnquiryRule);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "用于询盘规则过滤-通过id删除")
+    @Operation(summary = "用于询盘规则过滤-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+
+        if (id == null) {
+            return Result.error("参数不识别!");
+        }
+        boolean update = adwebEnquiryRuleService.update(new UpdateWrapper<AdwebPublicEnquiryRule>().set("status", 0).eq("id", id));
+
+        return update ? Result.OK("删除成功!") : Result.error("删除失败!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "用于询盘规则过滤-批量删除")
+    @Operation(summary = "用于询盘规则过滤-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        if (ids == null) {
+            return Result.error("参数不识别!");
+        }
+        List<String> idList = Arrays.asList(ids.split(","));
+        boolean update = adwebEnquiryRuleService.update(new UpdateWrapper<AdwebPublicEnquiryRule>().set("status", 0).in("id", idList));
+        return update ? Result.OK("批量删除成功!") : Result.error("批量删除失败!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "用于询盘规则过滤-通过id查询")
+    @Operation(summary = "用于询盘规则过滤-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
+        if (StringUtils.isNotBlank(id)) {
+            return Result.error("参数不识别!");
+        }
+
+        AdwebPublicEnquiryRule adwebEnquiryRule = adwebEnquiryRuleService.getById(id);
+        if (adwebEnquiryRule == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(adwebEnquiryRule);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param adwebEnquiryRule
+     */
+    @RequestMapping(value = "/exportXls")
+    public void exportXls(HttpServletRequest request, AdwebPublicEnquiryRule adwebEnquiryRule, HttpServletResponse response) {
+        Page<AdwebPublicEnquiryRule> page = new Page<AdwebPublicEnquiryRule>(1, -1);
+        String column = request.getParameter("column");
+        String order = request.getParameter("order");
+        List<AdwebPublicEnquiryRule> list = getPageList(page, adwebEnquiryRule, column, order).getRecords();
+//		QueryWrapper<AdwebPublicEnquiryRule> queryWrapper = QueryGenerator.initQueryWrapper(adwebEnquiryRule, request.getParameterMap());
+//		queryWrapper.ne("status", 0);
+//		List<AdwebPublicEnquiryRule> list = adwebEnquiryRuleService.list(queryWrapper);
+        // 通过工具类创建writer,默认创建xls格式
+        ExcelWriter writer = ExcelUtil.getWriter(true);
+
+        writer.addHeaderAlias("word", "关键词");
+        writer.addHeaderAlias("translateWord", "关键词翻译");
+        writer.addHeaderAlias("blackOrWhiteList", "黑白名单");
+        writer.addHeaderAlias("isEnable", "是否启用");
+        writer.addHeaderAlias("useStatus", "作用域");
+        // 默认的,未添加alias的属性也会写出,如果想只写出加了别名的字段,可以调用此方法排除之
+        writer.setOnlyAlias(true);
+
+        StringBuilder fileName = new StringBuilder();
+        fileName.append("用于询盘规则过滤");
+
+        response.setContentType("application/vnd.ms-excel;charset=utf-8");
+        // test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
+        ServletOutputStream out = null;
+        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);
+            AdaptiveWidthUtils.setSizeColumn(sheet, 3);
+            // 写出到文件
+            writer.flush(out, true);
+            // 关闭writer,释放内存
+            writer.close();
+            // 此处记得关闭输出Servlet流
+            IoUtil.close(out);
+        } catch (IOException e) {
+            log.error(e.getMessage());
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(@RequestParam("file") MultipartFile file) {
+        try {
+            //字节输入流
+            InputStream inputStream = file.getInputStream();
+            //通过输入流创建ExcelReader 对象
+            ExcelReader reader = ExcelUtil.getReader(inputStream);
+            //这个同上导入
+            reader.addHeaderAlias("关键词", "word");
+            reader.addHeaderAlias("关键词翻译", "translateWord");
+            reader.addHeaderAlias("黑白名单", "blackOrWhiteList");
+            reader.addHeaderAlias("是否启用", "isEnable");
+            reader.addHeaderAlias("作用域", "useStatus");
+
+            List<AdwebPublicEnquiryRule> rulesList = reader.readAll(AdwebPublicEnquiryRule.class);
+
+            if (rulesList.isEmpty()) {
+                return Result.error("导入数据异常!");
+            }
+
+            for (AdwebPublicEnquiryRule adwebEnquiryRule : rulesList) {
+                UpdateWrapper updateWrapper = new UpdateWrapper();
+                updateWrapper.eq("word", adwebEnquiryRule.getWord());
+                updateWrapper.ne("status", 0);
+                updateWrapper.eq("use_status", 0);
+                updateWrapper.set("translate_word", adwebEnquiryRule.getTranslateWord());
+                adwebEnquiryRuleService.update(updateWrapper);
+            }
+
+            List<String> wordList = rulesList.stream().map(AdwebPublicEnquiryRule::getWord).collect(Collectors.toList());
+            List<AdwebPublicEnquiryRule> adwebEnquiryRules = adwebEnquiryRuleService.list(new QueryWrapper<AdwebPublicEnquiryRule>().in("word", wordList).ne("status", 0).select("word").eq("use_status", 0));
+            List<String> adwebEnquiryRuleList = adwebEnquiryRules.stream().map(AdwebPublicEnquiryRule::getWord).collect(Collectors.toList());
+
+            List<AdwebPublicEnquiryRule> collect = rulesList.stream().filter(adwebEnquiryRule -> !adwebEnquiryRuleList.contains(adwebEnquiryRule.getWord())).collect(Collectors.toList());
+
+            collect.forEach(adwebEnquiryRule -> adwebEnquiryRule.setStatus(1));
+
+            if (CollectionUtils.isNotEmpty(collect)) {
+                adwebEnquiryRuleService.saveBatch(collect);
+            }
+            return Result.OK("文件导入成功!数据行数:" + rulesList.size() + ",重复数据行数:" + adwebEnquiryRules.size() + ",导入数据行数:" + collect.size());
+        } catch (IOException e) {
+            e.printStackTrace();
+            return Result.error("文件导入失败!失败信息:" + e.getMessage());
+        }
+    }
+
+}

+ 559 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/controller/AdwebSiteBlackEmailController.java

@@ -0,0 +1,559 @@
+package org.jeecg.modules.adweb.enquiry.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.SecurityUtils;
+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.vo.LoginUser;
+import org.jeecg.common.util.RedisUtil;
+import org.jeecg.modules.adweb.enquiry.entity.AdwebEnquiryBlacklist;
+import org.jeecg.modules.adweb.enquiry.entity.AdwebPublicBlackEmail;
+import org.jeecg.modules.adweb.enquiry.entity.AdwebSiteBlackEmail;
+import org.jeecg.modules.adweb.enquiry.service.IAdwebEnquiryBlacklistService;
+import org.jeecg.modules.adweb.enquiry.service.IAdwebPublicBlackEmailService;
+import org.jeecg.modules.adweb.enquiry.service.IAdwebSiteBlackEmailService;
+import org.jeecg.modules.adweb.site.entity.AdwebSite;
+import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
+import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: AdwebSiteBlackEmailController.java;
+ * @Author: chenpeiqing
+ * @Date: 2024/11/1 : 17:22
+ * @Version: V1.0
+ */
+@Tag(name = "adweb_site_black_email")
+@RestController
+@RequestMapping("/adweb/enquirySiteBlackEmail")
+@Slf4j
+public class AdwebSiteBlackEmailController extends JeecgController<AdwebSiteBlackEmail, IAdwebSiteBlackEmailService> {
+
+    @Resource
+    private IAdwebSiteBlackEmailService enquirySiteBlackEmailService;
+    @Resource
+    private RedisUtil redisUtil;
+    @Resource
+    private ISysBaseAPI sysBaseAPI;
+
+    @Resource
+    private IAdwebSiteService adwebSiteService;
+    @Resource
+    private ISiteUserPermissionService siteUserPermissionService;
+    @Resource
+    private IAdwebPublicBlackEmailService enquiryPublicBlackEmailService;
+    @Resource
+    private IAdwebEnquiryBlacklistService adwebEnquiryBlacklistService;
+
+
+    private static final String SiteBlackEmailKey = "SITE_BLACK_EMAIL_LIST";
+    private static final String SiteWhiteEmailListKey = "SITE_WHITE_EMAIL_LIST";
+    private static final String SiteEmailTenMinKey = "JUDGE_WASTE_SITE_ENQUIRY_EMAIL_BY_10_MIN::";
+    private static final String SiteEmailOneDayKey = "JUDGE_WASTE_SITE_ENQUIRY_EMAIL_BY_ONE_DAY::";
+    private static final String NotBlackEmailWasteSiteEnquiryKey = "NOT_BLACK_EMAIL_WASTE_SITE_ENQUIRY_MAP::";
+    //	private static final String EmailTenMinKey = "JUDGE_WASTE_ENQUIRY_EMAIL_BY_10_MIN::";
+//	private static final String EmailOneDayKey = "JUDGE_WASTE_ENQUIRY_EMAIL_BY_ONE_DAY::";
+//	private static final String NotBlackEmailWasteEnquiryKey = "NOT_BLACK_EMAIL_WASTE_ENQUIRY_MAP::";
+    private static final String BlackEmailKey = "BLACK_EMAIL_LIST";
+
+    /**
+     * 分页列表查询
+     *
+     * @param enquirySiteBlackEmail
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "adweb_site_black_email-分页列表查询")
+    @Operation(summary = "adweb_site_black_email-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<?> queryPageList(AdwebSiteBlackEmail enquirySiteBlackEmail,
+                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                   HttpServletRequest req) {
+        Page<AdwebSiteBlackEmail> page = new Page<AdwebSiteBlackEmail>(pageNo, pageSize);
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        List<String> codeList = null;
+        List<String> uidList = null;
+        if (sysBaseAPI.isAdmin()) {
+
+        } else if (sysBaseAPI.isOem()) {
+            uidList = sysBaseAPI.getOemGroupUids();
+        } else {
+            uidList = new ArrayList<>();
+            uidList.add(sysUser.getId());
+        }
+        List<String> siteCodeList = null;
+        if (CollectionUtils.isNotEmpty(uidList)) {
+            siteCodeList = siteUserPermissionService.getSiteCodeListByUids(uidList);
+        }
+
+        if (enquirySiteBlackEmail.getSiteId() != null) {
+            String siteCode = adwebSiteService.getSiteCodeById(enquirySiteBlackEmail.getSiteId());
+            if (StringUtils.isNotBlank(siteCode)) {
+                QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("id", enquirySiteBlackEmail.getSiteId()).or().eq("parent_group_code", siteCode);
+                queryWrapper.ne("status", 0);
+                queryWrapper.in(!sysBaseAPI.isAdmin(), "code", siteCodeList);
+                codeList = adwebSiteService.list(queryWrapper).stream().map(AdwebSite::getCode).collect(Collectors.toList());
+            }
+        } else {
+            codeList = siteCodeList;
+        }
+        String column = req.getParameter("column");
+        String order = req.getParameter("order");
+        IPage<AdwebSiteBlackEmail> pageList = enquirySiteBlackEmailService.pageList(page, enquirySiteBlackEmail, codeList, column, order);
+        List<AdwebSiteBlackEmail> record = pageList.getRecords();
+
+        if (CollectionUtils.isNotEmpty(record)) {
+            for (AdwebSiteBlackEmail enquirySiteBlackEmail1 : record) {
+                if (enquirySiteBlackEmail1.getType().equals("0")) {
+                    if (enquirySiteBlackEmail1.getWasteGeneralEnquiryNum() != null) {
+                        enquirySiteBlackEmail1.setWasteEnquiryNum(enquirySiteBlackEmail1.getWasteGeneralEnquiryNum());
+                    }
+                }
+            }
+        }
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 添加
+     *
+     * @param enquirySiteBlackEmail
+     * @return
+     */
+    @AutoLog(value = "adweb_site_black_email-添加")
+    @Operation(summary = "adweb_site_black_email-添加")
+    @PostMapping(value = "/add")
+    public Result<?> add(@RequestBody AdwebSiteBlackEmail enquirySiteBlackEmail) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        if (StringUtils.isBlank(enquirySiteBlackEmail.getEmail())) {
+            return Result.error("邮箱不能为空");
+        }
+
+        //将邮箱转换为小写
+        enquirySiteBlackEmail.setEmail(enquirySiteBlackEmail.getEmail().trim().toLowerCase());
+
+        int count = (int) enquirySiteBlackEmailService.count(new QueryWrapper<AdwebSiteBlackEmail>().ne("status", 0).eq("email", enquirySiteBlackEmail.getEmail())
+                .eq("site_id", enquirySiteBlackEmail.getSiteId()).eq("type", enquirySiteBlackEmail.getType()));
+
+        if (count > 0) {
+            return Result.error("邮箱已存在");
+        }
+
+        //判断站点询盘黑名单是否存在添加进来的黑名单
+        QueryWrapper<AdwebEnquiryBlacklist> adwebEnquiryBlacklistQueryWrapper = new QueryWrapper<>();
+        adwebEnquiryBlacklistQueryWrapper.eq("site_id", enquirySiteBlackEmail.getSiteId());
+        adwebEnquiryBlacklistQueryWrapper.eq("status", 1);
+        adwebEnquiryBlacklistQueryWrapper.eq("email", enquirySiteBlackEmail.getEmail());
+        List<AdwebEnquiryBlacklist> enquiryBlacklists = adwebEnquiryBlacklistService.list(adwebEnquiryBlacklistQueryWrapper);
+
+        if (CollectionUtils.isNotEmpty(enquiryBlacklists)) {
+            return Result.error("在拒收的邮箱黑名单中已存在!");
+        }
+
+        enquirySiteBlackEmail.setStatus(1);
+        enquirySiteBlackEmail.setCreateTime(new Date());
+        enquirySiteBlackEmailService.save(enquirySiteBlackEmail);
+
+        Map<String, List<String>> enquirySiteBlackEmailListMap = enquirySiteBlackEmailService.getSiteBlackEmailListBySiteId(enquirySiteBlackEmail.getSiteId());
+        List<String> emailList = enquirySiteBlackEmailListMap.get("black");
+        List<String> whiteEmailList = enquirySiteBlackEmailListMap.get("white");
+
+        //处理对应站点的黑名单
+        if (CollectionUtils.isNotEmpty(emailList)) {
+            redisUtil.set(SiteBlackEmailKey + "::" + enquirySiteBlackEmail.getSiteId(), emailList, 60 * 60 * 24);
+        } else {
+            redisUtil.del(SiteBlackEmailKey + "::" + enquirySiteBlackEmail.getSiteId());
+        }
+
+        //处理对应站点的白名单
+        if (CollectionUtils.isNotEmpty(whiteEmailList)) {
+            redisUtil.set(SiteWhiteEmailListKey + "::" + enquirySiteBlackEmail.getSiteId(), whiteEmailList, 60 * 60 * 24);
+        } else {
+            redisUtil.del(SiteWhiteEmailListKey + "::" + enquirySiteBlackEmail.getSiteId());
+        }
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param enquirySiteBlackEmail
+     * @return
+     */
+    @AutoLog(value = "adweb_site_black_email-编辑")
+    @Operation(summary = "adweb_site_black_email-编辑")
+    @PutMapping(value = "/edit")
+    public Result<?> edit(@RequestBody AdwebSiteBlackEmail enquirySiteBlackEmail) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        if (StringUtils.isBlank(enquirySiteBlackEmail.getEmail())) {
+            return Result.error("邮箱不能为空");
+        }
+
+        //将邮箱转换为小写
+        enquirySiteBlackEmail.setEmail(enquirySiteBlackEmail.getEmail().trim().toLowerCase());
+
+        int count = (int) enquirySiteBlackEmailService.count(new QueryWrapper<AdwebSiteBlackEmail>().ne("status", 0).eq("email", enquirySiteBlackEmail.getEmail()).eq("site_id", enquirySiteBlackEmail.getSiteId()).eq("black_or_white", enquirySiteBlackEmail.getBlackOrWhite()).ne("id", enquirySiteBlackEmail.getId()));
+
+        if (count > 0) {
+            return Result.error("邮箱已存在");
+        }
+
+        //判断站点询盘黑名单是否存在添加进来的黑名单
+        QueryWrapper<AdwebEnquiryBlacklist> adwebEnquiryBlacklistQueryWrapper = new QueryWrapper<>();
+        adwebEnquiryBlacklistQueryWrapper.eq("site_id", enquirySiteBlackEmail.getSiteId());
+        adwebEnquiryBlacklistQueryWrapper.eq("status", 1);
+        adwebEnquiryBlacklistQueryWrapper.eq("email", enquirySiteBlackEmail.getEmail());
+        List<AdwebEnquiryBlacklist> enquiryBlacklists = adwebEnquiryBlacklistService.list(adwebEnquiryBlacklistQueryWrapper);
+
+        if (CollectionUtils.isNotEmpty(enquiryBlacklists)) {
+            return Result.error("在拒收的邮箱黑名单中已存在!");
+        }
+
+        AdwebSiteBlackEmail oldAdwebSiteBlackEmail = enquirySiteBlackEmailService.getById(enquirySiteBlackEmail.getId());
+
+        //判断公共询盘缓存的是否包含历史的黑名单数据
+        if (!oldAdwebSiteBlackEmail.getEmail().equals(enquirySiteBlackEmail.getEmail())) {
+            List<AdwebPublicBlackEmail> emailList = enquiryPublicBlackEmailService.list(new QueryWrapper<AdwebPublicBlackEmail>().eq("status", 1).eq("black_or_white", 0));
+            List<String> pubicBlackEmailList = emailList.stream().map(AdwebPublicBlackEmail::getEmail).collect(Collectors.toList());
+
+            List<String> publicBlackList = (List<String>) redisUtil.get(BlackEmailKey);
+
+            publicBlackList.removeAll(pubicBlackEmailList);
+            if (CollectionUtils.isNotEmpty(publicBlackList)) {
+                for (int i = 0; i < publicBlackList.size(); i++) {
+                    String oldEmail = oldAdwebSiteBlackEmail.getEmail();
+                    if (oldAdwebSiteBlackEmail.getType().equals("0")) {
+                        oldEmail = "*" + oldEmail + "*";
+                    }
+                    if (oldEmail.equals(publicBlackList.get(i))) {
+                        publicBlackList.remove(i);
+                        break;
+                    }
+                }
+                pubicBlackEmailList.addAll(publicBlackList);
+                redisUtil.set(BlackEmailKey, pubicBlackEmailList, 60 * 60 * 24);
+            }
+        }
+
+        enquirySiteBlackEmail.setUpdateTime(new Date());
+        enquirySiteBlackEmailService.updateById(enquirySiteBlackEmail);
+
+        QueryWrapper<AdwebSiteBlackEmail> siteAllEmailQueryWrapper = new QueryWrapper<>();
+        siteAllEmailQueryWrapper.ne("status", 0);
+        siteAllEmailQueryWrapper.eq("site_id", enquirySiteBlackEmail.getSiteId());
+        List<AdwebSiteBlackEmail> allEmailList = enquirySiteBlackEmailService.list(siteAllEmailQueryWrapper);
+        if (CollectionUtils.isEmpty(allEmailList)) {
+            log.info("未获取到对应站点的黑白名单数据");
+        }
+
+        Map<String, List<String>> enquirySiteBlackEmailListMap = enquirySiteBlackEmailService.getSiteBlackEmailListBySiteId(enquirySiteBlackEmail.getSiteId());
+        List<String> emailList = enquirySiteBlackEmailListMap.get("black");
+        List<String> whiteEmailList = enquirySiteBlackEmailListMap.get("white");
+
+        //处理对应站点的黑名单
+        if (CollectionUtils.isNotEmpty(emailList)) {
+            redisUtil.set(SiteBlackEmailKey + "::" + enquirySiteBlackEmail.getSiteId(), emailList, 60 * 60 * 24);
+        } else {
+            redisUtil.del(SiteBlackEmailKey + "::" + enquirySiteBlackEmail.getSiteId());
+        }
+
+        //处理对应站点的白名单
+        if (CollectionUtils.isNotEmpty(whiteEmailList)) {
+            redisUtil.set(SiteWhiteEmailListKey + "::" + enquirySiteBlackEmail.getSiteId(), whiteEmailList, 60 * 60 * 24);
+        } else {
+            redisUtil.del(SiteWhiteEmailListKey + "::" + enquirySiteBlackEmail.getSiteId());
+        }
+
+        //处理站点改变的数据缓存
+        if (!oldAdwebSiteBlackEmail.getSiteId().equals(enquirySiteBlackEmail.getSiteId())) {
+            Map<String, List<String>> oldAdwebSiteBlackEmailListMap = enquirySiteBlackEmailService.getSiteBlackEmailListBySiteId(oldAdwebSiteBlackEmail.getSiteId());
+            List<String> oldEmailList = oldAdwebSiteBlackEmailListMap.get("black");
+            List<String> oldWhiteEmailList = oldAdwebSiteBlackEmailListMap.get("white");
+            //处理对应站点的黑名单
+            if (CollectionUtils.isNotEmpty(oldEmailList)) {
+                redisUtil.set(SiteBlackEmailKey + "::" + oldAdwebSiteBlackEmail.getSiteId(), oldEmailList, 60 * 60 * 24);
+            } else {
+                redisUtil.del(SiteBlackEmailKey + "::" + oldAdwebSiteBlackEmail.getSiteId());
+            }
+
+            //处理对应站点的白名单
+            if (CollectionUtils.isNotEmpty(oldWhiteEmailList)) {
+                redisUtil.set(SiteWhiteEmailListKey + "::" + oldAdwebSiteBlackEmail.getSiteId(), oldWhiteEmailList, 60 * 60 * 24);
+            } else {
+                redisUtil.del(SiteWhiteEmailListKey + "::" + oldAdwebSiteBlackEmail.getSiteId());
+            }
+        }
+
+
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "adweb_site_black_email-通过id删除")
+    @Operation(summary = "adweb_site_black_email-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        if (StringUtils.isBlank(id)) {
+            return Result.error("参数不识别!");
+        }
+        AdwebSiteBlackEmail enquirySiteBlackEmail = enquirySiteBlackEmailService.getById(id);
+        if (enquirySiteBlackEmail == null) {
+            return Result.error("未找到对应数据");
+        }
+
+        //判断公共询盘缓存的是否包含历史的黑名单数据
+        List<AdwebPublicBlackEmail> pubicEmailList = enquiryPublicBlackEmailService.list(new QueryWrapper<AdwebPublicBlackEmail>().eq("status", 1).eq("black_or_white", 0));
+        List<String> pubicBlackEmailList = pubicEmailList.stream().map(AdwebPublicBlackEmail::getEmail).collect(Collectors.toList());
+
+        List<String> publicBlackList = (List<String>) redisUtil.get(BlackEmailKey);
+
+        if (CollectionUtils.isNotEmpty(publicBlackList)) {
+            if (CollectionUtils.isNotEmpty(pubicBlackEmailList)) {
+                publicBlackList.removeAll(pubicBlackEmailList);
+            } else {
+                pubicBlackEmailList = new ArrayList<>();
+            }
+            for (int i = 0; i < publicBlackList.size(); i++) {
+                String oldEmail = enquirySiteBlackEmail.getEmail();
+                if (enquirySiteBlackEmail.getType().equals("0")) {
+                    oldEmail = "*" + oldEmail + "*";
+                }
+                if (oldEmail.equals(publicBlackList.get(i))) {
+                    publicBlackList.remove(i);
+                    break;
+                }
+            }
+            pubicBlackEmailList.addAll(publicBlackList);
+            redisUtil.set(BlackEmailKey, pubicBlackEmailList, 60 * 60 * 24);
+        }
+        enquirySiteBlackEmail.setStatus(0);
+        enquirySiteBlackEmail.setUpdateTime(new Date());
+        enquirySiteBlackEmailService.updateById(enquirySiteBlackEmail);
+
+        redisUtil.del(SiteEmailTenMinKey + enquirySiteBlackEmail.getSiteId() + "::" + enquirySiteBlackEmail.getEmail());
+        redisUtil.del(SiteEmailOneDayKey + enquirySiteBlackEmail.getSiteId() + "::" + enquirySiteBlackEmail.getEmail());
+        redisUtil.del(NotBlackEmailWasteSiteEnquiryKey + enquirySiteBlackEmail.getSiteId() + "::" + enquirySiteBlackEmail.getEmail());
+
+        QueryWrapper<AdwebSiteBlackEmail> siteAllEmailQueryWrapper = new QueryWrapper<>();
+        siteAllEmailQueryWrapper.ne("status", 0);
+        siteAllEmailQueryWrapper.eq("site_id", enquirySiteBlackEmail.getSiteId());
+        List<AdwebSiteBlackEmail> allEmailList = enquirySiteBlackEmailService.list(siteAllEmailQueryWrapper);
+        if (CollectionUtils.isEmpty(allEmailList)) {
+            log.info("未获取到对应站点的黑白名单数据");
+        }
+
+        List<String> emailList = new ArrayList<>();
+        List<String> whiteEmailList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(allEmailList)) {
+            for (AdwebSiteBlackEmail enquirySiteBlackEmail1 : allEmailList) {
+                if (enquirySiteBlackEmail1.getBlackOrWhite() == 0) {
+                    if (enquirySiteBlackEmail1.getType().equals("0")) {
+                        emailList.add("*" + enquirySiteBlackEmail1.getEmail() + "*");
+                    } else {
+                        emailList.add(enquirySiteBlackEmail1.getEmail());
+                    }
+                } else {
+                    if (enquirySiteBlackEmail1.getType().equals("0")) {
+                        whiteEmailList.add("*" + enquirySiteBlackEmail1.getEmail() + "*");
+                    } else {
+                        whiteEmailList.add(enquirySiteBlackEmail1.getEmail());
+                    }
+                }
+            }
+        }
+        //处理对应站点的黑名单
+        if (CollectionUtils.isNotEmpty(emailList)) {
+            redisUtil.set(SiteBlackEmailKey + "::" + enquirySiteBlackEmail.getSiteId(), emailList, 60 * 60 * 24);
+        } else {
+            redisUtil.del(SiteBlackEmailKey + "::" + enquirySiteBlackEmail.getSiteId());
+        }
+
+        //处理对应站点的白名单
+        if (CollectionUtils.isNotEmpty(whiteEmailList)) {
+            redisUtil.set(SiteWhiteEmailListKey + "::" + enquirySiteBlackEmail.getSiteId(), whiteEmailList, 60 * 60 * 24);
+        } else {
+            redisUtil.del(SiteWhiteEmailListKey + "::" + enquirySiteBlackEmail.getSiteId());
+        }
+
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "adweb_site_black_email-批量删除")
+    @Operation(summary = "adweb_site_black_email-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        if (StringUtils.isBlank(ids)) {
+            return Result.error("参数不识别!");
+        }
+
+        List<String> idList = Arrays.asList(ids.split(","));
+
+        List<AdwebSiteBlackEmail> list = enquirySiteBlackEmailService.list(new QueryWrapper<AdwebSiteBlackEmail>().in("id", idList).ne("status", 0));
+
+        if (list.isEmpty()) {
+            return Result.error("未找到对应数据");
+        }
+
+        boolean update = enquirySiteBlackEmailService.update(new UpdateWrapper<AdwebSiteBlackEmail>().in("id", idList).set("status", 0));
+
+        HashSet<Integer> siteList = new HashSet<>();
+        //删除redis中的数据
+        for (AdwebSiteBlackEmail enquirySiteBlackEmail : list) {
+
+            //判断公共询盘缓存的是否包含历史的黑名单数据
+            List<AdwebPublicBlackEmail> pubicEmailList = enquiryPublicBlackEmailService.list(new QueryWrapper<AdwebPublicBlackEmail>().eq("status", 1).eq("black_or_white", 0));
+            List<String> pubicBlackEmailList = pubicEmailList.stream().map(AdwebPublicBlackEmail::getEmail).collect(Collectors.toList());
+
+            List<String> publicBlackList = (List<String>) redisUtil.get(BlackEmailKey);
+
+            if (CollectionUtils.isNotEmpty(publicBlackList)) {
+                if (CollectionUtils.isNotEmpty(pubicBlackEmailList)) {
+                    publicBlackList.removeAll(pubicBlackEmailList);
+                } else {
+                    pubicBlackEmailList = new ArrayList<>();
+                }
+                for (int i = 0; i < publicBlackList.size(); i++) {
+                    String oldEmail = enquirySiteBlackEmail.getEmail();
+                    if (enquirySiteBlackEmail.getType().equals("0")) {
+                        oldEmail = "*" + oldEmail + "*";
+                    }
+                    if (oldEmail.equals(publicBlackList.get(i))) {
+                        publicBlackList.remove(i);
+                        break;
+                    }
+                }
+                pubicBlackEmailList.addAll(publicBlackList);
+                redisUtil.set(BlackEmailKey, pubicBlackEmailList, 60 * 60 * 24);
+            }
+
+            redisUtil.del(SiteEmailTenMinKey + enquirySiteBlackEmail.getSiteId() + "::" + enquirySiteBlackEmail.getEmail());
+            redisUtil.del(SiteEmailOneDayKey + enquirySiteBlackEmail.getSiteId() + "::" + enquirySiteBlackEmail.getEmail());
+            redisUtil.del(NotBlackEmailWasteSiteEnquiryKey + enquirySiteBlackEmail.getSiteId() + "::" + enquirySiteBlackEmail.getEmail());
+            siteList.add(enquirySiteBlackEmail.getSiteId());
+        }
+
+
+        for (Integer siteId : siteList) {
+            QueryWrapper<AdwebSiteBlackEmail> siteAllEmailQueryWrapper = new QueryWrapper<>();
+            siteAllEmailQueryWrapper.ne("status", 0);
+            siteAllEmailQueryWrapper.eq("site_id", siteId);
+            List<AdwebSiteBlackEmail> allEmailList = enquirySiteBlackEmailService.list(siteAllEmailQueryWrapper);
+            if (CollectionUtils.isEmpty(allEmailList)) {
+                log.info("未获取到对应站点的黑白名单数据");
+            }
+
+            List<String> emailList = new ArrayList<>();
+            List<String> whiteEmailList = new ArrayList<>();
+            if (CollectionUtils.isNotEmpty(allEmailList)) {
+                for (AdwebSiteBlackEmail enquirySiteBlackEmail : allEmailList) {
+                    if (enquirySiteBlackEmail.getBlackOrWhite() == 0) {
+                        if (enquirySiteBlackEmail.getType().equals("0")) {
+                            emailList.add("*" + enquirySiteBlackEmail.getEmail() + "*");
+                        } else {
+                            emailList.add(enquirySiteBlackEmail.getEmail());
+                        }
+                    } else {
+                        if (enquirySiteBlackEmail.getType().equals("0")) {
+                            whiteEmailList.add("*" + enquirySiteBlackEmail.getEmail() + "*");
+                        } else {
+                            whiteEmailList.add(enquirySiteBlackEmail.getEmail());
+                        }
+                    }
+                }
+            }
+            //处理对应站点的黑名单
+            if (CollectionUtils.isNotEmpty(emailList)) {
+                redisUtil.set(SiteBlackEmailKey + "::" + siteId, emailList, 60 * 60 * 24);
+            } else {
+                redisUtil.del(SiteBlackEmailKey + "::" + siteId);
+            }
+
+            //处理对应站点的白名单
+            if (CollectionUtils.isNotEmpty(whiteEmailList)) {
+                redisUtil.set(SiteWhiteEmailListKey + "::" + siteId, whiteEmailList, 60 * 60 * 24);
+            } else {
+                redisUtil.del(SiteWhiteEmailListKey + "::" + siteId);
+            }
+        }
+        return update ? Result.OK("批量删除成功!") : Result.error("批量删除失败!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "adweb_site_black_email-通过id查询")
+    @Operation(summary = "adweb_site_black_email-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
+        AdwebSiteBlackEmail enquirySiteBlackEmail = enquirySiteBlackEmailService.getById(id);
+        if (enquirySiteBlackEmail == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(enquirySiteBlackEmail);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param enquirySiteBlackEmail
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, AdwebSiteBlackEmail enquirySiteBlackEmail) {
+        return super.exportXls(request, enquirySiteBlackEmail, AdwebSiteBlackEmail.class, "adweb_site_black_email");
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, AdwebSiteBlackEmail.class);
+    }
+
+}

+ 231 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/controller/AdwebSiteEnquiryRuleController.java

@@ -0,0 +1,231 @@
+package org.jeecg.modules.adweb.enquiry.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
+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.vo.LoginUser;
+import org.jeecg.modules.adweb.enquiry.entity.AdwebSiteEnquiryRule;
+import org.jeecg.modules.adweb.enquiry.mapper.AdwebSiteEnquiryRuleMapper;
+import org.jeecg.modules.adweb.enquiry.service.IAdwebSiteEnquiryRuleService;
+import org.jeecg.modules.adweb.site.entity.AdwebSite;
+import org.jeecg.modules.adweb.site.service.IAdwebSiteService;
+import org.jeecg.modules.adweb.site.service.ISiteUserPermissionService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: adweb_site_enquiry_rule
+ * @Author: jeecg-boot
+ * @Date: 2023-08-31
+ * @Version: V1.0
+ */
+@Tag(name = "adweb_site_enquiry_rule")
+@RestController
+@RequestMapping("/adweb/adwebEnquirySiteRule")
+@Slf4j
+public class AdwebSiteEnquiryRuleController extends JeecgController<AdwebSiteEnquiryRule, IAdwebSiteEnquiryRuleService> {
+    @Resource
+    private IAdwebSiteEnquiryRuleService adwebSiteEnquiryRuleService;
+    @Resource
+    private AdwebSiteEnquiryRuleMapper adwebEnquirySiteRuleMapper;
+    @Resource
+    private IAdwebSiteService adwebSiteService;
+    @Resource
+    private ISysBaseAPI sysBaseAPI;
+    @Resource
+    private ISiteUserPermissionService siteUserPermissionService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param adwebEnquirySiteRule
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "adweb_site_enquiry_rule-分页列表查询")
+    @Operation(summary = "adweb_site_enquiry_rule-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<?> queryPageList(AdwebSiteEnquiryRule adwebEnquirySiteRule,
+                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                   HttpServletRequest req) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        List<String> codeList = null;
+        List<String> uidList = null;
+        if (sysBaseAPI.isAdmin()) {
+
+        } else if (sysBaseAPI.isOem()) {
+            uidList = sysBaseAPI.getOemGroupUids();
+        } else {
+            uidList = new ArrayList<>();
+            uidList.add(sysUser.getId());
+        }
+        List<String> siteCodeList = null;
+        if (CollectionUtils.isNotEmpty(uidList)) {
+            siteCodeList = siteUserPermissionService.getSiteCodeListByUids(uidList);
+        }
+
+        if (adwebEnquirySiteRule.getSiteId() != null) {
+            String siteCode = adwebSiteService.getSiteCodeById(adwebEnquirySiteRule.getSiteId());
+            if (StringUtils.isNotBlank(siteCode)) {
+                QueryWrapper<AdwebSite> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("id", adwebEnquirySiteRule.getSiteId()).or().eq("parent_group_code", siteCode);
+                queryWrapper.ne("status", 0);
+                queryWrapper.in(!sysBaseAPI.isAdmin(), "code", siteCodeList);
+                codeList = adwebSiteService.list(queryWrapper).stream().map(AdwebSite::getCode).collect(Collectors.toList());
+            }
+        } else {
+            codeList = siteCodeList;
+        }
+        Page<AdwebSiteEnquiryRule> page = new Page<AdwebSiteEnquiryRule>(pageNo, pageSize);
+        IPage<AdwebSiteEnquiryRule> pageList = getPageList(page, adwebEnquirySiteRule, codeList);
+        List<AdwebSiteEnquiryRule> record = pageList.getRecords();
+
+        return Result.OK(pageList);
+    }
+
+    public IPage<AdwebSiteEnquiryRule> getPageList(Page<AdwebSiteEnquiryRule> page, AdwebSiteEnquiryRule adwebEnquirySiteRule, List<String> codeList) {
+
+        IPage<AdwebSiteEnquiryRule> pageList = adwebEnquirySiteRuleMapper.pageList(page, adwebEnquirySiteRule, codeList);
+        return pageList;
+    }
+
+    /**
+     * 添加
+     *
+     * @param adwebEnquirySiteRule
+     * @return
+     */
+    @AutoLog(value = "adweb_site_enquiry_rule-添加")
+    @Operation(summary = "adweb_site_enquiry_rule-添加")
+    @PostMapping(value = "/add")
+    public Result<?> add(@RequestBody AdwebSiteEnquiryRule adwebEnquirySiteRule) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        AdwebSite adwebSite = adwebSiteService.getById(adwebEnquirySiteRule.getSiteId());
+        adwebEnquirySiteRule.setSiteCode(adwebSite.getCode());
+        adwebEnquirySiteRule.setStatus(1);
+        adwebSiteEnquiryRuleService.save(adwebEnquirySiteRule);
+        return Result.OK("添加成功!");
+    }
+
+    /**
+     * 编辑
+     *
+     * @param adwebEnquirySiteRule
+     * @return
+     */
+    @AutoLog(value = "adweb_site_enquiry_rule-编辑")
+    @Operation(summary = "adweb_site_enquiry_rule-编辑")
+    @PutMapping(value = "/edit")
+    public Result<?> edit(@RequestBody AdwebSiteEnquiryRule adwebEnquirySiteRule) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        AdwebSite adwebSite = adwebSiteService.getById(adwebEnquirySiteRule.getSiteId());
+        adwebEnquirySiteRule.setSiteCode(adwebSite.getCode());
+        adwebSiteEnquiryRuleService.updateById(adwebEnquirySiteRule);
+        return Result.OK("编辑成功!");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "adweb_site_enquiry_rule-通过id删除")
+    @Operation(summary = "adweb_site_enquiry_rule-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        AdwebSiteEnquiryRule adwebEnquirySiteRule = adwebSiteEnquiryRuleService.getById(id);
+        adwebEnquirySiteRule.setStatus(0);
+        adwebSiteEnquiryRuleService.updateById(adwebEnquirySiteRule);
+//		adwebSiteEnquiryRuleService.removeById(id);
+        return Result.OK("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "adweb_site_enquiry_rule-批量删除")
+    @Operation(summary = "adweb_site_enquiry_rule-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+
+        List<String> strings = Arrays.asList(ids.split(","));
+        for (String s : strings) {
+            AdwebSiteEnquiryRule adwebEnquirySiteRule = adwebSiteEnquiryRuleService.getById(s);
+            adwebEnquirySiteRule.setStatus(0);
+            adwebSiteEnquiryRuleService.updateById(adwebEnquirySiteRule);
+        }
+//		this.adwebSiteEnquiryRuleService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("批量删除成功!");
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "adweb_site_enquiry_rule-通过id查询")
+    @Operation(summary = "adweb_site_enquiry_rule-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
+        AdwebSiteEnquiryRule adwebEnquirySiteRule = adwebSiteEnquiryRuleService.getById(id);
+        if (adwebEnquirySiteRule == null) {
+            return Result.error("未找到对应数据");
+        }
+        return Result.OK(adwebEnquirySiteRule);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param adwebEnquirySiteRule
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, AdwebSiteEnquiryRule adwebEnquirySiteRule) {
+        return super.exportXls(request, adwebEnquirySiteRule, AdwebSiteEnquiryRule.class, "adweb_site_enquiry_rule");
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, AdwebSiteEnquiryRule.class);
+    }
+
+}

+ 32 - 18
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/entity/AdwebSiteEnquiryRule.java

@@ -16,46 +16,60 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * @Description: adweb_enquiry_site_rule
+ * @Description: adweb_site_enquiry_rule
  * @Author: jeecg-boot
- * @Date:   2023-08-31
+ * @Date: 2023-08-31
  * @Version: V1.0
  */
 @Data
 @TableName("adweb_site_enquiry_rule")
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = false)
-@Schema(description="adweb_site_enquiry_rule")
+@Schema(description = "adweb_site_enquiry_rule")
 public class AdwebSiteEnquiryRule implements Serializable {
     private static final long serialVersionUID = 1L;
 
-	/**id*/
-	@TableId(type = IdType.ASSIGN_ID)
+    /**
+     * id
+     */
+    @TableId(type = IdType.ASSIGN_ID)
     @Schema(description = "id")
     private String id;
-	/**站点id*/
-	@Excel(name = "站点id", width = 15)
+    /**
+     * 站点id
+     */
+    @Excel(name = "站点id", width = 15)
     @Schema(description = "站点id")
     private Integer siteId;
-	/**站点code*/
-	@Excel(name = "站点code", width = 15)
+    /**
+     * 站点code
+     */
+    @Excel(name = "站点code", width = 15)
     @Schema(description = "站点code")
     private String siteCode;
-	/**状态0为删除1为使用中*/
-	@Excel(name = "状态0为删除1为使用中", width = 15)
+    /**
+     * 状态0为删除1为使用中
+     */
+    @Excel(name = "状态0为删除1为使用中", width = 15)
     @Schema(description = "状态0为删除1为使用中")
     private Integer status;
-	/**关键词*/
-	@Excel(name = "关键词", width = 15)
+    /**
+     * 关键词
+     */
+    @Excel(name = "关键词", width = 15)
     @Schema(description = "关键词")
     private String word;
-	/**黑名单或白名单0为黑名单,1为白名单*/
-	@Excel(name = "黑名单或白名单0为黑名单,1为白名单", width = 15)
+    /**
+     * 黑名单或白名单0为黑名单,1为白名单
+     */
+    @Excel(name = "黑名单或白名单0为黑名单,1为白名单", width = 15)
     @Schema(description = "黑名单或白名单0为黑名单,1为白名单")
     private Integer blackOrWhite;
-	/**创建日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    /**
+     * 创建日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "创建日期")
     private Date createTime;
 

+ 4 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/AdwebSiteBlackEmailMapper.java

@@ -8,19 +8,20 @@ import org.jeecg.modules.adweb.enquiry.entity.AdwebSiteBlackEmail;
 import java.util.List;
 
 /**
- * @Description: enquiry_site_black_email
+ * @Description: adweb_site_black_email
  * @Author: jeecg-boot
- * @Date:   2023-06-28
+ * @Date: 2023-06-28
  * @Version: V1.0
  */
 public interface AdwebSiteBlackEmailMapper extends BaseMapper<AdwebSiteBlackEmail> {
 
     /**
      * 获取分页列表数据
+     *
      * @param page
      * @param enquirySiteBlackEmail
      * @param codeList
      * @return
      */
-    IPage<AdwebSiteBlackEmail> getPageList(Page<AdwebSiteBlackEmail> page, AdwebSiteBlackEmail enquirySiteBlackEmail, List<String> codeList,String column,String order);
+    IPage<AdwebSiteBlackEmail> getPageList(Page<AdwebSiteBlackEmail> page, AdwebSiteBlackEmail enquirySiteBlackEmail, List<String> codeList, String column, String order);
 }

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/AdwebSiteEnquiryRuleMapper.java

@@ -8,11 +8,11 @@ import org.jeecg.modules.adweb.enquiry.entity.AdwebSiteEnquiryRule;
 import java.util.List;
 
 /**
- * @Description: adweb_enquiry_site_rule
+ * @Description: adweb_site_enquiry_rule
  * @Author: jeecg-boot
- * @Date:   2023-08-31
+ * @Date: 2023-08-31
  * @Version: V1.0
  */
 public interface AdwebSiteEnquiryRuleMapper extends BaseMapper<AdwebSiteEnquiryRule> {
-    IPage<AdwebSiteEnquiryRule> pageList(Page<AdwebSiteEnquiryRule> page, AdwebSiteEnquiryRule adwebEnquirySiteRule,List<String> codeList);
+    IPage<AdwebSiteEnquiryRule> pageList(Page<AdwebSiteEnquiryRule> page, AdwebSiteEnquiryRule adwebEnquirySiteRule, List<String> codeList);
 }

+ 10 - 10
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebEnquirySiteRuleMapper.xml

@@ -3,16 +3,16 @@
 <mapper namespace="org.jeecg.modules.adweb.enquiry.mapper.AdwebSiteEnquiryRuleMapper">
     <select id="pageList" resultType="org.jeecg.modules.adweb.enquiry.entity.AdwebSiteEnquiryRule">
         SELECT t1.*, t2.num wasteEnquiryNum,t3.`name` siteName
-        FROM `adweb_enquiry_site_rule` t1
+        FROM `adweb_site_enquiry_rule` t1
         LEFT JOIN (
-            SELECT
-                   t1.reason,t1.site_code,count(*) num
-            FROM
-            (
-                SELECT SUBSTRING_INDEX(effective_reason,'-',-1) reason,site_code
-                FROM `adweb_enquiry`
-                WHERE `status` = 1 AND user_effective = 0 AND sys_effective = 1 AND waste_enquiry_type = 'keyword'
-            ) t1 GROUP BY t1.reason,t1.site_code
+        SELECT
+        t1.reason,t1.site_code,count(*) num
+        FROM
+        (
+        SELECT SUBSTRING_INDEX(effective_reason,'-',-1) reason,site_code
+        FROM `adweb_enquiry`
+        WHERE `status` = 1 AND user_effective = 0 AND sys_effective = 1 AND waste_enquiry_type = 'keyword'
+        ) t1 GROUP BY t1.reason,t1.site_code
         ) t2 ON t2.reason LIKE CONCAT('%',t1.word,'%') AND t2.site_code = t1.site_code,adweb_site t3
         WHERE t1.site_id = t3.id
         AND t1.status = 1
@@ -26,7 +26,7 @@
                 </when>
             </choose>
         </if>
-        <if test = "adwebEnquirySiteRule.siteId != null and adwebEnquirySiteRule.siteId != ''" >
+        <if test="adwebEnquirySiteRule.siteId != null and adwebEnquirySiteRule.siteId != ''">
             AND t1.site_id = #{adwebEnquirySiteRule.siteId}
         </if>
         <if test="adwebEnquirySiteRule.word != null and adwebEnquirySiteRule.word != ''">

+ 20 - 20
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebPublicEnquiryRuleMapper.xml

@@ -3,16 +3,16 @@
 <mapper namespace="org.jeecg.modules.adweb.enquiry.mapper.AdwebPublicEnquiryRuleMapper">
     <select id="pageList" resultType="org.jeecg.modules.adweb.enquiry.entity.AdwebPublicEnquiryRule">
         SELECT t1.*, t2.num wasteEnquiryNum
-        FROM `adweb_enquiry_rule` t1
-                 LEFT JOIN (SELECT
-                                t1.reason,count(*) num
-                            FROM
-                            (
-                                SELECT SUBSTRING_INDEX(effective_reason,'-',-1) reason
-                                FROM `adweb_enquiry`
-                                WHERE `status` = 1 AND user_effective = 0 AND sys_effective = 1 AND waste_enquiry_type = 'keyword'
-                            ) t1 GROUP BY t1.reason) t2
-                           ON t2.reason = t1.word WHERE t1.`status` != 0
+        FROM `adweb_public_enquiry_rule` t1
+        LEFT JOIN (SELECT
+        t1.reason,count(*) num
+        FROM
+        (
+        SELECT SUBSTRING_INDEX(effective_reason,'-',-1) reason
+        FROM `adweb_enquiry`
+        WHERE `status` = 1 AND user_effective = 0 AND sys_effective = 1 AND waste_enquiry_type = 'keyword'
+        ) t1 GROUP BY t1.reason) t2
+        ON t2.reason = t1.word WHERE t1.`status` != 0
         <if test="word != null and word != ''">
             AND t1.word like CONCAT('%', #{word}, '%')
         </if>
@@ -25,20 +25,20 @@
         <if test="useStatus != null">
             AND t1.use_status = #{useStatus}
         </if>
-        <if test = "column != null and column != ''">
-              ORDER BY
-              <if test = "column == 'createTime'">
+        <if test="column != null and column != ''">
+            ORDER BY
+            <if test="column == 'createTime'">
                 t1.create_time ${order}
-              </if>
-              <if test = "column == 'isEnable'">
+            </if>
+            <if test="column == 'isEnable'">
                 t1.is_enable ${order}
-              </if>
-              <if test = "column == 'useStatus'">
+            </if>
+            <if test="column == 'useStatus'">
                 t1.use_status ${order}
-              </if>
-              <if test = "column == 'blackOrWhiteList'">
+            </if>
+            <if test="column == 'blackOrWhiteList'">
                 t1.black_or_white_list ${order}
-              </if>
+            </if>
         </if>
     </select>
 </mapper>

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/mapper/xml/AdwebSiteBlackEmailMapper.xml

@@ -4,17 +4,17 @@
 
     <select id="getPageList" resultType="org.jeecg.modules.adweb.enquiry.entity.AdwebSiteBlackEmail">
         SELECT t1.*,t2.`name` siteName,t3.num wasteEnquiryNum,t4.num wasteGeneralEnquiryNum
-        FROM enquiry_site_black_email t1
+        FROM adweb_site_black_email t1
         LEFT JOIN (SELECT from_email, COUNT(*) num, site_id
         FROM `adweb_enquiry`
         WHERE `status` = 1
         AND user_effective = 0
         AND sys_effective = 1
         AND waste_enquiry_type = 'email'
-        GROUP BY from_email) t3
+        GROUP BY from_email, site_id) t3
         ON t1.email = t3.from_email AND t1.site_id = t3.site_id
         LEFT JOIN (
-        SELECT t1.email,SUM(t2.num) num,t1.site_id FROM enquiry_site_black_email t1
+        SELECT t1.email,SUM(t2.num) num,t1.site_id FROM adweb_site_black_email t1
         LEFT JOIN (SELECT from_email, COUNT(*) num, site_id
         FROM `adweb_enquiry`
         WHERE `status` = 1

+ 6 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/IAdwebSiteBlackEmailService.java

@@ -10,16 +10,16 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * @Description: enquiry_site_black_email
+ * @Description: adweb_site_black_email
  * @Author: jeecg-boot
- * @Date:   2023-06-28
+ * @Date: 2023-06-28
  * @Version: V1.0
  */
 public interface IAdwebSiteBlackEmailService extends IService<AdwebSiteBlackEmail> {
     /**
      * 根据站点id获取并存取黑名单数据到redis
      */
-    void saveRedisSiteBlackEmailBySiteId(Integer siteId,Integer blackOrWhite);
+    void saveRedisSiteBlackEmailBySiteId(Integer siteId, Integer blackOrWhite);
 
     /**
      * 根据站点id获取对应所有的黑白名单数据
@@ -28,15 +28,17 @@ public interface IAdwebSiteBlackEmailService extends IService<AdwebSiteBlackEmai
 
     /**
      * 获取分页列表数据
+     *
      * @param page
      * @param enquirySiteBlackEmail
      * @param codeList
      * @return
      */
-    IPage<AdwebSiteBlackEmail> pageList(Page<AdwebSiteBlackEmail> page, AdwebSiteBlackEmail enquirySiteBlackEmail, List<String> codeList,String column,String order);
+    IPage<AdwebSiteBlackEmail> pageList(Page<AdwebSiteBlackEmail> page, AdwebSiteBlackEmail enquirySiteBlackEmail, List<String> codeList, String column, String order);
 
     /**
      * 更改为垃圾询盘处理邮箱黑名单
+     *
      * @param effectiveEnquiryParamDto
      */
     void addBlackEmailByContent(EffectiveEnquiryParamDto effectiveEnquiryParamDto);

+ 3 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/IAdwebSiteEnquiryRuleService.java

@@ -5,15 +5,16 @@ import org.jeecg.modules.adweb.enquiry.dto.param.EffectiveEnquiryParamDto;
 import org.jeecg.modules.adweb.enquiry.entity.AdwebSiteEnquiryRule;
 
 /**
- * @Description: adweb_enquiry_site_rule
+ * @Description: adweb_site_enquiry_rule
  * @Author: jeecg-boot
- * @Date:   2023-08-31
+ * @Date: 2023-08-31
  * @Version: V1.0
  */
 public interface IAdwebSiteEnquiryRuleService extends IService<AdwebSiteEnquiryRule> {
 
     /**
      * 更改为垃圾询盘处理关键词黑名单
+     *
      * @param effectiveEnquiryParamDto
      */
     void addBlackKeywordByContent(EffectiveEnquiryParamDto effectiveEnquiryParamDto);

+ 35 - 35
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebSiteBlackEmailServiceImpl.java

@@ -4,9 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import jakarta.annotation.Resource;
-
 import org.apache.commons.collections4.CollectionUtils;
 import org.jeecg.common.util.RedisUtil;
 import org.jeecg.modules.adweb.enquiry.dto.param.EffectiveEnquiryParamDto;
@@ -18,9 +16,9 @@ import org.springframework.stereotype.Service;
 import java.util.*;
 
 /**
- * @Description: enquiry_site_black_email
+ * @Description: adweb_site_black_email
  * @Author: jeecg-boot
- * @Date:   2023-06-28
+ * @Date: 2023-06-28
  * @Version: V1.0
  */
 @Service
@@ -41,37 +39,37 @@ public class AdwebSiteBlackEmailServiceImpl extends ServiceImpl<AdwebSiteBlackEm
      * 根据站点id获取并存取黑名单数据到redis
      */
     @Override
-    public void saveRedisSiteBlackEmailBySiteId(Integer siteId,Integer blackOrWhite){
+    public void saveRedisSiteBlackEmailBySiteId(Integer siteId, Integer blackOrWhite) {
         QueryWrapper<AdwebSiteBlackEmail> siteAllEmailQueryWrapper = new QueryWrapper<>();
         siteAllEmailQueryWrapper.ne("status", 0);
         siteAllEmailQueryWrapper.eq("site_id", siteId);
         siteAllEmailQueryWrapper.eq("black_or_white", blackOrWhite);
         List<AdwebSiteBlackEmail> allEmailList = list(siteAllEmailQueryWrapper);
-        if(CollectionUtils.isEmpty(allEmailList)){
+        if (CollectionUtils.isEmpty(allEmailList)) {
             log.warn("未获取到对应站点的名单数据");
         }
 
         List<String> emailList = new ArrayList<>();
-        if(CollectionUtils.isNotEmpty(allEmailList)){
-            for (AdwebSiteBlackEmail enquirySiteBlackEmail1 : allEmailList){
-                if(enquirySiteBlackEmail1.getType().equals("0")){
+        if (CollectionUtils.isNotEmpty(allEmailList)) {
+            for (AdwebSiteBlackEmail enquirySiteBlackEmail1 : allEmailList) {
+                if (enquirySiteBlackEmail1.getType().equals("0")) {
                     emailList.add("*" + enquirySiteBlackEmail1.getEmail() + "*");
-                }else{
+                } else {
                     emailList.add(enquirySiteBlackEmail1.getEmail());
                 }
             }
         }
         //处理对应站点的黑名单
-        if(blackOrWhite == 0){
+        if (blackOrWhite == 0) {
             if (CollectionUtils.isNotEmpty(emailList)) {
                 redisUtil.set(SiteBlackEmailKey + "::" + siteId, emailList, 60 * 60 * 24);
-            }else {
+            } else {
                 redisUtil.del(SiteBlackEmailKey + "::" + siteId);
             }
-        }else{
+        } else {
             if (CollectionUtils.isNotEmpty(emailList)) {
                 redisUtil.set(SiteWhiteEmailListKey + "::" + siteId, emailList, 60 * 60 * 24);
-            }else {
+            } else {
                 redisUtil.del(SiteWhiteEmailListKey + "::" + siteId);
             }
         }
@@ -82,29 +80,29 @@ public class AdwebSiteBlackEmailServiceImpl extends ServiceImpl<AdwebSiteBlackEm
      * 根据站点id获取对应所有的黑白名单数据
      */
     @Override
-    public Map<String, List<String>> getSiteBlackEmailListBySiteId(Integer siteId){
+    public Map<String, List<String>> getSiteBlackEmailListBySiteId(Integer siteId) {
         QueryWrapper<AdwebSiteBlackEmail> siteAllEmailQueryWrapper = new QueryWrapper<>();
         siteAllEmailQueryWrapper.ne("status", 0);
         siteAllEmailQueryWrapper.eq("site_id", siteId);
         List<AdwebSiteBlackEmail> allEmailList = list(siteAllEmailQueryWrapper);
-        if(CollectionUtils.isEmpty(allEmailList)){
+        if (CollectionUtils.isEmpty(allEmailList)) {
             log.warn("未获取到对应站点的黑白名单数据");
         }
 
         List<String> emailList = new ArrayList<>();
         List<String> whiteEmailList = new ArrayList<>();
-        if(CollectionUtils.isNotEmpty(allEmailList)){
-            for (AdwebSiteBlackEmail enquirySiteBlackEmail1 : allEmailList){
-                if(enquirySiteBlackEmail1.getBlackOrWhite() == 0){
-                    if(enquirySiteBlackEmail1.getType().equals("0")){
+        if (CollectionUtils.isNotEmpty(allEmailList)) {
+            for (AdwebSiteBlackEmail enquirySiteBlackEmail1 : allEmailList) {
+                if (enquirySiteBlackEmail1.getBlackOrWhite() == 0) {
+                    if (enquirySiteBlackEmail1.getType().equals("0")) {
                         emailList.add("*" + enquirySiteBlackEmail1.getEmail() + "*");
-                    }else{
+                    } else {
                         emailList.add(enquirySiteBlackEmail1.getEmail());
                     }
-                }else{
-                    if(enquirySiteBlackEmail1.getType().equals("0")){
+                } else {
+                    if (enquirySiteBlackEmail1.getType().equals("0")) {
                         whiteEmailList.add("*" + enquirySiteBlackEmail1.getEmail() + "*");
-                    }else{
+                    } else {
                         whiteEmailList.add(enquirySiteBlackEmail1.getEmail());
                     }
                 }
@@ -112,29 +110,31 @@ public class AdwebSiteBlackEmailServiceImpl extends ServiceImpl<AdwebSiteBlackEm
         }
 
         Map<String, List<String>> enquirySiteBlackEmailMap = new HashMap<>();
-        enquirySiteBlackEmailMap.put("black",emailList);
+        enquirySiteBlackEmailMap.put("black", emailList);
         enquirySiteBlackEmailMap.put("white", whiteEmailList);
         return enquirySiteBlackEmailMap;
     }
 
     /**
      * 获取分页列表数据
+     *
      * @param page
      * @param enquirySiteBlackEmail
      * @param codeList
      * @return
      */
     @Override
-    public IPage<AdwebSiteBlackEmail> pageList(Page<AdwebSiteBlackEmail> page, AdwebSiteBlackEmail enquirySiteBlackEmail, List<String> codeList,String column,String order){
+    public IPage<AdwebSiteBlackEmail> pageList(Page<AdwebSiteBlackEmail> page, AdwebSiteBlackEmail enquirySiteBlackEmail, List<String> codeList, String column, String order) {
         return enquirySiteBlackEmailMapper.getPageList(page, enquirySiteBlackEmail, codeList, column, order);
     }
 
     /**
      * 更改为垃圾询盘处理邮箱黑名单
+     *
      * @param effectiveEnquiryParamDto
      */
     @Override
-    public void addBlackEmailByContent(EffectiveEnquiryParamDto effectiveEnquiryParamDto){
+    public void addBlackEmailByContent(EffectiveEnquiryParamDto effectiveEnquiryParamDto) {
         //排查添加的邮箱是否已有
         QueryWrapper<AdwebSiteBlackEmail> enquirySiteBlackEmailQueryWrapper = new QueryWrapper<>();
         enquirySiteBlackEmailQueryWrapper.eq("email", effectiveEnquiryParamDto.getWasteEnquirySeason());
@@ -142,11 +142,11 @@ public class AdwebSiteBlackEmailServiceImpl extends ServiceImpl<AdwebSiteBlackEm
         enquirySiteBlackEmailQueryWrapper.eq("site_code", effectiveEnquiryParamDto.getSiteCode());
         enquirySiteBlackEmailQueryWrapper.eq("status", 1);
         List<AdwebSiteBlackEmail> enquirySiteBlackEmailList = list(enquirySiteBlackEmailQueryWrapper);
-        if(CollectionUtils.isNotEmpty(enquirySiteBlackEmailList)){
+        if (CollectionUtils.isNotEmpty(enquirySiteBlackEmailList)) {
             //如果有白名单 先删除原数据,后添加新的黑名单数据
-            for(AdwebSiteBlackEmail enquirySiteBlackEmail : enquirySiteBlackEmailList){
-                if(enquirySiteBlackEmail.getBlackOrWhite() == 1){
-                    if(enquirySiteBlackEmail.getType().equals("1")){
+            for (AdwebSiteBlackEmail enquirySiteBlackEmail : enquirySiteBlackEmailList) {
+                if (enquirySiteBlackEmail.getBlackOrWhite() == 1) {
+                    if (enquirySiteBlackEmail.getType().equals("1")) {
                         enquirySiteBlackEmail.setStatus(0);
                         enquirySiteBlackEmail.setUpdateTime(new Date());
                         updateById(enquirySiteBlackEmail);
@@ -163,7 +163,7 @@ public class AdwebSiteBlackEmailServiceImpl extends ServiceImpl<AdwebSiteBlackEm
                     save(newEnquirySiteBlackEmail);
                 }
             }
-        }else{
+        } else {
             AdwebSiteBlackEmail enquirySiteBlackEmail = new AdwebSiteBlackEmail();
             enquirySiteBlackEmail.setEmail(effectiveEnquiryParamDto.getWasteEnquirySeason());
             enquirySiteBlackEmail.setType("1");
@@ -176,21 +176,21 @@ public class AdwebSiteBlackEmailServiceImpl extends ServiceImpl<AdwebSiteBlackEm
         }
 
         //重新处理站点的黑名单redis缓存
-        Map<String,List<String>> enquirySiteBlackEmailListMap = getSiteBlackEmailListBySiteId(effectiveEnquiryParamDto.getSiteId());
+        Map<String, List<String>> enquirySiteBlackEmailListMap = getSiteBlackEmailListBySiteId(effectiveEnquiryParamDto.getSiteId());
         List<String> emailList = enquirySiteBlackEmailListMap.get("black");
         List<String> whiteEmailList = enquirySiteBlackEmailListMap.get("white");
 
         //处理对应站点的黑名单
         if (CollectionUtils.isNotEmpty(emailList)) {
             redisUtil.set(SiteBlackEmailKey + "::" + effectiveEnquiryParamDto.getSiteId(), emailList, 60 * 60 * 24);
-        }else {
+        } else {
             redisUtil.del(SiteBlackEmailKey + "::" + effectiveEnquiryParamDto.getSiteId());
         }
 
         //处理对应站点的白名单
         if (CollectionUtils.isNotEmpty(whiteEmailList)) {
             redisUtil.set(SiteWhiteEmailListKey + "::" + effectiveEnquiryParamDto.getSiteId(), whiteEmailList, 60 * 60 * 24);
-        }else {
+        } else {
             redisUtil.del(SiteWhiteEmailListKey + "::" + effectiveEnquiryParamDto.getSiteId());
         }
     }

+ 7 - 6
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/adweb/enquiry/service/impl/AdwebSiteEnquiryRuleServiceImpl.java

@@ -12,9 +12,9 @@ import java.util.Date;
 import java.util.List;
 
 /**
- * @Description: adweb_enquiry_site_rule
+ * @Description: adweb_site_enquiry_rule
  * @Author: jeecg-boot
- * @Date:   2023-08-31
+ * @Date: 2023-08-31
  * @Version: V1.0
  */
 @Service
@@ -22,10 +22,11 @@ public class AdwebSiteEnquiryRuleServiceImpl extends ServiceImpl<AdwebSiteEnquir
 
     /**
      * 更改为垃圾询盘处理关键词黑名单
+     *
      * @param effectiveEnquiryParamDto
      */
     @Override
-    public void addBlackKeywordByContent(EffectiveEnquiryParamDto effectiveEnquiryParamDto){
+    public void addBlackKeywordByContent(EffectiveEnquiryParamDto effectiveEnquiryParamDto) {
         //排查添加的关键词是否已有
         QueryWrapper<AdwebSiteEnquiryRule> adwebEnquirySiteRuleQueryWrapper = new QueryWrapper<>();
         adwebEnquirySiteRuleQueryWrapper.eq("word", effectiveEnquiryParamDto.getWasteEnquirySeason());
@@ -33,10 +34,10 @@ public class AdwebSiteEnquiryRuleServiceImpl extends ServiceImpl<AdwebSiteEnquir
         adwebEnquirySiteRuleQueryWrapper.eq("site_code", effectiveEnquiryParamDto.getSiteCode());
         adwebEnquirySiteRuleQueryWrapper.eq("status", 1);
         List<AdwebSiteEnquiryRule> adwebEnquirySiteRuleList = list(adwebEnquirySiteRuleQueryWrapper);
-        if(!adwebEnquirySiteRuleList.isEmpty()){
+        if (!adwebEnquirySiteRuleList.isEmpty()) {
             //如果有白名单 先删除原数据,后添加新的黑名单数据
             AdwebSiteEnquiryRule adwebEnquirySiteRule = adwebEnquirySiteRuleList.get(0);
-            if(adwebEnquirySiteRule.getBlackOrWhite() == 1){
+            if (adwebEnquirySiteRule.getBlackOrWhite() == 1) {
                 adwebEnquirySiteRule.setStatus(0);
                 updateById(adwebEnquirySiteRule);
 
@@ -49,7 +50,7 @@ public class AdwebSiteEnquiryRuleServiceImpl extends ServiceImpl<AdwebSiteEnquir
                 newAdwebSiteEnquiryRule.setCreateTime(new Date());
                 save(newAdwebSiteEnquiryRule);
             }
-        }else{
+        } else {
             AdwebSiteEnquiryRule newAdwebSiteEnquiryRule = new AdwebSiteEnquiryRule();
             newAdwebSiteEnquiryRule.setWord(effectiveEnquiryParamDto.getWasteEnquirySeason());
             newAdwebSiteEnquiryRule.setBlackOrWhite(0);