mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-01-30 19:17:54 +08:00
【其他】日期调整为工具类
This commit is contained in:
parent
ebb5aad829
commit
8963b7f57d
3 changed files with 134 additions and 133 deletions
|
@ -6,6 +6,7 @@ package com.skyeye.mq.job.impl;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.skyeye.common.constans.MqConstants;
|
import com.skyeye.common.constans.MqConstants;
|
||||||
|
import com.skyeye.common.util.DateUtil;
|
||||||
import com.skyeye.common.util.EmailUtil;
|
import com.skyeye.common.util.EmailUtil;
|
||||||
import com.skyeye.common.util.ShowMail;
|
import com.skyeye.common.util.ShowMail;
|
||||||
import com.skyeye.common.util.ToolUtil;
|
import com.skyeye.common.util.ToolUtil;
|
||||||
|
@ -28,109 +29,108 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @ClassName: MailAccessDeleteServiceImpl
|
* @ClassName: MailAccessDeleteServiceImpl
|
||||||
* @Description: 已删除邮件获取
|
* @Description: 已删除邮件获取
|
||||||
* @author: skyeye云系列--卫志强
|
* @author: skyeye云系列--卫志强
|
||||||
* @date: 2021/7/4 21:58
|
* @date: 2021/7/4 21:58
|
||||||
*
|
|
||||||
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
|
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
|
||||||
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
|
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
|
||||||
*/
|
*/
|
||||||
@Service("mailAccessDeleteService")
|
@Service("mailAccessDeleteService")
|
||||||
public class MailAccessDeleteServiceImpl implements JobMateService{
|
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;
|
|
||||||
|
|
||||||
@Autowired
|
private static final Logger LOGGER = LoggerFactory.getLogger(MailAccessDeleteServiceImpl.class);
|
||||||
private SystemFoundationSettingsService systemFoundationSettingsService;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@Value("${IMAGES_PATH}")
|
||||||
@Override
|
private String tPath;
|
||||||
public void call(String data) throws Exception {
|
|
||||||
Map<String, Object> map = JSONUtil.toBean(data, null);
|
|
||||||
String jobId = map.get("jobMateId").toString();
|
|
||||||
try {
|
|
||||||
// 任务开始
|
|
||||||
jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_PROCESSING, "");
|
|
||||||
try{
|
|
||||||
//获取服务器信息
|
|
||||||
Map<String, Object> 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");
|
@Autowired
|
||||||
if (!folder.exists()) {//如果文件夹不存在,则创建
|
private MQUserEmailDao mqUserEmailDao;
|
||||||
folder.create(Folder.HOLDS_MESSAGES);
|
|
||||||
}
|
@Autowired
|
||||||
folder.open(Folder.READ_ONLY);
|
private JobMateMationService jobMateMationService;
|
||||||
Message[] message = folder.getMessages();//获取邮件信息
|
|
||||||
ShowMail re = null;
|
@Autowired
|
||||||
//邮件集合
|
private SystemFoundationSettingsService systemFoundationSettingsService;
|
||||||
List<Map<String, Object>> beans = new ArrayList<>();
|
|
||||||
Map<String, Object> bean = null;
|
@SuppressWarnings("unchecked")
|
||||||
//附件集合
|
@Override
|
||||||
List<Map<String, Object>> enclosureBeans = new ArrayList<>();
|
public void call(String data) throws Exception {
|
||||||
//获取当前邮箱已有的邮件
|
Map<String, Object> map = JSONUtil.toBean(data, null);
|
||||||
List<Map<String, Object>> emailHasMail = mqUserEmailDao.queryDeleteEmailListByEmailFromAddress(map);
|
String jobId = map.get("jobMateId").toString();
|
||||||
|
try {
|
||||||
//创建目录
|
// 任务开始
|
||||||
ToolUtil.createFolder(basePath);
|
jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_PROCESSING, "");
|
||||||
|
//获取服务器信息
|
||||||
//遍历邮件数据
|
Map<String, Object> emailServer = systemFoundationSettingsService.getSystemFoundationSettings();
|
||||||
for (int i = 0; i < message.length; i++) {
|
|
||||||
if(!message[i].getFolder().isOpen()) //判断是否open
|
String storeType = emailServer.get("emailType").toString();//邮箱类型
|
||||||
message[i].getFolder().open(Folder.READ_ONLY); //如果close,就重新open
|
String host = emailServer.get("emailReceiptServer").toString();//邮箱收件服务器
|
||||||
re = new ShowMail((MimeMessage) message[i]);
|
String username = map.get("userAddress").toString();//登录邮箱账号
|
||||||
//如果该邮件在本地数据库中不存在并且messageId不为空
|
String password = map.get("userPassword").toString();//密码
|
||||||
//收件人或者抄送人或者暗送人是当前账号
|
String basePath = tPath + "upload/emailenclosure/";//附件存储路径
|
||||||
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)){
|
Folder folder = ToolUtil.getFolderByServer(host, username, password, storeType, "Deleted Messages");
|
||||||
bean = EmailUtil.getEmailMationByUtil(re, message[i]);
|
if (!folder.exists()) {//如果文件夹不存在,则创建
|
||||||
String rowId = ToolUtil.getSurFaceId();
|
folder.create(Folder.HOLDS_MESSAGES);
|
||||||
re.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
}
|
||||||
bean.put("id", rowId);//id
|
folder.open(Folder.READ_ONLY);
|
||||||
bean.put("emailState", "2");//邮件状态 0.草稿 1.正常 2.已删除
|
Message[] message = folder.getMessages();//获取邮件信息
|
||||||
re.setAttachPath(basePath);//设置附件保存基础路径
|
ShowMail re = null;
|
||||||
enclosureBeans.addAll(re.saveAttachMent((Part) message[i], rowId));//保存附件
|
//邮件集合
|
||||||
beans.add(bean);
|
List<Map<String, Object>> beans = new ArrayList<>();
|
||||||
}
|
Map<String, Object> bean = null;
|
||||||
if(beans.size() >= 20){//每20条数据保存一次
|
//附件集合
|
||||||
if(!beans.isEmpty())
|
List<Map<String, Object>> enclosureBeans = new ArrayList<>();
|
||||||
mqUserEmailDao.insertEmailListToServer(beans);
|
//获取当前邮箱已有的邮件
|
||||||
if(!enclosureBeans.isEmpty())
|
List<Map<String, Object>> emailHasMail = mqUserEmailDao.queryDeleteEmailListByEmailFromAddress(map);
|
||||||
mqUserEmailDao.insertEmailEnclosureListToServer(enclosureBeans);
|
|
||||||
beans.clear();
|
//创建目录
|
||||||
enclosureBeans.clear();
|
ToolUtil.createFolder(basePath);
|
||||||
emailHasMail = mqUserEmailDao.queryDeleteEmailListByEmailFromAddress(map);
|
|
||||||
}
|
//遍历邮件数据
|
||||||
}
|
for (int i = 0; i < message.length; i++) {
|
||||||
if(!beans.isEmpty())
|
if (!message[i].getFolder().isOpen()) //判断是否open
|
||||||
mqUserEmailDao.insertEmailListToServer(beans);
|
message[i].getFolder().open(Folder.READ_ONLY); //如果close,就重新open
|
||||||
if(!enclosureBeans.isEmpty())
|
re = new ShowMail((MimeMessage) message[i]);
|
||||||
mqUserEmailDao.insertEmailEnclosureListToServer(enclosureBeans);
|
//如果该邮件在本地数据库中不存在并且messageId不为空
|
||||||
}finally{
|
//收件人或者抄送人或者暗送人是当前账号
|
||||||
}
|
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)) {
|
||||||
jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_SUCCESS, "");
|
bean = EmailUtil.getEmailMationByUtil(re, message[i]);
|
||||||
} catch (Exception e) {
|
String rowId = ToolUtil.getSurFaceId();
|
||||||
LOGGER.warn("get Trash acquisition failed, reason is {}.", e);
|
re.setDateFormat(DateUtil.YYYY_MM_DD_HH_MM_SS);
|
||||||
// 任务失败
|
bean.put("id", rowId);//id
|
||||||
jobMateMationService.comMQJobMation(jobId, MqConstants.JOB_TYPE_IS_FAIL, "");
|
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, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
|
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
package com.skyeye.eve.service;
|
package com.skyeye.eve.service;
|
||||||
|
|
||||||
import com.skyeye.common.object.InputObject;
|
import com.skyeye.common.object.InputObject;
|
||||||
|
@ -8,56 +9,56 @@ import com.skyeye.common.object.OutputObject;
|
||||||
|
|
||||||
public interface ScheduleDayService {
|
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 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 exploreScheduleTemplate(InputObject inputObject, OutputObject outputObject) throws Exception;
|
public void queryScheduleDayMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
|
|
||||||
public void deleteHolidayScheduleById(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 deleteHolidayScheduleByThisYear(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
|
|
||||||
public void queryHolidayScheduleListBySys(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;
|
||||||
|
|
||||||
/**
|
public void queryScheduleByIdToEdit(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
* 将其他模块同步到日程
|
|
||||||
* 不启动日程定时任务,如需启动,在该接口外面自行启动
|
public void editScheduleById(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
*
|
|
||||||
* @param title 标题
|
public void addSchedule(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
* @param content 日程内容
|
|
||||||
* @param startTime 开始时间,格式为:yyyy-MM-dd HH:mm:ss
|
public void queryHolidayScheduleListBySys(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
* @param endTime 结束时间,格式为:yyyy-MM-dd HH:mm:ss
|
|
||||||
* @param userId 执行人
|
public void queryMyScheduleList(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
* @param objectId 关联id
|
|
||||||
* @param objectType object类型:1.任务计划id,2.项目任务id
|
void insertScheduleMationByOtherModule(InputObject inputObject, OutputObject outputObject) throws Exception;
|
||||||
* @throws Exception
|
|
||||||
*/
|
/**
|
||||||
public String synchronizationSchedule(String title, String content, String startTime, String endTime, String userId, String objectId, int objectType) 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class HotForumQuartz {
|
||||||
*/
|
*/
|
||||||
public static ArrayList<String> pastDay(String time) throws ParseException {
|
public static ArrayList<String> pastDay(String time) throws ParseException {
|
||||||
ArrayList<String> pastDaysList = new ArrayList<>();
|
ArrayList<String> pastDaysList = new ArrayList<>();
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.YYYY_MM_DD);
|
||||||
Date date = sdf.parse(time);
|
Date date = sdf.parse(time);
|
||||||
for (int i = 6; i >= 0; i--) {
|
for (int i = 6; i >= 0; i--) {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
Loading…
Reference in a new issue