From 8963b7f57d4e663a34faee329828324ba7096113 Mon Sep 17 00:00:00 2001 From: weizhiqiang <> Date: Tue, 21 Jun 2022 17:10:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=85=B6=E4=BB=96=E3=80=91=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E8=B0=83=E6=95=B4=E4=B8=BA=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/impl/MailAccessDeleteServiceImpl.java | 186 +++++++++--------- .../eve/service/ScheduleDayService.java | 79 ++++---- .../com/skyeye/sys/quartz/HotForumQuartz.java | 2 +- 3 files changed, 134 insertions(+), 133 deletions(-) diff --git a/skyeye-promote/skyeye-mq/src/main/java/com/skyeye/mq/job/impl/MailAccessDeleteServiceImpl.java b/skyeye-promote/skyeye-mq/src/main/java/com/skyeye/mq/job/impl/MailAccessDeleteServiceImpl.java index 3daffa70..472c97ad 100644 --- a/skyeye-promote/skyeye-mq/src/main/java/com/skyeye/mq/job/impl/MailAccessDeleteServiceImpl.java +++ b/skyeye-promote/skyeye-mq/src/main/java/com/skyeye/mq/job/impl/MailAccessDeleteServiceImpl.java @@ -6,6 +6,7 @@ package com.skyeye.mq.job.impl; import cn.hutool.json.JSONUtil; import com.skyeye.common.constans.MqConstants; +import com.skyeye.common.util.DateUtil; import com.skyeye.common.util.EmailUtil; import com.skyeye.common.util.ShowMail; import com.skyeye.common.util.ToolUtil; @@ -28,109 +29,108 @@ import java.util.List; import java.util.Map; /** - * * @ClassName: MailAccessDeleteServiceImpl * @Description: 已删除邮件获取 * @author: skyeye云系列--卫志强 * @date: 2021/7/4 21:58 - * * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 */ @Service("mailAccessDeleteService") -public class MailAccessDeleteServiceImpl implements JobMateService{ - - private static final Logger LOGGER = LoggerFactory.getLogger(MailAccessDeleteServiceImpl.class); - - @Value("${IMAGES_PATH}") - private String tPath; - - @Autowired - private MQUserEmailDao mqUserEmailDao; - - @Autowired - private JobMateMationService jobMateMationService; +public class MailAccessDeleteServiceImpl implements JobMateService { - @Autowired - private SystemFoundationSettingsService systemFoundationSettingsService; + private static final Logger LOGGER = LoggerFactory.getLogger(MailAccessDeleteServiceImpl.class); - @SuppressWarnings("unchecked") - @Override - public void call(String data) throws Exception { - Map map = JSONUtil.toBean(data, null); - String jobId = map.get("jobMateId").toString(); - try { - // 任务开始 - jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_PROCESSING, ""); - try{ - //获取服务器信息 - Map emailServer = systemFoundationSettingsService.getSystemFoundationSettings(); - - String storeType = emailServer.get("emailType").toString();//邮箱类型 - String host = emailServer.get("emailReceiptServer").toString();//邮箱收件服务器 - String username = map.get("userAddress").toString();//登录邮箱账号 - String password = map.get("userPassword").toString();//密码 - String basePath = tPath + "upload/emailenclosure/";//附件存储路径 + @Value("${IMAGES_PATH}") + private String tPath; - Folder folder = ToolUtil.getFolderByServer(host, username, password, storeType, "Deleted Messages"); - if (!folder.exists()) {//如果文件夹不存在,则创建 - folder.create(Folder.HOLDS_MESSAGES); - } - folder.open(Folder.READ_ONLY); - Message[] message = folder.getMessages();//获取邮件信息 - ShowMail re = null; - //邮件集合 - List> beans = new ArrayList<>(); - Map bean = null; - //附件集合 - List> enclosureBeans = new ArrayList<>(); - //获取当前邮箱已有的邮件 - List> emailHasMail = mqUserEmailDao.queryDeleteEmailListByEmailFromAddress(map); - - //创建目录 - ToolUtil.createFolder(basePath); - - //遍历邮件数据 - for (int i = 0; i < message.length; i++) { - if(!message[i].getFolder().isOpen()) //判断是否open - message[i].getFolder().open(Folder.READ_ONLY); //如果close,就重新open - re = new ShowMail((MimeMessage) message[i]); - //如果该邮件在本地数据库中不存在并且messageId不为空 - //收件人或者抄送人或者暗送人是当前账号 - if(!ToolUtil.judgeInListByMessage(emailHasMail, re.getMessageId()) && !ToolUtil.isBlank(re.getMessageId()) - && (re.getMailAddress("to").indexOf(username) > -1 || re.getMailAddress("cc").indexOf(username) > -1 || re.getMailAddress("bcc").indexOf(username) > -1)){ - bean = EmailUtil.getEmailMationByUtil(re, message[i]); - String rowId = ToolUtil.getSurFaceId(); - re.setDateFormat("yyyy-MM-dd HH:mm:ss"); - bean.put("id", rowId);//id - bean.put("emailState", "2");//邮件状态 0.草稿 1.正常 2.已删除 - re.setAttachPath(basePath);//设置附件保存基础路径 - enclosureBeans.addAll(re.saveAttachMent((Part) message[i], rowId));//保存附件 - beans.add(bean); - } - if(beans.size() >= 20){//每20条数据保存一次 - if(!beans.isEmpty()) - mqUserEmailDao.insertEmailListToServer(beans); - if(!enclosureBeans.isEmpty()) - mqUserEmailDao.insertEmailEnclosureListToServer(enclosureBeans); - beans.clear(); - enclosureBeans.clear(); - emailHasMail = mqUserEmailDao.queryDeleteEmailListByEmailFromAddress(map); - } - } - if(!beans.isEmpty()) - mqUserEmailDao.insertEmailListToServer(beans); - if(!enclosureBeans.isEmpty()) - mqUserEmailDao.insertEmailEnclosureListToServer(enclosureBeans); - }finally{ - } - // 任务完成 - jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_SUCCESS, ""); - } catch (Exception e) { - LOGGER.warn("get Trash acquisition failed, reason is {}.", e); - // 任务失败 - jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_FAIL, ""); - } - } + @Autowired + private MQUserEmailDao mqUserEmailDao; + + @Autowired + private JobMateMationService jobMateMationService; + + @Autowired + private SystemFoundationSettingsService systemFoundationSettingsService; + + @SuppressWarnings("unchecked") + @Override + public void call(String data) throws Exception { + Map map = JSONUtil.toBean(data, null); + String jobId = map.get("jobMateId").toString(); + try { + // 任务开始 + jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_PROCESSING, ""); + //获取服务器信息 + Map emailServer = systemFoundationSettingsService.getSystemFoundationSettings(); + + String storeType = emailServer.get("emailType").toString();//邮箱类型 + String host = emailServer.get("emailReceiptServer").toString();//邮箱收件服务器 + String username = map.get("userAddress").toString();//登录邮箱账号 + String password = map.get("userPassword").toString();//密码 + String basePath = tPath + "upload/emailenclosure/";//附件存储路径 + + Folder folder = ToolUtil.getFolderByServer(host, username, password, storeType, "Deleted Messages"); + if (!folder.exists()) {//如果文件夹不存在,则创建 + folder.create(Folder.HOLDS_MESSAGES); + } + folder.open(Folder.READ_ONLY); + Message[] message = folder.getMessages();//获取邮件信息 + ShowMail re = null; + //邮件集合 + List> beans = new ArrayList<>(); + Map bean = null; + //附件集合 + List> enclosureBeans = new ArrayList<>(); + //获取当前邮箱已有的邮件 + List> emailHasMail = mqUserEmailDao.queryDeleteEmailListByEmailFromAddress(map); + + //创建目录 + ToolUtil.createFolder(basePath); + + //遍历邮件数据 + for (int i = 0; i < message.length; i++) { + if (!message[i].getFolder().isOpen()) //判断是否open + message[i].getFolder().open(Folder.READ_ONLY); //如果close,就重新open + re = new ShowMail((MimeMessage) message[i]); + //如果该邮件在本地数据库中不存在并且messageId不为空 + //收件人或者抄送人或者暗送人是当前账号 + if (!ToolUtil.judgeInListByMessage(emailHasMail, re.getMessageId()) && !ToolUtil.isBlank(re.getMessageId()) + && (re.getMailAddress("to").indexOf(username) > -1 || re.getMailAddress("cc").indexOf(username) > -1 || re.getMailAddress("bcc").indexOf(username) > -1)) { + bean = EmailUtil.getEmailMationByUtil(re, message[i]); + String rowId = ToolUtil.getSurFaceId(); + re.setDateFormat(DateUtil.YYYY_MM_DD_HH_MM_SS); + bean.put("id", rowId);//id + bean.put("emailState", "2");//邮件状态 0.草稿 1.正常 2.已删除 + re.setAttachPath(basePath);//设置附件保存基础路径 + enclosureBeans.addAll(re.saveAttachMent((Part) message[i], rowId));//保存附件 + beans.add(bean); + } + if (beans.size() >= 20) {//每20条数据保存一次 + if (!beans.isEmpty()) { + mqUserEmailDao.insertEmailListToServer(beans); + } + if (!enclosureBeans.isEmpty()) { + mqUserEmailDao.insertEmailEnclosureListToServer(enclosureBeans); + } + beans.clear(); + enclosureBeans.clear(); + emailHasMail = mqUserEmailDao.queryDeleteEmailListByEmailFromAddress(map); + } + } + if (!beans.isEmpty()) { + mqUserEmailDao.insertEmailListToServer(beans); + } + if (!enclosureBeans.isEmpty()) { + mqUserEmailDao.insertEmailEnclosureListToServer(enclosureBeans); + } + // 任务完成 + jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_SUCCESS, ""); + } catch (Exception e) { + LOGGER.warn("get Trash acquisition failed, reason is {}.", e); + // 任务失败 + jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_FAIL, ""); + } + } } diff --git a/skyeye-promote/skyeye-schedule/src/main/java/com/skyeye/eve/service/ScheduleDayService.java b/skyeye-promote/skyeye-schedule/src/main/java/com/skyeye/eve/service/ScheduleDayService.java index e4535518..f1b4da23 100644 --- a/skyeye-promote/skyeye-schedule/src/main/java/com/skyeye/eve/service/ScheduleDayService.java +++ b/skyeye-promote/skyeye-schedule/src/main/java/com/skyeye/eve/service/ScheduleDayService.java @@ -1,6 +1,7 @@ /******************************************************************************* * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye ******************************************************************************/ + package com.skyeye.eve.service; import com.skyeye.common.object.InputObject; @@ -8,56 +9,56 @@ import com.skyeye.common.object.OutputObject; public interface ScheduleDayService { - public void insertScheduleDayMation(InputObject inputObject, OutputObject outputObject) throws Exception; + public void insertScheduleDayMation(InputObject inputObject, OutputObject outputObject) throws Exception; - public void queryScheduleDayMationByUserId(InputObject inputObject, OutputObject outputObject) throws Exception; + public void queryScheduleDayMationByUserId(InputObject inputObject, OutputObject outputObject) throws Exception; - public void queryScheduleDayMationTodayByUserId(InputObject inputObject, OutputObject outputObject) throws Exception; + public void queryScheduleDayMationTodayByUserId(InputObject inputObject, OutputObject outputObject) throws Exception; - public void editScheduleDayMationById(InputObject inputObject, OutputObject outputObject) throws Exception; - - public void queryScheduleDayMationById(InputObject inputObject, OutputObject outputObject) throws Exception; - - public void deleteScheduleDayMationById(InputObject inputObject, OutputObject outputObject) throws Exception; - - public void queryHolidayScheduleList(InputObject inputObject, OutputObject outputObject) throws Exception; - - public void downloadScheduleTemplate(InputObject inputObject, OutputObject outputObject) throws Exception; + public void editScheduleDayMationById(InputObject inputObject, OutputObject outputObject) throws Exception; - public void exploreScheduleTemplate(InputObject inputObject, OutputObject outputObject) throws Exception; - - public void deleteHolidayScheduleById(InputObject inputObject, OutputObject outputObject) throws Exception; + public void queryScheduleDayMationById(InputObject inputObject, OutputObject outputObject) throws Exception; - public void deleteHolidayScheduleByThisYear(InputObject inputObject, OutputObject outputObject) throws Exception; + public void deleteScheduleDayMationById(InputObject inputObject, OutputObject outputObject) throws Exception; - public void addHolidayScheduleRemind(InputObject inputObject, OutputObject outputObject) throws Exception; + public void queryHolidayScheduleList(InputObject inputObject, OutputObject outputObject) throws Exception; - public void deleteHolidayScheduleRemind(InputObject inputObject, OutputObject outputObject) throws Exception; + public void downloadScheduleTemplate(InputObject inputObject, OutputObject outputObject) throws Exception; - public void queryScheduleByIdToEdit(InputObject inputObject, OutputObject outputObject) throws Exception; + public void exploreScheduleTemplate(InputObject inputObject, OutputObject outputObject) throws Exception; - public void editScheduleById(InputObject inputObject, OutputObject outputObject) throws Exception; + public void deleteHolidayScheduleById(InputObject inputObject, OutputObject outputObject) throws Exception; - public void addSchedule(InputObject inputObject, OutputObject outputObject) throws Exception; - - public void queryHolidayScheduleListBySys(InputObject inputObject, OutputObject outputObject) throws Exception; + public void deleteHolidayScheduleByThisYear(InputObject inputObject, OutputObject outputObject) throws Exception; - public void queryMyScheduleList(InputObject inputObject, OutputObject outputObject) throws Exception; + public void addHolidayScheduleRemind(InputObject inputObject, OutputObject outputObject) throws Exception; - void insertScheduleMationByOtherModule(InputObject inputObject, OutputObject outputObject) throws Exception; + public void deleteHolidayScheduleRemind(InputObject inputObject, OutputObject outputObject) throws Exception; - /** - * 将其他模块同步到日程 - * 不启动日程定时任务,如需启动,在该接口外面自行启动 - * - * @param title 标题 - * @param content 日程内容 - * @param startTime 开始时间,格式为:yyyy-MM-dd HH:mm:ss - * @param endTime 结束时间,格式为:yyyy-MM-dd HH:mm:ss - * @param userId 执行人 - * @param objectId 关联id - * @param objectType object类型:1.任务计划id,2.项目任务id - * @throws Exception - */ - public String synchronizationSchedule(String title, String content, String startTime, String endTime, String userId, String objectId, int objectType) throws Exception; + public void queryScheduleByIdToEdit(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void editScheduleById(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void addSchedule(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void queryHolidayScheduleListBySys(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void queryMyScheduleList(InputObject inputObject, OutputObject outputObject) throws Exception; + + void insertScheduleMationByOtherModule(InputObject inputObject, OutputObject outputObject) throws Exception; + + /** + * 将其他模块同步到日程 + * 不启动日程定时任务,如需启动,在该接口外面自行启动 + * + * @param title 标题 + * @param content 日程内容 + * @param startTime 开始时间,格式为:yyyy-MM-dd HH:mm:ss + * @param endTime 结束时间,格式为:yyyy-MM-dd HH:mm:ss + * @param userId 执行人 + * @param objectId 关联id + * @param objectType object类型:1.任务计划id,2.项目任务id + * @throws Exception + */ + public String synchronizationSchedule(String title, String content, String startTime, String endTime, String userId, String objectId, int objectType) throws Exception; } diff --git a/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java b/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java index 8dfa55ce..9eea3394 100644 --- a/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java +++ b/skyeye-promote/skyeye-web/src/main/java/com/skyeye/sys/quartz/HotForumQuartz.java @@ -149,7 +149,7 @@ public class HotForumQuartz { */ public static ArrayList pastDay(String time) throws ParseException { ArrayList pastDaysList = new ArrayList<>(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.YYYY_MM_DD); Date date = sdf.parse(time); for (int i = 6; i >= 0; i--) { Calendar calendar = Calendar.getInstance();