Procházet zdrojové kódy

邮箱发送 and 文件导出

yumeng před 5 roky
rodič
revize
6f20584dea

+ 248 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MailLogController.java

@@ -0,0 +1,248 @@
+package org.jeecg.modules.ctop.controller;
+
+import com.alibaba.fastjson.JSON;
+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.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ctop.entity.MailLog;
+import org.jeecg.modules.ctop.service.IMailLogService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 邮箱记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+@Slf4j
+@Api(tags = "邮箱记录表")
+@RestController
+@RequestMapping("/top/mailLog")
+public class MailLogController {
+    @Autowired
+    private IMailLogService mailLogService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param mailLog
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-分页列表查询")
+    @ApiOperation(value = "邮箱记录表-分页列表查询", notes = "邮箱记录表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<MailLog>> queryPageList(MailLog mailLog,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                HttpServletRequest req) {
+        Result<IPage<MailLog>> result = new Result<IPage<MailLog>>();
+        QueryWrapper<MailLog> queryWrapper = QueryGenerator.initQueryWrapper(mailLog, req.getParameterMap());
+        Page<MailLog> page = new Page<MailLog>(pageNo, pageSize);
+        IPage<MailLog> pageList = mailLogService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param mailLog
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-添加")
+    @ApiOperation(value = "邮箱记录表-添加", notes = "邮箱记录表-添加")
+    @PostMapping(value = "/add")
+    public Result<MailLog> add(@RequestBody MailLog mailLog) {
+        Result<MailLog> result = new Result<MailLog>();
+        try {
+            mailLogService.save(mailLog);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param mailLog
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-编辑")
+    @ApiOperation(value = "邮箱记录表-编辑", notes = "邮箱记录表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<MailLog> edit(@RequestBody MailLog mailLog) {
+        Result<MailLog> result = new Result<MailLog>();
+        MailLog mailLogEntity = mailLogService.getById(mailLog.getId());
+        if (mailLogEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = mailLogService.updateById(mailLog);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-通过id删除")
+    @ApiOperation(value = "邮箱记录表-通过id删除", notes = "邮箱记录表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            mailLogService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-批量删除")
+    @ApiOperation(value = "邮箱记录表-批量删除", notes = "邮箱记录表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<MailLog> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<MailLog> result = new Result<MailLog>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.mailLogService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "邮箱记录表-通过id查询")
+    @ApiOperation(value = "邮箱记录表-通过id查询", notes = "邮箱记录表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<MailLog> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<MailLog> result = new Result<MailLog>();
+        MailLog mailLog = mailLogService.getById(id);
+        if (mailLog == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(mailLog);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<MailLog> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                MailLog mailLog = JSON.parseObject(deString, MailLog.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(mailLog, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<MailLog> pageList = mailLogService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "邮箱记录表列表");
+        mv.addObject(NormalExcelConstants.CLASS, MailLog.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("邮箱记录表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<MailLog> listMailLogs = ExcelImportUtil.importExcel(file.getInputStream(), MailLog.class, params);
+                mailLogService.saveBatch(listMailLogs);
+                return Result.ok("文件导入成功!数据行数:" + listMailLogs.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 69 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/MailLog.java

@@ -0,0 +1,69 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 邮箱记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+@Data
+@TableName("ctop_mail_log")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_mail_log对象", description = "邮箱记录表")
+public class MailLog {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 发送邮箱
+     */
+    @Excel(name = "发送邮箱", width = 15)
+    @ApiModelProperty(value = "发送邮箱")
+    private String sendEmil;
+    /**
+     * 标题
+     */
+    @Excel(name = "标题", width = 15)
+    @ApiModelProperty(value = "标题")
+    private String subject;
+    /**
+     * 内容
+     */
+    @Excel(name = "内容", width = 15)
+    @ApiModelProperty(value = "内容")
+    private String content;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java

@@ -77,6 +77,11 @@ public class Project {
     @Excel(name = "媒体类型", width = 15)
     @ApiModelProperty(value = "媒体类型")
     private String mediaId;
+
+    /**
+     * 最高出价
+     */
+    private Long maxBid;
     /**
      * 创建时间
      */

+ 26 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/AccountBidJob.java

@@ -0,0 +1,26 @@
+package org.jeecg.modules.ctop.job;
+
+import org.jeecg.modules.ctop.service.IBidWarningService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 出价预警
+ */
+public class AccountBidJob implements Job {
+    @Autowired
+    private IBidWarningService bidWarningService;
+
+    /**
+     * 出价预警
+     *
+     * @param jobExecutionContext
+     * @throws JobExecutionException
+     */
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) {
+        bidWarningService.BidWarning();
+    }
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MailLogMapper.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.ctop.entity.MailLog;
+
+import java.util.List;
+
+/**
+ * 邮箱记录表
+ *
+ * @author: jeecg-boot
+ * @date: 2019-12-08
+ * @cersion: V1.0
+ */
+public interface MailLogMapper extends BaseMapper<MailLog> {
+
+    Integer selectCountByAccountIdAndDate(@Param("accountId") Long accountId, @Param("createTime") String createTime);
+
+    List<String> selectMailList(@Param("projectId") Long projectId);
+
+    List<String> selectWeiXinIdList(@Param("projectId") Long projectId);
+}

+ 41 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MailLogMapper.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.ctop.mapper.MailLogMapper">
+
+
+    <select id="selectCountByAccountIdAndDate" resultType="java.lang.Integer">
+
+        select
+        count(1)
+        from
+        ctop_mail_log
+        where account_id = #{accountId}
+        and DATE_FORMAT(create_time,'%Y-%m-%d') = #{createTime}
+
+
+    </select>
+    <select id="selectMailList" resultType="java.lang.String">
+     select
+     t2.email
+     from
+     ctop_project_member t1
+     left join sys_user t2
+     on t1.user_id = t2.id
+     where t1.project_id = #{projectId}
+     and t2.email != ''
+    </select>
+
+
+    <select id="selectWeiXinIdList" resultType="java.lang.String">
+     select
+     t2.wexin_id
+     from
+     ctop_project_member t1
+     left join ctop_corp_wexin_user t2
+     on t1.user_id = t2.user_id
+     where t1.project_id = #{projectId}
+     and t2.wexin_id != ''
+    </select>
+
+
+</mapper>

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBidWarningService.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.ctop.service;
+
+public interface IBidWarningService {
+    void BidWarning();
+
+
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMailLogService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.MailLog;
+
+/**
+ * 邮箱记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+public interface IMailLogService extends IService<MailLog> {
+
+}

+ 115 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BidWarningServiceImpl.java

@@ -0,0 +1,115 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
+import cn.com.ctop.common.module.utils.SendMailUtil;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.MailLog;
+import org.jeecg.modules.ctop.entity.Project;
+import org.jeecg.modules.ctop.mapper.MailLogMapper;
+import org.jeecg.modules.ctop.mapper.ProjectMapper;
+import org.jeecg.modules.ctop.service.IBidWarningService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+
+/**
+ * 出价预警
+ */
+@Slf4j
+@Service
+public class BidWarningServiceImpl implements IBidWarningService {
+
+    @Autowired
+    private ProjectMapper projectMapper;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    @Autowired
+    private KuaiShouGroupMapper groupMapper;
+    @Autowired
+    private MailLogMapper mailLogMapper;
+
+
+    /**
+     * 预警
+     */
+
+    @Override
+    public void BidWarning() {
+
+        try {
+            QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>();
+            projectQueryWrapper.eq("media_id", "2");
+            List<Project> projects = projectMapper.selectList(projectQueryWrapper);
+            if (!Check.isNull(projects)) {
+                for (Project project : projects) {
+                    Long maxBid = project.getMaxBid();
+                    Long projectId = project.getId();
+                    QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
+                    userAllocationQueryWrapper.eq("project_id", projectId);
+                    List<UserAllocation> userAllocations = userAllocationMapper.selectList(userAllocationQueryWrapper);
+                    if (!Check.isNull(userAllocations)) {
+                        for (UserAllocation userAllocation : userAllocations) {
+                            Long accountId = userAllocation.getAccountId();
+                            List<String> unitWarning = groupMapper.selectWarningGroup(accountId, maxBid);
+                            if (!Check.isNull(unitWarning)) {
+                                sendMessage(accountId, projectId, project.getProjectName(), userAllocation.getAuthName(), unitWarning, maxBid);
+                            }
+                        }
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+    private void sendMessage(Long accountId, Long projectId, String projectName, String authName, List<String> unitWarning, Long maxBid) {
+
+        String createTime = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer count = mailLogMapper.selectCountByAccountIdAndDate(accountId, createTime);
+        StringBuilder text = new StringBuilder();
+
+
+        String s = "";
+        for (int i = 0; i < unitWarning.size(); i++) {
+            s += unitWarning.get(i) + "," + "<br/>";
+
+        }
+        text.append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("授权名称为:" + authName + " 下的,").append("<br/>").append(s)
+                .append("大于项目设置的最高出价:").append(maxBid / 1000).append(" 元! 请您及时调整。");
+        if (count < 3) {
+            List<String> mailList = mailLogMapper.selectMailList(projectId);
+            String subject = "广告组出价预警";
+            try {
+                SendMailUtil.sendMail(mailList, subject, text.toString());
+                MailLog mailLog = new MailLog();
+                mailLog.setAccountId(accountId);
+                mailLog.setContent(text.toString());
+                mailLog.setSendEmil(JSON.toJSONString(mailList));
+                mailLog.setSubject(subject);
+                mailLogMapper.insert(mailLog);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        List<String> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
+        CorpWexinUtils.sendMessage(wexinIds, text.toString());
+
+
+    }
+}

+ 19 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MailLogServiceImpl.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.MailLog;
+import org.jeecg.modules.ctop.mapper.MailLogMapper;
+import org.jeecg.modules.ctop.service.IMailLogService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 邮箱记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-08
+ */
+@Service
+public class MailLogServiceImpl extends ServiceImpl<MailLogMapper, MailLog> implements IMailLogService {
+
+}

+ 65 - 0
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.service.IBidWarningService;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.jeecg.modules.mq.Sender;
 import org.junit.Test;
@@ -24,8 +25,15 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Properties;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest
@@ -158,4 +166,61 @@ public class SampleTest {
 
     }
 
+    @Test
+    public void testMail() throws Exception {
+        Properties properties = new Properties();
+        properties.put("mail.transport.protocol", "smtp");// 连接协议
+        properties.put("mail.smtp.host", "smtp.exmail.qq.com");// 主机名
+        properties.put("mail.smtp.port", 465);// 端口号
+        properties.put("mail.smtp.auth", "true");
+        properties.put("mail.smtp.ssl.enable", "true");// 设置是否使用ssl安全连接 ---一般都使用
+        properties.put("mail.debug", "true");// 设置是否显示debug信息 true 会在控制台显示相关信息
+        // 得到回话对象
+        Session session = Session.getInstance(properties);
+        // 获取邮件对象
+        Message message = new MimeMessage(session);
+        // 设置发件人邮箱地址
+        message.setFrom(new InternetAddress("notice@c-top.com.cn"));
+        // 设置收件人邮箱地址
+
+
+        List<String> mails = new ArrayList<>();
+        mails.add("yumengmeng@c-top.com.cn");
+        mails.add("zhuxinbo@c-top.com.cn");
+
+        InternetAddress[] internetAddresses = new InternetAddress[mails.size()];
+        for (int i = 0; i < mails.size(); i++) {
+            InternetAddress addr = new InternetAddress(mails.get(i));
+            internetAddresses[i] = addr;
+        }
+
+        message.setRecipients(Message.RecipientType.TO, internetAddresses);
+        //  message.setRecipients(Message.RecipientType.TO, new InternetAddress[]{new InternetAddress("yumengmeng@c-top.com.cn"),new InternetAddress("zhuxinbo@c-top.com.cn")});
+        //message.setRecipient(Message.RecipientType.TO, new InternetAddress("xxx@qq.com"));//一个收件人
+        // 设置邮件标题
+        message.setSubject("测试邮件");
+        // 设置邮件内容
+        message.setText("你好啊");
+        // 得到邮差对象
+        Transport transport = session.getTransport();
+        // 连接自己的邮箱账户
+        transport.connect("notice@c-top.com.cn", "Hcst@2019");// 密码为QQ邮箱开通的stmp服务后得到的客户端授权码
+        // 发送邮件
+        transport.sendMessage(message, message.getAllRecipients());
+        transport.close();
+    }
+
+
+    @Autowired
+    private IBidWarningService bidWarningService;
+
+    @Test
+    public void testMa() throws Exception {
+        bidWarningService.BidWarning();
+    }
+
+
 }
+
+
+

+ 69 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/SendMailUtil.java

@@ -0,0 +1,69 @@
+package cn.com.ctop.common.module.utils;
+
+import javax.mail.*;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+import java.util.List;
+import java.util.Properties;
+
+public class SendMailUtil {
+    private static String protocol = "smtp";
+    private static String host = "smtp.exmail.qq.com";
+    private static Integer port = 465;
+    private static String fromEmil = "notice@c-top.com.cn";
+    private static String connectUser = "notice@c-top.com.cn";
+    private static String connectPassWord = "Hcst@2019";
+
+
+    public static void sendMail(List<String> mails, String subject, String text) throws Exception {
+        if (Check.isNull(mails)) {
+            throw new Exception("请输入邮箱");
+        }
+
+        Properties properties = new Properties();
+        properties.put("mail.transport.protocol", protocol);// 连接协议
+        properties.put("mail.smtp.host", host);// 主机名
+        properties.put("mail.smtp.port", port);// 端口号
+        properties.put("mail.smtp.auth", "true");
+        properties.put("mail.smtp.ssl.enable", "true");// 设置是否使用ssl安全连接 ---一般都使用
+        properties.put("mail.debug", "false");// 设置是否显示debug信息 true 会在控制台显示相关信息
+        // 得到回话对象
+        Session session = Session.getInstance(properties);
+        // 获取邮件对象
+        Message message = new MimeMessage(session);
+        // 设置发件人邮箱地址
+        message.setFrom(new InternetAddress(fromEmil));
+        // 设置收件人邮箱地址
+
+        InternetAddress[] internetAddresses = new InternetAddress[mails.size()];
+        for (int i = 0; i < mails.size(); i++) {
+            InternetAddress addr = new InternetAddress(mails.get(i));
+            internetAddresses[i] = addr;
+        }
+        message.setRecipients(Message.RecipientType.TO, internetAddresses);
+        // 设置邮件标题
+        message.setSubject(subject);
+        // 设置邮件内容
+        // message.setText(text);
+
+        BodyPart html = new MimeBodyPart();
+        Multipart mainPart = new MimeMultipart();
+        // 设置HTML内容
+        html.setContent(text, "text/html; charset=utf-8");
+        mainPart.addBodyPart(html);
+        message.setContent(mainPart);
+
+
+        // 得到邮差对象
+        Transport transport = session.getTransport();
+        // 连接自己的邮箱账户
+        transport.connect(connectUser, connectPassWord);// 密码为QQ邮箱开通的stmp服务后得到的客户端授权码
+        // 发送邮件
+        transport.sendMessage(message, message.getAllRecipients());
+        transport.close();
+    }
+
+
+}

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java

@@ -14,4 +14,6 @@ import java.util.List;
  */
 public interface KuaiShouGroupMapper extends BaseMapper<KuaiShouGroup> {
     void replaceBatch(@Param(value = "groups") List<KuaiShouGroup> groups);
+
+    List<String> selectWarningGroup(@Param("accountId") Long accountId, @Param("maxBid") Long maxBid);
 }

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml

@@ -53,4 +53,18 @@
             #{getGroup.updateTime})
         </foreach>
     </insert>
+
+
+    <select id="selectWarningGroup" resultType="java.lang.String">
+
+
+   SELECT
+   unit_name
+   FROM ctop_kuaishou_group
+   WHERE account_id = #{accountId}
+   and (cpa_bid &gt; #{maxBid} or bid &gt; #{maxBid})
+   group by unit_id
+    </select>
+
+
 </mapper>