|
|
@@ -3,20 +3,22 @@ package cn.cslg.pas.service.quartzService;
|
|
|
import cn.cslg.pas.common.core.base.Cycle;
|
|
|
import cn.cslg.pas.common.model.report.QueryMatchCasePersonDTO;
|
|
|
import cn.cslg.pas.common.model.report.QueryMatchCasePersonVO;
|
|
|
+import cn.cslg.pas.common.utils.DateUtils;
|
|
|
import cn.cslg.pas.common.utils.DateUtils2;
|
|
|
+import cn.cslg.pas.common.utils.StringUtils;
|
|
|
import cn.cslg.pas.common.utils.utilVO.CheckDateConditionVO;
|
|
|
-import cn.cslg.pas.domain.business.ImportTaskCondition;
|
|
|
-import cn.cslg.pas.domain.business.PatentProject;
|
|
|
-import cn.cslg.pas.domain.business.ReportAffair;
|
|
|
-import cn.cslg.pas.domain.business.ReportProject;
|
|
|
+import cn.cslg.pas.domain.business.*;
|
|
|
+import cn.cslg.pas.domain.project.MailSendRecord;
|
|
|
import cn.cslg.pas.domain.report.MatchCasePerson;
|
|
|
import cn.cslg.pas.mapper.ReportAffairMapper;
|
|
|
import cn.cslg.pas.service.MailSendService;
|
|
|
-import cn.cslg.pas.service.business.ImportTaskConditionService;
|
|
|
-import cn.cslg.pas.service.business.ImportTaskService;
|
|
|
-import cn.cslg.pas.service.business.PatentProjectService;
|
|
|
-import cn.cslg.pas.service.business.ReportProjectService;
|
|
|
+import cn.cslg.pas.service.ReportAffairCasePhaseService;
|
|
|
+import cn.cslg.pas.service.business.*;
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
+import cn.cslg.pas.service.project.MailSendRecordService;
|
|
|
import cn.cslg.pas.service.report.MatchCasePersonService;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -28,7 +30,9 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -38,11 +42,14 @@ import java.util.stream.Collectors;
|
|
|
public class SysReportNoticeJobService extends QuartzJobBean {
|
|
|
private final ImportTaskConditionService importTaskConditionService;
|
|
|
private final ImportTaskService importTaskService;
|
|
|
- private final PatentProjectService patentProjectService;
|
|
|
+ private final ProjectService projectService;
|
|
|
private final MailSendService mailSendService;
|
|
|
private final ReportProjectService reportProjectService;
|
|
|
private final ReportAffairMapper reportAffairMapper;
|
|
|
private final MatchCasePersonService matchCasePersonService;
|
|
|
+ private final ReportAffairCasePhaseService reportAffairCasePhaseService;
|
|
|
+ private final MailSendRecordService mailSendRecordService;
|
|
|
+ private final PermissionService permissionService;
|
|
|
|
|
|
@Override
|
|
|
public void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
|
|
@@ -64,31 +71,98 @@ public class SysReportNoticeJobService extends QuartzJobBean {
|
|
|
page += 1;
|
|
|
}
|
|
|
while (current <= page) {
|
|
|
- try {
|
|
|
- IPage<ReportProject> reportProjectIPage1 = reportProjectService.page(new Page<>(1, 10));
|
|
|
- List<ReportProject> reportProjects = reportProjectIPage1.getRecords();
|
|
|
- for (ReportProject reportProject : reportProjects) {
|
|
|
-
|
|
|
+ IPage<ReportProject> reportProjectIPage1 = reportProjectService.page(new Page<>(1, 10));
|
|
|
+ List<ReportProject> reportProjects = reportProjectIPage1.getRecords();
|
|
|
+ for (ReportProject reportProject : reportProjects) {
|
|
|
+ try {
|
|
|
Integer projectId = reportProject.getProjectId();
|
|
|
+ Project project = projectService.getById(projectId);
|
|
|
+ String createId = project.getCreateId();
|
|
|
+
|
|
|
List<ReportAffair> reportAffairs = reportAffairMapper.queryShouldNoticeAffair(projectId);
|
|
|
if (reportAffairs != null && reportAffairs.size() > 0) {
|
|
|
ReportAffair reportAffair = reportAffairs.get(0);
|
|
|
- QueryMatchCasePersonDTO queryMatchCasePersonDTO = new QueryMatchCasePersonDTO();
|
|
|
- queryMatchCasePersonDTO.setReportId(projectId);
|
|
|
- List<QueryMatchCasePersonVO> queryMatchCasePersonVOS = matchCasePersonService.getReportMatchCasePerson(queryMatchCasePersonDTO);
|
|
|
+ Integer id = reportAffair.getId();
|
|
|
+ //检查是否有发邮件的功能
|
|
|
+ String json = permissionService.getPermissionListNoRoot("e424f3cc4f8138f0f68bef092b92212f;6a8d3f4d1d5f11eda41c00163e2f0200", id);
|
|
|
+ List<String> functions = JSONArray.parseArray(json, String.class);
|
|
|
+ if (!functions.contains("")) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //查看是否发过通知
|
|
|
+ MailSendRecord mailSendRecord = mailSendRecordService.queryMailSendRecord(2, id);
|
|
|
+ if (mailSendRecord != null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Date noticeDate = this.calculateDate(reportAffair);
|
|
|
+ if (noticeDate == null || noticeDate.compareTo(new Date()) > 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //发送邮件
|
|
|
+ this.sendEmail(project, reportAffair);
|
|
|
+
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- current += 1;
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
+ current += 1;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void sendEmail(Integer project,ReportAffair reportAffair, List<QueryMatchCasePersonVO> queryMatchCasePersonVOS){
|
|
|
-
|
|
|
+ public void sendEmail(Project project, ReportAffair reportAffair) {
|
|
|
+ Integer projectId = project.getId();
|
|
|
+ QueryMatchCasePersonDTO queryMatchCasePersonDTO = new QueryMatchCasePersonDTO();
|
|
|
+ queryMatchCasePersonDTO.setReportId(projectId);
|
|
|
+ List<QueryMatchCasePersonVO> queryMatchCasePersonVOS = matchCasePersonService.getReportMatchCasePerson(queryMatchCasePersonDTO);
|
|
|
+ MailSendRecord mailSendRecord = new MailSendRecord();
|
|
|
+// String personStr = JSONObject.toJSONString(commonPeople);
|
|
|
+// String contentStr = JSONObject.toJSONString(map);
|
|
|
+// mailSendRecord.setSendTo(personStr);
|
|
|
+// mailSendRecord.setProjectId(projectId);
|
|
|
+// mailSendRecord.setCreateId(project.getCreateId());
|
|
|
+// mailSendRecord.setSendWay(0);
|
|
|
+// mailSendRecord.setSendContent(contentStr);
|
|
|
+// mailSendRecord.setType(2);
|
|
|
+// mailSendRecord.setFromId(reportAffair.getId());
|
|
|
+// mailSendRecord.insert();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public Date calculateDate(ReportAffair reportAffair) {
|
|
|
+ Date noticeDate = null;
|
|
|
+ Integer assoCasePhaseId = reportAffair.getAssoCasePhaseId();
|
|
|
+ Date occurredTime = reportAffair.getOccurredTime();
|
|
|
+ //查看该节点是否到发通知的时候了
|
|
|
+ ReportAffairCasePhase reportAffairCasePhase = reportAffairCasePhaseService.getById(assoCasePhaseId);
|
|
|
+ String noticeDateStr = reportAffairCasePhase.getNoticeDate();
|
|
|
+ if (noticeDateStr != null && !noticeDateStr.equals("")) {
|
|
|
+ List<String> strings = StringUtils.changeStringToString(noticeDateStr, "/");
|
|
|
+ if (strings.size() == 2) {
|
|
|
+ String noticeTime = strings.get(0).trim();
|
|
|
+ String timeUnit = strings.get(1).trim();
|
|
|
+ Integer timeLong = Integer.parseInt(noticeTime);
|
|
|
+
|
|
|
+ switch (timeUnit) {
|
|
|
+ case "day":
|
|
|
+ noticeDate = DateUtils.getPlusDayDate(occurredTime, timeLong);
|
|
|
+ break;
|
|
|
+ case "week":
|
|
|
+ noticeDate = DateUtils.getPlusDayDate(occurredTime, timeLong * 7);
|
|
|
+ break;
|
|
|
+ case "month":
|
|
|
+ noticeDate = DateUtils.getPlusMonthDate(occurredTime, timeLong * 7);
|
|
|
+ break;
|
|
|
+ case "year":
|
|
|
+ noticeDate = DateUtils.getPlusMonthDate(occurredTime, timeLong * 12);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return noticeDate;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|